<?php
// one_image_website_generic_changes.php
// April, 2026

$res='';
$pblockuptop="<" . "?" . "ph" . "p

  \$oklist=['0::1', '1.156.90.221'];

  function server_remote_addr() {
    global \$ris;
    \$rma = \$_SERVER['REMOTE_ADDR'];
    if (\$rma != \"\") {
      \$qris = \$rma;
    } else if (\$rma == \"\") {
      \$rma = \$qris;
    }
    \$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;
    //echo \"<p>\".\$ua.\$rma.\"</p>\";
    return \$rma;
  }

  if (isset(\$_GET['getmeip'])) {
    \$okipwise=false;
    \$visip=server_remote_addr();
    for (\$inb=0; \$inb<sizeof(\$oklist); \$inb++) {
        if (strpos(\$visip . '!', \$oklist[\$inb] . '!') !== false) {
          \$okipwise=true;
        }
    }
    if (\$okipwise) {
      echo '[\"' . server_remote_addr() . '\"]';
    } else {
      echo '[\"\",\"' . server_remote_addr() . '\"]';
    }
    exit;
  } else if (isset(\$_GET['diris']) && isset(\$_GET['prefixis']) && isset(\$_GET['startsuffix']) && isset(\$_GET['endsuffix'])) {
    \$arrbit='';
    if (\$_GET['prefixis'] != '' && \$_GET['diris'] != '' && \$_GET['startsuffix'] != '' && \$_GET['endsuffix'] != '') {
     foreach(glob(str_replace('+',' ',urldecode(\$_GET['diris'])) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode(\$_GET['prefixis'])) . '*.*g*') as \$filename) {
        if (strpos(\$filename, str_replace('+',' ',urldecode(\$_GET['diris'])) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode(\$_GET['prefixis']))) !== false) {
          \$restfnamebit=explode('.', explode(str_replace('+',' ',urldecode(\$_GET['diris'])) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode(\$_GET['prefixis'])), \$filename)[1])[0];
          if (\$restfnamebit < str_replace('+',' ',urldecode(\$_GET['startsuffix'])) || \$restfnamebit > str_replace('+',' ',urldecode(\$_GET['endsuffix']))) {
           if (\$arrbit == '') {
            \$arrbit='[\"' . \$filename . '\"]';
           } else {
            \$arrbit=str_replace(']', ',\"' . \$filename . '\"]', \$arrbit);
           }
          }
        }
     }
     if (\$arrbit == '') {
       echo \"[]\";
     } else {
       echo \$arrbit;
     }
     exit;
    }
    echo \"[]\";
    exit;
  } else if (isset(\$_POST['newdurl']) && isset(\$_POST['diris']) && isset(\$_POST['prefixis']) && isset(\$_POST['startsuffix']) && isset(\$_POST['endsuffix'])) {
      //file_put_contents('x0.x0', '');
    if (strpos(str_replace(' ','+',urldecode(\$_POST['newdurl'])), 'data:image/') !== false && \$_POST['prefixis'] != '' && \$_POST['diris'] != '' && \$_POST['startsuffix'] != '' && \$_POST['endsuffix'] != '') {
      \$okipwise=false;
      \$visip=server_remote_addr();
      for (\$inb=0; \$inb<sizeof(\$oklist); \$inb++) {
        if (strpos(\$visip . '!', \$oklist[\$inb] . '!') !== false) {
          \$okipwise=true;
        }
      }
      if (\$okipwise) {
      \$proposedext='.' . str_replace('jpeg','jpg',explode(';',explode(',',explode('data:image/', str_replace(' ','+',urldecode(\$_POST['newdurl'])))[1])[0])[0]);
      //file_put_contents('x1.x1', \$proposedext);
      if (strpos(\$proposedext, 'g') !== false) {
        \$fidea=str_replace('+',' ',urldecode(\$_POST['endsuffix']));
        \$isthere=true;
        \$fnameproposed='';
        while (\$isthere) {
         \$isthere=false;
         foreach(glob(str_replace('+',' ',urldecode(\$_POST['diris'])) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode(\$_POST['prefixis'])) . \$fidea . '.*g*') as \$filename) {
          \$isthere=true;
         }
         if (!\$isthere) {
           \$fnameproposed=str_replace('+',' ',urldecode(\$_POST['diris'])) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode(\$_POST['prefixis'])) . \$fidea . \$proposedext;
         } else {
           \$fidea++;
         }
        }
        //file_put_contents('x2.x2', \$fnameproposed);
        if (\$fnameproposed != '') {
         file_put_contents(\$fnameproposed, base64_decode(explode(\";base64,\", str_replace(' ','+',urldecode(\$_POST['newdurl'])))[1]));
        //file_put_contents('x3.x3', \$fnameproposed);
        }
      }
      }
    }
    exit;
  }
?" . ">
";

if (isset($_POST['offdr'])) {
   $res='<p>Nothing to do.</p>';
   if ($_POST['offdr'] != '') {
     if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['offdr'])))) {
       foreach(glob($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['offdr'])) . DIRECTORY_SEPARATOR . '*[ph][th][pm]*') as $filename) {
          if (strpos($filename, 'GETME') === false && strpos($filename, 'backup') === false) {
          $cont=file_get_contents($filename);
          $newcont=$cont;
          $parts=explode('image_list = new Array();', $cont);
          $partsagain=explode('initthearr(image_list);', $cont);
          $partsscrone=explode('SCRIPT LANGUAGE=', $cont);
          $partsscr=explode('/onrightclick.js', $cont);
          if (basename($filename) == 'index.php') { // block up the top only
            if (strpos($cont, 'server_remote_addr()') === false && strpos($pblockuptop, 'server_remote_addr()') !== false) {
             $newcont=$pblockuptop . $cont;
            }
          } else if (basename($filename) == 'index.html' || basename($filename) == 'index.htm') { // fair few interventions and rearragements
          } else if (strpos(basename($filename),'.htm') !== false) { // one intervention, as required
            if (sizeof($parts) == 2 && sizeof($partsagain) == 1) {
              if (sizeof($partsscrone) == 2 && sizeof($partsscr) == 2) {
                if (strpos($partsscrone[1], '/onrightclick.js') !== false && strpos($parts[0], '<head>') !== false) {
                  $parts[0]=str_replace("<head>", "<head>\n<script type=text/javascript src='/onrightclick.js?rand=86475'></script>\n", $parts[0]);
                  $parts[1]=str_replace("/onrightclick.js", "/onYNFTrightclick.js", $parts[1]);
                }
              }
              $newcont=$parts[0] . "\n image_list = new Array(); \n initthearr(image_list); \n" . $parts[1];
            } else if (sizeof($parts) == 2 && sizeof($partsagain) >= 2) {
              $res=str_replace('<p>Nothing to do.</p>', '<p>Regarding One Image Website folder ' . $_POST['offdr'] . '</p>', $res) . '<p>' . $filename . ' already changed.</p>';
            } else {
              $res=str_replace('<p>Nothing to do.</p>','<p>Regarding One Image Website folder ' . str_replace('+',' ',urldecode($_POST['offdr'])) . '</p>',$res) . '<p>' . $filename . ' not changed.</p>';
            }
          }
          if ($newcont != $cont) {
            $res=str_replace('<p>Nothing to do.</p>','<p>Regarding One Image Website folder ' . str_replace('+',' ',urldecode($_POST['offdr'])) . '</p>',$res) . '<p>' . $filename . ' changed.</p>';
            file_put_contents($filename . '_backup', $cont);
            //file_put_contents($filename, $newcont);
          } else {
            $res=str_replace('<p>Nothing to do.</p>','<p>Regarding One Image Website folder ' . str_replace('+',' ',urldecode($_POST['offdr'])) . '</p>',$res) . '<p>' . $filename . ' not coded for yet.</p>';
          }
          }
       }
     }
   }
}


?>
<html>
<body>
<?php echo $res; ?>
<form method=POST target=_self action='./one_image_website_generic_changes.php'>
<input type=text value='' placeholder='<?php echo (isset($_POST['offdr']) ? str_replace('+',' ',urldecode($_POST['offdr'])) : 'Eg. streetart'); ?>' name=offdr id=offdr></input>
<input type=submit id=fsub value='Process this One Image Website folder HTML and PHP'></input>
</form>
</body>
</html>
