"; if (isset($_GET['endfind'])) $endfind=str_replace("+"," ",urldecode($_GET['endfind'])); $newlabelfindstart=' label="'; if (isset($_GET['newlabelfindstart'])) $newlabelfindstart=str_replace("+"," ",urldecode($_GET['newlabelfindstart'])); $newlabelfindend='"'; if (isset($_GET['newlabelfindend'])) $newlabelfindend=str_replace("+"," ",urldecode($_GET['newlabelfindend'])); $oldlabelfindstart=' old_label="'; if (isset($_GET['oldlabelfindstart'])) $oldlabelfindstart=str_replace("+"," ",urldecode($_GET['oldlabelfindstart'])); $oldlabelfindend='"'; if (isset($_GET['oldlabelfindend'])) $oldlabelfindend=str_replace("+"," ",urldecode($_GET['oldlabelfindend'])); $findthis=' role="paragraph"'; if (isset($_GET['findthis'])) $findthis=str_replace("+"," ",urldecode($_GET['findthis'])); $findthistwo=''; if (isset($_GET['findthistwo'])) $findthistwo=str_replace("+"," ",urldecode($_GET['findthistwo'])); $findthisthree=''; if (isset($_GET['findthisthree'])) $findthisthree=str_replace("+"," ",urldecode($_GET['findthisthree'])); $csvname="tr_mapping.csv"; if (isset($_GET['csvname'])) $csvname=str_replace("+"," ",urldecode($_GET['csvname'])); $kshname="tr_mapping.ksh"; if (isset($_GET['kshname'])) $kshname=str_replace("+"," ",urldecode($_GET['kshname'])); $doksh=""; // "ksh -x tr_mapping.ksh"; if (isset($_GET['doksh'])) $doksh=str_replace("+"," ",urldecode($_GET['doksh'])); $uext=".XML"; $lext=".xml"; $ualt=".XXX"; $lalt=".xxx"; $extis=explode(".", $indexfilecalled); if (sizeof($extis) > 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"; } } foreach (glob($filespec) as $filename) { $cont=@file_get_contents($filename); $sections=explode($startfind, $cont); for ($i=1; $i " . 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 ($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):