i漂泊

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3825|回复: 0

PHP获取Google PR值 方法二

[复制链接]
TA的礼物信息
  • 收到:0
  • 送出:2
发表于 2013-3-18 20:52:39 | 显示全部楼层 |阅读模式
  1. 这是一款用来检测网站pr值的源码了,下载后直接就会可以使用的哦。
复制代码
  1. function my_file_get_contents($url, $timeout=30) {
  2. if ( function_exists('curl_init') ) {
  3.   $ch = curl_init();
  4.   curl_setopt ($ch, CURLOPT_URL, $url);
  5.   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  6.   curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  7.   $file_contents = curl_exec($ch);
  8.   curl_close($ch);
  9. } else if ( ini_get('allow_url_fopen') == 1 || strtolower(ini_get('allow_url_fopen')) == 'on' ) {
  10.   $file_contents = @file_get_contents($url);
  11. } else {
  12.   $file_contents = '';
  13. }
  14. return $file_contents;
  15. }
  16. // 开始检查
  17. if( isset($_GET['mod']) && $_GET['mod'] == 'check_now' && isset($_GET['id']) && isset($_GET['my_url']) && isset($_GET['url']) && isset($_GET['auto_check']) ){
  18. $js_id = 'parent.document.getElementById("s_' . $_GET['id'] . '").innerHTML';
  19. if( strstr($_GET['url'],$_GET['my_url']) ) {
  20.    echo '<script>' . $js_id . ' = "内部链接";</script>';
  21. } else if( !stristr($_GET['url'],'http://') ) {
  22.    echo '<script>' . $js_id . ' = "错误链接";</script>';
  23. } else {
  24.   $s = my_file_get_contents($_GET['url']);
  25.   if( trim($s) == '' ){
  26.    echo '<script>' . $js_id . ' = "抓取内容失败";</script>';
  27.   } else  if( stristr($s,$_GET['my_url']) ){
  28.    echo '<script>' . $js_id . ' = "<font color=green>包含链接,检查通过</font>";</script>';
  29.   } else {
  30.    echo '<script>' . $js_id . ' = "<font color=red>没有找到链接,请核查</font>";</script>';
  31.   }
  32. }
  33. if($_GET['auto_check']==1){
  34.   echo '<script>parent.checkLink(' . ($_GET['id']+1) . ');</script>';
  35. }
  36. exit('
  37. done!');

  38. }
  39. ?>
  40. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  41. <html xmlns="http://www.w3.org/1999/xhtml">
  42. <head>
  43.   <title>《做网站》友情链接自动检查程序</title>
  44.   <meta name="generator" content="editplus" />
  45.   <meta name="author" content="www.zuowangzhang.com.cn" />

  46.   <meta name="description" content="我们很BS这样的人,当时双方都交换了首页链接,但对方却随意取消和您交换的友情链接(即对方去掉您网站的链接,而您却还保留了它的链接)有了本程序,您可以快速、自动的检查您的友情链接网址,查看对方的网站是否去掉了您的链接。" />
  47. <style>
  48. body,td{font-size:9pt;font-family:arial;}
  49. a:link,a:visited{color:blue;}
  50. a:hover{color:red;}
  51. A.black:link,A.black:visited{color:black;text-decoration: none;}
  52. .main_tb {width:580px;}
  53. .main_tb .tb_title {background-color: #CCFFFF;}
  54. .main_tb .tr_title {background-color: #A6D9D2;height:40px;}
  55. </style>
  56. <base target=_blank></base>
  57. </head>
  58. <body>
  59. <iframe src="about:blank" width=0  height=0 name="hidden_iframe" id="hidden_iframe"></iframe>
  60. <script type="text/javascript">
  61. <!--
  62. my_url = '';
  63. checking_str = "正在检查...";
  64. check_time_out = 25000;
  65. auto_check = 0;

  66. function checkZuoWangZhang() {
  67. var all_code = window.frames["zuoWangZhang.com.cn"].document.body.innerHTML;
  68. if(all_code.indexOf('http://') ==-1){
  69.   alert("请直接将您网站的文字和图片链接复制Ctrl+c,粘贴Ctrl+v进来 ");
  70.   return false;
  71. }
  72. if(f.my_url.value.indexOf('.') ==-1){
  73.   alert("请输入您的网站首页地址");
  74.   return false;
  75. }
  76. if(f.my_url.value.indexOf('http://') ==-1){
  77.   f.my_url.value = 'http://' + f.my_url.value;
  78. }
  79. if( f.my_url.value.substr(f.my_url.value.length-1,1) == '/' ) {
  80.   f.my_url.value = f.my_url.value.substr(0,f.my_url.value.length-1);
  81. }
  82. f.html_code.value = all_code;
  83. return true;
  84. }
  85. function checkTimeout(id) {
  86. if(document.getElementById('s_'+id).innerHTML!=checking_str){
  87.   return false;
  88. }
  89. document.getElementById('s_'+id).innerHTML = "可能超时,<a href='#' onclick='return checkLink("+id+");'>重新检查</a>";
  90. if(auto_check==1){
  91.   checkLink((id+1));
  92. }
  93. return true;
  94. }
  95. function checkLink(id) {
  96. if(document.getElementById('s_'+id)==null){
  97.   auto_check = 0;
  98.   return false;
  99. }
  100. if( auto_check==1 && document.getElementById('s_'+id).innerHTML.indexOf('超时')!=-1 ){
  101.   alert("请等自动检查全部结束以后,再进行操作!");
  102.   return false;
  103. }
  104. document.getElementById('hidden_iframe').src = 'check_links.php?mod=check_now&url=' + escape(document.getElementById('u_'+id).href) + '&id=' + id + '&my_url='+ escape(my_url) + '&auto_check=' + auto_check + '';
  105. document.getElementById('s_'+id).innerHTML = checking_str;
  106. setTimeout("checkTimeout("+id+")",check_time_out);
  107. return false;
  108. }
  109. function autoCheckLink(id) {
  110. checkLink(id);
  111. //setTimeout("checkLink("+(id+1)+")",(check_time_out+1000));
  112. }
  113. //-->
  114. </script>

  115. <center>
  116. <h4>友情链接自动检查程序</h4>
  117. 我们很BS这样的人,当时双方都交换了首页链接,但对方却随意取消和您交换的友情链接(即对方去掉您网站的链接,而您却还保留了它的链接)



  118. 有了本程序,您可以快速、自动的检查您的友情链接网址,查看对方的网站是否去掉了您的链接。


  119. <?php
  120. // 显示获取到的链接地址
  121. if( isset($_POST['html_code']) && isset($_POST['my_url']) ){

  122. preg_match_all("/<a[strn]{1,}[^<]{0,}href=["']{0,}(https?://.*)[strn"'>]{1,}/isU",stripslashes($_POST['html_code']),$ary);
  123. if( isset($ary[1]) && count($ary[1])>0 ){
  124.   echo '<table bordercolordark="#ffffff" align="center" bordercolorlight="#000000" border="1"  cellspacing="0" cellpadding="4" class=main_tb><tr><td colspan=10 class=tb_title> <font size="4" ><b>开始检查</b></font>
  125.   

  126.    检查下列网址是否包含有 <font color=green>' . $_POST['my_url'] . '</font> 的链接
  127.   </td></tr>
  128.   <tr class=tr_title>
  129.    <td>序号</td>
  130.    <td align=left>被检查的网址</td>
  131.    <td >检查结果</td>
  132.    </tr>
  133.   ';
  134.   for($i=0; $i<count($ary[1]); $i++){
  135.    
  136.    $check_str = ($_POST['auto_check']==0) ? '<a href="#" onclick="return checkLink(' . $i . ');">开始检查</a>' : '<font color=gray>等待中...</font>';
  137.    echo '<tr>
  138.    <td>' . ($i+1) . '.</td>
  139.    <td align=left><a href="' . $ary[1][$i] . '" id=u_' . $i . '  target=_blank>' . $ary[1][$i] . '</a></td>
  140.    <td id=s_' . $i . '>' . $check_str . '</td>
  141.    </tr>';
  142.    if($i>$max_allow_links){
  143.     break;
  144.    }
  145.   }
  146.   echo '</table>';
  147. }
  148. echo '<script>my_url="' . trim($_POST['my_url']) . '";auto_check=' . (int)$_POST['auto_check'] . ';</script>';
  149. if( $_POST['auto_check']==1 ){
  150.   echo '<script>autoCheckLink(0);</script>';
  151. }

  152. }
  153. ?>

  154. <form method="post" action="check_links.php" name="formZuoWangZhang" target=_top>
  155. 必须包含地址(自己网站首页):<input type="text" name="my_url" size=50 value="<?php if(isset($_POST['my_url'])){echo $_POST['my_url'];}?>" />


  156. 自动或手工检查:<select name="auto_check"><option value=1>自动</option><option value=0>手工</option></select>



  157. 要检查的网站(下面是可视化输入框,请直接将文字链接和图片链接复制,粘贴 到下面即可):

  158. <iframe id="zuoWangZhang.com.cn" name="zuoWangZhang.com.cn" height="150" width="600" style="padding:0px;"></iframe>
  159. <script>window.frames["zuoWangZhang.com.cn"].document.designMode="On";</script>




  160. <input type="hidden" name="html_code" />

  161. <table width=600>
  162. <tr>
  163.   <td width=100 align=center> </td>
  164.   <td width=400 align=center><input type="submit" onclick="return checkZuoWangZhang();" value="  开始检查  " /></td>
  165.   <td width=100 align=right><a href=# onclick="return setTestLinks(this);">载入测试数据</a>
  166. </td>
  167. </tr>
  168. </table>




  169. 如果您不知道怎么开始,请点击 <a href=# onclick="return setTestLinks(this);">载入测试数据</a>,然后点击 <input type="submit" onclick="return checkZuoWangZhang();" value="开始检查" style="height:19px;" /> 查看演示





  170. <!-- 欢迎转载,但请保留下面的文字和链接,修改链接会被BS,谢谢合作 -->
  171. 本程序由《<A HREF="http://www.ZuoWangZhanG.com.cn/" class=black>做网站</a>》原创,完全开源!<a href="http://www.zuowangzhang.com.cn/download/check_links.zip">下载</a>


  172. 欢迎各位转载,但请保留<A HREF="http://www.ZuoWangZhang.com.cn/ZuoWangZhan/RuHeZuoWangZhan/"  class=black>如何做网站</a>的文字,谢谢!



  173. 欢迎您 <a href="http://www.zuowangzhang.com.cn/hbcms/user/add_msg.php?to_user_id=1&to_user_name=网站管理员" target=_blank>给作者提出反馈意见</a>,我会不断的改善它,推出更好用的版本。
  174. </form>
  175. <script type="text/javascript">
  176. f = document.formZuoWangZhang;
  177. </script>

  178. </center>
  179. <?php
  180. if(isset($_POST['html_code'])){
  181. echo '
  182. <div id=old_links style="display:none;">
  183. ' . stripslashes($_POST['html_code']) . '
  184. </div>
  185. <script type="text/javascript">
  186. function setOldLinks() {
  187.   window.frames["zuoWangZhang.com.cn"].document.body.innerHTML = document.getElementById("old_links").innerHTML;
  188.   document.getElementById("old_links").innerHTML = "";
  189. }
  190. setTimeout("setOldLinks()",3000);
  191. </script>';

  192. }

  193. ?>

  194. <p> </p>






  195. <span id=test_links>
  196. <TABLE align=center  cellpadding='1' cellspacing='0' style="font-size:9pt;">
  197. <TR >
  198. <TD colspan="6">
  199. 我的友情连接:
  200. </td><TD colspan=2>
  201. <div align=right>
  202. </td></tr><tr>
  203. <!-- 文字链接 -->
  204. <td>
  205. <A HREF="http://www.hao123.com/">Hao123
  206. </td>
  207.    <td>
  208. <A HREF="http://www.265.com/">265
  209. </td>
  210.    <td>
  211. <A HREF="http://site.baidu.com/">百度网址
  212. </td>
  213.    <td>
  214. <A HREF="http://www.zuoWANGZHANG.com.cn/">建网站</a>
  215. </td>
  216.    <td>
  217. <a class="l" href="http://site.yahoo.com.cn/" target="_blank">雅虎网址</a>

  218. </td>
  219.    <td>
  220. <A HREF="http://www.baidu.com/">baidu
  221. </td>
  222.    <td>
  223. <a  href="http://daohang.google.cn/" target="_blank">Google导航</a>
  224. </td>  
  225.   </tr>
  226. <!-- 图片链接 -->
  227. <tr>

  228.    <td>
  229. <A HREF="http://www.lian123.com/"><img src="http://cn.yimg.com/sp/yahoohp060323/logo_yahoo.gif" width=88 height=31 border=0  ></A>
  230. </td>
  231.    <td>
  232. <A HREF="http://www.yisou.com/"><img src="http://static.php.net/www.php.net/images/logos/php-power-white.gif" width=88 height=31 border=0 ></A>
  233. </td>
  234.    <td>
  235. <A HREF="http://www.google.cn/"><img src="http://www.mysql.com/common/logos/mysql_100x52-64.gif" width=88 height=31 border=0  ></A>
  236. </td>
  237. <td>

  238.    <td>
  239. <A HREF="http://www.jipiaojiage.cn/"><img src="http://image2.sina.com.cn/home/images/sina_logo2.gif" width=88 height=31 border=0  ></A>
  240. </td>
  241.    <td>
  242. <A HREF="http://www.google.com/"><img src="http://www.google.com/logos/lunarnewyear03.gif" width=88 height=31 border=0 alt="谷歌Google"></A>
  243. </td>
  244.   <td>
  245. <a class="l"   href="http://123.sogou.com/" target="_blank">搜狗网址</a>
  246. </td>
  247.   </tr>
  248.   <tr><td colspan=10>
  249. 其他测试链接:
  250. <a href="http://www.163.com/">163内部链接测试</a>
  251.   </td></tr>
  252. </TABLE>

  253. </span>

  254. <script type="text/javascript">
  255. <!--
  256. document.write('<sty'+'le>#te'+'st_li'+'nks {disp'+'lay:no'+'ne;}</sty'+'le>');
  257. function setTestLinks(t) {
  258. window.frames["zuoWangZhang.com.cn"].document.body.innerHTML = document.getElementById('test_links').innerHTML;
  259. document.getElementById('test_links').innerHTML = '';
  260. f.my_url.value = 'http://www.111cn.cn/';
  261. return false;
  262. }



  263. //-->
  264. </script>
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|IPiaoBo Inc. ( 渝ICP备17002826号 )

GMT+8, 2024-4-29 10:28 , Processed in 0.075453 second(s), 47 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表