Slide 2.6: An indexing demonstration
Slide 2.8: The code sample of indexing
Home         Print version

The Code Sample of Interface


The program below is used to implement the previous interface, which includes the following three buttons:
http://undcemcs01.und.edu/~wen.chen.hu/course/525/2/Index.php
<?php

 # Remove leading and trailing spacing.
 $keyword = trim( $_POST["keyword"] );
 $URL     = trim( $_POST["URL"] );

 # For security, remove some Unix metacharacters.
 $meta    = array( ";", ">", ">>", "<", "*", "?", "&", "|" );
 $keyword = str_replace( $meta, "", $keyword );
 $URL     = str_replace( $meta, "", $URL );

 if ( $_POST['act'] == "Clear system" ) {
   header( "Content-type: text/plain" );
   system( "/usr/bin/php  Clear.php" );
 }

 elseif ( $_POST['act'] == "Index web pages" ) {
   header( "Content-type: text/plain" );
   system( "/usr/bin/php  Spider.php  $keyword $URL" );
 }

 elseif ( $_POST["act"] == "List indexes" ) {
   header( "Content-type: text/html" );
   system( "/usr/bin/php  List.php  $keyword" );
 }

 elseif ( $_POST["act"] == "Help" ) {
   header( "Content-type: text/html" );
   $file = fopen( "Help.html", "r" ) or
     exit( "Unable to open file!" );
   while ( !feof( $file ) )
     echo  fgets( $file );
   fclose( $file );
 }

 else {
   header( "Content-type: text/html" );
   echo( "<html><body>" );
   echo( "<h3>No such option: " . $_POST["act"] . "</h3>" );
   echo( "</body></html>" );
 }

?>




      What’s the last thing to go through a fly’s head as it    
      hits the windshield of a car going 70 miles per hour?    
      Its butt.