<html>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
target url: <input type="text" name="target_url" maxlength="256" />
<input type="Submit" value="Submit" />
</form>
<?php
//john pfeiffer 2010-03
// get a web page
// use the extract function to remove unwanted chars (e.g. between < and >)
// also removing the start and stop characters!
// display result (formatting?)
function extract_between_start_and_stop_characters( &$array , $start_char , $stop_char )
{
$i = 0;
do{
$c = $array[$i];
$i++;
if( $c == $start_char ) //if at start_char strip out chars until stop_char
{
do{
$c = $array[$i];
$i++;
//invisibly strip out the unwanted chars
}while( $c != $stop_char );
}
if( $c != $stop_char )
{ echo $c; }
}while( $i < strlen( $array ) );
} /* end function extract-between-start-and-stop-characters( &$array ) */
if( !isset($_POST['target_url']) || empty($_POST['target_url'] ) )
{
echo "<b>You must fill in the target url.</b>";
}
else
{
$target_url = strtolower($_POST['target_url']);
$result = file_get_contents( $target_url ); //char array of the target file
if($result == NULL)
{ echo "Error: could not get page"; }
else
{
echo"<pre>";
echo $target_url . " had " . strlen($result) . " characters\n";
extract_between_start_and_stop_characters( $result , '<' , '>' );
//DEBUGGING:
echo "---------------------------------------- ORIGINAL PAGE ----------------------------------";
print_r( $result );
/*
foreach ($matches[0] as $key => $value)
{
echo htmlspecialchars($value) . "\n<br />";
}
*/
echo "</pre>";
}//end else error webpage not found
}//end else webpage form not filled in
?>
</html>