View Single Post
Old Sep 14th, 2005, 2:03 AM   #3
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 420
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Filename: results.php
Purpose: To find sites based on user input and output them in a structured manner.

<html>
	<head>
		<title>
			Search Results
		</title>
	</head>
	<body background="../jr.gif" bgcolor="#000031" link="##91DAFF" vlink="##91DAFF">
		<font color="#FFFFFF" face="verdana" size="1">
<?php
	switch(count($_GET))
	{
		case 0:
			echo 'Welcome to JRSearch.';
			break;
		default:
			$searchstring = strtolower($_GET['sendstring']);
			$searchbase = $_GET['database'];
			if($searchstring == NULL)
			{
				die('You did not enter a search term.');
			}
			if($searchbase == NULL)
			{
				die('You did not select a database.');
			}

			$searchbase = substr($searchbase, 0, strpos($searchbase, "."));

			$i = 1;
			
			switch($searchbase)
			{
				case $i++:
					$filename = 'anime';
					$searchbase = 'anime';
					break;
				case $i++:
					$filename = 'graphics';
					$searchbase = 'graphics';
					break;
				case $i++:
					$filename = 'misc';
					$searchbase = 'miscellaneous';
					break;
				case $i++:
					$filename = 'music';
					$searchbase = 'music';
					break;
				case $i++:
					$filename = 'reference';
					$searchbase = 'reference';
					break;
				case $i++:
					$filename = 'vgames';
					$searchbase = 'video games';
					break;
				case $i++:
					$filename = 'web';
					$searchbase = 'world wide web';
					break;
			}

			$filename .= '.txt';
			if(!$handle = fopen($filename, 'r'))
			{
				echo "Cannot open file ($filename)";
				exit();
			}
			$contents = fread($handle, filesize($filename));
			fclose($handle);
	
			$end_tag = 'EOINPUT';
			$thread_contents = explode($end_tag, $contents);
			unset($thread_contents[count($thread_contents) - 1]);

			echo '<font color="#F8BF24"><strong>';
			echo intval(count($thread_contents) / 4);
			echo '</strong></font> total sites in <font color="#F8BF24"><strong>';
			echo strtoupper($searchbase);
			echo'</strong></font> database<br><br>';

			$n = 0;

			for($i = 0; $i < count($thread_contents); $i += 4)
			{
				$title = $thread_contents[$i + 0];
				$desc = $thread_contents[$i + 1];
				$url = $thread_contents[$i + 2];
				$kword = strtolower($thread_contents[$i + 3]);
				$kword .= 'list_all';

				if(is_int(strpos($kword, $searchstring)))
				{
					$n ++;
					echo '<font color="#F8BF24"><strong>';
					echo $n;
					echo '</strong></font>. <a href="';
					echo $url;
					echo '" target="_blank">';
					echo $title;
					echo '</a><br>';
					echo $desc;
					echo '<hr>';
				}
			}
			if($n == 0)
			{
				echo 'No results found.';
			}
			break;
	}
?>
		</font>
	</body>
</html>
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote