Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


 
 
LinkBack Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 09-08-2005, 07:31 AM   #1 (permalink)
Member
 
Clark's Avatar
 
Join Date: 10-18-03
Posts: 84
iTrader: 0 / 0%
Latest Blog:
None

Clark is just really niceClark is just really niceClark is just really niceClark is just really niceClark is just really niceClark is just really niceClark is just really niceClark is just really niceClark is just really nice
Php script embeding

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,
Clark is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues with embeding Jason Web Design Lobby 4 05-17-2005 02:01 AM
Embeding a popup into flash GeXus Graphic Design Forum 1 11-22-2004 12:22 PM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 06:53 PM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.