Shop pdf search

Fileserver(linux) has the mirrored raid filesystem mounted on /files  in this is /doc/ in this is /pdf/ under which lie all the collected pdf's.
All workstations mount the fileservers repository under /files/

My origional idea to make a pdf search was to have a webpage that would use the 'locate' database on the server to search for keywords requested, and then generate a page with file:// links to the results, easy enough....

It turns out that iceweasel will not open file:// links from a webpage... huh, ok, plan B

The fileservers webserver is given a link that provides access to the entire /files/ via apache, and the links for results on the page are listed with adjusted urls.
This worked, but searching for anything took a long time, as maybe it should, locate is searching all filenames, there are lots of files, lots, I think I have a million of so in there that are part of the result set of my program that tried to generate every black and white 5x7 pixel combination...optimizations in order..

It turns out, that using 'find' on the pdf branch of the filesystem, and 'grep'ing out what you want is MUCH faster, well, ok.

so here we have it, its php based, it uses bash for doing the actual grunt work.
THIS IS SO HACKABLE DANGEROUS ITS INSANE
consider this as safe as having a textbox on you server for running bash commands, because it is!
Here are the two files, one for entering your search, one for showing results and re-searching.

PDFInput.html
<head>
 <title> PDF Search </title>
</head>
<body>
  <form name="input" action="PDFSearch.php" method="get">
  Filename Keyword: <input type="text" name="pn">
  <input type="submit" value="Search">
</form>
</body>

PDFSearch.php
<html>
 <head>
  <title> Datasheet Search Results </title>
 </head>
 <body>
  <br>
  <?php

      $partNum = $_GET['pn'];

      print("<br>-- SEARCH RESULTS FOR: ".$partNum."--<br><br>");

      exec("find /files/doc/pdf/ | grep -i ".$partNum."|grep -i pdf", $retval);

     if (!$retval) {
       printf("I dunt found you nun result, master. :-(<br>");
     } else {

       foreach($retval as $line) {
         $link = $line;
         print("<a href=\"$link\">".$line."</a><br>");
       }

     }

  ?>
<br> -- END OF RESULTS -- <br>
<br>
 <form name="input" action="PDFSearch.php" method="get">
   Filename Keyword: <input type="text" name="pn">
   <input type="submit" value="Search">
 </form>
<br>
<br>
<a href="PDFInput.html">Back</a>
<br>
<br>
OR go see whats new at <a href="http://www.hackaday.com"> HACKADAY.COM </a>
<br>
 </body>
</html>


screenshots! (cause, for some reason, gimp is still open)





This is a hack, one I hope you to can make use of.