Preminder Beta后台程序源码

Preminder Beta后台程序源码,用PHP-CLI写的(什么是PHP-CLI?)加了些注释,大家可以看一下。最有意思就是HashURL时的$SEED,其实获取PR是不符合Google的服务条款的,很汗的吧……
写好脚本之后,在/etc/crontab里加入一条每小时执行的计划,就可以啦,在这里可以看到PR检测日志

27 *    * * *   root    /usr/bin/php -f /home/kangzj/kang.php


数据库的结构为:


— 表的结构 logs

CREATE TABLE logs (
  ID int(11) NOT NULL auto_increment,
  info varchar(150) NOT NULL,
  utime bigint(11) NOT NULL,
  PRIMARY KEY  (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;

— 表的结构 users

CREATE TABLE users (
  ID int(11) NOT NULL auto_increment,
  email varchar(50) NOT NULL,
  domain varchar(100) NOT NULL,
  pr tinyint(2) NOT NULL,
  lastcheck timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

< ?
//随机取5个PR低的域名进行检测,如果有PR变化则继续检测所有域名,否则退出程序
//测试集的大小
$testSetSize = 5;
//connect to mysql
$conn  = mysql_connect('localhost','preminder','111') or die('error');
mysql_select_db('preminder');
$result = mysql_query("select email, domain, pr from users where pr<=3  order by RAND() limit $testSetSize");
//计数
$i=0;
while($row = mysql_fetch_array($result))
{
	$nowpr = intval(pagerank($row['domain']));
	// $nowpr.' '.$row['pr'];
	if($nowpr != $row['pr']){
		break;
	}
	$i++;
	sleep(1);
}
if($i == $testSetSize){
             //写日志
	mysql_query("INSERT OR REPLACE into logs (utime, info) values ('".time()."','No pr updates detected!')");
            //没有更新退出程序
	exit;//no updates
}
//and there's pr update
$up=0;
$down=0;
$same=0;
$logs="domaintfromtton";
$result = mysql_query('select email, domain, pr from users');
while($row = mysql_fetch_array($result))
{
        $nowpr = intval(pagerank($row['domain']));
	$email = $row['email'];
	$domain = $row['domain'];
	$pr = $row['pr'];
	if($nowpr != $pr)
	        mysql_query("update users set pr='$nowpr' where email='$email' and domain='$domain'");
 	$subject = '您的'.$domain.'的PR由'.$pr.'更新为'.$nowpr;
	$message = '亲爱的'.$email.',

  您的域名'.$domain.'的pr由'.$pr.'更新为'.$nowpr; $headers = $headers = "MIME-Version: 1.0rnContent-type: text/html; rn charset="utf-8"rn".'From: noreply@kangzj.net' . "rn" . 'Reply-To: kangzj@kangzj.net' . "rn" . 'X-Mailer: PHP/' . phpversion(); if($nowpr>$pr) { $up++; $message.=',恭喜!'; }elseif($nowpr< $pr) { $down++; $message.=',降低了...'; }else { $same++; $message.=',没有变化哦。'; } $message.='

             http://kangzj.net敬上

'; mail($email, $subject, $message, $headers); $logs .= "$domaint$prt$nowprtn"; sleep(1); } $fname = './'.date("Y-m-d-H-i-s", time()).'.log'; //写文件更新日志,含所有域名PR变化情况 file_put_contents($fname, $logs); //更新日志 mysql_query("INSERT OR REPLACE into logs (info, utime) values ('$up domains PR rose, $down domains PR dropped, $same domains PR remained the same.','" .time()."')"); //检测PR函数 /* *encode the url */ function HashURL($url) {$SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer."; $Result = 0x01020345; for ($i=0; $i> 23) & 0x1FF) | $Result < < 9; } return sprintf("8%x", $Result); } /* *get pagerank */ function pagerank($domain) { $StartURL = "http://www.google.com/search?client=navclient-auto&googleip=0;973&ie=UTF-8&oe=UTF-8&features=Rank&q=info:"; $GoogleURL = $StartURL.$domain. '&ch='.HashURL($domain); $fcontents = file_get_contents("$GoogleURL"); $pagerank = substr($fcontents,9); return intval($pagerank); } ?>

Posted

in

by

Comments

20 responses to “Preminder Beta后台程序源码”

  1. Shily Avatar

    偶也破解了下 看来也不符合服务条款了…

  2. japan style Avatar

    A lot of thanks for your own efforts on this web site. My niece take interest in getting into internet research and it is obvious why. Most of us know all relating to the lively medium you make functional secrets on your web site and even boost contribution from others about this situation plus our favorite child is now becoming educated a great deal. Take pleasure in the rest of the new year. You are always performing a very good job.

  3. […] 这个错误的演示地址:http://kangzj.net/preminder-beta-source-code/ […]

  4. Louis Han Avatar

    看到别人说更新了我再去查。。。

    1. kangzj Avatar

      @Louis Han, 呵呵,终于更新了啊

  5. Lc. Avatar

    不错。学习了。HashURL这个看不懂。
    PS:有几行太长了,都看不到后面的。

  6. Hobo Avatar

    谢谢分享了

    1. kangzj Avatar

      @Hobo, 谢谢支持了

  7. sdpfoue Avatar

    pr这种东西,设成1小时执行一次太浪费了吧。1天一次足够用了

    1. kangzj Avatar

      @sdpfoue, 就是想在第一时间嘛,呵呵;一个小时确实有点短,先改成四个小时试试

  8. maple's sky Avatar

    有意思的小东西, 研究下…

    1. kangzj Avatar

      @maple’s sky, 自己无聊的时候做的,呵呵

  9. houkai Avatar

    看了你定置的文章 下载了那个查看pr的代码 就一个index。php 还没仔细学习呢。
    你的代码又放出来了,继续学 :)

    1. kangzj Avatar

      @houkai, 呵呵,没有什么技术含量;你python很熟吧?

  10. Lxhome Avatar

    这个……这个,我看不懂!

    1. kangzj Avatar

      @Lxhome, 有人问过是怎么做的,于是乎就把代码贴出来了,学下php就会了,很简单的

  11. Leo.N Avatar

    高手。。。。我是理解不透这些东西。。。

    1. kangzj Avatar

      不是高手,代码很简单的,呵呵

  12. 阿东 Avatar

    这个是随时更新PR值吗。。。看不太懂。

    1. kangzj Avatar

      嗯,就是监测PR的后台程序

Leave a Reply