Try: ca/tecreations/ViewFile.php -- Online
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/tec_SiteRoot.php";
global $ts;
if (isset($_REQUEST['ts']) && $_REQUEST['ts'] != "") {
$ts = $_REQUEST['ts'];
} else {
$ts = "a";
}
function addOne() {
global $ts;
$parts = str_split($ts);
for($i = count($parts) - 1;$i >= 0; $i--) {
if ($parts[$i] == 'z') {
while ($i >= 0 && ($parts[$i] == 'z')) {
$parts[$i] = 'a';
$i--;
}
if ($i == -1) { // leftmost character reached, add an 'a'
return "a" . implode("",$parts);
} else {
// somewhere in the string, increment the current position
$parts[$i] = getNext($parts[$i]);
return implode($parts);
}
} else {
$parts[$i] = getNext($parts[$i]);
return implode($parts);
}
}
}
function getNext($str) {
if ($str == "a") return "b";
if ($str == "b") return "c";
if ($str == "c") return "d";
if ($str == "d") return "e";
if ($str == "e") return "f";
if ($str == "f") return "g";
if ($str == "g") return "h";
if ($str == "h") return "i";
if ($str == "i") return "j";
if ($str == "j") return "k";
if ($str == "k") return "l";
if ($str == "l") return "m";
if ($str == "m") return "n";
if ($str == "n") return "o";
if ($str == "o") return "p";
if ($str == "p") return "q";
if ($str == "q") return "r";
if ($str == "r") return "s";
if ($str == "s") return "t";
if ($str == "t") return "u";
if ($str == "u") return "v";
if ($str == "v") return "w";
if ($str == "w") return "x";
if ($str == "x") return "y";
if ($str == "y") return "z";
if ($str == "z") return "a";
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == "Add 1") {
$ts = addOne($ts);
}
?>
<html>
<body>
<a href="/ca/tecreations/ViewFile.php?path=ca/tecreations/tstring/add1.php">View This File's Code</a><br />
<br />
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method='GET'>
<label for="ts">TString:</label><br />
<input type="text" name="ts" value="<?php global $ts; echo $ts; ?>" maxlength="256" /><br />
<input type="submit" name="action" value="Add 1" /><br />
</form>
</body>
</html>