All pastes #625694 Raw Edit

Mine

public text v1 · immutable
·published 2007-07-19 03:19 UTC
rendered paste body
<?php
  $message = 'what do engineers do? they solve problems that have not already been solved.';
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
        "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Contact Form</title>
<meta http-equiv="Content-Type"
   content="text/html; charset=iso-8859-1">
</head>
<body>

<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $me = $_SERVER['PHP_SELF'];
?>

<form name="form_1" method="post"
         action="<?php echo $_SERVER['PHP_SELF'] ?>">
      <table border="0" cellspacing="0" cellpadding="2">
         <tr>
            <td>Query: </td>
            <td><input type="text" name="form_query"></td>
         </tr>
         <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="Submit"
               value="Submit"></td>
         </tr>
      </table>
   </form>

<?php
  echo $message;
 ?>


</body>
</html>



<?php
   } else {

     $e = array();
     $page = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

     if(!ereg($page, $_SERVER['HTTP_REFERER']))
        $e[] = "dont try and hack me pal.\n";

     if(!$_POST['form_query'])
        $e[] = "Query required br0.\n";

     if (count($e)>0)
     {
        echo "<strong>ERROR:<br>\n";
        foreach($e as $err)
          echo "$err<br>\n";
     } else {

//       $query = stripslashes($_POST['form_query']);
       $query = get_magic_quotes_gpc() ? stripslashes($_POST['form_query']) : $_POST['form_query'];

       echo nl2br("<b>Query:</b> $query<p></p>");
       $cmd = escapeshellcmd($query);



       $output = `grep -iR "$query" /home/trill/public_html/drdave/Exams_Quizzes/*`;

      // $pattern = "^/(.*)/";

          $pattern = "/file\ (.*)+\ matches/";
          if (preg_match($pattern, $output, $match)) {

              echo "1: $match[1]<p>\n";

              foreach ($match as $temp)
                echo "AA: $temp<p>";


          } else {
              echo "Invalid pattern match: $output<br>";
          }

                  echo "FILE: $file <br>";

                  echo "\$output: $output<p>";



   } }
?>
</body>
</html>