<?php
// fileinfotable.php
// Create table of information about filespec or differences with files of filespec or report about dead links or zip files
// RJM Programming
// October, 2014

$sword = 'Submit';
$fmh = ' omyh1=document.getElementById("myh1"); if (urlsuf != "" && omyh1.innerHTML.indexOf(" Please wait ") == -1) { omyh1.innerHTML = omyh1.innerHTML + " ... Please wait while we analyze your URLs ... "; } ';
$fsev = ' document.getElementById("files").addEventListener("change", handleFileSelect, false); ';
$iscalled = "";
$mode = "Read bytes";
$title = "<a target=_blank href=./fileinfotable.php?zipfile= title=Zipfile>File</a> Information Table";
$rtitle = "File Functionality";
$snapshot = "";
$myfe = "myf=";
$flh = "";
$omyh1stuff = "";
$fnameis = "";
$lnameis = "";
$pnameis = "";
$undefined = " ";
$urlsuffix = "";
$urllist = "";
$statuslist = "";
$linelist = "";
$collist = "";
$askwhentwo = "";
$outrepis = "";
$zipcnt = 0;

if (isset($_GET['myf'])) {
$huhis = explode("strong>", $_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']);
}
} else if (isset($_GET['differences'])) {
$askwhentwo = " "; //if (bigj == 1) { alert(881); document.getElementById(\"f1name\").value = ininf; } else if (bigj == 2) { alert(888); document.getElementById(\"f2name\").value = ininf; document.getElementById(\"ddiff\").style.display=\"block\"; document.getElementById(\"btwo\").click(); } ";
$urlsuffix = "?differences=" . urlencode(urldecode($_GET['differences']));
$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 = "<a target=_blank href=./fileinfotable.php?zipfile= title=Zipfile>File</a> <a target=_blank href=./fileinfotable.php title=Information>Differences</a> Table";
$deadlinks = "n";
$myfe = "differences=Report%20list%20of%20file%20differences%20of%20file%20list&myf=";
if ($_GET['differences'] == "") {
$mode = "Report list of file differences of file list";
} else {
$mode = urldecode($_GET['differences']);
}
$outrepis = diffask();
} else if (isset($_POST['differences'])) {
$askwhentwo = " "; //if (bigj == 1) { alert(882); document.getElementById(\"f1name\").value = ininf; } else if (bigj == 2) { alert(887); document.getElementById(\"f2name\").value = ininf; document.getElementById(\"ddiff\").style.display=\"block\"; document.getElementById(\"btwo\").click(); } ";
$urlsuffix = "?deadlinks=" . urlencode(urldecode($_POST['differences']));
$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 = "<a target=_blank href=./fileinfotable.php?zipfile= title=Zipfile>File</a> <a target=_blank href=./fileinfotable.php title=Information>Differences</a> Table";
$deadlinks = "n";
$myfe = "differences=Report%20list%20of%20file%20differences%20of%20file%20list&myf=";
if ($_POST['differences'] == "") {
$mode = "Report list of file differences of file list";
} else {
$mode = urldecode($_POST['differences']);
}
$outrepis = diffask();


} else if (isset($_GET['zipfile'])) {
if (isset($_GET['fnum'])) {
$zipf = zipfile();
if ($zipf != "") {
if (file_exists($zipf)) {
$zipfs = explode("/", $zipf);
$myext = $zipfs[sizeof($zipfs) - 1];
$mydir = str_replace("/" . $myext, "/", $zipf);
echo "<html><body onload=' parent.document.getElementById(\"xsubmit\").value = \"Download\"; parent.document.getElementById(\"ext\").value = \"" . $myext . "\"; parent.document.getElementById(\"dir\").value = \"" . $mydir . "\"; '></body></html>";
}
}
if ($_GET['fnum'] != 0) exit;
} else if (isset($_POST['dir']) && isset($_POST['ext'])) {
if (strpos($_POST['dir'], "/tmp/zips/") !== false) {
header('Content-Type: application/zip');
header('Content-Disposition: inline; filename=' . $_POST['ext']) ;
//header("Content-Length: ". filesize($_POST['dir'] . $_POST['ext']));
echo file_get_contents($_POST['dir'] . $_POST['ext']);
}
}
$sword = 'Zip';
$askwhentwo = " "; //if (bigj == 1) { alert(881); document.getElementById(\"f1name\").value = ininf; } else if (bigj == 2) { alert(888); document.getElementById(\"f2name\").value = ininf; document.getElementById(\"ddiff\").style.display=\"block\"; document.getElementById(\"btwo\").click(); } ";
$urlsuffix = "?zipfile=" . urlencode(urldecode($_GET['zipfile']));
$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 = "<a target=_blank href=./fileinfotable.php title=File>Zipfile</a> <a target=_blank href=./fileinfotable.php?differences= title=Differences>Information</a> Table";
$deadlinks = "no";
$myfe = "zipfile=Report%20list%20of%20zipped%20up%20files&myf=";
if ($_GET['zipfile'] == "") {
$mode = "Zip up file";
} else {
$mode = urldecode($_GET['zipfile']);
}
} else if (isset($_POST['zipfile'])) {
if (isset($_GET['fnum'])) {
$zipf = zipfile();
if ($zipf != "") {
if (file_exists($zipf)) {
$zipfs = explode("/", $zipf);
$myext = $zipfs[sizeof($zipfs) - 1];
$mydir = str_replace("/" . $myext, "/", $zipf);
echo "<html><body onload=' parent.document.getElementById(\"xsubmit\").value = \"Download\"; parent.document.getElementById(\"ext\").value = \"" . $myext . "\"; parent.document.getElementById(\"dir\").value = \"" . $mydir . "\"; '></body></html>";
}
}
if ($_GET['fnum'] != 0) exit;
} else if (isset($_POST['dir']) && isset($_POST['ext'])) {
if (strpos($_POST['dir'], "/tmp/zips/") !== false) {
header('Content-Type: application/zip');
header('Content-Disposition: inline; filename=' . $_POST['ext']) ;
//header("Content-Length: ". filesize($_POST['dir'] . $_POST['ext']));
echo file_get_contents($_POST['dir'] . $_POST['ext']);
}
}
$sword = 'Zip';
$askwhentwo = " "; //if (bigj == 1) { alert(882); document.getElementById(\"f1name\").value = ininf; } else if (bigj == 2) { alert(887); document.getElementById(\"f2name\").value = ininf; document.getElementById(\"ddiff\").style.display=\"block\"; document.getElementById(\"btwo\").click(); } ";
$urlsuffix = "?zipfile=" . urlencode(urldecode($_POST['zipfile']));
$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 = "<a target=_blank href=./fileinfotable.php title=File>Zipfile</a> <a target=_blank href=./fileinfotable.php?differences= title=Differences>Information</a> Table";
$deadlinks = "no";
$myfe = "zipfile=Report%20list%20of%20zipped%20up%20files&myf=";
if ($_POST['zipfile'] == "") {
$mode = "Report list of zipped up files";
} else {
$mode = urldecode($_POST['zipfile']);
}
//$outrepis = diffask();

}


$youthtml = "<input type='hidden' id='cntzip' name='cntzip' value='0' /><form id=tf name=tf style='display:none;background-color:lightgreen;' align='center' border=5 method='POST' action='" . $_SERVER['PHP_SELF'] . $urlsuffix . "'>";
$youthtml .= "<input type='hidden' name='ans' id='ans' value=''></input><br>";
$youthtml .= "<input type='submit' name='yxsubmit' id='yxsubmit' value='Submit'></input></form>";

function zipfile() {
$backidea = "";
$ks = explode(";", $_GET['fnum']);
$k = $ks[sizeof($ks) - 1];
try {
exec('mkdir /tmp/zips');
} catch (Exception $qw) {
}
try {
exec('mkdir /tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])));
} catch (Exception $qwq) {
}
if ($k > 0) {
if (sizeof($ks) > 1) {
if (!file_exists('/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/' . basename($ks[0]))) {
//$uriPhp = 'data://' . substr($_POST['z' . $k . 'data'], 5);
//$binary = file_get_contents($uriPhp);
// Strip the crud from the front of the string [1]
if (1 == 2 && isset($_FILES['z' . $k . 'data'])) {
file_put_contents('/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/' . basename($ks[0]), file_get_contents($_FILES['z' . $k . 'data']['tmp_name']));
} else {


$pf = $_POST['z' . $k . 'data'];
if (strpos($_POST['filename'], "data%") !== false) {
$pf = urldecode($_POST['z' . $k . 'data']);
}
file_put_contents('/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/' . basename($ks[0]), file_get_contents($pf));

//$stuffs = explode(",", $_POST['z' . $k . 'data']);
//$encodeString = substr($_POST['z' . $k . 'data'],strpos($_POST['z' . $k . 'data'],",")+1);
//$encodeString = str_replace(' ', '+', $encodeString);
//$decoded = base64_decode($encodedString);

//file_put_contents('/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/' . basename($ks[0]), $decoded);
}
}
} else if (isset($_POST['z' . $k . 'name']) && $_POST['z' . $k . 'name'] != "") {
if (!file_exists('/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/' . basename($_POST['z' . $k . 'name']))) {
//$uriPhp = 'data://' . substr($_POST['z' . $k . 'data'], 5);
//$binary = file_get_contents($uriPhp);

$pf = $_POST['z' . $k . 'data'];
if (strpos($_POST['filename'], "data%") !== false) {
$pf = urldecode($_POST['z' . $k . 'data']);
}
file_put_contents('/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/' . basename($ks[0]), file_get_contents($pf));

//$stuffs = explode(",", $_POST['z' . $k . 'data']);
//$encodeString = substr($_POST['z' . $k . 'data'],strpos($_POST['z' . $k . 'data'],",")+1);
//$encodeString = str_replace(' ', '+', $encodeString);
//$decoded = base64_decode($encodedString);

//file_put_contents('/tmp/zips/x.x', file_get_contents('/tmp/zips/x.x') . "\nfile=" . basename($_POST['z' . $k . 'name']));
//file_put_contents('/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/' . basename($_POST['z' . $k . 'name']), $decoded);
}
} else if (isset($_FILES['z' . $k . 'name'])) {
if (!file_exists('/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/' . basename($_POST['z' . $k . 'name']))) {
file_put_contents('/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/' . basename($ks[0]), file_get_contents($_FILES['z' . $k . 'data']['tmp_name']));
}
} else {
//file_put_contents('/tmp/zips/x.x', file_get_contents('/tmp/zips/x.x') . "\ncmd=" . 'zip -mrjT /tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '_' . basename($_GET['zname']) . ' /tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/*');
$backidea = '/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '_' . basename($_GET['zname']);
exec('zip -mrjT /tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '_' . basename($_GET['zname']) . ' /tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/*');
}
}
return $backidea;
}

function diffask() {
$ourrepis = "";
if (isset($_POST['f1data'])) {
exec(' mkdir /tmp/diffs');
file_put_contents("/tmp/diffs/" . basename($_POST['f1name']), $_POST['f1data']);
$ffile = "/tmp/diffs/" . basename($_POST['f1name']);
if ($_POST['f2data'] == "") {
$ourrepis = "<p>Filename " . $_POST['f1name'] . " on its lonesome but you'll be pleased to know it does not have a split personality.</p>";
} else {
$ssdir = "diffs/";
file_put_contents("/tmp/" . $ssdir . basename($_POST['f2name']), $_POST['f2data']);
exec(' diff "' . $ffile . '" "/tmp/' . $ssdir . basename($_POST['f2name']) . '" > /tmp/diffs/xd.xd ');
//$ourrepis = "Filename " . $_POST['f1name'] . " differs from filename " . $_POST['f2name'] . " as below:<br><br><textarea style='width:100%;height:700px;'>" . str_replace("<", "<", str_replace(">", ">", file_get_contents("/tmp/diffs/xd.xd"))) . "</textarea>";
$ourrepis = "Filename " . $_POST['f1name'] . " differs from filename " . $_POST['f2name'] . " as below:<br><br><textarea style='width:100%;height:700px;'>" . str_replace("\r", "", file_get_contents("/tmp/diffs/xd.xd")) . "</textarea>";
exec(' rm -f /tmp/diffs/xd.xd');
exec(' rm -f "' . $ffile . '"');
exec(' rm -f "/tmp/' . $ssdir . basename($dir . $fsp . $ext) . '"');
}
}
return $ourrepis;
}


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 "<html><body><script type='text/javascript'> top.document.title='" . $ine . "'; top.document.body.innerHTML = top.document.body.innerHTML + '<p>" . str_replace("\n", "", $ine) . "</p><br>'; </script><p>" . $ine . "</p></body></html>";
}

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 == "=") {
if (strpos($bstr, "'") !== false && strpos($bstr, '"') !== false) {
if (strpos($bstr, "'") < strpos($bstr, '"')) {
$sdelim = "'";
} else {
$sdelim = '"';
}
}
}
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] . "<br>";
if (url_exists($pstr . $turl[0])) {
$statuslist .= "exists<br>";
} else {
$statuslist .= "<font color=red>does not</font> exist<br>";
}
$linelist .= $ourln . "<br>";
$collist .= $ourcp . "<br>";
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<sizeof($interimst); $ik++) {
$xinst = $interimst[$ik];
$iposis = strpos($interimst[$ik], "http");
while ($iposis !== false) {
if ($iposis == 0) {
$interimst[$ik] = "xxxx" . substr($xinst, ($iposis + 4));
if (substr($xinst, ($iposis + 4), 1) != "_" && substr($xinst, ($iposis + 4), 1) != "-") $urlbit = pluck("", "http", substr($xinst, ($iposis + 4)), "\n", ($ik + 1), ($iposis + 1));
$outst .= $urlbit;
$xinst = $interimst[$ik];
$urlbit = "";
} else {
$interimst[$ik] = substr($xinst, 0, $iposis) . "xxxx" . substr($xinst, ($iposis + 4));
if (substr($xinst, ($iposis + 4), 1) != "_" && substr($xinst, ($iposis + 4), 1) != "-") $urlbit = pluck(substr($xinst, ($iposis - 1), 1), "http", substr($xinst, ($iposis + 4)), "\n", ($ik + 1), ($iposis + 1));
$xinst = $interimst[$ik];
$outst .= $urlbit;
$urlbit = "";

}
$iposis = strpos($interimst[$ik], "http");
}

$iposis = strpos($interimst[$ik], "HTTP");
while ($iposis !== false) {
if ($iposis == 0) {
$interimst[$ik] = "xxxx" . substr($xinst, ($iposis + 4));
if (substr($xinst, ($iposis + 4), 1) != "_" && substr($xinst, ($iposis + 4), 1) != "-") $urlbit = pluck("", "HTTP", substr($xinst, ($iposis + 4)), "\n", ($ik + 1), ($iposis + 1));
$xinst = $interimst[$ik];
$outst .= $urlbit;
$urlbit = "";
} else {
$interimst[$ik] = substr($xinst, 0, $iposis) . "xxxx" . substr($xinst, ($iposis + 4));
if (substr($xinst, ($iposis + 4), 1) != "_" && substr($xinst, ($iposis + 4), 1) != "-") $urlbit = pluck(substr($xinst, ($iposis - 1), 1), "HTTP", substr($xinst, ($iposis + 4)), "\n", ($ik + 1), ($iposis + 1));
$xinst = $interimst[$ik];
$outst .= $urlbit;
$urlbit = "";
}
$iposis = strpos($interimst[$ik], "HTTP");
}
}

return $outst;
}

function readandprocess($infl) {
global $fnameis;
global $lnameis;
global $pnameis;
global $flh, $urlsuffix;
$fnameis = "";
$endl = "";
$outfl = "<table>";
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<sizeof($urls); $ij++) {
$urls[$ij] = prelook($urls[$ij]);
if ($urls[$ij] != "") {
$endl = "";
if (strpos(substr(trim($urls[$ij]), 8), "/") === false) $urls[$ij] = trim($urls[$ij]) . "/";
if (url_exists($urls[$ij] . $endl)) {
$outfl .= "<tr><td><b>" . $urls[$ij] . $endl . "</b> exists" . $fnameis . $lnameis . $pnameis . ".</td></tr>";
} else {
$outfl .= "<tr><td><b>" . $urls[$ij] . $endl . "</b> <font color=red>does not</font> exist" . $fnameis . $lnameis . $pnameis . ".</td></tr>";
}
$flh = "";
}
}
$outfl .= "</table>";
}
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) . " <font color=red>does not</font> exist" . $fnameis . $lnameis . $pnameis . ".\n");
} else {
file_put_contents($to, file_get_contents($to) . urldecode($on) . " <font color=red>does not</font> 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 if ($deadlinks == "n") {
$fsp = "*";
$ext = ".php";
} 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 if ($deadlinks != "n") {
$dir = 'http://';
}

if ($iscalled == "") {
$outhtml = "<!DOCTYPE html>\n<html><head><title>" . $rtitle . "</title>\n";

$outhtml .= '
<script type="text/javascript">
var which="' . $sword . '";
var xwhat="xsubmit";
var what="/tmp/zips/";

var imgmode=" ";
var omyh1;
var fcont="";
var bigi=0;
var bigj=0;
var wl="";
var doneonce="";
var presm="sm";
var bigbuffer="";
var prevmy_res="";
var bigf=new Array();
var urlsuf="' . str_replace("?differences=", "", str_replace("?zipfile=", "", $urlsuffix)) . '";
var zipcnt=' . $zipcnt . ';

function lookoutfor() {
if (document.getElementById("af").value != "" && document.getElementById("vf").value != "") {
if (document.getElementById("afilename").value != "" && document.getElementById("vfilename").value != "") {
var huhav=prompt("Do you want a synchronized playing of " + document.getElementById("af").value + " with " + document.getElementById("vf").value + " ?", "Yes");
document.getElementById("af").value = "";
document.getElementById("vf").value = "";
if (huhav != null) {
if (huhav == "Yes") {
document.getElementById("avtable").style.display = "block";
document.getElementById("abt").style.display = "block";
document.getElementById("asubmit").click();
document.getElementById("vsubmit").click();
location.href = "#abt";
}
}
}
}

}

function mh() { ' . $fmh . ' }

function btwoclick() {
//alert(document.getElementById("flist").value);
document.getElementById("btwo").click();
document.getElementById("btwo").style.display = "none";
}

function dlbclick() {
//alert(document.getElementById("flist").value);
document.getElementById("dlb").click();
}

function check(thisfordelim) {
var outval = thisfordelim.value;
if (outval.length > 0) {
if ((outval + "@!@").indexOf(String.fromCharCode(47) + "@!@") == -1 && (outval + "@!@").indexOf(String.fromCharCode(92) + "@!@") == -1) {
if (outval.indexOf(String.fromCharCode(92)) != -1) {
outval = outval + String.fromCharCode(92);
thisfordelim.value = outval;
} else if (outval.indexOf(String.fromCharCode(47)) != -1) {
outval = outval + String.fromCharCode(47);
thisfordelim.value = outval;
} else {
outval = outval + String.fromCharCode(47);
thisfordelim.value = outval;
}
}
}
return outval;
}

function readBlob(opt_startByte, opt_stopByte) {

omyh1 = document.getElementById("myh1");

' . $omyh1stuff . '

var files = document.getElementById("file").files;
if (!files.length) {
alert("Please select a file!");
return;
}

var file = files[0];
var start = parseInt(opt_startByte) || 0;
var stop = parseInt(opt_stopByte) || file.size - 1;

var reader = new FileReader();

if ((imgmode == " " && file.type.match(' . "'" . 'image.*' . "'" . ') && "' . $deadlinks . '" != "n") || "' . $deadlinks . '" == "no") {
imgmode = "y";
} else if (imgmode == " ") {
imgmode = "";
}



if ("' . $deadlinks . '" != "n" && "' . $deadlinks . '" != "nowayjose" && (imgmode == "y" || file.type.match(' . "'" . 'image.*' . "'" . ') || file.type.indexOf(' . "'" . '/pdf' . "'" . ') != -1 || file.type.indexOf(' . "'" . 'audio/' . "'" . ') != -1 || file.type.indexOf(' . "'" . 'video/' . "'" . ') != -1 || file.type.indexOf(' . "'" . 'application/' . "'" . ') != -1)) {
// Closure to capture the file information.
reader.onload = (function(theFile) {
return function(e) {



if ("' . $deadlinks . '" == "no") { // zipping files scenario ... yay one
var ond=0; //parseInt(document.getElementById("cntzip").value);
var dno=eval(1 + ond);
if (escape(theFile.name) != "" && document.body.innerHTML.indexOf("*" + escape(theFile.name) + "*") == -1) {
document.body.innerHTML = document.body.innerHTML + "<p style=display:none;>*" + escape(theFile.name) + "*</p>";
//alert(dno);
document.getElementById("cntzip").value = dno;
//alert(document.getElementById("cntzip").value);
var maybe=prompt("Zipping " + theFile.name + " ... is this okay? When all done, click the Download button to access the zip file.", "Yes");
if (maybe == null || maybe != "Yes") {
maybe = maybe;
} else {
document.getElementById("z" + dno + "name").value = escape(theFile.name);
document.getElementById("fzip" + dno).action = document.getElementById("fzip" + dno).action.replace("fnum=", "fnum=" + escape(theFile.name) + ";");
document.getElementById("izip" + dno).src = document.getElementById("izip" + dno).src.replace("fnum=", "fnum=" + escape(theFile.name) + ";");

document.getElementById("z" + dno + "data").value = e.target.result;
document.getElementById("bzip" + dno).click();
setTimeout(zclick, 5000);
}
}
} else {


// Render thumbnail.
if (document.body.innerHTML.indexOf(' . "'" . '" title="' . "'" . ' + escape(theFile.name) + ' . "'" . "'" . ' ) == -1) {
var vid = theFile.name.replace(".","");
var mvid = theFile.name.replace(".","m");
if (theFile.type.indexOf("image/") != -1 || theFile.type.indexOf("/pdf") != -1 || theFile.type.indexOf("audio/") != -1 || theFile.type.indexOf("video/") != -1 || theFile.type.indexOf("application/") != -1) {
var span = document.createElement("span");
var elt = "img";
if (theFile.type.indexOf("image/") == -1) elt = "iframe";

if (theFile.type.indexOf("/pdf") != -1) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_pdf.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
} else if (theFile.type.indexOf("audio/") != -1) {
//alert(11);
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_external.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
if (document.getElementById("afilename").value == "") {
document.getElementById("afilename").value = ((encodeURIComponent(e.target.result)));
//alert(1);
document.getElementById("af").value = theFile.name;
}
} else if (theFile.type.indexOf("video/") != -1) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_external.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
if (document.getElementById("vfilename").value == "") {
document.getElementById("vfilename").value = ((encodeURIComponent(e.target.result)));
//alert(2);
document.getElementById("vf").value = theFile.name;
}
} else if (theFile.type.indexOf("application/") != -1 && theFile.type.indexOf("spreadsheet") != -1) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_xls.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
} else if (theFile.type.indexOf("application/") != -1 && (theFile.type.indexOf("document") != -1 || theFile.type.indexOf("msword") != -1)) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_doc.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
} else if (theFile.type.indexOf("application/") != -1) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_popup.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
} else {
span.innerHTML = [' . "'" . '<img onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
}
document.getElementById(' . "'" . 'imglist' . "'" . ').insertBefore(span, null);
}
var xxxx="<p id="' . "" . ' + mvid + ' . "" . '" align=center>Filename is <strong>" + maybemedia(escape(theFile.name) + "</strong> ... Type is (" + (theFile.type || "n/a") + ") ... Date is ") + (theFile.lastModifiedDate ? theFile.lastModifiedDate.toLocaleDateString() : "n/a") + " ... Size is " + theFile.size + " bytes </p>";
var span1 = document.createElement("span");
span1.innerHTML = xxxx;
document.getElementById(' . "'" . 'imglist' . "'" . ').insertBefore(span1, null);
if (theFile.type.indexOf("image/") != -1 || theFile.type.indexOf("/pdf") != -1 || theFile.type.indexOf("audio/") != -1 || theFile.type.indexOf("video/") != -1 || theFile.type.indexOf("application/") != -1) {
var span2 = document.createElement("span");
if (theFile.type.indexOf("/pdf") != -1) {
span2.innerHTML = [' . "'" . '<iframe class=big id="' . "'" . ' + vid + ' . "'" . '" style="display:none;" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
} else if (theFile.type.indexOf("audio/") != -1) {
span2.innerHTML = [' . "'" . '<audio controls=controls autoplay=autoplay class=big id="' . "'" . ' + vid + ' . "'" . '" style="display:none;" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
if (document.getElementById("afilename").value == "") {
document.getElementById("afilename").value = ((encodeURIComponent(e.target.result)));
document.getElementById("af").value = theFile.name;
}
} else if (theFile.type.indexOf("video/") != -1) {
span2.innerHTML = [' . "'" . '<video controls=controls autoplay=autoplay class=big id="' . "'" . ' + vid + ' . "'" . '" style="display:none;" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
if (document.getElementById("vfilename").value == "") {
document.getElementById("vfilename").value = ((encodeURIComponent(e.target.result)));
document.getElementById("vf").value = theFile.name;
}
} else if (theFile.type.indexOf("application/") != -1) {
span2.innerHTML = [' . "'" . '<iframe class=big id="' . "'" . ' + vid + ' . "'" . '" style="display:none;" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
} else {
span2.innerHTML = [' . "'" . '<img class=big id="' . "'" . ' + vid + ' . "'" . '" style="display:none;" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
}
document.getElementById(' . "'" . 'imglist' . "'" . ').insertBefore(span2, null);
}
}
}
};
})(file);

reader.readAsDataURL(file);

} else if (imgmode == "y") {
// Closure to capture the file information.
reader.onload = (function(theFile) {
return function(e) {
var vid = theFile.name.replace(".","");
var mvid = theFile.name.replace(".","m");
var xxxx="<p id="' . "" . ' + mvid + ' . "" . '" align=center>Filename is <strong>" + maybemedia(escape(theFile.name) + "</strong> ... Type is (" + (theFile.type || "n/a") + ") ... Date is ") + (theFile.lastModifiedDate ? theFile.lastModifiedDate.toLocaleDateString() : "n/a") + " ... Size is " + theFile.size + " bytes </p>";
var span1 = document.createElement("span");
span1.innerHTML = xxxx;
document.getElementById(' . "'" . 'imglist' . "'" . ').insertBefore(span1, null);
};
})(file);

reader.readAsDataURL(file);

} else {



// If we use onloadend, we need to check the readyState.

reader.onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
document.getElementById("byte_content").textContent = evt.target.result;
document.getElementById("byte_range").textContent =
["Read bytes: ", start + 1, " - ", stop + 1,
" of ", file.size, " byte file"].join("");
';
if ($deadlinks == "n" && 1 == 2) { // differences table
$outhtml .= '
if (document.getElementById("f1data").value == "") {
alert(1718);
document.getElementById("f1data").value = evt.target.result;
alert(543);
} else if (document.getElementById("f2data").value == "") {
document.getElementById("f2data").value = evt.target.result;
}
';
}
$outhtml .= '
process(evt.target.result);
}
};
var blob = file.slice(start, stop + 1);
reader.readAsBinaryString(blob);
}


}

function doonload() {
';

$outhtml .= '
setInterval(lookoutfor, 5000);
omyh1 = document.getElementById("myh1");

if (window.File && window.FileReader && window.FileList && window.Blob) {
var iii=0;
} else {
document.getElementById("files").style.display = "none";
document.getElementById("file").style.display = "none";
if (1 == 2) { alert("The File APIs are not fully supported in this browser."); }
}
var ourf=location.search.split("myf=")[1] ? location.search.split("myf=")[1].split("&")[0] : "";
document.body.innerHTML = document.body.innerHTML + decodeURIComponent(ourf);

document.querySelector(' . "'.readBytesButtons'" . ').addEventListener(' . "'click'" . ', function(evt) {
if (evt.target.tagName.toLowerCase() == "button") {
var startByte = evt.target.getAttribute("data-startbyte");
var endByte = evt.target.getAttribute("data-endbyte");
readBlob(startByte, endByte);
}
}, false);

' . $fsev . '

}


function maybemedia(inidea) {
var outidea = inidea;
var parts = inidea.split("<");
var pdfi = "icon_pdf.gif";
var doci = "icon_doc.gif";
var xlsi = "icon_xls.gif";
var appi = "icon_popup.gif";
var audioi = "icon_external.gif";
var dparts = String.fromCharCode(34) + parts[0] + String.fromCharCode(34);
var videoi = "icon_external.gif";
if (inidea.indexOf("/pdf") != -1) {
outidea = inidea.replace(" Type is ", "<img onclick=window.open(' . "'" . '" + parts[0] + "' . "'" . ',' . "'" . '_blank' . "'" . '); width=45 height=45 src=' . "'" . '" + pdfi + "' . "'" . ' title=' . "'" . '" + parts[0] + "' . "'" . ' /> Type is ");
} else if (inidea.indexOf("audio/") != -1) {
outidea = inidea.replace(" Type is ", "<img onclick=window.open(' . "'" . '" + parts[0] + "' . "'" . ',' . "'" . '_blank' . "'" . '); width=45 height=45 src=' . "'" . '" + audioi + "' . "'" . ' title=' . "'" . '" + parts[0] + "' . "'" . ' /> Type is ");
} else if (inidea.indexOf("video/") != -1) {
outidea = inidea.replace(" Type is ", "<img onclick=window.open(' . "'" . '" + parts[0] + "' . "'" . ',' . "'" . '_blank' . "'" . '); width=45 height=45 src=' . "'" . '" + videoi + "' . "'" . ' title=' . "'" . '" + parts[0] + "' . "'" . ' /> Type is ");
} else if (inidea.indexOf("application/") != -1 && inidea.indexOf("spreadsheet") != -1) {
outidea = inidea.replace(" Type is ", "<img onclick=window.open(' . "'" . '" + parts[0] + "' . "'" . ',' . "'" . '_blank' . "'" . '); width=45 height=45 src=' . "'" . '" + xlsi + "' . "'" . ' title=' . "'" . '" + parts[0] + "' . "'" . ' /> Type is ");
} else if (inidea.indexOf("application/") != -1 && (inidea.indexOf("document") != -1 || inidea.indexOf("msword") != -1)) {
outidea = inidea.replace(" Type is ", "<img onclick=window.open(' . "'" . '" + parts[0] + "' . "'" . ',' . "'" . '_blank' . "'" . '); width=45 height=45 src=' . "'" . '" + doci + "' . "'" . ' title=' . "'" . '" + parts[0] + "' . "'" . ' /> Type is ");
} else if (inidea.indexOf("application/") != -1) {
outidea = inidea.replace(" Type is ", "<img onclick=window.open(' . "'" . '" + parts[0] + "' . "'" . ',' . "'" . '_blank' . "'" . '); width=45 height=45 src=' . "'" . '" + appi + "' . "'" . ' title=' . "'" . '" + parts[0] + "' . "'" . ' /> Type is ");
} else if (inidea.indexOf("image/") != -1) {
outidea = inidea.replace(" Type is ", "<img onclick=window.open(' . "'" . '" + parts[0] + "' . "'" . ',' . "'" . '_blank' . "'" . '); width=45 height=45 src=' . "'" . '" + parts[0] + "' . "'" . ' title=' . "'" . '" + parts[0] + "' . "'" . ' /> Type is ");
}
//alert(outidea);
return outidea;
}

function process(infilecontents) {
if (infilecontents != null) {
if (1 == 7) { alert(infilecontents); }
var ourlines = infilecontents.split(String.fromCharCode(10));
';
if ($deadlinks == "y") {
$outhtml .= '
if (1 == 1) {
document.getElementById("flist").value = document.getElementById("flist").value + justhttp(ourlines);
document.getElementById("dlb").click();
} else {
for (var jj=0; jj<ourlines.length; jj++) {
document.getElementById("dli").src = "./fileinfotable.php?deadlinks=&justreporton=" + encodeURIComponent(ourlines[jj]);
}
}
';
} else {
$outhtml .= '
var ourwords, ourwordcnt = 0; //infilecontents.split(String.fromCharCode(32));
for (var jjj=0; jjj<ourlines.length; jjj++) {
ourwords = ourlines[jjj].split(String.fromCharCode(32));
ourwordcnt = eval(ourwordcnt + ourwords.length);
}

if (1 == 2 && ((document.getElementById("file").files[0].type || "n/a").indexOf("image/") != -1 || (document.getElementById("file").files[0].type || "n/a").indexOf("/pdf") != -1 || (document.getElementById("file").files[0].type || "n/a").indexOf("audio/") != -1 || (document.getElementById("file").files[0].type || "n/a").indexOf("video/") != -1 || (document.getElementById("file").files[0].type || "n/a").indexOf("application/") != -1)) {
window.open(document.getElementById("file").value, "_blank");
document.getElementById("media").width = "500px";
document.getElementById("media").height = "500px";
document.getElementById("media").style.display = "block";
document.getElementById("media").src = document.getElementById("file").value;
}

//var myfis = "<br><br><p id=myf align=center>Filename is <strong>" + escape(document.getElementById("file").files[0].mozFullPath + document.getElementById("file").value) + "</strong> ... Type is (" + (document.getElementById("file").files[0].type || "n/a") + ") ... Date is " + (document.getElementById("file").files[0].lastModifiedDate ? document.getElementById("file").files[0].lastModifiedDate.toLocaleDateString() : "n/a") + " ... Size is " + infilecontents.length + " bytes ... Line Count is " + ourlines.length + " ... Word Count is " + ourwords.length + "</p>";
var myfis = "<br><br><p id=myf align=center>Filename is <strong>" + maybemedia(escape(document.getElementById("file").value) + "</strong> ... Type is (" + (document.getElementById("file").files[0].type || "n/a") + ") ... Date is ") + (document.getElementById("file").files[0].lastModifiedDate ? document.getElementById("file").files[0].lastModifiedDate.toLocaleDateString() : "n/a") + " ... Size is " + infilecontents.length + " bytes ... Line Count is " + ourlines.length + " ... Word Count is " + ourwordcnt + "</p>";
document.body.innerHTML = document.body.innerHTML + myfis;
var huh = document.URL.replace("?diffeXXXrences=", "").split("?");
if (huh.length > 1) {
location.href = huh[0] + "?' . $myfe . '" + decodeURIComponent(myfis);
} else {
location.href = document.URL + "?' . $myfe . '" + decodeURIComponent(myfis);
}
fcont = infilecontents;
';
}
$outhtml .= '
}
}

function nocaret(iinf, lno, jpos, inc) {
var prenoinc = inc.split("<");
var noinc = prenoinc[0].split(String.fromCharCode(92));
if (jpos > 0) return noinc[0].replace("http", "http(" + iinf + "|" + lno + "@" + jpos + ")").replace("HTTP", "HTTP(" + iinf + "|" + lno + "@" + jpos + ")");
return noinc[0].replace("http", "http(" + iinf + "|" + lno + ")").replace("HTTP", "HTTP(" + iinf + "|" + lno + ")");
}

function justhttps(instr, ininfo) {
//document.title = ininfo;
if (bigf[bigj] == null || bigf[bigj] == undefined) {
bigf[bigj] = document.getElementById("file").value;
}
if (1 == 2) {
if (document.getElementById("f1data").value == "") {
alert(178);
document.getElementById("f1data").value = instr;
alert(179);
} else if (document.getElementById("f2data").value == "") {
document.getElementById("f2data").value = instr;
}
}
return justhttp(instr.split(String.fromCharCode(eval(0 + 10))), bigf[bigj]); // ininfo);
}

function justhttp(inarr, ininf) {
var outst = "", arec = "", ipos = 0, httparr, ijkh, otherarr, endl = "", qpos = 0;
bigj = bigj + 1; ' . $askwhentwo . '
//alert(ininf);
for (var iq=0; iq<inarr.length; iq++) {
arec = inarr[iq];
if (arec.indexOf("http") == 0 || arec.indexOf("HTTP") == 0) {
endl = "";
//if (inarr[iq].substring(8).indexOf("/") == -1) endl = "/";
outst = outst + nocaret(ininf,eval(iq + 1),1,inarr[iq] + endl) + String.fromCharCode(eval(0 + 10));
arec = "";
} else if (arec.indexOf("http") == 1 || arec.indexOf("HTTP") == 1) {
endl = "";
//if (inarr[iq].replace(inarr[iq].substring(0,1), "").replace(inarr[iq].substring(0,1), "").substring(8).indexOf("/") == -1) endl = "/";
outst = outst + nocaret(ininf,eval(iq + 1),2,inarr[iq].replace(inarr[iq].substring(0,1), "").replace(inarr[iq].substring(0,1), "")) + endl + String.fromCharCode(eval(0 + 10));
arec = "";
}
if (arec.indexOf("http") > 1) {
while (arec.indexOf("http") > 1) {
qpos = eval(1 + arec.indexOf("http"));
httparr = arec.split("http");
for (ijkh=1; ijkh<httparr.length; ijkh++) {
endl = "";
otherarr = httparr[ijkh].split(httparr[eval(-1 + ijkh)].substring(eval(-1 + httparr[eval(-1 + ijkh)].length)));
if (otherarr[0].substring(0,1) != "_") {
//if (otherarr[0].substring(4).indexOf("/") == -1) endl = "/";
outst = outst + nocaret(ininf,eval(iq + 1),qpos,"http" + otherarr[0] + endl) + String.fromCharCode(eval(0 + 10));
}
arec = arec.replace("http", "xxxx");
}
}
}
if (arec.indexOf("HTTP") > 1) {
while (arec.indexOf("HTTP") > 1) {
qpos = eval(1 + arec.indexOf("HTTP"));
httparr = arec.split("HTTP");
for (ijkh=1; ijkh<httparr.length; ijkh++) {
endl = "";
otherarr = httparr[ijkh].split(httparr[eval(-1 + ijkh)].substring(eval(-1 + httparr[eval(-1 + ijkh)].length)));
if (otherarr[0].substring(0,1) != "_") {
//if (otherarr[0].substring(4).indexOf("/") == -1) endl = "/";
outst = outst + nocaret(ininf,eval(iq + 1),qpos,"HTTP" + otherarr[0] + endl) + String.fromCharCode(eval(0 + 10));
}
arec = arec.replace("HTTP", "xxxx");
}
}
}
}
//alert(outst);
return outst;
}

function zclick() {
zipcnt = eval((zipcnt % 10) + 1);
//for (var ip=0; ip<zipcnt; ip++) {
// document.getElementById("bzip" + ip).click();
//}
//document.getElementById("cntzip").value = zipcnt;
document.getElementById("z" + zipcnt + "name").value = "";
document.getElementById("z" + zipcnt + "data").value = "";
document.getElementById("bzip" + zipcnt).click();

}

function handleFileSelect(evt) {
var ourcont="";
var readers = new Array();
var f;
var thelines;
var thewords;
var files = evt.target.files; // FileList object

// files is a FileList of File objects. List some properties.
var output = [];
var file; // = files[0];
var start; // = parseInt(opt_startByte) || 0;
var stop; // = parseInt(opt_stopByte) || file.size - 1;
var blob; // = file.slice(start, stop + 1);



omyh1 = document.getElementById("myh1");

' . $omyh1stuff . '

document.getElementById("list").innerHTML = "";
try {
document.getElementById("xlist").innerHTML = "";
} catch (exx) {
}

if (document.body.innerHTML.indexOf("my" + "res") == -1) {
document.body.innerHTML = document.body.innerHTML + "<span id=my" + "res style=display:none;>~" + "~</span>";
} else {
prevmy_res = document.getElementById("my" + "res").innerHTML;
document.getElementById("my" + "res").innerHTML = "~" + "~";
}



for (var i = 0, f; f = files[i]; i++) {
bigf[bigf.length] = f.name;
document.getElementById("fname").value = f.name;
bigi = eval(1 + i);
file = f;
start = 0;
fcont = "";
stop = file.size - 1;

readers[readers.length] = new FileReader();

if ((imgmode == " " && file.type.match(' . "'" . 'image.*' . "'" . ') && "' . $deadlinks . '" != "n") || "' . $deadlinks . '" == "no") {
imgmode = "y";
} else if (imgmode == " ") {
imgmode = "";
}

if ("' . $deadlinks . '" == "n") {
if (document.getElementById("f1name").value == "") {
document.getElementById("f1name").value = f.name;
} else if (document.getElementById("f2name").value == "") {
document.getElementById("f2name").value = f.name;
}
} else if ("' . $deadlinks . '" == "no") {
if (zipcnt == 0) setTimeout(zclick, 5000);
zipcnt = eval((zipcnt % 10) + 1);
document.getElementById("z" + zipcnt + "name").value = f.name;
}


// Only process image files.
if ("' . $deadlinks . '" != "n" && "' . $deadlinks . '" != "nowayjosE" && (imgmode == "y" || file.type.match(' . "'" . 'image.*' . "'" . ') || file.type.indexOf(' . "'" . '/pdf' . "'" . ') != -1 || file.type.indexOf(' . "'" . 'audio/' . "'" . ') != -1 || file.type.indexOf(' . "'" . 'video/' . "'" . ') != -1 || file.type.indexOf(' . "'" . 'application/' . "'" . ') != -1)) {
// Closure to capture the file information.
readers[readers.length - 1].onload = (function(theFile) {
return function(e) {




if ("' . $deadlinks . '" == "no") { // zipping files scenario ... yay
var ond=0; //parseInt(document.getElementById("cntzip").value);
var dno=eval(1 + ond);
if (escape(theFile.name) != "" && document.body.innerHTML.indexOf(">*" + escape(theFile.name) + "*<") == -1) {
dno=eval(1 + dno);
}
document.body.innerHTML = document.body.innerHTML + "<p style=display:none;>*" + escape(theFile.name) + "*</p>";
//alert(dno);
document.getElementById("cntzip").value = dno;
//alert(document.getElementById("cntzip").value);
var maybe=prompt("Zipping " + theFile.name + " ... is this okay? When all done, click the Download button to access the zip file.", "Yes");
if (maybe == null || maybe != "Yes") {
maybe = maybe;
} else {
document.getElementById("z" + dno + "data").value = e.target.result;
document.getElementById("z" + dno + "name").value = escape(theFile.name);
document.getElementById("fzip" + dno).action = document.getElementById("fzip" + dno).action.replace("fnum=", "fnum=" + escape(theFile.name) + ";");
document.getElementById("izip" + dno).src = document.getElementById("izip" + dno).src.replace("fnum=", "fnum=" + escape(theFile.name) + ";");

document.getElementById("bzip" + dno).click();
setTimeout(zclick, 5000);
}
} else {



// Render thumbnail.
if (document.body.innerHTML.indexOf(' . "'" . '" title="' . "'" . ' + escape(theFile.name) + ' . "'" . "'" . ' ) == -1) {
var vid=escape(theFile.name).replace(".","");
var mvid = theFile.name.replace(".","m");
if (theFile.type.indexOf("image/") != -1 || theFile.type.indexOf("/pdf") != -1 || theFile.type.indexOf("audio/") != -1 || theFile.type.indexOf("video/") != -1 || theFile.type.indexOf("application/") != -1) {
var span = document.createElement("span");
var elt = "img";
if (theFile.type.indexOf("image/") == -1) elt = "iframe";
if (theFile.type.indexOf("/pdf") != -1) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_pdf.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
} else if (theFile.type.indexOf("audio/") != -1) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_external.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
if (document.getElementById("afilename").value == "") {
document.getElementById("afilename").value = ((encodeURIComponent(e.target.result)));
//alert(1);
document.getElementById("af").value = theFile.name;
}
} else if (theFile.type.indexOf("video/") != -1) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_external.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
if (document.getElementById("vfilename").value == "") {
document.getElementById("vfilename").value = ((encodeURIComponent(e.target.result)));
//alert(1);
document.getElementById("vf").value = theFile.name;
}
} else if (theFile.type.indexOf("application/") != -1 && theFile.type.indexOf("spreadsheet") != -1) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_xls.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
} else if (theFile.type.indexOf("application/") != -1 && (theFile.type.indexOf("document") != -1 || theFile.type.indexOf("msword") != -1)) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_doc.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
} else if (theFile.type.indexOf("application/") != -1) {
span.innerHTML = [' . "'" . '<a class=pdfa href=#' . "'" . ' + vid + ' . "'" . ' onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"><img src=icon_popup.gif title=Pdf />' . "'" . ' + escape(theFile.name) + ' . "'" . '</a>' . "'" . '].join(' . "'" . '' . "'" . ');
} else {
span.innerHTML = [' . "'" . '<img onclick=document.getElementById("' . "'" . ' + vid + ' . "'" . '").style.display="block"; class="thumb" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
}
document.getElementById(' . "'" . 'imglist' . "'" . ').insertBefore(span, null);
}
var xxxx="<p id="' . "" . ' + mvid + ' . "" . '" align=center>Filename is <strong>" + maybemedia(escape(theFile.name) + "</strong> ... Type is (" + (theFile.type || "n/a") + ") ... Date is ") + (theFile.lastModifiedDate ? theFile.lastModifiedDate.toLocaleDateString() : "n/a") + " ... Size is " + theFile.size + " bytes </p>";
var span1 = document.createElement("span");
span1.innerHTML = xxxx;
document.getElementById(' . "'" . 'imglist' . "'" . ').insertBefore(span1, null);
if (theFile.type.indexOf("image/") != -1 || theFile.type.indexOf("/pdf") != -1 || theFile.type.indexOf("audio/") != -1 || theFile.type.indexOf("video/") != -1 || theFile.type.indexOf("application/") != -1) {
var span2 = document.createElement("span");
var elt = "img";
if (theFile.type.indexOf("image/") == -1) elt = "iframe";

// .xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
// .docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
// .ods application/vnd.oasis.opendocument.spreadsheet
// .odb application/vnd.oasis.opendocument.database
// .odf application/vnd.oasis.opendocument.formula
// .pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
// .doc application/msword
// .htm* text/html

if (theFile.type.indexOf("/pdf") != -1) {
span2.innerHTML = [' . "'" . '<iframe class=big id="' . "'" . ' + vid + ' . "'" . '" style="display:none;" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
} else if (theFile.type.indexOf("audio/") != -1) {
span2.innerHTML = [' . "'" . '<audio controls=controls autoplay=autoplay class=big id="' . "'" . ' + vid + ' . "'" . '" style="display:none;" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
if (document.getElementById("afilename").value == "") {
document.getElementById("afilename").value = ((encodeURIComponent(e.target.result)));
//alert(1);
document.getElementById("af").value = theFile.name;
}
} else if (theFile.type.indexOf("video/") != -1) {
span2.innerHTML = [' . "'" . '<video controls=controls autoplay=autoplay class=big id="' . "'" . ' + vid + ' . "'" . '" style="display:none;" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
if (document.getElementById("vfilename").value == "") {
document.getElementById("vfilename").value = e.target.result;
//alert(1);
document.getElementById("vf").value = theFile.name;
}
} else if (theFile.type.indexOf("application/") != -1) {
span2.innerHTML = [' . "'" . '<iframe class=big id="' . "'" . ' + vid + ' . "'" . '" style="display:none;" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
} else {
span2.innerHTML = [' . "'" . '<img class=big id="' . "'" . ' + vid + ' . "'" . '" style="display:none;" src="' . "'" . ', e.target.result,
' . "'" . '" title="' . "'" . ', escape(theFile.name), ' . "'" . '"/>' . "'" . '].join(' . "'" . '' . "'" . ');
}
document.getElementById(' . "'" . 'imglist' . "'" . ').insertBefore(span2, null);
}
}
}
};
})(file);

readers[readers.length - 1].readAsDataURL(file);
} else if (imgmode == "y") {
readers[readers.length - 1].onload = (function(theFile) {
return function(e) {
var mvid = theFile.name.replace(".","m");
var xxxx="<p id="' . "" . ' + mvid + ' . "" . '" align=center>Filename is <strong>" + maybemedia(escape(theFile.name) + "</strong> ... Type is (" + (theFile.type || "n/a") + ") ... Date is ") + (theFile.lastModifiedDate ? theFile.lastModifiedDate.toLocaleDateString() : "n/a") + " ... Size is " + theFile.size + " bytes </p>";
var span1 = document.createElement("span");
span1.innerHTML = xxxx;
};
})(file);

readers[readers.length - 1].readAsDataURL(file);
} else {



// If we use onloadend, we need to check the readyState.
readers[readers.length - 1].onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
var xfcont=evt.target.result;
var thoselines = xfcont.split(String.fromCharCode(10));
';
if ($deadlinks == "n") { // differences table
$outhtml .= '
if (document.getElementById("f1data").value == "") {
document.getElementById("f1data").value = evt.target.result;
} else if (document.getElementById("f2data").value == "") {
document.getElementById("f2data").value = evt.target.result;
document.getElementById("ddiff").style.display="block";
setTimeout(btwoclick, 1000); // document.getElementById("btwo").click();
}
';
} else if ($deadlinks == "no") { // zip files
$outhtml .= '
//alert(parseInt(document.getElementById("cntzip").value));
var ond=parseInt(document.getElementById("cntzip").value);
var dno=eval(1 + ond);
//alert(dno);
document.getElementById("cntzip").value = dno;
//alert(document.getElementById("cntzip").value);
document.getElementById("z" + dno + "data").value = evt.target.result;
var maybe=prompt("ZippinG " + document.getElementById("z" + dno + "name").value + " ... is this okay?", "Yes");
if (maybe == null || maybe != "Yes") {
maybe = maybe;
} else {
document.getElementById("z" + dno + "name").value = document.getElementById("z" + dno + "name").value;
document.getElementById("fzip" + dno).action = document.getElementById("fzip" + dno).action.replace("fnum=", "fnum=" + document.getElementById("z" + dno + "name").value + ";");
document.getElementById("izip" + dno).src = document.getElementById("izip" + dno).src.replace("fnum=", "fnum=" + document.getElementById("z" + dno + "name").value + ";");
document.getElementById("bzip" + dno).click();
}
';
}
if ($deadlinks == "y") {
$outhtml .= '
if (1 == 1) {
bigbuffer = bigbuffer + evt.target.result + String.fromCharCode(10);
document.getElementById("flist").value = document.getElementById("flist").value + justhttps(evt.target.result, document.getElementById("fname").value);
}
';
}
$outhtml .= '
var thosewordscnt = 0, thosewords = xfcont.split(String.fromCharCode(32));

var ourwords, ourwordcnt = 0; //infilecontents.split(String.fromCharCode(32));
for (var jjjj=0; jjjj<thoselines.length; jjjj++) {
thosewords = thoselines[jjjj].split(String.fromCharCode(32));
thosewordscnt = eval(thosewordscnt + thosewords.length);
}

if (document.body.innerHTML.indexOf("~" + "~") == -1) {
document.body.innerHTML = document.body.innerHTML + "<span id=my" + "res style=display:none;>;" + document.getElementById("fname").value + "~" + thoselines.length + "~" + thosewordscnt + "~" + "~</span>";
} else {
document.body.innerHTML = document.body.innerHTML.replace("~" + "~", ";" + document.getElementById("fname").value + "~" + thoselines.length + "~" + thosewordscnt + "~" + "~");
}
var sofar = document.getElementById("my" + "res").innerHTML;
var sofars = sofar.split(";");
var sofarlw;
for (var j=1; j<sofars.length; j++) {
if (sofars[j] != "") {
sofarlw = sofars[j].split("~");
document.getElementById("l" + j).innerHTML = sofarlw[1];
document.getElementById("w" + j).innerHTML = sofarlw[2];
}
document.getElementById("prelist").value = encodeURIComponent(document.getElementById("list").innerHTML);
}
}

};
output.push("<li>Filename is <strong>", escape(f.name), "</strong> ... Type is (", f.type || "n/a", ") ... Date is ",
f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : "n/a", " ... Size is ",
f.size, " bytes ... Line Count is <span id=l" + bigi + ">", "", "</span> ... Word Count is <span id=w" + bigi + ">", "", "</span>",
"</li>");

blob = file.slice(start, stop + 1);
readers[readers.length - 1].readAsText(blob, "UTF-8");
}


}
document.getElementById("list").innerHTML = "<ul>" + output.join("") + "</ul>";
document.getElementById("prelist").value = encodeURIComponent(document.getElementById("list").innerHTML);
doneonce="y";
';
if ($deadlinks == "y") {
$outhtml .= '
if (1 == 1) {
if (omyh1.innerHTML.indexOf(" Please wait ") == -1) { omyh1.innerHTML = omyh1.innerHTML + " ... Please wait while we analyze your URLs ... "; }
setTimeout(dlbclick, 5000);
if (1 == 2) {
if (document.getElementById("flist").value == "") {
if (bigbuffer != "" || 1 == 1) alert(document.getElementById("my" + "res").innerHTML + " " + "Please wait while we analyze your URLs ... click OK now please.");
document.getElementById("flist").value = document.getElementById("flist").value + justhttps(bigbuffer, document.getElementById("my" + "res").innerHTML + prevmy_res);
}
bigbuffer="";
document.getElementById("dlb").click();
}
}
';
}
$outhtml .= '
}


</script>
';

$outhtml .= '<style>
.thumb {
height: 75px;
border: 1px solid #000;
margin: 10px 5px 0 0;
}
.pdfa {
border: 1px solid yellow;
margin: 10px 5px 0 0;
}
.pdfa:visited {
border: 1px solid yellow;
margin: 10px 5px 0 0;
color: lightgreen;
}
.pdfa:hover {
border: 1px solid yellow;
margin: 10px 5px 0 0;
color: yellow;
}
.big {
border: 9px solid pink;
margin: 10px 5px 0 0;
}
</style></head>' . "\n";
if (isset($_POST['flist'])) {
$outhtml .= "<body style='background-color:yellow;' onload='doonload(); '>" . $youthtml . $outrepis . "<input type='hidden' id='fname' name='fname' style='display:none;' value=''></input><iframe id='media' src='javascript:none;' width=1 height=1 style='display:none;'></iframe><iframe id='dli' src='javascript:none;' width=1 height=1 style='display:none;'></iframe><h1 id='myh1' align='center'>" . str_replace(" Information ", " <a target=_blank href=./fileinfotable.php?differences= title=Differences>Information</a> ", str_replace(">Report", "> Report", str_replace(" Differences ", " <a target=_blank href=./fileinfotable.php title=Information>Differences</a> ", str_replace("Table", "<a target=_blank href=./fileinfotable.php?deadlinks= title=DeadLinks>Table</a>", str_replace(" Report", " <a target=_blank href=./fileinfotable.php title=Information>Report</a>", $title))))) . "</h1>";
$outhtml .= '<form id="myfdl" name="myfdl" style="display:none;" method="POST" action="./fileinfotable.php' . $urlsuffix . '"><input type="hidden" name="myf" id="myf" value=""></input><input type="hidden" name="flist" id="flist" value=""></input><input type="hidden" name="deadlinks" id="deadlinks" value="Report list of dead links of file of Absolute URLs"></input><input onclick="' . $omyh1stuff . '" type="submit" name="dlb" id="dlb" value="DeadLinks"></input></form>';
//$snapshot = $outhtml . "<p align=center>Please wait while we analyze your URLs ...</p><br>";
//echo $snapshot;
//$snapshot = "<div id=dac align=center> " . readandprocess($_POST['flist']) . "</div>";
$outhtml .= "<p align=center>Please wait while we analyze your URLs ...</p><br>";
$outhtml .= "<div id=dac align=center> " . readandprocess($_POST['flist']) . "</div>";
} else {
$outhtml .= "<body style='background-color:yellow;' onload='doonload();'>" . $youthtml . $outrepis . "<input type='hidden' id='fname' name='fname' style='display:none;' value=''></input><iframe id='media' src='javascript:none;' width=1 height=1 style='display:none;'></iframe><iframe id='dli' src='javascript:none;' width=1 height=1 style='display:none;'></iframe><h1 id='myh1' align='center'>" . str_replace(" Information ", " <a target=_blank href=./fileinfotable.php?differences= title=Differences>Information</a> ", str_replace(">Report", "> Report", str_replace(" Differences ", " <a target=_blank href=./fileinfotable.php title=Information>Differences</a> ", str_replace("Table", "<a target=_blank href=./fileinfotable.php?deadlinks= title=DeadLinks>Table</a>", str_replace(" Report", " <a target=_blank href=./fileinfotable.php title=Information>Report</a>", $title))))) . "</h1>";
$outhtml .= '<form id="myfdl" name="myfdl" style="display:none;" method="POST" action="./fileinfotable.php' . $urlsuffix . '"><input type="hidden" name="myf" id="myf" value=""></input><input type="hidden" name="flist" id="flist" value=""></input><input type="hidden" name="deadlinks" id="deadlinks" value="Report list of dead links of file of Absolute URLs"></input><input onclick="' . $omyh1stuff . '" type="submit" name="dlb" id="dlb" value="DeadLinks"></input></form>';
//$snapshot = $outhtml;
}
$outhtml .= "<div align='center'><form id=tf name=tf style='background-color:lightgreen;' align='center' border=5 method='POST' action='" . $_SERVER['PHP_SELF'] . $urlsuffix . "'>";
$outhtml .= "<input type='hidden' name='fsp' id='fsp' value=''></input><br>";
$outhtml .= "Filepath (or URL): <input size=120 type='text' name='dir' id='dir' value='" . $dir . "' onblur=' if (this.value != what) { document.getElementById(xwhat).value=which; } if (this.value.length > 0) { check(this); }'></input><br><br>";
$outhtml .= "Filespec (or Name): <input size=120 type='text' name='ext' id='ext' value='" . $fsp . $ext . "'></input><br><br>";
$outhtml .= "<input onclick='" . $omyh1stuff . "' type='submit' name='xsubmit' id='xsubmit' value='Submit'></input>";
$outhtml .= "</form></div><div align='center' style='background-color:orange;'><br><br><h2>... or ...</h2>";
$moi = $_SERVER['PHP_SELF'];
if (1 == 1) { // Thanks to http://www.html5rocks.com/en/tutorials/file/dndfiles/
$outhtml .= '<input onmouseover=" if (doneonce.length > 0) { document.getElementById(presm).click(); } " type="file" id="files" name="files[]" multiple />';
if (isset($_POST['prelist'])) { $outhtml .= '<div id="xlist" name="xlist">' . urldecode($_POST['prelist']) . '</div><br>' . '<output id="imglist" name="imglist"></output><output id="list" name="list"></output>'; } else { $outhtml .= '<output id="imglist" name="imglist"></output><output id="list" name="list"></output>'; }
$outhtml .= '<form id="myfx" name="myfx" style="display:none;" method="POST" action="./fileinfotable.php' . $urlsuffix . '"><input type="hidden" name="prelist" id="prelist" value=""></input><input onclick="' . $omyh1stuff . '" type="submit" name ="sm" id="sm" value="Presubmit" style="display:none;"></input></form></div>';
if ($deadlinks != "") {
//$outhtml = $snapshot . '<div align="center" style="background-color:lightgray;"><br><br>';
if ($deadlinks == "n") { // differences table ... needs at least two files
$outhtml .= '<div id=ddiff align="center" style="background-color:lightgray;display:none;width:98%;height:800px;"><iframe style="width:96%;height:780px;" id=idiff name=idiff src=./fileinfotable.php?differences=></iframe><form id=topf name=topf action="./fileinfotable.php?differences=" method="POST" target="idiff"><input type="hidden" name="f1data" id="f1data" value="" /><input type="hidden" name="f2data" id="f2data" value="" /><input type="hidden" name="f1name" id="f1name" value="" /><input type="hidden" name="f2name" id="f2name" value="" /><input id="btwo" name="btwo" type="submit" value="Differences" /></form></div><br>';
$outhtml .= '<div align="center" style="background-color:lightgray;display:none;"><br><br>';
} else if ($deadlinks == "no") {
$outhtml .= '<div id=dzip align="center" style="background-color:lightgray;display:none;width:98%;height:800px;">' . "\n";
date_default_timezone_set('Australia/Perth');
$dsuff = "_" . date('Ymd');
for ($iw=1; $iw<=10; $iw++) {
//$outhtml .= '<iframe style="width:1;height:1;" id=izip' . $iw .' name=izip' . $iw .' src="./fileinfotable.php?zname=Archive.zip&fnum=' . $iw .'&zipfile=' . $_GET['zipfile'] . '"></iframe><form enctype="multipart/form-data" id=fzip' . $iw .' name=fzip' . $iw .' action="./fileinfotable.php?zname=Archive.zip&fnum=' . $iw .'&zipfile=' . $_GET['zipfile'] . '" method="POST" target="izip' . $iw .'"><fieldset><input type="hidden" name="MAX_FILE_SIZE" value="10000000" /><input type="file" name="z' . $iw .'data" id="z' . $iw .'data" value="" /><input type="hidden" name="z' . $iw .'name" id="z' . $iw .'name" value="" /></fieldset><input id="bzip' . $iw .'" name="bzip' . $iw .'" type="submit" value="Zip" /></form>' . "\n";
$outhtml .= '<iframe style="width:1;height:1;" id=izip' . $iw .' name=izip' . $iw .' src="./fileinfotable.php?zname=Archive' . $dsuff . '.zip&fnum=' . $iw .'&zipfile=' . $_GET['zipfile'] . '"></iframe><form id=fzip' . $iw .' name=fzip' . $iw .' action="./fileinfotable.php?zname=Archive' . $dsuff . '.zip&fnum=' . $iw .'&zipfile=' . $_GET['zipfile'] . '" method="POST" target="izip' . $iw .'"><input type="hidden" name="z' . $iw .'data" id="z' . $iw .'data" value="" /><input type="hidden" name="z' . $iw .'name" id="z' . $iw .'name" value="" /><input id="bzip' . $iw .'" name="bzip' . $iw .'" type="submit" value="Zip" /></form>' . "\n";
}
$outhtml .= '</div>' . "\n";
$outhtml .= '<div align="center" style="background-color:lightgray;"><br><br>';
} else {
$outhtml .= '<div align="center" style="background-color:lightgray;"><br><br>';
}
} else if ($deadlinks == "n") { // differences table ... needs at least two files
$outhtml .= '<div id=ddiff align="center" style="background-color:lightgray;display:none;"><iframe id=idiff src=./fileinfotable.php?differences=></iframe></div><br>';
$outhtml .= '<div align="center" style="background-color:lightgray;display:none;"><br><br>';
} else if ($deadlinks == "no") {
$outhtml .= '<div id=dzip align="center" style="background-color:lightgray;display:none;width:98%;height:800px;">' . "\n";
date_default_timezone_set('Australia/Perth');
$dsuff = "_" . date('Ymd');
for ($iw=1; $iw<=10; $iw++) {
//$outhtml .= '<iframe style="width:1;height:1;" id=izip' . $iw .' name=izip' . $iw .' src="./fileinfotable.php?zname=Archive.zip&fnum=' . $iw .'&zipfile=' . $_GET['zipfile'] . '"></iframe><form enctype="multipart/form-data" id=fzip' . $iw .' name=fzip' . $iw .' action="./fileinfotable.php?zname=Archive.zip&fnum=' . $iw .'&zipfile=' . $_GET['zipfile'] . '" method="POST" target="izip' . $iw .'"><fieldset><input type="hidden" name="MAX_FILE_SIZE" value="10000000" /><input type="file" name="z' . $iw .'data" id="z' . $iw .'data" value="" /><input type="hidden" name="z' . $iw .'name" id="z' . $iw .'name" value="" /></fieldset><input id="bzip' . $iw .'" name="bzip' . $iw .'" type="submit" value="Zip" /></form>' . "\n";
$outhtml .= '<iframe style="width:1;height:1;" id=izip' . $iw .' name=izip' . $iw .' src="./fileinfotable.php?zname=Archive' . $dsuff . '.zip&fnum=' . $iw .'&zipfile=' . $_GET['zipfile'] . '"></iframe><form id=fzip' . $iw .' name=fzip' . $iw .' action="./fileinfotable.php?zname=Archive' . $dsuff . '.zip&fnum=' . $iw .'&zipfile=' . $_GET['zipfile'] . '" method="POST" target="izip' . $iw .'"><input type="hidden" name="z' . $iw .'data" id="z' . $iw .'data" value="" /><input type="hidden" name="z' . $iw .'name" id="z' . $iw .'name" value="" /><input id="bzip' . $iw .'" name="bzip' . $iw .'" type="submit" value="Zip" /></form>' . "\n";
}
$outhtml .= '</div>' . "\n";
$outhtml .= '<div align="center" style="background-color:lightgray;"><br><br>';
} else {
$outhtml .= '<div align="center" style="background-color:lightgray;"><br><br><h2>... or ...</h2>';
}
$outhtml .= '<input type="file" id="file" name="file" /> <span id="mode" name="mode">' . $mode . '</span>:
<span class="readBytesButtons">
<button data-startbyte="0" data-endbyte="4" style="display:none;">1-5</button>
<button data-startbyte="5" data-endbyte="14" style="display:none;">6-15</button>
<button data-startbyte="6" data-endbyte="7" style="display:none;">7-8</button>
<button onclick="readBlob(0,0);" onmouseover=" bigf[bigf.length] = document.getElementById(' . "'" . 'file' . "'" . ').value; document.getElementById(' . "'" . 'myf' . "'" . ').value = document.getElementById(' . "'" . 'file' . "'" . ').value; ">Process</button>
</span>
<div id="byte_range" style="display:none;"></div>
<div id="byte_content" style="display:none;"></div>
';
} else {
$outhtml .= '
<form style="background-color: #E4E4E4;" action="' . $moi . '" method="post" enctype="multipart/form-data">

<fieldset align="center">
<legend align="center">Browse for local file</legend>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<input style="background-color: yellow;" size="100" type="file" id="browsefile" name="browsefile" onchange="analyze();" />
</fieldset>
<input style="color: green;display:none;" type="submit" name="submit" value="Browse for File" />
</form>
';
}
$outhtml .= "</div>";
$outhtml .= "</body></html>";
} else {
$goes = 0;
$sdir = "diffs/";
$outhtml = "<html><head><title>" . $title . " for " . $dir . $fsp . $ext . "</title></head>\n";
$dc = "<th>Date</th>";
$sb = "<th>Size (bytes)</th>";
$lc = "<th>Lines</th>";
$wc = "<th>Words</th>";
if ($urlsuffix != "") {
if (isset($_GET['differences'])) {
$dc = "<th id=fn1></th>";
$sb = "<th>Vs</th>";
$lc = "<th>Filename</th>";
$wc = "<th id=fn2></th>";
} else {
$dc = "<th>URL</th>";
$sb = "<th>Status</th>";
$lc = "<th>On Line</th>";
$wc = "<th>At Column</th>";
}
}
if ($dir == "") {
$outhtml .= "<body style='background-color:yellow;'><h1 align='center'>" . $title . " for " . $dir . $fsp . $ext . "</h1><table style='background-color:lightgreen;' align='center' border=5 cellpadding=12 cellspacing=8><tr style='background-color:lightblue;'>";
$outhtml .= "<th id=th1><a href='./fileinfotable.php" . $urlsuffix . "' title='Another go?'>Filename</a></th>" . $dc . "" . $sb . "" . $lc . "" . $wc . "</tr>";
} else {
$outhtml .= "<body style='background-color:yellow;'><h1 align='center'>" . $title . " for " . $dir . $fsp . $ext . "</h1><table style='background-color:lightgreen;' align='center' border=5 cellpadding=12 cellspacing=8><tr style='background-color:lightblue;'>";
$outhtml .= "<th id=th1>Filename in <a href='./fileinfotable.php" . $urlsuffix . "' title='Another go?'>" . $dir . "</a></th>" . $dc . "" . $sb . "" . $lc . "" . $wc . "</tr>";
}


// File from 1 of the 2 bottom 2/3 ideas of local files
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)) {
if (isset($_GET['differences'])) { // file differences table
if ($goes == 0) {
$outhtml .= " <script> document.getElementById('fn1').innerHTML = '" . basename($dir . $fsp . $ext) . "'; </script> ";
exec(' mkdir /tmp/diffs');
file_put_contents("/tmp/diffs/" . basename($dir . $fsp . $ext), file_get_contents($dir . $fsp . $ext));
$ffile = "/tmp/diffs/" . basename($dir . $fsp . $ext);
$goes = 1;
$sdir = "";
}
if ($goes == 1) {
$outhtml .= " <script> document.getElementById('fn2').innerHTML = '" . basename($dir . $fsp . $ext) . "'; </script> ";
file_put_contents("/tmp/" . $sdir . basename($dir . $fsp . $ext), file_get_contents($dir . $fsp . $ext));
exec(' diff "' . $ffile . '" "/tmp/' . $sdir . basename($dir . $fsp . $ext) . '" > /tmp/diffs/xd.xd ');
$outhtml .= "<tr><td colspan=5>" . "<textarea style='width:100%;height:700px;'>" . str_replace("\r", "", file_get_contents("/tmp/diffs/xd.xd")) . "</textarea></td></tr>";
exec(' rm -f /tmp/diffs/xd.xd');
exec(' rm -f "' . $ffile . '"');
exec(' rm -f "/tmp/' . $sdir . basename($dir . $fsp . $ext) . '"');
}
} else { // non file differences options
$cdt = "";
$cont = file_get_contents($dir . $fsp . $ext);
if ($urlsuffix != "") {
readandprocess($fsp . $ext . "@!~*^@" . $cont); // new ideas here
$outhtml .= "<tr><td>" . str_replace($dir, "", $dir . $fsp . $ext) . "</td><td>" . $urllist . "</td><td>" . $statuslist . "</td><td>" . $linelist . "</td><td>" . $collist . "</td></tr>";
$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 .= "<tr><td>" . str_replace($dir, "", $dir . $fsp . $ext) . "</td><td>" . $cdt . "</td><td>" . strlen($cont) . "</td><td>" . count($recs) . "</td><td>" . count($words) . "</td></tr>";
}
}
}
} else { // top third idea from web server files
$redir = "";
if (isset($_GET['zipfile'])) { // zipping files
try {
exec('mkdir /tmp/zips');
} catch (Exception $qw) {
}
try {
exec('mkdir /tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])));
} catch (Exception $qwq) {
}
}

foreach (glob($dir . $fsp . $ext) as $filename) {

if (url_exists($filename)) {
if (isset($_GET['zipfile'])) { // zipping files
if (strpos($dir, "/tmp/zips/") === false && strpos($ext, ".zip") === false && strpos($fsp, "Archive") === false) {
date_default_timezone_set('Australia/Perth');
$redir = "y";
$dsuff = "_" . date('Ymd');
//echo $filename . ' ' . '/tmp/zips/' . basename($filename) . ' ' . 'zip -mrjT /tmp/zips/' . str_replace(":", "_", $_SERVER['REMOTE_ADDR']) . '_' . 'Archive' . $dsuff . '.zip /tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/*';
copy($filename, '/tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/' . basename($filename));
exec('zip -mrjT /tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '_' . 'Archive' . $dsuff . '.zip /tmp/zips/' . str_replace(".", "_", str_replace(":", "_", $_SERVER['REMOTE_ADDR'])) . '/*');
}
} else if (isset($_GET['differences'])) { // file differences table
if ($goes == 0) {
$outhtml .= " <script> document.getElementById('fn1').innerHTML = '" . basename($filename) . "'; </script> ";
exec(' mkdir /tmp/diffs');
file_put_contents("/tmp/diffs/" . basename($filename), file_get_contents($filename));
$ffile = "/tmp/diffs/" . basename($filename);
} else if ($goes == 1) {
$outhtml .= " <script> document.getElementById('fn2').innerHTML = '" . basename($filename) . "'; </script> ";
file_put_contents("/tmp/diffs/" . basename($filename), file_get_contents($filename));
exec(' diff "' . $ffile . '" "/tmp/diffs/' . basename($filename) . '" > /tmp/diffs/xd.xd ');
$outhtml .= "<tr><td colspan=5><textarea style='width:100%;height:700px;'>" . str_replace("\r", "", file_get_contents("/tmp/diffs/xd.xd")) . "</textarea></td></tr>";
exec(' rm -f /tmp/diffs/xd.xd');
exec(' rm -f "' . $ffile . '"');
exec(' rm -f "/tmp/diffs/' . basename($filename) . '"');
}
$goes = $goes + 1;
} else if ($urlsuffix != "") { // dead links report
readandprocess($filename . "@!~*^@" . file_get_contents($filename)); // new ideas here
$outhtml .= "<tr><td>" . str_replace($dir, "", $filename) . "</td><td>" . $urllist . "</td><td>" . $statuslist . "</td><td>" . $linelist . "</td><td>" . $collist . "</td></tr>";
$urllist = "";
$statuslist = "";
$linelist = "";
$collist = "";
} else { // file information table
$lines = file($filename);
$cwords = 0;
foreach ($lines as $line) {
$cwords += str_word_count($line);
}
$outhtml .= "<tr><td>" . str_replace($dir, "", $filename) . "</td><td>" . date("F d Y H:i:s", filemtime($filename)) . "</td><td>" . filesize($filename) . "</td><td>" . count($lines) . "</td><td>" . $cwords . "</td></tr>";
}

}

}
if ($redir == "y") {
header("Location: ./fileinfotable.php?zipfile=&fnum=0");
exit;
}
if ($goes == 1) {
$outhtml .= " <script> document.getElementById('fn2').innerHTML = '" . str_replace("/tmp/diffs/", "", $ffile) . "'; </script> ";
file_put_contents("/tmp/" . str_replace("/tmp/diffs/", "", $ffile), file_get_contents($ffile));
exec(' diff "' . $ffile . '" "/tmp/' . str_replace("/tmp/diffs/", "", $ffile) . '" > /tmp/diffs/xd.xd ');
$outhtml .= "<tr><td colspan=5><textarea style='width:100%;height:700px;'>" . str_replace("\r", "", file_get_contents("/tmp/diffs/xd.xd")) . "</textarea></td></tr>";
exec(' rm -f /tmp/diffs/xd.xd');
exec(' rm -f "' . $ffile . '"');
exec(' rm -f "/tmp/' . str_replace("/tmp/diffs/", "", $ffile) . '"');
}
}
$outhtml .= "</table></body></html>";
}

echo str_replace("</body></html>", "<div align='center'><a id='abt' style='display:none;' href='#myh1' title='Top'>Back to top</a></div><input type='hidden' name='af' id='af' value='' /><input type='hidden' name='vf' id='vf' value='' /><form id='aform' style='display:none;' action='./audio_generic.php' method='POST' target='iaudio'><input type='hidden' name='afilename' id='afilename' value='' /><input type='submit' id='asubmit' name='asubmit' value='Audio' /></form><form id='vform' style='display:none;' action='./video_generic.php' method='POST' target='ivideo'><input type='hidden' name='vfilename' id='vfilename' value='' /><input type='submit' id='vsubmit' name='vsubmit' value='Video' /></form><br><div align='center'><table id='avtable' style='width:100%;display:none;'><tbody><tr><th>Audio</th><th>Video</th></tr><tr><td style='width:48%;'><iframe id='iaudio' name='iaudio' src='javascript:none;' height='900px' width='100%'></iframe></td><td style='width:48%;'><iframe id='ivideo' name='ivideo' src='javascript:none;' height='900px' width='100%'></iframe></td></tr></tbody></table></div><br></body></html>", $outhtml);
}
?>