<?php
// renamer.php
// Allow for *.htm* rename to *.php
// RJM Programming
// October, 2016

if (isset($_GET['access']) && isset($_GET['from'])) {
  $getfrom = $_GET['from'];
  if (strpos($getfrom, ".") === false) $getfrom=urldecode($_GET['from']);
  if ($_GET['access'] == 'password') {
   $bits=explode(".", $getfrom);
   if (file_exists($getfrom) && sizeof($bits) > 1) {
     if (strlen($bits[-1 + sizeof($bits)]) > 0 && strlen($bits[-1 + sizeof($bits)]) <= 4) {
        $outf=str_replace("." . $bits[-1 + sizeof($bits)] . "~", ".php", $getfrom . "~");
        if (!file_exists($outf)) {
         rename($getfrom, $outf);
        }
     }
   }
  }
}
?>