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 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', () => {
</ul>
`;
}
$(".joe_owo__contain").html(`
$('.joe_owo__contain').html(`
<div class="seat">OωO</div>
<div class="box">
${scrollStr}
<div class="bar">${barStr}</div>
</div>
`)
`);
$(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();

View File

@ -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 = '/\<img.*?src\=\"(.*?)\"[^>]*>/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 = '/\<img.*?src\=\"(.*?)\"[^>]*>/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 '<div class="parent"><span style="vertical-align: 1px;">@</span> ' . $commentInfo['author'] . '</div>';
}
if ($parent !== "0") {
$db = Typecho_Db::get();
$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>';
}
}
/* 获取侧边栏作者随机文章 */
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 "
<li class='item'>
<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'>
@ -278,36 +278,36 @@ function _getAsideAuthorNav()
</svg>
</li>
";
}
}
}
}
}
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;
}

View File

@ -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 '<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();
$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', '<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(
'/\{music-list\s{0,}id="(\d{0,})"\s{0,}\/\}/SU',
'<iframe class="lazyload" data-src="//music.163.com/outchain/player?type=0&id=$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(
'/\{music\s{0,}id="(\d{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>',
/* 过滤网易云音乐 */
if (strpos($content, '{music') !== false) {
$content = preg_replace_callback(
'/\{music-list\s{0,}id="(\w{0,})"\s{0,}\/\}/SU',
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
);
$content = preg_replace_callback(
'/\{music\s{0,}id="(\w{0,})"\s{0,}\/\}/SU',
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
);
}
/* 过滤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',
'<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
);
}
/* 过滤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',
'<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
);
}
/* 过滤完成任务勾选 */
if (preg_match('/\{x\}/SU', $content)) {
$content = preg_replace(
'/\{x\}/SU',
'<input type="checkbox" class="joe_detail__article-checkbox" checked 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 (strpos($content, '{x}') !== false || strpos($content, '{ }') !== false) {
$content = strtr($content, array(
"{x}" => '<input type="checkbox" class="joe_detail__article-checkbox" checked disabled></input>',
"{ }" => '<input type="checkbox" class="joe_detail__article-checkbox" disabled></input>'
));
}
/* 过滤复制粘贴功能 */
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',
'<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
);
}
/* 过滤居中标题 */
if (strpos($content, '{/mtitle}') !== false) {
$content = strtr($content, array(
"{mtitle}" => '<span class="joe_detail__article-mtitle"><span class="text">',
"{/mtitle}" => '</span></span>'
));
}
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">
<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="<?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>
<body>