$value) { if (strlen($value) == 0) { unset($parts[$index]); } } $parts = array_values($parts); if (count($parts) == 4) { // we probably have the main page if ($parts[3] == 'ElectricMini') { $parts[4] = 'WebHome'; } } if (count($parts) != 5) { header('Status: 404'); print 'Expected 5 parts found ' . count($parts) . ' in ' . $path; return; } if ($parts[1] == "pub") { // this is an image $web = $parts[2]; $img = $parts[4]; print "
" . $web . " " . $img . "
"; header('Status: 301'); header('Location: http://carrott.org/_emini/img_auth.php/a/a6/' . $img); return; } if ($parts[4] == 'WebRss') { header('Status: 301'); header('Location: http://carrott.org/_emini/index.php?title=Special:RecentChanges&feed=rss'); return; } if ($parts[4] == 'WebAtom') { header('Status: 301'); header('Location: http://carrott.org/_emini/index.php?title=Special:RecentChanges&feed=atom'); return; } $page = $parts[4]; $web = $parts[3]; print "
" . " " . htmlspecialchars($web) . " " . htmlspecialchars($page) . "
"; if ($web != "ElectricMini") { header('Status: 404'); print 'Not Found'; return; } $nameMapping = array("Siemens1LH5118" => "Siemens_1LH5118", "WebHome" => "Main_Page", "GPSRollingResistanceCalculator" => "GPS_Rolling_Resistance_Calculator"); if (isset($nameMapping[$page])) { $newPage = $nameMapping[$page]; } else { $newPage = ""; $lastIsUpper = True; for ($i = 0; $i < strlen($page); $i++) { $c = substr($page, $i, 1); if (ctype_upper($c) and !$lastIsUpper) { $newPage = $newPage . "_" . $c; } else { $newPage = $newPage . $c; } $lastIsUpper = ctype_upper($c) or $c == "#"; } } header('Status: 301'); // how do we make this safe? header('Location: http://carrott.org/emini/' . $newPage); ?>