<?php
// world.php
// RJM Programming
// March, 2016
// Help out world.html with canvas element data email attachments

$isgif = false;
$psubject = '';
$gmtblurb = '';
$pngext = 'png';
$idata = '';
$ismobile = '';
$gmode = '';
$mydurl = '';
$ubits = explode(".htm", $_SERVER['HTTP_REFERER']);
$uubits = explode("/", $ubits[0]);
$lworld = $uubits[-1 + sizeof($uubits)]; 
$okay = 1;
$bigbits;
$atendis = '';
$postsubj = '';
$postfname = '';
$altmydurl = '';
$fflist="";
$subjarr=["", "", "", ""];
$localdt="";

foreach( $_POST as  $name=>$val ) {
  if ($val != "") {
  if ($name != "inline" && substr(($name . "      "),0,6) == "inline" && strpos(urldecode($val), ":") !== false && sizeof(explode(" ", urldecode($val))) <= 5 && trim(urldecode($val)) != "") {
    $localdt=str_replace("`", "+", str_replace("+", " ", str_replace("++", " `", urldecode($val))));
  }
  }
}

foreach( $_GET as  $name=>$val ) {
  if ($val != "") {
  if ($name != "inline" && substr(($name . "      "),0,6) == "inline" && strpos(urldecode($val), ":") !== false && sizeof(explode(" ", urldecode($val))) <= 5 && trim(urldecode($val)) != "") {
    $localdt=str_replace("`", "+", str_replace("+", " ", str_replace("++", " `", urldecode($val))));
  }
  }
}

if (isset($_POST['isgif']) || isset($_GET['isgif'])) {
  if (isset($_GET['isgif'])) {
  if (strlen($_GET['isgif']) > 0) { $isgif = true; } //$pngext = 'gif';
  } else if (isset($_POST['isgif'])) { 
  if (strlen($_POST['isgif']) > 0) { $isgif = true; } //$pngext = 'gif';
  }
}

//// file_put_contents("001.001","");
if (isset($_POST['tdsubj']) || isset($_GET['tdsubj'])) {
  if (isset($_GET['tdsubj'])) {
//// file_put_contents("002.002",explode("~", str_replace("+"," ",urldecode($_GET['tdsubj'])))[0]);
  $psubject = analtoken(explode("~", str_replace("+"," ",urldecode($_GET['tdsubj'])))[0],"");
  if (strpos(str_replace("+"," ",urldecode($_GET['tdsubj'])),"~") !== false) {
//// file_put_contents("003.003",explode("~", str_replace("+"," ",urldecode($_GET['tdsubj'])))[0]);
  $gmtblurb = explode("~", str_replace("+"," ",urldecode($_GET['tdsubj'])))[1];
  }
  } else {
//// file_put_contents("004.004",explode("~", str_replace("+"," ",urldecode($_POST['tdsubj'])))[0]);
  $psubject = analtoken(explode("~", str_replace("+"," ",urldecode($_POST['tdsubj'])))[0],"");
  if (strpos(str_replace("+"," ",urldecode($_POST['tdsubj'])),"~") !== false) {
//// file_put_contents("005.005",explode("~", str_replace("+"," ",urldecode($_GET['tdsubj'])))[0]);
  $gmtblurb = explode("~", str_replace("+"," ",urldecode($_POST['tdsubj'])))[1];
  }
  }
}

if (isset($_POST['mysubject']) && isset($_POST['myfname'])) {
  if (strpos($_POST['mysubject'], ' via ') !== false && strpos(($_POST['mysubject'] . ''), 'animated_gif_slideshow.gif') !== false) {
    sleep(9);
    if (file_exists('../PHP/animegif/' . server_remote_addr() . '.gif')) {
    $altmydurl = @file_get_contents('../PHP/animegif/' . server_remote_addr() . '.gif');
    $postsubjs = explode(' via ', $_POST['mysubject']);
//// file_put_contents("006.006",str_replace(' via ' . $postsubjs[-1 + sizeof($postsubjs)], '', $_POST['mysubject']));
    $postsubj = analtoken(str_replace(' via ' . $postsubjs[-1 + sizeof($postsubjs)], '', $_POST['mysubject']),"");
    $postfname = $_POST['myfname'];
    if (strpos($_POST['myfname'], '.' . $pngext) !== false) {
     $postfname = str_replace('.' . $pngext, '.gif', $_POST['myfname']);
    } else {
     $postfname = $_POST['myfname'];
    }
    $pngext = 'gif';
    } else {
    $postsubjs = explode(' via ', $_POST['mysubject']);
//// file_put_contents("007.007",str_replace(' via ' . $postsubjs[-1 + sizeof($postsubjs)], '', $_POST['mysubject']));
    $postsubj = analtoken(str_replace(' via ' . $postsubjs[-1 + sizeof($postsubjs)], '', $_POST['mysubject']),"");
    $postfname = $_POST['myfname'];
    }
  } else {
//// file_put_contents("008.008",$_POST['mysubject']);
    $postsubj = analtoken($_POST['mysubject'],"");
    $postfname = $_POST['myfname'];
  }
} else if (isset($_GET['mysubject']) && isset($_GET['myfname'])) {
  if (strpos($_GET['mysubject'], ' via ') !== false && strpos(($_GET['mysubject'] . ''), 'animated_gif_slideshow.gif') !== false) {
    sleep(9);
    if (file_exists('../PHP/animegif/' . server_remote_addr() . '.gif')) {
    $altmydurl = @file_get_contents('../PHP/animegif/' . server_remote_addr() . '.gif');
    $postsubjs = explode(' via ', $_GET['mysubject']);
//// file_put_contents("009.009",str_replace(' via ' . $postsubjs[-1 + sizeof($postsubjs)], '', $_GET['mysubject']));
    $postsubj = analtoken(str_replace(' via ' . $postsubjs[-1 + sizeof($postsubjs)], '', $_GET['mysubject']),"");
    $postfname = $_GET['myfname'];
    if (strpos($_GET['myfname'], '.' . $pngext) !== false) {
     $postfname = str_replace('.' . $pngext, '.gif', $_GET['myfname']);
    } else {
     $postfname = $_GET['myfname'];
    }
    $pngext = 'gif';
    } else {
    $postsubjs = explode(' via ', $_GET['mysubject']);
//// file_put_contents("010.010",str_replace(' via ' . $postsubjs[-1 + sizeof($postsubjs)], '', $_GET['mysubject']));
    $postsubj = analtoken(str_replace(' via ' . $postsubjs[-1 + sizeof($postsubjs)], '', $_GET['mysubject']),"");
    $postfname = $_GET['myfname'];
    }
  } else {
//// file_put_contents("011.011",$_GET['mysubject']);
    $postsubj = analtoken($_GET['mysubject'],"");
    $postfname = $_GET['myfname'];
  }
}

function zmail($zris, $zxsis, $ztis, $zhis) {
     global $subjarr, $fflist, $localdt;
     // file_put_contents("091.091","");
     if (strpos($zxsis, "[") === false && strpos($zxsis, "<") === false && $zxsis != "") {
        $zxsis.=" at [date] for [files]";
    // file_put_contents("092.092",$zxsis);
        analtoken($zxsis, "");
     }
    // file_put_contents("093.093",$fflist);
     subjtokenization($fflist, "files");
    // file_put_contents("094.094",$subjarr[0]);
     $zhis=str_replace("<files>", $fflist, str_replace("[files]", $fflist, $zhis));
    // file_put_contents("095.095",$xsis);
       return mail($zris, subjtokenization($zxsis,"subject"), $ztis, $zhis);
}

    
function analtoken($inofinterest, $ifnotblankbody) {
  global $subjarr, $fflist, $localdt;
  $inofinterest=trim($inofinterest);
  if ($ifnotblankbody == "" && $inofinterest != "") {   // subject
    if (strpos(($inofinterest . "~"), "]~") !== false && strpos(($inofinterest . "~"), "[") !== false) {
// file_put_contents("012.012",$inofinterest);
      $subjarr[3]="html";
      if ($localdt != "") {
      $inofinterest=str_replace("[date]", $localdt, $inofinterest);
      } else {
      $inofinterest=str_replace("[date]", date('l jS \of F Y h:i:s A'), $inofinterest);
      }
      if (isset($_SERVER['HTTP_REFERER'])) {
      $inofinterest=str_replace("[httpreferer]", $_SERVER['HTTP_REFERER'], $inofinterest);
      $inofinterest=str_replace("[serveraddr]", $_SERVER['SERVER_ADDR'], $inofinterest);
      $inofinterest=str_replace("[requesttime]", $_SERVER['REQUEST_TIME'], $inofinterest);
      $inofinterest=str_replace("[httpacceptlanguage]", $_SERVER['HTTP_ACCEPT_LANGUAGE'], $inofinterest);
      $inofinterest=str_replace("[httpuseragent]", $_SERVER['HTTP_USER_AGENT'], $inofinterest);
      $inofinterest=str_replace("[remoteaddr]", $_SERVER['REMOTE_ADDR'], $inofinterest);
      $inofinterest=str_replace("[requesturi]", $_SERVER['REQUEST_URI'], $inofinterest);
      if (isset($_SERVER['PATH_INFO'])) {
      $inofinterest=str_replace("[pathinfo]", $_SERVER['PATH_INFO'], $inofinterest);
      }
      }
      $inofinterest=str_replace("[lf]", "\n", $inofinterest);
      $inofinterest=str_replace("[crlf]", "\r\n", $inofinterest);
      $huharr=explode("[", $inofinterest);
// file_put_contents("013.013",$inofinterest);
      // $proposedih=$huharr[0];
      if (strpos(($inofinterest . "~"), "]") !== false && strpos(($inofinterest . "~"), "[") !== false) {
// file_put_contents("014.014",$inofinterest);
        for ($ih=1; $ih<sizeof($huharr); $ih++) {
          $thisone=explode("]", $huharr[$ih])[0];
          //if ($huharr[$ih] != ($thisone . "]")) {
          //  $proposedih.=explode(($thisone . "]"), $huharr[$ih])[1];
          //}
          if (strpos($thisone, " ") === false) {
            if (isset($_POST[$thisone])) {
              $inofinterest=str_replace("[" . $thisone . "]", str_replace("+", " ", urldecode($_POST[$thisone])), $inofinterest);
            } else if (isset($_GET[$thisone])) {
              $inofinterest=str_replace("[" . $thisone . "]", str_replace("+", " ", urldecode($_GET[$thisone])), $inofinterest);
            }
          }
        }
      }
      if (strpos(($inofinterest . "~"), "]") !== false && strpos(($inofinterest . "~"), "[") !== false) {
// file_put_contents("015.015",$inofinterest);
        $huharr=explode("[", $inofinterest);
        $proposedih=$huharr[0];
        for ($ih=1; $ih<sizeof($huharr); $ih++) {
          $thisone=explode("]", $huharr[$ih])[0];
          if ($huharr[$ih] != ($thisone . "]")) {
            $proposedih.=explode(($thisone . "]"), $huharr[$ih])[1];
          }
        }
// file_put_contents("025.025",$inofinterest);
        $subjarr[0]=str_replace("\n", " ", str_replace("\r\n", " ", $proposedih));
        if (substr($inofinterest, 0, 1) == "[") {
// file_put_contents("026.026",$inofinterest);
          $subjarr[1]=str_replace("\n", "<br>", str_replace("[", "<", str_replace("]", ">", $inofinterest)));
        } else {
        if (strpos($inofinterest, "\n") !== false) {
// file_put_contents("027.027",$inofinterest);
          $huharr=explode("\n", $inofinterest);
          $subjarr[1]="<html><body><textarea style='width:90%;font-size:28px;font-weight:bold;border:1px solid transparent;background-color:#f0f0f0;' rows=" . (1 + sizeof($huharr)) . ">" . $inofinterest . "</textarea></body></html>";
        } else {
          $subjarr[1]="<html><body><h1>" . $inofinterest . "</h1></body></html>";
// file_put_contents("028.028",$subjarr[1]);
        }
        }
      } else {
// file_put_contents("016.016",$inofinterest);
        $subjarr[0]=str_replace("\n", " ", str_replace("\r\n", " ", $inofinterest));
        if (strpos($inofinterest, "\n") !== false) {
          $huharr=explode("\n", $inofinterest);
          $subjarr[1]="<html><body><textarea style='width:90%;font-size:28px;font-weight:bold;border:1px solid transparent;background-color:#f0f0f0;' rows=" . (1 + sizeof($huharr)) . ">" . $inofinterest . "</textarea></body></html>";
        } else {
          $subjarr[1]="<html><body><h1>" . $inofinterest . "</h1></body></html>";
        }
      }
    }
  } else if ($inofinterest != "") {   // body
    $ifnotblankbody=trim($ifnotblankbody);
  }
// file_put_contents("017.017",$inofinterest);
  return $inofinterest;
}
    
function subjtokenization($inthing, $inmode) {
  global $subjarr, $fflist;
  if ($inmode == "subject") {
    if ($subjarr[0] != "") {
      if ($fflist == "") { return $subjarr[0];   }
      return str_replace("<files>", $fflist, str_replace("[files]", $fflist, str_replace("<file>", $fflist, str_replace("[file]", $fflist, $subjarr[0]))));
    } else if (strpos($inthing, "[") !== false) {
      if ($fflist == "") { return str_replace("[date]", date('l jS \of F Y h:i:s A'), $inthing);   }
      return str_replace("<files>", $fflist, str_replace("[files]", $fflist, str_replace("<file>", $fflist, str_replace("[file]", $fflist, str_replace("[date]", date('l jS \of F Y h:i:s A'), $inthing)))));
    }
    return str_replace("<files>", $fflist, str_replace("[files]", $fflist, $inthing));
  } else if ($inmode == "bodysubject") {
// file_put_contents("036.036","");
    if ($subjarr[1] != "") {
// file_put_contents("037.037",$subjarr[1]);
      if (substr($subjarr[1], 0, 1) == "<" && strpos($subjarr[1], "</h1>") !== false) {
        $subjarr[1]=str_replace("</h1>", "</h1><h3>" . str_replace("\n", "<br>", $inthing) . "</h3>", $subjarr[1]);
      } else if (substr($subjarr[1], 0, 1) == "<" && strpos($subjarr[1], "</body>") !== false) {
        $subjarr[1]=str_replace("</body>", "<h3>" . str_replace("\n", "<br>", $inthing) . "</h3></body>", $subjarr[1]);
      }
      if ($fflist == "" || 1 == 1) { return $subjarr[1]; }
      return str_replace("<files>", $fflist, str_replace("[files]", $fflist, $subjarr[1]));
    }
  } else if ($inmode == "body") {
    if ($subjarr[2] != "") {
      return $subjarr[2];
    }
  } else if ($inmode == "contenttype") {
    if ($subjarr[3] != "") {
      return $subjarr[3];
    }
  } else if ($inmode == "file") {
// file_put_contents("057.057",$subjarr[1]);
    $subjarr[1]=str_replace("<file>", $inthing, str_replace("[file]", $inthing, $subjarr[1]));
// file_put_contents("058.058",$subjarr[1]);
  } else if ($inmode == "files" && $inthing != "") {
// file_put_contents("067.067",$subjarr[0]);
    $subjarr[0]=str_replace("<files>", $inthing, str_replace("[files]", $inthing, $subjarr[0]));
    $subjarr[1]=str_replace("<files>", $inthing, str_replace("[files]", $inthing, $subjarr[1]));
    if ($subjarr[0] != "" && $subjarr[1] != "") {
      if (strpos(preg_replace('/\s+/', ' ', str_replace("<br>","",str_replace("\n","",$subjarr[1]))), preg_replace('/\s+/', ' ', str_replace("<br>","",str_replace("\n","",$subjarr[0])))) !== false) {
        $subjarr[0].=explode("<", explode(preg_replace('/\s+/', ' ', str_replace("<br>","",str_replace("\n","",$subjarr[0]))), preg_replace('/\s+/', ' ', str_replace("<br>","",str_replace("\n","",$subjarr[1]))))[1])[0];
      }
    }
  }
  return $inthing;
}

function server_remote_addr() {
    $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 $rma;
}

function ourpremail($ris, $ssis, $tis, $his) {
    global $okay, $atendis, $idata, $pngext, $postfname, $postfname, $altmydurl, $fflist, $subjarr;
    $imdata = "";
    $otherccs="";
    $xris=""; //$ris;
    $spareris="";
    $toaststyling="<style> .custom-alert { display: inline-block; visibility: visible; background-color: #666; color: #fff; text-align: enter; margin: 5% auto; padding: 12px 48px; } </style> ";
    $xxris=explode(",", $ris);
    for ($iy=0; $iy<sizeof($xxris); $iy++) {
      $xris.="<a target=_blank href=mailto:" . $xxris[$iy] . " title=EmailClient>" . $xxris[$iy] . "</a>";
    }
    if (isset($_GET['cc'])) {
      $xxris=explode(",", urldecode($_GET['cc']));
      $spareris="";
      for ($iy=0; $iy<sizeof($xxris); $iy++) {
       $spareris.="<a target=_blank href=mailto:" . $xxris[$iy] . " title=EmailClient>" . $xxris[$iy] . "</a>";
      }
      if ($_GET['cc'] != "") $otherccs.="<br>CC: " . $spareris;
    } else if (isset($_POST['cc'])) {
      $xxris=explode(",", urldecode($_POST['cc']));
      $spareris="";
      for ($iy=0; $iy<sizeof($xxris); $iy++) {
       $spareris.="<a target=_blank href=mailto:" . $xxris[$iy] . " title=EmailClient>" . $xxris[$iy] . "</a>";
      }
      if ($_POST['cc'] != "") $otherccs.="<br>CC: " . $spareris;
    }
    if (isset($_GET['bcc'])) {
      $xxris=explode(",", urldecode($_GET['bcc']));
      $spareris="";
      for ($iy=0; $iy<sizeof($xxris); $iy++) {
       $spareris.="<a target=_blank href=mailto:" . $xxris[$iy] . " title=EmailClient>" . $xxris[$iy] . "</a>";
      }
      if ($_GET['bcc'] != "") $otherccs.="<br>BCC: " . $spareris;
    } else if (isset($_POST['bcc'])) {
      $xxris=explode(",", urldecode($_POST['bcc']));
      $spareris="";
      for ($iy=0; $iy<sizeof($xxris); $iy++) {
       $spareris.="<a target=_blank href=mailto:" . $xxris[$iy] . " title=EmailClient>" . $xxris[$iy] . "</a>";
      }
      if ($_POST['bcc'] != "") $otherccs.="<br>BCC: " . $spareris;
    }
    $hgt="200";
    $xsis = $ssis;
    $altwin='';
    if (1 == 1 && $idata != "") {
      if ($altmydurl != '') {
      $imdata="<img src=//www.rjmprogramming.com.au/PHP/animegif/" . server_remote_addr() . ".gif></img>";
      } else {
      $imdata="<img src=data:image/" . $pngext . ";base64," . base64_encode($idata) . "></img>";
      }
      $hgt="480";
    }
    try {
       //file_put_contents("aaaaa.00aaa", $ris . " " . $xsis);
       //mail("rmetcalfe15@gmail.com", $xsis, "My Body", $his);
       zmail($ris, $xsis, $tis, $his);
       $altwin = "<!doctype html><html><head>" . $toaststyling . "<script type='text/javascript'> var wo=null; function andthenx() { if (wo) { wo.close(); } }  </script></head><body onload=\" wo=window.open('','_blank','status=no,toolbar=no,menubar=yes,left=10,top=300,width=1350,height=" . $hgt . "'); wo.document.write('" . $toaststyling . "<div class=custom-alert>Email sent successfully <br>To: " . $xris . $otherccs . "<br>Subject: " . $ssis . "</div><br>" . $imdata . "<br>'); setTimeout(andthenx,7000); \"></body></html>";
    } catch (Exception $merr) {
      $okay = 0;
      if (file_exists(dirname(__FILE__) . "/mail.prob")) {
        file_put_contents(dirname(__FILE__) . "/mail.prob", file_get_contents(dirname(__FILE__) . "/mail.prob") . "\n\n" . date('l jS \of F Y h:i:s A') . " ... " . $merr->getMessage());
        $altwin = "<!doctype html><html><head><script type='text/javascript'> var wo=null; function andthenx() { if (wo) { wo.close(); } }  </script></head><body onload=\" wo=window.open('','_blank','status=no,toolbar=no,menubar=yes,left=100,top=100,width=750,height=200'); wo.document.write('<p>" . $merr->getMessage() . " sending to <br>" . $ris . $otherccs . "</p>'); setTimeout(andthenx,7000);  \"></body></html>";
      } else {
        file_put_contents(dirname(__FILE__) . "/mail.prob", date('l jS \of F Y h:i:s A') . " ... " . $merr->getMessage());
        $altwin = "<!doctype html><html><head><script type='text/javascript'> var wo=null; function andthenx() { if (wo) { wo.close(); } }  </script></head><body onload=\" wo=window.open('','_blank','status=no,toolbar=no,menubar=yes,left=100,top=100,width=750,height=200'); wo.document.write('<p>" . $merr->getMessage() . " sending to <br>" . $ris . $otherccs . "</p>'); setTimeout(andthenx,7000);  \"></body></html>";
      }
    }
    if ($atendis != "") {
      echo $atendis;
      $atendis='';
      exit;
    } else if ($altwin != "") {
      echo $altwin;
      $altwin='';
      exit;
    }
}

function issetgetaudiodata($which) {
    global $bigbits;
    if (isset($_POST[$which])) {
      return true;
    } else if (sizeof($bigbits) == 2) {
                  if (strpos($bigbits[0], $which . "=") !== false) {
                    return true;
                  }
    }
    return false;
}

function getaudiodata($which) {
    global $bigbits;
    if (isset($_POST[$which])) {
      return $_POST[$which];
    } else if (sizeof($bigbits) == 2) {
                  if (strpos($bigbits[0], $which . "=") !== false) {
                    $xxx=explode($which . "=", $bigbits[0]);
                    $yyy=explode("&", $xxx[1]);
                    return $yyy[0];
                  }
    }
    return "";
}

function send_email($tem, $mysubject, $mybody) {
    global $idata, $bigbits, $atendis, $pngext, $postfname, $postfname, $altmydurl, $isgif, $psubject, $gmtblurb, $fflist, $subjarr;
    if ($psubject != "") { $mysubject=$psubject; }
    $aext = ".wav";
    $cno = 0;
    $mobilewav = "";
    $pref="";
    $defone = ""; //"Please see or download image (first) before any download and double clicking of image clickable and applicable web application below:";
    $eol = PHP_EOL;
    if (issetgetaudiodata('mapclick1') && issetgetaudiodata('mapcoords1') && issetgetaudiodata('mapaudio1')) {
     if (urldecode(getaudiodata('mapcoords1')) != "") {
       $cfound = 0;
       $cno = 1;
       while ((issetgetaudiodata('mapclick' . $cno) || issetgetaudiodata('mapaudio' . $cno)) && issetgetaudiodata('mapcoords' . $cno)) {
                if (issetgetaudiodata('mapclick' . $cno)) {
                if (urldecode(getaudiodata('mapclick' . $cno)) != "" && urldecode(getaudiodata('mapcoords' . $cno)) != "") {
                  $cfound = 1;
                  if ($defone == "") {
                    $defone = $pref . "Please see or download image (first) before any download and double clicking of image clickable and applicable web application below ... please note mobile web email clients are preferred to mobile email clients:";
                  } else if (strpos($defone, " audio") !== false) {
                    $defone = $pref . "Please see or download image (first) and audios (second) before any download and double clicking of image clickable and applicable web application below ... please note mobile web email clients are preferred to mobile email clients:";
                  } else {
                    $defone = $pref . "Please see or download image (first) before any download and double clicking of image clickable and applicable web application below ... please note mobile web email clients are preferred to mobile email clients:";
                  }
                }
                }
                if (issetgetaudiodata('mapaudio' . $cno)) {
                if (urldecode(getaudiodata('mapaudio' . $cno)) != "" && urldecode(getaudiodata('mapcoords' . $cno)) != "") {
                  $cfound = 1;
                  if ($defone == "") {
                    $defone = $pref . "Please see or download audio (first) before any download and double clicking of image clickable and applicable web application below ... please note mobile web email clients are preferred to mobile email clients:";
                  } else if (strpos($defone, "download image") !== false) {
                    $defone = $pref . "Please see or download image (first) and audios (second) before any download and double clicking of image clickable and applicable web application below ... please note mobile web email clients are preferred to mobile email clients:";
                  } else {
                    $defone = $pref . "Please see or download audios (first) before any download and double clicking of image clickable and applicable web application below ... please note mobile web email clients are preferred to mobile email clients:";
                  }
                }
                } else if (sizeof($bigbits) == 2) {
                  if (strpos($bigbits[0], "mapaudio") !== false) {
                    $pref = ""; //"huh ";
                    $defone = $pref . $defone;
                  }
                }
                $cno++;
       }
       $cno = $cfound;
     }
    } else if (issetgetaudiodata('mapclick1') && issetgetaudiodata('mapcoords1')) {
     //if (urldecode(getaudiodata('mapclick1') != "" && urldecode(getaudiodata('mapcoords1') != "") {
     if (urldecode(getaudiodata('mapcoords1')) != "") {
       $cfound = 0;
       $cno = 1;
       while (issetgetaudiodata('mapclick' . $cno) && issetgetaudiodata('mapcoords' . $cno)) {
                if (urldecode(getaudiodata('mapclick' . $cno)) != "" && urldecode(getaudiodata('mapcoords' . $cno)) != "") {
                  $cfound = 1;
                }
                $cno++;
       }
       $cno = $cfound;
     }
    }

    if (strpos($tem, ",") !== false) {
        $hs = explode(",", $tem);
        for ($ihs=0; $ihs<sizeof($hs); $ihs++) {
           if (strpos($hs[$ihs], "@") !== false) {
             send_email($hs[$ihs], $mysubject, $mybody);
           } 
        }
    } else {
        if (isset($_POST['from'])) {
        if ($_POST['from'] != '') {
        $headers = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
        $headers .= 'Reply-To: ' . urldecode($_POST['from']) . $eol;
        } else {
        $headers = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
        $headers .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
        }
        } else {
        $headers = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
        $headers .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
        }
        if (isset($_POST['cc'])) {
        if ($_POST['CC'] != '') {
        $headers .= 'CC: ' . urldecode($_POST['cc']) . $eol;
        }
        }
        if (isset($_POST['bcc'])) {
        if ($_POST['BCC'] != '') {
        $headers .= 'BCC: ' . urldecode($_POST['bcc']) . $eol;
        }
        }
                   //     'X-Mailer: PHP/' . phpversion();
        $contents = "";
        if ($idata != "") {
          $contents = $idata;
          if (strpos('~' . $mybody, '~http') === false && strpos($mybody, '/') === false) {
            if (file_exists($mybody)) unlink($mybody);
            $mybody='http://www.rjmprogramming.com.au/HTMLCSS/' . $mybody;
          }
        } else if (strpos('~' . $mybody, '~http') === false && strpos($mybody, '/') === false) {
          if (file_exists($mybody)) {
            $mybodys='http://www.rjmprogramming.com.au/HTMLCSS/' . $mybody;
            $contents=@file_get_contents($mybody);
            unlink($mybody);
                        $mybody=$mybodys;
            $idata = $contents;
          }
        }
        if (strpos('~' . $mybody, '~http') !== false || $contents != "") {
          if ($contents == "") {
            $contents = @file_get_contents($mybody);
          }
          if ($contents != '') {

    		date_default_timezone_set('Australia/Perth');

            //$mysubject .= ' ... ' . $mybody;
    		$fs = explode("/", $mybody);
    		if ($altmydurl != '') {
    		$filename = str_replace('.png','.gif',$fs[-1 + sizeof($fs)]);
    		$content = chunk_split(base64_encode($altmydurl));
    		} else {
    		$filename = $fs[-1 + sizeof($fs)];
    		if ($isgif || strpos($filename, ".png") !== false && strpos($contents, "data:image/gif;base64,") !== false) {
    		  $filename=str_replace(".png",".gif",$filename);
    		} 
    		$content = chunk_split(base64_encode($contents));
    		}
    		//$uid = md5(uniqid(time()));

    		// a random hash will be necessary to send mixed content
    		$separator = md5(time());

    		$headers .= "MIME-Version: 1.0" . $eol;
    		$headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol . $eol;
    		$headers .= "Content-Transfer-Encoding: 7bit" . $eol;
    		$headers .= "This is a MIME encoded message." . $eol . $eol;

    		// message
    		$headers .= "--" . $separator . $eol;
    		$headers .= "Content-Type: text/" . subjtokenization("plain", "contenttype") . "; charset=\"iso-8859-1\"" . $eol;
    		$headers .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;

			if ($cno != 0) {
			  // file_put_contents("046.046", $defone);
    		  $headers .= subjtokenization($defone, "bodysubject") . $eol . $eol;
    		} else if ($gmtblurb != "") { 
			  // file_put_contents("047.047", $defone);
    		  $headers .= subjtokenization("Please see attached " . $gmtblurb . " image below:", "bodysubject") . $eol . $eol;
    		} else {
			  // file_put_contents("048.048", $defone);
    		  $headers .= subjtokenization("Please see attached image below:", "bodysubject") . $eol . $eol;
    		}
            //ourpremail($tem, $mysubject, "", $headers . "--" . $separator . "--");

    		// attachment
    		$headers .= "--" . $separator . $eol;
    		$headers .= "Content-Type: application/octet-stream; name=\"" . $filename . "\"" . $eol;
    		$headers .= "Content-Transfer-Encoding: base64" . $eol;
                if ($fflist == "") {
                  $fflist=$filename;
                } else {
                  $fflist.="," . $filename;
                }
    		$headers .= "Content-Disposition: attachment;filename=\"" . subjtokenization($filename,"file") . "\"" . $eol;
    		$headers .= $content . $eol . $eol;
    		
			if ($cno == 0) {
    		  $headers .= "--" . $separator . "--";
			} else {
			  $origcno = $cno;
    		  $headers .= "--" . $separator . $eol; //"--";
    		  $befdots = explode(".", $filename);


              while (issetgetaudiodata('mapcoords' . $cno) && issetgetaudiodata('mapaudio' . $cno)) {  // allow for audio
                if (urldecode(getaudiodata('mapaudio' . $cno)) != "" && urldecode(getaudiodata('mapcoords' . $cno)) != "") {
                 $aext = ".wav";
                 if (issetgetaudiodata('mapext' . $cno)) {
                   if (getaudiodata('mapext' . $cno) != "") $aext=urldecode(getaudiodata('mapext' . $cno));
                 }
                 $mobilewav .= "<br>";
                 //$mobilewav .= "<audio id='au" . $cno . "' controls='controls' autobuffer='autobuffer' autoplay='false'> ";
                 $ais="audio";
                 $bigais="";
                 if (issetgetaudiodata('maptype' . $cno)) {
                   if (str_replace("img","",urldecode(getaudiodata('maptype' . $cno))) != "") {
                     $bigais=urldecode(getaudiodata('maptype' . $cno));
                     $bs=explode("/",$bigais);
                     $ais=$bs[0];
                   } else {
                     $bigais=$ais . '/' . strtolower(str_replace(".","",$aext));
                   }
                 }
                 $mobilewav .= "<" . $ais . " id='au" . $cno . "' controls='controls' autobuffer='autobuffer'> ";
                 if (strpos(urldecode(getaudiodata('mapaudio' . $cno)), ";base64,") !== false) {
                 if (strpos(urldecode(getaudiodata('mapaudio' . $cno)), "data:;base64,") !== false) {
                 $mobilewav .= '    <source id="sc' . $cno . '" src="data:' . $bigais . substr(urldecode(getaudiodata('mapaudio' . $cno)),5) . '" /> ';
                 } else {
                 $mobilewav .= '    <source id="sc' . $cno . '" src="' . urldecode(getaudiodata('mapaudio' . $cno)) . '" /> ';
                 }
                 } else {
                 $mobilewav .= '    <source id="sc' . $cno . '" src="data:audio/x-wav;base64,' . getaudiodata('mapaudio' . $cno) . '" /> ';
                 }
                 $mobilewav .= "</" . $ais . "> ";
                 $mobilewav .= "<br>";
    		     $content = chunk_split(getaudiodata('mapaudio' . $cno));
    		     $fwav=$befdots[0] . "_" . $cno . $aext; //".wav";
    		     $headers .= "Content-Type: application/octet-stream; name=\"" . $fwav . "\"" . $eol;
    		     $headers .= "Content-Transfer-Encoding: base64" . $eol;
                if ($fflist == "") {
                  $fflist=$fwav;
                } else {
                  $fflist.="," . $fwav;
                }
    		     $headers .= "Content-Disposition: attachment;filename=\"" . subjtokenization($fwav,"file") . "\"" . $eol;
    		     $headers .= $content . $eol . $eol;
    		     $headers .= "--" . $separator . $eol; //"--";
                }
                $cno++;
			  }
              $cno = $origcno;

    		  $somehtml = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
    		  $somehtml .= '<html>';
    		  $somehtml .= '<head>';
    		  $somehtml .= '<title>Web Application for Clickable ' . $filename . '</title>';
    		  $somehtml .= '<body>';
    		  //$somehtml .= '<img style="zoom: 50%;" src="' . $filename . '" usemap="#' . str_replace(".","",str_replace("_","",str_replace("-","",$filename)))  . '" width="1692" height="1133" alt="click map" border="0" />';
    		  $somehtml .= '<img style="zoom: 50%;" src="' . $filename . '" usemap="#' . str_replace(".","",str_replace("_","",str_replace("-","",$filename)))  . '" alt="click map" border="0" />';
    		  $somehtml .= '<map id="' . str_replace(".","",str_replace("_","",str_replace("-","",$filename))) . '" name="' . str_replace(".","",str_replace("_","",str_replace("-","",$filename))) . '">';
    		  $somehtml .= '<area shape="default" nohref alt="" />';
    		  $somehtml .= '</map><div id="audiostuff"></div>';
    		  $somehtml .= '</body>';
    		  $somehtml .= '</html>';

              if (issetgetaudiodata('mapclick1') && issetgetaudiodata('mapcoords1') && issetgetaudiodata('mapaudio1')) {
              while (issetgetaudiodata('mapclick' . $cno) && issetgetaudiodata('mapcoords' . $cno) && issetgetaudiodata('mapaudio' . $cno)) {
                if (urldecode(getaudiodata('mapclick' . $cno)) != "" && urldecode(getaudiodata('mapaudio' . $cno)) == "" && urldecode(getaudiodata('mapcoords' . $cno)) != "") {
                 $somehtml = str_replace('<area shape', '<area shape="rect" alt="Navigate ' . $cno . '" title="Navigate ' . $cno . ' to ' . urldecode(getaudiodata('mapclick' . $cno)) . '" coords="' . urldecode(getaudiodata('mapcoords' . $cno)) . '" href="' . urldecode(getaudiodata('mapclick' . $cno)) . '" target="_blank" />' . '<area shape', $somehtml);
                } else if (urldecode(getaudiodata('mapclick' . $cno)) != "" && urldecode(getaudiodata('mapaudio' . $cno)) != "" && urldecode(getaudiodata('mapcoords' . $cno)) != "") {
                 $somehtml = str_replace('<area shape', '<area shape="rect" alt="Listen and Navigate ' . $cno . '" title="Listen ' . ' to ' . $befdots[0] . '_' . $cno . $aext . ' and Navigate ' . $cno . ' to ' . urldecode(getaudiodata('mapclick' . $cno)) . '" coords="' . urldecode(getaudiodata('mapcoords' . $cno)) . '" href="' . urldecode(getaudiodata('mapclick' . $cno)) . '" target="_blank" style="  display:block; border:3px solid pink; " onclick=" var auis=document.getElementById(' . "'" . "au" . $cno . "'" . '); if (auis != null) { auis.play(); } else { var px=document.URL.replace(' . "'" . '(1)' . "','" . '' . "'" . ').replace(' . "'" . '(2)' . "','" . '' . "'" . ').replace(' . "'" . '(3)' . "','" . '' . "'" . ').replace(' . "'" . '(4)' . "','" . '' . "'" . ').replace(' . "'" . '(5)' . "','" . '' . "'" . ').replace(' . "'mobile_" . $befdots[0] . '.htm' . "','" . $befdots[0] . '_' . $cno . $aext . '' . "'" . ').replace(' . "'" . $befdots[0] . '.html' . "','" . $befdots[0] . '_' . $cno . $aext . '' . "'" . '); window.open(px' . ",'_blank','top=50,left=50,height=100,width=300'" . ");" . ' } " />' . '<area shape', $somehtml);
                } else if (urldecode(getaudiodata('mapclick' . $cno)) == "" && urldecode(issetgetaudiodata('mapaudio' . $cno)) != "" && urldecode(getaudiodata('mapcoords' . $cno)) != "") {
                 $somehtml = str_replace('<area shape', '<area shape="rect" alt="Listen ' . $cno . '" title="Listen ' . $cno . ' to ' . $befdots[0] . '_' . $cno . $aext . '' . '" coords="' . urldecode(getaudiodata('mapcoords' . $cno)) . '" href="#" target="_blank" style=" display:block; border:2px solid yellow; " onclick=" var auis=document.getElementById(' . "'" . "au" . $cno . "'" . '); if (auis != null) { auis.play(); } else {  var px=document.URL.replace(' . "'" . '(1)' . "','" . '' . "'" . ').replace(' . "'" . '(2)' . "','" . '' . "'" . ').replace(' . "'" . '(3)' . "','" . '' . "'" . ').replace(' . "'" . '(4)' . "','" . '' . "'" . ').replace(' . "'" . '(5)' . "','" . '' . "'" . ').replace(' . "'mobile_" . $befdots[0] . '.htm' . "','" . $befdots[0] . '_' . $cno . $aext . '' . "'" . ').replace(' . "'" . $befdots[0] . '.html' . "','" . $befdots[0] . '_' . $cno . $aext . '' . "'" . '); window.open(px' . ",'_blank','top=50,left=50,height=100,width=300'" . ");" . ' } " />' . '<area shape', $somehtml);
                }
                $cno++;
			  }
              } else {
              while (issetgetaudiodata('mapclick' . $cno) && issetgetaudiodata('mapcoords' . $cno)) {
                if (urldecode(getaudiodata('mapclick' . $cno)) != "" && urldecode(getaudiodata('mapcoords' . $cno)) != "") {
                 $somehtml = str_replace('<area shape', '<area shape="rect" alt="Navigate ' . $cno . '" title="Navigate ' . $cno . ' to ' . urldecode(getaudiodata('mapclick' . $cno)) . '" coords="' . urldecode(getaudiodata('mapcoords' . $cno)) . '" href="' . urldecode(getaudiodata('mapclick' . $cno)) . '" target="_blank" />' . '<area shape', $somehtml);
                }
                $cno++;
			  }
			  }

    		  $content=chunk_split(base64_encode($somehtml));
    		  //$filename=$befdots[0] . ".html";
    		  $headers .= "Content-Type: application/octet-stream; name=\"" . $befdots[0] . ".html" . "\"" . $eol;
    		  $headers .= "Content-Transfer-Encoding: base64" . $eol;
    		  $headers .= "Content-Disposition: attachment;filename=\"" . $befdots[0] . ".html" . "\"" . $eol;
    		  $headers .= $content . $eol . $eol;
    		  if ('domobile' == 'domobile') {
    		    $headers .= "--" . $separator . $eol; //"--";
    		    $content=chunk_split(base64_encode(str_replace('style="zoom: 50%;" src="' . $filename,  'style="zoom: 50%;" src="data:image/' . $pngext . ';base64,' . base64_encode($contents), str_replace("</body>", $mobilewav . "</body>", $somehtml))));
    		    $filename="mobile_" . $befdots[0] . ".htm";
    		    $headers .= "Content-Type: application/octet-stream; name=\"" . $filename . "\"" . $eol;
    		    $headers .= "Content-Transfer-Encoding: base64" . $eol;
                if ($fflist == "") {
                  $fflist=$filename;
                } else {
                  $fflist.="," . $filename;
                }
    		    $headers .= "Content-Disposition: attachment;filename=\"" . subjtokenization($filename,"file") . "\"" . $eol;
    		    $headers .= $content . $eol . $eol;
    		  }  
    		  $headers .= "--" . $separator . "--";
    		}
    		
    		//file_put_contents("aaa.aaa", $filename);
            
            ourpremail($tem, $mysubject, "", $headers);
          }
        } 
        if ($contents == '') {    // on fail
    		
    		//file_put_contents("aaa.aaa", "fail");
    		
          ourpremail($tem, $mysubject, $mybody, $headers);
        }
    }
    return "";
}

  if (isset($_GET['lookfor'])) {  // audio content
  if (strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
            while (!file_exists("../MarkItUp/html/audio/audio" . $_GET['lookfor'] . "_" . str_replace(":","",str_replace(".","",server_remote_addr())) . ".wav")) {
              sleep(5);
            }
            //sleep(2);
            $audioc = file_get_contents("../MarkItUp/html/audio/audio" . $_GET['lookfor'] . "_" . str_replace(":","",str_replace(".","",server_remote_addr())) . ".wav");
            unlink("../MarkItUp/html/audio/audio" . $_GET['lookfor'] . "_" . str_replace(":","",str_replace(".","",server_remote_addr())) . ".wav");
            echo "<html><head><sc" . "ript type='text/javascript'> parent.document.getElementById('mapaudio" . $_GET['lookfor'] . "').value='" . base64_encode($audioc) . "'; parent.document.getElementById('mapxaudio" . $_GET['lookfor'] . "').value='" . base64_encode($audioc) . "';  </sc" . "ript></head><body></body></html>";
  }
            exit;
  } else {  // email work
  
            if ($altmydurl != "") {
    		 $mydurl = $altmydurl;
    		 $idata = $mydurl;
            } else {
            $bigbits = explode("mydurl=", file_get_contents('php://input'));
    		if (sizeof($bigbits) == 2) { 
    		 //if (strlen($bigbits[1]) < 35) {
             //  sleep(13);
             //  $bigbits = explode("&mydurl=", file_get_contents('php://input'));
    		 //}
             //$putfp = fopen('php://input', 'r');
             //$putdata = '';
             //while ($data = fread($putfp, 1024)) {
             // $putdata .= $data;
             //}
             //fclose($putfp);
             //$bigbits[1]=$putdata;
    		 $mydurl = urldecode($bigbits[1]);
    		 //file_put_contents("aaaaa.aaaaa", $mydurl);
    		 if (isset($_POST['mydurl'])) {
    		   if (strlen(urldecode($_POST['mydurl'])) > strlen($mydurl)) {
    		     $mydurl=urldecode($_POST['mydurl']);
    		   }
    		 }
             $idata = base64_decode(explode("&from=",$mydurl)[0]);
    		}
    		}


if (isset($_GET['mode']) || isset($_POST['mode']) || isset($_POST['ismobile'])) {
    		//file_put_contents("aaa.aaa", "a.a");
  if (isset($_POST['ismobile'])) {
    $gmode .= " ";
    $ismobile = $_POST['ismobile'];
    if (!isset($_POST['mydurl']) && $mydurl == '') { // && isset($_POST['myfname'])) {
            if ($altmydurl != "") {
    		 $mydurl = $altmydurl;
    		 $idata = $mydurl;
            } else {
            $bigbits = explode("mydurl=", file_get_contents('php://input'));
    		if (sizeof($bigbits) == 2) { 
    		 $mydurl = urldecode($bigbits[1]);
    		 //file_put_contents("aaaa.aaaa", $mydurl);
    		 if (isset($_POST['mydurl'])) {
    		   if (strlen(urldecode($_POST['mydurl'])) > strlen($mydurl)) {
    		     $mydurl=urldecode($_POST['mydurl']);
    		   }
    		 }
             $idata = base64_decode(explode("&from=",$mydurl)[0]);
    		}
    		}
    }
  }
  if (isset($_GET['mode'])) $gmode .= $_GET['mode'];
  if (isset($_POST['mode'])) $gmode .= $_POST['mode'];
       //file_put_contents("aaaaa.0aaa", $lworld . " " . $postfname);
  if (strlen(str_replace("*feedback_", "", ("*" . $postfname))) != strlen(("*" . $postfname))) {
   $tem = urldecode($_POST['to']);
       //file_put_contents("aaaaa.02aaa", $lworld . " " . $postfname);
   if (strlen(str_replace("." . $pngext . "*", "", ($postfname . "*"))) != strlen(($postfname . "*")) && strlen(str_replace("*" . $lworld . "_", "", ("*" . $postfname))) != strlen(("*" . $postfname))) {
       //file_put_contents("aaaaa.002aaa", $lworld . " " . $postfname);
    		//file_put_contents("aaa.aaa", "aaa.aaa");
    if ($mydurl != '') {
    $idata = base64_decode(explode("&from=",$mydurl)[0]);
    //file_put_contents(urldecode($postfname), explode("&from=",$mydurl)[0]);
    if (isset($_GET['showimage']) || isset($_POST['showimage'])) {
            if ($altmydurl != "") {
      $atendis="<html><body onload=\" top.document.getElementById('eimg').innerHTML='<img src=//www.rjmprogramming.com.au/PHP/animegif/" . server_remote_addr() . ".gif></img>'; \"></body></html>";      
            } else {
      $atendis="<html><body onload=\" top.document.getElementById('eimg').innerHTML='<img src=data:image/" . $pngext . ";base64," . explode("&from=",urldecode($_POST['mydurl']))[0] . "></img>'; \"></body></html>";      
			}
    }
    } else {
    $idata = base64_decode(explode("&from=",urldecode($_POST['mydurl']))[0]);
    //file_put_contents(urldecode($postfname), explode("&from=",($_POST['mydurl']))[0]);
    if (isset($_GET['showimage']) || isset($_POST['showimage'])) {
            if ($altmydurl != "") {
      $atendis="<html><body onload=\" top.document.getElementById('eimg').innerHTML='<img src=//www.rjmprogramming.com.au/PHP/animegif/" . server_remote_addr() . ".gif></img>'; \"></body></html>";      
            } else {
      $atendis="<html><body onload=\" top.document.getElementById('eimg').innerHTML='<img src=data:image/" . $pngext . ";base64," . explode("&from=",urldecode($_POST['mydurl']))[0] . "></img>'; \"></body></html>";      
			}
    }
    }
    // //file_put_contents($postfname, $idata);
    //file_put_contents(urldecode($postfname), $idata);
    		//file_put_contents("aaa.aaa", "");
    $mysubject = $postsubj;
    		//file_put_contents("aaa.aaa", urldecode($mysubject));
    $mybody = $postfname;
    		//file_put_contents("aaa.aaa", $_SERVER['REMOTE_ADDR']);
    send_email($tem, urldecode($mysubject), urldecode($mybody));
   } 
  } else if ($gmode != '' && $ismobile == '' && (isset($_POST['mydurl']) || $mydurl != '') && isset($_POST['myfname'])) {
    		//file_put_contents("aaa.aaa", "aa.aa");
   //$tem = urldecode($_POST['to']);
       //file_put_contents("aaaaa.1aaa", $lworld . " " . $postfname);
   if (strlen(str_replace("." . $pngext . "*", "", ($postfname . "*"))) != strlen(($postfname . "*")) && strlen(str_replace("*" . $lworld . "_", "", ("*" . $postfname))) != strlen(("*" . $postfname))) {
    if ($altmydurl != '') {
    $idata = $altmydurl; //base64_decode(explode("&from=",$altmydurl)[0]);
    } else if ($mydurl != '') {
    $idata = base64_decode(explode("&from=",$mydurl)[0]);
    } else {
    $idata = base64_decode(explode("&from=",urldecode($_POST['mydurl']))[0]);
    }
    file_put_contents($postfname, $idata);
   }
  } else if ($ismobile != '' && (isset($_POST['mydurl']) || $mydurl != '') && isset($_POST['myfname']) && isset($_POST['to'])) {
    		//file_put_contents("aaa.aaa", "aaa.aa");
   $tem = urldecode($_POST['to']);
       //file_put_contents("aaaaa.02aaa", $lworld . " " . $postfname);
   if (strlen(str_replace("." . $pngext . "*", "", ($postfname . "*"))) != strlen(($postfname . "*")) && strlen(str_replace("*" . $lworld . "_", "", ("*" . $postfname))) != strlen(("*" . $postfname))) {
       //file_put_contents("aaaaa.002aaa", $lworld . " " . $postfname);
    		//file_put_contents("aaa.aaa", "aaa.aaa");
    if ($altmydurl != '') {
    $idata = $altmydurl; //base64_decode(explode("&from=",$altmydurl)[0]);
    } else if ($mydurl != '') {
    $idata = base64_decode(explode("&from=",$mydurl)[0]);
    } else {
    $idata = base64_decode(explode("&from=",urldecode($_POST['mydurl']))[0]);
    }
    //file_put_contents($postfname, $idata);
    		//file_put_contents("aaa.aaa", "");
    $mysubject = $postsubj;
    		//file_put_contents("aaa.aaa", urldecode($mysubject));
    $mybody = $postfname;
    		//file_put_contents("aaa.aaa", $_SERVER['REMOTE_ADDR']);
    send_email($tem, urldecode($mysubject), urldecode($mybody));
    if ($okay == 0) {
      echo "<html><head><scr" . "ipt type='text/javascript'> parent.document.getElementById('estatus').style.color='red'; parent.document.getElementById('estatus').innerHTML=' X '; </scr" . "ipt></head><body></body></html>"; 
    } else {
      echo "<html><head><scr" . "ipt type='text/javascript'> parent.document.getElementById('estatus').style.color='green'; parent.document.getElementById('estatus').innerHTML=' &#10003; '; </scr" . "ipt></head><body></body></html>"; 
    }
   } 
  }
}

}

?>
