From 138f29c95b6d4f2202b05387314608dc393f1dbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=9C=E6=81=92?= <2323333339@qq.com>
Date: Sun, 21 Feb 2021 17:45:35 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
assets/js/joe.global.js | 8 +-
core/function.php | 426 ++++++++++++++++++++--------------------
core/short.php | 208 +++++++++++---------
friends.php | 2 +-
4 files changed, 334 insertions(+), 310 deletions(-)
diff --git a/assets/js/joe.global.js b/assets/js/joe.global.js
index 247e0ae..100e0bc 100644
--- a/assets/js/joe.global.js
+++ b/assets/js/joe.global.js
@@ -160,7 +160,7 @@ document.addEventListener('DOMContentLoaded', () => {
const style = $('.joe_aside__item.weather').attr('data-style');
const aqiColor = { 1: 'FFFFFF', 2: '4A4A4A', 3: 'FFFFFF' };
window.WIDGET = { CONFIG: { layout: 2, width: '220', height: '270', background: style, dataColor: aqiColor[style], language: 'zh', key: key } };
- $.getScript("https://apip.weatherdt.com/standard/static/js/weather-standard.js?v=2.0")
+ $.getScript('https://apip.weatherdt.com/standard/static/js/weather-standard.js?v=2.0');
}
}
@@ -470,19 +470,19 @@ document.addEventListener('DOMContentLoaded', () => {
`;
}
- $(".joe_owo__contain").html(`
+ $('.joe_owo__contain').html(`
OωO
- `)
+ `);
$(document).on('click', function () {
$('.joe_owo__contain .box').stop().slideUp('fast');
});
$('.joe_owo__contain .seat').on('click', function (e) {
e.stopPropagation();
- $(this).siblings('.box').stop().slideToggle('fast')
+ $(this).siblings('.box').stop().slideToggle('fast');
});
$('.joe_owo__contain .box .bar .item').on('click', function (e) {
e.stopPropagation();
diff --git a/core/function.php b/core/function.php
index 42f2565..0ec0de3 100644
--- a/core/function.php
+++ b/core/function.php
@@ -3,234 +3,234 @@
/* 获取主题当前版本号 */
function _getVersion()
{
- return "5.3.5";
+ return "5.3.6";
};
/* 判断是否是手机 */
function _isMobile()
{
- if (isset($_SERVER['HTTP_X_WAP_PROFILE']))
- return true;
- if (isset($_SERVER['HTTP_VIA'])) {
- return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
- }
- if (isset($_SERVER['HTTP_USER_AGENT'])) {
- $clientkeywords = array('nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile');
- if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
- return true;
- }
- if (isset($_SERVER['HTTP_ACCEPT'])) {
- if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html')))) {
- return true;
- }
- }
- return false;
+ if (isset($_SERVER['HTTP_X_WAP_PROFILE']))
+ return true;
+ if (isset($_SERVER['HTTP_VIA'])) {
+ return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
+ }
+ if (isset($_SERVER['HTTP_USER_AGENT'])) {
+ $clientkeywords = array('nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile');
+ if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
+ return true;
+ }
+ if (isset($_SERVER['HTTP_ACCEPT'])) {
+ if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html')))) {
+ return true;
+ }
+ }
+ return false;
}
/* 根据评论agent获取浏览器类型 */
function _getAgentBrowser($agent)
{
- if (preg_match('/MSIE\s([^\s|;]+)/i', $agent, $regs)) {
- $outputer = 'Internet Explore';
- } else if (preg_match('/FireFox\/([^\s]+)/i', $agent, $regs)) {
- $outputer = 'FireFox';
- } else if (preg_match('/Maxthon([\d]*)\/([^\s]+)/i', $agent, $regs)) {
- $outputer = 'MicroSoft Edge';
- } else if (preg_match('#360([a-zA-Z0-9.]+)#i', $agent, $regs)) {
- $outputer = '360 Fast Browser';
- } else if (preg_match('/Edge([\d]*)\/([^\s]+)/i', $agent, $regs)) {
- $outputer = 'MicroSoft Edge';
- } else if (preg_match('/UC/i', $agent)) {
- $outputer = 'UC Browser';
- } else if (preg_match('/QQ/i', $agent, $regs) || preg_match('/QQ Browser\/([^\s]+)/i', $agent, $regs)) {
- $outputer = 'QQ Browser';
- } else if (preg_match('/UBrowser/i', $agent, $regs)) {
- $outputer = 'UC Browser';
- } else if (preg_match('/Opera[\s|\/]([^\s]+)/i', $agent, $regs)) {
- $outputer = 'Opera';
- } else if (preg_match('/Chrome([\d]*)\/([^\s]+)/i', $agent, $regs)) {
- $outputer = 'Google Chrome';
- } else if (preg_match('/safari\/([^\s]+)/i', $agent, $regs)) {
- $outputer = 'Safari';
- } else {
- $outputer = 'Google Chrome';
- }
- echo $outputer;
+ if (preg_match('/MSIE\s([^\s|;]+)/i', $agent, $regs)) {
+ $outputer = 'Internet Explore';
+ } else if (preg_match('/FireFox\/([^\s]+)/i', $agent, $regs)) {
+ $outputer = 'FireFox';
+ } else if (preg_match('/Maxthon([\d]*)\/([^\s]+)/i', $agent, $regs)) {
+ $outputer = 'MicroSoft Edge';
+ } else if (preg_match('#360([a-zA-Z0-9.]+)#i', $agent, $regs)) {
+ $outputer = '360 Fast Browser';
+ } else if (preg_match('/Edge([\d]*)\/([^\s]+)/i', $agent, $regs)) {
+ $outputer = 'MicroSoft Edge';
+ } else if (preg_match('/UC/i', $agent)) {
+ $outputer = 'UC Browser';
+ } else if (preg_match('/QQ/i', $agent, $regs) || preg_match('/QQ Browser\/([^\s]+)/i', $agent, $regs)) {
+ $outputer = 'QQ Browser';
+ } else if (preg_match('/UBrowser/i', $agent, $regs)) {
+ $outputer = 'UC Browser';
+ } else if (preg_match('/Opera[\s|\/]([^\s]+)/i', $agent, $regs)) {
+ $outputer = 'Opera';
+ } else if (preg_match('/Chrome([\d]*)\/([^\s]+)/i', $agent, $regs)) {
+ $outputer = 'Google Chrome';
+ } else if (preg_match('/safari\/([^\s]+)/i', $agent, $regs)) {
+ $outputer = 'Safari';
+ } else {
+ $outputer = 'Google Chrome';
+ }
+ echo $outputer;
}
/* 根据评论agent获取设备类型 */
function _getAgentOS($agent)
{
- $os = "Linux";
- if (preg_match('/win/i', $agent)) {
- if (preg_match('/nt 6.0/i', $agent)) {
- $os = 'Windows Vista';
- } else if (preg_match('/nt 6.1/i', $agent)) {
- $os = 'Windows 7';
- } else if (preg_match('/nt 6.2/i', $agent)) {
- $os = 'Windows 8';
- } else if (preg_match('/nt 6.3/i', $agent)) {
- $os = 'Windows 8.1';
- } else if (preg_match('/nt 5.1/i', $agent)) {
- $os = 'Windows XP';
- } else if (preg_match('/nt 10.0/i', $agent)) {
- $os = 'Windows 10';
- } else {
- $os = 'Windows X64';
- }
- } else if (preg_match('/android/i', $agent)) {
- if (preg_match('/android 9/i', $agent)) {
- $os = 'Android Pie';
- } else if (preg_match('/android 8/i', $agent)) {
- $os = 'Android Oreo';
- } else {
- $os = 'Android';
- }
- } else if (preg_match('/ubuntu/i', $agent)) {
- $os = 'Ubuntu';
- } else if (preg_match('/linux/i', $agent)) {
- $os = 'Linux';
- } else if (preg_match('/iPhone/i', $agent)) {
- $os = 'iPhone';
- } else if (preg_match('/mac/i', $agent)) {
- $os = 'MacOS';
- } else if (preg_match('/fusion/i', $agent)) {
- $os = 'Android';
- } else {
- $os = 'Linux';
- }
- echo $os;
+ $os = "Linux";
+ if (preg_match('/win/i', $agent)) {
+ if (preg_match('/nt 6.0/i', $agent)) {
+ $os = 'Windows Vista';
+ } else if (preg_match('/nt 6.1/i', $agent)) {
+ $os = 'Windows 7';
+ } else if (preg_match('/nt 6.2/i', $agent)) {
+ $os = 'Windows 8';
+ } else if (preg_match('/nt 6.3/i', $agent)) {
+ $os = 'Windows 8.1';
+ } else if (preg_match('/nt 5.1/i', $agent)) {
+ $os = 'Windows XP';
+ } else if (preg_match('/nt 10.0/i', $agent)) {
+ $os = 'Windows 10';
+ } else {
+ $os = 'Windows X64';
+ }
+ } else if (preg_match('/android/i', $agent)) {
+ if (preg_match('/android 9/i', $agent)) {
+ $os = 'Android Pie';
+ } else if (preg_match('/android 8/i', $agent)) {
+ $os = 'Android Oreo';
+ } else {
+ $os = 'Android';
+ }
+ } else if (preg_match('/ubuntu/i', $agent)) {
+ $os = 'Ubuntu';
+ } else if (preg_match('/linux/i', $agent)) {
+ $os = 'Linux';
+ } else if (preg_match('/iPhone/i', $agent)) {
+ $os = 'iPhone';
+ } else if (preg_match('/mac/i', $agent)) {
+ $os = 'MacOS';
+ } else if (preg_match('/fusion/i', $agent)) {
+ $os = 'Android';
+ } else {
+ $os = 'Linux';
+ }
+ echo $os;
}
/* 获取全局懒加载图 */
function _getLazyload($type = true)
{
- if ($type) echo Helper::options()->JLazyload;
- else return Helper::options()->JLazyload;
+ if ($type) echo Helper::options()->JLazyload;
+ else return Helper::options()->JLazyload;
}
/* 获取头像懒加载图 */
function _getAvatarLazyload($type = true)
{
- if ($type) echo "https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/img/lazyload_avatar.gif";
- else return "https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/img/lazyload_avatar.gif";
+ if ($type) echo "https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/img/lazyload_avatar.gif";
+ else return "https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/img/lazyload_avatar.gif";
}
/* 查询文章浏览量 */
function _getViews($item, $type = true)
{
- $db = Typecho_Db::get();
- $result = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $item->cid))['views'];
- if ($type) echo number_format($result);
- else return number_format($result);
+ $db = Typecho_Db::get();
+ $result = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $item->cid))['views'];
+ if ($type) echo number_format($result);
+ else return number_format($result);
}
/* 查询文章点赞量 */
function _getAgree($item, $type = true)
{
- $db = Typecho_Db::get();
- $result = $db->fetchRow($db->select('agree')->from('table.contents')->where('cid = ?', $item->cid))['agree'];
- if ($type) echo number_format($result);
- else return number_format($result);
+ $db = Typecho_Db::get();
+ $result = $db->fetchRow($db->select('agree')->from('table.contents')->where('cid = ?', $item->cid))['agree'];
+ if ($type) echo number_format($result);
+ else return number_format($result);
}
/* 页面开始计时 */
function _startCountTime()
{
- global $timeStart;
- $mTime = explode(' ', microtime());
- $timeStart = $mTime[1] + $mTime[0];
- return true;
+ global $timeStart;
+ $mTime = explode(' ', microtime());
+ $timeStart = $mTime[1] + $mTime[0];
+ return true;
}
/* 页面结束计时 */
function _endCountTime($precision = 3)
{
- global $timeStart, $timeEnd;
- $mTime = explode(' ', microtime());
- $timeEnd = $mTime[1] + $mTime[0];
- $timeTotal = number_format($timeEnd - $timeStart, $precision);
- echo $timeTotal < 1 ? $timeTotal * 1000 . 'ms' : $timeTotal . 's';
+ global $timeStart, $timeEnd;
+ $mTime = explode(' ', microtime());
+ $timeEnd = $mTime[1] + $mTime[0];
+ $timeTotal = number_format($timeEnd - $timeStart, $precision);
+ echo $timeTotal < 1 ? $timeTotal * 1000 . 'ms' : $timeTotal . 's';
}
/* 通过邮箱生成头像地址 */
function _getAvatarByMail($mail)
{
- $gravatarsUrl = 'https://gravatar.helingqi.com/wavatar/';
- $mailLower = strtolower($mail);
- $md5MailLower = md5($mailLower);
- $qqMail = str_replace('@qq.com', '', $mailLower);
- if (strstr($mailLower, "qq.com") && is_numeric($qqMail) && strlen($qqMail) < 11 && strlen($qqMail) > 4) {
- echo 'https://thirdqq.qlogo.cn/g?b=qq&nk=' . $qqMail . '&s=100';
- } else {
- echo $gravatarsUrl . $md5MailLower . '?d=mm';
- }
+ $gravatarsUrl = 'https://gravatar.helingqi.com/wavatar/';
+ $mailLower = strtolower($mail);
+ $md5MailLower = md5($mailLower);
+ $qqMail = str_replace('@qq.com', '', $mailLower);
+ if (strstr($mailLower, "qq.com") && is_numeric($qqMail) && strlen($qqMail) < 11 && strlen($qqMail) > 4) {
+ echo 'https://thirdqq.qlogo.cn/g?b=qq&nk=' . $qqMail . '&s=100';
+ } else {
+ echo $gravatarsUrl . $md5MailLower . '?d=mm';
+ }
};
/* 获取侧边栏随机一言 */
function _getAsideAuthorMotto()
{
- $JMottoRandom = explode("\r\n", Helper::options()->JAside_Author_Motto);
- echo $JMottoRandom[array_rand($JMottoRandom, 1)];
+ $JMottoRandom = explode("\r\n", Helper::options()->JAside_Author_Motto);
+ echo $JMottoRandom[array_rand($JMottoRandom, 1)];
}
/* 获取文章摘要 */
function _getAbstract($item, $type = true)
{
- $abstract = "";
- if ($item->password) {
- $abstract = "加密文章,请前往内页查看详情";
- } else {
- if ($item->fields->abstract) {
- $abstract = $item->fields->abstract;
- } else {
- $abstract = Typecho_Common::subStr(strip_tags($item->excerpt), 0, 180, '...');;
- }
- }
- if ($abstract === '') $abstract = "暂无简介";
- if ($type) echo $abstract;
- else return $abstract;
+ $abstract = "";
+ if ($item->password) {
+ $abstract = "加密文章,请前往内页查看详情";
+ } else {
+ if ($item->fields->abstract) {
+ $abstract = $item->fields->abstract;
+ } else {
+ $abstract = Typecho_Common::subStr(strip_tags($item->excerpt), 0, 180, '...');;
+ }
+ }
+ if ($abstract === '') $abstract = "暂无简介";
+ if ($type) echo $abstract;
+ else return $abstract;
}
/* 获取列表缩略图 */
function _getThumbnails($item)
{
- $result = [];
- $pattern = '/\]*>/i';
- $patternMD = '/\!\[.*?\]\((http(s)?:\/\/.*?(jpg|jpeg|gif|png|webp))/i';
- $patternMDfoot = '/\[.*?\]:\s*(http(s)?:\/\/.*?(jpg|jpeg|gif|png|webp))/i';
- /* 如果填写了自定义缩略图,则优先显示填写的缩略图 */
- if ($item->fields->thumb) {
- $fields_thumb_arr = explode("\r\n", $item->fields->thumb);
- foreach ($fields_thumb_arr as $list) $result[] = $list;
- }
- /* 如果匹配到正则,则继续补充匹配到的图片 */
- if (preg_match_all($pattern, $item->content, $thumbUrl)) {
- foreach ($thumbUrl[1] as $list) $result[] = $list;
- }
- if (preg_match_all($patternMD, $item->content, $thumbUrl)) {
- foreach ($thumbUrl[1] as $list) $result[] = $list;
- }
- if (preg_match_all($patternMDfoot, $item->content, $thumbUrl)) {
- foreach ($thumbUrl[1] as $list) $result[] = $list;
- }
- /* 如果上面的数量不足3个,则直接补充3个随即图进去 */
- if (sizeof($result) < 3) {
- $custom_thumbnail = Helper::options()->JThumbnail;
- /* 将for循环放里面,减少一次if判断 */
- if ($custom_thumbnail) {
- $custom_thumbnail_arr = explode("\r\n", $custom_thumbnail);
- for ($i = 0; $i < 3; $i++) {
- $result[] = $custom_thumbnail_arr[array_rand($custom_thumbnail_arr, 1)] . "?key=" . mt_rand(0, 1000000);
- }
- } else {
- for ($i = 0; $i < 3; $i++) {
- $result[] = 'https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/thumb/' . rand(1, 42) . '.jpg';
- }
- }
- }
- return $result;
+ $result = [];
+ $pattern = '/\]*>/i';
+ $patternMD = '/\!\[.*?\]\((http(s)?:\/\/.*?(jpg|jpeg|gif|png|webp))/i';
+ $patternMDfoot = '/\[.*?\]:\s*(http(s)?:\/\/.*?(jpg|jpeg|gif|png|webp))/i';
+ /* 如果填写了自定义缩略图,则优先显示填写的缩略图 */
+ if ($item->fields->thumb) {
+ $fields_thumb_arr = explode("\r\n", $item->fields->thumb);
+ foreach ($fields_thumb_arr as $list) $result[] = $list;
+ }
+ /* 如果匹配到正则,则继续补充匹配到的图片 */
+ if (preg_match_all($pattern, $item->content, $thumbUrl)) {
+ foreach ($thumbUrl[1] as $list) $result[] = $list;
+ }
+ if (preg_match_all($patternMD, $item->content, $thumbUrl)) {
+ foreach ($thumbUrl[1] as $list) $result[] = $list;
+ }
+ if (preg_match_all($patternMDfoot, $item->content, $thumbUrl)) {
+ foreach ($thumbUrl[1] as $list) $result[] = $list;
+ }
+ /* 如果上面的数量不足3个,则直接补充3个随即图进去 */
+ if (sizeof($result) < 3) {
+ $custom_thumbnail = Helper::options()->JThumbnail;
+ /* 将for循环放里面,减少一次if判断 */
+ if ($custom_thumbnail) {
+ $custom_thumbnail_arr = explode("\r\n", $custom_thumbnail);
+ for ($i = 0; $i < 3; $i++) {
+ $result[] = $custom_thumbnail_arr[array_rand($custom_thumbnail_arr, 1)] . "?key=" . mt_rand(0, 1000000);
+ }
+ } else {
+ for ($i = 0; $i < 3; $i++) {
+ $result[] = 'https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/thumb/' . rand(1, 42) . '.jpg';
+ }
+ }
+ }
+ return $result;
}
@@ -238,39 +238,39 @@ function _getThumbnails($item)
/* 获取父级评论 */
function _getParentReply($parent)
{
- if ($parent !== "0") {
- $db = Typecho_Db::get();
- $commentInfo = $db->fetchRow($db->select('author')->from('table.comments')->where('coid = ?', $parent));
- echo '@ ' . $commentInfo['author'] . '
';
- }
+ if ($parent !== "0") {
+ $db = Typecho_Db::get();
+ $commentInfo = $db->fetchRow($db->select('author')->from('table.comments')->where('coid = ?', $parent));
+ echo '@ ' . $commentInfo['author'] . '
';
+ }
}
/* 获取侧边栏作者随机文章 */
function _getAsideAuthorNav()
{
- if (Helper::options()->JAside_Author_Nav !== "off") {
- $db = Typecho_Db::get();
- $adapterName = $db->getAdapterName();
- if ($adapterName == 'pgsql' || $adapterName == 'Pdo_Pgsql' || $adapterName == 'Pdo_SQLite' || $adapterName == 'SQLite') {
- $order_by = 'RANDOM()';
- } else {
- $order_by = 'RAND()';
- }
- $result = $db->fetchAll(
- $db->select()
- ->from('table.contents')
- ->where('table.contents.status = ?', 'publish')
- ->where('table.contents.type = ?', 'post')
- ->where("table.contents.password IS NULL OR table.contents.password = ''")
- ->limit(Helper::options()->JAside_Author_Nav)
- ->order($order_by)
- );
- foreach ($result as $item) {
- $obj = Typecho_Widget::widget('Widget_Abstract_Contents');
- $item = $obj->push($item);
- $title = htmlspecialchars($item['title']);
- $permalink = $item['permalink'];
- echo "
+ if (Helper::options()->JAside_Author_Nav !== "off") {
+ $db = Typecho_Db::get();
+ $adapterName = $db->getAdapterName();
+ if ($adapterName == 'pgsql' || $adapterName == 'Pdo_Pgsql' || $adapterName == 'Pdo_SQLite' || $adapterName == 'SQLite') {
+ $order_by = 'RANDOM()';
+ } else {
+ $order_by = 'RAND()';
+ }
+ $result = $db->fetchAll(
+ $db->select()
+ ->from('table.contents')
+ ->where('table.contents.status = ?', 'publish')
+ ->where('table.contents.type = ?', 'post')
+ ->where("table.contents.password IS NULL OR table.contents.password = ''")
+ ->limit(Helper::options()->JAside_Author_Nav)
+ ->order($order_by)
+ );
+ foreach ($result as $item) {
+ $obj = Typecho_Widget::widget('Widget_Abstract_Contents');
+ $item = $obj->push($item);
+ $title = htmlspecialchars($item['title']);
+ $permalink = $item['permalink'];
+ echo "
{$title}
";
- }
- }
+ }
+ }
}
function _curl($url)
{
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- if (strpos($url, 'https') !== false) {
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- }
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ if (strpos($url, 'https') !== false) {
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+ }
+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+ $result = curl_exec($ch);
+ curl_close($ch);
+ return $result;
}
/* 判断敏感词是否在字符串内 */
function _checkSensitiveWords($words_str, $str)
{
- $words = explode("||", $words_str);
- if (empty($words)) {
- return false;
- }
- foreach ($words as $word) {
- if (false !== strpos($str, trim($word))) {
- return true;
- }
- }
- return false;
+ $words = explode("||", $words_str);
+ if (empty($words)) {
+ return false;
+ }
+ foreach ($words as $word) {
+ if (false !== strpos($str, trim($word))) {
+ return true;
+ }
+ }
+ return false;
}
diff --git a/core/short.php b/core/short.php
index d25a97b..4c9b3e5 100644
--- a/core/short.php
+++ b/core/short.php
@@ -8,124 +8,148 @@ function _parseContent($post, $login)
/* 过滤表情 */
$content = _parseReply($content);
+ /* 过滤默认卡片 */
+ if (strpos($content, '{/card-default}') !== false) {
+ $content = preg_replace_callback(
+ '/\{card-default\s{0,}width="(.{0,})"\s{0,}label="(.{0,})"\s{0,}\}(.{0,})\{\/card-default\}/sSU',
+ function ($matches) {
+ return '
+ ' . $matches[2] . '
+ ' . $matches[3] . '
+
+ ';
+ },
+ $content
+ );
+ }
+
+ /* 过滤消息提示 */
+ if (strpos($content, '{/message}') !== false) {
+ $content = preg_replace_callback(
+ '/\{message\s{0,}type="(success|info|warning|error)"\s{0,}\}(.{0,})\{\/message\}/sSU',
+ function ($matches) {
+ return '
+
+ ' . $matches[2] . '
+
+ ';
+ },
+ $content
+ );
+ }
+
+ /* 过滤note button */
+ if (strpos($content, '{/anote}') !== false) {
+ $content = preg_replace_callback(
+ '/\{anote\s{0,}icon="(.{0,})"\s{0,}href="(.{0,})"\s{0,}type="(secondary|success|warning|error|info)"\s{0,}}(.{0,})\{\/anote\}/sSU',
+ function ($matches) {
+ return '
+ ' . $matches[4] . '
+
+ ';
+ },
+ $content
+ );
+ }
+
+ /* 过滤普通button */
+ if (strpos($content, '{/abtn}') !== false) {
+ $content = preg_replace_callback(
+ '/\{abtn\s{0,}icon="(.{0,})"\s{0,}color="(.{0,})"\s{0,}href="(.{0,})"\s{0,}radius="(.{0,})"\s{0,}\}(.{0,})\{\/abtn\}/sSU',
+ function ($matches) {
+ return '
+ ' . $matches[5] . '
+
+ ';
+ },
+ $content
+ );
+ }
+
/* 过滤回复可见 */
- if (preg_match('/\{hide\}.{0,}\{\/hide\}/sSU', $content)) {
+ if (strpos($content, '{/hide}') !== false) {
$db = Typecho_Db::get();
$hasComment = $db->fetchAll($db->select()->from('table.comments')->where('cid = ?', $post->cid)->where('mail = ?', $post->remember('mail', true))->limit(1));
if ($hasComment || $login) {
- $content = preg_replace('/\{hide\}(.{0,})\{\/hide\}/sSU', '$1', $content);
+ $content = strtr($content, array("{hide}" => "", "{/hide}" => ""));
} else {
- $content = preg_replace('/\{hide\}(.{0,})\{\/hide\}/sSU', '此处内容作者设置了 回复 可见', $content);
+ $content = preg_replace_callback(
+ '/\{hide\}.{0,}\{\/hide\}/sSU',
+ function () {
+ return '此处内容作者设置了 回复 可见';
+ },
+ $content
+ );
}
}
- /* 过滤网易云音乐歌单 */
- if (preg_match('/\{music-list\s{0,}id="\d{0,}"\s{0,}\/\}/SU', $content)) {
- $content = preg_replace(
- '/\{music-list\s{0,}id="(\d{0,})"\s{0,}\/\}/SU',
- '',
- $content
- );
- }
- /* 过滤网易云音乐单首歌 */
- if (preg_match('/\{music\s{0,}id="\d{0,}"\s{0,}\/\}/SU', $content)) {
- $content = preg_replace(
- '/\{music\s{0,}id="(\d{0,})"\s{0,}\/\}/SU',
- '',
+
+ /* 过滤网易云音乐 */
+ if (strpos($content, '{music') !== false) {
+ $content = preg_replace_callback(
+ '/\{music-list\s{0,}id="(\w{0,})"\s{0,}\/\}/SU',
+ function ($matches) {
+ return '';
+ },
+ $content
+ );
+ $content = preg_replace_callback(
+ '/\{music\s{0,}id="(\w{0,})"\s{0,}\/\}/SU',
+ function ($matches) {
+ return '';
+ },
$content
);
}
+
/* 过滤dplayer播放器 */
- if (preg_match('/\{dplayer\s{0,}src=".{0,}"\s{0,}\/\}/sSU', $content)) {
- $player = Helper::options()->JCustomPlayer ? Helper::options()->JCustomPlayer : '/usr/themes/Joe/library/player.php?url=';
- $content = preg_replace(
+ if (strpos($content, '{dplayer') !== false) {
+ $content = preg_replace_callback(
'/\{dplayer\s{0,}src="(.{0,})"\s{0,}\/\}/sSU',
- '',
+ function ($matches) {
+ $player = Helper::options()->JCustomPlayer ? Helper::options()->JCustomPlayer : '/usr/themes/Joe/library/player.php?url=';
+ return '';
+ },
$content
);
}
+
/* 过滤bilibili播放器 */
- if (preg_match('/\{bilibili\s{0,}bvid="\w{0,}"\s{0,}\/\}/sSU', $content)) {
- $content = preg_replace(
+ if (strpos($content, '{bilibili') !== false) {
+ $content = preg_replace_callback(
'/\{bilibili\s{0,}bvid="(\w{0,})"\s{0,}\/\}/sSU',
- '',
+ function ($matches) {
+ return '';
+ },
$content
);
}
+
/* 过滤完成任务勾选 */
- if (preg_match('/\{x\}/SU', $content)) {
- $content = preg_replace(
- '/\{x\}/SU',
- '',
- $content
- );
- }
- /* 过滤未完成任务勾选 */
- if (preg_match('/\{\s{1}\}/SU', $content)) {
- $content = preg_replace(
- '/\{\s{1}\}/SU',
- '',
- $content
- );
- }
- /* 过滤默认卡片 */
- if (preg_match('/\{card-default\s{0,}width=".{0,}"\s{0,}label=".{0,}"\s{0,}\}.{0,}\{\/card-default\}/sSU', $content)) {
- $content = preg_replace(
- '/\{card-default\s{0,}width="(.{0,})"\s{0,}label="(.{0,})"\s{0,}\}(.{0,})\{\/card-default\}/sSU',
- '
- $2
- $3
- ',
- $content
- );
- }
- /* 过滤消息提示 */
- if (preg_match('/\{message\s{0,}type="success|info|warning|error"\s{0,}\}.{0,}\{\/message\}/sSU', $content)) {
- $content = preg_replace(
- '/\{message\s{0,}type="(success|info|warning|error)"\s{0,}\}(.{0,})\{\/message\}/sSU',
- '
-
- $2
- ',
- $content
- );
- }
- /* 过滤居中标题 */
- if (preg_match('/\{mtitle\}.{0,}\{\/mtitle\}/sSU', $content)) {
- $content = preg_replace(
- '/\{mtitle\}(.{0,})\{\/mtitle\}/sSU',
- '
- $1
- ',
- $content
- );
- }
- /* 过滤note button */
- if (preg_match('/\{anote\s{0,}icon=".{0,}"\s{0,}href=".{0,}"\s{0,}type="secondary|success|warning|error|info"\s{0,}}.{0,}\{\/anote\}/sSU', $content)) {
- $content = preg_replace(
- '/\{anote\s{0,}icon="(.{0,})"\s{0,}href="(.{0,})"\s{0,}type="(secondary|success|warning|error|info)"\s{0,}}(.{0,})\{\/anote\}/sSU',
- '
- $4
- ',
- $content
- );
- }
- /* 过滤note button */
- if (preg_match('/\{abtn\s{0,}icon=".{0,}"\s{0,}color=".{0,}"\s{0,}href=".{0,}"\s{0,}radius=".{0,}"\s{0,}\}.{0,}\{\/abtn\}/sSU', $content)) {
- $content = preg_replace(
- '/\{abtn\s{0,}icon="(.{0,})"\s{0,}color="(.{0,})"\s{0,}href="(.{0,})"\s{0,}radius="(.{0,})"\s{0,}\}(.{0,})\{\/abtn\}/sSU',
- '
- $5
- ',
- $content
- );
+ if (strpos($content, '{x}') !== false || strpos($content, '{ }') !== false) {
+ $content = strtr($content, array(
+ "{x}" => '',
+ "{ }" => ''
+ ));
}
+
/* 过滤复制粘贴功能 */
- if (preg_match('/\{copy\s{0,}text=".{0,}"\s{0,}\}.{0,}\{\/copy\}/sSU', $content)) {
- $content = preg_replace(
+ if (strpos($content, '{/copy}') !== false) {
+ $content = preg_replace_callback(
'/\{copy\s{0,}text="(.{0,})"\s{0,}\}(.{0,})\{\/copy\}/sSU',
- '$2',
+ function ($matches) {
+ return '' . $matches[2] . '';
+ },
$content
);
}
+
+ /* 过滤居中标题 */
+ if (strpos($content, '{/mtitle}') !== false) {
+ $content = strtr($content, array(
+ "{mtitle}" => '',
+ "{/mtitle}" => ''
+ ));
+ }
+
echo $content;
}
diff --git a/friends.php b/friends.php
index ac7b7dd..ab7c93a 100644
--- a/friends.php
+++ b/friends.php
@@ -18,7 +18,7 @@
-
+