Discuz友情连接自动提取PR,自动检测对方有没有本站的连接
第一步,首先建立一个 /source/function/function_autopr.php<?php第二步,再建立一个 source\include\cron\cron_autolink.php
<?
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
require_once DISCUZ_ROOT.'./source/function/function_autopr.php';
$discuz = & discuz_core::instance();
$myhost = 'http://www.XXXXXXX.com';//你的域名
set_time_limit(1800);
$query = DB::query("select id,url,display from pre_common_friendlink where display=0 and checknum<10");
while($links = DB::fetch($query)) {
$links['url']=strtolower($links['url']);
if(!empty($links['url']) and substr($links['url'],0,4)=="http"){
$htmls=@file_get_contents($links['url']);
}
$website = $links['url'] ;
$website = str_replace("http://","",$website);
$website = str_replace("https://","",$website);
$website = str_replace("/","",$website);
$website = trim($website);
$pr = prget($website);
$pr = str_replace( "\n", "", $pr );
if(substr($htmls,-1) == "/"){
$htmls = str_replace("/","",$htmls);
}
//if( !strstr($htmls,$myhost) ) {
if(!ereg($myhost,$htmls)){
DB::query("update pre_common_friendlink set checknum=checknum+1,pr='".$pr."' where id=".$links['id']);
}else{
if($links["display"]==0){
DB::query("update pre_common_friendlink set display=1,checknum=0,pr=".$pr." where id=".$links['id']);
}
}
}
DB::query("update pre_common_friendlink set display=0 where checknum>7");//七次检查没有,自动隐藏
//DB::query("delete from pre_common_friendlink where checknum>10");//十次检查没有,自动删除。
?>第三步,在数据库表 pre_common_friendlink 增加display,checknum,pr字段
ALTER TABLE pre_common_friendlink ADD `display` smallint(2) unsigned NOT NULL default '0'
ALTER TABLE pre_common_friendlink ADD `checknum` tinyint(3) NOT NULL default '0'
ALTER TABLE pre_common_friendlink ADD `pr` int(11) NOT NULL default '0'第四步,在后台--工具--计划任务添加cron_autolink.php执行一下就可以了。
大功告成。
另外,也可以在添加时,就直接提取对方的PR值。用法:$pr = prget($pr);
这个帖子希望官方能够看到,并完善DZ1.5的友情连接功能里。
X2 RC版本可以吗? 2.0能用吗?还要修改数据库,这个最头疼了 我晕,怎么这么背呀!七个!{:4_107:}
页:
[1]