Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Lionsanime Directory   World's Leading Outsourcing Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 09-08-2005, 06:31 AM   #1 (permalink)
Contributing Member
 
Clark's Avatar
 
Join Date: 10-18-03
Posts: 117
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
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 09-12-2005, 08:48 PM   #2 (permalink)
Inactive
 
insitedev's Avatar
 
Join Date: 12-14-04
Posts: 108
iTrader: 0 / 0%
Latest Blog:
None

insitedev is liked by somebodyinsitedev is liked by somebodyinsitedev is liked by somebodyinsitedev is liked by somebody
1. Take the Heading tags (HTML - Body) and the footing tags (/body and /html).

2. Save the file (something like "search.inc.php"... it can be whatever you want, it's just my personal preference to name included files ".inc.php")

3. On the existing page (i'm assuming it is index.php or something .php) add the line <?php include("search.inc.php"); ?> in the main content cell.

Let me know if that works for you.
insitedev is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



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

vB 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 01:01 AM
Embeding a popup into flash GeXus Graphic Design Forum 1 11-22-2004 12:22 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 01:24 AM.
© Copyright 2008 V7 Inc