information
|google position
| see demonstration of google positionthis script gets the position of your site at google.
full source of google position [ line 1 - 78 ] | download google position
| 1 | <?php |
| 2 | if(!empty($_POST['searchquery']) && !empty($_POST['searchurl'])) |
| 3 | { |
| 4 | $querycleaner = array(' '=>'+','%26'=>'&'); |
| 5 | $query = strtr($_POST['searchquery'],$querycleaner); |
| 6 | $total_to_search = 100; |
| 7 | $hits_per_page = 10; |
| 8 | $position = 0; |
| 9 | $real_position = 0; |
| 10 | $found = NULL; |
| 11 | $lastURL = NULL; |
| 12 | $despacer = array(' '=>''); |
| 13 | for($i = 0; $i < $total_to_search && empty($found); $i += $hits_per_page) |
| 14 | { |
| 15 | $filename = "http://www.google.com/search?as_q=$query". |
| 16 | "&num={$hits_per_page}&hl=en&ie=UTF-8&btnG=Google+Search". |
| 17 | "&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype=". |
| 18 | "&as_qdr=all&as_nlo=&as_nhi=&as_occt=any&as_dt=i". |
| 19 | "&as_sitesearch=&safe=images&start=$i"; |
| 20 | $file = fopen($filename, "r"); |
| 21 | if (!$file) |
| 22 | { |
| 23 | echo '<p>Unable to open remote file '.$filename; |
| 24 | }else{ |
| 25 | while(!feof($file)) |
| 26 | { |
| 27 | $var = fgets($file, 1024); |
| 28 | if(eregi('<b>1</b> - <b>10</b> of about <b>(.*)</b>',$var,$outs)) |
| 29 | { |
| 30 | $total = end(array_reverse(explode(' ',$outs[1]))); |
| 31 | } |
| 32 | if(eregi('<font color=#008000>(.*)</font><nobr>',$var,$out)) |
| 33 | { |
| 34 | $out[1] = strtolower(strip_tags($out[1])); |
| 35 | $x = strpos($out[1],'/'); |
| 36 | $url = substr($out[1],0,$x); |
| 37 | $position++; |
| 38 | if(strcmp($lastURL,$url)<>0)$real_position++; |
| 39 | $lastURL = $url; |
| 40 | if(strcmp($_POST['searchurl'],$url)==0) |
| 41 | { |
| 42 | $urlparts = explode(' - ',$out[1]); |
| 43 | $foundurl = strtr($urlparts[0],$despacer); |
| 44 | $found = $position; |
| 45 | break; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | fclose($file); |
| 51 | } |
| 52 | if($found) |
| 53 | { |
| 54 | $result = 'The site <a href="http://'.$foundurl.'" title="'.$foundurl.'" target="_blank">'.$_POST['searchurl'].'</a> |
| 55 | is at position <b>'.$found.'</b> ( '.$real_position.' ) of about '.$total.' |
| 56 | for the term <b>'.$_POST['searchquery'].'</b>'; |
| 57 | }else{ |
| 58 | $result = 'The site '.$_POST['searchurl'].' is not in the top '.$total_to_search.' for the term <b>'.$_POST['searchquery'].'</b>'; |
| 59 | } |
| 60 | } |
| 61 | echo ' |
| 62 | <form method="post" action="'.$_SERVER['PHP_SELF'].'">'.(isset($result) ? '<fieldset> |
| 63 | <legend>result</legend> |
| 64 | '.$result.' |
| 65 | </fieldset>' : '').' |
| 66 | <fieldset> |
| 67 | <legend>search term</legend> |
| 68 | <input name="searchquery" type="text" value="'.$_POST['searchquery'].'" /> |
| 69 | </fieldset> |
| 70 | <fieldset> |
| 71 | <legend>domain (without http:// and subdirectories)</legend> |
| 72 | <input name="searchurl" type="text" value="'.$_POST['searchurl'].'" /> |
| 73 | </fieldset> |
| 74 | <fieldset> |
| 75 | <legend>get position</legend> |
| 76 | <input type="submit" value="get position" /> |
| 77 | </form>'; |
| 78 | ?> |
30 hits by 19 users in the last 30 minutes.