2c2 < // global_substitution.php --- > // tr_mapping.php 6,11c6,7 < // 1) From filespec create CSV mapping (global_substitution.csv) for second part via section tags containing role="paragraph" and old_label="[OldLabel]" and label="[NewLabel]" all before section tag end < // 2) From input index file and CSV above create Korn Shell (ksh) file that runs ... ksh -x global_substitution.ksh ... to update for new index file (but backup yourself first) < // September, 2017 ... Allow for jobs where supplied with index file and intermediate CSV and a "halfway prefix" to search for in CSV file, but no KSH file yet < // ... Allow for a final COM_rep.txt "sanity check" extraction of a single tag value < < ini_set('max_execution_time', 6000); --- > // 1) From filespec create CSV mapping (tr_mapping.csv) for second part via section tags containing role="paragraph" and old_label="[OldLabel]" and label="[NewLabel]" all before section tag end > // 2) From input index file and CSV above create Korn Shell (ksh) file that runs ... ksh -x tr_mapping.ksh ... to update for new index file (but backup yourself first) 18,20c14 < < < $filespec="COM_.TL16~INDEX_pudd.xml"; --- > $filespec="COMM.PINSW*.xml"; 22c16 < $indexfilecalled="COMM.TL16~*.xml"; --- > $indexfilecalled="COMM.PIN~INDEX.xml"; 36,42d29 < < $labelthis=' uci="'; < if (isset($_GET['labelthis'])) $labelthis=str_replace("+"," ",urldecode($_GET['labelthis'])); < $labelthistwo='"'; < if (isset($_GET['labelthistwo'])) $labelthistwo=str_replace("+"," ",urldecode($_GET['labelthistwo'])); < < 49,55c36 < < $titlethis='>'; < if (isset($_GET['titlethis'])) $titlethis=str_replace("+"," ",urldecode($_GET['titlethis'])); < $titlethistwo=''; < if (isset($_GET['titlethistwo'])) $titlethistwo=str_replace("+"," ",urldecode($_GET['titlethistwo'])); < < $csvname="global_substitution.csv"; --- > $csvname="tr_mapping.csv"; 57,59c38 < $halfwayprefix=""; < if (isset($_GET['halfwayprefix'])) $halfwayprefix=str_replace(",","",str_replace("+"," ",urldecode($_GET['halfwayprefix']))); < $kshname="global_substitution.ksh"; --- > $kshname="tr_mapping.ksh"; 61c40 < $doksh=""; // "ksh -x global_substitution.ksh"; --- > $doksh=""; // "ksh -x tr_mapping.ksh"; 63,76d41 < $followup=""; < if (isset($_GET['followup'])) $followup=str_replace(">","",str_replace("<","",str_replace("" . basename($indexfilecalled) . " changes on " . gmdate("l jS \of F Y h:i:s A") . " GMT below ..."; < $oldresults="
" . basename($indexfilecalled) . " below ...
" . str_replace("<","<",str_replace(">",">",file_get_contents($indexfilecalled))) . "
... New Versus Old ..." . basename($indexfilecalled . "_original_backup") . " below ...
" . str_replace("<","<",str_replace(">",">",file_get_contents($indexfilecalled))) . "

"; < } < for ($icsvlines=0; $icsvlines" . $oldfielddata . "", $oldresults); < if ($newfielddata != "") $results=str_replace($oldfielddata,"" . $newfielddata . "", $results); < } < } < $kshout.=$delim . "cat " . $indexfilecalled . " | sed '/\\" . str_replace("]","\\]",$oldfielddata) . "/s//\\" . str_replace("]","\\]",$newfielddata) . "/g' > " . str_replace($uext,$ualt,str_replace($lext,$lalt,$indexfilecalled)) . " ; rm -f " . $indexfilecalled . " ; cat " . str_replace($uext,$ualt,str_replace($lext,$lalt,$indexfilecalled)) . " > " . $indexfilecalled . " ; "; < $delim="\n"; < } < } < if ($delim != "") { < rename($csvname, $csvname . "_original_backup"); < file_put_contents($kshname, $kshout); 124,140d60 < if ($doksh != "") { < if (!file_exists($indexfilecalled . "_original_backup")) copy($indexfilecalled, $indexfilecalled . "_original_backup"); < $results.=$oldresults; < file_put_contents("COM_.htm", "
" . explode("",explode("",$results)[0])[-1 + sizeof(explode("",explode("",$results)[0]))] . "
"); < exec($doksh); < sleep(2); < $results.="
" . basename($indexfilecalled) . " " . gmdate("l jS \of F Y h:i:s A") . " GMT below ...
" . basename($indexfilecalled) . " below ...
... New Versus Old ..." . basename($indexfilecalled . "_original_backup") . " below ...

"; < } < } < } else if (isset($_GET['filespec'])) { // jobs with no CSV yet < $topresults=""; < $oldresults=""; < $newresults=""; < if ($doksh != "") { < $newresults.="
" . basename($indexfilecalled) . " changes on " . gmdate("l jS \of F Y h:i:s A") . " GMT below ..."; < $oldresults.="
" . basename($indexfilecalled) . " below ...
" . str_replace("<","<",str_replace(">",">",file_get_contents($indexfilecalled))) . "
... New Versus Old ..." . basename($indexfilecalled . "_original_backup") . " below ...
" . str_replace("<","<",str_replace(">",">",file_get_contents($indexfilecalled))) . "

"; < } 143,148d62 < $chapteruci=""; < if ($labelthis != "" && $labelthistwo != "") { < if (strpos($cont,$labelthis) !== false) { < $chapteruci=explode($labelthistwo,explode($labelthis, $cont)[1])[0]; < } < } 155,179c69 < < $subtitle=""; < if ($titlethis != "" && $titlethistwo != "") { < try { < if (strpos($cont, trim($thebit)) !== false) { < if (strpos(explode(str_replace(">>",">",str_replace("")))),explode(trim($thebit), $cont)[1])[0], $titlethistwo) !== false && strpos(explode(str_replace(">>",">",str_replace("")))),explode(trim($thebit), $cont)[1])[0], $titlethis) !== false) { < < < $subtitle=explode($titlethis,explode($titlethistwo,str_replace("","",str_replace("","",str_replace("","",str_replace("","",explode(trim($thebit), $cont)[1])))))[0])[-1 + sizeof(explode($titlethis,explode($titlethistwo,str_replace("","",str_replace("","",str_replace("","",str_replace("","",explode(trim($thebit), $cont)[1])))))[0]))]; < < < } < } < } catch (Exception $ee) { < $subtitle=""; < } < } < < $csvout.=$delim . $chapteruci . "," . explode($oldlabelfindend,explode($oldlabelfindstart, $thebit)[1])[0] . ",," . explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0] . "," . $subtitle; < if ($doksh != "") { < if (explode($oldlabelfindend,explode($oldlabelfindstart, $thebit)[1])[0] != "") { < $oldresults=str_replace(explode($oldlabelfindend,explode($oldlabelfindstart, $thebit)[1])[0],"" . explode($oldlabelfindend,explode($oldlabelfindstart, $thebit)[1])[0] . "", $oldresults); < if (explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0] != "") $newresults=str_replace(explode($oldlabelfindend,explode($oldlabelfindstart, $thebit)[1])[0],"" . explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0] . "", $newresults); < } < } --- > $csvout.=$delim . "," . explode($oldlabelfindend,explode($oldlabelfindstart, $thebit)[1])[0] . ",," . explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0]; 183,213d72 < } else if ($objections == "" && strpos($thebit, $newlabelfindstart) !== false && strpos($thebit, $newlabelfindstart) !== false && ($findthis == '' || strpos($thebit, $findthis) !== false) && ($findthistwo == '' || strpos($thebit, $findthistwo) !== false) && ($findthisthree == '' || strpos($thebit, $findthisthree) === false)) { < //echo "it happens"; < //exit; < if (str_replace("]","\\]",explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0]) != "") { < //echo "thebit=" . trim($thebit) . " afters=" . str_replace(">",">",str_replace("<","<",explode(trim($thebit), $cont)[1])) . " thisbits[1]=" . str_replace("<","<",str_replace(">",">",$thisbits[1])); < //exit; < $subtitle=""; < < if ($titlethis != "" && $titlethistwo != "") { < try { < if (strpos($cont, trim($thebit)) !== false) { < if (strpos(explode(str_replace(">>",">",str_replace("")))),explode(trim($thebit), $cont)[1])[0], $titlethistwo) !== false && strpos(explode(str_replace(">>",">",str_replace("")))),explode(trim($thebit), $cont)[1])[0], $titlethis) !== false) { < < $subtitle=explode($titlethis,explode($titlethistwo,str_replace("","",str_replace("","",str_replace("","",str_replace("","",explode(trim($thebit), $cont)[1])))))[0])[-1 + sizeof(explode($titlethis,explode($titlethistwo,str_replace("","",str_replace("","",str_replace("","",str_replace("","",explode(trim($thebit), $cont)[1])))))[0]))]; < } < } < } catch (Exception $ee) { < $subtitle=""; < } < } < < $csvout.=$delim . $chapteruci . ",,," . explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0] . "," . $subtitle; < if ($doksh != "") { < if (explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0] != "") { < $oldresults=str_replace(explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0],"" . explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0] . "", $oldresults); < if (explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0] != "") $newresults=str_replace(explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0],"" . explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0] . "", $newresults); < } < } < $kshout.=$delim . "cat " . $indexfilecalled . " | sed '/\\" . "" . "/s//\\" . str_replace("]","\\]",explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0]) . "/g' > " . str_replace($uext,$ualt,str_replace($lext,$lalt,$indexfilecalled)) . " ; rm -f " . $indexfilecalled . " ; cat " . str_replace($uext,$ualt,str_replace($lext,$lalt,$indexfilecalled)) . " > " . $indexfilecalled . " ; "; < $delim="\n"; < } 217c76 < $topresults.=$newresults . $oldresults; --- > 221,223c80 < if ($topresults != "") { < file_put_contents("COM_.htm", "
" . explode("",explode("",$topresults)[0])[-1 + sizeof(explode("",explode("",$topresults)[0]))] . "
"); < } --- > 227,229c84 < sleep(2); < $results="
" . basename($indexfilecalled) . " " . gmdate("l jS \of F Y h:i:s A") . " GMT below ...
" . basename($indexfilecalled) . " below ...
... New Versus Old ..." . basename($indexfilecalled . "_original_backup") . " below ...

"; < $results.=$topresults; --- > $results="
" . basename($indexfilecalled) . " below ...
... New Versus Old ..." . basename($indexfilecalled . "_original_backup") . " below ...
"; 232,244d86 < } < < if ($followup != "" && file_exists($indexfilecalled)) { < $cont=@file_get_contents($indexfilecalled); < $sections=explode("", $cont); < $repd=""; < for ($i=0; $i",$sections[$i])[-1 + sizeof(explode("<" . $followup . ">",$sections[$i]))] . "\n"; < } < file_put_contents("COM_rep.txt", $repd); < } < < 248,253c90,95 < < Global Substitution Helper - RJM Programming - September, 2017 < < <

Global Substitution Helper

  RJM Programming - September, 2017

<
--- > >

Global Substitution Helper

>

RJM Programming

>

March, 2017

>
>
255,256c97,98 < File name for input (and output) index file (to change):

< File specification for input data:
--- > File name for input (and output) index file (to change):
> File specification for input data:
259c101 < New label regarding global substitutions start delimitation (but if you want both old and new finds click "both"):
--- > New label regarding global substitutions start delimitation:
263,264d104 < First Label (CSV first field) tag prefix:
< First Label (CSV first field) tag suffix:
268,277c108,111 < After Find Title (CSV last field) tag prefix:
< After Find Title (CSV last field) tag suffix:

< Output (and intermediate) CSV file name:

< Halfway House Old and New Prefix (eg: [) for jobs where supplied with existant index file and existant intermediate CSV file,
but no existant Korn Shell file yet (and so for this we also recommend filling in "finalize job" below):

< Output (and intermediate) Korn Shell script file name:

< Optional command line to finalize job (eg. ksh -x global_substitution.ksh) ... can result in COM_.htm report:
< Follow Up COM_rep.txt "sanity check" report tag report basis (eg. <olink>) ... can result in COM_rep.txt report:

< < < --- > Output (and intermediate) CSV file name:
> Output (and intermediate) Korn Shell script file name:
> Optional command line to finalize job (eg. ksh -x tr_mapping.ksh):
> 282d115 <