Php ile网站Bilgilerinin Alınması(Yusuf KOÇ)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Php ile网站Bilgilerinin Alınması(Yusuf KOÇ)相关的知识,希望对你有一定的参考价值。

  1. < ?php
  2. /**
  3.  * Betik Yazarı: Yusuf KOÇ ( Raiden )
  4.  * http://www.ysfkc.com
  5.  *
  6.  * Copyright 2009 ysfkc.com
  7.  * Licensed under the GNU General Public License, version 2.
  8.  * See the file http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
  9.  *
  10.  **/
  11.  
  12. # Read Site
  13. # @access private
  14. # -------------
  15. function getData($site)
  16. {
  17. $ch = curl_init();
  18. curl_setopt($ch,CURLOPT_URL, $site);
  19. curl_setopt($ch,CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; tr-TR; rv:1.9.0.3) Gecko/2008092818 Pardus/2008 Firefox/3.0.4');
  20. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  21. $return = curl_exec($ch);
  22. curl_exec($ch);
  23.  
  24. return $return;
  25. }
  26.  
  27. # Google PageRank
  28. # @access private
  29. # ---------------------
  30. function _StrToNum($Str, $Check, $Magic)
  31. {
  32. $Int32Unit = 4294967296; // 2^32
  33. $length = strlen($Str);
  34. for ($i = 0; $i < $length; $i++) {
  35. $Check *= $Magic;
  36. //If the float is beyond the boundaries of integer (usually +/- 2.15e+9 = 2^31),
  37. // the result of converting to integer is undefined
  38. // refer to http://www.php.net/manual/en/language.types.integer.php
  39. if ($Check >= $Int32Unit) {
  40. $Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
  41. //if the check less than -2^31
  42. $Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
  43. }
  44. $Check += ord($Str{$i});
  45. }
  46. return $Check;
  47. }
  48.  
  49. # Google PageRank
  50. # @access private
  51. # ---------------------
  52. function _HashURL($String)
  53. {
  54. $Check1 = _StrToNum($String, 0x1505, 0x21);
  55. $Check2 = _StrToNum($String, 0, 0x1003F);
  56. $Check1 >>= 2;
  57. $Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
  58. $Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
  59. $Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);
  60.  
  61. $T1 = (((($Check1 & 0x3C0) < < 4) | ($Check1 & 0x3C)) << 2) | ($Check2 & 0xF0F );
  62. $T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );
  63.  
  64. return ($T1 | $T2);
  65. }
  66.  
  67. # Google PageRank
  68. # @access private
  69. # ---------------------
  70. function _CheckHash($Hashnum) {
  71. $CheckByte = 0;
  72. $Flag = 0;
  73. $HashStr = sprintf('%u', $Hashnum) ;
  74. $length = strlen($HashStr);
  75.  
  76. for ($i = $length - 1; $i >= 0; $i --) {
  77. $Re = $HashStr{$i};
  78. if (1 === ($Flag % 2)) {
  79. $Re += $Re;
  80. $Re = (int)($Re / 10) + ($Re % 10);
  81. }
  82. $CheckByte += $Re;
  83. $Flag ++;
  84. }
  85.  
  86. $CheckByte %= 10;
  87. if (0 !== $CheckByte) {
  88. $CheckByte = 10 - $CheckByte;
  89. if (1 === ($Flag % 2) ) {
  90. if (1 === ($CheckByte % 2)) {
  91. $CheckByte += 9;
  92. }
  93. $CheckByte >>= 1;
  94. }
  95. }
  96. return '7'.$CheckByte.$HashStr;
  97. }
  98.  
  99. # Google PageRank
  100. # @access private
  101. # --------------------
  102. function _googlePr($site)
  103. {
  104. $hash = _CheckHash(_HashURL($site));
  105. $url = "http://toolbarqueries.google.com/search?client=navclient-auto&hl=en&ch=".$hash."&ie=UTF-8&oe=UTF-8&features=Rank&q=info:".$site;
  106. $return = getData($url);
  107. echo preg_replace('/Rank_1:.:/','',$return);
  108. }
  109.  
  110. # Google Backlink
  111. # @access private
  112. # --------------------
  113. function _googleBacklink($site)
  114. {
  115. $url = "http://www.google.com.tr/search?hl=tr&q=link:".$site;
  116. $return = getData($url);
  117. preg_match("#.*?<b>(d*)< /b>#sim",$return,$result);
  118. if ($result[1] == null)
  119. {
  120. echo 'Yok';
  121. }
  122. else
  123. {
  124. echo $result[1];
  125. }
  126. }
  127.  
  128. # Google Index
  129. # @access private
  130. # ------------------
  131. function _googleIndex($site)
  132. {
  133. $url = "http://www.google.com.tr/search?hl=tr&q=site:".$site;
  134. $return = getData($url);
  135. preg_match("#.*?(yakla.*?</b><b>(.*?)< /b>|aramas.*?</b><b>(.*?)< /b>).*?#",$return,$result);
  136. echo $result[3];
  137. }
  138.  
  139. # Dmoz Result
  140. # @access private
  141. # --------------------
  142. function _dmoz($site)
  143. {
  144. $url = 'http://search.dmoz.org/cgi-bin/search?search='.str_replace('http://www.','',$site);
  145. $return = getData($url);
  146. preg_match("#.*?<center>(.*).*<b>.*?#",$return,$result);
  147. if (rtrim($result[1]) == 'No')
  148. {
  149. echo 'Yok';
  150. }
  151. else
  152. {
  153. echo 'Var';
  154. }
  155. }
  156.  
  157. # Alexa Rank
  158. # @access private
  159. # -----------------------
  160. function _alexa($url)
  161. {
  162. $url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url='.str_replace('http://','',$url);
  163. $alexa = new SimpleXMLElement($url,NULL,TRUE);
  164. echo number_format($alexa->SD->POPULARITY['TEXT']);
  165. }
  166.  
  167. # Genel Fonksiyon
  168. # @access public
  169. # ------------------
  170. function sonucAl($istek,$url)
  171. {
  172. switch ($istek)
  173. {
  174. case 'googleP': _googlePr($url); break;
  175. case 'googleB': _googleBacklink($url); break;
  176. case 'googleI': _googleIndex($url); break;
  177. case 'alexa': _alexa($url); break;
  178. case 'dmoz': _dmoz($url); break;
  179. }
  180. }
  181. ?>
  182.  
  183.  
  184. /*
  185. Betiğimizde sizin kullanacağınız tek fonksiyon sonucAl() olacaktır. Çünkü diğerleri sonucAl() içinden çağrılmaktadır. Sonuc Fonksiyonumuz ise beş farklı parametre almaktadır.
  186.  
  187. Bunlar;
  188.  
  189.   * googleP: Google pagerank deÄŸeri öğrenilmek istendiÄŸinde kullanılır
  190.   * googleB: Google backlink deÄŸeri öğrenilmek istendiÄŸinde kullanılır
  191.   * googleI: Google index deÄŸeri öğrenilmek istendiÄŸinde kullanılır
  192.   * alexa: Alexa rank deÄŸeri öğrenilmek istendiÄŸinde kullanılır
  193.   * dmoz: Dmoz kaydı öğrenilmek istendiÄŸinde kullanılır
  194. */
  195.  
  196. // Şimdi bir örnekle sonlandıralım.
  197.  
  198. < ?php
  199. # Fonksiyon dosyamızı çağırıyoruz
  200. include_once('functions.php');
  201.  
  202. # Sonuc Fonksiyonumuzu çağırıyoruz.
  203. sonucAl('googleP','http://www.ysfkc.com');
  204. ?>

以上是关于Php ile网站Bilgilerinin Alınması(Yusuf KOÇ)的主要内容,如果未能解决你的问题,请参考以下文章

特殊 ä ö 字符打破 UTF-8 编码

ASP.Net mvc5 我的网站不允许'åäö'

Resim Upload Sınıfı-(Yusuf KOÇ)

从 Android 应用程序调用 PHP REST API 无法正确显示变音符号 (äüö)

UTF-8 with mysql and php in freebsd swedish chars (åäö) [重复]

(问号) 而不是旧页面上的ÅÄÖ