Hi
I have two utility scripts I normally run on separate webpages, one is a webpage view source script and the other is a link extractor script, I would like to run both on the same page using one form with two buttons to call each one separately, here is the form and the two scripts I'm using. Thanks for any help. Joe
<!--------------------------Form---------------------------------->
<body onLoad="document.form.url.focus()">
<center>
<form name="form" action="" method="GET">
<font color=blue><b>URL:</b></font> <input type=text size=55 name=url value="<? echo "$url" ?>"/>
<input type=submit name=submit>
</form></center>
<!--------------------------End Form------------------------------>
<!-------------------------Start Link Extract Script--------------->
<!-----------------------End Link Extract Script----------------------->
<!-----------------------Source Viewer Script--------------------------->
<!---------------------------End Script------------------------------------
I have two utility scripts I normally run on separate webpages, one is a webpage view source script and the other is a link extractor script, I would like to run both on the same page using one form with two buttons to call each one separately, here is the form and the two scripts I'm using. Thanks for any help. Joe
<!--------------------------Form---------------------------------->
<body onLoad="document.form.url.focus()">
<center>
<form name="form" action="" method="GET">
<font color=blue><b>URL:</b></font> <input type=text size=55 name=url value="<? echo "$url" ?>"/>
<input type=submit name=submit>
</form></center>
<!--------------------------End Form------------------------------>
<!-------------------------Start Link Extract Script--------------->
PHP Code:
<?
error_reporting(0);
$url = $_REQUEST[url];
?>
PHP Code:
<?php
function hyperlinkextract($s1,$s2,$s){
$myarray=array();
$s1=strtolower($s1);
$s2=strtolower($s2);
$L1=strlen($s1);
$L2=strlen($s2);
$scheck=strtolower($s);
do{
$pos1 = strpos($scheck,$s1);
if($pos1!==false){
$pos2 = strpos(substr($scheck,$pos1+$L1),$s2);
if($pos2!==false){
$myarray[]=substr($s,$pos1+$L1,$pos2);
$s=substr($s,$pos1+$L1+$pos2+$L2);
$scheck=strtolower($s);
}
}
}
while (($pos1!==false)and($pos2!==false));
return $myarray;
}
$content = file_get_contents($url);
$myarray = hyperlinkextract("href=\"","\"",$content);
print "<font size=3><b>Links for: $url</b></font><br>";
print "<font size=3><b>Link Count: ";
echo count($myarray, COUNT_RECURSIVE);
print "</b></font>";
foreach($myarray as $key => $val) {
$position = $key + 1;
print("<p>");
print $position. ' ';
print "<font color=red><b>";
print "$val";
print "</b></font>";
}
?>
<!-----------------------Source Viewer Script--------------------------->
PHP Code:
<?
error_reporting(0);
$url = $_REQUEST[url];
?>
PHP Code:
<?
if ( isset($url) )
{
$source = file_get_contents($url);
$source = str_replace("<", "<", $source);
$source = str_replace(">", ">", $source);
function get_file_size ($url)
{
$url = parse_url($url);
$fp = fsockopen($url[host],80,$errno,$errstr,30);
socket_set_blocking($fp, TRUE);
if (! $fp) { return 0; }
fwrite($fp, "HEAD $url[path] HTTP/1.0\r\nHost: $url[host]\r\n\r\n");
for($result = ""; !feof($fp); $result .= fread($fp, 10000000));
fclose($fp);
if (preg_match("/content-length:\\s?(\\d+)/i", $result, $match)){
return $match[1];
} else {
return 0;
}
}
echo "<center><textarea name=\"area\" cols=\"100\" rows=\"10\" onBlur=\"doResize()\" onKeypress=\"KeyP()\">";
echo "$source";
echo "</textarea><br><br><br><br></center>";
}
?>
Comment