This commit is contained in:
杜恒 2021-02-21 17:45:35 +08:00
parent 2e670269a6
commit 138f29c95b
4 changed files with 334 additions and 310 deletions

View File

@ -160,7 +160,7 @@ document.addEventListener('DOMContentLoaded', () => {
const style = $('.joe_aside__item.weather').attr('data-style'); const style = $('.joe_aside__item.weather').attr('data-style');
const aqiColor = { 1: 'FFFFFF', 2: '4A4A4A', 3: 'FFFFFF' }; 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 } }; 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', () => {
</ul> </ul>
`; `;
} }
$(".joe_owo__contain").html(` $('.joe_owo__contain').html(`
<div class="seat">OωO</div> <div class="seat">OωO</div>
<div class="box"> <div class="box">
${scrollStr} ${scrollStr}
<div class="bar">${barStr}</div> <div class="bar">${barStr}</div>
</div> </div>
`) `);
$(document).on('click', function () { $(document).on('click', function () {
$('.joe_owo__contain .box').stop().slideUp('fast'); $('.joe_owo__contain .box').stop().slideUp('fast');
}); });
$('.joe_owo__contain .seat').on('click', function (e) { $('.joe_owo__contain .seat').on('click', function (e) {
e.stopPropagation(); e.stopPropagation();
$(this).siblings('.box').stop().slideToggle('fast') $(this).siblings('.box').stop().slideToggle('fast');
}); });
$('.joe_owo__contain .box .bar .item').on('click', function (e) { $('.joe_owo__contain .box .bar .item').on('click', function (e) {
e.stopPropagation(); e.stopPropagation();

View File

@ -3,234 +3,234 @@
/* 获取主题当前版本号 */ /* 获取主题当前版本号 */
function _getVersion() function _getVersion()
{ {
return "5.3.5"; return "5.3.6";
}; };
/* 判断是否是手机 */ /* 判断是否是手机 */
function _isMobile() function _isMobile()
{ {
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) if (isset($_SERVER['HTTP_X_WAP_PROFILE']))
return true; return true;
if (isset($_SERVER['HTTP_VIA'])) { if (isset($_SERVER['HTTP_VIA'])) {
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false; return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
} }
if (isset($_SERVER['HTTP_USER_AGENT'])) { 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'); $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']))) if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
return true; return true;
} }
if (isset($_SERVER['HTTP_ACCEPT'])) { 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')))) { 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 true;
} }
} }
return false; return false;
} }
/* 根据评论agent获取浏览器类型 */ /* 根据评论agent获取浏览器类型 */
function _getAgentBrowser($agent) function _getAgentBrowser($agent)
{ {
if (preg_match('/MSIE\s([^\s|;]+)/i', $agent, $regs)) { if (preg_match('/MSIE\s([^\s|;]+)/i', $agent, $regs)) {
$outputer = 'Internet Explore'; $outputer = 'Internet Explore';
} else if (preg_match('/FireFox\/([^\s]+)/i', $agent, $regs)) { } else if (preg_match('/FireFox\/([^\s]+)/i', $agent, $regs)) {
$outputer = 'FireFox'; $outputer = 'FireFox';
} else if (preg_match('/Maxthon([\d]*)\/([^\s]+)/i', $agent, $regs)) { } else if (preg_match('/Maxthon([\d]*)\/([^\s]+)/i', $agent, $regs)) {
$outputer = 'MicroSoft Edge'; $outputer = 'MicroSoft Edge';
} else if (preg_match('#360([a-zA-Z0-9.]+)#i', $agent, $regs)) { } else if (preg_match('#360([a-zA-Z0-9.]+)#i', $agent, $regs)) {
$outputer = '360 Fast Browser'; $outputer = '360 Fast Browser';
} else if (preg_match('/Edge([\d]*)\/([^\s]+)/i', $agent, $regs)) { } else if (preg_match('/Edge([\d]*)\/([^\s]+)/i', $agent, $regs)) {
$outputer = 'MicroSoft Edge'; $outputer = 'MicroSoft Edge';
} else if (preg_match('/UC/i', $agent)) { } else if (preg_match('/UC/i', $agent)) {
$outputer = 'UC Browser'; $outputer = 'UC Browser';
} else if (preg_match('/QQ/i', $agent, $regs) || preg_match('/QQ Browser\/([^\s]+)/i', $agent, $regs)) { } else if (preg_match('/QQ/i', $agent, $regs) || preg_match('/QQ Browser\/([^\s]+)/i', $agent, $regs)) {
$outputer = 'QQ Browser'; $outputer = 'QQ Browser';
} else if (preg_match('/UBrowser/i', $agent, $regs)) { } else if (preg_match('/UBrowser/i', $agent, $regs)) {
$outputer = 'UC Browser'; $outputer = 'UC Browser';
} else if (preg_match('/Opera[\s|\/]([^\s]+)/i', $agent, $regs)) { } else if (preg_match('/Opera[\s|\/]([^\s]+)/i', $agent, $regs)) {
$outputer = 'Opera'; $outputer = 'Opera';
} else if (preg_match('/Chrome([\d]*)\/([^\s]+)/i', $agent, $regs)) { } else if (preg_match('/Chrome([\d]*)\/([^\s]+)/i', $agent, $regs)) {
$outputer = 'Google Chrome'; $outputer = 'Google Chrome';
} else if (preg_match('/safari\/([^\s]+)/i', $agent, $regs)) { } else if (preg_match('/safari\/([^\s]+)/i', $agent, $regs)) {
$outputer = 'Safari'; $outputer = 'Safari';
} else { } else {
$outputer = 'Google Chrome'; $outputer = 'Google Chrome';
} }
echo $outputer; echo $outputer;
} }
/* 根据评论agent获取设备类型 */ /* 根据评论agent获取设备类型 */
function _getAgentOS($agent) function _getAgentOS($agent)
{ {
$os = "Linux"; $os = "Linux";
if (preg_match('/win/i', $agent)) { if (preg_match('/win/i', $agent)) {
if (preg_match('/nt 6.0/i', $agent)) { if (preg_match('/nt 6.0/i', $agent)) {
$os = 'Windows Vista'; $os = 'Windows Vista';
} else if (preg_match('/nt 6.1/i', $agent)) { } else if (preg_match('/nt 6.1/i', $agent)) {
$os = 'Windows 7'; $os = 'Windows 7';
} else if (preg_match('/nt 6.2/i', $agent)) { } else if (preg_match('/nt 6.2/i', $agent)) {
$os = 'Windows 8'; $os = 'Windows 8';
} else if (preg_match('/nt 6.3/i', $agent)) { } else if (preg_match('/nt 6.3/i', $agent)) {
$os = 'Windows 8.1'; $os = 'Windows 8.1';
} else if (preg_match('/nt 5.1/i', $agent)) { } else if (preg_match('/nt 5.1/i', $agent)) {
$os = 'Windows XP'; $os = 'Windows XP';
} else if (preg_match('/nt 10.0/i', $agent)) { } else if (preg_match('/nt 10.0/i', $agent)) {
$os = 'Windows 10'; $os = 'Windows 10';
} else { } else {
$os = 'Windows X64'; $os = 'Windows X64';
} }
} else if (preg_match('/android/i', $agent)) { } else if (preg_match('/android/i', $agent)) {
if (preg_match('/android 9/i', $agent)) { if (preg_match('/android 9/i', $agent)) {
$os = 'Android Pie'; $os = 'Android Pie';
} else if (preg_match('/android 8/i', $agent)) { } else if (preg_match('/android 8/i', $agent)) {
$os = 'Android Oreo'; $os = 'Android Oreo';
} else { } else {
$os = 'Android'; $os = 'Android';
} }
} else if (preg_match('/ubuntu/i', $agent)) { } else if (preg_match('/ubuntu/i', $agent)) {
$os = 'Ubuntu'; $os = 'Ubuntu';
} else if (preg_match('/linux/i', $agent)) { } else if (preg_match('/linux/i', $agent)) {
$os = 'Linux'; $os = 'Linux';
} else if (preg_match('/iPhone/i', $agent)) { } else if (preg_match('/iPhone/i', $agent)) {
$os = 'iPhone'; $os = 'iPhone';
} else if (preg_match('/mac/i', $agent)) { } else if (preg_match('/mac/i', $agent)) {
$os = 'MacOS'; $os = 'MacOS';
} else if (preg_match('/fusion/i', $agent)) { } else if (preg_match('/fusion/i', $agent)) {
$os = 'Android'; $os = 'Android';
} else { } else {
$os = 'Linux'; $os = 'Linux';
} }
echo $os; echo $os;
} }
/* 获取全局懒加载图 */ /* 获取全局懒加载图 */
function _getLazyload($type = true) function _getLazyload($type = true)
{ {
if ($type) echo Helper::options()->JLazyload; if ($type) echo Helper::options()->JLazyload;
else return Helper::options()->JLazyload; else return Helper::options()->JLazyload;
} }
/* 获取头像懒加载图 */ /* 获取头像懒加载图 */
function _getAvatarLazyload($type = true) function _getAvatarLazyload($type = true)
{ {
if ($type) echo "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"; else return "https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/img/lazyload_avatar.gif";
} }
/* 查询文章浏览量 */ /* 查询文章浏览量 */
function _getViews($item, $type = true) function _getViews($item, $type = true)
{ {
$db = Typecho_Db::get(); $db = Typecho_Db::get();
$result = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $item->cid))['views']; $result = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $item->cid))['views'];
if ($type) echo number_format($result); if ($type) echo number_format($result);
else return number_format($result); else return number_format($result);
} }
/* 查询文章点赞量 */ /* 查询文章点赞量 */
function _getAgree($item, $type = true) function _getAgree($item, $type = true)
{ {
$db = Typecho_Db::get(); $db = Typecho_Db::get();
$result = $db->fetchRow($db->select('agree')->from('table.contents')->where('cid = ?', $item->cid))['agree']; $result = $db->fetchRow($db->select('agree')->from('table.contents')->where('cid = ?', $item->cid))['agree'];
if ($type) echo number_format($result); if ($type) echo number_format($result);
else return number_format($result); else return number_format($result);
} }
/* 页面开始计时 */ /* 页面开始计时 */
function _startCountTime() function _startCountTime()
{ {
global $timeStart; global $timeStart;
$mTime = explode(' ', microtime()); $mTime = explode(' ', microtime());
$timeStart = $mTime[1] + $mTime[0]; $timeStart = $mTime[1] + $mTime[0];
return true; return true;
} }
/* 页面结束计时 */ /* 页面结束计时 */
function _endCountTime($precision = 3) function _endCountTime($precision = 3)
{ {
global $timeStart, $timeEnd; global $timeStart, $timeEnd;
$mTime = explode(' ', microtime()); $mTime = explode(' ', microtime());
$timeEnd = $mTime[1] + $mTime[0]; $timeEnd = $mTime[1] + $mTime[0];
$timeTotal = number_format($timeEnd - $timeStart, $precision); $timeTotal = number_format($timeEnd - $timeStart, $precision);
echo $timeTotal < 1 ? $timeTotal * 1000 . 'ms' : $timeTotal . 's'; echo $timeTotal < 1 ? $timeTotal * 1000 . 'ms' : $timeTotal . 's';
} }
/* 通过邮箱生成头像地址 */ /* 通过邮箱生成头像地址 */
function _getAvatarByMail($mail) function _getAvatarByMail($mail)
{ {
$gravatarsUrl = 'https://gravatar.helingqi.com/wavatar/'; $gravatarsUrl = 'https://gravatar.helingqi.com/wavatar/';
$mailLower = strtolower($mail); $mailLower = strtolower($mail);
$md5MailLower = md5($mailLower); $md5MailLower = md5($mailLower);
$qqMail = str_replace('@qq.com', '', $mailLower); $qqMail = str_replace('@qq.com', '', $mailLower);
if (strstr($mailLower, "qq.com") && is_numeric($qqMail) && strlen($qqMail) < 11 && strlen($qqMail) > 4) { 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'; echo 'https://thirdqq.qlogo.cn/g?b=qq&nk=' . $qqMail . '&s=100';
} else { } else {
echo $gravatarsUrl . $md5MailLower . '?d=mm'; echo $gravatarsUrl . $md5MailLower . '?d=mm';
} }
}; };
/* 获取侧边栏随机一言 */ /* 获取侧边栏随机一言 */
function _getAsideAuthorMotto() function _getAsideAuthorMotto()
{ {
$JMottoRandom = explode("\r\n", Helper::options()->JAside_Author_Motto); $JMottoRandom = explode("\r\n", Helper::options()->JAside_Author_Motto);
echo $JMottoRandom[array_rand($JMottoRandom, 1)]; echo $JMottoRandom[array_rand($JMottoRandom, 1)];
} }
/* 获取文章摘要 */ /* 获取文章摘要 */
function _getAbstract($item, $type = true) function _getAbstract($item, $type = true)
{ {
$abstract = ""; $abstract = "";
if ($item->password) { if ($item->password) {
$abstract = "加密文章,请前往内页查看详情"; $abstract = "加密文章,请前往内页查看详情";
} else { } else {
if ($item->fields->abstract) { if ($item->fields->abstract) {
$abstract = $item->fields->abstract; $abstract = $item->fields->abstract;
} else { } else {
$abstract = Typecho_Common::subStr(strip_tags($item->excerpt), 0, 180, '...');; $abstract = Typecho_Common::subStr(strip_tags($item->excerpt), 0, 180, '...');;
} }
} }
if ($abstract === '') $abstract = "暂无简介"; if ($abstract === '') $abstract = "暂无简介";
if ($type) echo $abstract; if ($type) echo $abstract;
else return $abstract; else return $abstract;
} }
/* 获取列表缩略图 */ /* 获取列表缩略图 */
function _getThumbnails($item) function _getThumbnails($item)
{ {
$result = []; $result = [];
$pattern = '/\<img.*?src\=\"(.*?)\"[^>]*>/i'; $pattern = '/\<img.*?src\=\"(.*?)\"[^>]*>/i';
$patternMD = '/\!\[.*?\]\((http(s)?:\/\/.*?(jpg|jpeg|gif|png|webp))/i'; $patternMD = '/\!\[.*?\]\((http(s)?:\/\/.*?(jpg|jpeg|gif|png|webp))/i';
$patternMDfoot = '/\[.*?\]:\s*(http(s)?:\/\/.*?(jpg|jpeg|gif|png|webp))/i'; $patternMDfoot = '/\[.*?\]:\s*(http(s)?:\/\/.*?(jpg|jpeg|gif|png|webp))/i';
/* 如果填写了自定义缩略图,则优先显示填写的缩略图 */ /* 如果填写了自定义缩略图,则优先显示填写的缩略图 */
if ($item->fields->thumb) { if ($item->fields->thumb) {
$fields_thumb_arr = explode("\r\n", $item->fields->thumb); $fields_thumb_arr = explode("\r\n", $item->fields->thumb);
foreach ($fields_thumb_arr as $list) $result[] = $list; foreach ($fields_thumb_arr as $list) $result[] = $list;
} }
/* 如果匹配到正则,则继续补充匹配到的图片 */ /* 如果匹配到正则,则继续补充匹配到的图片 */
if (preg_match_all($pattern, $item->content, $thumbUrl)) { if (preg_match_all($pattern, $item->content, $thumbUrl)) {
foreach ($thumbUrl[1] as $list) $result[] = $list; foreach ($thumbUrl[1] as $list) $result[] = $list;
} }
if (preg_match_all($patternMD, $item->content, $thumbUrl)) { if (preg_match_all($patternMD, $item->content, $thumbUrl)) {
foreach ($thumbUrl[1] as $list) $result[] = $list; foreach ($thumbUrl[1] as $list) $result[] = $list;
} }
if (preg_match_all($patternMDfoot, $item->content, $thumbUrl)) { if (preg_match_all($patternMDfoot, $item->content, $thumbUrl)) {
foreach ($thumbUrl[1] as $list) $result[] = $list; foreach ($thumbUrl[1] as $list) $result[] = $list;
} }
/* 如果上面的数量不足3个则直接补充3个随即图进去 */ /* 如果上面的数量不足3个则直接补充3个随即图进去 */
if (sizeof($result) < 3) { if (sizeof($result) < 3) {
$custom_thumbnail = Helper::options()->JThumbnail; $custom_thumbnail = Helper::options()->JThumbnail;
/* 将for循环放里面减少一次if判断 */ /* 将for循环放里面减少一次if判断 */
if ($custom_thumbnail) { if ($custom_thumbnail) {
$custom_thumbnail_arr = explode("\r\n", $custom_thumbnail); $custom_thumbnail_arr = explode("\r\n", $custom_thumbnail);
for ($i = 0; $i < 3; $i++) { for ($i = 0; $i < 3; $i++) {
$result[] = $custom_thumbnail_arr[array_rand($custom_thumbnail_arr, 1)] . "?key=" . mt_rand(0, 1000000); $result[] = $custom_thumbnail_arr[array_rand($custom_thumbnail_arr, 1)] . "?key=" . mt_rand(0, 1000000);
} }
} else { } else {
for ($i = 0; $i < 3; $i++) { for ($i = 0; $i < 3; $i++) {
$result[] = 'https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/thumb/' . rand(1, 42) . '.jpg'; $result[] = 'https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/thumb/' . rand(1, 42) . '.jpg';
} }
} }
} }
return $result; return $result;
} }
@ -238,39 +238,39 @@ function _getThumbnails($item)
/* 获取父级评论 */ /* 获取父级评论 */
function _getParentReply($parent) function _getParentReply($parent)
{ {
if ($parent !== "0") { if ($parent !== "0") {
$db = Typecho_Db::get(); $db = Typecho_Db::get();
$commentInfo = $db->fetchRow($db->select('author')->from('table.comments')->where('coid = ?', $parent)); $commentInfo = $db->fetchRow($db->select('author')->from('table.comments')->where('coid = ?', $parent));
echo '<div class="parent"><span style="vertical-align: 1px;">@</span> ' . $commentInfo['author'] . '</div>'; echo '<div class="parent"><span style="vertical-align: 1px;">@</span> ' . $commentInfo['author'] . '</div>';
} }
} }
/* 获取侧边栏作者随机文章 */ /* 获取侧边栏作者随机文章 */
function _getAsideAuthorNav() function _getAsideAuthorNav()
{ {
if (Helper::options()->JAside_Author_Nav !== "off") { if (Helper::options()->JAside_Author_Nav !== "off") {
$db = Typecho_Db::get(); $db = Typecho_Db::get();
$adapterName = $db->getAdapterName(); $adapterName = $db->getAdapterName();
if ($adapterName == 'pgsql' || $adapterName == 'Pdo_Pgsql' || $adapterName == 'Pdo_SQLite' || $adapterName == 'SQLite') { if ($adapterName == 'pgsql' || $adapterName == 'Pdo_Pgsql' || $adapterName == 'Pdo_SQLite' || $adapterName == 'SQLite') {
$order_by = 'RANDOM()'; $order_by = 'RANDOM()';
} else { } else {
$order_by = 'RAND()'; $order_by = 'RAND()';
} }
$result = $db->fetchAll( $result = $db->fetchAll(
$db->select() $db->select()
->from('table.contents') ->from('table.contents')
->where('table.contents.status = ?', 'publish') ->where('table.contents.status = ?', 'publish')
->where('table.contents.type = ?', 'post') ->where('table.contents.type = ?', 'post')
->where("table.contents.password IS NULL OR table.contents.password = ''") ->where("table.contents.password IS NULL OR table.contents.password = ''")
->limit(Helper::options()->JAside_Author_Nav) ->limit(Helper::options()->JAside_Author_Nav)
->order($order_by) ->order($order_by)
); );
foreach ($result as $item) { foreach ($result as $item) {
$obj = Typecho_Widget::widget('Widget_Abstract_Contents'); $obj = Typecho_Widget::widget('Widget_Abstract_Contents');
$item = $obj->push($item); $item = $obj->push($item);
$title = htmlspecialchars($item['title']); $title = htmlspecialchars($item['title']);
$permalink = $item['permalink']; $permalink = $item['permalink'];
echo " echo "
<li class='item'> <li class='item'>
<a class='link' href='{$permalink}' title='{$title}'>{$title}</a> <a class='link' href='{$permalink}' title='{$title}'>{$title}</a>
<svg class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' width='16' height='16'> <svg class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' width='16' height='16'>
@ -278,36 +278,36 @@ function _getAsideAuthorNav()
</svg> </svg>
</li> </li>
"; ";
} }
} }
} }
function _curl($url) function _curl($url)
{ {
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (strpos($url, 'https') !== false) { if (strpos($url, 'https') !== false) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
} }
curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$result = curl_exec($ch); $result = curl_exec($ch);
curl_close($ch); curl_close($ch);
return $result; return $result;
} }
/* 判断敏感词是否在字符串内 */ /* 判断敏感词是否在字符串内 */
function _checkSensitiveWords($words_str, $str) function _checkSensitiveWords($words_str, $str)
{ {
$words = explode("||", $words_str); $words = explode("||", $words_str);
if (empty($words)) { if (empty($words)) {
return false; return false;
} }
foreach ($words as $word) { foreach ($words as $word) {
if (false !== strpos($str, trim($word))) { if (false !== strpos($str, trim($word))) {
return true; return true;
} }
} }
return false; return false;
} }

View File

@ -8,124 +8,148 @@ function _parseContent($post, $login)
/* 过滤表情 */ /* 过滤表情 */
$content = _parseReply($content); $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 '<span class="joe_detail__article-card block" style="width: ' . $matches[1] . '">
<span class="title block">' . $matches[2] . '</span>
<span class="content block">' . $matches[3] . '</span>
</span>
';
},
$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 '<span class="joe_detail__article-message block ' . $matches[1] . '">
<span class="icon"></span>
<span class="content">' . $matches[2] . '</span>
</span>
';
},
$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 '<a class="joe_detail__article-anote ' . $matches[3] . '" href="' . $matches[2] . '" target="_blank" rel="noopener noreferrer nofollow">
<span class="icon"><i class="fa ' . $matches[1] . '"></i></span><span class="content">' . $matches[4] . '</span>
</a>
';
},
$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 '<a class="joe_detail__article-abtn" style="background: ' . $matches[2] . '; border-radius: ' . $matches[4] . '" href="' . $matches[3] . '" target="_blank" rel="noopener noreferrer nofollow">
<span class="icon"><i class="' . $matches[1] . ' fa"></i></span><span class="content">' . $matches[5] . '</span>
</a>
';
},
$content
);
}
/* 过滤回复可见 */ /* 过滤回复可见 */
if (preg_match('/\{hide\}.{0,}\{\/hide\}/sSU', $content)) { if (strpos($content, '{/hide}') !== false) {
$db = Typecho_Db::get(); $db = Typecho_Db::get();
$hasComment = $db->fetchAll($db->select()->from('table.comments')->where('cid = ?', $post->cid)->where('mail = ?', $post->remember('mail', true))->limit(1)); $hasComment = $db->fetchAll($db->select()->from('table.comments')->where('cid = ?', $post->cid)->where('mail = ?', $post->remember('mail', true))->limit(1));
if ($hasComment || $login) { if ($hasComment || $login) {
$content = preg_replace('/\{hide\}(.{0,})\{\/hide\}/sSU', '$1', $content); $content = strtr($content, array("{hide}" => "", "{/hide}" => ""));
} else { } else {
$content = preg_replace('/\{hide\}(.{0,})\{\/hide\}/sSU', '<span class="joe_detail__article-hide block">此处内容作者设置了 <i>回复</i> 可见</span>', $content); $content = preg_replace_callback(
'/\{hide\}.{0,}\{\/hide\}/sSU',
function () {
return '<span class="joe_detail__article-hide block">此处内容作者设置了 <i>回复</i> 可见</span>';
},
$content
);
} }
} }
/* 过滤网易云音乐歌单 */
if (preg_match('/\{music-list\s{0,}id="\d{0,}"\s{0,}\/\}/SU', $content)) { /* 过滤网易云音乐 */
$content = preg_replace( if (strpos($content, '{music') !== false) {
'/\{music-list\s{0,}id="(\d{0,})"\s{0,}\/\}/SU', $content = preg_replace_callback(
'<iframe class="lazyload" data-src="//music.163.com/outchain/player?type=0&id=$1&auto=1&height=430" width="330" height="450"></iframe>', '/\{music-list\s{0,}id="(\w{0,})"\s{0,}\/\}/SU',
$content function ($matches) {
); return '<iframe class="lazyload" data-src="//music.163.com/outchain/player?type=0&id=' . $matches[1] . '&auto=1&height=430" width="330" height="450"></iframe>';
} },
/* 过滤网易云音乐单首歌 */ $content
if (preg_match('/\{music\s{0,}id="\d{0,}"\s{0,}\/\}/SU', $content)) { );
$content = preg_replace( $content = preg_replace_callback(
'/\{music\s{0,}id="(\d{0,})"\s{0,}\/\}/SU', '/\{music\s{0,}id="(\w{0,})"\s{0,}\/\}/SU',
'<iframe class="lazyload" data-src="//music.163.com/outchain/player?type=2&id=$1&auto=1&height=66" width="330" height="86"></iframe>', function ($matches) {
return '<iframe class="lazyload" data-src="//music.163.com/outchain/player?type=2&id=' . $matches[1] . '&auto=1&height=66" width="330" height="86"></iframe>';
},
$content $content
); );
} }
/* 过滤dplayer播放器 */ /* 过滤dplayer播放器 */
if (preg_match('/\{dplayer\s{0,}src=".{0,}"\s{0,}\/\}/sSU', $content)) { if (strpos($content, '{dplayer') !== false) {
$player = Helper::options()->JCustomPlayer ? Helper::options()->JCustomPlayer : '/usr/themes/Joe/library/player.php?url='; $content = preg_replace_callback(
$content = preg_replace(
'/\{dplayer\s{0,}src="(.{0,})"\s{0,}\/\}/sSU', '/\{dplayer\s{0,}src="(.{0,})"\s{0,}\/\}/sSU',
'<iframe class="joe_detail__article-player block lazyload" allowfullscreen="true" data-src="' . $player . '$1"></iframe>', function ($matches) {
$player = Helper::options()->JCustomPlayer ? Helper::options()->JCustomPlayer : '/usr/themes/Joe/library/player.php?url=';
return '<iframe class="joe_detail__article-player block lazyload" allowfullscreen="true" data-src="' . $player . $matches[1] . '"></iframe>';
},
$content $content
); );
} }
/* 过滤bilibili播放器 */ /* 过滤bilibili播放器 */
if (preg_match('/\{bilibili\s{0,}bvid="\w{0,}"\s{0,}\/\}/sSU', $content)) { if (strpos($content, '{bilibili') !== false) {
$content = preg_replace( $content = preg_replace_callback(
'/\{bilibili\s{0,}bvid="(\w{0,})"\s{0,}\/\}/sSU', '/\{bilibili\s{0,}bvid="(\w{0,})"\s{0,}\/\}/sSU',
'<iframe class="joe_detail__article-player block lazyload" allowfullscreen="true" data-src="//player.bilibili.com/player.html?bvid=$1"></iframe>', function ($matches) {
return '<iframe class="joe_detail__article-player block lazyload" allowfullscreen="true" data-src="//player.bilibili.com/player.html?bvid=' . $matches[1] . '"></iframe>';
},
$content $content
); );
} }
/* 过滤完成任务勾选 */ /* 过滤完成任务勾选 */
if (preg_match('/\{x\}/SU', $content)) { if (strpos($content, '{x}') !== false || strpos($content, '{ }') !== false) {
$content = preg_replace( $content = strtr($content, array(
'/\{x\}/SU', "{x}" => '<input type="checkbox" class="joe_detail__article-checkbox" checked disabled></input>',
'<input type="checkbox" class="joe_detail__article-checkbox" checked disabled></input>', "{ }" => '<input type="checkbox" class="joe_detail__article-checkbox" disabled></input>'
$content ));
);
}
/* 过滤未完成任务勾选 */
if (preg_match('/\{\s{1}\}/SU', $content)) {
$content = preg_replace(
'/\{\s{1}\}/SU',
'<input type="checkbox" class="joe_detail__article-checkbox" disabled></input>',
$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',
'<span class="joe_detail__article-card block" style="width: $1">
<span class="title block">$2</span>
<span class="content block">$3</span>
</span>',
$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',
'<span class="joe_detail__article-message block $1">
<span class="icon"></span>
<span class="content">$2</span>
</span>',
$content
);
}
/* 过滤居中标题 */
if (preg_match('/\{mtitle\}.{0,}\{\/mtitle\}/sSU', $content)) {
$content = preg_replace(
'/\{mtitle\}(.{0,})\{\/mtitle\}/sSU',
'<span class="joe_detail__article-mtitle">
<span class="text">$1</span>
</span>',
$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',
'<a class="joe_detail__article-anote $3" href="$2" target="_blank" rel="noopener noreferrer nofollow">
<span class="icon"><i class="fa $1"></i></span><span class="content">$4</span>
</a>',
$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',
'<a class="joe_detail__article-abtn" style="background: $2; border-radius: $4" href="$3" target="_blank" rel="noopener noreferrer nofollow">
<span class="icon"><i class="$1 fa"></i></span><span class="content">$5</span>
</a>',
$content
);
} }
/* 过滤复制粘贴功能 */ /* 过滤复制粘贴功能 */
if (preg_match('/\{copy\s{0,}text=".{0,}"\s{0,}\}.{0,}\{\/copy\}/sSU', $content)) { if (strpos($content, '{/copy}') !== false) {
$content = preg_replace( $content = preg_replace_callback(
'/\{copy\s{0,}text="(.{0,})"\s{0,}\}(.{0,})\{\/copy\}/sSU', '/\{copy\s{0,}text="(.{0,})"\s{0,}\}(.{0,})\{\/copy\}/sSU',
'<span data-clipboard-text="$1" class="joe_detail__article-copy">$2</span>', function ($matches) {
return '<span data-clipboard-text="' . $matches[1] . '" class="joe_detail__article-copy">' . $matches[2] . '</span>';
},
$content $content
); );
} }
/* 过滤居中标题 */
if (strpos($content, '{/mtitle}') !== false) {
$content = strtr($content, array(
"{mtitle}" => '<span class="joe_detail__article-mtitle"><span class="text">',
"{/mtitle}" => '</span></span>'
));
}
echo $content; echo $content;
} }

View File

@ -18,7 +18,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-tomorrow.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-tomorrow.css">
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/prism/prism.js"></script> <script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/prism/prism.js"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.post&page.js?v=111'); ?>"></script> <script src="<?php $this->options->themeUrl('assets/js/joe.post&page.js'); ?>"></script>
</head> </head>
<body> <body>