<?php
// butsel.php
// Contents of "justmenu" call of Google Charts web application's iframe (id=iagc) at bottom

$butsel = ""; 
$butsel_buttons = "";
$butsel_selects = "";
$suffix = "";

function getsuffix($ins) {
   global $suffix;
   if ($ins == "") {
    $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
    if (strpos($_SERVER['HTTP_X_REQUESTED_WITH'], "rjmprogramming") !== false && strpos($_SERVER['HTTP_X_REQUESTED_WITH'], "com.") !== false && strpos($_SERVER['HTTP_X_REQUESTED_WITH'], ".au") !== false) {
     $suffix = @file_get_contents("http://www.rjmprogramming.com.au/PHP/webviewemail.php?ask=");
    } else if ((strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile/') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari/') == false)) {
     $suffix = @file_get_contents("http://www.rjmprogramming.com.au/PHP/webviewemail.php?ask=");
    } 
   } else if ($ins == " ") {
     if (strpos($suffix, "?") === false) {
       if (strlen($suffix) > 0 && strlen($_SERVER['QUERY_STRING']) == 0) {
         file_put_contents("aaaaahuh.huh", "?WebView=justmenuWebView" . $suffix);
         return "?WebView=justmenuWebView" . $suffix;
       }
     }
     //file_put_contents("aaaahuh.huh", "?" . $_SERVER['QUERY_STRING'] . $suffix);
   }
   return $suffix;
}

function butsel_buttons() {
   global $butsel, $butsel_buttons, $butsel_selects;
   if ($butsel_buttons != "") {
     if (!file_exists("butsel.buttons")) file_put_contents("butsel.buttons", $butsel_buttons);
     return $butsel_buttons;
   } else if (file_exists("butsel.buttons")) {
     $butsel_buttons = @file_get_contents("butsel.buttons");
     return $butsel_buttons;
   } else {
     $tabdata = explode("tbody", $butsel);
     if (sizeof($tabdata) > 2) {
       $trdata = explode("<tr", $tabdata[1]);
       for ($i=1; $i<(sizeof($trdata) - 1); $i++) {
         $tdata = explode('/PHP/', $trdata[$i]);
         if (sizeof($tdata) > 2) {
          $prenamedata = explode('"', $tdata[1]);
          $namedata = explode('.php', $prenamedata[0]);
          $dnamedata = explode('/', $namedata[0]);
          if (str_replace(" ", "", $butsel_buttons) == "") $butsel_buttons .= '<div align="center" id="butsel_buttons" style="display:none;">';
          $butsel_buttons .= '<input style="font-size:18px;" height=80 type="button" onclick=" window.top.location.href=' . "'" . 'http://www.rjmprogramming.com.au/PHP/' . $namedata[0] . ".php'" . '; " value="' . strtoupper(substr($dnamedata[sizeof($dnamedata) - 1],0,1)) . str_replace("Diagram", "diagram", str_replace("Difference", "diff", str_replace("Line Graph", "lgraph", str_replace(" chart", " Chart", str_replace("_", " ", substr($dnamedata[sizeof($dnamedata) - 1],1)))))) . '"></input>&nbsp;&nbsp;';
         }
       }
     }
     if (str_replace(" ", "", $butsel_buttons) != "") $butsel_buttons .= '<input style="font-size:20px;" height=80 type="button" onclick=" window.top.location.href=' . "'" . 'https://developers.google.com/chart/' . "'" . '; " value="' . "Google Charts information from Google" . '"></input>' . '</div>';
     file_put_contents("butsel.buttons", $butsel_buttons);
   }
   return $butsel_buttons;
}

function butsel_selects() {
   global $butsel, $butsel_buttons, $butsel_selects;
   if ($butsel_selects != "") {
     if (!file_exists("butsel.selects")) file_put_contents("butsel.selects", $butsel_selects);
     return $butsel_selects;
   } else if (file_exists("butsel.selects")) {
     $butsel_selects = @file_get_contents("butsel.selects");
     return $butsel_selects;
   } else {
     $tabdata = explode("tbody", $butsel);
     if (sizeof($tabdata) > 2) {
       $trdata = explode("<tr", $tabdata[1]);
       for ($i=1; $i<(sizeof($trdata) - 1); $i++) {
         $tdata = explode('/PHP/', $trdata[$i]);
         if (sizeof($tdata) > 2) {
          $prenamedata = explode('"', $tdata[1]);
          $namedata = explode('.php', $prenamedata[0]);
          $dnamedata = explode('/', $namedata[0]);
          if (str_replace(" ", "", $butsel_selects) == "") $butsel_selects .= '<div align="center" id="butsel_selects" style="display:none;"><br><br><select style="text-align:center;" id="butselselects" size=33 onchange="  window.top.location.href=this.value; "><option value="#">Please choose Google Chart idea below ...</option>';
          $butsel_selects .= '<option value="http://www.rjmprogramming.com.au/PHP/' . $namedata[0] . '.php"' . '>' . strtoupper(substr($dnamedata[sizeof($dnamedata) - 1],0,1)) . str_replace("Diagram", "diagram", str_replace("Difference", "diff", str_replace("Line Graph", "lgraph", str_replace(" chart", " Chart", str_replace("_", " ", substr($dnamedata[sizeof($dnamedata) - 1],1)))))) . '</option>';
         }
       }
     }
     if (str_replace(" ", "", $butsel_selects) != "") $butsel_selects .= '<option value="https://developers.google.com/chart/">Google Charts information from Google</option>' . '</select></div>';
     file_put_contents("butsel.selects", $butsel_selects);
   }
   return $butsel_selects;
}

if (isset($_GET['clear'])) {
  if (file_exists("but.sel")) unlink("but.sel");
  if (file_exists("butsel.buttons")) unlink("butsel.buttons");
  if (file_exists("butsel.selects")) unlink("butsel.selects");
}

if (file_exists("but.sel")) {
     $butsel = file_get_contents("but.sel");
} else {
     $butsel = @file_get_contents("http://www.rjmprogramming.com.au/wordpress/?p=11696");
     file_put_contents("but.sel", $butsel);
}
getsuffix("");
$preabits=" function lotlater() { var ij=0; var asis=parent.document.getElementsByTagName('a');  if (asis[0] != null) {  for (ij=0; ij<asis.length; ij++) {  asis[ij].style.padding=' 3 3 3 3 '; asis[ij].style.lineHeight='200%';   asis[ij].style.fontSize='18px';  asis[ij].style.border=' 8px solid red'; asis[ij].style.backgroundColor='lightgray';  asis[ij].style.textDecoration='none'; }   } } ";
$abits=" setTimeout(lotlater,2000); ";
echo "<!doctype html><html><head><meta name='viewport' content='width=device-width, initial-scale=1, minimum-scale=0.5, maximum-scale=4, user-scalable=yes' /><meta charset='UTF-8' /><style> input { margin: 4 24 12 12; } </style><script type=\"text/javascript\"> " . $preabits . " function checkdn() {  var xx=''; if (document.URL.indexOf('justmenu') != -1) { var xp=(document.URL + '" . getsuffix(" ") . "').split('?'); var xxp=''; if (xp.length > 1) { xxp='?' + xp[1]; } if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { if (xxp != '') { xx=document.getElementById('butsel_buttons').innerHTML; xx=xx.replace(/.php/g, '.php' + xxp); document.getElementById('butsel_buttons').innerHTML=xx;  } document.getElementById('butsel_buttons').style.display='block';   var pifx=parent.document.getElementById('iagc'); if (pifx == null) {  parent.document.body.style.paddingTop='70px';  } else {   parent.document.body.style.paddingTop='0px';    }  parent.document.body.style.background='-webkit-linear-gradient(top, #FFFF00, #00FFFF)';   parent.document.body.style.background='-moz-linear-gradient(top, #FFFF00, #00FFFF)'; " . $abits . "   } else {   if (xxp != '') { xx=document.getElementById('butsel_selects').innerHTML; xx=xx.replace(/.php/g, '.php' + xxp); document.getElementById('butsel_selects').innerHTML=xx;  } document.getElementById('butsel_selects').style.display='block';  } var pif=parent.document.getElementById('iagc'); if (pif != null) { pif.style.width='600px'; pif.style.height='200px'; parent.document.body.style.paddingTop='20px';  parent.document.body.style.background='-webkit-linear-gradient(top, #FFFF00, #00FFFF)';   parent.document.body.style.background='-moz-linear-gradient(top, #FFFF00, #00FFFF)';    }    }    document.body.style.background='-moz-linear-gradient(top, #FFFF00, #00FFFF)';document.body.style.background='-webkit-linear-gradient(top, #FFFF00, #00FFFF)';  } </script></head><body onload=\" checkdn(); \">\n" . butsel_buttons() . "\n";
echo butsel_selects() . "\n</body></html>";
?>