= 2) { if ($inv == "lookup") { $subthings=explode("you_will_neverfind-this", $things[1]); $retval=str_replace("|", "\n", $subthings[0]); } else { $subthings=explode("|", $things[1]); $retval=$subthings[0]; } } } return $retval; } $cidea="curl " . "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] . "?curlget="; $curlget=""; if (isset($_GET['curlget'])) $curlget=urldecode($_GET['curlget']); $letthrough=" "; $filespec="COM_.IOVBK/*.xml"; $thisext="xml"; $bckext="lmx"; $ynftt="#@!@#"; $prefix1="olink>"; $prefix2='olink targetptr="start">'; $prefix3='olink targetptr="end">'; $prefix4='label="['; $prefix5='label="'; $prefix6='COMM.IOVBK~CH.'; $lookup="[30.,[29. [32.,[30. [33.,[31. [34.,[32. [35.,[33. [36.,[34. [37.,[35. [38.,[36. [39.,[37. [40.,[38. [41.,[39. [42.,[40. [43.,[41. [46.,[42. [47.,[43. [48.,[44. [49.,[45. [50.,[46. [50A.,[47. [52.,[48. [53.,[49. [54.,[50. [55.,[51. [56.,[52. [59.,[53. [60.,[54. [61.,[55."; $ourlookup=$lookup; $argv0=""; if (isset($argv[0])) $argv0=$argv[0]; if (isset($argv[0])) { // PHP command line specific interactive input code below ... $letthrough= "*" . $_SERVER['SCRIPT_FILENAME'] . "!"; $ourlookup=""; print " Chapter Renumbering ------------------- "; $filespec = "COM_.IOVBK/*.xml"; print "Type file specification [COM_.IOVBK/*.xml].\n Type nothing on a line by itself when you're done.\n"; $line = " "; $first=true; while (strlen($line) != 0) { $line = trim(fgets(STDIN)); // reads one line from STDIN //fscanf(STDIN, "%s\n%s", $filespec, $other); // reads number from STDIN $things=explode("\n", $line); if ($first) { if ($things[0] == "" || strlen($line) == 0) { $filespec="COM_.IOVBK/*.xml"; } else { $filespec=$things[0]; } } $first=false; } $bits=explode(".",$filespec); $thisext=$bits[sizeof($bits) - 1]; $bckext=strrev($thisext); if ($bckext == $thisext) $bckext .= "_bck"; $things=explode("\n", $line); print "Type comma separated chapter mapping data [[30.,[29. [32.,[30. [33.,[31. [34.,[32. [35.,[33. [36.,[34. [37.,[35. [38.,[36. [39.,[37. [40.,[38. [41.,[39. [42.,[40. [43.,[41. [46.,[42. [47.,[43. [48.,[44. [49.,[45. [50.,[46. [50A.,[47. [52.,[48. [53.,[49. [54.,[50. [55.,[51. [56.,[52. [59.,[53. [60.,[54. [61.,[55.]\n Type nothing on a line by itself when you're done.\n"; $line = " "; $first=true; while (strlen($line) != 0) { $line = trim(fgets(STDIN)); // reads one line from STDIN //fscanf(STDIN, "%s\n%s", $filespec, $other); // reads number from STDIN $things=explode("\n", $line); if ($first || 1 == 1) { if ($first && ($things[0] == "" || strlen($line) == 0)) { $ourlookup=$lookup; } else { $ourlookup.=$things[0] . "\n"; } } $first=false; } print "Type the string that causes no internal clashes [#@!@#] by being temporarily placed before '.'.\n Type nothing on a line by itself when you're done.\n"; $line = " "; $first=true; while (strlen($line) != 0) { $line = trim(fgets(STDIN)); // reads one line from STDIN //fscanf(STDIN, "%s\n%s", $filespec, $other); // reads number from STDIN $things=explode("\n", $line); if ($first) { if ($things[0] == "" || strlen($line) == 0) { $ynftt="#@!@#"; } else { $ynftt=$things[0]; } } $first=false; } print "Type the prefix identifier 1 of 6 [olink>] (before what is in your lookup).\n Type dot to not do this substitution idea.\n Type nothing on a line by itself when you're done.\n"; $line = " "; $first=true; while (strlen($line) != 0) { $line = trim(fgets(STDIN)); // reads one line from STDIN //fscanf(STDIN, "%s\n%s", $filespec, $other); // reads number from STDIN $things=explode("\n", $line); if ($first) { if ($things[0] == "" || strlen($line) == 0) { $prefix1="olink>"; } else if ($things[0] == '.') { $prefix1=""; } else { $prefix1=trim($things[0]); } } $first=false; } print "Type the prefix identifier 2 of 6 [olink targetptr=" . '"' . "start" . '"' . ">] (before what is in your lookup).\n Type dot to not do this substitution idea.\n Type nothing on a line by itself when you're done.\n"; $line = " "; $first=true; while (strlen($line) != 0) { $line = trim(fgets(STDIN)); // reads one line from STDIN //fscanf(STDIN, "%s\n%s", $filespec, $other); // reads number from STDIN $things=explode("\n", $line); if ($first) { if ($things[0] == "" || strlen($line) == 0) { $prefix2='olink targetptr="start">'; } else if ($things[0] == '.') { $prefix2=""; } else { $prefix2=trim($things[0]); } } $first=false; } print "Type the prefix identifier 3 of 6 [olink targetptr=" . '"' . "end" . '"' . ">] (before what is in your lookup).\n Type dot to not do this substitution idea.\n Type nothing on a line by itself when you're done.\n"; $line = " "; $first=true; while (strlen($line) != 0) { $line = trim(fgets(STDIN)); // reads one line from STDIN //fscanf(STDIN, "%s\n%s", $filespec, $other); // reads number from STDIN $things=explode("\n", $line); if ($first) { if ($things[0] == "" || strlen($line) == 0) { $prefix3='olink targetptr="end">'; } else if ($things[0] == '.') { $prefix3=""; } else { $prefix3=trim($things[0]); } } $first=false; } print "Type the prefix identifier 4 of 6 [label=" . '"' . "[] (before just the chapter number and " . '.' . ").\n Type dot to not do this substitution idea.\n Type nothing on a line by itself when you're done.\n"; $line = " "; $first=true; while (strlen($line) != 0) { $line = trim(fgets(STDIN)); // reads one line from STDIN //fscanf(STDIN, "%s\n%s", $filespec, $other); // reads number from STDIN $things=explode("\n", $line); if ($first) { if ($things[0] == "" || strlen($line) == 0) { $prefix4='label="['; } else if ($things[0] == '.') { $prefix4=""; } else { $prefix4=trim($things[0]); } } $first=false; } print "Type the prefix identifier 5 of 6 [label=" . '"' . "] (before just the chapter number and " . '"' . ").\n Type dot to not do this substitution idea.\n Type nothing on a line by itself when you're done.\n"; $line = " "; $first=true; while (strlen($line) != 0) { $line = trim(fgets(STDIN)); // reads one line from STDIN //fscanf(STDIN, "%s\n%s", $filespec, $other); // reads number from STDIN $things=explode("\n", $line); if ($first) { if ($things[0] == "" || strlen($line) == 0) { $prefix5='label="'; } else if ($things[0] == '.') { $prefix5=""; } else { $prefix5=trim($things[0]); } } $first=false; } print "Type the prefix identifier 6 of 6 [COMM.IOVBK~CH.] (before just the chapter number and " . '"' . ").\n Type dot to not do this substitution idea.\n Type nothing on a line by itself when you're done.\n"; $line = " "; $first=true; while (strlen($line) != 0) { $line = trim(fgets(STDIN)); // reads one line from STDIN //fscanf(STDIN, "%s\n%s", $filespec, $other); // reads number from STDIN $things=explode("\n", $line); if ($first) { if ($things[0] == "" || strlen($line) == 0) { $prefix6="COMM.IOVBK~CH."; } else if ($things[0] == '.') { $prefix6=""; } else { $prefix6=trim($things[0]); } } $first=false; } } else if (!isset($_GET['thisext']) && !isset($_GET['curlget'])) { // ... end of PHP command line specific interactive input code ... $letthrough=""; $cidea .= urlencode("|filespec=" . $filespec); $cidea .= urlencode("|ynftt=" . $ynftt); $cidea .= urlencode("|prefix1=" . $prefix1); $cidea .= urlencode("|prefix2=" . $prefix2); $cidea .= urlencode("|prefix3=" . $prefix3); $cidea .= urlencode("|prefix4=" . $prefix4); $cidea .= urlencode("|prefix5=" . $prefix5); $cidea .= urlencode("|prefix6=" . $prefix6); $cidea .= urlencode("|lookup=" . str_replace("\n","|",$lookup)); echo "" . $_SERVER['DOCUMENT_ROOT'] . "

Chapter Renumbering


Filespec (of data input):
Lookup to map chapters:
Padding text (make it something not in data input):
Prefix 1 of 6 (before what is in your lookup ... enter . for none):
Prefix 2 of 6 (before what is in your lookup ... enter . for none):
Prefix 3 of 6 (before what is in your lookup ... enter . for none):
Prefix 4 of 6 (before just the chapter number and . ... enter . for none):
Prefix 5 of 6 (before just the chapter number and " . '"' . " ... enter . for none):
Prefix 6 of 6 (before just the chapter number and " . '"' . " ... enter . for none):

\n\nYou might be here using curl and we want you to copy/adjust/paste the example usage string below to help ...\n\n" . $cidea . "\n\n

"; } else if (isset($_GET['filespec']) || isset($_GET['curlget'])) { // phase two run via form results $filespec=cget('filespec'); //urldecode($_GET['filespec']); $bits=explode(".",$filespec); $thisext=$bits[sizeof($bits) - 1]; $bckext=strrev($thisext); if ($bckext == $thisext) $bckext .= "_bck"; $ynftt=cget('ynftt'); //urldecode($_GET['ynftt']); $prefix1=cget('prefix1'); //urldecode($_GET['prefix1']); $prefix2=cget('prefix2'); //urldecode($_GET['prefix2']); $prefix3=cget('prefix3'); //urldecode($_GET['prefix3']); $prefix4=cget('prefix4'); //urldecode($_GET['prefix4']); $prefix5=cget('prefix5'); //urldecode($_GET['prefix5']); $prefix6=cget('prefix6'); //urldecode($_GET['prefix6']); if (prefix1 == '.') $prefix1=''; if (prefix2 == '.') $prefix2=''; if (prefix3 == '.') $prefix3=''; if (prefix4 == '.') $prefix4=''; if (prefix5 == '.') $prefix5=''; if (prefix6 == '.') $prefix6=''; $lookup=cget('lookup'); //urldecode($_GET['lookup']); $ourlookup=$lookup; $letthrough .= " Another go?"; } if (strlen($letthrough) > 0) { $from=[]; $to=[]; $flist=""; $num = 0; foreach (glob($filespec) as $filename) { if (!file_exists(str_replace("." . $thisext, "." . $bckext, $filename))) { file_put_contents(str_replace("." . $thisext, "." . $bckext, $filename), file_get_contents($filename)); } $flist.=$filename."\n"; $num++; } $lbits=explode("\n", $ourlookup); //$lookup); for ($i=0; $i