cyberking

nge600673

Aug 25th, 2016
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <style>
  2. body {
  3.    font:8pt tahoma;
  4.    margin:4;
  5.    color:#330000;
  6.    background:#99ff00; }
  7. a {
  8.    text-decoration:none;
  9.    color:#009999;
  10. }
  11. .r {
  12.    font:8pt tahoma bold;
  13.    margin:2;margin-top:4; }
  14. </style>
  15. <body>
  16. <?php
  17.  
  18. $q = $_GET['key'];
  19.  
  20. if (!empty($q)) {
  21. $q = stripslashes($q);
  22. $hasil = googling($q,$m);
  23. echo "<h2> search results: $q<hr size=1 noshade>\n";
  24. }
  25. echo $hasil;
  26. echo "<br><br>";
  27. ?>
  28.  
  29. <hr size=1 noshade>
  30. <center>
  31. <form method="GET">
  32.  
  33. Input Keyword: <input type="text" name="key" size=50 value="<?php echo htmlentities($q); ?>">
  34. <input type="submit" value="Cari">
  35. </form>
  36. </center>
  37. <hr size=1 noshade>
  38.  
  39. <?php
  40.  
  41. function googling($key,$max) {
  42.  $key = urlencode($key);
  43.  $num = 100;
  44.  $c = 0;
  45.  for ($p=0;$p<=1000;$p+=10) {
  46.   $rez = httpquery("http://www.google.com/search?q=".$num."&hl=id&q=".$key."&start=".$p."&sa=N",5);
  47.   #$pattern = '#<h3 class="r"><a href="([^"]*)" class#i';
  48.  $pattern = '#<h3 class="r"><a href="([^"]*)"#i';
  49.   $count = preg_match_all($pattern,$rez,$matches,PREG_SET_ORDER);
  50.  
  51.   if ($count == 0) { return $h; }
  52.   else {
  53.    for ($i = 0;$i < $count;$i++) {
  54.    $urlz = urldecode($matches[$i][1]); $desc = $matches[$i][2];
  55.    $c++;
  56.    }
  57.   }
  58. }
  59. return $h;
  60. }
  61.  
  62. function httpquery($url,$timeout) {
  63.  $aurl = explode ("/",$url);
  64.  $host = $aurl[2];
  65.  $ruri = "/".join("/",array_slice ($aurl,3));
  66.  $port = 80;
  67.  $sock = fsockopen ($host,$port,$errno,$errstr,$timeout);
  68.  if ($sock) {
  69.   $out = "GET $ruri HTTP/1.1\r\n".
  70.         "Host: $host\r\n".
  71.         "Accept: */*\r\n".
  72.         "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 \r\n".
  73.         "Connection: Close\r\n\r\n";
  74.   fputs($sock,$out);
  75.   while (!feof($sock)) {
  76.    $rez .= @fgets($sock,512); }
  77.   fclose($sock);
  78.  }
  79.  return $rez;
  80. }
  81.  
  82. ?>
  83. </body>
  84. <?php die(); ?>
Advertisement
Add Comment
Please, Sign In to add comment