1.修改friends.php文件
文件路径:Joe-master/
1.第一段
<?php
$max_allow_links = 100; // 最大许可检查的链接数目
function my_file_get_contents($url, $timeout = 30) {
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
} else if (ini_get('allow_url_fopen') == 1 || strtolower(ini_get('allow_url_fopen')) == 'on') {
$file_contents = @file_get_contents($url);
} else {
$file_contents = '';
}
return $file_contents;
}
function isExistsContentUrl($url, &$retMsg, $mydomain = "") {
if (!isset($url) || empty($url)) {
$retMsg = "配置URL为空";
return false;
}
if (!isset($mydomain) || empty($mydomain)) {
$mydomain = $_SERVER['SERVER_NAME'];
}
$resultContent = my_file_get_contents($url);
if (trim($resultContent) == '') {
$retMsg = "网站无法访问";
return false;
}
if (strripos($resultContent, $mydomain)) {
$retMsg = "友链正常";
return true;
} else {
$retMsg = "未添加本站";
return false;
}
}
?>
2.第二段
$friendsUrl = explode("||", $friends_arr[$i])[4];
if($friendsUrl) {
$friends[] = array("name" => trim($name), "url" => trim($url), "avatar" => trim($avatar), "desc" => trim($desc),
"friendsUrl" => trim($friendsUrl));
}
else {
$friends[] = array("name" => trim($name), "url" => trim($url), "avatar" => trim($avatar), "desc" => trim($desc),
"friendsUrl" => trim($url));
}
3.第三段
<span class="title" style="float: right;<?php if(Helper::options()->JFriendsSwitch !== 'on') echo 'display:none;' ?>">
<?php
if(Helper::options()->JFriendsSwitch !== 'off') {
$result = "";
$ret = isExistsContentUrl($item['friendsUrl'], $result, null);
echo $result;
}
?>
</span>
2.修改functions.php文件
文件路径:Joe-master/
$JFriendsSwitch = new Typecho_Widget_Helper_Form_Element_Select(
'JFriendsSwitch',
array('off' => '关闭(默认)', 'on' => '开启'),
'off',
'是否开启友链检测功能',
'介绍:开启后友链界面可以自动检测对方站点是否添加本站友链'
);
$JFriendsSwitch->setAttribute('class', 'joe_content joe_other');
$form->addInput($JFriendsSwitch->multiMode());
$JFriends = new Typecho_Widget_Helper_Form_Element_Textarea(
'JFriends',
NULL,
'Joe的博客 || https://78.al || https://cdn.jsdelivr.net/npm/[email protected]/assets/img/link.png || Eternity is not a distance but a decision || 友链页面地址(可不填写)',
'友情链接(非必填)',
'介绍:用于填写友情链接 <br />
注意:您需要先增加友联链接页面(新增独立页面-右侧模板选择友联),该项才会生效 <br />
格式:博客名称 || 博客地址 || 博客头像 || 博客简介 || 友链页面地址 <br />
其他:一行一个,一行代表一个友联'
);
$JFriends->setAttribute('class', 'joe_content joe_other');
$form->addInput($JFriends);
3.增加友链链接
在主题中开启此功能后,需要在友链配置最后增加一个友链界面的链接,如果没有友链页面可不添加
本文来自执念博客
© 版权声明
分享是一种美德,转载请保留原链接
THE END
- 最新
- 最热
只看作者