<?php
// middle_interest.php
// Supervise middle_interest.html

$savecont='';
$savemode=false;
$recallmode=false;
$html='';
$sidea='';
$datepart='';
$fname='';
$spare='';
$fcont='';
$exp='';

function server_remote_addr() {
    $rma = $_SERVER['REMOTE_ADDR'];
    if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARTDED_FOR'] != '') {
      $rma = $_SERVER['HTTP_X_FORWARDED_FOR'];
	} else {
      $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 check_glob($inht) {
  global $sidea, $exp;
  
  $oldexp=$exp;

 if (isset($_POST['save']) || isset($_GET['save'])) {
  if (isset($_POST['save'])) {
   $sidea=urldecode($_POST['save']);
  } else {
   $sidea=urldecode($_GET['save']);
  }
 }
 
  $delim='</select>';
  $x='';
     //file_put_contents('zmz.zm', $inht);
  //if (strpos($inht, '<form') !== false) $delim='</option></sel';
     //file_put_contents('zmz.zm', $_SERVER['QUERY_STRING']);
  if (isset($_GET['blogselect'])) $x=$_GET['blogselect'];
  if ($x == '00000000') {
    $outht='<!doctype html><html><head><scr' . 'ipt type="text/javascript"> function placeopt() {  var imtb=top.document.getElementById("mymode"); if (imtb) {   } } </scr' . 'ipt></head><body onload="placeopt();"></body></html>';
     //file_put_contents('zmz.zm', $x);
  } else {
   if (file_exists($inht)) {
   $outht=file_get_contents($inht);
   } else {
   $outht=$inht;
   }
  }
  $obits='';
  $sb=explode($delim, $outht);
  if (sizeof($sb) == 5 || $x == '00000000') {
   //file_put_contents('zm.zm',$sb[-1 + sizeof($sb)]);
   //file_put_contents('zm2.zm',$sb[-2 + sizeof($sb)]);
   //file_put_contents('zm3.zm',$sb[-3 + sizeof($sb)]);
   //file_put_contents('zm4.zm',$sb[-4 + sizeof($sb)]);
   //$outht=str_replace('<head><scr','<head><title>Title</title><scr',  $outht);
   foreach (glob("mi_" . server_remote_addr() . "_*.php") as $filename) {
    if ($x == '00000000') {
      $tbits=explode('var theme = "', file_get_contents($filename));
      if (sizeof($tbits) > 1) {
        $tbitstwo=explode('"',$tbits[1]);
        $exp=$tbitstwo[0]; 
      } 
    }
    if ($exp == '') $exp='ESL';
    $sf=explode("mi_" . server_remote_addr() . "_", $filename);
    //if (strpos($_SERVER['QUERY_STRING'], 'select=00000000') !== false) {
    // $outht=str_replace("}", "\n top.document.getElementById('mymode').innerHTML+='" . "<option value=./middle_interest.php?blogselect=" . str_replace('.php','',$sf[1]) . ">" . $filename . "</option>" . "'; \n }");
    //} else {
     $lastobits="<option value=./middle_interest.php?blogselect=" . str_replace('.php','',$sf[1]) . ">" . str_replace("mi_" . server_remote_addr() . "_", str_replace('&theme=','',$exp) . " ", $filename) . "</option>";
     if ($x == '00000000') {
     if (strpos($outht,substr($lastobits,strlen($lastobits) - 21)) === false) $outht=str_replace('(imtb) {','(imtb) { if (imtb.innerHTML.indexOf("' . str_replace('.php','',$sf[1]) . '") == -1) { imtb.innerHTML+="' . $lastobits . '"; } ',  $outht);
     } else {
     //$lastobits=str_replace('<option ','<option  ',$lastobits);
     if (strpos($outht,"=" . str_replace('.php','',$sf[1])) === false) $outht=str_replace('var mtmodeadd="','var mtmodeadd="' . $lastobits,  $outht);
     }
     $obits .= str_replace('<option  ','<option ',$lastobits);
     //file_put_contents('zm.zm',$obits);
    //}
    
    $exp=$oldexp;
   }
  }
  
  if ($obits != '') {
    //$outht=str_replace('var mtmodeadd="','var mtmodeadd="' . $obits,str_replace('<option value=./middle_interest.php?save=save>Save All</option></select>','<option value=./middle_interest.php?save=save>Save All</option>' . $obits . '</select>', str_replace($delim . $sb[-2 + sizeof($sb)], $obits . $delim . $sb[-2 + sizeof($sb)], $outht)));
    if ($inht != "") $outht=str_replace('<option value=./middle_interest.php?save=save>Save All</option></select>','<option value=./middle_interest.php?save=save>Save All</option>' . $obits . '</select>', str_replace($delim . $sb[-2 + sizeof($sb)], $obits . $delim . $sb[-2 + sizeof($sb)], $outht));
    //if (strpos($outht, $delim . $sb[-2 + sizeof($sb)]) !== false) file_put_contents('zm90.zm', $obits . $delim . $sb[-2 + sizeof($sb)]);
    //file_put_contents('zm9.zm', $obits . $delim . $sb[-2 + sizeof($sb)]);
    //file_put_contents('zm8.zm', $outht);
  }
  if (file_exists($inht) && $obits != '') {
    file_put_contents($inht, $outht);
    //header("Location: " . $outht);
    //exit;
  }
  return $outht;
}

function dollar_get($inhuh) {
  global $datepart, $fname, $fcont;
   //  file_put_contents('zmqaq.zm', $inhuh);
  $retval='';
    if ($datepart == '') {
     date_default_timezone_set('Australia/Perth');
     $datepart=date('Ymd');
    }
  if ($fname == '') $fname="mi_" . server_remote_addr() . "_" . $datepart . ".php";
   //  if ($inhuh == 'bw1_2_') file_put_contents('zmqq.zm', $fname);
  if (file_exists($fname)) {
    if ($fcont == '') $fcont=file_get_contents($fname);
    $fb=explode(($inhuh . "="), ($fcont . "&"));
    if (sizeof($fb) > 1) {
     $fbs=explode("&", $fb[1]);
  //   if ($inhuh == 'bw1_2_') file_put_contents('zmq.zm', $fbs[0]);
     $retval=$fbs[0];
    }
  } 
  return $retval;
}

function appendto($inb, $two) {
  global $savemode, $datepart, $fname, $sidea;
  if ($sidea != '') {
    if ($datepart == '') {
     date_default_timezone_set('Australia/Perth');
     $datepart=date('Ymd');
    }
  //file_put_contents('zma.zm', $inb);
    if ($fname == '') $fname="mi_" . server_remote_addr() . "_" . $datepart . ".php";
    if (!file_exists($fname)) {
      if ($savemode) file_put_contents($fname, "");
      if (isset($_GET['mode'])) {
        if ($savemode) file_put_contents($fname, str_replace('?mode=./middle_interest.php?','./middle_interest.php?mode=&', "?mode=" . $_GET['mode'] . '&' . str_replace('=',$two . '=',substr($inb,1))) );
      } else if (isset($_POST['mode'])) {
        if ($savemode) file_put_contents($fname, str_replace('?mode=./middle_interest.php?','./middle_interest.php?mode=&', "?mode=" . $_POST['mode'] . '&' . str_replace('=',$two . '=',substr($inb,1))) );
      } else {
        if ($savemode) file_put_contents($fname, str_replace('=',$two . '=',$inb));
      }
    } else if (strpos(file_get_contents($fname), str_replace('=',$two . '=',$inb)) === false) {
      if ($savemode) file_put_contents($fname, file_get_contents($fname) . str_replace('=',$two . '=',$inb));
    }
  }
  return $inb;
}

 if (isset($_POST['save']) || isset($_GET['save'])) {
  if (isset($_POST['save'])) {
   $sidea=urldecode($_POST['save']);
   $savemode=true;
  } else {
   $sidea=urldecode($_GET['save']);
   $savemode=true;
  }
 }

if (isset($_GET['blogselect'])) {
 if (str_replace('select=00000000','',$_SERVER['QUERY_STRING']) != $_SERVER['QUERY_STRING']) {
   echo check_glob("");
   exit;
 }
   //file_put_contents('zmqqqa.zm', "mi_" . server_remote_addr() . '_' . $_GET['blogselect'] . ".php");
 if (strlen($_GET['blogselect']) == 8 && file_exists("mi_" . server_remote_addr() . '_' . $_GET['blogselect'] . ".php")) {
   $datepart=$_GET['blogselect'];
   $recallmode=true;
   //file_put_contents('zmqqq.zm', "mi_" . server_remote_addr() . '_' . $_GET['blogselect'] . ".php");
   $html='';
   $html=check_glob("mi_" . server_remote_addr() . '_' . $_GET['blogselect'] . ".php");
   header("Location: " . "mi_" . server_remote_addr() . '_' . $_GET['blogselect'] . ".php");
   exit;
 }
 $selbit="";
 $lpage=@file_get_contents("http://www.rjmprogramming.com.au/Welcome.html");
 $lbits=explode("<select", str_replace("</select", "<select", $lpage));
 if (sizeof($lbits) > 1) {
  $selbit="&nbsp;&nbsp;<select" . $lbits[sizeof($lbits) - 2] . "</select>";
 }
 $lbits=explode("<scr" . "ipt type='text/javascript'>", str_replace("</scr" . "ipt>", "<scr" . "ipt type='text/javascript'>", $lpage));
 if (sizeof($lbits) > 1) {
  $scrbit="<scr" . "ipt type='text/javascript'>
    var isiPad = navigator.userAgent.match(/iPad/i) != null;
    var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
    var isiPod = navigator.userAgent.match(/iPod/i) != null;
    var isAndroid = navigator.userAgent.match(/Android/i) != null;
    var tval = 1;
 var wasstr = '';
 var bval='  ';
 var bzgoes=0; 
 function butsatpend() {
 var tds = parent.document.getElementsByTagName('td');
 var jmap=[0,1,4,7,2,5,8,3,6,9];
 for (var iq=0; iq<tds.length; iq++) {
  if (iq != 4) tds[iq].innerHTML+='&nbsp;&nbsp;<input onclick=copy(this) style=background-color:pink; type=button id=eb1_' + jmap[eval(1 + iq)] + '_ value=-&gt;1 title=></input>&nbsp;&nbsp;<input onclick=copy(this) style=background-color:pink; type=button id=eb2_' + jmap[eval(1 + iq)] + '_ value=-&gt;2 title=></input>&nbsp;&nbsp;<input onclick=copy(this) style=background-color:pink; type=button id=eb3_' + jmap[eval(1 + iq)] + '_ value=-&gt;3 title=></input>';
 }
 }
 function ChangeTutNow(xxo) {
 var val = document.getElementById('tuts');
 if ( val.value.length == 1 && bzgoes == 0 ) { 
 bzgoes = 1; 
 if (1 == 2) window.open('http://www.rjmprogramming.com.au/ITblog/','Robert Metcalfe Blog','height=429, left=278, top=360, width=400'); } else if (val.value.trim() == '') { toggle(); } else if ( val.value.length != 0 ) {
 if (isiPhone || isAndroid) {
    windowopen(val.value, '_blank'); 
 } 
 }
 var ebo;
 var jmap=[0,1,4,7,2,5,8,3,6,9];
 for (var iq=0; iq<9; iq++) {
  if (iq != 4) {
    ebo=parent.document.getElementById('eb1_' + jmap[eval(1 + iq)] + '_');
    if (ebo != null) ebo.title=val.value;
    ebo=parent.document.getElementById('eb2_' + jmap[eval(1 + iq)] + '_');
    if (ebo != null) ebo.title=val.value;
    ebo=parent.document.getElementById('eb3_' + jmap[eval(1 + iq)] + '_');
    if (ebo != null) ebo.title=val.value;
  }
 }
 }
    function windowopen(myurl,mytarget) {
    } 
    " . $lbits[sizeof($lbits) - 2] . "</scr" . "ipt>";
  echo "<doctype html><html><head>" . $scrbit . "</head><body onload='butsatpend();'>" . $selbit . "</body></html>";
 } else {
 $lbits=explode('<scr' . 'ipt type="text/javascript">', str_replace('</scr' . 'ipt>', '<scr' . 'ipt type="text/javascript">', $lpage));
 if (sizeof($lbits) > 1) {
  $scrbit='<scr' . 'ipt type="text/javascript">
    var isiPad = navigator.userAgent.match(/iPad/i) != null;
    var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
    var isiPod = navigator.userAgent.match(/iPod/i) != null;
    var isAndroid = navigator.userAgent.match(/Android/i) != null;
    var tval = 1;
 var wasstr = "";
 var bval="  ";
 var bzgoes=0; 
 function butsatpend() {
 var tds = parent.document.getElementsByTagName("td");
 var jmap=[0,1,4,7,2,5,8,3,6,9];
 for (var iq=0; iq<tds.length; iq++) {
  if (iq != 4) tds[iq].innerHTML+="&nbsp;&nbsp;<input onclick=copy(this) style=background-color:pink; type=button id=eb1_" + jmap[eval(1 + iq)] + "_ value=-&gt;1 title=></input>&nbsp;&nbsp;<input onclick=copy(this) style=background-color:pink; type=button id=eb2_" + jmap[eval(1 + iq)] + "_ value=-&gt;2 title=></input>&nbsp;&nbsp;<input onclick=copy(this) style=background-color:pink; type=button id=eb3_" + jmap[eval(1 + iq)] + "_ value=-&gt;3 title=></input>";
 }
 }
 function ChangeTutNow(xxo) {
 var val = document.getElementById("tuts");
 if ( val.value.length == 1 && bzgoes == 0 ) { 
 bzgoes = 1; 
 if (1 == 2) window.open("http://www.rjmprogramming.com.au/ITblog/","Robert Metcalfe Blog","height=429, left=278, top=360, width=400"); } else if (val.value.trim() == "") { toggle(); } else if ( val.value.length != 0 ) {
 if (isiPhone || isAndroid) {
    windowopen(val.value, "_blank"); 
 } 
 }
 var ebo;
 var jmap=[0,1,4,7,2,5,8,3,6,9];
 for (var iq=0; iq<9; iq++) {
  if (iq != 4) {
    ebo=parent.document.getElementById("eb1_" + jmap[eval(1 + iq)] + "_");
    if (ebo != null) ebo.title=val.value;
    ebo=parent.document.getElementById("eb2_" + jmap[eval(1 + iq)] + "_");
    if (ebo != null) ebo.title=val.value;
    ebo=parent.document.getElementById("eb3_" + jmap[eval(1 + iq)] + "_");
    if (ebo != null) ebo.title=val.value;
  }
 }
 }
    function windowopen(myurl,mytarget) {
    } 
    ' . $lbits[sizeof($lbits) - 2] . '</scr' . 'ipt>';
  echo '<doctype html><html><head>' . $scrbit . '</head><body onload="butsatpend();">' . $selbit . '</body></html>';
 }
 }
} //else {
if (sizeof($lbits) <= 1 || $recallmode) {
if (sizeof($lbits) <= 1) $used='n';
$expone = '&theme=ESL';
if (file_exists("middle_interest.html")) {
  $html=@file_get_contents("middle_interest.html");
  $exps=explode('&theme=', $html);
  $preexps=explode('&', $exps[1]);
  $expone='&theme=' . $preexps[0];
}

$html = str_replace("'when ready' != 'when ready'", "'when ready' == 'when ready'", str_replace("'when ready'!='when ready'", "'when ready'=='when ready'", $html));
$exp = '&theme=ESL';


if (strlen($_GET['blogselect']) == 8 && file_exists("mi_" . server_remote_addr() . '_' . $_GET['blogselect'] . ".php")) $recallmode=true;
//if ($recallmode) file_put_contents('zmqqqb.zm', "mi_" . server_remote_addr() . '_' . $_GET['blogselect'] . ".php");
if ($recallmode) {
  $used='y';
  $exp = '&theme=' . str_replace('+','%20',str_replace(' ','%20',(dollar_get('theme'))));
  $html = str_replace('var theme', 'var theme="' . urldecode(dollar_get('theme')) . '"; /' . '/', $html);
  $things = explode('&theme=', $html);
  for ($i=1; $i<sizeof($things); $i++) {
   $subthings = explode('&', $things[$i]);
   $html = str_replace('&theme=' . $subthings[0] . '&', appendto('&theme=' . str_replace('+','%20',urlencode(dollar_get('theme'))),'') . '&', $html);
  }
  $exp=$expone;  
} else if (isset($_POST['theme'])) {
  $used='y';
  $exp = '&theme=' . str_replace('+','%20',str_replace(' ','%20',($_POST['theme'])));
  $html = str_replace('var theme', 'var theme="' . urldecode($_POST['theme']) . '"; /' . '/', $html);
  $things = explode('&theme=', $html);
  for ($i=1; $i<sizeof($things); $i++) {
   $subthings = explode('&', $things[$i]);
   $html = str_replace('&theme=' . $subthings[0] . '&', appendto('&theme=' . str_replace('+','%20',urlencode($_POST['theme'])),'') . '&', $html);
  }  
} else if (isset($_GET['theme'])) {
  $used='y';
  $exp = '&theme=' . str_replace('+','%20',str_replace(' ','%20',($_GET['theme'])));
  $html = str_replace('var theme', 'var theme="' . urldecode($_GET['theme']) . '"; /' . '/', $html);
  $things = explode('&theme=', $html);
  for ($i=1; $i<sizeof($things); $i++) {
   $subthings = explode('&', $things[$i]);
   $html = str_replace('&theme=' . $subthings[0] . '&', appendto('&theme=' . str_replace('+','%20',urlencode($_GET['theme'])),'') . '&', $html);
  }  
}




 if ($recallmode) {
  $spare=appendto('&opt1=' . urldecode(dollar_get('opt1')),'');
  $used='y';
  $html = str_replace('var toneis', 'var toneis="' . urldecode(dollar_get('opt1')) . '"; /' . '/', $html);
  //if (isset($_GET['mode'])) {
    if (urldecode(dollar_get('opt1')) == urldecode(dollar_get('mode'))) {
      $html = str_replace('var seltoneis', 'var seltoneis=" selected"; /' . '/', $html);
    } else {
      $html = str_replace('var seltoneis', 'var seltoneis=""; /' . '/', $html);
    }
  //}
} else if (isset($_POST['opt1'])) {
  $spare=appendto('&opt1=' . urldecode($_POST['opt1']),'');
  $used='y';
  $html = str_replace('var toneis', 'var toneis="' . urldecode($_POST['opt1']) . '"; /' . '/', $html);
  if (isset($_POST['mode'])) {
    if (urldecode($_POST['opt1']) == urldecode($_POST['mode'])) {
      $html = str_replace('var seltoneis', 'var seltoneis=" selected"; /' . '/', $html);
    } else {
      $html = str_replace('var seltoneis', 'var seltoneis=""; /' . '/', $html);
    }
  }
} else if (isset($_GET['opt1'])) {
  $spare=appendto('&opt1=' . urldecode($_GET['opt1']),'');
  $used='y';
  $html = str_replace('var toneis', 'var toneis="' . urldecode($_GET['opt1']) . '"; /' . '/', $html);
  if (isset($_GET['mode'])) {
    if (urldecode($_GET['opt1']) == urldecode($_GET['mode'])) {
      $html = str_replace('var seltoneis', 'var seltoneis=" selected"; /' . '/', $html);
    } else {
      $html = str_replace('var seltoneis', 'var seltoneis=""; /' . '/', $html);
    }
  }
}

 if ($recallmode) {
  $spare=appendto('&opt2=' . urldecode(dollar_get('opt2')),'');
  $html = str_replace('var tonealtis', 'var tonealtis="' . urldecode(dollar_get('opt2')) . '"; /' . '/', $html);
  //if (isset($_GET['mode'])) {
    if (urldecode(dollar_get('opt2')) == urldecode(dollar_get('mode'))) {
      $html = str_replace('var seltonealtis', 'var seltonealtis=" selected"; /' . '/', $html);
    } else {
      $html = str_replace('var seltonealtis', 'var seltonealtis=""; /' . '/', $html);
    }
  //}
} else if (isset($_POST['opt2'])) {
  $spare=appendto('&opt2=' . urldecode($_POST['opt2']),'');
  $used='y';
  $html = str_replace('var tonealtis', 'var tonealtis="' . urldecode($_POST['opt2']) . '"; /' . '/', $html);
  if (isset($_POST['mode'])) {
    if (urldecode($_POST['opt2']) == urldecode($_POST['mode'])) {
      $html = str_replace('var seltonealtis', 'var seltonealtis=" selected"; /' . '/', $html);
    } else {
      $html = str_replace('var seltonealtis', 'var seltonealtis=""; /' . '/', $html);
    }
  }
} else if (isset($_GET['opt2'])) {
  $spare=appendto('&opt2=' . urldecode($_GET['opt2']),'');
  $html = str_replace('var tonealtis', 'var tonealtis="' . urldecode($_GET['opt2']) . '"; /' . '/', $html);
  if (isset($_GET['mode'])) {
    if (urldecode($_GET['opt2']) == urldecode($_GET['mode'])) {
      $html = str_replace('var seltonealtis', 'var seltonealtis=" selected"; /' . '/', $html);
    } else {
      $html = str_replace('var seltonealtis', 'var seltonealtis=""; /' . '/', $html);
    }
  }
} 

 

$map=[0,1,4,7,2,5,8,3,6,9];
$rcmprefix='';

  //file_put_contents('zmtq.zm', $html);
$things = explode($exp, $html);
//$things = explode($expone, $html);
$j=1;
$bits='';
for ($i=1; $i<=9; $i++) {
  $j=1;
  $bits='';
  $subthings = explode('"', $things[$map[$i]]);
  if ($recallmode) {
  $map=[0,1,2,3,4,5,6,78,8,9]; //,7,2,5,8,3,6,9];
  if ($i != 5) {
  if ($subthings[0] != "") {
  //file_put_contents('zmt.zm', $subthings[0]);
  while ("" != dollar_get('oc' . $j . '_' . $i . '_')) {
   if ("" != dollar_get('te' . $j . '_' . $i . '_')) { // && strstr(str_replace('http://www.rjmprogramming.com.au/','',urldecode(dollar_get('oc' . $j . '_' . $i . '_'))),'.')) {
    if ("" != dollar_get('bw' . $j . '_' . $i . '_')) {
      $used='y';
      $bits .= appendto('&oc' . $j . '=' . str_replace('+','%20',urlencode(dollar_get('oc' . $j . '_' . $i . '_'))) . '&te' . $j . '=' . str_replace('+','%20',urlencode(dollar_get('te' . $j . '_' . $i . '_'))) . '&bw' . $j . '=' . str_replace('+','%20',urlencode(dollar_get('bw' . $j . '_' . $i . '_'))),'_' . $i . '_');
    }
   }
   $j++;
  }
  if (1 == 4) {
  while ("" != dollar_get('oc' . $j)) {
   if ("" != dollar_get('te' . $j)) { // && strstr(str_replace('http://www.rjmprogramming.com.au/','',urldecode(dollar_get('oc' . $j))),'.')) {
    if ("" != dollar_get('bw' . $j)) {
      $used='y';
      if ($i == 1) $bits .= appendto('&oc' . $j . '=' . str_replace('+','%20',urlencode(dollar_get('oc' . $j))) . '&te' . $j . '=' . str_replace('+','%20',urlencode(dollar_get('te' . $j))) . '&bw' . $j . '=' . str_replace('+','%20',urlencode(dollar_get('bw' . $j))),'');
    }
   }
   $j++;
  }
  }
  if ($bits != "") {
    //if ($i == 2) file_put_contents('zmqbq.zm', $subthings[0] . " vs " . $bits);
    //if ($i == 2 && strpos($html,$subthings[0]) !== false) file_put_contents('zmqcq.zm', str_replace($subthings[0], $bits, $html));
    $rcmprefix='&rcm=1&theme=';
    $html = str_replace($subthings[0], $bits, $html);
  }
  }
  }

  } else {
  if ($subthings[0] != "") {
  while (isset($_POST['oc' . $j])) {
   if (isset($_POST['te' . $j])) { // && strstr(str_replace('http://www.rjmprogramming.com.au/','',urldecode($_POST['oc' . $j])),'.')) {
    if (isset($_POST['bw' . $j])) {
      $used='y';
      if ($i == 1) $bits .= appendto('&oc' . $j . '=' . str_replace('+','%20',urlencode($_POST['oc' . $j])) . '&te' . $j . '=' . str_replace('+','%20',urlencode($_POST['te' . $j])) . '&bw' . $j . '=' . str_replace('+','%20',urlencode($_POST['bw' . $j])),'');
    }
   }
   $j++;
  }
  while (isset($_GET['oc' . $j])) {
   if (isset($_GET['te' . $j])) { // && strstr(str_replace('http://www.rjmprogramming.com.au/','',urldecode($_GET['oc' . $j])),'.')) {
    if (isset($_GET['bw' . $j])) {
      $used='y';
      if ($i == 1) $bits .= appendto('&oc' . $j . '=' . str_replace('+','%20',urlencode($_GET['oc' . $j])) . '&te' . $j . '=' . str_replace('+','%20',urlencode($_GET['te' . $j])) . '&bw' . $j . '=' . str_replace('+','%20',urlencode($_GET['bw' . $j])),'');
    }
   }
   $j++;
  }
  while (isset($_POST['oc' . $j . '_' . $i . '_'])) {
   if (isset($_POST['te' . $j . '_' . $i . '_'])) { // && strstr(str_replace('http://www.rjmprogramming.com.au/','',urldecode($_POST['oc' . $j . '_' . $i . '_'])),'.')) {
    if (isset($_POST['bw' . $j . '_' . $i . '_'])) {
      $used='y';
      $bits .= appendto('&oc' . $j . '=' . str_replace('+','%20',urlencode($_POST['oc' . $j . '_' . $i . '_'])) . '&te' . $j . '=' . str_replace('+','%20',urlencode($_POST['te' . $j . '_' . $i . '_'])) . '&bw' . $j . '=' . str_replace('+','%20',urlencode($_POST['bw' . $j . '_' . $i . '_'])),'_' . $map[$i] . '_');
    }
   }
   $j++;
  }
  while (isset($_GET['oc' . $j . '_' . $i . '_'])) {
   if (isset($_GET['te' . $j . '_' . $i . '_'])) { // && strstr(str_replace('http://www.rjmprogramming.com.au/','',urldecode($_GET['oc' . $j . '_' . $i . '_'])),'.')) {
    if (isset($_GET['bw' . $j . '_' . $i . '_'])) {
      $used='y';
      $bits .= appendto('&oc' . $j . '=' . str_replace('+','%20',urlencode($_GET['oc' . $j . '_' . $i . '_'])) . '&te' . $j . '=' . str_replace('+','%20',urlencode($_GET['te' . $j . '_' . $i . '_'])) . '&bw' . $j . '=' . str_replace('+','%20',urlencode($_GET['bw' . $j . '_' . $i . '_'])),'_' . $map[$i] . '_');
    }
   }
   $j++;
  }
  if ($bits != "") $html = str_replace($subthings[0], $bits, $html);
  }
  }
  $things = explode($exp, $html);
}

if (9 == 8) {

$things = explode($exp, $html);
$j=1;
$bits='';
for ($i=1; $i<=9; $i++) {
  $j=1;
  $bits='';
  $subthings = explode('"', $things[$map[$i]]);
  if ($subthings[0] != "") {
  while (isset($_POST['oc' . $j])) {
   if (isset($_POST['te' . $j])) { // && strstr(str_replace('http://www.rjmprogramming.com.au/','',urldecode($_POST['oc' . $j])),'.')) {
    if (isset($_POST['bw' . $j])) {
      $used='y';
      if ($i == 1) $bits .= '&oc' . $j . '=' . str_replace('+','%20',urlencode($_POST['oc' . $j])) . '&te' . $j . '=' . str_replace('+','%20',urlencode($_POST['te' . $j])) . '&bw' . $j . '=' . str_replace('+','%20',urlencode($_POST['bw' . $j]));
    }
   }
   $j++;
  }
  while (isset($_GET['oc' . $j])) {
   if (isset($_GET['te' . $j])) { // && strstr(str_replace('http://www.rjmprogramming.com.au/','',urldecode($_GET['oc' . $j])),'.')) {
    if (isset($_GET['bw' . $j])) {
      $used='y';
      if ($i == 1) $bits .= '&oc' . $j . '=' . str_replace('+','%20',urlencode($_GET['oc' . $j])) . '&te' . $j . '=' . str_replace('+','%20',urlencode($_GET['te' . $j])) . '&bw' . $j . '=' . str_replace('+','%20',urlencode($_GET['bw' . $j]));
    }
   }
   $j++;
  }
  while (isset($_POST['oc' . $j . '_' . $i . '_'])) {
   if (isset($_POST['te' . $j . '_' . $i . '_'])) { // && strstr(str_replace('http://www.rjmprogramming.com.au/','',urldecode($_POST['oc' . $j . '_' . $i . '_'])),'.')) {
    if (isset($_POST['bw' . $j . '_' . $i . '_'])) {
      $used='y';
      $bits .= '&oc' . $j . '=' . str_replace('+','%20',urlencode($_POST['oc' . $j . '_' . $i . '_'])) . '&te' . $j . '=' . str_replace('+','%20',urlencode($_POST['te' . $j . '_' . $i . '_'])) . '&bw' . $j . '=' . str_replace('+','%20',urlencode($_POST['bw' . $j . '_' . $i . '_']));
    }
   }
   $j++;
  }
  while (isset($_GET['oc' . $j . '_' . $i . '_'])) {
   if (isset($_GET['te' . $j . '_' . $i . '_'])) { // && strstr(str_replace('http://www.rjmprogramming.com.au/','',urldecode($_GET['oc' . $j . '_' . $i . '_'])),'.')) {
    if (isset($_GET['bw' . $j . '_' . $i . '_'])) {
      $used='y';
      $bits .= '&oc' . $j . '=' . str_replace('+','%20',urlencode($_GET['oc' . $j . '_' . $i . '_'])) . '&te' . $j . '=' . str_replace('+','%20',urlencode($_GET['te' . $j . '_' . $i . '_'])) . '&bw' . $j . '=' . str_replace('+','%20',urlencode($_GET['bw' . $j . '_' . $i . '_']));
    }
   }
   $j++;
  }
  if ($bits != "") $html = str_replace($subthings[0], $bits, $html);
  }
  $things = explode($exp, $html);
}

}

//file_put_contents('zmq0q.zm', "0");
if ($savemode && $fname != '') {
  file_put_contents($fname, check_glob($html));
  echo check_glob($html);
} else if ($recallmode) {
//file_put_contents('zmq1q.zm', "1");
  if ($rcmprefix != '') {
//file_put_contents('zmq11q.zm', $rcmprefix);
    $html=str_replace('&theme=', $rcmprefix, $html);
//file_put_contents('zmq111q.html', $html);
//  header('Location: zmq111q.html');
//  exit;
  }
  echo $html;
} else if ($used != "y" && strlen($_SERVER['QUERY_STRING']) > 0) {
//file_put_contents('zmq2q.zm', "2");
  if (str_replace('select=00000000','',$_SERVER['QUERY_STRING']) != $_SERVER['QUERY_STRING']) {
  echo $html;
  } else {
  header('Location: middle_interest.html?' . $_SERVER['QUERY_STRING']);
  }
} else if (strlen($_SERVER['QUERY_STRING']) > 0) {
//file_put_contents('zmq3q.zm', "3");
  echo str_replace('location.search','("' . $_SERVER['QUERY_STRING'] . '")', str_replace('document.URL','("middle_interest.html?' . $_SERVER['QUERY_STRING'] . '")', $html));
} else {
//file_put_contents('zmq4q.zm', "4");
  if ($rcmprefix != '') $html=str_replace('&theme=', $rcmprefix, $html);
  echo check_glob($html);
}
}
?>
