// http://stuporglue.org // // This script is provided in the hopes that it will be useful. This script may contain bugs which could lead to data loss or compromise the security // of your server. Your use of this script indicates that you understand and accept these risks. // This script may be used or modified for any purpose, free or commercial, as long as this comment, disclaimer and copyright notice is left intact // // //---------------- Config --------------------------// global $emailAddress, $searchButton, $tableofcontents, $prev_button, $next_button, $top; $emailAddress = 'stuporglue@gmail.com'; $searchButton = 'Search Book'; $tableofcontents = 'Table of Contents'; $prev_button = 'Previous Page'; $next_button = 'Next Page'; $top = 'Go to Top'; //---------------- Functions -------------------------// // get a list of all .html files and sort them by name function sortHTMLFiles(){ global $fileArray, $emailAddress, $searchButton, $tableofcontents, $prev_button, $next_button, $top; // Get list of .html files and sort them $fileArray = Array(); if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if (substr($file,-5) == '.html') { array_push($fileArray,$file); } } closedir($handle); } sort($fileArray); return $fileArray; } // Print the OCR small image and the text that goes with it function printORCDiv($filename = NULL) { global $emailAddress, $searchButton, $tableofcontents, $prev_button, $next_button, $top, $fileArray; if($filename === NULL){$filename = array_pop(explode("/",$_SERVER['REQUEST_URI']));} // Write .htaccess file if it doesn't exist. If it does exist, you'll need to add these lines yourself if($filename == "index.php" || $filename == ''){ if(!file_exists('.htaccess')){ `echo 'RewriteEngine on' > .htaccess`; `echo 'RewriteRule !\.(gif|jpg|png|tif|css|php)$ index.php' >> .htaccess`; } } // If a file that exists on the server was requested then include it and link its image, otherwise link to the first image $navidx = array_search($filename,$fileArray); if($navidx === FALSE){ $navidx = 0; $filename = $fileArray[0]; } $imageFile = basename($fileArray[$navidx],".html"); print "
$imageFile"; print "

The following OCR conversion of the image may contain errors. Click here to see the original scan. If you have additional information on one of the people mentioned here, please contact me at $emailAddress.

$tableofcontents

"; // Navigation buttons print ""; print "

";
    include($fileArray[$navidx]);
    print "
"; return $filename; } function printNav($foundFile = FALSE){ global $emailAddress, $searchButton, $tableofcontents, $prev_button, $next_button, $top, $fileArray; print ""; } function simpleSearch($searchTerm = ""){ global $emailAddress, $searchButton, $tableofcontents, $prev_button, $next_button, $top; $searchTerm = escapeshellarg($searchTerm); $command = "grep $searchTerm *.html | sed 's/:.*//' | sort -u"; $res = explode("\n",`$command`); array_pop($res); if(count($res) == 0){ print "

Sorry, Nothing was found when searching for $searchTerm!

Back to the book

"; sortHTMLFiles(); printNav(); } else { print "

I found $searchTerm on the following pages:

"; } } //--------------------- Logic Starts Here --------------------------// ?> An OCRed Book
This page is displayed with OCRShow. For information on how to convert your book to a webpage like this, visit the OCRShow webpage.