<?PHP
define("MYSQLUSER", "root");
define("MYSQLPASS", "HSB90mp5!");
define("MYSQLHOST", "127.0.0.1");
define("MYSQLDB", "vpnsearch");

$dbcon = mysql_connect(MYSQLHOST, MYSQLUSER, MYSQLPASS);
mysql_select_db(MYSQLDB, $dbcon);
PHP?>

<html>
<head>
<title>tajgoren.net file search</title>
</head>
<body>
<form action="search.php" method="POST">
<input type="text" name="searchpattern">
<input type="submit" value="sök">
</form>
<?PHP
	if(isset($_POST[searchpattern]))
	{
		$query = "select host, share, file from files where file like '%$_POST[searchpattern]%'";
		$result = mysql_query($query);
		$hits = mysql_num_rows($result);
		if($hits > 0)
		{
			echo "Found $hits files<br>\n";
			echo "<table border=0 cellpadding=0 cellspacing=0>\n<tr>\n<td width=75>Host</td><td width=50>Share</td><td>file</td>\n</tr>\n";
			while($line = mysql_fetch_array($result))
			{
				echo "<tr>\n<td>$line[host]</td><td><center>$line[share]</center></td><td>$line[file]</td>\n</tr>\n";
			}
		}
		else
			echo "No hits<br>\n";
	}
PHP?>
</body>
</html>

<?PHP
mysql_close($dbcon);
PHP?>
