<?php
// PHP Linux diff file differences ... RJM Programming November 2013
$called="";
$fillinone="http://";
$fillintwo="http://";
$onec="";
$twoc="";
$suffix="";
$iframebits="";
$onloadbit="";
$suffid="_" . rand();
$lastoi="";
$udirname="";
$ynft="";
$ynftf="";
$eweh="";
$ew="";
$contis="";
$inid="";
$lastonetodelete="";
$bciy="background-color:yellow;";
if (strpos(('' . $_SERVER['QUERY_STRING']), "linkit=") !== false) { // thanks to https://www.sitepoint.com/css-gradients-a-syntax-crash-course/ and https://uigradients.com/#MegaTron
$bciy="background: linear-gradient(to right, #ffe6ee, #FFE2E2, #fadadd, lightpink, pink, #f4c2c2, hotpink, #ff1493);"; // , #f7797d 10%
}
function server_remote_addr() {
$rma = $_SERVER['REMOTE_ADDR'];
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
// you can add different browsers with the same way ..
if(preg_match('/(chromium)[ \/]([\w.]+)/', $ua))
$rma = '000000'.$rma;
elseif(preg_match('/(chrome)[ \/]([\w.]+)/', $ua))
$rma = '00000'.$rma;
elseif(preg_match('/(safari)[ \/]([\w.]+)/', $ua))
$rma = '0000'.$rma;
elseif(preg_match('/(opera)[ \/]([\w.]+)/', $ua))
$rma = '000'.$rma;
elseif(preg_match('/(msie)[ \/]([\w.]+)/', $ua))
$rma = '00'.$rma;
elseif(preg_match('/(mozilla)[ \/]([\w.]+)/', $ua))
$rma = '0'.$rma;
return str_replace(":", "_", $rma);
}
function relative_to_absolute_php($inth) {
global $udirname, $ynft, $ynftf, $eweh, $ew;
$charoneprefix="";
$hds=explode("data:", $inth);
for ($ih=1; $ih<sizeof($hds); $ih++) {
if (sizeof($hds) == 2) { $eweh=" elem.width*=window.devicePixelRatio; elem.height*=window.devicePixelRatio; "; $ew=" * window.devicePixelRatio"; }
if (strpos(explode('"',$hds[$ih])[0], ' ') !== false) {
$ynft=str_replace(" ","+",explode('"',$hds[$ih])[0]);
$inth=str_replace(explode('"',$hds[$ih])[0], $ynft, $inth);
} else {
$ynft=explode('"',$hds[$ih])[0];
}
}
$outth = $inth;
$ideas = array(" action='", ' action="', " Action='", ' Action="', " ACTION='", ' ACTION="', " action=", " Action=", " ACTION=", " href='", ' href="', " Href='", ' Href="', " HREF='", ' HREF="', " href=", " Href=", " HREF=", " src='", ' src="', " Src='", ' Src="', " SRC='", ' SRC="', " src=", " Src=", " SRC=");
for ($m=0; $m<sizeof($ideas); $m++) {
if (strpos($inth, $ideas[$m] . '//') !== false) {
$inth = str_replace($ideas[$m] . '//', $ideas[$m] . 'http://', $inth);
$outth = $inth;
}
}
if ($udirname != "") {
$inth=str_replace(".//", $udirname, str_replace("..//", $udirname . "../", $inth));
if (strpos($udirname, "//") !== false) {
if (strpos(explode("//", $udirname)[1], "/") !== false) {
$charoneprefix=str_replace("@!@%","/~",explode("//", $udirname)[0] . "//" . explode("/", str_replace("/~","@!@%",explode("//", $udirname)[1]))[0]);
}
}
$outth=$inth;
for ($m=0; $m<sizeof($ideas); $m++) {
$huhs = explode($ideas[$m], $inth);
if (sizeof($huhs) > 1) {
for ($ii=(sizeof($huhs) - 1); $ii>=1; $ii--) {
if ($charoneprefix != "" && substr($huhs[$ii], 0, 1) == "/" && substr($huhs[$ii], 1, 1) != "/" && substr($huhs[$ii], 0, 1) != "'" && substr($huhs[$ii], 0, 1) != '"') {
if (substr($ideas[$m],-1) == "'") {
$outth = str_replace("/./","/",$ideas[$m] . str_replace(explode("'",$huhs[$ii])[0] . "'", $ideas[$m] . $charoneprefix . explode("'",$huhs[$ii])[0] . "'", $outth));
} else if (substr($ideas[$m],-1) == '"') {
$outth = str_replace("/./","/",$ideas[$m] . str_replace(explode('"',$huhs[$ii])[0] . '"', $ideas[$m] . $charoneprefix . explode('"',$huhs[$ii])[0] . '"', $outth));
} else {
$outth = str_replace("/./","/",str_replace($huhs[$ii], $charoneprefix . $huhs[$ii], $outth));
}
} else if (strtolower(str_replace("file", "http", strtolower(substr($huhs[$ii], 0, 4)))) == "http") {
$outth = $outth;
} else if (substr($huhs[$ii], 0, 1) != "/" && substr($huhs[$ii], 0, 1) != "'" && substr($huhs[$ii], 0, 1) != '"') {
if (strpos($huhs[$ii], "data:") === false) {
if (substr($ideas[$m],-1) == "'") {
$outth = str_replace("/./","/",$ideas[$m] . str_replace(explode("'",$huhs[$ii])[0] . "'", $ideas[$m] . $udirname . explode("'",$huhs[$ii])[0] . "'", $outth));
} else if (substr($ideas[$m],-1) == '"') {
$outth = str_replace("/./","/",$ideas[$m] . str_replace(explode('"',$huhs[$ii])[0] . '"', $ideas[$m] . $udirname . explode('"',$huhs[$ii])[0] . '"', $outth));
} else {
$outth = str_replace("/./","/",str_replace($huhs[$ii], $udirname . $huhs[$ii], $outth));
}
} else {
$outth = str_replace("/./","/",str_replace($huhs[$ii], str_replace("data:","DATA:",$huhs[$ii]), $outth));
}
} else if (substr($huhs[$ii], 1, 1) != "/" && substr($huhs[$ii], 0, 1) != "'" && substr($huhs[$ii], 0, 1) != '"') {
if (strpos($huhs[$ii], "data:") === false) {
if (substr($ideas[$m],-1) == "'") {
$outth = str_replace("/./","/",$ideas[$m] . str_replace(explode("'",$huhs[$ii])[0] . "'", $ideas[$m] . substr($udirname, 0, (strlen($udirname) - 1)) . explode("'",$huhs[$ii])[0] . "'", $outth));
} else if (substr($ideas[$m],-1) == '"') {
$outth = str_replace("/./","/",$ideas[$m] . str_replace(explode('"',$huhs[$ii])[0] . '"', $ideas[$m] . substr($udirname, 0, (strlen($udirname) - 1)) . explode('"',$huhs[$ii])[0] . '"', $outth));
} else {
$outth = str_replace("/./","/",str_replace($huhs[$ii], substr($udirname, 0, (strlen($udirname) - 1)) . $huhs[$ii], $outth));
}
} else {
$outth = str_replace("/./","/",str_replace($huhs[$ii], str_replace("data:","DATA:",$huhs[$ii]), $outth));
}
}
}
}
}
}
$outth=str_replace("DATA:","data:",$outth);
if (strpos($outth, "</body>") !== false && strpos($outth, "<body") !== false) {
return "<body" . explode("<body", explode("</body>", $outth)[0])[-1 + sizeof(explode("<body", explode("</body>", str_replace("/./","/",$outth))[0]))] . "</body>";
}
return str_replace("/./","/",$outth);
}
if (isset($_GET['inurl']) && isset($_GET['inid'])) {
$inid=str_replace("+"," ",urldecode($_GET['inid']));
$udirname=str_replace(" ","+",urldecode($_GET['inurl']));
$contis=relative_to_absolute_php(file_get_contents($udirname));
}
function postmapit($oon) {
if (isset($_GET['linkit']) || isset($_POST['linkit'])) {
if (isset($_GET['one'])) {
return "<a title=\"See no functional links version\" style=cursor:pointer;text-decoration:underline; onclick=\" window.open('" . str_replace("+"," ",urldecode($_GET['one'])) . "', '_blank', 'top=50,left=50,width=400,height=400'); \">...</a>";
} else if (isset($_POST['one'])) {
return "<a title=\"See no functional links version\" style=cursor:pointer;text-decoration:underline; onclick=\" window.open('" . str_replace("+"," ",urldecode($_POST['one'])) . "', '_blank', 'top=50,left=50,width=400,height=400'); \">...</a>";
} else {
return "<a title=\"See no functional links version\" style=cursor:pointer;text-decoration:underline; onclick=\" window.open('./one.one', '_blank', 'top=50,left=50,width=400,height=400'); \">...</a>";
}
}
return $oon;
}
function mapit($oone) {
global $lastoi, $lastonetodelete;
if (isset($_GET['linkit']) || isset($_POST['linkit'])) {
//file_put_contents("found.c",strlen($lastoi));
if (file_exists($oone) && $lastoi == '') {
ofinterest(file_get_contents($oone));
}
}
if ($lastoi != "" && (isset($_GET['linkit']) || isset($_POST['linkit']))) {
//file_put_contents("found.that","huh");
file_put_contents($oone . server_remote_addr() . ".html", "<div>" . str_replace("&#","&#", str_replace("\n","<br>", str_replace('<A ','<A ', str_replace('<SPAN ','<SPAN ', str_replace('</A>','</A>', str_replace('<DIV ','<DIV ', str_replace('</DIV>','</DIV>', str_replace('</SPAN>','</SPAN>', str_replace('ccc">','ccc">', str_replace("<","<",str_replace(">",">",$lastoi)))))))))) ) . "</div><script type='text/javascript'> var lasturlis=''; function tl(inid) { return document.getElementById(inid).getBoundingClientRect().top + ',left=' + document.getElementById(inid).getBoundingClientRect().left; } </script>");
$lastonetodelete=$oone . server_remote_addr() . ".html";
return $oone . server_remote_addr() . ".html";
}
//$lastoi="";
return $oone;
}
function ofinterest($intobelinked) {
global $lastoi, $contis, $inid;
$spareintobelinked=$intobelinked;
$outtobelinked=$intobelinked;
$fns=explode("(", $intobelinked);
for ($ifns=0; $ifns<sizeof($fns); $ifns++) {
if ($ifns == 0) { $outtobelinked=""; }
if (trim($fns[$ifns]) != "") {
$fnidea="";
$jns=strlen($fns[$ifns]);
$jns--;
if (substr(strtolower($fns[$ifns]),$jns,1) >= "a" && substr(strtolower($fns[$ifns]),$jns,1) <= "z") {
$fnidea=substr($fns[$ifns],$jns,1);
$jns--;
while (substr($fns[$ifns],$jns,1) == "." || substr($fns[$ifns], $jns,1) == "_" || (substr(strtolower($fns[$ifns]),$jns,1) >= "a" && substr(strtolower($fns[$ifns]),$jns,1) <= "z")) {
$fnidea=substr($fns[$ifns], $jns,1) . $fnidea;
$kns=$jns;
$jns--;
if ($jns < 0) { break; }
if (substr($fns[$ifns],$kns,1) == ".") { break; }
}
if ($fnidea != "") {
if (substr($fnidea,0,1) == ".") {
if (strpos($outtobelinked, "this" . $fnidea . "=") !== false) {
$outtobelinked=str_replace("this" . $fnidea . "=", "this.<SPAN onclick=\"location.href='#a" . substr($fnidea,1) . "'; \" title=\"Click to find first call\" style=background-color:cyan; id='" . substr($fnidea,1) . "' class=\"spanccc\">" . substr($fnidea,1) . "</SPAN><DIV style=display:inline-block; id='div" . substr($fnidea,1) . "' class=\"divccc\"></DIV>=", $outtobelinked);
} else if (strpos($outtobelinked, "this" . $fnidea . " =") !== false) {
$outtobelinked=str_replace("this" . $fnidea . " =", "this.<SPAN onclick=\"location.href='#a" . substr($fnidea,1) . "'; \" title=\"Click to find first call\" style=background-color:cyan; id='" . substr($fnidea,1) . "' class=\"spanccc\">" . substr($fnidea,1) . "</SPAN><DIV style=display:inline-block; id='div" . substr($fnidea,1) . "' class=\"divccc\"></DIV> =", $outtobelinked);
} else if (strpos($spareintobelinked, "this" . $fnidea . " =") !== false) {
$spareintobelinked=str_replace("this" . $fnidea . " =", "this.<SPAN onclick=\"location.href='#a" . substr($fnidea,1) . "'; \" title=\"Click to find first call\" style=background-color:cyan; id='" . substr($fnidea,1) . "' class=\"spanccc\">" . substr($fnidea,1) . "</SPAN><DIV style=display:inline-block; id='div" . substr($fnidea,1) . "' class=\"divccc\"></DIV> =", $spareintobelinked);
$fns=explode("(", $spareintobelinked);
} else if (strpos($spareintobelinked, "this" . $fnidea . "=") !== false) {
$spareintobelinked=str_replace("this" . $fnidea . "=", "this.<SPAN onclick=\"location.href='#a" . substr($fnidea,1) . "'; \" title=\"Click to find first call\" style=background-color:cyan; id='" . substr($fnidea,1) . "' class=\"spanccc\">" . substr($fnidea,1) . "</SPAN><DIV style=display:inline-block; id='div" . substr($fnidea,1) . "' class=\"divccc\"></DIV>=", $spareintobelinked);
$fns=explode("(", $spareintobelinked);
}
$fnidea=substr($fnidea,1);
$jns++;
}
}
//file_put_contents("found.this",$fnidea);
if (strpos(($fns[$ifns] . "("), "function " . $fnidea . "(") !== false && strpos($outtobelinked, "<SPAN style=background-color:yellow; id='" . $fnidea . "'") === false) {
$outtobelinked.=substr($fns[$ifns],0,($jns + 1)) . "<SPAN onclick=\"location.href='#a" . substr($fnidea,1) . "'; \" title=\"Click to find first call\" style=background-color:cyan; class=\"spanccc\">" . $fnidea . "</SPAN><DIV style=display:inline-block; id='div" . substr($fnidea,1) . "' class=\"divccc\"></DIV>(";
} else if (strlen($fnidea) > 3 && strpos($outtobelinked, ">" . $fnidea . "</A>") === false && strpos($spareintobelinked, ">" . $fnidea . "</SPAN>") !== false) {
$outtobelinked.=substr($fns[$ifns],0,($jns + 1)) . "<A id=a" . $fnidea . " href='#" . $fnidea . "' class=\"accc\">" . $fnidea . "</A>(";
} else if (strlen($fnidea) > 3 && strpos($outtobelinked, ">" . $fnidea . "</A>") === false && strpos($outtobelinked, ">" . $fnidea . "</SPAN>") !== false) {
$outtobelinked.=substr($fns[$ifns],0,($jns + 1)) . "<A id=a" . $fnidea . " href='#" . $fnidea . "' class=\"accc\">" . $fnidea . "</A>(";
} else if (strlen($fnidea) > 3 && strpos($outtobelinked, ">" . $fnidea . "</A>") === false) {
$oty=urlencode("http://www.google.com/search?q=" . urlencode($fnidea) . "+w3schools+php.net+computerhope");
$outtobelinked.=substr($fns[$ifns],0,($jns + 1)) . "<A style=background-color:orange; title='Hover for inline help' onmouseover=\" if (lasturlis != this.href) { lasturlis=this.href; window.open(this.href,'_blank','top=' + tl('div" . $fnidea . "') + ',width=600,height=400'); } \" data-onmouseover=\" var locationhref=top.document.URL.split('&in')[0] + '&inid=div" . urlencode($fnidea) . "&inurl=" . $oty . "#" . $fnidea . "'; top.location.href=locationhref; \" id='" . $fnidea . "' target=_blank href='//www.google.com/search?q=" . urlencode($fnidea) . "+w3schools+php.net+computerhope' title='Google search for " . $fnidea . "' class=\"accc\">" . $fnidea . "</A><DIV style=display:inline-block; id='div" . $fnidea . "' class=\"divccc\"></DIV>(";
} else {
$outtobelinked.=$fns[$ifns] . "(";
}
} else {
$outtobelinked.=$fns[$ifns] . "(";
}
} else {
$outtobelinked.="(";
}
}
if (isset($_GET['linkit']) || isset($_POST['linkit'])) {
//file_put_contents("found.b", strlen($outtobelinked));
if ($contis != "") {
$outtobelinked=str_replace("<DIV style=display:inline-block; id='" . $inid . "' class=\"divccc\"></DIV>", "<IFRAME style=display:inline-block; id='" . $inid . "' class=\"divccc\" srcdoc=\"" . str_replace("\n", " ", str_replace('"','\"',$contis)) . "\"></IFRAME>", $outtobelinked);
}
$lastoi=$outtobelinked;
}
return $intobelinked;
}
function yourfile_get_contents($inuis) {
global $lastoi;
if (strpos(("~" . $inuis), "~//") !== false) {
if (isset($_GET['linkit']) || isset($_POST['linkit'])) {
//file_put_contents("found.it","huh");
return ofinterest(file_get_contents("http:" . $inuis));
}
return file_get_contents("http:" . $inuis);
}
if (isset($_GET['linkit']) || isset($_POST['linkit'])) {
//file_put_contents("found.oi","huh");
return ofinterest(file_get_contents($inuis));
}
return file_get_contents($inuis);
}
function ourfile_get_contents($inuis) {
if (strpos(("~" . $inuis), "~//") !== false) {
return file_get_contents("http:" . $inuis);
}
return file_get_contents($inuis);
}
if (isset($_GET['one']) && !isset($_GET['two'])) {
if (str_replace("--GETME", "", $_GET['one']) != $_GET['one']) {
$called="y";
$iframebits="<h1 id=latest_file" . $suffid . ">Latest file " . postmapit('...') . " <a href=#differences" . $suffid . " title=Differences>Differences</a> below this ... " . $_GET['one'] . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . " title='" . $_GET['one'] . "'></iframe></details><br>";
$iframebits.="<h1 id=differences" . $suffid . ">Differences <a href=#latest_file" . $suffid . " title=Latest>^</a> <a href=#older_file" . $suffid . " title=Older>v</a></h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 src='huh.huh' title='Differences between " . $_GET['one'] . " and " . str_replace("--GETME", "-GETME", $_GET['one']) . "'></iframe></details><br>";
$iframebits.="<h1 id=older_file" . $suffid . ">Older file ... <a href=#differences" . $suffid . " title=Differences>Differences</a> just above ... " . str_replace("--GETME", "-GETME", $_GET['one']) . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src='two.two' title='" . str_replace("--GETME", "-GETME", $_GET['one']) . "'></iframe></details><br>";
$suffix = " file(s) not found";
if (str_replace("GETME", "", $_GET['one']) != $_GET['one']) {
$suffix="";
$onec = yourfile_get_contents($_GET['one']);
if (str_replace(" ","",$onec) == "" || strpos($onec, "No newline" . " at end of file") !== false) $suffix = " " . $_GET['one'] . " not found";
$twoc = ourfile_get_contents(str_replace("--GETME", "-GETME", $_GET['one']));
if (str_replace(" ","",$twoc) == "" || strpos($twoc, "No newline" . " at end of file") !== false) $suffix .= " " . str_replace("--GETME", "-GETME", $_GET['one']) . " not found";
} else {
$suffix = " sorry, no can do";
}
} else if (str_replace("-GETME", "", $_GET['one']) != $_GET['one']) {
$called="y";
$iframebits="<h1 id=latest_file" . $suffid . ">Latest file " . postmapit('...') . " <a href=#differences" . $suffid . " title=Differences>Differences</a> below this ... " . $_GET['one'] . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . " title='" . $_GET['one'] . "'></iframe></details><br>";
$iframebits.="<h1 id=differences" . $suffid . ">Differences <a href=#latest_file" . $suffid . " title=Latest>^</a> <a href=#older_file" . $suffid . " title=Older>v</a></h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 src='huh.huh' title='Differences between " . $_GET['one'] . " and " . str_replace("-GETME", "_GETME", $_GET['one']) . "'></iframe></details><br>";
$iframebits.="<h1 id=older_file" . $suffid . ">Older file ... <a href=#differences" . $suffid . " title=Differences>Differences</a> just above ... " . str_replace("-GETME", "_GETME", $_GET['one']) . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src='two.two' title='" . str_replace("-GETME", "_GETME", $_GET['one']) . "'></iframe></details><br>";
$suffix = " file(s) not found";
if (str_replace("GETME", "", $_GET['one']) != $_GET['one']) {
$suffix="";
$onec = yourfile_get_contents($_GET['one']);
if (str_replace(" ","",$onec) == "" || strpos($onec, "No newline" . " at end of file") !== false) $suffix = " " . $_GET['one'] . " not found";
$twoc = ourfile_get_contents(str_replace("-GETME", "_GETME", $_GET['one']));
if (str_replace(" ","",$twoc) == "" || strpos($twoc, "No newline" . " at end of file") !== false) $suffix .= " " . str_replace("-GETME", "_GETME", $_GET['one']) . " not found";
} else {
$suffix = " sorry, no can do";
}
} else if (str_replace("GETME", "", $_GET['one']) != $_GET['one']) {
$fillinone=$_GET['one'];
}
} else if (isset($_GET['one']) && isset($_GET['two'])) {
if ($_GET['one'] != "" && $_GET['two'] != "" && $_GET['one'] != $_GET['two'] && str_replace("GETME","",str_replace("_","",str_replace("-","",$_GET['one']))) == str_replace("GETME","",str_replace("_","",str_replace("-","",$_GET['two'])))) {
if (str_replace("GETME", "", $_GET['one']) != $_GET['one'] && str_replace("GETME", "", $_GET['two']) != $_GET['two']) {
$xprefix="";
$xsuffix="";
} else if (str_replace("GETME", "", $_GET['one']) != $_GET['one'] || str_replace("GETME", "", $_GET['two']) != $_GET['two']) {
$xprefix="<div id='diffdiv' style='display:none;'>";
$xsuffix="</div>";
$onloadbit=" onload=\" var huh=prompt('Password? (Hint: Why is a duck?)',''); if (huh != null && huh == 'BecausE IT FlieS SO HigH') { document.getElementById('diffdiv').style.display='block'; } else { document.getElementById('diffdiv').innerHTML=''; } \"";
$prevg="";
if (str_replace("GETME", "", $_GET['one']) == $_GET['one']) {
if ("" != @ourfile_get_contents(str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $_GET['two']))))) {
$prevg=str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $_GET['two'])));
while ($prevg != "") {
$_GET['one']=$prevg;
if ("" != ourfile_get_contents(str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $prevg))))) {
$prevg=str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $prevg)));
} else {
$prevg="";
}
}
$xprefix="";
$xsuffix="";
$onloadbit="";
}
} else {
if ("" != @ourfile_get_contents(str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $_GET['one']))))) {
$prevg=str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $_GET['one'])));
while ($prevg != "") {
$_GET['two']=$prevg;
if ("" != ourfile_get_contents(str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $prevg))))) {
$prevg=str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $prevg)));
} else {
$prevg="";
}
}
$xprefix="";
$xsuffix="";
$onloadbit="";
}
}
}
$called="y";
$iframebits=$xprefix . "<h1 id=latest_file" . $suffid . ">Latest file " . postmapit('...') . " <a href=#differences" . $suffid . " title=Differences>Differences</a> below this " . $_GET['one'] . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . " title='" . $_GET['one'] . "'></iframe></details><br>";
$iframebits.="<h1 id=differences" . $suffid . ">Differences <a href=#latest_file" . $suffid . " title=Latest>^</a> <a href=#older_file" . $suffid . " title=Older>v</a></h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 src='huh.huh' title='Differences between " . $_GET['one'] . " and " . $_GET['two'] . "'></iframe></details><br>";
$iframebits.="<h1 id=older_file" . $suffid . ">Older file ... <a href=#differences" . $suffid . " title=Differences>Differences</a> just above " . $_GET['two'] . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src='two.two' title='" . $_GET['two'] . "'></iframe></details><br>" . $xsuffix;
}
$suffix = " file(s) not found";
if (str_replace("GETME", "", $_GET['one']) != $_GET['one'] || str_replace("GETME", "", $_GET['two']) != $_GET['two']) {
$suffix="";
$onec = yourfile_get_contents($_GET['one']);
if (str_replace(" ","",$onec) == "" || strpos($onec, "No newline" . " at end of file") !== false) $suffix = " " . $_GET['one'] . " not found";
$twoc = ourfile_get_contents($_GET['two']);
if (str_replace(" ","",$twoc) == "" || strpos($twoc, "No newline" . " at end of file") !== false) $suffix .= " " . $_GET['two'] . " not found";
} else {
$suffix = " sorry, no can do";
}
} else if (isset($_POST['one']) && !isset($_POST['two'])) {
if (str_replace("--GETME", "", $_POST['one']) != $_POST['one']) {
$called="y";
$iframebits="<h1 id=latest_file" . $suffid . ">Latest file " . postmapit('...') . " <a href=#differences" . $suffid . " title=Differences>Differences</a> below this" . $_POST['one'] . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . " title='" . $_POST['one'] . "'></iframe></details><br>";
$iframebits.="<h1 id=differences" . $suffid . ">Differences <a href=#latest_file" . $suffid . " title=Latest>^</a> <a href=#older_file" . $suffid . " title=Older>v</a></h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 src='huh.huh' title='Differences between " . $_POST['one'] . " and " . str_replace("--GETME", "-GETME", $_POST['one']) . "'></iframe></details><br>";
$iframebits.="<h1 id=older_file" . $suffid . ">Older file ... <a href=#differences" . $suffid . " title=Differences>Differences</a> just above" . str_replace("--GETME", "-GETME", $_POST['one']) . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src='two.two' title='" . str_replace("--GETME", "-GETME", $_POST['one']) . "'></iframe></details><br>";
$suffix = " file(s) not found";
if (str_replace("GETME", "", $_POST['one']) != $_POST['one']) {
$suffix="";
$onec = yourfile_get_contents($_POST['one']);
if (str_replace(" ","",$onec) == "" || strpos($onec, "No newline" . " at end of file") !== false) $suffix = " " . $_POST['one'] . " not found";
$twoc = ourfile_get_contents(str_replace("--GETME", "-GETME", $_POST['one']));
if (str_replace(" ","",$twoc) == "" || strpos($twoc, "No newline" . " at end of file") !== false) $suffix .= " " . str_replace("--GETME", "-GETME", $_POST['one']) . " not found";
} else {
$suffix = " sorry, no can do";
}
} else if (str_replace("-GETME", "", $_POST['one']) != $_POST['one']) {
$called="y";
$iframebits="<h1 id=latest_file" . $suffid . ">Latest file " . postmapit('...') . " <a href=#differences" . $suffid . " title=Differences>Differences</a> below this" . $_POST['one'] . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . " title='" . $_POST['one'] . "'></iframe></details><br>";
$iframebits.="<h1 id=differences" . $suffid . ">Differences <a href=#latest_file" . $suffid . " title=Latest>^</a> <a href=#older_file" . $suffid . " title=Older>v</a></h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 src='huh.huh' title='Differences between " . $_POST['one'] . " and " . str_replace("-GETME", "_GETME", $_POST['one']) . "'></iframe></details><br>";
$iframebits.="<h1 id=older_file" . $suffid . ">Older file ... <a href=#differences" . $suffid . " title=Differences>Differences</a> just above" . str_replace("-GETME", "_GETME", $_POST['one']) . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src='two.two' title='" . str_replace("-GETME", "_GETME", $_POST['one']) . "'></iframe></details><br>";
$suffix = " file(s) not found";
if (str_replace("GETME", "", $_POST['one']) != $_POST['one']) {
$suffix="";
$onec = yourfile_get_contents($_POST['one']);
if (str_replace(" ","",$onec) == "" || strpos($onec, "No newline" . " at end of file") !== false) $suffix = " " . $_POST['one'] . " not found";
$twoc = ourfile_get_contents(str_replace("-GETME", "_GETME", $_POST['one']));
if (str_replace(" ","",$twoc) == "" || strpos($twoc, "No newline" . " at end of file") !== false) $suffix .= " " . str_replace("-GETME", "_GETME", $_POST['one']) . " not found";
} else {
$suffix = " sorry, no can do";
}
} else if (str_replace("GETME", "", $_POST['one']) != $_POST['one']) {
$fillinone=$_POST['one'];
}
} else if (isset($_POST['one']) && isset($_POST['two'])) {
$suffix = " file(s) not found";
if ($_POST['one'] != "" && $_POST['two'] != "" && $_POST['one'] != $_POST['two'] && str_replace("GETME","",str_replace("_","",str_replace("-","",$_POST['one']))) == str_replace("GETME","",str_replace("_","",str_replace("-","",$_POST['two'])))) {
if (str_replace("GETME", "", $_POST['one']) != $_POST['one'] && str_replace("GETME", "", $_POST['two']) != $_POST['two']) {
$xprefix="";
$xsuffix="";
} else if (str_replace("GETME", "", $_POST['one']) != $_POST['one'] || str_replace("GETME", "", $_POST['two']) != $_POST['two']) {
$xprefix="<div id='diffdiv' style='display:none;'>";
$xsuffix="</div>";
$onloadbit=" onload=\" var huh=prompt('Password? (Hint: Why is a duck?)',''); if (huh != null && huh == 'BecausE IT FlieS SO HigH') { document.getElementById('diffdiv').style.display='block'; } else { document.getElementById('diffdiv').innerHTML=''; } \"";
$prevg="";
if (str_replace("GETME", "", $_POST['one']) == $_POST['one']) {
if ("" != @ourfile_get_contents(str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $_POST['two']))))) {
$prevg=str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $_POST['two'])));
while ($prevg != "") {
$_POST['one']=$prevg;
if ("" != @ourfile_get_contents(str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $prevg))))) {
$prevg=str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $prevg)));
} else {
$prevg="";
}
}
$xprefix="";
$xsuffix="";
$onloadbit="";
}
} else {
if ("" != ourfile_get_contents(str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $_POST['one']))))) {
$prevg=str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $_POST['one'])));
while ($prevg != "") {
$_POST['two']=$prevg;
if ("" != ourfile_get_contents(str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $prevg))))) {
$prevg=str_replace("GET~ME","GETME",str_replace("_GETME", "-GET~ME", str_replace("-GETME", "--GET~ME", $prevg)));
} else {
$prevg="";
}
}
$xprefix="";
$xsuffix="";
$onloadbit="";
}
}
}
$called="y";
$iframebits=$xprefix . "<h1 id=latest_file" . $suffid . ">Latest file " . postmapit('...') . " <a href=#differences" . $suffid . " title=Differences>Differences</a> below this " . $_POST['one'] . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . " title='" . $_POST['one'] . "'></iframe></details><br>";
$iframebits.="<h1 id=differences" . $suffid . ">Differences <a href=#latest_file" . $suffid . " title=Latest>^</a> <a href=#older_file" . $suffid . " title=Older>v</a></h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 src='huh.huh' title='Differences between " . $_POST['one'] . " and " . $_POST['two'] . "'></iframe></details><br>";
$iframebits.="<h1 id=older_file" . $suffid . ">Older file ... <a href=#differences" . $suffid . " title=Differences>Differences</a> just above " . $_POST['two'] . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src='two.two' title='" . $_POST['two'] . "'></iframe></details><br>" . $xsuffix;
}
if (str_replace("GETME", "", $_POST['one']) != $_POST['one'] || str_replace("GETME", "", $_POST['two']) != $_POST['two']) {
$suffix="";
$onec = yourfile_get_contents($_POST['one']);
if (str_replace(" ","",$onec) == "" || strpos($onec, "No newline" . " at end of file") !== false) $suffix = " " . $_POST['one'] . " not found";
$twoc = ourfile_get_contents($_POST['two']);
if (str_replace(" ","",$twoc) == "" || strpos($twoc, "No newline" . " at end of file") !== false) $suffix .= " " . $_POST['two'] . " not found";
} else {
$suffix = " sorry, no can do";
}
}
if ($suffix == "" && (str_replace(" ","",$onec) != "" || str_replace(" ","",$twoc) != "")) {
//file_put_contents("found.a","");
$fh = fopen(dirname(__FILE__) . "/one.one", "w");
fwrite($fh, $onec);
fclose($fh);
$fh = fopen(dirname(__FILE__) . "/two.two", "w");
fwrite($fh, $twoc);
fclose($fh);
exec("diff " . $_GET['minus'] . " " . dirname(__FILE__) . "/one.one " . dirname(__FILE__) . "/two.two > " . dirname(__FILE__) . "/huh.huh");
//if ($called == "") unlink(dirname(__FILE__) . "/one.one" . server_remote_addr() . ".html");
if ($called == "") unlink(dirname(__FILE__) . "/one.one");
if ($called == "") unlink(dirname(__FILE__) . "/two.two");
if ($called != "") {
if (strpos(('' . $_SERVER['QUERY_STRING']), "linkit=") !== false && strpos(('' . $_SERVER['QUERY_STRING']), "linktwoit=") === false) {
//sleep(5);
header('Location: ./diff.php?' . str_replace("linkit=", "linktwoit=y&linkit=", $_SERVER['QUERY_STRING']));
exit;
}
echo "<html><head><title>PHP Linux diff file differences ... First file, Differences, Second file ... RJM Programming November 2013</title></head><body" . $onloadbit . ">\n";
echo $iframebits;
echo "</body></html>";
if ($lastonetodelete != "") {
exec("sleep 8; rm -f " . $lastonetodelete);
$lastonetodelete="";
}
} else {
header("Location: " . "/huh.huh");
}
} else {
if (strpos(('' . $_SERVER['QUERY_STRING']), "linkit=") !== false && strpos(('' . $_SERVER['QUERY_STRING']), "linktwoit=") === false) {
//sleep(5);
header('Location: ./diff.php?' . str_replace("linkit=", "linktwoit=y&linkit=", $_SERVER['QUERY_STRING']));
exit;
}
echo "<html><head><title>PHP Linux diff file differences ... RJM Programming November 2013</title></head><body>\n";
echo "<form style='background-color:yellow;' action='" . $_SERVER['PHP_SELF'] . "' method='POST'><h1>File comparison ... " . $suffix . "</h1>" . "\n";
echo "Enter URL (ending in GETME) for file comparison 1 of 2: <input style='background-color:pink;' size=120 name='one' id='one' type='text' value='" . $fillinone . "'></input><br>\n";
echo "Enter URL (ending in GETME) for file comparison 2 of 2: <input style='background-color:pink;' size=120 name='two' id='two' type='text' value='" . $fillintwo . "'></input><br><br>\n";
echo "<input type='submit' name='submit' id='submit' value='Compare'></input></form>";
echo "<iframe style=display:none; id=ifdiff src='./diff.php'></iframe>";
echo "</body></html>";
if ($lastonetodelete != "") {
exec("sleep 8; rm -f " . $lastonetodelete);
$lastonetodelete="";
}
}
?>