15) { return substr($text,0,15)."..."; } else { return $text; } } if ($_SESSION['logged']==1) { $words = $_POST['words']; $words = strtolower(trim($words)); if (isset($words) && strlen($words)>0) { $not_allowed = array("\"","\'","\\",";","(",")","-"); foreach ($not_allowed as $char) { $words = str_replace($char,"",$words); } echo "

Your search query: ".$words."

"; /* PROCEDURE: 1. GET ALL THE FILES WITH THE SEARCH QUERY IN FILENAME 2. GET ALL THE FILES WITH THE SEARCH QUERY IN CONTENTS */ $locus = array(); $terms = explode(" ",$words); include ("../../auth.inc.php"); $fquery = mysql_query("select * from `keepit_docbank` where owner='".$_SESSION['username']."'") or die("Error: " . mysql_error()); $allFiles = array(); while($file= mysql_fetch_array($fquery)) { array_push($allFiles,$file); } foreach ($allFiles as $file) { $title = strtolower($file['title']); $b = FALSE; foreach ($terms as $term) { if (strlen($term)>0) { if (strpos($title,$term)!==FALSE) { $b = TRUE; } } else { $b = FALSE; } } if ($b) { array_push($locus,$file); } } if (count($locus)>0) { echo ""; } else { echo "No files found. Sorry :("; } } else { echo "

You must enter a search string.

"; } } else { echo "

You must be logged in.

"; } ?>