diff --git a/assets/js/gdk.js b/assets/js/gdk.js
index 1ddf163..58d1ccd 100644
--- a/assets/js/gdk.js
+++ b/assets/js/gdk.js
@@ -86,6 +86,7 @@ jQuery(function ($) { /**声明加载jQuery */
* 已经密码可见的自动从浏览器读取内容
* 并显示,这里加个延时处理
*/
+
(function () {
if ($("#submit_pass_view").length > 0) { /**如果网站有密码可见,就执行 */
setTimeout(function () {
@@ -94,7 +95,7 @@ jQuery(function ($) { /**声明加载jQuery */
for (var i = 0; i < length; i++) {
var key = localStorage.key(i),
value = localStorage.getItem(key);
- if (key.indexOf(id) >= 0) { /**发现目标 */
+ if (key.indexOf(id) >= 0) { /*发现目标 */
show_hide_content('.pass_viewbox', value);
break;
}
@@ -103,6 +104,7 @@ jQuery(function ($) { /**声明加载jQuery */
}, 900);
}
}());
+
/**密码可见end */
diff --git a/class/class_load.php b/class/class_load.php
index 29b21af..44d151c 100644
--- a/class/class_load.php
+++ b/class/class_load.php
@@ -9,4 +9,5 @@ include( 'updates.php' );//在线更新
include( 'Payjs.php' );//支付功能
include( 'points/points.php' );//积分功能
-include( 'aq_resizer.php' );//缩略图功能
\ No newline at end of file
+include( 'aq_resizer.php' );//缩略图功能
+include( 'wechat.php' );//微信功能
\ No newline at end of file
diff --git a/class/wechat.php b/class/wechat.php
new file mode 100644
index 0000000..c9ea8d1
--- /dev/null
+++ b/class/wechat.php
@@ -0,0 +1,387 @@
+token = $token;
+ $this->callback_function = $callback_function_name;
+ }
+
+ /**
+ * 检查签名是否正确
+ *
+ * @return boolean 正确返回true,否则返回false
+ */
+ private function checkSignature()
+ {
+ $signature = $_GET["signature"];
+ $timestamp = $_GET["timestamp"];
+ $nonce = $_GET["nonce"];
+
+ $token = $this->token;
+
+ $tmpArr = array($token, $timestamp, $nonce);
+ sort($tmpArr, SORT_STRING);
+ $tmpStr = implode($tmpArr);
+ $tmpStr = sha1($tmpStr);
+
+
+ if ($tmpStr == $signature)
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * 验证签名是否有效
+ */
+ protected function valid()
+ {
+ $echoStr = $_GET["echostr"];
+ //valid signature , option
+ if ($this->checkSignature()) {
+ echo $echoStr;
+ exit;
+ } else {
+ echo 'error signature';
+ }
+ }
+
+ /**
+ * 处理来自微信服务器的消息
+ */
+ public function process()
+ {
+ //如果是验证请求,则执行签名验证并退出
+ if (!empty($_GET["echostr"])) {
+ $this->valid(); //验证签名是否有效
+ return; //返回退出
+ }
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ echo '';
+ return;
+ }
+
+ //如果不是验证请求,则
+ //首先,取得POST原始数据(XML格式)
+ //$postData = $GLOBALS["HTTP_RAW_POST_DATA"];
+ $postData = file_get_contents('php://input');
+ if (empty($postData)) {
+ echo '';
+ return;
+ } //如果没有POST数据,则退出
+
+
+ //解析POST数据(XML格式)
+ $object = simplexml_load_string($postData, 'SimpleXMLElement', LIBXML_NOCDATA);
+ $messgeType = trim($object->MsgType); //取得消息类型
+ $this->fromUser = "" . $object->FromUserName; //记录消息发送方(不是发送者的微信号,而是一个加密后的OpenID)
+ $this->toUser = "" . $object->ToUserName; //记录消息接收方(就是公共平台的OpenID)
+
+ //如果回调函数没有设置,则退出
+ if (!is_callable($this->callback_function)) {
+ return;
+ }
+
+ //根据不同的消息类型,分别处理
+ switch ($messgeType) {
+ case "text": //文本消息
+ //调用回调函数
+ call_user_func($this->callback_function, $this, "text", $object->Content, "", "");
+ break;
+ case "event": //事件
+ switch ($object->Event) {
+ case "subscribe": //订阅事件
+ call_user_func($this->callback_function, $this, "subscribe", $object->FromUserName, "", "");
+ break;
+ default :
+ //Unknow Event
+ break;
+ }
+ break;
+ default:
+ //Unknow msg type
+ break;
+ }
+ }
+
+ /**
+ * 形成 文本消息响应值
+ *
+ * @param string $toUser
+ * @param string $fromUser
+ * @param string $content
+ * @param integer $flag
+ *
+ * @return string
+ */
+ protected function textResponse($toUser, $fromUser, $content, $flag = 0)
+ {
+ $xmlTemplate = "
+
+
+ %s
+
+
+ %d
+ ";
+
+ $xmlText = sprintf($xmlTemplate, $toUser, $fromUser, time(), $content, $flag);
+
+ return $xmlText;
+ }
+
+
+ /**
+ * 形成 图文消息响应值
+ *
+ * @param string $toUser
+ * @param string $fromUser
+ * @param array $articles 一个array,每个元素保存一条图文信息;每个元素也是一个array, 有Title,Description,PicUrl,Url四个键值
+ *
+ * @return string
+ */
+ protected function newsResponse($toUser, $fromUser, $articles)
+ {
+ $xmlTemplate = "
+
+
+ %s
+
+ ";
+ $xmlText = sprintf($xmlTemplate, $toUser, $fromUser, time());
+ $xmlText .= '' . count($articles) . '';
+ $xmlText .= '';
+
+ foreach ($articles as $article) {
+ $xmlText .= '- ';
+ $xmlText .= '';
+ $xmlText .= '';
+ $xmlText .= '';
+ $xmlText .= '';
+ $xmlText .= '
';
+ }
+
+ $xmlText .= ' ';
+
+ return $xmlText;
+ }
+
+
+ /**
+ * 发送文本内容
+ *
+ * @param string $content 文本内容
+ */
+ public function sendText($content)
+ {
+ echo $this->textResponse($this->fromUser, $this->toUser, $content);
+ }
+
+
+ /**
+ * 添加一条图文信息
+ *
+ * @param string $title 标题
+ * @param string $description 内容
+ * @param string $url 网页链接URL
+ * @param string $pictureUrl 图片的URL
+ */
+ public function addNews($title, $description, $url, $pictureUrl)
+ {
+ $article = array('Title' => $title,
+ 'Description' => $description,
+ 'PicUrl' => $pictureUrl,
+ 'Url' => $url);
+ $this->articles[] = $article;
+ }
+
+ /**
+ * 发送图文信息
+ * 用法:首先用addNews()函数一条一条地添加图文信息,添加完成后用本函数发送
+ */
+ public function sendNews()
+ {
+ echo $this->newsResponse($this->fromUser, $this->toUser, $this->articles);
+ }
+
+
+}
+
+
+
+
+
+define("TOKEN", 'wxcaptcha'); //TOKEN值
+define("WX_WELCOME", '欢迎关注极客公园'); //欢迎词
+define("POSTNUM", '5'); //文章数量
+define("DEFAULT_THUMB", '');//封面
+
+
+
+add_action('pre_get_posts', 'wm_preprocess', 4);
+/**
+ * 预处理函数
+ *
+ * @param $wp_query
+ */
+function wm_preprocess($wp_query)
+{
+ global $object;
+ if (!isset($object)) {
+ //创建一个WeChat类的实例, 回调函数名称为"onMessage",即消息处理函数
+ $object = new WeChat(TOKEN, "onMessage");
+ $object->process(); //处理消息
+ return;
+ }
+}
+
+/**
+ * 消息处理函数
+ *
+ * @param WeChat $object
+ * @param string $messageType
+ * @param string $content
+ * @param string $arg1
+ * @param string $arg2
+ */
+function onMessage(WeChat $object, $messageType, $content, $arg1, $arg2)
+{
+
+ //处理subscribe消息
+ switch ($messageType) {
+ case "subscribe": //当用户关注
+ $object->addNews(WX_WELCOME, "", "", "");
+ $object->sendNews();
+ break;
+ case "text":
+ $keyword = trim($content);
+ switch ($keyword) {
+ case 'yzm':
+ case 'Yzm':
+ case 'yZm':
+ case 'yzM':
+ case 'YZM':
+ case '验证码':
+ $object->sendText('您的验证码为:【'.wx_captcha().'】,验证码有效期为2分钟,请抓紧使用,过期需重新申请');
+ break;
+ case 'r':
+ send_post($object, 'r');
+ break;
+ case "help":
+ case "h":
+ case "?":
+ case "?":
+ case "???":
+ $object->sendText(WX_WELCOME);
+ break;
+ default:
+ send_post($object, 'r');
+ break;
+ }
+ break;
+ default:
+ $object->sendText("暂无设置此功能"); //否则,显示出错信息
+ }
+}
+
+
+
+
+//获取博客文章
+function wm_query_posts($q, $s = "")
+{
+ global $wp_query;
+ $articles = [];
+ $query_base = array(
+ 'ignore_sticky_posts' => true,
+ 'posts_per_page' => POSTNUM,
+ 'post_status' => 'publish',
+ );
+ if (empty($s)) {
+ switch ($q) {
+ case "n":
+ $query_more = array(
+ "order" => "DESC",
+ "orderby" => "date",
+ );
+ break;
+ case "r":
+ $query_more = array(
+ "orderby" => "rand",
+ );
+ break;
+ default:
+ $query_more = [];
+ break;
+ }
+ } else {
+ $query_more = array(
+ 's' => $s,
+ );
+ }
+ $weixin_query_array = array_merge($query_base, $query_more);
+ $wp_query->query($weixin_query_array);
+ if (have_posts()) {
+ while (have_posts()) {
+ the_post();
+ global $post;
+ $title = get_the_title();
+ $excerpt = gdk_print_excerpt(120,$post,false);
+ $thumbnail_id = get_post_thumbnail_id($post->ID);
+ if ($thumbnail_id) {
+ $thumb = wp_get_attachment_image_src($thumbnail_id, 'full');
+ $thumb = $thumb[0];
+ } else {
+ $thumb = gdk_thumbnail_src();
+ }
+ if (empty(DEFAULT_THUMB) && !empty(DEFAULT_THUMB)) {
+ $thumb = DEFAULT_THUMB;
+ }
+ $link = get_permalink();
+ $articles[] = array($title, $excerpt, $link, $thumb);
+ }
+ }
+
+ return $articles;
+}
+
+function send_post(WeChat $object, $type = '', $value = '')
+{
+ $articles = wm_query_posts($type, $value);
+ if (empty($articles)) {
+ $no_post = '暂无相关文章';
+ $object->sendText($no_post);
+ }
+ foreach ($articles as $v) {
+ $object->addNews($v['0'], $v['1'], $v['2'], $v['3']);
+ }
+ $object->sendNews();
+}
\ No newline at end of file
diff --git a/functions/Ajax.php b/functions/Ajax.php
index 548e61f..5aa7798 100644
--- a/functions/Ajax.php
+++ b/functions/Ajax.php
@@ -72,8 +72,9 @@ function gdk_pass_view() {
$action = $_POST['action'];
$post_id = $_POST['id'];
$pass = $_POST['pass'];
+ $wxcaptcha = wx_captcha();
if(!isset( $action ) || !isset( $post_id ) || !isset( $pass ) ) exit('400');
- if($pass == '2233') {
+ if($pass == $wxcaptcha ) {
$pass_content = get_post_meta($post_id, '_pass_content')[0];
exit($pass_content);
}else{
diff --git a/functions/Common.php b/functions/Common.php
index 3d5c9ba..b81d76c 100644
--- a/functions/Common.php
+++ b/functions/Common.php
@@ -34,7 +34,7 @@ function nc_reverse_strrchr($haystack, $needle, $trail)
/**
* 获取完整的句子
*/
-function nc_print_excerpt($length, $post = null, $echo = true)
+function gdk_print_excerpt($length, $post = null, $echo = true)
{
global $post;
$text = $post->post_excerpt;
@@ -64,6 +64,9 @@ function nc_print_excerpt($length, $post = null, $echo = true)
}
}
+
+
+
function nc_comment_add_at($comment_text, $comment = '')
{
if (!empty($comment) && $comment->comment_parent > 0) {
@@ -965,11 +968,11 @@ function gdk_thumb_img($way,$width,$height,$style = '',$atrr = 'class="thumb_img
if ($way === 1) {//cdn
$src = $url.'!'.$style;
}elseif ($way === 2) {
- $src = GDK_BASE_URL . '/public/timthumb.php?src='.$url.'&h='.$height.'&w='.$width.'&q=90&zc=1&ct=1';
+ $src = GDK_BASE_URL . 'public/timthumb.php?src='.$url.'&h='.$height.'&w='.$width.'&q=90&zc=1&ct=1';
}elseif ($way === 3) {
$src = aq_resize( $url, $width , $height , true);
if(empty($src)){
- $src = GDK_BASE_URL . '/public/timthumb.php?src='.$url.'&h='.$height.'&w='.$width.'&q=90&zc=1&ct=1';
+ $src = GDK_BASE_URL . 'public/timthumb.php?src='.$url.'&h='.$height.'&w='.$width.'&q=90&zc=1&ct=1';
}
}else{
return false;
@@ -1027,7 +1030,7 @@ function gdk_get_the_link_items($id = null) {
if (!empty($bookmarks)) {
foreach ($bookmarks as $bookmark) {
$output.= '
';
+ ';
}
}
return $output;
@@ -1116,11 +1119,11 @@ function payjs_notify() {
function buy_points(){
if(is_user_logged_in()) {//logined
$result = '
- 点击充值
+ 点击充值
';
}else{// no login
- $result = '';
+ $result = '';
}
return $result;
}
@@ -1240,3 +1243,69 @@ function create_user_id( $userdata ){
return $user_id;
}
+
+//生成hover颜色
+function editorial_hover_color( $hex, $steps ) {
+ // Steps should be between -255 and 255. Negative = darker, positive = lighter
+ $steps = max( -255, min( 255, $steps ) );
+ // Normalize into a six character long hex string
+ $hex = str_replace( '#', '', $hex );
+ if ( strlen( $hex ) == 3) {
+ $hex = str_repeat( substr( $hex,0,1 ), 2 ).str_repeat( substr( $hex, 1, 1 ), 2 ).str_repeat( substr( $hex,2,1 ), 2 );
+ }
+ // Split into three parts: R, G and B
+ $color_parts = str_split( $hex, 2 );
+ $return = '#';
+ foreach ( $color_parts as $color ) {
+ $color = hexdec( $color );
+ // Convert to decimal
+ $color = max( 0, min( 255, $color + $steps ) );
+ // Adjust color
+ $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT );
+ // Make two char hex code
+ }
+ return $return;
+}
+
+
+
+/**
+ * Get minified css and removed space
+ *
+ * @since 1.2.5
+ */
+/**
+ * Minify CSS
+ *
+ * @since 1.0.0
+ */
+function pwd_minify_css( $css ) {
+
+ // Normalize whitespace
+ $css = preg_replace( '/\s+/', ' ', $css );
+ // Remove ; before }
+ $css = preg_replace( '/;(?=\s*})/', '', $css );
+ // Remove space after , : ; { } */ >
+ $css = preg_replace( '/(,|:|;|\{|}|\*\/|>) /', '$1', $css );
+ // Remove space before , ; { }
+ $css = preg_replace( '/ (,|;|\{|})/', '$1', $css );
+ // Strips leading 0 on decimal values (converts 0.5px into .5px)
+ $css = preg_replace( '/(:| )0\.([0-9]+)(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}.${2}${3}', $css );
+ // Strips units if value is 0 (converts 0px to 0)
+ $css = preg_replace( '/(:| )(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}0', $css );
+ // Return minified CSS
+ return trim( $css );
+}
+
+//生成微信验证码
+function wx_captcha(){
+ date_default_timezone_set('Asia/Shanghai');
+ $min = floor(date("i")/2);
+ $day = date("d");
+ $day = ltrim($day,0);
+ $url = 'https://gitcafe.net';//home_url();
+ $captcha = sha1($min.$url);
+ $captcha = substr($captcha , $day , 6);
+ return $captcha;
+
+}
\ No newline at end of file
diff --git a/functions/email.php b/functions/email.php
new file mode 100644
index 0000000..b1ae9f8
--- /dev/null
+++ b/functions/email.php
@@ -0,0 +1,99 @@
+From = gdk_option('gdk_maildizhi_b'); //发件人地址
+ $phpmailer->FromName = gdk_option('gdk_mailnichen_b'); //发件人昵称
+ $phpmailer->Host = gdk_option('gdk_mailsmtp_b'); //SMTP服务器地址
+ $phpmailer->Port = gdk_option('gdk_mailport_b'); //SMTP邮件发送端口
+ if (gdk_option('gdk_smtpssl_b')) {
+ $phpmailer->SMTPSecure = 'ssl';
+ } else {
+ $phpmailer->SMTPSecure = '';
+ } //SMTP加密方式(SSL/TLS)没有为空即可
+ $phpmailer->Username = gdk_option('gdk_mailuser_b'); //邮箱帐号
+ $phpmailer->Password = gdk_option('gdk_mailpass_b'); //邮箱密码
+ $phpmailer->IsSMTP();
+ $phpmailer->SMTPAuth = true; //启用SMTPAuth服务
+
+ }
+ add_action('phpmailer_init', 'googlo_mail_smtp');
+}
+*/
+//修改默认发信地址
+function deel_res_from_email($email) {
+ $wp_from_email = get_option('admin_email');
+ return $wp_from_email;
+}
+function deel_res_from_name($email) {
+ $wp_from_name = get_option('blogname');
+ return $wp_from_name;
+}
+add_filter('wp_mail_from', 'deel_res_from_email');
+add_filter('wp_mail_from_name', 'deel_res_from_name');
+
+//评论回应邮件通知
+function comment_mail_notify($comment_id) {
+ $admin_notify = '0'; // admin 要不要收回复通知 ( '1'=要 ; '0'=不要 )
+ $admin_email = get_bloginfo('admin_email'); // $admin_email 可改为你指定的 e-mail.
+ $comment = get_comment($comment_id);
+ $comment_author_email = trim($comment->comment_author_email);
+ $parent_id = $comment->comment_parent ? $comment->comment_parent : '';
+ $blogname = get_option("blogname");
+ global $wpdb;
+ if ($wpdb->query("Describe {$wpdb->comments} comment_mail_notify") == '') $wpdb->query("ALTER TABLE {$wpdb->comments} ADD COLUMN comment_mail_notify TINYINT NOT NULL DEFAULT 0;");
+ if (($comment_author_email != $admin_email && isset($_POST['comment_mail_notify'])) || ($comment_author_email == $admin_email && $admin_notify == '1')) $wpdb->query("UPDATE {$wpdb->comments} SET comment_mail_notify='1' WHERE comment_ID='$comment_id'");
+ $notify = $parent_id ? get_comment($parent_id)->comment_mail_notify : '0';
+ $spam_confirmed = $comment->comment_approved;
+ if ($parent_id != '' && $spam_confirmed != 'spam' && $notify == '1') {
+ $wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); // e-mail 发出点, no-reply 可改为可用的 e-mail.
+ $to = trim(get_comment($parent_id)->comment_author_email);
+ $subject = 'Hi,您在 [' . get_option("blogname") . '] 的留言有人回复啦!';
+ $message = 'Copyright © 2013-2018 ' . $blogname . '
';
+ $from = "From: \"" . get_option('blogname') . "\" <$wp_email>";
+ $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n";
+ wp_mail($to, $subject, $message, $headers);
+ }
+}
+add_action('comment_post', 'comment_mail_notify');
+
+//站长评论邮件添加评论链接
+function gdk_notify_postauthor($notify_message,$comment_ID) {
+ $notify = $notify_message;
+ $notify.= '快速回复此评论: ' . admin_url("edit-comments.php").'#comment-'.$comment_ID;
+ return $notify;
+}
+add_filter('comment_notification_text', 'gdk_notify_postauthor', 10, 2);
+
+
+//欢迎新用户邮件
+
+ function gdk_register_mail($user_id) {
+ $user = get_user_by('id', $user_id);
+ $user_pass = $_POST['password'];
+ $blogname = get_option('blogname');
+ $message = '注册成功通知
尊敬的' . $user->user_login . ',您好!
欢迎您注册[' . $blogname . '],下面是您的账号信息,请妥善保管!
您的详细注册信息 |
---|
登录邮箱 | ' . $user->user_email . ' |
登录密码 | ' . $user_pass . ' |
如果您的账号有异常,请您在第一时间和我们取得联系哦,联系邮箱:' . get_bloginfo('admin_email') . '
';
+ $headers = "Content-Type:text/html;charset=UTF-8\n";
+ wp_mail($user->user_email, '[' . $blogname . ']欢迎注册' . $blogname, $message, $headers);
+ }
+ add_action('user_register', 'gdk_register_mail');
+
+
+
+//登录失败提醒
+
+ function gdk_login_failed_notify() {
+ date_default_timezone_set('PRC');
+ $admin_email = get_bloginfo('admin_email');
+ $to = $admin_email;
+ $subject = '您的网站登录错误警告';
+ $message = '您好!您的网站(' . get_option("blogname") . ')有登录错误!
' . '请确定是您自己的登录失误,以防别人攻击!登录信息如下:
' . '登录名:' . $_POST['log'] . '
' . '登录密码:' . $_POST['pwd'] . '
' . '登录时间:' . date("Y-m-d H:i:s") . '
' . '登录IP:' . $_SERVER['REMOTE_ADDR'] . '
' . '————本邮件由系统发送,无需回复
';
+ $wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
+ $from = "From: \"" . get_option('blogname') . "\" <$wp_email>";
+ $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n";
+ wp_mail($to, $subject, $message, $headers);
+ }
+ add_action('wp_login_failed', 'gdk_login_failed_notify');
diff --git a/functions/shortcode.php b/functions/shortcode.php
index 1bd7af0..ad22349 100644
--- a/functions/shortcode.php
+++ b/functions/shortcode.php
@@ -204,14 +204,26 @@ add_shortcode('vip', 'gdk_login_to_read');
// 部分内容输入密码可见
function gdk_secret_view($atts, $content = null) {
- extract(shortcode_atts(array('wx' => null) , $atts));
$pid = get_the_ID();
add_post_meta($pid, '_pass_content', $content, true) or update_post_meta($pid, '_pass_content', $content);
if ( current_user_can( 'administrator' ) || gdk_is_weixin()) { return $content; }//admin show
- return '
';
+ return '
+
+
+
+
+
+
+
';
}
-add_shortcode('secret', 'gdk_secret_view');
+add_shortcode('wxcaptcha', 'gdk_secret_view');
+
// 支持文章和页面运行PHP代码
function gdk_php_include($attr) {
diff --git a/public/daohang.php b/public/daohang.php
index 99eda52..b63712f 100644
--- a/public/daohang.php
+++ b/public/daohang.php
@@ -33,20 +33,20 @@ add_filter( 'template_include', 'gdk_daohang_html_api_handlers', 99 );
function gdk_create_html_daohang() {
?>
-
+
网址导航 -
@@ -57,7 +57,7 @@ function gdk_create_html_daohang() {
-
+
';
@@ -80,12 +80,12 @@ function gdk_create_html_daohang() {
?>