mirror of
https://github.com/yunluo/gdk.git
synced 2024-05-21 15:46:40 +02:00
1,优化了后台选项,去除了debug出来的报错
2,增加了微信,支付宝H5支付 3,优化了小工具缓存功能 4,去除暂时无用的文件 5,优化了metabox的代码 6,取消了设置友情链接分类ID功能,取代为自动获取 7,断代码模块去除多余无用代码 8,优化了导航页面的很多代码
This commit is contained in:
parent
aeda2bed05
commit
2f66c5ddfe
|
@ -6,6 +6,7 @@ class GDK_Payjs
|
|||
private $key;
|
||||
private $api_url_native;
|
||||
private $api_url_cashier;
|
||||
private $api_url_mweb;
|
||||
private $api_url_check;
|
||||
|
||||
public function __construct($config = null)
|
||||
|
@ -14,10 +15,11 @@ class GDK_Payjs
|
|||
|
||||
$this->mchid = $config['mchid'];
|
||||
$this->key = $config['key'];
|
||||
$api_url = isset($config['api_url']) ? $config['api_url'] : 'https://payjs.cn/api/';
|
||||
$api_url = $config['api_url'] ?? 'https://payjs.cn/api/';
|
||||
|
||||
$this->api_url_native = $api_url . 'native';
|
||||
$this->api_url_cashier = $api_url . 'cashier';
|
||||
$this->api_url_mweb = $api_url . 'mweb';
|
||||
$this->api_url_close = $api_url . 'close';
|
||||
$this->api_url_check = $api_url . 'check';
|
||||
}
|
||||
|
@ -28,7 +30,12 @@ class GDK_Payjs
|
|||
$this->url = $this->api_url_native;
|
||||
return $this->post($data);
|
||||
}
|
||||
|
||||
// MWEB(H5) 支付
|
||||
public function mweb(array $data)
|
||||
{
|
||||
$this->url = $this->api_url_mweb;
|
||||
return $this->post($data);
|
||||
}
|
||||
// 收银台模式
|
||||
public function cashier(array $data)
|
||||
{
|
||||
|
@ -95,4 +102,3 @@ class GDK_Payjs
|
|||
}
|
||||
|
||||
}
|
||||
?>
|
45
class/ai.php
45
class/ai.php
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
include 'ai/AipNlp.php'; //文本分析接口
|
||||
//include 'ai/AipContentCensor.php'; //评论审核接口
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function gdk_newsSummary($post_ID){
|
||||
|
||||
// 你的 APPID AK SK
|
||||
$APP_ID = '22837593';
|
||||
$API_KEY = 'hYYE9TWp0T5Um5b0p1FUALlw';
|
||||
$SECRET_KEY = 'otXMPD6TGGWKjKnfm9aB9USErsQrH2HD';
|
||||
|
||||
$Nlpclient = new AipNlp($APP_ID, $API_KEY, $SECRET_KEY);
|
||||
$post = get_post( $post_ID );
|
||||
$content = '从官网上面看统信操作系统,目前分为三个版本,第一种是统信操作系统专业版,然后是统信操作系统个人版,然后是统信操作系统社区版,也就是现在的深度系统,这里面要注意一点,由于深度系统本身已经非常有知名度,而且在海外也有一定的知名度,所以统信操作系统社区并没有改名,仍然使用深度系统名字。
|
||||
在三个版本区别当中,很明显专业版是提供给党政军等机构使用,个人版可以给个人使用的,然后社区板和个人版差不多,但是权限要比个人版要更多也更自由一点,其中专业版是需要付费的,然后个人版是有增值服务的,然后社区版是完全免费的。
|
||||
这里面有一点要说明一下个人版是没有root权限的,如果需要root权限,还要开通开发者权限,开发者权限需要注册的,然后社区版是默认自带root权限的。没有root的权限,对于很多linux系统爱好者来说是不太友好的,但是对于个人用户来说,这个却是非常重要的,因为自带root权限对一些对电脑不太熟悉的人来说实在是太危险了,很容易把电脑或者系统搞坏的。';
|
||||
|
||||
|
||||
$maxSummaryLen = 300;
|
||||
|
||||
// 带参数调用新闻摘要接口
|
||||
$result = $Nlpclient->newsSummary($content, $maxSummaryLen);
|
||||
|
||||
var_dump($result);
|
||||
|
||||
|
||||
$my_post = array(
|
||||
'ID' => $post_ID,
|
||||
'post_excerpt' => $result //摘要信息
|
||||
|
||||
);
|
||||
|
||||
|
||||
//入库
|
||||
|
||||
//wp_insert_post( $my_post );
|
||||
|
||||
}
|
||||
add_action('publish_post', 'gdk_newsSummary', 0);
|
||||
add_action('update_post', 'gdk_newsSummary', 0);
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* Http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
require_once 'AipImageCensor.php';
|
||||
|
||||
/**
|
||||
* 内容审核
|
||||
*/
|
||||
class AipContentCensor extends AipImageCensor{
|
||||
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* Http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
include_once 'lib/AipBase.php';
|
||||
class AipNlp extends AipBase {
|
||||
/**
|
||||
* 评论观点抽取 comment_tag api url
|
||||
* @var string
|
||||
*/
|
||||
private $commentTagUrl = 'https://aip.baidubce.com/rpc/2.0/nlp/v2/comment_tag';
|
||||
|
||||
/**
|
||||
* 情感倾向分析 sentiment_classify api url
|
||||
* @var string
|
||||
*/
|
||||
private $sentimentClassifyUrl = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/sentiment_classify';
|
||||
|
||||
/**
|
||||
* 文章标签 keyword api url
|
||||
* @var string
|
||||
*/
|
||||
private $keywordUrl = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/keyword';
|
||||
|
||||
/**
|
||||
* 文章分类 topic api url
|
||||
* @var string
|
||||
*/
|
||||
private $topicUrl = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/topic';
|
||||
|
||||
/**
|
||||
* 文本纠错 ecnet api url
|
||||
* @var string
|
||||
*/
|
||||
private $ecnetUrl = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/ecnet';
|
||||
|
||||
/**
|
||||
* 新闻摘要接口 news_summary api url
|
||||
* @var string
|
||||
*/
|
||||
private $newsSummaryUrl = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/news_summary';
|
||||
|
||||
|
||||
/**
|
||||
* 格式化结果
|
||||
* @param $content string
|
||||
* @return mixed
|
||||
*/
|
||||
protected function proccessResult($content){
|
||||
return json_decode(mb_convert_encoding($content, 'UTF8', 'GBK'), true, 512, JSON_BIGINT_AS_STRING);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 评论观点抽取接口
|
||||
*
|
||||
* @param string $text - 评论内容(GBK编码),最大10240字节
|
||||
* @param array $options - 可选参数对象,key: value都为string类型
|
||||
* @description options列表:
|
||||
* type 评论行业类型,默认为4(餐饮美食)
|
||||
* @return array
|
||||
*/
|
||||
public function commentTag($text, $options=array()){
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['text'] = $text;
|
||||
|
||||
$data = array_merge($data, $options);
|
||||
$data = mb_convert_encoding(json_encode($data), 'GBK', 'UTF8');
|
||||
|
||||
return $this->request($this->commentTagUrl, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 情感倾向分析接口
|
||||
*
|
||||
* @param string $text - 文本内容(GBK编码),最大102400字节
|
||||
* @param array $options - 可选参数对象,key: value都为string类型
|
||||
* @description options列表:
|
||||
* @return array
|
||||
*/
|
||||
public function sentimentClassify($text, $options=array()){
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['text'] = $text;
|
||||
|
||||
$data = array_merge($data, $options);
|
||||
$data = mb_convert_encoding(json_encode($data), 'GBK', 'UTF8');
|
||||
|
||||
return $this->request($this->sentimentClassifyUrl, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章标签接口
|
||||
*
|
||||
* @param string $title - 篇章的标题,最大80字节
|
||||
* @param string $content - 篇章的正文,最大65535字节
|
||||
* @param array $options - 可选参数对象,key: value都为string类型
|
||||
* @description options列表:
|
||||
* @return array
|
||||
*/
|
||||
public function keyword($title, $content, $options=array()){
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['title'] = $title;
|
||||
$data['content'] = $content;
|
||||
|
||||
$data = array_merge($data, $options);
|
||||
$data = mb_convert_encoding(json_encode($data), 'GBK', 'UTF8');
|
||||
|
||||
return $this->request($this->keywordUrl, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章分类接口
|
||||
*
|
||||
* @param string $title - 篇章的标题,最大80字节
|
||||
* @param string $content - 篇章的正文,最大65535字节
|
||||
* @param array $options - 可选参数对象,key: value都为string类型
|
||||
* @description options列表:
|
||||
* @return array
|
||||
*/
|
||||
public function topic($title, $content, $options=array()){
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['title'] = $title;
|
||||
$data['content'] = $content;
|
||||
|
||||
$data = array_merge($data, $options);
|
||||
$data = mb_convert_encoding(json_encode($data), 'GBK', 'UTF8');
|
||||
|
||||
return $this->request($this->topicUrl, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本纠错接口
|
||||
*
|
||||
* @param string $text - 待纠错文本,输入限制511字节
|
||||
* @param array $options - 可选参数对象,key: value都为string类型
|
||||
* @description options列表:
|
||||
* @return array
|
||||
*/
|
||||
public function ecnet($text, $options=array()){
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['text'] = $text;
|
||||
|
||||
$data = array_merge($data, $options);
|
||||
$data = mb_convert_encoding(json_encode($data), 'GBK', 'UTF8');
|
||||
|
||||
return $this->request($this->ecnetUrl, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新闻摘要接口接口
|
||||
*
|
||||
* @param string $content - 字符串(限3000字符数以内)字符串仅支持GBK编码,长度需小于3000字符数(即6000字节),请输入前确认字符数没有超限,若字符数超长会返回错误。正文中如果包含段落信息,请使用"\n"分隔,段落信息算法中有重要的作用,请尽量保留
|
||||
* @param integer $maxSummaryLen - 此数值将作为摘要结果的最大长度。例如:原文长度1000字,本参数设置为150,则摘要结果的最大长度是150字;推荐最优区间:200-500字
|
||||
* @param array $options - 可选参数对象,key: value都为string类型
|
||||
* @description options列表:
|
||||
* title 字符串(限200字符数)字符串仅支持GBK编码,长度需小于200字符数(即400字节),请输入前确认字符数没有超限,若字符数超长会返回错误。标题在算法中具有重要的作用,若文章确无标题,输入参数的“标题”字段为空即可
|
||||
* @return array
|
||||
*/
|
||||
public function newsSummary($content, $maxSummaryLen, $options=array()){
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['content'] = $content;
|
||||
$data['max_summary_len'] = $maxSummaryLen;
|
||||
|
||||
$data = array_merge($data, $options);
|
||||
$data = mb_convert_encoding(json_encode($data), 'GBK', 'UTF8');
|
||||
|
||||
return $this->request($this->newsSummaryUrl, $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,345 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* Http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* BCE Util
|
||||
*/
|
||||
class AipHttpUtil
|
||||
{
|
||||
// 根据RFC 3986,除了:
|
||||
// 1.大小写英文字符
|
||||
// 2.阿拉伯数字
|
||||
// 3.点'.'、波浪线'~'、减号'-'以及下划线'_'
|
||||
// 以外都要编码
|
||||
public static $PERCENT_ENCODED_STRINGS;
|
||||
|
||||
//填充编码数组
|
||||
public static function __init()
|
||||
{
|
||||
AipHttpUtil::$PERCENT_ENCODED_STRINGS = array();
|
||||
for ($i = 0; $i < 256; ++$i) {
|
||||
AipHttpUtil::$PERCENT_ENCODED_STRINGS[$i] = sprintf("%%%02X", $i);
|
||||
}
|
||||
|
||||
//a-z不编码
|
||||
foreach (range('a', 'z') as $ch) {
|
||||
AipHttpUtil::$PERCENT_ENCODED_STRINGS[ord($ch)] = $ch;
|
||||
}
|
||||
|
||||
//A-Z不编码
|
||||
foreach (range('A', 'Z') as $ch) {
|
||||
AipHttpUtil::$PERCENT_ENCODED_STRINGS[ord($ch)] = $ch;
|
||||
}
|
||||
|
||||
//0-9不编码
|
||||
foreach (range('0', '9') as $ch) {
|
||||
AipHttpUtil::$PERCENT_ENCODED_STRINGS[ord($ch)] = $ch;
|
||||
}
|
||||
|
||||
//以下4个字符不编码
|
||||
AipHttpUtil::$PERCENT_ENCODED_STRINGS[ord('-')] = '-';
|
||||
AipHttpUtil::$PERCENT_ENCODED_STRINGS[ord('.')] = '.';
|
||||
AipHttpUtil::$PERCENT_ENCODED_STRINGS[ord('_')] = '_';
|
||||
AipHttpUtil::$PERCENT_ENCODED_STRINGS[ord('~')] = '~';
|
||||
}
|
||||
|
||||
/**
|
||||
* 在uri编码中不能对'/'编码
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public static function urlEncodeExceptSlash($path)
|
||||
{
|
||||
return str_replace("%2F", "/", AipHttpUtil::urlEncode($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用编码数组编码
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public static function urlEncode($value)
|
||||
{
|
||||
$result = '';
|
||||
for ($i = 0; $i < strlen($value); ++$i) {
|
||||
$result .= AipHttpUtil::$PERCENT_ENCODED_STRINGS[ord($value[$i])];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成标准化QueryString
|
||||
* @param array $parameters
|
||||
* @return array
|
||||
*/
|
||||
public static function getCanonicalQueryString(array $parameters)
|
||||
{
|
||||
//没有参数,直接返回空串
|
||||
if (count($parameters) == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$parameterStrings = array();
|
||||
foreach ($parameters as $k => $v) {
|
||||
//跳过Authorization字段
|
||||
if (strcasecmp('Authorization', $k) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($k)) {
|
||||
throw new \InvalidArgumentException(
|
||||
"parameter key should not be null"
|
||||
);
|
||||
}
|
||||
if (isset($v)) {
|
||||
//对于有值的,编码后放在=号两边
|
||||
$parameterStrings[] = AipHttpUtil::urlEncode($k)
|
||||
. '=' . AipHttpUtil::urlEncode((string) $v);
|
||||
} else {
|
||||
//对于没有值的,只将key编码后放在=号的左边,右边留空
|
||||
$parameterStrings[] = AipHttpUtil::urlEncode($k) . '=';
|
||||
}
|
||||
}
|
||||
//按照字典序排序
|
||||
sort($parameterStrings);
|
||||
|
||||
//使用'&'符号连接它们
|
||||
return implode('&', $parameterStrings);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成标准化uri
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public static function getCanonicalURIPath($path)
|
||||
{
|
||||
//空路径设置为'/'
|
||||
if (empty($path)) {
|
||||
return '/';
|
||||
} else {
|
||||
//所有的uri必须以'/'开头
|
||||
if ($path[0] == '/') {
|
||||
return AipHttpUtil::urlEncodeExceptSlash($path);
|
||||
} else {
|
||||
return '/' . AipHttpUtil::urlEncodeExceptSlash($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成标准化http请求头串
|
||||
* @param array $headers
|
||||
* @return array
|
||||
*/
|
||||
public static function getCanonicalHeaders($headers)
|
||||
{
|
||||
//如果没有headers,则返回空串
|
||||
if (count($headers) == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$headerStrings = array();
|
||||
foreach ($headers as $k => $v) {
|
||||
//跳过key为null的
|
||||
if ($k === null) {
|
||||
continue;
|
||||
}
|
||||
//如果value为null,则赋值为空串
|
||||
if ($v === null) {
|
||||
$v = '';
|
||||
}
|
||||
//trim后再encode,之后使用':'号连接起来
|
||||
$headerStrings[] = AipHttpUtil::urlEncode(strtolower(trim($k))) . ':' . AipHttpUtil::urlEncode(trim($v));
|
||||
}
|
||||
//字典序排序
|
||||
sort($headerStrings);
|
||||
|
||||
//用'\n'把它们连接起来
|
||||
return implode("\n", $headerStrings);
|
||||
}
|
||||
}
|
||||
AipHttpUtil::__init();
|
||||
|
||||
|
||||
class AipSignOption
|
||||
{
|
||||
const EXPIRATION_IN_SECONDS = 'expirationInSeconds';
|
||||
|
||||
const HEADERS_TO_SIGN = 'headersToSign';
|
||||
|
||||
const TIMESTAMP = 'timestamp';
|
||||
|
||||
const DEFAULT_EXPIRATION_IN_SECONDS = 1800;
|
||||
|
||||
const MIN_EXPIRATION_IN_SECONDS = 300;
|
||||
|
||||
const MAX_EXPIRATION_IN_SECONDS = 129600;
|
||||
}
|
||||
|
||||
|
||||
class AipSampleSigner
|
||||
{
|
||||
|
||||
const BCE_AUTH_VERSION = "bce-auth-v1";
|
||||
const BCE_PREFIX = 'x-bce-';
|
||||
|
||||
//不指定headersToSign情况下,默认签名http头,包括:
|
||||
// 1.host
|
||||
// 2.content-length
|
||||
// 3.content-type
|
||||
// 4.content-md5
|
||||
public static $defaultHeadersToSign;
|
||||
|
||||
public static function __init()
|
||||
{
|
||||
AipSampleSigner::$defaultHeadersToSign = array(
|
||||
"host",
|
||||
"content-length",
|
||||
"content-type",
|
||||
"content-md5",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 签名
|
||||
* @param array $credentials
|
||||
* @param string $httpMethod
|
||||
* @param string $path
|
||||
* @param array $headers
|
||||
* @param string $params
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
public static function sign(
|
||||
array $credentials,
|
||||
$httpMethod,
|
||||
$path,
|
||||
$headers,
|
||||
$params,
|
||||
$options = array()
|
||||
) {
|
||||
//设定签名有效时间
|
||||
if (!isset($options[AipSignOption::EXPIRATION_IN_SECONDS])) {
|
||||
//默认值1800秒
|
||||
$expirationInSeconds = AipSignOption::DEFAULT_EXPIRATION_IN_SECONDS;
|
||||
} else {
|
||||
$expirationInSeconds = $options[AipSignOption::EXPIRATION_IN_SECONDS];
|
||||
}
|
||||
|
||||
//解析ak sk
|
||||
$accessKeyId = $credentials['ak'];
|
||||
$secretAccessKey = $credentials['sk'];
|
||||
|
||||
//设定时间戳,注意:如果自行指定时间戳需要为UTC时间
|
||||
if (!isset($options[AipSignOption::TIMESTAMP])) {
|
||||
//默认值当前时间
|
||||
$timestamp = gmdate('Y-m-d\TH:i:s\Z');
|
||||
} else {
|
||||
$timestamp = $options[AipSignOption::TIMESTAMP];
|
||||
}
|
||||
|
||||
//生成authString
|
||||
$authString = AipSampleSigner::BCE_AUTH_VERSION . '/' . $accessKeyId . '/'
|
||||
. $timestamp . '/' . $expirationInSeconds;
|
||||
|
||||
//使用sk和authString生成signKey
|
||||
$signingKey = hash_hmac('sha256', $authString, $secretAccessKey);
|
||||
|
||||
//生成标准化URI
|
||||
$canonicalURI = AipHttpUtil::getCanonicalURIPath($path);
|
||||
|
||||
//生成标准化QueryString
|
||||
$canonicalQueryString = AipHttpUtil::getCanonicalQueryString($params);
|
||||
|
||||
//填充headersToSign,也就是指明哪些header参与签名
|
||||
$headersToSign = null;
|
||||
if (isset($options[AipSignOption::HEADERS_TO_SIGN])) {
|
||||
$headersToSign = $options[AipSignOption::HEADERS_TO_SIGN];
|
||||
}
|
||||
|
||||
//生成标准化header
|
||||
$canonicalHeader = AipHttpUtil::getCanonicalHeaders(
|
||||
AipSampleSigner::getHeadersToSign($headers, $headersToSign)
|
||||
);
|
||||
|
||||
//整理headersToSign,以';'号连接
|
||||
$signedHeaders = '';
|
||||
if ($headersToSign !== null) {
|
||||
$signedHeaders = strtolower(
|
||||
trim(implode(";", $headersToSign))
|
||||
);
|
||||
}
|
||||
|
||||
//组成标准请求串
|
||||
$canonicalRequest = "$httpMethod\n$canonicalURI\n"
|
||||
. "$canonicalQueryString\n$canonicalHeader";
|
||||
|
||||
//使用signKey和标准请求串完成签名
|
||||
$signature = hash_hmac('sha256', $canonicalRequest, $signingKey);
|
||||
|
||||
//组成最终签名串
|
||||
$authorizationHeader = "$authString/$signedHeaders/$signature";
|
||||
|
||||
return $authorizationHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据headsToSign过滤应该参与签名的header
|
||||
* @param array $headers
|
||||
* @param array $headersToSign
|
||||
* @return array
|
||||
*/
|
||||
public static function getHeadersToSign($headers, $headersToSign)
|
||||
{
|
||||
|
||||
$arr = array();
|
||||
foreach ($headersToSign as $value) {
|
||||
$arr[] = strtolower(trim($value));
|
||||
}
|
||||
|
||||
//value被trim后为空串的header不参与签名
|
||||
$result = array();
|
||||
foreach ($headers as $key => $value) {
|
||||
if (trim($value) !== '') {
|
||||
$key = strtolower(trim($key));
|
||||
if (in_array($key, $arr)) {
|
||||
$result[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//返回需要参与签名的header
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查header是不是默认参加签名的:
|
||||
* 1.是host、content-type、content-md5、content-length之一
|
||||
* 2.以x-bce开头
|
||||
* @param array $header
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isDefaultHeaderToSign($header)
|
||||
{
|
||||
$header = strtolower(trim($header));
|
||||
if (in_array($header, AipSampleSigner::$defaultHeadersToSign)) {
|
||||
return true;
|
||||
}
|
||||
return substr_compare($header, AipSampleSigner::BCE_PREFIX, 0, strlen(AipSampleSigner::BCE_PREFIX)) == 0;
|
||||
}
|
||||
}
|
||||
AipSampleSigner::__init();
|
|
@ -1,394 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* Http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
require_once 'AipHttpClient.php';
|
||||
require_once 'AipBCEUtil.php';
|
||||
|
||||
/**
|
||||
* Aip Base 基类
|
||||
*/
|
||||
class AipBase {
|
||||
|
||||
/**
|
||||
* 获取access token url
|
||||
* @var string
|
||||
*/
|
||||
protected $accessTokenUrl = 'https://aip.baidubce.com/oauth/2.0/token';
|
||||
|
||||
/**
|
||||
* 反馈接口
|
||||
* @var string
|
||||
*/
|
||||
protected $reportUrl = 'https://aip.baidubce.com/rpc/2.0/feedback/v1/report';
|
||||
|
||||
/**
|
||||
* appId
|
||||
* @var string
|
||||
*/
|
||||
protected $appId = '';
|
||||
|
||||
/**
|
||||
* apiKey
|
||||
* @var string
|
||||
*/
|
||||
protected $apiKey = '';
|
||||
|
||||
/**
|
||||
* secretKey
|
||||
* @var string
|
||||
*/
|
||||
protected $secretKey = '';
|
||||
|
||||
/**
|
||||
* 权限
|
||||
* @var array
|
||||
*/
|
||||
protected $scope = 'brain_all_scope';
|
||||
|
||||
/**
|
||||
* @param string $appId
|
||||
* @param string $apiKey
|
||||
* @param string $secretKey
|
||||
*/
|
||||
public function __construct($appId, $apiKey, $secretKey){
|
||||
$this->appId = trim($appId);
|
||||
$this->apiKey = trim($apiKey);
|
||||
$this->secretKey = trim($secretKey);
|
||||
$this->isCloudUser = null;
|
||||
$this->client = new AipHttpClient();
|
||||
$this->version = '2_2_19';
|
||||
$this->proxies = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看版本
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function getVersion(){
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接超时
|
||||
* @param int $ms 毫秒
|
||||
*/
|
||||
public function setConnectionTimeoutInMillis($ms){
|
||||
$this->client->setConnectionTimeoutInMillis($ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应超时
|
||||
* @param int $ms 毫秒
|
||||
*/
|
||||
public function setSocketTimeoutInMillis($ms){
|
||||
$this->client->setSocketTimeoutInMillis($ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理
|
||||
* @param array $proxy
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function setProxies($proxies){
|
||||
$this->client->setConf($proxies);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求参数
|
||||
* @param string $url
|
||||
* @param array $params
|
||||
* @param array $data
|
||||
* @param array $headers
|
||||
*/
|
||||
protected function proccessRequest($url, &$params, &$data, $headers){
|
||||
$params['aipSdk'] = 'php';
|
||||
$params['aipSdkVersion'] = $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Api 请求
|
||||
* @param string $url
|
||||
* @param mixed $data
|
||||
* @return mixed
|
||||
*/
|
||||
protected function request($url, $data, $headers=array()){
|
||||
try{
|
||||
$result = $this->validate($url, $data);
|
||||
if($result !== true){
|
||||
return $result;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$authObj = $this->auth();
|
||||
|
||||
if($this->isCloudUser === false){
|
||||
$params['access_token'] = $authObj['access_token'];
|
||||
}
|
||||
|
||||
// 特殊处理
|
||||
$this->proccessRequest($url, $params, $data, $headers);
|
||||
|
||||
$headers = $this->getAuthHeaders('POST', $url, $params, $headers);
|
||||
$response = $this->client->post($url, $data, $params, $headers);
|
||||
|
||||
$obj = $this->proccessResult($response['content']);
|
||||
|
||||
if(!$this->isCloudUser && isset($obj['error_code']) && $obj['error_code'] == 110){
|
||||
$authObj = $this->auth(true);
|
||||
$params['access_token'] = $authObj['access_token'];
|
||||
$response = $this->client->post($url, $data, $params, $headers);
|
||||
$obj = $this->proccessResult($response['content']);
|
||||
}
|
||||
|
||||
if(empty($obj) || !isset($obj['error_code'])){
|
||||
$this->writeAuthObj($authObj);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
return array(
|
||||
'error_code' => 'SDK108',
|
||||
'error_msg' => 'connection or read data timeout',
|
||||
);
|
||||
}
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Api 多个并发请求
|
||||
* @param string $url
|
||||
* @param mixed $data
|
||||
* @return mixed
|
||||
*/
|
||||
protected function multi_request($url, $data){
|
||||
try{
|
||||
$params = array();
|
||||
$authObj = $this->auth();
|
||||
$headers = $this->getAuthHeaders('POST', $url);
|
||||
|
||||
if($this->isCloudUser === false){
|
||||
$params['access_token'] = $authObj['access_token'];
|
||||
}
|
||||
|
||||
$responses = $this->client->multi_post($url, $data, $params, $headers);
|
||||
|
||||
$is_success = false;
|
||||
foreach($responses as $response){
|
||||
$obj = $this->proccessResult($response['content']);
|
||||
|
||||
if(empty($obj) || !isset($obj['error_code'])){
|
||||
$is_success = true;
|
||||
}
|
||||
|
||||
if(!$this->isCloudUser && isset($obj['error_code']) && $obj['error_code'] == 110){
|
||||
$authObj = $this->auth(true);
|
||||
$params['access_token'] = $authObj['access_token'];
|
||||
$responses = $this->client->post($url, $data, $params, $headers);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($is_success){
|
||||
$this->writeAuthObj($authObj);
|
||||
}
|
||||
|
||||
$objs = array();
|
||||
foreach($responses as $response){
|
||||
$objs[] = $this->proccessResult($response['content']);
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
return array(
|
||||
'error_code' => 'SDK108',
|
||||
'error_msg' => 'connection or read data timeout',
|
||||
);
|
||||
}
|
||||
|
||||
return $objs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式检查
|
||||
* @param string $url
|
||||
* @param array $data
|
||||
* @return mix
|
||||
*/
|
||||
protected function validate($url, &$data){
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化结果
|
||||
* @param $content string
|
||||
* @return mixed
|
||||
*/
|
||||
protected function proccessResult($content){
|
||||
return json_decode($content, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回 access token 路径
|
||||
* @return string
|
||||
*/
|
||||
private function getAuthFilePath(){
|
||||
return dirname(__FILE__) . DIRECTORY_SEPARATOR . md5($this->apiKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入本地文件
|
||||
* @param array $obj
|
||||
* @return void
|
||||
*/
|
||||
private function writeAuthObj($obj){
|
||||
if($obj === null || (isset($obj['is_read']) && $obj['is_read'] === true)){
|
||||
return;
|
||||
}
|
||||
|
||||
$obj['time'] = time();
|
||||
$obj['is_cloud_user'] = $this->isCloudUser;
|
||||
@file_put_contents($this->getAuthFilePath(), json_encode($obj));
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取本地缓存
|
||||
* @return array
|
||||
*/
|
||||
private function readAuthObj(){
|
||||
$content = @file_get_contents($this->getAuthFilePath());
|
||||
if($content !== false){
|
||||
$obj = json_decode($content, true);
|
||||
$this->isCloudUser = $obj['is_cloud_user'];
|
||||
$obj['is_read'] = true;
|
||||
if($this->isCloudUser || $obj['time'] + $obj['expires_in'] - 30 > time()){
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 认证
|
||||
* @param bool $refresh 是否刷新
|
||||
* @return array
|
||||
*/
|
||||
private function auth($refresh=false){
|
||||
|
||||
//非过期刷新
|
||||
if(!$refresh){
|
||||
$obj = $this->readAuthObj();
|
||||
if(!empty($obj)){
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
|
||||
$response = $this->client->get($this->accessTokenUrl, array(
|
||||
'grant_type' => 'client_credentials',
|
||||
'client_id' => $this->apiKey,
|
||||
'client_secret' => $this->secretKey,
|
||||
));
|
||||
|
||||
$obj = json_decode($response['content'], true);
|
||||
|
||||
$this->isCloudUser = !$this->isPermission($obj);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断认证是否有权限
|
||||
* @param array $authObj
|
||||
* @return boolean
|
||||
*/
|
||||
protected function isPermission($authObj)
|
||||
{
|
||||
if(empty($authObj) || !isset($authObj['scope'])){
|
||||
return false;
|
||||
}
|
||||
|
||||
$scopes = explode(' ', $authObj['scope']);
|
||||
|
||||
return in_array($this->scope, $scopes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method HTTP method
|
||||
* @param string $url
|
||||
* @param array $param 参数
|
||||
* @return array
|
||||
*/
|
||||
private function getAuthHeaders($method, $url, $params=array(), $headers=array()){
|
||||
|
||||
//不是云的老用户则不用在header中签名 认证
|
||||
if($this->isCloudUser === false){
|
||||
return $headers;
|
||||
}
|
||||
|
||||
$obj = parse_url($url);
|
||||
if(!empty($obj['query'])){
|
||||
foreach(explode('&', $obj['query']) as $kv){
|
||||
if(!empty($kv)){
|
||||
list($k, $v) = explode('=', $kv, 2);
|
||||
$params[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//UTC 时间戳
|
||||
$timestamp = gmdate('Y-m-d\TH:i:s\Z');
|
||||
$headers['Host'] = isset($obj['port']) ? sprintf('%s:%s', $obj['host'], $obj['port']) : $obj['host'];
|
||||
$headers['x-bce-date'] = $timestamp;
|
||||
|
||||
//签名
|
||||
$headers['authorization'] = AipSampleSigner::sign(array(
|
||||
'ak' => $this->apiKey,
|
||||
'sk' => $this->secretKey,
|
||||
), $method, $obj['path'], $headers, $params, array(
|
||||
'timestamp' => $timestamp,
|
||||
'headersToSign' => array_keys($headers),
|
||||
));
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 反馈
|
||||
*
|
||||
* @param array $feedbacks
|
||||
* @return array
|
||||
*/
|
||||
public function report($feedback){
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['feedback'] = $feedback;
|
||||
|
||||
return $this->request($this->reportUrl, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用接口
|
||||
* @param string $url
|
||||
* @param array $data
|
||||
* @param array header
|
||||
* @return array
|
||||
*/
|
||||
public function post($url, $data, $headers=array()){
|
||||
return $this->request($url, $data, $headers);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,214 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* Http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Http Client
|
||||
*/
|
||||
class AipHttpClient{
|
||||
|
||||
/**
|
||||
* HttpClient
|
||||
* @param array $headers HTTP header
|
||||
*/
|
||||
public function __construct($headers=array()){
|
||||
$this->headers = $this->buildHeaders($headers);
|
||||
$this->connectTimeout = 60000;
|
||||
$this->socketTimeout = 60000;
|
||||
$this->conf = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接超时
|
||||
* @param int $ms 毫秒
|
||||
*/
|
||||
public function setConnectionTimeoutInMillis($ms){
|
||||
$this->connectTimeout = $ms;
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应超时
|
||||
* @param int $ms 毫秒
|
||||
*/
|
||||
public function setSocketTimeoutInMillis($ms){
|
||||
$this->socketTimeout = $ms;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置
|
||||
* @param array $conf
|
||||
*/
|
||||
public function setConf($conf){
|
||||
$this->conf = $conf;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求预处理
|
||||
* @param resource $ch
|
||||
*/
|
||||
public function prepare($ch){
|
||||
foreach($this->conf as $key => $value){
|
||||
curl_setopt($ch, $key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param array $data HTTP POST BODY
|
||||
* @param array $param HTTP URL
|
||||
* @param array $headers HTTP header
|
||||
* @return array
|
||||
*/
|
||||
public function post($url, $data=array(), $params=array(), $headers=array()){
|
||||
$url = $this->buildUrl($url, $params);
|
||||
$headers = array_merge($this->headers, $this->buildHeaders($headers));
|
||||
|
||||
$ch = curl_init();
|
||||
$this->prepare($ch);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, is_array($data) ? http_build_query($data) : $data);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->socketTimeout);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->connectTimeout);
|
||||
$content = curl_exec($ch);
|
||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
if($code === 0){
|
||||
throw new Exception(curl_error($ch));
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
return array(
|
||||
'code' => $code,
|
||||
'content' => $content,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param array $datas HTTP POST BODY
|
||||
* @param array $param HTTP URL
|
||||
* @param array $headers HTTP header
|
||||
* @return array
|
||||
*/
|
||||
public function multi_post($url, $datas=array(), $params=array(), $headers=array()){
|
||||
$url = $this->buildUrl($url, $params);
|
||||
$headers = array_merge($this->headers, $this->buildHeaders($headers));
|
||||
|
||||
$chs = array();
|
||||
$result = array();
|
||||
$mh = curl_multi_init();
|
||||
foreach($datas as $data){
|
||||
$ch = curl_init();
|
||||
$chs[] = $ch;
|
||||
$this->prepare($ch);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, is_array($data) ? http_build_query($data) : $data);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->socketTimeout);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->connectTimeout);
|
||||
curl_multi_add_handle($mh, $ch);
|
||||
}
|
||||
|
||||
$running = null;
|
||||
do{
|
||||
curl_multi_exec($mh, $running);
|
||||
usleep(100);
|
||||
}while($running);
|
||||
|
||||
foreach($chs as $ch){
|
||||
$content = curl_multi_getcontent($ch);
|
||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$result[] = array(
|
||||
'code' => $code,
|
||||
'content' => $content,
|
||||
);
|
||||
curl_multi_remove_handle($mh, $ch);
|
||||
}
|
||||
curl_multi_close($mh);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param array $param HTTP URL
|
||||
* @param array $headers HTTP header
|
||||
* @return array
|
||||
*/
|
||||
public function get($url, $params=array(), $headers=array()){
|
||||
$url = $this->buildUrl($url, $params);
|
||||
$headers = array_merge($this->headers, $this->buildHeaders($headers));
|
||||
|
||||
$ch = curl_init();
|
||||
$this->prepare($ch);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->socketTimeout);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->connectTimeout);
|
||||
$content = curl_exec($ch);
|
||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
if($code === 0){
|
||||
throw new Exception(curl_error($ch));
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
return array(
|
||||
'code' => $code,
|
||||
'content' => $content,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造 header
|
||||
* @param array $headers
|
||||
* @return array
|
||||
*/
|
||||
private function buildHeaders($headers){
|
||||
$result = array();
|
||||
foreach($headers as $k => $v){
|
||||
$result[] = sprintf('%s:%s', $k, $v);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $params 参数
|
||||
* @return string
|
||||
*/
|
||||
private function buildUrl($url, $params){
|
||||
if(!empty($params)){
|
||||
$str = http_build_query($params);
|
||||
return $url . (strpos($url, '?') === false ? '?' : '&') . $str;
|
||||
}else{
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
<?php
|
||||
|
||||
|
||||
include 'local_avatars.php'; //本地头像
|
||||
|
||||
include 'updates.php'; //在线更新
|
||||
//include( 'widget_cache.php' );//小工具缓存
|
||||
include( 'widget_cache.php' );//小工具缓存
|
||||
|
||||
include 'Payjs.php'; //支付功能
|
||||
include 'points/points.php'; //积分功能
|
||||
|
@ -12,4 +11,3 @@ include 'points/points.php'; //积分功能
|
|||
include 'aq_resizer.php'; //缩略图功能
|
||||
include 'wechat.php'; //微信功能
|
||||
|
||||
//include 'ai.php'; //AI功能
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
<?php
|
||||
|
||||
class Auto_Widget_cache
|
||||
|
@ -54,8 +53,7 @@ class Auto_Widget_cache
|
|||
<p>
|
||||
<input id="<?php
|
||||
echo $t->get_field_id('wc_cache'); ?>" name="<?php
|
||||
echo $t->get_field_name('wc_cache'); ?>" type="checkbox" <?php
|
||||
checked(isset($instance['wc_cache']) ? $instance['wc_cache'] : 0); ?> />
|
||||
echo $t->get_field_name('wc_cache'); ?>" type="checkbox" <?php checked($instance['wc_cache'] ?? 0); ?> />
|
||||
<label for="<?php
|
||||
echo $t->get_field_id('wc_cache'); ?>">禁止缓存本工具?</label>
|
||||
</p>
|
||||
|
@ -67,4 +65,6 @@ echo $t->get_field_id('wc_cache'); ?>">禁止缓存本工具?</label>
|
|||
return $instance;
|
||||
}
|
||||
}
|
||||
if( gdk_option('gdk_sidebar_cache')){
|
||||
$GLOBALS['Auto_Widget_cache'] = new Auto_Widget_cache();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
error_reporting(E_ALL ^ E_NOTICE); //镇魔石,镇压一切魑魅魍魉!
|
||||
|
||||
if (!class_exists('myCustomFields')) {
|
||||
|
||||
class myCustomFields
|
||||
|
@ -21,7 +21,7 @@ if (!class_exists('myCustomFields')) {
|
|||
"title" => "自定义缩略图",
|
||||
"description" => "这里可以输入您的自定义缩略图链接",
|
||||
"type" => "text",
|
||||
"scope" => array("post"),
|
||||
"scope" => ['post'],
|
||||
"capability" => "edit_posts",
|
||||
),
|
||||
array(
|
||||
|
@ -29,7 +29,7 @@ if (!class_exists('myCustomFields')) {
|
|||
"title" => "单页下载文件名字",
|
||||
"description" => "这里可以输入您的下载文件的名字",
|
||||
"type" => "text",
|
||||
"scope" => array("post"),
|
||||
"scope" => ['post'],
|
||||
"capability" => "edit_posts",
|
||||
),
|
||||
array(
|
||||
|
@ -37,7 +37,7 @@ if (!class_exists('myCustomFields')) {
|
|||
"title" => "单页下载文件大小",
|
||||
"description" => "这里可以输入您的下载文件的大小,可以加上单位,比如:233KB或者233MB",
|
||||
"type" => "text",
|
||||
"scope" => array("post"),
|
||||
"scope" => ['post'],
|
||||
"capability" => "edit_posts",
|
||||
),
|
||||
array(
|
||||
|
@ -45,7 +45,7 @@ if (!class_exists('myCustomFields')) {
|
|||
"title" => "单页下载下载链接",
|
||||
"description" => "按照链接,名字,备注的格式,注意中间是用英文逗号,换行可添加多个,举个栗子:<code>https://www.baidu.com,百度官网,中国最大的搜索引擎网站</code>",
|
||||
"type" => "textarea",
|
||||
"scope" => array("post"),
|
||||
"scope" => ['post'],
|
||||
"capability" => "edit_posts",
|
||||
),
|
||||
);
|
||||
|
@ -56,8 +56,6 @@ if (!class_exists('myCustomFields')) {
|
|||
{
|
||||
add_action('admin_menu', array($this, 'createCustomFields'));
|
||||
add_action('save_post', array($this, 'saveCustomFields'), 1, 2);
|
||||
// 下面这句可以关闭WordPress自带的自定义栏目,但是不推荐,需要的话可以开启
|
||||
//add_action( 'do_meta_boxes', array( $this, 'removeDefaultCustomFields' ), 10, 3 );
|
||||
}
|
||||
/**
|
||||
* 创建一组你自己的自定义栏目
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
*/
|
||||
|
||||
$gdk_options = [
|
||||
'优化选项' => [
|
||||
'优化' => [
|
||||
[
|
||||
'name' => '古腾堡编辑器',
|
||||
'desc' => '新版编辑器尚不成熟,很多主题不兼容,建议禁用',
|
||||
'id' => 'gdk_diasble_gutenberg',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '开启',
|
||||
'1' => '禁用(推荐)',
|
||||
'0' => '启用',
|
||||
'1' => '禁用',
|
||||
],
|
||||
'std' => '1',
|
||||
],
|
||||
|
@ -22,97 +22,56 @@ $gdk_options = [
|
|||
'id' => 'gdk_diasble_widgets_block',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '开启',
|
||||
'1' => '禁用(推荐)',
|
||||
'0' => '启用',
|
||||
'1' => '禁用',
|
||||
],
|
||||
'std' => '1',
|
||||
],
|
||||
[
|
||||
'name' => '头部冗余代码',
|
||||
'desc' => 'WordPress头部自带很多无用代码,不安全且浪费,建议禁用',
|
||||
'desc' => '禁用<br>WordPress头部自带很多无用代码,不安全且浪费,建议禁用',
|
||||
'id' => 'gdk_diasble_head_useless',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '开启',
|
||||
'1' => '禁用(推荐)',
|
||||
],
|
||||
'std' => '1',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '禁用WordPress更新',
|
||||
'desc' => 'WordPress更新会不时发送请求数据,所以可以关闭WordPress更新,包括主题,插件和内核更新,默认禁用',
|
||||
'id' => 'gdk_diasble_wp_update',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '0',
|
||||
],
|
||||
[
|
||||
'name' => '禁用Emojis功能',
|
||||
'desc' => 'WordPress的Emojis功能会加载国外资源,那是网站速度,所以建议开启',
|
||||
'name' => 'Emojis表情功能',
|
||||
'desc' => '禁用<br>WordPress自带的Emojis功能会加载国外资源,那是网站速度,建议禁用',
|
||||
'id' => 'gdk_disable_emojis',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '前台禁用dashicons字体和编辑器资源',
|
||||
'desc' => '一般前台不需要加载dashicons字体,默认开启',
|
||||
'name' => '前台Dashicons字体资源',
|
||||
'desc' => '禁用<br>一般前台不需要加载dashicons字体,建议禁用',
|
||||
'id' => 'gdk_disable_dashicons',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '中英文自动空格',
|
||||
'desc' => '启用 【开启后,中文和英文之前将自动增加一个空格,比如:WordPress插件=>WordPress 插件】',
|
||||
'desc' => '启用<br>【开启后,中文和英文之前将自动增加一个空格,比如:WordPress插件=>WordPress 插件】',
|
||||
'id' => 'gdk_auto_space',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '禁用XML-RPC功能',
|
||||
'desc' => '该功能有安全风险,如果不使用WordPress的手机客户端或者第三方编辑器软件,那么建议开启',
|
||||
'name' => 'XML-RPC发布功能',
|
||||
'desc' => '禁用<br>该功能有安全风险,如果不使用WordPress的手机客户端或者第三方编辑器软件,那么建议禁用',
|
||||
'id' => 'gdk_disable_xmlrpc',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '禁用文章版本功能',
|
||||
'desc' => '该功能有会造成数据库体量暴增为了你的数据库考虑,建议开启',
|
||||
'name' => '文章版本功能',
|
||||
'desc' => '禁用<br>该功能有会造成数据库体量暴增为了你的数据库考虑,建议禁用',
|
||||
'id' => 'gdk_disable_revision',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '禁用pingback功能',
|
||||
'desc' => '该功能会增加垃圾评论的几率,建议开启',
|
||||
'name' => 'Pingback功能',
|
||||
'desc' => '禁用<br>该功能会增加垃圾评论的几率,建议禁用',
|
||||
'id' => 'gdk_disable_trackbacks',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '文件上传重命名',
|
||||
'desc' => '该功能会将zip,rar,7z格式以外的所有全部数字重命名,服务器文件不建议使用中文,默认开启',
|
||||
'desc' => '该功能会将上传的文件图片等按照数字格式重命名,服务器文件不建议使用中文,默认开启',
|
||||
'id' => 'gdk_upload_rename',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
|
@ -122,19 +81,20 @@ $gdk_options = [
|
|||
'std' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'WordPress更新中国加速',
|
||||
'desc' => '该功能会帮助顺利更新WordPress,突破429,注意:如果上面的WordPress禁用更新了,此处设置无效,建议开启',
|
||||
'id' => 'gdk_porxy_update',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
'name' => 'WordPress更新',
|
||||
'desc' => '禁用<br>WordPress更新会不时发送请求数据,所以可以关闭WordPress更新,包括主题,插件和内核更新,建议禁用',
|
||||
'id' => 'gdk_diasble_wp_update',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
'std' => '1',
|
||||
[
|
||||
'name' => 'WordPress更新中国加速',
|
||||
'desc' => '启用<br>该功能会帮助更顺利更新WordPress,注意:如果上面的WordPress禁用更新了,此处设置无效,由Litepress提供镜像,建议开启',
|
||||
'id' => 'gdk_porxy_update',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '头像加速功能',
|
||||
'desc' => '该功能会增加头像加载速度,有随机头像,V2EX头像镜像和七牛头像镜像,默认选择随机头像',
|
||||
'desc' => '该功能会增加头像加载速度,有随机头像,V2EX头像镜像和七牛头像镜像,默认选择随机头像,本地头像和微信头像不受影响',
|
||||
'id' => 'gdk_switch_get_avatar',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
|
@ -143,10 +103,10 @@ $gdk_options = [
|
|||
'3' => '七牛头像镜像',
|
||||
'4' => 'Cravatar',
|
||||
],
|
||||
'std' => '3',
|
||||
'std' => '1',
|
||||
],
|
||||
],
|
||||
'SEO设置' => [
|
||||
'SEO' => [
|
||||
[
|
||||
'name' => '网站关键字', //选项显示的文字,选填
|
||||
'desc' => '各关键字间用半角逗号', '分割,数量在6个以内最佳。', //选项显示的一段描述文字,选填
|
||||
|
@ -162,21 +122,16 @@ $gdk_options = [
|
|||
],
|
||||
[
|
||||
'name' => 'title分隔符',
|
||||
'desc' => '显示在浏览器标题栏的一个用来风格网站名字的',
|
||||
'desc' => '显示在浏览器标题栏的一个用来分隔网站名字的',
|
||||
'id' => 'gdk_delimiter',
|
||||
'type' => 'text',
|
||||
'std' => '|',
|
||||
],
|
||||
[
|
||||
'name' => '自动添加nofollow',
|
||||
'desc' => '该功能会给外链自动添加nofollow,默认开启',
|
||||
'desc' => '该功能会给外链自动添加nofollow,推荐开启',
|
||||
'id' => 'gdk_nofollow',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '分类去Category优化',
|
||||
|
@ -186,14 +141,9 @@ $gdk_options = [
|
|||
],
|
||||
[
|
||||
'name' => '文章自动内链',
|
||||
'desc' => '该功能会将文章中与标签匹配的文字自动添加标签链接,如果是纯文字的内容建议打开,默认禁用',
|
||||
'desc' => '启用<br>该功能会将文章中与标签匹配的文字自动添加标签链接,如果是纯文字的内容建议打开,注意该功能和一些短代码等功能有冲突',
|
||||
'id' => 'gdk_tag_link',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '0',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '关键词链接次数',
|
||||
|
@ -204,64 +154,39 @@ $gdk_options = [
|
|||
],
|
||||
[
|
||||
'name' => 'Robots.txt 优化',
|
||||
'desc' => '该功能会自动生成一个虚拟Robots.txt文件,和真实文件效果一样的,默认开启',
|
||||
'desc' => '启用<br>该功能会自动生成一个虚拟Robots.txt文件,和真实文件效果一样的,默认开启',
|
||||
'id' => 'gdk_robots',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '禁止蜘蛛爬取作者页面',
|
||||
'desc' => '该功能会屏蔽蜘蛛访问作者页面,如果是单作者网站没必要展示作者页,根据自己网站实际情况选择是否开启,默认禁用',
|
||||
'desc' => '启用<br>该功能会屏蔽蜘蛛访问作者页面,如果是单作者网站没必要展示作者页,根据自己网站实际情况选择是否开启,建议启用',
|
||||
'id' => 'gdk_no_author_page',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '0',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '网站地图 sitemap',
|
||||
'desc' => '该功能会自动生成网站地图[xml版和html版],链接:域名/sitemap.xml,域名/sitemap.html,开启后建议更新固定链接一次,默认开启',
|
||||
'desc' => '启用<br>该功能会自动生成网站地图[xml版和html版],链接:域名/sitemap.xml,域名/sitemap.html,开启后建议更新固定链接一次,建议启用开启',
|
||||
'id' => 'gdk_sitemap_xml',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '文章图片自动添加alt以及title',
|
||||
'desc' => '该功能会自动给文章中图片添加alt和title,并且是按照文章标题进行命名,默认开启',
|
||||
'id' => 'gdk_seo_img',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '外链GO跳转',
|
||||
'desc' => '启用',
|
||||
'desc' => '启用<br>启用后,文章外链会转化为/go?url=的类型',
|
||||
'id' => 'gdk_link_go',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '百度自动&主动推送',
|
||||
'desc' => '该功能会自动给文章中图片添加alt和title,并且是按照文章标题进行命名,默认开启',
|
||||
'desc' => '启用<br>启用后可以采用自动推送和主动推送给百度',
|
||||
'id' => 'gdk_baidu_push',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '0',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '主动推送接口token',
|
||||
|
@ -270,33 +195,33 @@ $gdk_options = [
|
|||
'type' => 'text',
|
||||
],
|
||||
],
|
||||
'安全设置' => [
|
||||
'安全' => [
|
||||
[
|
||||
'name' => '屏蔽各种不正常的请求',
|
||||
'desc' => '该功能会将各种不正常的请求比如破解,注入类的屏蔽掉,默认开启',
|
||||
'id' => 'gdk_block_requst',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'1' => '开启',
|
||||
'0' => '禁用',
|
||||
'1' => '启用',
|
||||
],
|
||||
'std' => '1',
|
||||
],
|
||||
[
|
||||
'name' => '网站维护模式',
|
||||
'desc' => '开启 【启用后,未登录用户将看到一个简陋的维护页面】',
|
||||
'desc' => '启用<br>启用后,未登录用户将看到一个简陋的维护页面',
|
||||
'id' => 'gdk_maintenance_mode',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '禁用REST API功能',
|
||||
'desc' => '禁用 【启用后,REST API功能将关闭,如果没不使用该功能的话,建议关闭】',
|
||||
'desc' => '禁用<br>启用后,REST API功能将关闭,如果没不使用该功能的话,建议关闭',
|
||||
'id' => 'gdk_disable_restapi',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '保护用户暴露用户名',
|
||||
'desc' => '开启 【启用后,将隐藏掉用户的登录名,起到保护作用】',
|
||||
'desc' => '开启<br>启用后,将隐藏掉用户的登录名,起到保护作用',
|
||||
'id' => 'gdk_hide_user_name',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
|
@ -310,7 +235,7 @@ $gdk_options = [
|
|||
'id' => 'gdk_lock_login',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'1' => '开启',
|
||||
'1' => '启用',
|
||||
'0' => '禁用',
|
||||
],
|
||||
'std' => '1',
|
||||
|
@ -331,13 +256,13 @@ $gdk_options = [
|
|||
],
|
||||
[
|
||||
'name' => '登录失败邮件通知',
|
||||
'desc' => '启用 【开启后,将所有登陆失败信息发邮件通知管理员】',
|
||||
'desc' => '启用<br>开启后,将所有登陆失败信息发邮件通知管理员,预计会收到很多邮件,不建议启用',
|
||||
'id' => 'gdk_login_email',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '登陆数学验证',
|
||||
'desc' => '启用 【开启后,将会登陆页面增加数学验证码】',
|
||||
'desc' => '启用<br>开启后,将会登陆页面增加数学验证码',
|
||||
'id' => 'gdk_login_verify',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
|
@ -351,62 +276,34 @@ $gdk_options = [
|
|||
'id' => 'gdk_fuck_spam',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'1' => '开启',
|
||||
'0' => '禁用',
|
||||
'1' => '启用(推荐)',
|
||||
],
|
||||
'std' => '1',
|
||||
],
|
||||
],
|
||||
'高级设置' => [
|
||||
'高级' => [
|
||||
[
|
||||
'name' => '图片懒加载',
|
||||
'desc' => '该功能会降低因为图片而导致的打开速度慢问题,建议开启',
|
||||
'desc' => '启用<br>该功能会降低因为图片而导致的打开速度慢问题,建议开启',
|
||||
'id' => 'gdk_lazyload',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'jQuery加载位置设置',
|
||||
'desc' => '选择一个适合自己网站的jQuery加载位置,默认是底部加载',
|
||||
'id' => 'gdk_jq',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'1' => '底部加载,速度快',
|
||||
'0' => '头部加载,兼容好',
|
||||
],
|
||||
'std' => '1',
|
||||
],
|
||||
[
|
||||
'name' => '友情链接分类ID',
|
||||
'desc' => '请选择专门用来存放友链的链接分类ID',
|
||||
'id' => 'gdk_link_id',
|
||||
'type' => 'number',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => 'HTML代码压缩',
|
||||
'desc' => '启用 【开启后,将压缩网页HTML代码,可读性会降低,但是性能略有提升】',
|
||||
'desc' => '启用<br>开启后,将压缩网页HTML代码,提高网页加载速度',
|
||||
'id' => 'gdk_compress',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '文章目录',
|
||||
'desc' => '启用 【开启后,将在文章页显示一个文章目录】',
|
||||
'id' => 'gdk_article_list',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '侧边栏缓存',
|
||||
'desc' => '启用 【开启后,将会自动缓存小工具,如果想禁止缓存某个小工具,可以去小工具页面排除】',
|
||||
'desc' => '启用<br>开启后,将会自动缓存小工具,如果想禁止缓存某个小工具,可以去小工具页面排除',
|
||||
'id' => 'gdk_sidebar_cache',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '新窗口打开',
|
||||
'desc' => '禁用 【禁用后,所有文章链接将当前窗口打开】',
|
||||
'name' => '链接新窗口打开',
|
||||
'desc' => '启用<br>启用后,所有文章链接将在新标签页打开',
|
||||
'id' => 'gdk_target_blank',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
|
@ -415,19 +312,14 @@ $gdk_options = [
|
|||
'type' => 'title',
|
||||
],
|
||||
[
|
||||
'name' => '网站支付功能',
|
||||
'desc' => '开启网站支付功能需要HTTPS支持,需要开通Payjs使用,<a class="key_word" href="https://payjs.cn/ref/ZVEMKD" target="_blank" >点击注册Payjs</a>',
|
||||
'name' => '网站Psyjs支付功能',
|
||||
'desc' => '启用<br>网站支付功能需要HTTPS支持,需要开通Payjs使用,<a class="key_word" href="https://payjs.cn/ref/ZVEMKD" target="_blank" >点击注册Payjs</a>',
|
||||
'id' => 'gdk_payjs',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '0',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '支付宝支付通道',
|
||||
'desc' => '启用 【开启后,将增加支付宝支付方式,支付宝通道需要到payjs申请开通,如果开通的话,建议使用支付宝,因为费率便宜】',
|
||||
'desc' => '启用<br>开启后,将增加支付宝支付方式,支付宝通道需要到payjs申请开通,如果开通的话,建议使用支付宝,因为费率便宜',
|
||||
'id' => 'gdk_payjs_alipay',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
|
@ -458,18 +350,13 @@ $gdk_options = [
|
|||
],
|
||||
[
|
||||
'name' => 'CDN镜像加速',
|
||||
'desc' => '开启本功能可以将本站静态资源同步到远程CDN服务器,减轻本站的流量压力,提高网站整体速度,国内主流CDN服务商[七牛,又拍,阿里OSS,腾讯COS,华为BOS等等]均支持,默认关闭,配置好服务器端后开启',
|
||||
'desc' => '开启<br>本功能可以将本站静态资源同步到远程CDN服务器,减轻本站的流量压力,提高网站整体速度,国内主流CDN服务商[七牛,又拍,阿里OSS,腾讯COS,华为BOS等等]均支持,默认关闭,配置好服务器端后开启',
|
||||
'id' => 'gdk_cdn',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '0',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => 'CDN域名',
|
||||
'desc' => '输入您的CDN域名,一般需要到cdn后台获取,必须带 <span class="key_word">http(s):// ,且结尾不能带/ </span>',
|
||||
'desc' => '输入您的CDN域名,一般需要到VDN后台获取,必须带 <span class="key_word">http(s):// ,且结尾不能带/ </span>',
|
||||
'id' => 'gdk_cdn_host',
|
||||
'type' => 'text',
|
||||
'std' => '',
|
||||
|
@ -489,22 +376,23 @@ $gdk_options = [
|
|||
'std' => 'wp-content|wp-includes',
|
||||
],
|
||||
[
|
||||
'name' => 'CDN服务商',
|
||||
'name' => '静态CDN服务商',
|
||||
'desc' => '选择使用国内CDN服务商,此项主要影响CDN缩略图,请选择对应服务商',
|
||||
'id' => 'gdk_cdn_serves',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'1' => '七牛云',
|
||||
'2' => '又拍云',
|
||||
'3' => '腾讯云',
|
||||
'4' => '阿里云',
|
||||
'5' => '华为云',
|
||||
'3' => '腾讯云COS',
|
||||
'4' => '阿里云OSS',
|
||||
'5' => '华为云OBS',
|
||||
'6' => '百度云BOS',
|
||||
],
|
||||
'std' => '4',
|
||||
],
|
||||
[
|
||||
'name' => 'CDN水印',
|
||||
'desc' => '启用【如果启用,请在七牛,又拍,OSS等CDN中设置自定义样式,名字为:<span class="key_word">water.jpg</span>,分隔符为<span class="key_word">!</span> 】',
|
||||
'desc' => '启用<br>启用后,请在七牛,又拍,OSS等CDN中设置自定义样式,名字为:<span class="key_word">water.jpg</span>,分隔符为<span class="key_word">!</span>',
|
||||
'id' => 'gdk_cdn_water',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
|
@ -514,13 +402,13 @@ $gdk_options = [
|
|||
],
|
||||
[
|
||||
'name' => '是否启用微信扫码登录',
|
||||
'desc' => '启用 【开启后,新建微信登录页面即可,另外需要HTTPS】',
|
||||
'desc' => '启用<br>开启后,可以使用微信扫码,另外需要HTTPS',
|
||||
'id' => 'gdk_weauth_oauth',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '是否启用强制微信登录',
|
||||
'desc' => '启用 【开启后,将禁用WordPress自带的登录,所有登录地址都跳转到微信的登录,如需临时使用自带登录,可以使用这个链接:你的域名/wp-login.php?loggedout=true】',
|
||||
'name' => '强制微信登录',
|
||||
'desc' => '启用<br>开启后,将禁用WordPress自带的登录,所有登录地址都跳转到微信的登录,如需临时使用自带登录,可以使用这个链接:你的域名/wp-login.php?loggedout=true',
|
||||
'id' => 'gdk_weauth_force',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
|
@ -530,27 +418,57 @@ $gdk_options = [
|
|||
],
|
||||
[
|
||||
'name' => '评论微信推送提醒',
|
||||
'desc' => '启用【开启后,如果网站有新的评论,可以给您的微信推送提醒,这个只是给网站管理员提醒,不涉及访客】',
|
||||
'id' => 'gdk_Server',
|
||||
'desc' => '启用<br>开启后,如果网站有新的评论,可以给管理员的微信推送提醒',
|
||||
'id' => 'gdk_workpush',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '企业微信推送应用ID',
|
||||
'desc' => '请输入您的企业微信推送应用ID',
|
||||
'id' => 'gdk_workpush_id',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => '企业微信推送应用Secret',
|
||||
'desc' => '请输入您的企业微信推送应用Secret',
|
||||
'id' => 'gdk_workpush_secret',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => '企业微信企业ID',
|
||||
'desc' => '请输入您的企业微信ID',
|
||||
'id' => 'gdk_work_id',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'title' => '微信群发设置',
|
||||
'type' => 'title',
|
||||
],
|
||||
[
|
||||
'name' => '微信wxPushet应用Token',
|
||||
'desc' => '请输入Wxpuers应用Token,从wxpusher后台获取',
|
||||
'id' => 'gdk_wxpusher_key',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => '微信Wxpusher主题ID',
|
||||
'desc' => '请输入您的Wxpusher主题ID,可以从后台获取',
|
||||
'id' => 'gdk_wxpusher_id',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'title' => '微信公众号设置',
|
||||
'type' => 'title',
|
||||
],
|
||||
[
|
||||
'name' => '微信公众号TOKEN',
|
||||
'desc' => '请输入您的微信公众号TOKEN,微信公众号后台获取',
|
||||
'id' => 'gdk_wxmp_token',
|
||||
'type' => 'text',
|
||||
'std' => '',
|
||||
],
|
||||
[
|
||||
'name' => '微信推送KEY',
|
||||
'desc' => '请输入您的微信推送KEY',
|
||||
'id' => 'gdk_Server_key',
|
||||
'type' => 'text',
|
||||
'std' => '',
|
||||
],
|
||||
[
|
||||
'name' => '微信订阅号/公众号二维码',
|
||||
'desc' => '请输入您的微信订阅号/公众号二维码图片链接,不要想得太多,只是给主题调用的。',
|
||||
'name' => '微信公众号二维码',
|
||||
'desc' => '请输入您的微信订阅号/公众号二维码图片链接',
|
||||
'id' => 'gdk_mp_qr',
|
||||
'type' => 'text',
|
||||
'std' => '',
|
||||
|
@ -561,14 +479,9 @@ $gdk_options = [
|
|||
],
|
||||
[
|
||||
'name' => 'HTML5 桌面推送',
|
||||
'desc' => '该功能开启后会在浏览器进行信息推送,需要高级浏览器支持,默认关闭',
|
||||
'desc' => '启用<br>该功能开启后会在浏览器右下角进行信息推送',
|
||||
'id' => 'gdk_h5notice',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '0',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => 'HTML5推送标题【必选】',
|
||||
|
@ -618,21 +531,15 @@ $gdk_options = [
|
|||
],
|
||||
[
|
||||
'name' => 'SMTP邮箱发送',
|
||||
'desc' => '该功能利用第三方SMTP邮箱服务发送邮件,比如评论邮件,需要配置好再开启',
|
||||
'desc' => '启用<br>该功能利用第三方SMTP邮箱服务发送邮件,比如评论邮件,需要配置好再开启',
|
||||
'id' => 'gdk_smtp',
|
||||
'type' => 'radio',
|
||||
'options' => [
|
||||
'0' => '禁用',
|
||||
'1' => '开启',
|
||||
],
|
||||
'std' => '0',
|
||||
'type' => 'checkbox',
|
||||
],
|
||||
[
|
||||
'name' => '发件人昵称',
|
||||
'desc' => '请输入您的网站名称,比如:云落',
|
||||
'id' => 'gdk_smtp_username',
|
||||
'type' => 'text',
|
||||
'std' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'SMTP服务器地址',
|
||||
|
@ -653,14 +560,12 @@ $gdk_options = [
|
|||
'desc' => '请输入您的邮箱地址,比如云落的sp91@qq.com',
|
||||
'id' => 'gdk_smtp_mail',
|
||||
'type' => 'text',
|
||||
'std' => '',
|
||||
],
|
||||
[
|
||||
'name' => '邮箱密码',
|
||||
'desc' => '请输入您的邮箱授权码,<span class="key_word">注意不同邮箱服务器的密码不一样,有的是密码,有的比如QQ邮箱就是授权码</span>',
|
||||
'id' => 'gdk_smtp_password',
|
||||
'type' => 'password',
|
||||
'std' => '',
|
||||
],
|
||||
[
|
||||
'title' => '自定义代码',
|
||||
|
@ -671,28 +576,24 @@ $gdk_options = [
|
|||
'desc' => '代码将插入到head区域',
|
||||
'id' => 'gdk_custom_head_code',
|
||||
'type' => 'textarea',
|
||||
'std' => '',
|
||||
],
|
||||
[
|
||||
'name' => '网站底部自定义代码',
|
||||
'desc' => '代码将插入到foot区域',
|
||||
'id' => 'gdk_custom_foot_code',
|
||||
'type' => 'textarea',
|
||||
'std' => '',
|
||||
],
|
||||
[
|
||||
'name' => '文章顶部自定义内容',
|
||||
'desc' => '在文章顶部插入一个内容',
|
||||
'id' => 'gdk_artical_top',
|
||||
'type' => 'textarea',
|
||||
'std' => '',
|
||||
],
|
||||
[
|
||||
'name' => '文章底部自定义内容',
|
||||
'desc' => '在文章底部插入一个内容',
|
||||
'id' => 'gdk_artical_bottom',
|
||||
'type' => 'textarea',
|
||||
'std' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
@ -254,9 +254,12 @@ break;
|
|||
.filter-links li>a:hover{color:#666}
|
||||
.filter-links a:focus{color:#6b48ff;box-shadow:none}
|
||||
|
||||
.gdk_option input[type=radio]:checked::before {
|
||||
.gdk_option input[type=checkbox]:checked::before,.gdk_option input[type=radio]:checked::before {
|
||||
background-color: #6b48ff;
|
||||
}
|
||||
.gdk_option input[type=checkbox] {
|
||||
margin:4px;
|
||||
}
|
||||
.gdk_option input[type=radio]:focus, .gdk_option input[type=checkbox]:focus{
|
||||
box-shadow: 0 0 0 1px #6b48ff;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@ function gdk_rand_color() {
|
|||
$rndKey = array_rand($arr);
|
||||
echo $arr[$rndKey];
|
||||
}
|
||||
//获取友情链接ID,默认是第一个创建的分类
|
||||
function gdk_link_id() {
|
||||
$arr = get_terms( 'link_category', 'orderby=id&hide_empty=0' );
|
||||
return $arr[0]->term_id;
|
||||
}
|
||||
/**
|
||||
* 获取摘要
|
||||
*/
|
||||
|
|
|
@ -448,49 +448,6 @@ function contentblock_shortcode( $atts, $content = null ) {
|
|||
add_shortcode( 'cb', 'contentblock_shortcode' );
|
||||
|
||||
|
||||
|
||||
//
|
||||
function points_view($content){
|
||||
$cookie_name = 'huoduan_wechat_fans';
|
||||
|
||||
if (preg_match_all('/<!--pay points start-->([\s\S]*?)<!--pay points end-->/i', $content, $hide_words))
|
||||
{
|
||||
$re = '/<!--pay points start-->【(.*)】/i';
|
||||
$str = '我在这里,这里不是付费内容
|
||||
<!--pay points start-->【10】dssdssdfs我在这里,这里是付费内容
|
||||
第二行
|
||||
<!--pay points end-->';
|
||||
|
||||
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 0);
|
||||
$points = $matches[1][0];
|
||||
$wechatfans = get_option('huoduan_wechatfans');
|
||||
$cv = md5($wechatfans['wechat_key'].$cookie_name.'huoduan.com');
|
||||
$vtips='';
|
||||
if(isset($_POST['huoduan_verifycode'])){
|
||||
if($_POST['huoduan_verifycode']==$wechatfans['wechat_code']){
|
||||
setcookie($cookie_name, $cv ,time()+(int)$wechatfans['wechat_day']*86400, "/");
|
||||
$_COOKIE[$cookie_name] = $cv;
|
||||
}else{
|
||||
$vtips='<script>alert("验证码错误!请输入正确的验证码!");</script>';
|
||||
}
|
||||
}
|
||||
$cookievalue = isset($_COOKIE[$cookie_name])?$_COOKIE[$cookie_name]:'';
|
||||
|
||||
if($cookievalue==$cv){
|
||||
$content = str_replace($hide_words[0], '<div style="border:1px dashed #F60; padding:10px; margin:10px 0; line-height:200%; background-color:#FFF4FF; overflow:hidden; clear:both;">'.$hide_words[0][0].'</div>', $content);
|
||||
}else{
|
||||
|
||||
$hide_notice = '<div class="huoduan_hide_box" style="border:1px dashed #F60; padding:10px; margin:10px 0; line-height:200%; color:#F00; background-color:#FFF4FF; overflow:hidden; clear:both;"><img class="wxpic" align="right" src="'.$wechatfans['wechat_qrimg'].'" style="width:150px;height:150px;margin-left:20px;display:inline;border:none" width="150" height="150" alt="'.$wechatfans['wechat_name'].'" /><span style="font-size:18px;">此处内容已经被作者隐藏,请输入验证码查看内容</span><form method="post" style="margin:10px 0;"><span class="yzts" style="font-size:18px;float:left;">验证码:</span><input name="huo'.'duan_verifycode" id="verifycode" type="text" value="" style="border:none;float:left;width:80px; height:32px; line-height:30px; padding:0 5px; border:1px solid #FF6600;-moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius:0px;" /><input id="verifybtn" style="border:none;float:left;width:80px; height:32px; line-height:32px; padding:0 5px; background-color:#F60; text-align:center; border:none; cursor:pointer; color:#FFF;-moz-border-radius: 0px; font-size:14px; -webkit-border-radius: 0px; border-radius:0px;" name="" type="submit" value="提交查看" /></form><div style="clear:left;"></div><span style="color:#00BF30">请关注本站微信公众号,回复“<span style="color:blue">'.$wechatfans['wechat_keyword'].'</span>”,获取验证码。在微信里搜索“<span style="color:blue">'.$wechatfans['wechat_name'].'</span>”或者“<span style="color:blue">'.$wechatfans['wechat_account'].'</span>”或者微信扫描右侧二维码都可以关注本站微信公众号。</span><div class="cl"></div></div>'.$vtips;
|
||||
|
||||
$content = str_replace($hide_words[0], $hide_notice, $content);
|
||||
}
|
||||
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
add_filter('the_content', 'points_view');
|
||||
|
||||
//WordPress 段代码按钮集合
|
||||
function gdk_shortcode_list()
|
||||
{
|
||||
|
|
6
gdk.php
6
gdk.php
|
@ -3,10 +3,10 @@
|
|||
Plugin Name: GitCafe Development Kit 极客公园开发套件
|
||||
Plugin URI: https://gitcafe.net/
|
||||
Description: 为WordPress主题开发提供底层支持
|
||||
Version: 0.0.3
|
||||
Version: 0.0.4
|
||||
Author: 云落
|
||||
Author URI: https://gitcafe.net/
|
||||
Compatible:5.3.2
|
||||
Compatible:5.8.1
|
||||
*/
|
||||
|
||||
//万能的开头
|
||||
|
@ -28,7 +28,7 @@ if (!version_compare(PHP_VERSION, '7.2', '>=')) {
|
|||
}
|
||||
|
||||
//定义各种常量
|
||||
define('GDK_PLUGIN_VER', '0.0.3');
|
||||
define('GDK_PLUGIN_VER', '0.0.4');
|
||||
define('GDK_PLUGIN_FILE', __FILE__); //插件入口文件
|
||||
define('GDK_BASE_URL', plugin_dir_url(__FILE__)); //插件目录url
|
||||
define('GDK_ROOT_PATH', plugin_dir_path(__FILE__)); //插件目录路径
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue