Følgende script bruges til at måle et domænes position ved brug af et bestemt søgeterm. Brug det som du har lyst! Se eksempel her: http://www.seo-tools.dk/index.php/V%E6rkt%F8jer/M%E5l_Placering
<?php
/*
Copyright Regin Gaarsmand
http://www.reginscorner.dk
e-mail: regin (snabel-a) gaarsmand.dk
*/
$_HLS = array('Alle'=>'','lang_da'=>'Dansk');
switch($_GET['op'])
{
case 'measure':
$content = measure();
break;
}
$content .= mForm();
exit('<html>
<head>
<title>Måling af google position</title>
<style>
body
{
font-family:verdana;
font-size:12px;
margin:0px;
}
td
{
font-size:12px;
font-family:verdana;
}
</style>
<body><div style="width:400px;border:2px solid black;padding:3px;">'.$content.'</div>
</body>
</html>');
function measure()
{
global $_HLS;
$oQuery = trim(stripslashes($_GET['q']));
$query = urlencode(stripslashes($_GET['q']));
$hl = "";
if($_HLS[$_GET['hl']] !='')
{
$hl = $_GET['hl'];
}
$domain = strtolower(stripslashes($_GET['domain']));
$domainReg = str_replace('.','\.',$domain);
$errors = array();
if($oQuery=="")
{
$errors[]='Der blev ikke angivet nogen søgestreng til test.';
}
$tDomain = $domain;
if(substr($tDomain,0,7)=='http://www')
{
$tDomain = substr($tDomain,7);
}
if(substr($tDomain,-1)=='/')
{
$tDomain = substr($tDomain,0,-1);
}
$a1 = explode('/',$tDomain);
$a2 = explode('?',$tDomain);
$a3 = explode('.',$tDomain);
if(count($a1)>1||count($a2)>1||count($a3)==0)
{
$errors[]='Domæne navnet er ugyldigt.';
}
if(count($errors)==0)
{
$gStr = 'http://www.google.com/search?lr='.$hl.'&q='.$query.'&btnG=S%C3%B8g&num=100';
$gContent = strtolower(file_get_contents($gStr));
@$array = explode($domain,$gContent,2);
$result = "";
if(count($array)>1)
{
$str= str_replace('<blockquote class=g><p class=g>','',$array[0]);
$result = (substr_count($str,'class=g').'');
}
if($result !="")
{
$content = $domain.' er nummer '.$result.' på google når der søges på: <i><b>'.htmlentities($oQuery).'</b></i><br>
Se:<br><a target="_blank" href="'.'http://www.google.com/search?lr='.$hl.'&q='.$oQuery.'&btnG=S%C3%B8g&num=100'.'" style="font-size:9px;">'.$gStr.'</a>';
}
else
{
$content = $domain.' blev ikke fundet i de første 100 resultater ved søgning på <i><b>'.htmlentities($oQuery).'</i></b>';
}
}
else
{
$content = '<span style="font-weigh:bold;">'.implode('<br>',$errors).'</span>';
}
return $content;
}
function mForm()
{
global $_HLS;
$content = '<form>
<input type="hidden" value="measure" name="op">
<table cellspacing=0>
<tr>
<td>Søgeord:</td>
<td><input type="text" name="q" value="'.htmlentities(stripslashes($_GET['q'])).'"></td>
</tr>
<tr>
<td>Domæne:</td>
<td><input type="text" name="domain" value="'.htmlentities(stripslashes($_GET['domain'])).'"></td>
</tr>
<tr>
<td>Sprog:</td>
<td>'.DropDownArray('hl',$_HLS,$_GET['hl']).'</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Send"></td>
</tr>
</table>
</form>';
return $content;
}
function DropDownArray($name, $IdName, $selected="")
{
$dropdown = "<select name=\"$name\">\n";
foreach($IdName as $id => $name)
{
$dropdown .= "<option value=\"$id\"";
if($selected == $id){ $dropdown .= " SELECTED";}
$dropdown .= ">$name</option>";
}
$dropdown .= "</select>\n";
return $dropdown;
}
?>