Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHP scripts that deal with new URL style.
Eventually we should dump index.php and just have the perl script do it. Laziness.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
$arg = preg_replace('/\A\/finger\//', '', $_SERVER['REQUEST_URI']); | ||
$arg = 'user=' . preg_replace('/\?/', '&', $arg); | ||
|
||
putenv("SERVER_NAME=${_SERVER['SERVER_NAME']}"); | ||
putenv("QUERY_STRING=$arg"); | ||
putenv("GATEWAY_INTERFACE=1"); | ||
putenv("HTTP_USER_AGENT=${_SERVER['HTTP_USER_AGENT']}"); | ||
putenv("ICCULUSFINGER_ALTURL=1"); | ||
|
||
$io = popen('/webspace/icculus.org/finger/finger.pl', 'r'); | ||
if ($io === FALSE) { | ||
header('HTTP/1.0 500 Internal Server Error'); | ||
header('Content-Type: text/plain; charset=UTF-8'); | ||
print("Internal server error, try again later, please!\n"); | ||
exit(0); | ||
} | ||
|
||
while (($line = fgets($io)) !== FALSE) { | ||
$line = preg_replace('/[\r\n]*\Z/', '', $line); | ||
if ($line == '') | ||
break; | ||
header($line); | ||
} | ||
|
||
fpassthru($io); | ||
|
||
pclose($io); | ||
exit(0); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
$vhost = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'icculus.org'; | ||
$user = isset($_REQUEST['user']) ? $_REQUEST['user'] : ''; | ||
|
||
$args = ''; | ||
if (isset($_REQUEST) && (count($_REQUEST) > 0)) { | ||
$ch = '?'; | ||
foreach ($_REQUEST as $key => $val) { | ||
if ($key == 'user') { | ||
continue; | ||
} | ||
$args .= "$ch$key=$val"; | ||
$ch = '&'; | ||
} | ||
} | ||
|
||
$url = "https://$vhost/finger/$user$args"; | ||
header("Location: $url", true, 301); | ||
print("<html><head><title>Moved Permanently</title></head><body><center>\nThis URL has moved to <a href='$url'>\n\n$url\n\n</a></center></body></html>\n"); | ||
exit(0); | ||
?> |