-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6afb048
commit 30ab54d
Showing
3 changed files
with
92 additions
and
13 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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
#RewriteEngine on | ||
RewriteEngine on | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteRule . index.php [B,L] | ||
|
||
#RewriteRule ^(.*)$ https://ludumdare.com/$1 [R=301,L] |
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 |
---|---|---|
@@ -1,4 +1,72 @@ | ||
<?php | ||
@include __DIR__."/../config.php"; | ||
const CONFIG_PATH = "../shrub/"; | ||
const SHRUB_PATH = "../shrub/src/"; | ||
include_once __DIR__."/".CONFIG_PATH."config.php"; | ||
require_once __DIR__."/".SHRUB_PATH."api.php"; | ||
|
||
echo "huh"; | ||
json_Begin(); | ||
|
||
const DOMAIN_REDIRECT_TABLE = [ | ||
'url.ludumdare.org' => 'ludumdare.org', | ||
'url.ludumdare.dev' => 'ludumdare.dev', | ||
'url.jammer.work' => 'jammer.work', | ||
'url.jammer.dev' => 'jammer.dev', | ||
|
||
'ldj.am' => 'ldjam.com', | ||
'jam.mr' => 'jammer.vg', | ||
]; | ||
|
||
$action = json_ArgShift(); | ||
$node_id = null; | ||
$specific = false; | ||
|
||
if ( !$action ) { | ||
json_EmitFatalError_BadRequest('What?', $RESPONSE); | ||
} | ||
|
||
// Do Specific Actions | ||
switch ( $action ) { | ||
case 'SPECIAL': //SPECIAL | ||
$specific = true; | ||
|
||
$RESPONSE['ham'] = 1; | ||
|
||
break; // case 'SPECIAL': //SPECIAL | ||
|
||
default: | ||
if ( !isset(DOMAIN_REDIRECT_TABLE[$_SERVER['SERVER_NAME']]) ) { | ||
json_EmitFatalError_BadRequest('Unknown domain mapping: '.$_SERVER['SERVER_NAME'], $RESPONSE); | ||
} | ||
|
||
$url = '//'.DOMAIN_REDIRECT_TABLE[$_SERVER['SERVER_NAME']]; | ||
|
||
// Do a raw ID decode | ||
if ( $action[0] == '$' ) { | ||
$node_id = intval(substr($action, 1)); | ||
} | ||
else { | ||
// TODO: munger | ||
$node_id = 0; | ||
} | ||
|
||
if ( !$node_id ) { | ||
json_EmitFatalError_BadRequest('Unknown request', $RESPONSE); | ||
} | ||
|
||
$paths = node_GetPathById($node_id, 1); | ||
if ( !$paths ) { | ||
json_EmitFatalError_BadRequest('Unable to trace node: '.$node_id, $RESPONSE); | ||
} | ||
$RESPONSE['paths'] = $paths; | ||
|
||
$url .= $paths['path']; | ||
$RESPONSE['url'] = $url; | ||
|
||
// Redirect | ||
header('Location: '.$url, true, /*301*/307); | ||
die; | ||
|
||
break; | ||
}; | ||
|
||
json_End(); |
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