Version: 0.1

Type: Full Script

Category: Other

License: GNU General Public License

Description: See it working at 'www.huw.ukso.com' email me at 'huwsy@jediknights.co.uk' Will retrieve results from search engines and parse the data to only display the results. Can also be run to retreive the latest news from the internet. Based on php, no sql required. There is 2 files required, they are all included in the 1 upload file. 1st. hml.inc (containing layout info) 2nd. srch.php (the core file, and exercutable file)



<?
/*  ====================================================================
 *  Copyright (c) 2001 Huw, HuwSy@jediknights.co.uk
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  1. Redistributions of the code in any formmust retain the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer.
 *
 *  2. The line toward the bottom of the document containing my home
 *     url must remain compleatly intact. below is an example of the line.
echo "SRCHER vX.XX daily build XX-XXXX-XX, Copywright to <a href='http://www.huw.ukso.com'>Huw</a> - ";
 *
 *  3. The name of the author may not be used to endorse or promote products
 *     derived from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *  ==================================================================== 
 *  DONOT ATTEMPT TO MODIFY THIS FILE UNLESS
 *  YOU ARE ENTIERLY SURE OF THE ATTECTS IT
 *  MAY HAVE ON THE SCRIPTS PREFORMANCE.
 *
 *  ALL VARIABLES WITH A HASHED (#) COMMENT
 *  FOLLOWING MAY BE REQUIRED TO BE MODIFIED
 *  FOR CORRECT OPERATIONS UPON YOUR OWN
 *  SERVER.
 */

# $q
# search text
# $news
# if set to true then news results will be displayed
global $q, $news;
if ($news)
	$title = "Tech News";
else
	$title = "Web Multi Search for " . $q; # search website title, the $q displays the search text
$Tmp_login = "";
$cur_file_name = "srch.php";
if (isset($q))
	$Tmp_login = $Tmp_login . "<input type='hidden' name='q' value='$q' id='input'>\n";
include "html.inc"; # where visuals are pulled from

function news()
{
	$q = "tech news reports";
	google($q);
}

function search()
{
	global $q;
	$q = str_replace(" ", "+", $q);
	google($q);
}

function google($q)
{
	$start_res_delimiter = "<p><A";						# text at start of results
	$start_res_delimiter_alt = "<p><A ";				# alternate text at start of results
	$end_res_delimiter = "color=green>";				# text at end of results
	$end_res_delimiter_alt = "color=#008000>";			# alternate text at end of results
	$start_res_replace = "<a ";							# text to replace start result text with to prevent bad code
	$start_res_replace_alt = "<a ";						# text to replace alt start result text with to prevent bad code
	$end_res_replace = "></font><br>";					# text to replace end result text with to prevent bad code
	$end_res_replace_alt = "></font><br>";				# text to replace alt end result text with to prevent bad code
	$UrlBlank = "http://www.google.com/search?q=";		# url of search engine where query text follows
	$UrlBlank_end = "";									# url of search engine which follows query text
	$Name = "Google";									# search engine name
	$catagory = "search";
	$url = $UrlBlank . $q . $UrlBlank_end;
	display($start_res_delimiter,$end_res_delimiter,$start_res_replace,$end_res_replace,$url,$Name, $start_res_delimiter_alt, $end_res_delimiter_alt, $start_res_replace_alt, $end_res_replace_alt, $catagory);
}

function display($start_res_delimiter,$end_res_delimiter,$start_res_replace,$end_res_replace,$url,$Name, $start_res_delimiter_alt, $end_res_delimiter_alt, $start_res_replace_alt, $end_res_replace_alt, $catagory)
{
	$results_data = "";
	$line_compilation = "";
	# set file location and read
	$file_contents = file($url);
	# compile all lines into one string
	for($num = 0; $num < count($file_contents); $num++)
	{
		$Tmp = $line_compilation;
		$line_compilation = $Tmp . $file_contents[$num];
	}
	# remove new lines
	$line_compilation = str_replace("\n","",$line_compilation);
	# replace start and end delimiters with a string hopefully never used in the web page
	$line_compilation_post_modification = str_replace($start_res_delimiter,"!!!!__!!!!-START-!!!!__!!!!" . $start_res_replace,$line_compilation);
	if ($start_res_delimiter_alt)
		$line_compilation_post_modification = str_replace($start_res_delimiter_alt,"!!!!__!!!!-START-!!!!__!!!!" . $start_res_replace_alt,$line_compilation);
	$line_compilation_post_modification = str_replace($end_res_delimiter,$end_res_replace . "!!!!__!!!!-END-!!!!__!!!!",$line_compilation_post_modification);
	if ($end_res_delimiter_alt)
		$line_compilation_post_modification = str_replace($end_res_delimiter_alt,$end_res_replace_alt . "!!!!__!!!!-END-!!!!__!!!!",$line_compilation_post_modification);
	# split by the start delimiter
	$exploded_results_start = explode("!!!!__!!!!-START-!!!!__!!!!",$line_compilation_post_modification);
	# split all results into one string
	for ($num = 1; $num < count($exploded_results_start); $num++)
	{
		$split_results = explode("!!!!__!!!!-END-!!!!__!!!!",$exploded_results_start[$num]);
		$results_data .= "\n<br>\n" . $split_results[0];
	}
	# write a link to the official source page
	echo "<a href='" . $url . "' class='end'>" . $Name . "</a>";
	# write the results
	echo "<div class='res'>\n\n" . $results_data . "\n\n</div>\nEnd of " . $Name . "s " . $catagory . "results<BR>\n\n";
}

# Print document.
echo $above_title;
echo "\n<TITLE>" . $title . "</TITLE>\n";
echo $below_title;
echo $body_top;
echo $body_html;
echo $links;
echo $Post_links;
echo "\n      <div class='end'>" . $title . "</div>\n";
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center'>";
echo "<tr>";
echo "<td width='50' rowspan='3' align='center' valign='top'>";
echo $colour_changer_device1;
echo "</td>";
echo "<td width='100%' align='center' valign='top'>";
echo "</td>";
echo "<td width='50' rowspan='3' align='center' valign='top'>";
echo $colour_changer_device2;
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100%' valign='top'>";
if ($news)
	news();
else if ($q)
	search();
else
	echo "No search phrase has been supplied.";
echo $search_script;
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100%' align='center' valign='bottom'>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo $base_html;
# Following line which must remain being printed at the base of the document
echo "SRCHER v3.22 daily build 12-Sept-01, Copywright to <a href='http://www.huw.ukso.com'>Huw</a> - ";
# End of line wich must remain.
echo $body_base;
counter("",$PHP_SELF,$title);
?>