All pastes #514640 Raw Edit

Unnamed

public text v1 · immutable
#514640 ·published 2007-05-27 20:52 UTC
rendered paste body
<?php

$filename 		= "file.list";
			
if (is_file($filename) == TRUE) {
   $filec = file($filename);
} else {
   die("$filename is fucked somehow. Fix it.");
}

$termsarr 		= explode(" ", $_GET[param_terms]);
$terms2p 		= implode("+", $termsarr);
$results 		= array();
$count 			= 0;

foreach ($filec as $line) {
   $matches = 0;
   foreach ($termsarr as $search) {
      if (preg_match("/$search/i", $line) && preg_match("/.mp3/i", $line)) {
         $matches += 1;
      }
   }
  
   if ($matches == count($termsarr)) {
      $count += 1;
      array_push($results, $line);
   }
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<style media="all" type="text/css">
* {
	margin: 0;
	padding: 0;
}
body {
	font-family: Arial, Helvetica, sans-serif;
	font-size: .8em;
	margin: 1.4em;
	cursor: default;
	background: #000;
}
a {
	cursor: pointer;
}
form {
	margin: 0 0 0 .4em;
}
h1 {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-weight: normal;
	font-size: 2.8em;
	margin: 0 .4em .4em .2em;
}
ul {

}
li {
	padding: .8em .4em;
	border-bottom: 1px solid #999;
	list-style-type: none;
}
#container {
	width: 90%;
	margin: 0 auto;
	padding: 0 0 1em 0;
	background: #fff;
}
#results {
	margin: .6em 0 .6em .4em;
}
</style>
</head>

<body>

<div id="container">

<h1>search nrgetik ftp</h1>

<form action="search.php" method="GET">
    <label for="terms">Search: </label>	<input type="text" id="terms" name="param_terms">
    <input type="submit" value="Submit">
</form>

<div id="results">
<?php
if ($_GET[param_terms] != NULL) {
?>
    <b><?=$count?></b> results found.
<?php
	} else {
?>
	You did not enter a search term, try again.
<?php
}
?>
</div>

<ul>
<?php
if ($_GET[param_terms] != NULL) { 
	foreach ($results as $line) {
	   echo "<li>$line</li>\n";
	}
}
?>
</ul>

</div>

</body>
</html>