", $_GET['myf']);
if (sizeof($huhis) >= 3) $undefined = str_replace("", " ", " " . $huhis[1]);
} else if (isset($_POST['myf'])) {
if ($_POST['myf'] != "") $undefined = " " . $_POST['myf'] . " ";
}
if (isset($_GET['deadlinks'])) {
$urlsuffix = "?deadlinks=" . urlencode(urldecode($_GET['deadlinks']));
$omyh1stuff = " mh(); "; //" omyh1=document.getElementById('myh1'); if (omyh1.innerHTML.indexOf(' Please wait ') == -1) { omyh1.innerHTML = omyh1.innerHTML + ' ... Please wait while we analyze your URLs ... '; } ";
$title = "Dead Links via File of Absolute URLs Report";
$deadlinks = "y";
$myfe = "deadlinks=Report%20list%20of%20dead%20links%20of%20file%20of%20URLs&myf=";
if ($_GET['deadlinks'] == "") {
$mode = "Report list of dead links of file of Absolute URLs";
} else {
$mode = urldecode($_GET['deadlinks']);
}
} else if (isset($_POST['deadlinks'])) {
$urlsuffix = "?deadlinks=" . urlencode(urldecode($_POST['deadlinks']));
$omyh1stuff = " mh(); "; //" omyh1=document.getElementById('myh1'); if (omyh1.innerHTML.indexOf(' Please wait ') == -1) { omyh1.innerHTML = omyh1.innerHTML + ' ... Please wait while we analyze your URLs ... '; } ";
$title = "Dead Links via File of Absolute URLs Report";
$deadlinks = "y";
$myfe = "deadlinks=Report%20list%20of%20dead%20links%20of%20file%20of%20URLs&myf=";
if ($_POST['deadlinks'] == "") {
$mode = "Report list of dead links of file of Absolute URLs";
} else {
$mode = urldecode($_POST['deadlinks']);
}
}
function url_exists($url) { // Thanks to http://stackoverflow.com/questions/2280394/how-can-i-check-if-a-url-exists-via-php
global $fnameis;
global $lnameis;
global $pnameis;
global $flh;
$exists = false;
$url = urldecode($url);
if (strpos($url, "https:") !== false || strpos($url, "HTTPS:") !== false || strpos($url, "http:") !== false || strpos($url, "HTTP:") !== false) {
if (strpos(substr(trim($url), 8), "/") === false) $url = trim($url) . "/";
$wordsare = explode("/", $url);
if ($wordsare[sizeof($wordsare) - 1] != "") {
if (strpos($wordsare[sizeof($wordsare) - 1], ".") === false && strpos($wordsare[sizeof($wordsare) - 1], "?") === false && strpos($wordsare[sizeof($wordsare) - 1], "&") === false) {
$url = trim($url) . "/";
}
}
//if (!$fp = curl_init($url)) return false;
//curl_close($fp);
//return true;
$curl = curl_init(); // thanks to http://stackoverflow.com/questions/7852005/how-to-check-if-a-url-exists-with-php-and-make-it-time-out-after-a-number-of-sec
curl_setopt($curl, CURLOPT_URL, trim($url));
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($curl);
curl_close($curl);
preg_match("/HTTP\/1\.[1|0]\s(\d{3})/",$data,$matches);
return ($matches[1] == 200);
} else if (strpos($url, "http:") !== false || strpos($url, "HTTP:") !== false) {
$file = $url;
$file_headers = @get_headers($file);
$flh = $file_headers[0];
if (strpos($file_headers[0], " 404 ") !== false) { // == 'HTTP/1.1 404 Not Found') {
$exists = false;
} else {
$exists = true;
}
} else {
$exists = file_exists($url);
}
return $exists;
}
function echop($ine) {
global $fnameis;
global $lnameis;
global $pnameis;
echo "
" . $ine . "
";
}
function prelook($xinfl) {
global $fnameis;
global $lnameis;
global $pnameis;
global $undefined;
$outinfl = $xinfl;
$fnameis = "";
if (strpos($xinfl, "http(") !== false || strpos($xinfl, "HTTP(") !== false) {
$zxinfl = explode(")", substr($xinfl, 5));
$hbit = "(" . $zxinfl[0] . ")";
$outinfl = str_replace($hbit, "", $outinfl);
$fnameis = str_replace(" undefined ", $undefined, str_replace("(", " in ", str_replace(")", "", str_replace("|", " on line ", str_replace("@", " at column ", $hbit)))));
}
return $outinfl;
}
function pluck($sdelim, $pstr, $bstr, $edelim, $ourln, $ourcp) {
global $urllist, $statuslist, $linelist, $collist, $fnameis;
if ($sdelim == "") {
$preturl = explode($edelim, $bstr);
$pturl = explode("<", $preturl[0]);
$turl = explode(chr(92), $pturl[0]);
} else {
$preturl = explode($sdelim, $bstr);
$pturl = explode("<", $preturl[0]);
$turl = explode(chr(92), $pturl[0]);
}
$endl = "";
if (strpos(substr(trim($pstr . $turl[0]), 8), "/") === false) $turl[0] = trim($turl[0]) . "/";
$urllist .= $pstr . $turl[0] . "
";
if (url_exists($pstr . $turl[0])) {
$statuslist .= "exists
";
} else {
$statuslist .= "does not exist
";
}
$linelist .= $ourln . "
";
$collist .= $ourcp . "
";
return $pstr . "(" . $fnameis . "|" . $ourln . "@" . $ourcp . ")" . $turl[0] . $edelim;
}
function makeintolist($inst) { // via web server filelist via glob
global $urllist, $statuslist, $linelist, $collist, $fnameis, $urlsuffix;
$urlbit = "";
$outst = $inst;
$interimst = $inst;
$interimst = explode("\n", $inst);
if (sizeof($interimst) > 0) $outst = "";
for ($ik=0; $ik";
if (strpos($infl, "@!~*^@") !== false) {
if (strpos($infl, "@!~*^@") < 80) {
$spl = explode("@!~*^@", $infl);
$infl = $spl[1];
$fnameis = $spl[0];
}
}
if ($fnameis != "" || (strpos(("*" . $infl), "*http") === false && strpos(("*" . $infl), "*HTTP") === false)) {
$urls = explode("\n", makeintolist($infl));
$fnameis = "";
if ($urlsuffix != "") $outfl = "";
} else {
$urls = explode("\n", $infl);
}
if ($outfl != "") {
for ($ij=0; $ij exists" . $fnameis . $lnameis . $pnameis . ".";
} else {
$outfl .= "" . $urls[$ij] . $endl . " does not exist" . $fnameis . $lnameis . $pnameis . ". |
";
}
$flh = "";
}
}
$outfl .= "";
}
return $outfl;
}
function on_to($on, $to) {
global $fnameis;
global $lnameis;
global $pnameis;
if (url_exists(urldecode($on))) {
if ($to == "") {
echop(urldecode($on) . " exists" . $fnameis . $lnameis . $pnameis . ".\n");
} else {
file_put_contents($to, file_get_contents($to) . urldecode($on) . " exists" . $fnameis . $lnameis . $pnameis . ".\n");
}
exit;
} else {
if ($to == "") {
echop(urldecode($on) . " does not exist" . $fnameis . $lnameis . $pnameis . ".\n");
} else {
file_put_contents($to, file_get_contents($to) . urldecode($on) . " does not exist" . $fnameis . $lnameis . $pnameis . ".\n");
}
exit;
}
}
$outrep = "";
if (isset($_GET['justreportto'])) {
$outrep = urldecode($_GET['justreportto']);
if (strpos($outrep, "/") === false && strpos($outrep, "\\") === false) {
$outrep = dirname(__FILE__) . "/" . $outrep;
}
} else if (isset($_POST['justreportto'])) {
$outrep = urldecode($_POST['justreportto']);
if (strpos($outrep, "/") === false && strpos($outrep, "\\") === false) {
$outrep = dirname(__FILE__) . "/" . $outrep;
}
}
if (isset($_GET['justreporton'])) {
on_to(urldecode($_GET['justreporton']), $outrep);
exit;
} else if (isset($_POST['justreporton'])) {
on_to(urldecode($_POST['justreporton']), $outrep);
exit;
} else {
if (isset($_GET['fsp'])) {
$iscalled = "y";
$fsp = $_GET['fsp'];
} else if (isset($_POST['fsp'])) {
$iscalled = "y";
$fsp = $_POST['fsp'];
} else if ($deadlinks == "") {
$fsp = "*";
$ext = ".xml";
} else {
$fsp = "index";
$ext = ".html";
}
if (isset($_GET['ext'])) {
if ($iscalled == "") $fsp = "";
$iscalled = "y";
$ext = $_GET['ext'];
} else if (isset($_POST['ext'])) {
if ($iscalled == "") $fsp = "";
$iscalled = "y";
$ext = $_POST['ext'];
} else if ($iscalled != "") {
$ext = "";
}
if (isset($_GET['dir'])) {
$iscalled = "y";
$dir = $_GET['dir'];
} else if (isset($_POST['dir'])) {
$iscalled = "y";
$dir = $_POST['dir'];
} else if ($deadlinks == "") {
$dir = '/'; // '/Library/pgAgent/Downloads/CRL/';
} else {
$dir = 'http://';
}
if ($iscalled == "") {
$outhtml = "\n" . $title . "\n";
$outhtml .= '
';
$outhtml .= '' . "\n";
if (isset($_POST['flist'])) {
$outhtml .= "" . str_replace("Table", "Table", str_replace("Report", "Report", $title)) . "
";
$outhtml .= '';
//$snapshot = $outhtml . "Please wait while we analyze your URLs ...
";
//echo $snapshot;
//$snapshot = " " . readandprocess($_POST['flist']) . "
";
$outhtml .= "Please wait while we analyze your URLs ...
";
$outhtml .= " " . readandprocess($_POST['flist']) . "
";
} else {
$outhtml .= "" . str_replace("Table", "Table", str_replace("Report", "Report", $title)) . "
";
$outhtml .= '';
//$snapshot = $outhtml;
}
$outhtml .= "... or ...
";
$moi = $_SERVER['PHP_SELF'];
if (1 == 1) { // Thanks to http://www.html5rocks.com/en/tutorials/file/dndfiles/
$outhtml .= '
';
if (isset($_POST['prelist'])) { $outhtml .= '
' . urldecode($_POST['prelist']) . '
' . '
'; } else { $outhtml .= '
'; }
$outhtml .= '
';
if ($deadlinks != "") {
//$outhtml = $snapshot . '';
$outhtml .= '
';
} else {
$outhtml .= '
... or ...
';
}
$outhtml .= '
' . $mode . ':
';
} else {
$outhtml .= '
';
}
$outhtml .= "
";
$outhtml .= "";
} else {
$outhtml = "
" . $title . " for " . $dir . $fsp . $ext . "\n";
$dc = "Date";
$sb = "Size (bytes)";
$lc = "Lines";
$wc = "Words";
if ($urlsuffix != "") {
$dc = "URL";
$sb = "Status";
$lc = "On Line";
$wc = "At Column";
}
if ($dir == "") {
$outhtml .= "
" . $title . " for " . $dir . $fsp . $ext . "
";
$outhtml .= "Filename | " . $dc . " | " . $sb . " | " . $lc . " | " . $wc . " |
";
} else {
$outhtml .= "" . $title . " for " . $dir . $fsp . $ext . "
";
$outhtml .= "Filename in " . $dir . " | " . $dc . " | " . $sb . " | " . $lc . " | " . $wc . " |
";
}
if (strpos($dir . $fsp . $ext, "https:") !== false || strpos($dir . $fsp . $ext, "http:") !== false || strpos($dir . $fsp . $ext, "HTTPS:") !== false || strpos($dir . $fsp . $ext, "HTTP:") !== false) {
if (url_exists($dir . $fsp . $ext)) {
$cdt = "";
$cont = file_get_contents($dir . $fsp . $ext);
if ($urlsuffix != "") {
readandprocess($fsp . $ext . "@!~*^@" . $cont); // new ideas here
$outhtml .= "" . str_replace($dir, "", $dir . $fsp . $ext) . " | " . $urllist . " | " . $statuslist . " | " . $linelist . " | " . $collist . " |
";
$urllist = "";
$statuslist = "";
$linelist = "";
$collist = "";
} else {
$recs = explode("\n", $cont);
$words = explode(" ", $cont);
$h = get_headers($dir . $fsp . $ext, 1); // Thanks to http://stackoverflow.com/questions/845220/get-the-last-modified-date-of-a-remote-file
$cdt = "";
try {
$cdt = $h['Last-Modified'];
} catch (Exception $exxx) {
$cdt = "";
}
$outhtml .= "" . str_replace($dir, "", $dir . $fsp . $ext) . " | " . $cdt . " | " . strlen($cont) . " | " . count($recs) . " | " . count($words) . " |
";
}
}
} else {
foreach (glob($dir . $fsp . $ext) as $filename) {
if (url_exists($filename)) {
if ($urlsuffix != "") {
readandprocess($filename . "@!~*^@" . file_get_contents($filename)); // new ideas here
$outhtml .= "" . str_replace($dir, "", $filename) . " | " . $urllist . " | " . $statuslist . " | " . $linelist . " | " . $collist . " |
";
$urllist = "";
$statuslist = "";
$linelist = "";
$collist = "";
} else {
$lines = file($filename);
$cwords = 0;
foreach ($lines as $line) {
$cwords += str_word_count($line);
}
$outhtml .= "" . str_replace($dir, "", $filename) . " | " . date("F d Y H:i:s", filemtime($filename)) . " | " . filesize($filename) . " | " . count($lines) . " | " . $cwords . " |
";
}
}
}
}
$outhtml .= "
";
}
echo $outhtml;
}
?>