PHParadise source code of “google position” in category “information”
PHParadise
>
information
> google position
this script gets the position of your site at google.
back to the download options
see PHP code for “google position”
see demo of “google position”
copy the code of information / google position
click here to select all the code
<?php /*------------------------------------------------------------------------------ | | PHParadise source code | |------------------------------------------------------------------------------- | | file: google position | category: information | | last modified: Mon, 19 Sep 2005 17:07:42 GMT | downloaded: Thu, 24 May 2012 08:23:22 GMT as copy from textarea | | code URL: | http://phparadise.de/php-code/information/google-position/ | | description: | this script gets the position of your site at google. | ------------------------------------------------------------------------------*/ if(!empty($_POST['searchquery']) && !empty($_POST['searchurl'])) { $querycleaner = array(' '=>'+','%26'=>'&'); $query = strtr($_POST['searchquery'],$querycleaner); // total entries to search $total_to_search = 100; // hits per page to search through $hits_per_page = 10; $position = 0; $real_position = 0; $found = NULL; $lastURL = NULL; $despacer = array(' '=>''); for($i = 0; $i < $total_to_search && empty($found); $i += $hits_per_page) { $filename = 'http://www.google.com/search?as_q='.$query. '&num='.$hits_per_page.'&hl=en&ie=UTF-8&btnG=Google+Search'. '&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype='. '&as_qdr=all&as_nlo=&as_nhi=&as_occt=any&as_dt=i'. '&as_sitesearch=&safe=images&start='.$i; $file = fopen($filename, 'r'); if(!$file) { echo '<p>Unable to open remote file '.$filename; }else{ while(!feof($file)) { $var = fgets($file, 1024); if(eregi('<b>1</b> - <b>10</b> of about <b>(.*)</b>',$var,$outs)) { $total = end(array_reverse(explode(' ',$outs[1]))); } if(eregi('<font color=#008000>(.*)</font><nobr>',$var,$out)) { $out[1] = strtolower(strip_tags($out[1])); $x = strpos($out[1],'/'); $url = substr($out[1],0,$x); $position++; if(strcmp($lastURL,$url)<>0) $real_position++; $lastURL = $url; if(strcmp($_POST['searchurl'],$url)==0) { $urlparts = explode(' - ',$out[1]); $foundurl = strtr($urlparts[0],$despacer); $found = $position; break; } } } } fclose($file); } if($found) { $result = ' <p> The site <a href="http://'.$foundurl.'">'.$_POST['searchurl'].'</a> is at position <b>'.$found.'</b> ( '.$real_position.' ) of about <b>'.$total.' for the term <b>'.$_POST['searchquery'].'</b> </p>'; }else{ $result = ' <p> The site '.$_POST['searchurl'].' is not in the top '.$total_to_search.' for the term <b>'.$_POST['searchquery'].'</b> </p>'; } } echo ' <form method="post" action="./">'.(isset($result) ? ' <fieldset> <legend>result</legend> '.$result.' </fieldset>' : '').' <fieldset> <legend>search term</legend> <input name="searchquery" type="text"'.(isset($_POST['searchquery']) ? ' value="'.$_POST['searchquery'].'"' : '').' /> </fieldset> <fieldset> <legend>domain (without http:// and subdirectories)</legend> <input name="searchurl" type="text"'.(isset($_POST['searchurl']) ? ' value="'.$_POST['searchurl'].'"' : '').' /> </fieldset> <fieldset> <legend>get position</legend> <input type="submit" value="get position" /> </fieldset> </form>'; ?>
array handling
array multi sort
entries per row
complex array sort
communication
send email
databases
mySQL class
mySQL to excel
date and time
date and time
date examples
loading time
remote last modified
timestamp to time passed
directories
directory list with exec
htaccess 2
htaccess
human readable size
read dir and list
recursive directory delete
recursive directory listing
recursive make directory
directory structure to list
file handling
delete file
download counter
file exists
file informations
file upload
include secure
line by line
open file
read and select csv
read file
strip file extension
write to file
write to first line of file
forms
datepicker
google results
keep selected combobox
simple calculator
html and code
alternate row colors
convert html
extract vars
floating div
force PHP in HTML
get offsite code
html entities
html head
meta tags
prime numbers
simple bar chart
simple php code highlight
view php source
image editing
analog GD clock
colorizing
crop image
grayscale an image
image rotate
outlining
shadowing
textures
translucent text
invert image
image handling
base64 image encode
image upload and resize
list image folder
resize offsite image
information
detect user language
domaincheck
google position
phpinfo
referer info
server variables
visitor IP
visitors online
sessions and co
basic authorization
sessions class
string handling
autolink
extract string from offsite
insert at specific location
number to words
string compare
string in string
string replace
string to columns
substring examples
summarize article