','
',''); $sumsuffix=str_replace('','
',''); $line=''; $numargs=-1; $gxml=""; $pxml=""; $ziparr = array(); $detailrec=''; $zdis=''; $zipn=''; $predetc=''; $postdetc=''; function extbits() { global $errmsg, $ucextnodot, $lcextnodot, $mcextnodot, $ucextdot, $mcextdot, $lcextdot, $tlextdot; $lcextnodot=strtolower($ucextnodot); $mcextnodot=strtoupper(substr($ucextnodot,0,1)) . strtolower(substr($ucextnodot,1)); $ucextdot="." . $ucextnodot; $mcextdot="." . strtoupper(substr($ucextnodot,0,1)) . strtolower(substr($ucextnodot,1)); $lcextdot="." . $lcextnodot; $tlextdot=substr($lcextdot,0,3); } function ourglob($infil) { global $iferr, $errmsg, $ziparr; if (isset($_GET['zipdata'])) { $ziparr = array(); array_push($ziparr, $infil); return $ziparr; } else if (isset($_POST['zipdata'])) { $ziparr = array(); array_push($ziparr, $infil); return $ziparr; } else { try { $previferr=$iferr; $iferr= "./csv_via_xml_report.php?error="; $gi=glob($infil); $iferr=$previferr; return $gi; } catch(Exception $exception) { echo 'Caught in try/catch ' . $exception->getMessage() . ' at ' . $exception->getLine(); } } } function ourfile_get_contents($infil) { global $iferr, $errmsg, $zdis; if (isset($_GET['zipdata'])) { if ($zdis == '') { $zdis=str_replace( "\r", " ", str_replace("\n"," ",str_replace('<','<',str_replace('>','>',str_replace("+"," ",urldecode($_GET['zipdata'])))))); } return explode("!@!@!",explode(($infil . "@!@!@"), $zdis)[1])[0]; } else if (isset($_POST['zipdata'])) { if ($zdis == '') { $zdis=str_replace( "\r", " ", str_replace("\n"," ",str_replace('<','<',str_replace('>','>',str_replace("+"," ",urldecode($_POST['zipdata'])))))); } return explode("!@!@!",explode(($infil . "@!@!@"), $zdis)[1])[0]; } else { $previferr=$iferr; $iferr= "./csv_via_xml_report.php?error="; try { $fir=file_get_contents($infil); } catch(Exception $exception) { $fir=""; } try { if ($fir == "") { if (!file_exists($infil)) { header("Location: " . $iferr . urlencode("File " . $infil . " not found")); exit; } else { header("Location: " . $iferr . urlencode("File " . $infil . " empty ")); exit; } } $iferr=$previferr; return $fir; } catch(Exception $exception) { echo 'Caught in try/catch ' . $exception->getMessage() . ' at ' . $exception->getLine(); } } } function outinalways($inh) { $huhr=''; $wo=false; for ($iu=0; $iu') { $wo=true; } else if (substr($inh, $iu, 1) == '<') { $wo=false; } else if ($wo) { $huhr.=substr($inh, $iu, 1); } } return $huhr; } function outin($inh) { global $numargs; if ($numargs <= 0) { return $inh; } else { $huhr=''; $wo=false; $inh=str_replace("","\n",str_replace("

","\n",str_replace("","\n",str_replace("
","\n",$inh)))); for ($iu=0; $iu') { $wo=true; } else if (substr($inh, $iu, 1) == '<') { $wo=false; } else if ($wo) { $huhr.=substr($inh, $iu, 1); } } return $huhr; } } function userdef($pvsg, $infis, $outfis, $defhdr, $ct) { global $iferr, $detailrec, $ucextnodot, $lcextnodot, $mcextnodot, $ucextdot, $mcextdot, $lcextdot, $tlextdot, $one; $ourhdr=$defhdr; try { $iferr= "./csv_via_xml_report.php?error="; $firstoffs = array(); $counts = array(); $delm=""; $hdelm=""; $xcnt=0; $minrows=-1; $maxcols=0; $thisrows=0; //$xct=$ct; //if (strpos($ct, '@!@!@') !== false) { $xct=explode('@!@!@', $ct)[1]; } //if (substr(($xct . " "),0,1) == '[') { // via zip //$xcont=$ct; //} else if (substr(($xct . " "),0,1) == '<') { // via zip //$xcont=$ct; //} else if (substr(($xct . " "),0,4) == '<') { // via zip //$xcont=str_replace("<","<",str_replace(">",">",$ct)); //} else { //$xcont=ourfile_get_contents($infis); //} if (strpos($ct, '@!@!@') !== false) { $ct=explode('!@!@!',explode('@!@!@', $ct)[$one])[0]; $one++; } if (substr(($ct . " "),0,1) == '[') { // via zip $xcont=$ct; } else if (substr(($ct . " "),0,1) == '<') { // via zip $xcont=$ct; } else if (substr(($ct . " "),0,4) == '<') { // via zip $xcont=str_replace("<","<",str_replace(">",">",$ct)); } else { $xcont=ourfile_get_contents($infis); } $ix=0; if (strtoupper($pvsg) == "GET") { $ourhdr=""; while (isset($_GET['dheader' . $xcnt])) { $ourhdr.=$hdelm . '"' . str_replace("+"," ",urldecode($_GET['dheader' . $xcnt])) . '"'; $hdelm=","; $hdrhuh=str_replace("+"," ",urldecode($_GET['dprefix' . $xcnt])); while (strpos($hdrhuh, "&v[") !== false) { $ix=explode("]", explode("&v[", $hdrhuh)[1])[0]; $hdrhuh=str_replace("&v[" . $ix . "]", $firstoffs[-1 + $ix], $hdrhuh); } $thisrows=explode($hdrhuh, $xcont); array_push($counts, (-1 + sizeof($thisrows))); if (sizeof($thisrows) == 1) { array_push($firstoffs, ""); if ($minrows < 0) { $minrows=0; } else { $minrows=1; } } else if ($minrows < 0) { array_push($firstoffs, explode(str_replace("+"," ",urldecode($_GET['dsuffix' . $xcnt])), $thisrows[1])[0]); $minrows=-1 + sizeof($thisrows); } else if (sizeof($thisrows) <= $minrows) { array_push($firstoffs, explode(str_replace("+"," ",urldecode($_GET['dsuffix' . $xcnt])), $thisrows[1])[0]); $minrows=-1 + sizeof($thisrows); } $xcnt++; $maxcols=$xcnt; } } else if (strtoupper($pvsg) == "POST") { $ourhdr=""; while (isset($_POST['dheader' . $xcnt])) { $ourhdr.=$hdelm . '"' . str_replace("+"," ",urldecode($_POST['dheader' . $xcnt])) . '"'; $hdelm=","; $hdrhuh=str_replace("+"," ",urldecode($_POST['dprefix' . $xcnt])); while (strpos($hdrhuh, "&v[") !== false) { $ix=explode("]", explode("&v[", $hdrhuh)[1])[0]; $hdrhuh=str_replace("&v[" . $ix . "]", $firstoffs[-1 + $ix], $hdrhuh); } $thisrows=explode($hdrhuh, $xcont); array_push($counts, (-1 + sizeof($thisrows))); if (sizeof($thisrows) == 1) { array_push($firstoffs, ""); if ($minrows < 0) { $minrows=0; } else { $minrows=1; } } else if ($minrows < 0) { array_push($firstoffs, explode(str_replace("+"," ",urldecode($_POST['dsuffix' . $xcnt])), $thisrows[1])[0]); $minrows=-1 + sizeof($thisrows); } else if (sizeof($thisrows) <= $minrows) { array_push($firstoffs, explode(str_replace("+"," ",urldecode($_POST['dsuffix' . $xcnt])), $thisrows[1])[0]); $minrows=-1 + sizeof($thisrows); } $xcnt++; $maxcols=$xcnt; } } $xcnt=0; if (strtoupper($pvsg) == "GET") { $detailrec=""; $delm=""; for ($iyu=0; $iyu<$minrows; $iyu++) { if ($iyu == 0 && 1 == 3) { for ($ixu=0; $ixu<$maxcols; $ixu++) { $detailrec.=$delm . '"' . $firstoffs[$ixu] . '"'; $delm=","; } } else { for ($ixu=0; $ixu<$maxcols; $ixu++) { if ($counts[$ixu] <= $iyu) { $detailrec.=$delm . '""'; $delm=","; } else { $hdrhuh=str_replace("+"," ",urldecode($_GET['dprefix' . $ixu])); while (strpos($hdrhuh, "&v[") !== false) { $ix=explode("]", explode("&v[", $hdrhuh)[1])[0]; $hdrhuh=str_replace("&v[" . $ix . "]", $firstoffs[-1 + $ix], $hdrhuh); } $thisrows=explode($hdrhuh, $xcont); if (str_replace("getMessage() . ' at ' . $exception->getLine(); } return $ourhdr; } function buttonize($inh) { global $ucextnodot, $lcextnodot, $mcextnodot, $ucextdot, $mcextdot, $lcextdot, $tlextdot; $wo=false; $outsd=""; $elecnt=0; $ioff=0; if (substr(($inh . " "),0,1) == "[") { // JSON if ($ucextnodot != "JSON") { $ucextnodot="JSON"; extbits(); } } else { // XML if ($ucextnodot != "XML") { $ucextnodot="XML"; extbits(); } } for ($iu=0; $iu 0) { $ioff--; } else if (substr(($inh . " "), $iu, 1) == "\n" || substr(($inh . " "), $iu, 1) == "\r") { $outsd.=" "; } else if (substr(($inh . " "), $iu, 2) == '}{' && $ucextnodot == "JSON") { $elecnt++; $wo=false; $ioff=1; $outsd.=substr($inh, $iu, 1) . '{'; } else if (substr(($inh . " "), $iu, 2) == '}]' && $ucextnodot == "JSON") { $elecnt++; $wo=false; $ioff=1; $outsd.=substr($inh, $iu, 1) . ']'; } else if (substr(($inh . " "), $iu, 8) == '><' && $ucextnodot == "XML") { $elecnt++; $wo=false; $ioff=7; $outsd.=substr($inh, $iu, 4) . '<'; } else if (substr(($inh . " "), $iu, 1) == '}' && $ucextnodot == "JSON") { $wo=true; $ioff=0; $outsd.=substr($inh, $iu, 1); $outsd.=''; $wo=false; $ioff=0; $outsd.=substr($inh, $iu, 1); } else if (substr(($inh . " "), $iu, 4) == '<' && $ucextnodot == "XML") { if ($wo) { $outsd.='">'; } $outsd.=''; $wo=false; $ioff=3; $outsd.=substr($inh, $iu, 4); } else if ($wo) { $outsd.=substr($inh, $iu, 1); } else { $outsd.=substr($inh, $iu, 1); } } if (strpos(($outsd . "@$#@"), ' value="@$#@') !== false) { $outsd.='">'; } return str_replace("'", "' + String.fromCharCode(39) + '", str_replace("\n","
",$outsd)); } if (isset($_POST['body'])) { $wpproposed=str_replace(">",">",str_replace("<","<",str_replace("+"," ",urldecode($_POST['body'])))); //echo "

" . urldecode($_POST['to']) . "


" . urldecode($_POST['subject']) . "

"; //exit; if (strpos(urldecode($_POST['to']), "@") !== false && urldecode($_POST['subject']) != '') { $eol = PHP_EOL; $header = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol; $header .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol; //$header .= 'BCC: ' . 'rmetcalfe15@gmail.com' . $eol; // attachment $filename=str_replace(".php", ".html", explode("/",$_SERVER['REQUEST_URI'])[-1 + sizeof(explode("/",$_SERVER['REQUEST_URI']))]); $content = chunk_split(base64_encode($wpproposed)); $message="Please download attached webpage. "; if (sizeof(explode("\n",urldecode($_POST['subject']))) > 1) { $message.=str_replace("\r"," ",str_replace("\n"," ",str_replace(explode("\r",explode("\n",urldecode($_POST['subject']))[0])[0], "", str_replace("+"," ",urldecode($_POST['subject']))))); } // a random hash will be necessary to send mixed content $uid = md5(time()); $headers=''; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/html; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $message."\r\n\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"; $header .= $content."\r\n\r\n"; $wpproposeds=explode('>"', str_replace("'",'"',str_replace("
","\n",str_replace("
","\n",str_replace("
","\n",$wpproposed))))); if (sizeof($wpproposeds) == 1 || (urldecode($_POST['to']) != strtoupper(urldecode($_POST['to'])) && urldecode($_POST['to']) != strtolower(urldecode($_POST['to'])))) { $header .= "--".$uid."--"; } else { $header .= "--".$uid."\r\n"; //--"; $nextfile=str_replace(".html", ".csv", $filename); for ($ik=0; $ik","\n",str_replace("
","\n",str_replace("
","\n",'"' . explode('","\n",str_replace("
","\n",str_replace("
","\n",'"' . explode('"; exit; } } if (isset($_GET['xml'])) { // surfing the net if (isset($_GET['zipnames'])) { $zipn=explode("#",str_replace("+"," ",urldecode($_GET['xml'])))[0] . "'s "; $gxml=$_GET['zipnames']; } else { $gxml=$_GET['xml']; } } else if (isset($_POST['xml'])) { // surfing the net if (isset($_POST['zipnames'])) { $zipn=explode("#",str_replace("+"," ",urldecode($_POST['xml'])))[0] . "'s "; $pxml=$_POST['zipnames']; } else { $pxml=$_POST['xml']; } } else if (isset($argv)) { // command line $numargs = sizeof($argv); if ($numargs <= 1) { if (PHP_OS == 'WINNT') { echo '$ ' . $ucextnodot . ' File(spec) or URL: '; $line = stream_get_line(STDIN, 1024, PHP_EOL); } else { $line = readline('$ ' . $ucextnodot . ' File(spec) or URL: '); } $gxml=urlencode($line); } else { $gxml=$argv[1]; array_push($ziparr, $argv[1]); for ($iu=2; $iu<$numargs; $iu++) { $gxml.=' ' . $argv[$iu]; array_push($ziparr, $argv[$iu]); } $gxml=urlencode($gxml); } } $jobbits="Job Description Goes Here"; // fill this in if (isset($_GET['gtitle'])) { $jobbits=str_replace("+"," ",urldecode($_GET['gtitle'])); } else if (isset($_POST['gtitle'])) { $jobbits=str_replace("+"," ",urldecode($_POST['gtitle'])); } $emailask=" function emailask() { var emailee=prompt('Email to? (Make the email address a mix of cases to just email an HTML webpage else this and csv spreadsheet file(s) will be sent)', ''); if (emailee == null) { emailee=''; } if (emailee.indexOf('@') != -1) { var e_body=('' + document.head.innerHTML.split('' + document.body.innerHTML.replace(/\+/g,'%2b') + '').replace(/\/g,'>').replace(/\\\"/g,\"'\"); if (document.getElementById('e_to')) { document.getElementById('e_to').value=emailee; } else { document.getElementById('demaila').innerHTML+='
'; } document.getElementById('e_body').value=e_body; //alert(document.getElementById('e_body').value); document.getElementById('e_button').click(); //document.getElementById('e_form').submit(); } } "; function oursimplexml_load_file($inxml) { global $iferr, $detailrec, $ucextnodot, $lcextnodot, $mcextnodot, $ucextdot, $mcextdot, $lcextdot, $tlextdot; if (isset($_GET['generic']) || isset($_POST['generic'])) { return simplexml_load_file($inxml); } else { try { $iferr= "./csv_via_xml_report.php?error="; if (strpos(strtolower($inxml),strtolower($tlextdot)) === false) { if ($ucextnodot == "XML") { $ucextnodot="JSON"; extbits(); } else { $ucextnodot="XML"; extbits(); } } $outrpts=explode($tlextdot, str_replace($ucextdot,$lcextdot,str_replace($mcextdot,$lcextdot,$inxml))); $outrpt=""; if (sizeof($outrpts) > 1) { $bz=""; $prebz=""; $outrpt=$outrpts[0] . $prebz . $bz . ".csv"; while (file_exists($outrpts[0] . ".csv" . $bz)) { if (("" . $bz) == "") { $prebz="_"; $bz=1; } else { $bz++; } $outrpt=$outrpts[0] . $prebz . $bz . ".csv"; } } // Start of business logic piecing together CSV report ... $cont=ourfile_get_contents($inxml); $detailrec=''; $headerrec=''; $zd=''; if (isset($_GET['zipdata'])) { $zd=str_replace( "\r", " ", str_replace("\n"," ",str_replace('<','<',str_replace('>','>',str_replace("+"," ",urldecode($_GET['zipdata'])))))); } else if (isset($_POST['zipdata'])) { $zd=str_replace( "\r", " ", str_replace("\n"," ",str_replace('<','<',str_replace('>','>',str_replace("+"," ",urldecode($_POST['zipdata'])))))); } if (isset($_GET['dheader0'])) { $headerrec=userdef("GET", $inxml, $outrpt, '"col1label","col2label"', $zd); } else if (isset($_POST['dheader0'])) { $headerrec=userdef("POST", $inxml, $outrpt, '"col1label","col2label"', $zd); } else { $detailrec='"col1value","col2value"'; // you do more in depth work to get to this point via $cont } if (trim($detailrec) != "" || $headerrec != "") { if ($headerrec == "") { $headerrec='"col1label","col2label"'; // you do more in depth work to get a header record as required via $cont } if ($outrpt != "" && 1 == 1) { if ($headerrec != "") { $headerrec.="\n"; } file_put_contents($outrpt, $headerrec . $detailrec); exit; } else { if ($headerrec != "") { $headerrec.="
"; } echo "
" . $headerrec . $detailrec . "
"; return null; } } } catch(Exception $exception) { echo 'Caught in try/catch ' . $exception->getMessage() . ' at ' . $exception->getLine(); } // End of business logic piecing together CSV report return null; } } $genextra=""; if (isset($_GET['generic']) || isset($_POST['generic'])) { $genextra=""; } $xmlstr=""; $outidea="outfile.csv"; $keep=true; if (!isset($_GET['keep']) && !isset($_POST['keep'])) { $keep=false; } if ($gxml != "") { // add in file(spec) considerations here if (file_exists(str_replace("+"," ",urldecode($gxml))) || strpos(str_replace("+"," ",urldecode($gxml)), " ") !== false || strpos(str_replace("+"," ",urldecode($gxml)), "*") !== false || strpos(str_replace("+"," ",urldecode($gxml)), "%") !== false || strpos(str_replace("+"," ",urldecode($gxml)), "?") !== false) { try { $iferr= "./csv_via_xml_report.php?error="; $htmlis="XML or JSON to CSV " . $errmsg . $jobbits . " Report - RJM Programming - September, 2018" . $emailask . "

XML or JSON to CSV " . $predetc . $jobbits . $postdetc . " Report Run ...

"; if (strpos(str_replace("+"," ",urldecode($gxml)), " ") !== false) { $inths=str_replace(" ",",",str_replace("+"," ",urldecode($gxml))); //$ziparr; } else { $inths=str_replace("+"," ",urldecode($gxml)); } $intha=explode(",", $inths); for ($ii=0; $ii function popdiv() { if (parent.document.getElementById('fleshitout')) { if (parent.document.getElementById('fleshitout').innerHTML == '') { var dt=''; parent.document.getElementById('fleshitout').innerHTML='

Define Columns of InterestColumn Definition Basis
' + dt + '
'; parent.document.getElementById('divfleshitout').innerHTML='" . buttonize(str_replace(">",">",str_replace("<","<",ourfile_get_contents($xmlfil)))) . "'; parent.document.getElementById('xml').style.cursor='pointer'; parent.document.getElementById('isubmit').style.cursor='pointer'; } } }
"; exit; } $bz=""; $prebz=""; if (strpos(strtolower($xmlfil),strtolower($tlextdot)) === false) { if ($ucextnodot == "XML") { $ucextnodot="JSON"; extbits(); } else { $ucextnodot="XML"; extbits(); } } $outrpts=explode($tlextdot, str_replace($ucextdot,$lcextdot,str_replace($mcextdot,$lcextdot,$xmlfil))); $outrpt=$outrpts[0] . $prebz . $bz . ".csv"; while (file_exists($outrpts[0] . $prebz . $bz . ".csv")) { if (("" . $bz) == "") { $prebz="_"; $bz=1; } else { $bz++; } $outrpt=$outrpts[0] . $prebz . $bz . ".csv"; } if ($numargs >= 1) { exec("php " . $argv[0] . ' "' . $xmlfil . '"'); } else if (isset($_GET['dheader0']) || isset($_POST['dheader0'])) { //$cont=ourfile_get_contents($xmlfil); $detailrec=''; $headerrec=''; $zd=''; if (isset($_GET['zipdata'])) { $zd=str_replace( "\r", " ", str_replace("\n"," ",str_replace('<','<',str_replace('>','>',str_replace("+"," ",urldecode($_GET['zipdata'])))))); } else if (isset($_POST['zipdata'])) { $zd=str_replace( "\r", " ", str_replace("\n"," ",str_replace('<','<',str_replace('>','>',str_replace("+"," ",urldecode($_POST['zipdata'])))))); } if (isset($_GET['dheader0'])) { $headerrec=userdef("GET", $xmlfil, $outrpt, '"col1label","col2label"', $zd); if ($predetc == '') { $predetc=$detprefix . ' title="Total run CSV report" style=display:inline-block; id=cdet>' . $sumprefix . ' title="Total run CSV report">'; $postdetc=$sumsuffix . $headerrec . '
' . $detsuffix . ''; } } else if (isset($_POST['dheader0'])) { $headerrec=userdef("POST", $xmlfil, $outrpt, '"col1label","col2label"', $zd); if ($predetc == '') { $predetc=$detprefix . ' title="Total run CSV report" style=display:inline-block; id=cdet>' . $sumprefix . ' title="Total run CSV report">'; $postdetc=$sumsuffix . $headerrec . '
' . $detsuffix . ''; } } if (trim($detailrec) != "" || $headerrec != "") { if ($headerrec == "") { $headerrec='"col1label","col2label"'; // you do more in depth work to get a header record as required via $cont } if ($outrpt != "" && 1 == 1) { if ($headerrec != "") { $headerrec.="\n"; } if ($postdetc != '') { $postdetc=str_replace(str_replace('
','',$detsuffix), str_replace("\n","
",$detailrec) . '
' . str_replace('
','',$detsuffix),$postdetc); } file_put_contents($outrpt, $headerrec . $detailrec); } } } else { exec("curl " . "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . explode("?",$_SERVER['REQUEST_URI'])[0] . '?xml=' . urlencode($xmlfil)); } if (file_exists($outrpt)) { if (isset($_GET['dheader0']) || isset($_POST['dheader0'])) { $htmlis=str_replace("",$detprefix . " style=background-color:yellow;" . $op . ">" . $sumprefix . " style=background-color:pink;>Read " . $zipn . $xmlfil . " as basis for" . " " . $jobbits . " report " . $outrpt . " for your perusal." . $sumsuffix . str_replace("\n","
",file_get_contents($outrpt)) . $detsuffix . "",$htmlis); unlink($outrpt); } else { $htmlis=str_replace("","Read " . $xmlfil . " as basis for" . " " . $jobbits . " report " . $outrpt . " for your perusal.
",$htmlis); } } else { $htmlis=str_replace("","Could not read " . $xmlfil . " as basis for" . " " . $jobbits . " report " . $outrpt . " successfully, alas.
",$htmlis); } } } if ($predetc != '') { $htmlis=str_replace(">" . $jobbits . "
",">" . $predetc . $jobbits . $postdetc . "
",$htmlis); } echo outin($htmlis); exit; } catch(Exception $exception) { echo 'Caught in try/catch ' . $exception->getMessage() . ' at ' . $exception->getLine(); } } // end of file(spec) considerations above if (strpos(strtolower("~" . urldecode($gxml)), "~http") !== false) { $xmlstr=ourfile_get_contents(urldecode($gxml)); $outidea=explode("." . explode(".",urldecode($gxml))[-1 + sizeof(explode(".",urldecode($gxml)))], urldecode($gxml))[0]; $outidea=explode("/", $outidea)[-1 + sizeof(explode("/", $outidea))]; $outidea=explode(substr("\\",0,1), $outidea)[-1 + sizeof(explode(substr("\\",0,1), $outidea))]; $outidea.=".csv"; } else if (strpos(strtolower("~" . urldecode($gxml)), "~<") !== false) { $xmlstr=str_replace("+"," ",urldecode($gxml)); } if ($xmlstr != "") { $xml = oursimplexml_load_string($xmlstr); } else if (file_exists(urldecode($gxml))) { $xmlstr=" "; $outidea=explode("." . explode(".",urldecode($gxml))[-1 + sizeof(explode(".",urldecode($gxml)))], urldecode($gxml))[0]; $outidea=explode("/", $outidea)[-1 + sizeof(explode("/", $outidea))]; $outidea=explode(substr("\\",0,1), $outidea)[-1 + sizeof(explode(substr("\\",0,1), $outidea))]; $outidea.=".csv"; $xml = oursimplexml_load_file(urldecode($gxml)); } } else if ($pxml != '') { // add in file(spec) considerations here if (file_exists(str_replace("+"," ",urldecode($pxml))) || strpos(str_replace("+"," ",urldecode($pxml)), " ") !== false || strpos(str_replace("+"," ",urldecode($pxml)), "*") !== false || strpos(str_replace("+"," ",urldecode($pxml)), "%") !== false || strpos(str_replace("+"," ",urldecode($pxml)), "?") !== false) { try { $iferr= "./csv_via_xml_report.php?error="; //$htmlis="XML or JSON to CSV " . $jobbits . " Report - RJM Programming - September, 2018

XML or JSON to CSV " . $predetc . $jobbits . $postdetc . " Report Run ...

"; $htmlis="XML or JSON to CSV " . $errmsg . $jobbits . " Report - RJM Programming - September, 2018" . $emailask . "

XML or JSON to CSV " . $predetc . $jobbits . $postdetc . " Report Run ...

"; if (strpos(str_replace("+"," ",urldecode($pxml)), " ") !== false) { $inths=str_replace(" ",",",str_replace("+"," ",urldecode($pxml))); //$ziparr; } else { $inths=str_replace("+"," ",urldecode($pxml)); } $intha=explode(",", $inths); for ($ii=0; $ii function popdiv() { if (parent.document.getElementById('fleshitout')) { if (parent.document.getElementById('fleshitout').innerHTML == '') { var dt=''; parent.document.getElementById('fleshitout').innerHTML='

Define Columns of InterestColumn Definition Basis
' + dt + '
'; parent.document.getElementById('divfleshitout').innerHTML='" . buttonize(str_replace(">",">",str_replace("<","<",ourfile_get_contents($xmlfil)))) . "'; parent.document.getElementById('xml').style.cursor='pointer'; parent.document.getElementById('isubmit').style.cursor='pointer'; } } } "; exit; } $bz=""; $prebz=""; if (strpos(strtolower($xmlfil),strtolower($tlextdot)) === false) { if ($ucextnodot == "XML") { $ucextnodot="JSON"; extbits(); } else { $ucextnodot="XML"; extbits(); } } $outrpts=explode($tlextdot, str_replace($ucextdot,$lcextdot,str_replace($mcextdot,$lcextdot,$xmlfil))); $outrpt=$outrpts[0] . $prebz . $bz . ".csv"; //while (file_exists($outrpts[0] . ".csv" . $bz)) { while (file_exists($outrpts[0] . $prebz . $bz . ".csv")) { if (("" . $bz) == "") { $prebz="_"; $bz=1; } else { $bz++; } $outrpt=$outrpts[0] . $prebz . $bz . ".csv"; } if ($numargs >= 1) { exec("php " . $argv[0] . ' "' . $xmlfil . '"'); } else if (isset($_GET['dheader0']) || isset($_POST['dheader0'])) { //$cont=ourfile_get_contents($xmlfil); $detailrec=''; $headerrec=''; $zd=''; if (isset($_GET['zipdata'])) { $zd=str_replace( "\r", " ", str_replace("\n"," ",str_replace('<','<',str_replace('>','>',str_replace("+"," ",urldecode($_GET['zipdata'])))))); } else if (isset($_POST['zipdata'])) { $zd=str_replace( "\r", " ", str_replace("\n"," ",str_replace('<','<',str_replace('>','>',str_replace("+"," ",urldecode($_POST['zipdata'])))))); } if (isset($_GET['dheader0'])) { $headerrec=userdef("GET", $xmlfil, $outrpt, '"col1label","col2label"', $zd); if ($predetc == '') { $predetc=$detprefix . ' title="Total run CSV report" style=display:inline-block; id=cdet>' . $sumprefix . ' title="Total run CSV report">'; $postdetc=$sumsuffix . $headerrec . '
' . $detsuffix . ''; } } else if (isset($_POST['dheader0'])) { $headerrec=userdef("POST", $xmlfil, $outrpt, '"col1label","col2label"', $zd); if ($predetc == '') { $predetc=$detprefix . ' title="Total run CSV report" style=display:inline-block; id=cdet>' . $sumprefix . ' title="Total run CSV report">'; $postdetc=$sumsuffix . $headerrec . '
' . $detsuffix . ''; } } if (trim($detailrec) != "" || $headerrec != "") { if ($headerrec == "") { $headerrec='"col1label","col2label"'; // you do more in depth work to get a header record as required via $cont } if ($outrpt != "" && 1 == 1) { if ($headerrec != "") { $headerrec.="\n"; } if ($postdetc != '') { $postdetc=str_replace(str_replace('
','',$detsuffix), str_replace("\n","
",$detailrec) . '
' . str_replace('
','',$detsuffix),$postdetc); } file_put_contents($outrpt, $headerrec . $detailrec); } } } else { exec("curl " . "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . explode("?",$_SERVER['REQUEST_URI'])[0] . '?xml=' . urlencode($xmlfil)); } if (file_exists($outrpt)) { if (isset($_GET['dheader0']) || isset($_POST['dheader0'])) { $htmlis=str_replace("",$detprefix . " style=background-color:yellow;" . $op . ">" . $sumprefix . " style=background-color:pink;>Read " . $zipn . $xmlfil . " as basis for" . " " . $jobbits . " report " . $outrpt . " for your perusal." . $sumsuffix . str_replace("\n","
",file_get_contents($outrpt)) . $detsuffix . "",$htmlis); unlink($outrpt); } else { $htmlis=str_replace("","Read " . $xmlfil . " as basis for" . " " . $jobbits . " report " . $outrpt . " for your perusal.
",$htmlis); } } else { $htmlis=str_replace("","Could not read " . $xmlfil . " as basis for" . " " . $jobbits . " report " . $outrpt . " successfully, alas.
",$htmlis); } } } if ($predetc != '') { $htmlis=str_replace(">" . $jobbits . "
",">" . $predetc . $jobbits . $postdetc . "",$htmlis); } echo $htmlis; exit; } catch(Exception $exception) { echo 'Caught in try/catch ' . $exception->getMessage() . ' at ' . $exception->getLine(); } } // end of file(spec) considerations above if (strpos(strtolower("~" . urldecode($pxml)), "~http") !== false) { $xmlstr=ourfile_get_contents(urldecode($pxml)); $outidea=explode("." . explode(".",urldecode($pxml))[-1 + sizeof(explode(".",urldecode($pxml)))], urldecode($pxml))[0]; $outidea=explode("/", $outidea)[-1 + sizeof(explode("/", $outidea))]; $outidea=explode(substr("\\",0,1), $outidea)[-1 + sizeof(explode(substr("\\",0,1), $outidea))]; $outidea.=".csv"; } else if (strpos(strtolower("~" . urldecode($pxml)), "~<") !== false) { $xmlstr=str_replace("+"," ",urldecode($pxml)); } if ($xmlstr != "") { $xml = oursimplexml_load_string($xmlstr); } else if (file_exists(urldecode($pxml))) { $xmlstr=" "; $outidea=explode("." . explode(".",urldecode($pxml))[-1 + sizeof(explode(".",urldecode($pxml)))], urldecode($pxml))[0]; $outidea=explode("/", $outidea)[-1 + sizeof(explode("/", $outidea))]; $outidea=explode(substr("\\",0,1), $outidea)[-1 + sizeof(explode(substr("\\",0,1), $outidea))]; $outidea.=".csv"; $xml = oursimplexml_load_file(urldecode($pxml)); } } if ($xmlstr != "") { if ($xml) { while (file_exists($outidea)) { $outidea=str_replace(".csv","1.csv",$outidea); } $outstream = fopen($outidea,'w'); $header=false; foreach($xml as $k=>$details) { if (!$header) { $harr=array_keys(get_object_vars($details)); if (sizeof($harr) != 0) { fputcsv($outstream,$harr); $header=true; } } $harr=get_object_vars($details); if (sizeof($harr) != 0) fputcsv($outstream,$harr); } fclose($outstream); //$csvstr=preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "",ourfile_get_contents($outidea)); //$csvstr=preg_replace("/(^[\n]*|[\n]+)[\s\t]*[\n]+/", "",$csvstr); $csvstr=ourfile_get_contents($outidea); if (isset($_GET['download']) || isset($_POST['download'])) { echo outin("XML or JSON to CSV " . $errmsg . $jobbits . " Report - RJM Programming - September, 2018

XML or JSON to CSV " . $errmsg . $jobbits . " " . $outidea . "

RJM Programming - August, 2018



XML or JSON File(spec) or Zipfile with XML or JSON or URL: 0) { this.style.cursor='progress'; document.getElementById('isubmit').style.cursor='progress'; if ((this.value.toLowerCase().replace('#','~') + '~').indexOf('.zip~') != -1) { pretheni(this.value); } else { andtheni(this.value); } } \" type='text' name='xml' id='xml' value=''> 


" . $genextra . "
"); } } else { if (!$keep) { unlink($outidea); header('Content-type: text/csv'); echo $csvstr; exit; } else { if (isset($_GET['keep'])) { if (urldecode($_GET['keep']) == 'keep') { unlink($outidea); echo outin("XML or JSON to CSV " . $errmsg . $jobbits . " Report - RJM Programming - September, 2018 "); } else { header('Content-type: text/csv'); echo $csvstr; exit; } } else if (isset($_POST['keep'])) { if (urldecode($_POST['keep']) == 'keep') { unlink($outidea); echo outin("XML or JSON to CSV " . $errmsg . $jobbits . " Report - RJM Programming - September, 2018 "); } else { header('Content-type: text/csv'); echo $csvstr; exit; } } } } } else if ($numargs <= 0) { echo outin("XML or JSON to CSV " . $errmsg . $jobbits . " Report - RJM Programming - September, 2018

XML or JSON to CSV " . $errmsg . $jobbits . " Report

RJM Programming - September, 2018



XML or JSON File(spec) or Zipfile with XML or JSON or URL: 0) { this.style.cursor='progress'; document.getElementById('isubmit').style.cursor='progress'; if ((this.value.toLowerCase().replace('#','~') + '~').indexOf('.zip~') != -1) { pretheni(this.value); } else { andtheni(this.value); } } \" type='text' name='xml' id='xml' value=''> 


" . $genextra . "
"); } ?>