9d8 < $results=""; 15c14 < if (isset($_GET['filespec'])) $filespec=str_replace("+"," ",urldecode($_GET['filespec'])); --- > if (isset($_GET['filespec'])) $filespec=urldecode($_GET['filespec']); 17,59c16 < if (isset($_GET['index'])) $indexfilecalled=str_replace("+"," ",urldecode($_GET['index'])); < $startfind="
1) { < $uext=strtoupper("." . $extis[-1 + sizeof($extis)]); < $lext=strtolower("." . $extis[-1 + sizeof($extis)]); < if ($lext == ".xxx") { < $lalt=".xzz"; < $ualt=".XZZ"; < } else { < $lalt=substr($lext,0,2) . "xx"; < $ualt=substr($uext,0,2) . "XX"; < } < } < --- > if (isset($_GET['index'])) $indexfilecalled=urldecode($_GET['index']); 63c20 < $sections=explode($startfind, $cont); --- > $sections=explode("
$thisbits=explode(">", $sections[$i]); 67,70c24,27 < if (strpos($thebit, $oldlabelfindstart) !== false && strpos($thebit, $newlabelfindstart) !== false && ($findthis == '' || strpos($thebit, $findthis) !== false) && ($findthistwo == '' || strpos($thebit, $findthistwo) !== false) && ($findthisthree == '' || strpos($thebit, $findthisthree) === false)) { < if (str_replace("]","\\]",explode($oldlabelfindend,explode($oldlabelfindstart, $thebit)[1])[0]) != "") { < $csvout.=$delim . "," . explode($oldlabelfindend,explode($oldlabelfindstart, $thebit)[1])[0] . ",," . explode($newlabelfindend,explode($newlabelfindstart, $thebit)[1])[0]; < $kshout.=$delim . "cat " . $indexfilecalled . " | sed '/\\" . str_replace("]","\\]",explode($oldlabelfindend,explode($oldlabelfindstart, $thebit)[1])[0]) . "/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 . " ; "; --- > if (strpos($thebit, ' old_label="') !== false && strpos($thebit, ' label="') !== false && strpos($thebit, ' role="paragraph"') !== false) { > if (str_replace("]","\\]",explode('"',explode(' old_label="', $thebit)[1])[0]) != "") { > $csvout.=$delim . "," . explode('"',explode(' old_label="', $thebit)[1])[0] . ",," . explode('"',explode(' label="', $thebit)[1])[0]; > $kshout.=$delim . "cat " . $indexfilecalled . " | sed '/\\" . str_replace("]","\\]",explode('"',explode(' old_label="', $thebit)[1])[0]) . "/s//\\" . str_replace("]","\\]",explode('"',explode(' label="', $thebit)[1])[0]) . "/g' > " . str_replace(".XML",".XXX",str_replace(".xml",".xxx",$indexfilecalled)) . " ; rm -f " . $indexfilecalled . " ; cat " . str_replace(".XML",".XXX",str_replace(".xml",".xxx",$indexfilecalled)) . " > " . $indexfilecalled . " ; "; 77,114c34,35 < if ($csvout != "") { < file_put_contents($csvname, $csvout); < file_put_contents($kshname, $kshout); < < if ($doksh != "") { < if (!file_exists($indexfilecalled . "_original_backup")) copy($indexfilecalled, $indexfilecalled . "_original_backup"); < exec($doksh); < $results="
" . basename($indexfilecalled) . " below ...
... New Versus Old ..." . basename($indexfilecalled . "_original_backup") . " below ...
"; < } < } < ?> < < < <

Global Substitution Helper

<

RJM Programming

<

March, 2017

<
<
<
< File name for input (and output) index file (to change):
< File specification for input data:
< Start delimitation of tags of interest:
< End delimitation of tags of interest:
< New label regarding global substitutions start delimitation:
< New label regarding global substitutions end delimitation:
< Old label regarding global substitutions start delimitation:
< Old label regarding global substitutions end delimitation:
< Find this within tag 1/3:
< Find this within tag 2/3:
< Do not find this within tag:
< 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):
< <
< < --- > file_put_contents("tr_mapping.csv", $csvout); > file_put_contents("tr_mapping.ksh", $kshout); 115a37 > ?> \ No newline at end of file