Hi, I have got this script to be integrated with existing html page, since I have no knowledge of html coding in depth at all, I wonder how I could stick this little php function witin the page. The html page is
www.chinaseonetwork.com
The Script is:
<?php
function fetch($source, $target, $smark, $smlen, $emark, $start, $stop) {
// get data from source
$data = @implode('', @file($source));
// strip unnecessary data
$data = substr($data, strpos($data, $start));
if(substr_count($data, $stop))
$data = substr($data, 0, strpos($data, $stop));
// number of results on page
$results = substr_count($data, $smark);
// initialize valiables
$num = 0;
$found = false;
// check results
while($num < $results) {
$begin = strpos($data, $smark) + $smlen;
$length = strpos($data, $emark) - $begin;
$tmp = substr($data, $begin, $length);
$num++;
if(substr_count($tmp, $target)) {
$found = true;
break;
}
// move past result that was just checked
$data = substr($data, strpos($data, $emark));
$data = substr($data, strpos($data, $smark));
}
return array($found, $num);
}
if($_POST[submit]) {
$data = array();
$terms = urlencode(trim($_POST[terms]));
$target = trim($_POST[target]);
$target = eregi_replace('http://', '', $target);
$target = eregi_replace('www.', '', $target);
// MSN Search Beta
$source = 'http://beta.search.msn.com/results.aspx?q='.$terms.'&first=1&count=100';
$data['MSN Search'] = fetch($source, $target, '<h3>', 4, '</h3>', '<div id="results"', '<div id="ads_rightC"');
$data['MSN Search'][2] = $source;
// Google
$source = 'http://www.google.com/search?q='.$terms.'&num=100';
$data['Google'] = fetch($source, $target, '<p class=g>', 11, '</a>', '<div><p class=g>', '<br clear=all>');
$data['Google'][2] = $source;
// Yahoo!
$source = 'http://search.yahoo.com/search?p='.$terms.'&n=100';
$data['Yahoo!'] = fetch($source, $target, 'class=yschttl', 13, '</a>', 'WEB RESULTS', '</ol>');
$data['Yahoo!'][2] = $source;
// AltaVista
$source = 'http://www.altavista.com/web/results?q='.$terms.'&nbq=100';
$data['AltaVista'] = fetch($source, $target, "class='res'", 11, '</a>', 'AltaVista found', 'Result Pages');
$data['AltaVista'][2] = $source;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SERP Position Plus by Curve2 Design</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<div>
<form action='<?php echo $_SERVER[PHP_SELF]; ?>' method='post'>
<table width='350' border='0' cellpadding='3' cellspacing='0'>
<tr>
<td colspan='2'>
Enter the search term(s) and the URL that you would to check in the form below:
</td>
</tr>
<tr>
<td>
<label for='terms'>Search Terms</label>
</td>
<td>
<input type='text' name='terms' id='terms' value='<?php echo $_POST[terms]; ?>' style='width:200px;'/>
</td>
</tr>
<tr>
<td>
<label for='target'>Website URL</label>
</td>
<td>
<input type='text' name='target' id='target' value='<?php echo $_POST[target]; ?>' style='width:200px;'/>
</td>
</tr>
<tr>
<td></td>
<td>
<input type='submit' value='Submit'/>
</td>
</tr>
</table>
<?php
// display data summary
if($data) {
echo "<br/><table width='350' border='0' cellpadding='3' cellspacing='0'>";
echo "<tr><td align='center' colspan='2'><b>SERP Position Plus</b></td></tr>";
echo "<tr><td><b>Search Engine</b></td><td align='right'><b>Position</b></td></tr>";
foreach($data as $engine => $result) {
echo "<tr><td><a href='$result[2]' target='_blank'>$engine</a></td><td align='right'>";
if($result[0])
echo $result[1];
elseif($result[0] == '0')
echo 'Not Found';
else
echo 'Not Available';
echo '</td></tr>';
}
echo '</table>';
}
?>
<input type='hidden' name='submit' value='true'/>
</form>
<br/>
<a href='http://www.curve2.com'>SERP Position Plus by Curve2 Design</a>
</div>
</body>
</html>
I want to see the script goes into the main content area in html page. How can I achieve that? I would really appreciate it if you can provide some useful help. Thanks in advance,