<?php
// events_in_month.php
// RJM Programming
// August, 2023
// Help out events_in_month.htm

   $hcont=file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'events_in_month.htm');
   $cont=file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'events_in_month.php');
   $ipad=server_remote_addr();
   $ipadless=$ipad;
   $js='';

  function server_remote_addr() {
    global $ipadless;
    $rma = $_SERVER['REMOTE_ADDR'];
    $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
    // you can add different browsers with the same way ..
    $ipadless=str_replace(".", "_", str_replace(":", "_", $rma));
    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(".", "_", str_replace(":", "_", $rma));
  }

   $itdone=false;
   if (isset($_GET['init'])) {
     if (strpos($cont, '_' . $ipad . '=') !== false) {
       $things=explode('_' . $ipad . '=', $cont);
       for ($it=1; $it<sizeof($things); $it++) {
          if ($it == 1 && !$itdone) { 
           $itdone=true;
           $js.="\n parent.document.getElementById('myoldsel').style.display='inline-block'; \n";  
          } 
          $js.="\n parent.document.getElementById('myoldsel').innerHTML+='<option value=\"" . str_replace("'", "' + String.fromCharCode(39) + '", explode("\n", $things[$it])[0]) . "\">" . str_replace("'", "' + String.fromCharCode(39) + '", explode('__', explode(' ' . ' ' . ' ', $things[-1 + $it])[-1 + sizeof(explode(' ' . ' ' . ' ', $things[-1 + $it]))])[0] . ', ' . explode('_', explode('__', explode(' ' . ' ' . ' ', $things[-1 + $it])[-1 + sizeof(explode(' ' . ' ' . ' ', $things[-1 + $it]))])[1])[0]) . "</option>'; \n";
       }
     }
     if (strpos($cont, '0' . $ipadless . '=') !== false) {
       $things=explode('0' . $ipadless . '=', $cont);
       for ($it=1; $it<sizeof($things); $it++) {
          if ($it == 1 && !$itdone) { 
           $itdone=true;
           $js.="\n parent.document.getElementById('myoldsel').style.display='inline-block'; \n";  
          } 
          $js.="\n parent.document.getElementById('myoldsel').innerHTML+='<option value=\"" . str_replace("'", "' + String.fromCharCode(39) + '", explode("\n", $things[$it])[0]) . "\">" . str_replace("'", "' + String.fromCharCode(39) + '", explode('__', explode(' ' . ' ' . ' ', $things[-1 + $it])[-1 + sizeof(explode(' ' . ' ' . ' ', $things[-1 + $it]))])[0] . ', ' . explode('_', explode('__', explode(' ' . ' ' . ' ', $things[-1 + $it])[-1 + sizeof(explode(' ' . ' ' . ' ', $things[-1 + $it]))])[1])[0]) . "</option>'; \n";
       }
     }
     echo "<html><head><script type='text/javascript'> " . $js . " </script></head><body><p>" . $ipad . "</p></body></html>";
   } else if (isset($_GET['exactlabel'])) {
     if (strpos($cont, '//   ' . urldecode($_GET['exactlabel']) . '=') !== false) {
     echo str_replace("=docum" . "ent.URL","='" . str_replace("'", "' + String.fromCharCode(39) + '", explode("\n", explode('//   ' . urldecode($_GET['exactlabel']) . '=', $cont)[-1 + sizeof(explode('//   ' . urldecode($_GET['exactlabel']) . '=', $cont))])[0]) . "'", $hcont);
     } else {
     echo $hcont;
     }
   } else if (isset($_POST['phpthere']) && isset($_POST['bigurl']) && isset($_POST['caltitle'])) {
 //file_put_contents('xz.xz', 'l');
     if (strpos($cont, '//   ' . str_replace(' ','_',str_replace(',','_',str_replace('+',' ',urldecode($_POST['caltitle'])))) . '_' . str_replace('+',' ',urldecode($_POST['phpthere'])) . '=' . $_POST['bigurl'] . "\n") === false && strpos($cont, '//   ' . str_replace(' ','_',str_replace(',','_',str_replace('+',' ',urldecode($_POST['caltitle'])))) . '_' . str_replace('+',' ',urldecode($_POST['phpthere'])) . '=' . $_POST['bigurl'] . "#") === false) {
 //file_put_contents('xz.xzz', 'l');
     $arg1='?' . '>';
     $arg2='?' . '>';
     if (strpos($cont, '//   ' . str_replace(' ','_',str_replace(',','_',str_replace('+',' ',urldecode($_POST['caltitle'])))) . '_' . str_replace('+',' ',urldecode($_POST['phpthere'])) . '=') !== false) {
       $arg2='';
       $arg1='//   ' . str_replace(' ','_',str_replace(',','_',str_replace('+',' ',urldecode($_POST['caltitle'])))) . '_' . str_replace('+',' ',urldecode($_POST['phpthere'])) . '=' . explode("\n", explode('//   ' . str_replace(' ','_',str_replace(',','_',str_replace('+',' ',urldecode($_POST['caltitle'])))) . '_' . str_replace('+',' ',urldecode($_POST['phpthere'])) . '=', $cont)[1])[0] . "\n";
       $cont=str_replace($arg1, '', $cont);
     }
     $arg1='?' . '>';
     $arg2='?' . '>';
     $cont=str_replace($arg1, '//   ' . str_replace(' ','_',str_replace(',','_',str_replace('+',' ',urldecode($_POST['caltitle'])))) . '_' . str_replace('+',' ',urldecode($_POST['phpthere'])) . '=' . $_POST['bigurl'] . '#' . str_replace(' ','_',str_replace(',','_',str_replace('+',' ',urldecode($_POST['caltitle'])))) . '_' . str_replace('+',' ',urldecode($_POST['phpthere'])) . "\n" . $arg2, $cont);
     file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'events_in_month.php', $cont);
     }
     if (strpos($cont, '_' . $ipad . '=') !== false) {
       $things=explode('_' . $ipad . '=', $cont);
       for ($it=1; $it<sizeof($things); $it++) {
          if ($it == 1 && !$itdone) { 
           $itdone=true;
           $js.="\n parent.document.getElementById('myoldsel').style.display='inline-block'; \n";  
          } 
          $js.="\n parent.document.getElementById('myoldsel').innerHTML+='<option value=\"" . str_replace("'", "' + String.fromCharCode(39) + '", explode("\n", $things[$it])[0]) . "\">" . str_replace("'", "' + String.fromCharCode(39) + '", explode('__', explode(' ' . ' ' . ' ', $things[-1 + $it])[-1 + sizeof(explode(' ' . ' ' . ' ', $things[-1 + $it]))])[0] . ', ' . explode('_', explode('__', explode(' ' . ' ' . ' ', $things[-1 + $it])[-1 + sizeof(explode(' ' . ' ' . ' ', $things[-1 + $it]))])[1])[0]) . "</option>'; \n";
       }
     }
     if (strpos($cont, '0' . $ipadless . '=') !== false) {
       $things=explode('0' . $ipadless . '=', $cont);
       for ($it=1; $it<sizeof($things); $it++) {
          if ($it == 1 && !$itdone) { 
           $itdone=true;
           $js.="\n parent.document.getElementById('myoldsel').style.display='inline-block'; \n";  
          } 
          $js.="\n parent.document.getElementById('myoldsel').innerHTML+='<option value=\"" . str_replace("'", "' + String.fromCharCode(39) + '", explode("\n", $things[$it])[0]) . "\">" . str_replace("'", "' + String.fromCharCode(39) + '", explode('__', explode(' ' . ' ' . ' ', $things[-1 + $it])[-1 + sizeof(explode(' ' . ' ' . ' ', $things[-1 + $it]))])[0] . ', ' . explode('_', explode('__', explode(' ' . ' ' . ' ', $things[-1 + $it])[-1 + sizeof(explode(' ' . ' ' . ' ', $things[-1 + $it]))])[1])[0]) . "</option>'; \n";
       }
     }
 //file_put_contents('xz.xzzz', "<html><head><script type='text/javascript'> " . $js . "\n parent.checkif(parent.document.getElementById('phpif')); \n" . " </script></head><body><p>" . str_replace(' ','%20',str_replace('+',' ',urldecode($_POST['bigurl']))) . "</p></body></html>");
     echo "<html><head><script type='text/javascript'> " . $js . "\n parent.checkif(parent.document.getElementById('phpif')); \n" . " </script></head><body><p>" . str_replace("'",'%27',str_replace(' ','%20',str_replace('+',' ',urldecode($_POST['bigurl'])))) . "</p></body></html>";
   } else {
     echo $hcont;
   }
   exit;

//   
//
//   January__1970_00000__1=http://localhost:8888/events_in_month.htm?caltitle=January%2C%201970&i01.00=&ta01.00=kgjfjhf%20jhgfjhf%20jhkgkjhg%20jhgkjhg%20jkghhg%20jkhgkjhg%20kjhgkjhg&i02.00=&ta02.00=kjhgkjh%20kjhgkjhg%20jkhgkjhg%20kjhgkjhg%20kjhgkjhg%20jhkgkjhg%20kjgkjhg&i03.00=&ta03.00=kjhgkjhg%20kjhgkjhg%20kjhgkjhg%20kjhgkjhg%20kjhgkjhg%20jhkgkjhg&i04.00=&ta04.00=&i05.00=&ta05.00=&i06.00=&ta06.00=&i07.00=&ta07.00=&i08.00=&ta08.00=&i09.00=&ta09.00=&i10.00=&ta10.00=&i11.00=&ta11.00=&i12.00=&ta12.00=&i13.00=&ta13.00=&i14.00=&ta14.00=&i15.00=&ta15.00=&i16.00=&ta16.00=&i17.00=&ta17.00=&i18.00=&ta18.00=&i19.00=&ta19.00=&i20.00=&ta20.00=&i21.00=&ta21.00=&i22.00=&ta22.00=&i23.00=&ta23.00=&i24.00=&ta24.00=&i25.00=&ta25.00=&i26.00=&ta26.00=&i27.00=&ta27.00=&i28.00=&ta28.00=&i29.00=&ta29.00=&i30.00=&ta30.00=&i31.00=&ta31.00=#January__1970_00000__1
//   August__2023_00000__1=http://localhost:8888/events_in_month.htm?caltitle=August%2C%202023&i01.00=&ta01.00=Tomorrow's%20counterpart%20two%20weeks%20ago.&i02.00=&ta02.00=Hump%20Day%20a%20week%20ago.&i03.00=&ta03.00=This%20born%20on%20this%20day%20has%20far%20to%20go.&i04.00=&ta04.00=The%20weekend%20two%20ago%20beckons.&i05.00=&ta05.00=The%20weekend%20two%20ago%20starts%20here.&i06.00=&ta06.00=Week%2032%20of%20year%202023%20starts%20hereaways.&i07.00=&ta07.00=This%20is%20last%20Monday.&i08.00=&ta08.00=&i09.00=&ta09.00=&i10.00=&ta10.00=&i11.00=&ta11.00=&i12.00=&ta12.00=&i13.00=&ta13.00=&i14.00=&ta14.00=&i15.00=&ta15.00=&i16.00=&ta16.00=&i17.00=&ta17.00=&i18.00=&ta18.00=&i19.00=&ta19.00=&i20.00=&ta20.00=&i21.00=&ta21.00=&i22.00=&ta22.00=&i23.00=&ta23.00=&i24.00=&ta24.00=&i25.00=&ta25.00=&i26.00=&ta26.00=&i27.00=&ta27.00=&i28.00=&ta28.00=&i29.00=&ta29.00=&i30.00=&ta30.00=&i31.00=&ta31.00=#August__2023_00000__1
?>
