Skip to content

Commit

Permalink
PHP scripts that deal with new URL style.
Browse files Browse the repository at this point in the history
Eventually we should dump index.php and just have the perl script do it. Laziness.
  • Loading branch information
icculus committed May 27, 2017
1 parent b9f2c10 commit 2f6f78c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
31 changes: 31 additions & 0 deletions index.php
@@ -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);

?>
21 changes: 21 additions & 0 deletions old-finger-url-redirect.php
@@ -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);
?>

0 comments on commit 2f6f78c

Please sign in to comment.