Advertisement
Guest User

daily programmer 83int driver - taion809

a guest
Aug 1st, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. <?php
  2.  
  3.     require_once("83int_index.php");
  4.     require_once("83int_search.php");
  5.    
  6.  
  7.     $time_start = microtime(true);
  8.    
  9.     echo "<html>\n
  10.        <head>\n
  11.        <title>Daily Programmer 83 Intermediate</title>\n
  12.        <meta http-equiv=\"content-type\" content=\"text/html;charset=UTF-8\" />
  13.        </head>\n
  14.        <body>\n";
  15.    
  16.     if(isset($_SERVER['REQUEST_METHOD']))
  17.     {
  18.         if(isset($_GET['index']))
  19.         {
  20.             $index = new Index();
  21.             $index->begin_index();
  22.         }
  23.        
  24.         else if(isset($_GET['search']))
  25.         {
  26.             $search = new Search();
  27.             $search_terms = explode("%20",filter_var($_GET['search_term'], FILTER_SANITIZE_ENCODED));
  28.            
  29.             foreach($search_terms as $term)
  30.             {
  31.                 $results = $search->search($term);
  32.                
  33.                 if(count($results) > 0)
  34.                 {
  35.                     echo "Found " . count($results). " occurances of " . $term ."<br /><br />";
  36.            
  37.                     foreach($results as $item)
  38.                     {
  39.                         echo "File: " . $item["file"]." Line: " . $item["line"] . "<br />Context: " . $item['word'] ."<br /><hr /><br />";
  40.                     }
  41.                 }
  42.             }
  43.         }
  44.     }
  45.    
  46.     echo "</body>\n</html>";
  47.    
  48.     $end_time = microtime(true);
  49.    
  50.     $time = $end_time - $time_start;
  51.     echo "Execution Time: ".$time." seconds<br />";
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement