<?php
// PHP Linux diff file differences ... RJM Programming November 2013
error_reporting(E_ERROR | E_PARSE);

$style="<style> font { text-shadow: -1px 1px 1px #ff2d95; } </style>";
$legend="";
$mx="";
$onecommand=" function nocaret(invx) { var outvx=decodeURIComponent(invx); while (outvx.indexOf('<') > outvx.indexOf('>')) { outvx=outvx.replace('>' + outvx.split('>')[1].split('<')[0] + '<','');  }  return encodeURIComponent(outvx); } function onb(event) { var othis=event.target, cih='';  if (('' + othis.id + ' ').substring(0,1) == 'f') {  cih=('' + window.localStorage.getItem('diff_' + othis.id)).replace(/^undefined$/g,''.replace(/^null$/g,'')); if (('' + othis.innerHTML.replace(/\&nbsp\;/g,' ') + '~~').indexOf(' ~~') != -1) { if (cih == '') { window.localStorage.setItem('diff_' + othis.id, encodeURIComponent('14 >' + othis.innerText + '<'));  } else { window.localStorage.removeItem('diff_' + othis.id);  window.localStorage.setItem('diff_' + othis.id, nocaret(cih) + encodeURIComponent(' >' + othis.innerText + '<'));  } }  } } function blurize(othis) { if (1 == 2) { othis.onblur=function(event) { onb(event); }; } return othis; } function perhapsih(insg,ofo) { if (insg.indexOf('<') > insg.indexOf('<') && insg.indexOf('<') != -1) { ofo.innerHTML=insg.split('>')[1].split('>')[0]; ofo.setAttribute('data-ih', insg.split('>')[1].split('>')[0]); return insg.replace('>' + insg.split('>')[1].split('>')[0] + '<', '');  } } function givef(idn,cssis) { if (('' + document.getElementById('f' + idn).title).indexOf(' ' + decodeURIComponent(cssis) + ' ') == -1) { document.getElementById('f' + idn).title=document.getElementById('lspan').title + '  You have user CSS styling friendly one off setting of ' + decodeURIComponent(cssis) + ' for this category of Difference Reporting'; } } function getmaybe(foin,defis) { var mgs=document.URL.split(foin.id + '='); thatget=('' + window.localStorage.getItem('diff_' + foin.id)).replace(/^undefined$/g,'').replace(/^null$/g,''); if (thatget != '') { if (eval('' + mgs.length) == 1) { return decodeURIComponent(thatget); } else if (mgs[1].split('&')[0].split('#')[0] == '') { return decodeURIComponent(thatget); } } if (eval('' + mgs.length) > 1) { if (mgs[1].split('&')[0].split('#')[0] != '') { return decodeURIComponent(mgs[1].split('&')[0].split('#')[0]); } } return defis; } function getany() { var mgs=[],addget='',thisget=''; if (document.URL.replace('?','&').indexOf('&f') == -1 || 1 == 1) { for (var iig=0; iig<=6; iig++) { mgs=document.URL.split('f' + iig + '='); thisget=('' + window.localStorage.getItem('diff_f' + iig)).replace(/^undefined$/g,'').replace(/^null$/g,''); if (thisget != '') { document.getElementById('f' + iig).title=document.getElementById('lspan').title + '  You have user CSS styling friendly setting of ' + decodeURIComponent(thisget) + ' for this category of Difference Reporting'; } if (eval('' + mgs.length) > 1) { if (mgs[1].split('&')[0].split('#')[0] != '') { document.getElementById('f' + iig).title=document.getElementById('lspan').title + '  You have user CSS styling friendly setting of ' + decodeURIComponent(mgs[1].split('&')[0].split('#')[0]) + ' for this category of Difference Reporting'; } } if (document.URL.replace('?','&').indexOf('&f' + iig + '=') == -1) { addget+='&f' + iig + '=' + thisget; } }  } if (addget != '') { location.href=(document.URL.split('#')[0] + addget).replace('.php&','.php?');  } } setTimeout(getany,2000); function removeany(newfo) { window.localStorage.removeItem('diff_' + newfo.id); } function addany(newishfo,newwhat) { removeany(newishfo);  window.localStorage.setItem('diff_' + newishfo.id, newwhat); } function askabout(fo) { var defd='14', ccol='black', ccols=fo.outerHTML.split(' color=' + String.fromCharCode(34)), psizes=fo.outerHTML.split('px'); if (eval('' + ccols.length) > 1) {  ccol=ccols[1].split(String.fromCharCode(34))[0];  }  if (eval('' + psizes.length) > 1) {  defd=psizes[0].split(':')[eval(-1 + psizes[0].split(':').length)].trim();  }  var numis=prompt('How many px (ie. pixels) do you want for the font size of these ' + fo.innerHTML + ' parts of report?  Optionally append after a space a colour that is not the default colour ' + ccol + ' for this category of difference report.  Optionally append after a space any other styling you want ( eg. text-shadow: -1px 1px 1px #ff2d95; ).  Append spaces to save for other Coding Difference Report sessions into the future.  Prefix with minus ( ie. - ) to forget any remembered setting.    An entry can be > followed by a new wording for this category followed by <', getmaybe(fo,defd)); if (numis != null) { if ((perhapsih(numis,fo) + 'x').trim().substring(0,1) == '-') { removeany(fo); numis=numis.replace('-','');  } if (('' + numis).trim() != '') { if (numis.replace(/\ $/g,'') != numis) { addany(fo,encodeURIComponent(numis.trim())); } location.href=(document.URL.split('#')[0] + '&' + fo.id + '=' + encodeURIComponent(numis.trim())).replace('.php&','.php?'); } } } ";


if (isset($_GET['f0']) || isset($_GET['f1']) || isset($_GET['f2']) || isset($_GET['f3']) || isset($_GET['f4']) || isset($_GET['f5']) || isset($_GET['f6'])) {
   $onecommand.=" function sizefonts() {   }     setTimeout(sizefonts, 3000); ";
   for ($ij=0; $ij<=6; $ij++) {
   if (isset($_GET['f' . $ij])) {
     $ihbit="";
     $words=str_replace('+',' ',urldecode($_GET['f' . $ij]));
     if (strpos($words, '<') !== false && strpos($words, '>') !== false) {
       if (strpos($words, '<') > strpos($words, '>')) {
         $ihbit=" document.getElementById('f" . $ij . "').innerHTML='" . str_replace("'", "' + String.fromCharCode(39) + '", explode('<',explode('>',$words)[1])[0]) . "'; ";
       }
     }
     if (trim($words) != '') {  $onecommand=str_replace("}    ", " givef(" . $ij . ",'" . $_GET['f' . $ij] . "'); }    ", $onecommand);  }
     $wordsa=explode(' ', trim($words));
     if (sizeof($wordsa) > 1) {
        $words=substr($words,(1 + strlen($wordsa[0])));
        for ($ijj=1; $ijj<sizeof($wordsa); $ijj++) {
          if (strpos($wordsa[$ijj], ':') === false && $ijj == 1) {
            $words=trim(substr($words,(0 + strlen($wordsa[$ijj]))));
            $style.='<style>  .f' . $ij . " { font-color: " . trim($wordsa[$ijj]) . '; } </style>';
            $onecommand=str_replace("}    ", " document.getElementById('f" . $ij . "').color='' + '" . trim($wordsa[$ijj]) . "'; document.getElementById('f" . $ij . "').style.fontColor='' + '" . trim($wordsa[$ijj]) . "'; }    ", $onecommand);
          }
        }
        if (trim($words) != '') {
          if (strpos($words, "{") !== false && strpos($words, "}") !== false) {
            $style.='<style> ' . $words . ' </style>';
            $onecommand=str_replace("}    ", " document.getElementById('dstyle').innerHTML+='<style> ' + '" . $words . " </style>'; }    ", $onecommand);
          } else {
            $style.='<style>  .f' . $ij . " { " . $words . ' } </style>';
            $onecommand=str_replace("}    ", " document.getElementById('dstyle').innerHTML+='<style>  .f" . $ij . " { ' + '" . $words . " } </style>'; }    ", $onecommand);
          }
        }
     }
     $onecommand=str_replace("}    ", $ihbit . " document.getElementById('f" . $ij . "').style.fontSize='' + '" . trim($wordsa[0]) . "px'; }    ", $onecommand);
     $style.='<style>  .f' . $ij . " { font-size: " . trim($wordsa[0]) . 'px; } </style>';
   }
   }
}


if (isset($_GET['one'])) { // && !isset($_GET['two'])) {
if (isset($_GET['legend']) || isset($_GET['markit'])) {
  if (file_exists(dirname(__FILE__) . "/huh" . server_remote_addr() . ".huh")) {
    unlink(dirname(__FILE__) . "/huh" . server_remote_addr() . ".huh");
  }
    $legend='&nbsp;<span id=lspan title="Clicks can offer user controlled size and colour coding and other CSS styling functionality.   or two finger gesture allows for change of wording here.Right click"><span><font  onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f0 size=2 color=purple>New additional</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f1 size=2 color=magenta>Changed single </font><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f2 size=2 color=indigo> line</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f3 size=2 color=blue>New block of lines</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f4 size=2 color=orange>Deleted lines</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f5 size=2 color=darkgreen>Changed multiple </font><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f6 size=2 color=olive>lines</font>&nbsp;<a id=myaa onclick="var wod=window.open(' . "'','_blank','left=100,top=100,width=600,height=600'" . '); wod.document.write(' . "'<textarea title=' + document.URL + ' cols=120 rows=40 style=background-color:pink;>' + " . 'window.atob(' . "'" . trim(base64_encode(file_get_contents("huh" . server_remote_addr() . ".huh"))) . "'" . ') + ' . "'</textarea>'" . '); wod.document.title=document.URL;  " style=text-decoration:underline;cursor:pointer; title="If colour coding showing (just below) clicking here shows you original difference report (but empty until then).">Original ...</a></span></span>';
    $mx="<iframe onload=checkh(this); style=display:none; id=ifdiffx src='./diff.php?checkh='></iframe>";
} else if (isset($_GET['one'])) {
  if (file_exists(dirname(__FILE__) . "/huh" . server_remote_addr() . ".huh")) {
    unlink(dirname(__FILE__) . "/huh" . server_remote_addr() . ".huh");
  }
    $subjcf=str_replace('.php','.htm',str_replace('.js','.htm',str_replace('.asp','.htm',str_replace('.py','.htm',str_replace('.pl','.htm',str_replace('.cgi','.htm',str_replace('.ksh','.htm',str_replace('.sh','.htm',strtolower(str_replace("+"," ",urldecode($_GET['one'])))))))))));
    if (strpos($subjcf, ".htm") !== false) {
    $legend='&nbsp;<span id=lspan title="Clicks can offer user controlled size and colour coding and other CSS styling functionality.  Right click or two finger gesture allows for change of wording here, and if that changed wording ends with a space it will be saved."><span><font  onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f0 size=2 class=f0 color=purple>New additional</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f1 size=2 class=f1 color=magenta>Changed single </font><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f2 size=2 class=f2 color=indigo> line</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f3 size=2 color=blue>New block of lines</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f4 size=2 color=orange>Deleted lines</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f5 size=2 color=darkgreen>Changed multiple </font><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f6 size=2 color=olive>lines</font>&nbsp;<a id=myaa onclick="var wod=window.open(' . "'','_blank','left=100,top=100,width=600,height=600'" . '); wod.document.write(' . "'<textarea title=' + document.URL + ' cols=120 rows=40 style=background-color:pink;>' + " . 'window.atob(' . "'" . trim(base64_encode(file_get_contents("huh" . server_remote_addr() . ".huh"))) . "'" . ') + ' . "'</textarea>'" . '); wod.document.title=document.URL;  " style=text-decoration:underline;cursor:pointer; title="If colour coding showing (just below) clicking here shows you original difference report (but empty until then).">Original ...</a></span></span>';
    $mx="<iframe onload=checkh(this); style=display:none; id=ifdiffx src='./diff.php?checkh='></iframe>";
    $_GET['markit']='y';
    }
}
}

$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%
}

if (isset($_GET['checkh'])) {
    exit;
}

if (isset($_GET['checkhtml'])) {
    if (file_exists("huh" . server_remote_addr() . ".html") && file_exists("huh" . server_remote_addr() . ".huh") && strlen($_GET['checkhtml']) > 0) {
      $lfor=str_replace('+',' ',urldecode($_GET['checkhtml']));
      $hhl=file_get_contents("huh" . server_remote_addr() . ".html");
      $hhh=file_get_contents("huh" . server_remote_addr() . ".huh");
      if (strpos($hhh, $lfor) !== false) {
      if (strpos($hhl, $lfor) !== false) {
      echo "<html><body onload=\"if (window.parent) { if (parent.document.getElementById('ifhuh')) { parent.document.getElementById('ifhuh').style.backgroundColor='#f0f0f0'; parent.document.getElementById('ifhuh').src='./huh" . server_remote_addr() . ".html';   }  }\"><div id=dstyle></div></body></html>";
      //exec("sleep 38; rm -f " . str_replace('.huh','.html',dirname(__FILE__) . "/huh" . server_remote_addr() . ".html"));
      }
      }
    }
    exit;
}

if (isset($_GET['deletehtml'])) {
  if (file_exists(dirname(__FILE__) . "/huh" . server_remote_addr() . ".huh")) {
     unlink(dirname(__FILE__) . "/huh" . server_remote_addr() . ".huh");
  }
  if (file_exists(dirname(__FILE__) . "/huh" . server_remote_addr() . ".html")) {
     unlink(dirname(__FILE__) . "/huh" . server_remote_addr() . ".html");
  }
  exit;
}

function hit($inur) {
 if (strpos(('~' . $inur), '~//') !== false) {
   return 'http:' . $inur;
 }
 return $inur;
}


function ourshell_exec($incm) {
  global $legend, $mx, $onecommand, $style;
  $amx=$mx;
  $hdelm='<br>';
  $delm="\n";
  $outrepis='';
  $parts=explode('>', $incm);
  if (sizeof($parts) >= 2) {
    $outrepis=shell_exec($parts[0]);
    $outlines=[];
    if (strpos($outrepis, "\r\n") !== false) {
      $delm="\r\n";
      $outlines=explode("\r\n", $outrepis);
      //array_push($outlines, $delm);
    } else if (strpos($outrepis, "\n") !== false) {
      $delm="\n";
      $outlines=explode("\n", $outrepis);
      //array_push($outlines, $delm);
    } else if (strpos($outrepis, "\r") !== false) {
      $delm="\r";
      $outlines=explode("\r", $outrepis);
      //array_push($outlines, $delm);
    }

    $thisoldblock='';
    $thisnewblock='';
    $needschange='';
    $lastaline='';

    for ($ia=0; $ia<sizeof($outlines); $ia++) {
       $aline=$outlines[$ia];
       if (strpos($aline, '<') !== false || strpos($aline, '>') !== false || trim($aline) == '---' || strpos($aline, 'No newline at end of file') !== false) {
         if (strpos($aline, 'No newline at end of file') !== false) {
           if ($needschange != '') {
             $thisoldblock.=$aline . $delm;
             $thisnewblock.=str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',$aline)))) . $hdelm;
           } 
         } else if (trim($aline) == '---') {
           if ($needschange != '') {
             $thisoldblock.=$aline . $delm;
             $thisnewblock.=$aline . $hdelm;
           } 
         } else if (strpos($needschange, "a") !== false) {
           $thisoldblock.=$aline . $delm;
           if (substr($aline, 0, 1) == '>') {
             $thisnewblock.='&gt;' . '<font size=3 title="New additional line" class=f0 color=purple>' . str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . '</font>' . $hdelm;
           } else {
             $thisnewblock.=str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . $delm;
           }
         } else if (strpos($needschange, "c") !== false && strpos($needschange, ",") === false) {
           $thisoldblock.=$aline . $delm;
           if (substr($aline, 0, 1) == '>') {
             $thisnewblock.='&gt;' . '<font size=3 title="Changed to line" class=f2 color=indigo>' .  str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . '</font>' . $hdelm;
           } else if (substr($aline, 0, 1) == '<') {
             $thisnewblock.='&lt;' . '<font size=3 title="Changed from line" class=f1 color=magenta>' .  str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . '</font>' . $hdelm;
           } else {
             $thisnewblock.=str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . $delm;
           }
         } else if (strpos($needschange, "c") !== false && strpos($needschange, ",") !== false) {
           $thisoldblock.=$aline . $delm;
           if (substr($aline, 0, 1) == '>') {
             $thisnewblock.='&gt;' . '<font size=3 title="Changed to multiple line" class=f6 color=olive>' .  str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . '</font>' . $hdelm;
           } else if (substr($aline, 0, 1) == '<') {
             $thisnewblock.='&lt;' . '<font size=3 title="Changed from multiple line" class=f5 color=darkgreen>' .  str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . '</font>' . $hdelm;
           } else {
             $thisnewblock.=str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . $delm;
           }
         } else if (strpos($needschange, "d") !== false && strpos($needschange, ",") === false) {
           $thisoldblock.=$aline . $delm;
           if (substr($aline, 0, 1) == '<') {
             $thisnewblock.='&lt;' . '<font size=3 title="Deleted line" class=f4 color=orange>' .  str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . '</font>' . $hdelm;
           } else {
             $thisnewblock.=str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . $delm;
           }
         } else if (strpos($needschange, "d") !== false && strpos($needschange, ",") !== false) {
           if (strpos($amx, "='") !== false) {
             file_put_contents('x.x', $aline);
             $mx=str_replace("='", "=" . urlencode($aline) . "'", $mx);
             $amx="";
           }
           $thisoldblock.=$aline . $delm;
           if (substr($aline, 0, 1) == '<') {
             $thisnewblock.='&lt;' . '<font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" size=3 title="New block lines" class=f3 color=blue>' .  str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . '</font>' . $hdelm;
           } else {
             $thisnewblock.=str_replace(' ','&nbsp;',str_replace('&#','&amp;#',str_replace('>','&gt;',str_replace('<','&lt;',substr($aline,1))))) . $delm;
           }
         } else if ($needschange != '') {
           $thisoldblock.=$aline . $delm;
           $thisnewblock.=$aline . $hdelm;
         } 
       } else if (trim($aline) == '') {
         if ($needschange != '') {
           $thisoldblock.=$aline . $delm;
           $thisnewblock.=$aline . $hdelm;
         }
       } else {
         if ($thisoldblock != '' && $needschange != '') {
           if (strpos($outrepis, $thisoldblock) === false) {
             if (strpos($outrepis, $needschange) !== false && strpos($outrepis, $lastaline) !== false) {
               $thisoldblock=$needschange . explode($lastaline, explode($needschange, $outrepis)[1])[0] . $lastaline;
             }
           }
           $outrepis=str_replace($thisoldblock, $thisnewblock, $outrepis);
         }

    $thisoldblock='';
    $thisnewblock='';
    $needschange='';
         if (strpos($aline, "a") !== false) {
           if (strpos($amx, "checkh='") !== false) {
             $mx=str_replace("checkh='", "checkh=" . urlencode($aline) . "'", $mx);
             $amx="";
           }
    $needschange=$aline;
         } else if (strpos($aline, "c") !== false) {
           if (strpos($amx, "checkh='") !== false) {
             $mx=str_replace("checkh='", "checkh=" . urlencode($aline) . "'", $mx);
             $amx="";
           }
    $needschange=$aline;
         } else if (strpos($aline, "d") !== false) {
           if (strpos($amx, "checkh='") !== false) {
             $mx=str_replace("checkh='", "checkh=" . urlencode($aline) . "'", $mx);
             $amx="";
           }
    $needschange=$aline;
         }
         
         if ($needschange != '') {
           $thisoldblock=$aline . $delm;
           $thisnewblock=$aline . $hdelm;
         }

       }
       $lastaline=$aline;
    }
    
    if ($thisoldblock != '' && $needschange != '') {
           if (strpos($outrepis, $thisoldblock) === false) {
             if (strpos($outrepis, $needschange) !== false) {
               $thisoldblock=$needschange . explode($needschange, $outrepis)[1];
             }
           }
           $outrepis=str_replace($thisoldblock, $thisnewblock, $outrepis);
    }
    if ($outrepis != '') { 
      $xrepis='<html><head>' . $style . '</head><body>' . $outrepis;
      $outrepis=$xrepis . '</body></html>';  
    }
//file_put_contents('x.x', $outrepis);
    if (sizeof($parts) > 2) {
    if (file_exists(trim(str_replace('.huh','.html',$parts[2])))) {
    file_put_contents(trim(str_replace('.huh','.html',$parts[2])), file_get_contents(trim(str_replace('.huh','.html',$parts[2]))) . $delm . $outrepis);
    } else {
    file_put_contents(trim(str_replace('.huh','.html',$parts[2])), $outrepis);
    }
    } else {
    file_put_contents(trim(str_replace('.huh','.html',$parts[1])), $outrepis);
    }
    //$legend='&nbsp;<span><font size=2 color=purple>New additional</font></span>&nbsp;<span><font size=2 color=magenta>Changed single </font><font size=2 color=indigo>line</font></span>&nbsp;<span><font size=2 color=blue>New block of lines</font></span>&nbsp;<span><font size=2 color=orange>Deleted lines</font></span>&nbsp;<span><font size=2 color=darkgreen>Changed multiple </font><font size=2 color=olive>lines</font>&nbsp;<a onclick="window.open(' . "'huh" . server_remote_addr() . ".huh','_blank'" . ');" style=text-decoration:underline;cursor:pointer;>Original ...</a></span>';
    $legend='&nbsp;<span id=lspan title="Clicks can offer user controlled size and colour coding and other CSS styling functionality.  Right click or two finger gesture allows for change of wording here, and if that changed wording ends with a space it will be saved."><span><font  onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f0 size=2 color=purple>New additional</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f1 size=2 color=magenta>Changed single </font><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f2 size=2 color=indigo> line</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f3 size=2 color=blue>New block of lines</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f4 size=2 color=orange>Deleted lines</font></span>&nbsp;<span><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f5 size=2 color=darkgreen>Changed multiple </font><font onblur=onb(event); oncontextmenu="blurize(this).setAttribute(' . "'contenteditable'" . ',true);" onclick=askabout(this); style=cursor:pointer; id=f6 size=2 color=olive>lines</font>&nbsp;<a id=myaa onclick="var wod=window.open(' . "'','_blank','left=100,top=100,width=600,height=600'" . '); wod.document.write(' . "'<textarea title=' + document.URL + ' cols=120 rows=40 style=background-color:pink;>' + " . 'window.atob(' . "'" . trim(base64_encode(file_get_contents("huh" . server_remote_addr() . ".huh"))) . "'" . ') + ' . "'</textarea>'" . '); wod.document.title=document.URL;  " style=text-decoration:underline;cursor:pointer; title="If colour coding showing (just below) clicking here shows you original difference report (but empty until then).">Original ...</a></span></span>';
    //$onecommand=" function muchl() { if (document.getElementById('lspan').innerHTML.indexOf(\".atob('')\") != -1) { document.getElementById('lspan').innerHTML=document.getElementById('lspan').innerHTML.replace(\".atob('')\", \".atob('" . trim(base64_encode(file_get_contents("huh" . server_remote_addr() . ".huh"))) . "')\");   } } setTimeout(muchl,8000); ";
    return exec($incm);
  } else {
    return exec($incm);
  }
  return $outrepis;
}

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" . server_remote_addr() . ".one', '_blank', 'top=50,left=50,width=400,height=400'); \">...</a>";
    }
  }
  return $oon;
}

function mapit($oone) {
  global $lastoi, $lastonetodelete;
  if (strpos($oone, ".one") === false) {
  if (file_exists(dirname(__FILE__) . "/" . str_replace('.', server_remote_addr() . '.', $oone))) {
    return str_replace('.', server_remote_addr() . '.', $oone);
  }
  return $oone;
  }
  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("&#","&amp;#", str_replace("\n","<br>",   str_replace('&lt;A ','<A ', str_replace('&lt;SPAN ','<SPAN ',  str_replace('&lt;/A&gt;','</A>', str_replace('&lt;DIV ','<DIV ',  str_replace('&lt;/DIV&gt;','</DIV>',  str_replace('&lt;/SPAN&gt;','</SPAN>', str_replace('ccc"&gt;','ccc">',  str_replace("<","&lt;",str_replace(">","&gt;",$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="";
  if (file_exists(dirname(__FILE__) . "/" . str_replace('.', server_remote_addr() . '.', $oone))) {
    return str_replace('.', server_remote_addr() . '.', $oone);
  }
  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:indigo; 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:indigo; 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:indigo; 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:indigo; 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:indigo; 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));
   }
   //file_put_contents('x1.x1', "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) {
   //file_put_contents('x2.x2', "http:" . $inuis);
   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 ... " . hit($_GET['one']) . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . "?rand=" . rand(0,564533) . " 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>" . $legend . "</h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 id=ifhuh src='huh" . server_remote_addr() . ".huh?rand=" . rand(0,5645342) . "' 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 ... " . hit(str_replace("--GETME", "-GETME", $_GET['one'])) . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src=" . mapit('two.two') . "?rand=" . rand(0,564533) . " 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 ... " . hit($_GET['one']) . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . "?rand=" . rand(0,564533) . " 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>" . $legend . "</h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 id=ifhuh src='huh" . server_remote_addr() . ".huh?rand=" . rand(0,5645342) . "' 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 ... " . hit(str_replace("-GETME", "_GETME", $_GET['one'])) . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src=" . mapit('two.two') . "?rand=" . rand(0,564533) . " 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 " . hit($_GET['one']) . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . "?rand=" . rand(0,564533) . " 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>" . $legend . "</h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 id=ifhuh src='huh" . server_remote_addr() . ".huh?rand=" . rand(0,5645342) . "' 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 " . hit($_GET['two']) . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src=" . mapit('two.two') . "?rand=" . rand(0,564533) . " 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" . hit($_POST['one']) . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . "?rand=" . rand(0,564533) . " 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>" . $legend . "</h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 id=ifhuh src='huh" . server_remote_addr() . ".huh?rand=" . rand(0,5645342) . "' 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" . hit(str_replace("--GETME", "-GETME", $_POST['one'])) . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src=" . mapit('two.two') . "?rand=" . rand(0,564533) . " 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" . hit($_POST['one']) . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . "?rand=" . rand(0,564533) . " 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>" . $legend . "</h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 id=ifhuh src='huh" . server_remote_addr() . ".huh?rand=" . rand(0,5645342) . "' 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" . hit(str_replace("-GETME", "_GETME", $_POST['one'])) . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src=" . mapit('two.two') . "?rand=" . rand(0,564533) . " 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 " . hit($_POST['one']) . "</h1><br><details open><summary></summary><iframe style='" . $bciy . "width:100%;height:300px;' height=300 src=" . mapit('one.one') . "?rand=" . rand(0,564533) . " 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>" . $legend . "</h1><br><details open><summary></summary><iframe style='background-color:pink;width:100%;height:300px;' height=300 id=ifhuh src='huh" . server_remote_addr() . ".huh?rand=" . rand(0,5645342) . "' 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 " . hit($_POST['two']) . "</h1><br><details open><summary></summary><iframe style='background-color:lightgreen;width:100%;height:300px;' height=300 src=" . mapit('two.two') . "?rand=" . rand(0,564533) . " 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","");
  $jjg=1;
  while (file_exists(dirname(__FILE__) . "/huh0JUNK9.html")) {
     sleep(5);
     $jjg++;
     if ($jjg >= 9) {  unlink(dirname(__FILE__) . "/huh0JUNK9.html"); }
  }
  $fh = fopen(dirname(__FILE__) . "/one" . server_remote_addr() . ".one", "w");
  fwrite($fh, $onec);
  fclose($fh);
  $fh = fopen(dirname(__FILE__) . "/two" . server_remote_addr() . ".two", "w");
  fwrite($fh, $twoc);
  fclose($fh);
  if (isset($_GET['markit'])) {
  ourshell_exec("diff " . $_GET['minus'] . " " . dirname(__FILE__) . "/one" . server_remote_addr() . ".one " . dirname(__FILE__) . "/two" . server_remote_addr() . ".two > " . dirname(__FILE__) . "/huh" . server_remote_addr() . ".huh");
  exec("cp -r " . dirname(__FILE__) . "/one" . server_remote_addr() . ".one " . dirname(__FILE__) . "/one.one");
  exec("cp -r " . dirname(__FILE__) . "/two" . server_remote_addr() . ".two " . dirname(__FILE__) . "/two.two");
  } else {
  exec("diff " . $_GET['minus'] . " " . dirname(__FILE__) . "/one" . server_remote_addr() . ".one " . dirname(__FILE__) . "/two" . server_remote_addr() . ".two > " . dirname(__FILE__) . "/huh" . server_remote_addr() . ".huh");
  exec("cp -r " . dirname(__FILE__) . "/one" . server_remote_addr() . ".one " . dirname(__FILE__) . "/one.one");
  exec("cp -r " . dirname(__FILE__) . "/two" . server_remote_addr() . ".two " . dirname(__FILE__) . "/two.two");
  }
  $onecommand.=" function muchl() { if (document.getElementById('lspan').innerHTML.indexOf(\".atob('')\") != -1) { document.getElementById('lspan').innerHTML=document.getElementById('lspan').innerHTML.replace(\".atob('')\", \".atob('" . trim(base64_encode(file_get_contents("huh" . server_remote_addr() . ".huh"))) . "')\");  } } setTimeout(muchl,8000); ";
  if (file_exists(dirname(__FILE__) . "/one" . server_remote_addr() . ".one")) {
    unlink(dirname(__FILE__) . "/one" . server_remote_addr() . ".one");
  }
  if (file_exists(dirname(__FILE__) . "/two" . server_remote_addr() . ".two")) {
    unlink(dirname(__FILE__) . "/two" . server_remote_addr() . ".two");
  }
  //if ($called == "") unlink(dirname(__FILE__) . "/one" . server_remote_addr() . ".one" . server_remote_addr() . ".html");
  if ($called == "") unlink(dirname(__FILE__) . "/one" . server_remote_addr() . ".one");
  if ($called == "") unlink(dirname(__FILE__) . "/two" . server_remote_addr() . ".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>" . $style . "<scr" . "ipt type=text/javascript> function checkhcheckhtml() { document.getElementById('ifdiffx').src=document.getElementById('ifdiffx').src.replace('checkh=','checkhtml='); }  function checkhtmldeletehtml() { document.getElementById('ifdiffx').src=document.getElementById('ifdiffx').src.replace('checkhtml=','deletehtml='); } function checkh(iois) {  if (('' + iois.src).indexOf('checkh=') != -1) {  setTimeout(checkhcheckhtml,20000); } else if (('' + iois.src).indexOf('checkhtml=') != -1) {  setTimeout(checkhtmldeletehtml,20000);  } } " . $onecommand . " </scr" . "ipt><title>PHP Linux diff file differences ... First file, Differences, Second file ... RJM Programming November 2013</title></head><body" . $onloadbit . ">\n";
    echo $iframebits;
    echo $mx . "<div id=dstyle></div></body></html>";
  
    if ($lastonetodelete != "") {
      exec("sleep 8; rm -f " . $lastonetodelete);
      $lastonetodelete="";
    }
  } else {
    header("Location: " . "/huh" . server_remote_addr() . ".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>" . $style . "<scr" . "ipt type=text/javascript> function checkhcheckhtml() { document.getElementById('ifdiffx').src=document.getElementById('ifdiffx').src.replace('checkh=','checkhtml='); }  function checkhtmldeletehtml() { document.getElementById('ifdiffx').src=document.getElementById('ifdiffx').src.replace('checkhtml=','deletehtml='); } function checkh(iois) {  if (('' + iois.src).indexOf('checkh=') != -1) {  setTimeout(checkhcheckhtml,20000); } else if (('' + iois.src).indexOf('checkhtml=') != -1) {  setTimeout(checkhtmldeletehtml,20000);  } } " . $onecommand . " </scr" . "ipt><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 $mx . "<div id=dstyle></div></body></html>";
  
  if ($lastonetodelete != "") {
    exec("sleep 8; rm -f " . $lastonetodelete);
    $lastonetodelete="";
  }
}
?>
