2017-10-21 23:04:06 +02:00
|
|
|
<?php
|
|
|
|
|
2017-11-09 17:43:34 +01:00
|
|
|
require_once (__DIR__ . '/internals/base.php');
|
|
|
|
|
|
|
|
$URL_RULES =
|
|
|
|
[
|
|
|
|
[ 'url' => [], 'target' => 'pages/main.php', 'options' => [], ],
|
|
|
|
[ 'url' => ['index'], 'target' => 'pages/main.php', 'options' => [], ],
|
|
|
|
[ 'url' => ['index.php'], 'target' => 'pages/main.php', 'options' => [], ],
|
|
|
|
[ 'url' => ['msmain', 'index'], 'target' => 'pages/main.php', 'options' => [], ],
|
|
|
|
[ 'url' => ['about'], 'target' => 'pages/about.php', 'options' => [], ],
|
|
|
|
[ 'url' => ['msmain', 'about'], 'target' => 'pages/about.php', 'options' => [], ],
|
2018-01-21 19:35:49 +01:00
|
|
|
[ 'url' => ['login'], 'target' => 'pages/login.php', 'options' => [ 'login_target' => '/' ], ],
|
|
|
|
[ 'url' => ['logout'], 'target' => 'pages/logout.php', 'options' => [ 'logout_target' => '/' ], ],
|
2018-01-21 19:07:43 +01:00
|
|
|
|
2017-11-09 17:43:34 +01:00
|
|
|
[ 'url' => ['programs'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '' ], ],
|
|
|
|
[ 'url' => ['programs', 'index'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['programs', 'index'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '' ], ],
|
|
|
|
[ 'url' => ['programs', 'cat', '?{categoryfilter}'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '%URL%' ], ],
|
|
|
|
[ 'url' => ['downloads', 'details.php'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '' ], ],
|
|
|
|
[ 'url' => ['downloads', 'downloads.php'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '' ], ],
|
|
|
|
[ 'url' => ['programs', 'view', '?{id}'], 'target' => 'pages/programs_view.php', 'options' => [ 'id' => '%URL%' ], ],
|
|
|
|
[ 'url' => ['programs', 'view'], 'target' => 'pages/programs_view.php', 'options' => [ 'id' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['downloads', '?{id}'], 'target' => 'pages/programs_download.php', 'options' => [ 'id' => '%URL%' ], ],
|
|
|
|
[ 'url' => ['programs', 'download', '?{id}'], 'target' => 'pages/programs_download.php', 'options' => [ 'id' => '%URL%' ], ],
|
|
|
|
[ 'url' => ['programs', 'download'], 'target' => 'pages/programs_download.php', 'options' => [ 'id' => '%GET%' ], ],
|
2018-01-27 18:13:38 +01:00
|
|
|
|
|
|
|
[ 'url' => ['books'], 'target' => 'pages/books_list.php', 'options' => [], ],
|
|
|
|
[ 'url' => ['books', 'list'], 'target' => 'pages/books_list.php', 'options' => [], ],
|
|
|
|
[ 'url' => ['books', 'view', '?{id}'], 'target' => 'pages/books_view.php', 'options' => [ 'id' => '%GET%' ], ],
|
2018-01-28 01:29:25 +01:00
|
|
|
[ 'url' => ['books', 'view', '?{id}', '*'], 'target' => 'pages/books_view.php', 'options' => [ 'id' => '%URL%' ], ],
|
2018-01-27 18:13:38 +01:00
|
|
|
|
2018-02-03 13:47:38 +01:00
|
|
|
[ 'url' => ['update.php'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['update.php', '?{Name}'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%URL%' ], ],
|
|
|
|
[ 'url' => ['update'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['update', '?{Name}'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%URL%' ], ],
|
|
|
|
[ 'url' => ['update2'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['api', 'update'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['api', 'update', '?{Name}'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%URL%' ], ],
|
|
|
|
[ 'url' => ['api', 'test'], 'target' => 'pages/api_test.php', 'options' => [ '_opt' => 'http', ], ],
|
|
|
|
[ 'url' => ['api', 'setselfadress'], 'target' => 'pages/api_setselfadress.php', 'options' => [ '_opt' => 'http', ], ],
|
|
|
|
[ 'url' => ['api', 'statsping'], 'target' => 'pages/api_stats.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%', 'ClientID' => '%GET%', 'Version' => '%GET%', 'ProviderStr' => '%GET%', 'ProviderID' => '%GET%', 'NoteCount' => '%GET%', ], ],
|
2018-02-03 16:35:32 +01:00
|
|
|
[ 'url' => ['api', 'webhook', '?{target}'], 'target' => 'pages/api_webhook.php', 'options' => [ '_opt' => 'http', 'target' => '%URL%', 'secret' => '%GET%', ],],
|
2018-03-03 16:12:44 +01:00
|
|
|
[ 'url' => ['api', 'backupupload'], 'target' => 'pages/api_backupupload.php', 'options' => [ '_opt' => 'http', 'folder' => '%GET%', 'filename' => '%GET%', 'secret' => '%GET%', ],],
|
2018-01-21 19:07:43 +01:00
|
|
|
|
|
|
|
[ 'url' => ['admin'], 'target' => 'pages/admin.php', 'options' => [ '_opt' => 'password'], ],
|
2018-02-03 15:44:40 +01:00
|
|
|
[ 'url' => ['admin', 'updateslog', '${name}'], 'target' => 'pages/admin_ul-list.php', 'options' => [ '_opt' => 'password', 'name' => '%URL%'],],
|
2018-01-27 14:21:34 +01:00
|
|
|
[ 'url' => ['admin', 'cmd', '?{cmd}'], 'target' => 'pages/admin_cmd.php', 'options' => [ '_opt' => 'password', 'cmd' => '%URL%'], ],
|
2018-01-27 00:28:32 +01:00
|
|
|
[ 'url' => ['admin', 'egh', '?{cmd}'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => 'egh', 'cmd' => '%URL%', 'secret' => '%GET%' ], ],
|
2018-01-27 14:21:34 +01:00
|
|
|
|
2018-02-03 13:47:38 +01:00
|
|
|
[ 'url' => ['su_ajax', '?{cmd}'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => '', 'cmd' => '%URL%', 'secret' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['su_ajax'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => '', 'cmd' => '%GET%', 'secret' => '%GET%' ], ],
|
2017-12-30 23:11:51 +01:00
|
|
|
|
2017-11-09 17:43:34 +01:00
|
|
|
[ 'url' => ['blog'], 'target' => 'pages/blog_list.php', 'options' => [], ],
|
2017-12-30 23:11:51 +01:00
|
|
|
[ 'url' => ['log'], 'target' => 'pages/blog_list.php', 'options' => [], ],
|
2017-11-09 17:43:34 +01:00
|
|
|
[ 'url' => ['blogpost', 'index'], 'target' => 'pages/blog_list.php', 'options' => [], ],
|
|
|
|
[ 'url' => ['blog', '?{id}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ],
|
|
|
|
[ 'url' => ['blog', '?{id}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ],
|
|
|
|
[ 'url' => ['blog', '?{id}', '?{name}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ],
|
|
|
|
[ 'url' => ['blog', '?{id}', '?{name}', '?{subview}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '%URL%' ], ],
|
2017-12-30 23:11:51 +01:00
|
|
|
[ 'url' => ['log', '?{id}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ],
|
|
|
|
[ 'url' => ['log', '?{id}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ],
|
|
|
|
[ 'url' => ['log', '?{id}', '?{name}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ],
|
|
|
|
[ 'url' => ['log', '?{id}', '?{name}', '?{subview}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '%URL%' ], ],
|
2017-11-09 17:43:34 +01:00
|
|
|
[ 'url' => ['blogpost', 'view'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%GET%', 'subview' => '' ], ],
|
2018-05-13 15:46:13 +02:00
|
|
|
|
|
|
|
[ 'url' => ['webapps'], 'target' => 'pages/webapps_list.php', 'options' => [], ],
|
|
|
|
|
2018-02-03 13:47:38 +01:00
|
|
|
[ 'url' => ['highscores', 'list.php'], 'target' => 'pages/highscores_listentries.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['highscores', 'list'], 'target' => 'pages/highscores_listentries.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['highscores', 'listentries'], 'target' => 'pages/highscores_listentries.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['highscores', 'list.php'], 'target' => 'pages/highscores_listgames.php', 'options' => [ '_opt' => 'http' ], ],
|
|
|
|
[ 'url' => ['highscores', 'list'], 'target' => 'pages/highscores_listgames.php', 'options' => [ '_opt' => 'http' ], ],
|
|
|
|
[ 'url' => ['highscores', 'listgames'], 'target' => 'pages/highscores_listgames.php', 'options' => [ '_opt' => 'http' ], ],
|
|
|
|
[ 'url' => ['highscores', 'insert.php'], 'target' => 'pages/highscores_insert.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['highscores', 'insert'], 'target' => 'pages/highscores_insert.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['highscores', 'update.php'], 'target' => 'pages/highscores_update.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%', 'nameid' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['highscores', 'update'], 'target' => 'pages/highscores_update.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%', 'nameid' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['highscores', 'list_top50.php'], 'target' => 'pages/highscores_top50.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['highscores', 'list_top50'], 'target' => 'pages/highscores_top50.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['highscores', 'getNewID.php'], 'target' => 'pages/highscores_newid.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ],
|
|
|
|
[ 'url' => ['highscores', 'newid'], 'target' => 'pages/highscores_newid.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ],
|
2017-11-09 17:43:34 +01:00
|
|
|
|
|
|
|
[ 'url' => ['404'], 'target' => 'pages/error_404.php', 'options' => [], ],
|
|
|
|
];
|
|
|
|
|
|
|
|
//#############################################################################
|
|
|
|
|
2018-01-03 17:28:08 +01:00
|
|
|
try {
|
|
|
|
InitPHP();
|
2017-10-21 23:04:06 +02:00
|
|
|
|
2018-01-03 22:08:56 +01:00
|
|
|
if (isProd())
|
|
|
|
$requri = $_SERVER['REQUEST_URI'];
|
|
|
|
else
|
|
|
|
$requri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'localhost:80/';
|
|
|
|
|
|
|
|
$parse = parse_url($requri);
|
|
|
|
|
2018-01-27 14:21:34 +01:00
|
|
|
$path = isset($parse['path']) ? $parse['path'] : '';
|
2018-01-03 17:28:08 +01:00
|
|
|
$pathparts = preg_split('@/@', $path, NULL, PREG_SPLIT_NO_EMPTY);
|
|
|
|
$partcount = count($pathparts);
|
2018-01-03 01:03:43 +01:00
|
|
|
|
2018-01-03 17:28:08 +01:00
|
|
|
global $OPTIONS;
|
|
|
|
global $HEADER_ACTIVE;
|
2017-10-21 23:04:06 +02:00
|
|
|
|
2018-01-03 17:28:08 +01:00
|
|
|
$HEADER_ACTIVE = 'none';
|
|
|
|
|
|
|
|
foreach ($URL_RULES as $rule)
|
2017-11-09 17:43:34 +01:00
|
|
|
{
|
2018-01-03 17:28:08 +01:00
|
|
|
if ($partcount !== count($rule['url'])) continue;
|
|
|
|
|
|
|
|
$urlparams = [];
|
2018-02-03 17:46:31 +01:00
|
|
|
$ctrlOpt = key_exists('_opt', $rule['options']) ? explode('|', $rule['options']['_opt']) : [];
|
2018-01-21 19:07:43 +01:00
|
|
|
$target = $rule['target'];
|
2018-01-03 17:28:08 +01:00
|
|
|
|
|
|
|
$match = true;
|
|
|
|
for($i = 0; $i < $partcount; $i++)
|
2017-11-09 17:43:34 +01:00
|
|
|
{
|
2018-01-03 17:28:08 +01:00
|
|
|
$comp = $rule['url'][$i];
|
|
|
|
if (startsWith($comp, '?{') && endsWith($comp, '}'))
|
|
|
|
{
|
|
|
|
$ident = substr($comp, 2, strlen($comp)-3);
|
|
|
|
$urlparams[$ident] = $pathparts[$i];
|
|
|
|
}
|
2018-01-28 01:29:25 +01:00
|
|
|
else if ($comp === '*')
|
|
|
|
{
|
|
|
|
// ok
|
|
|
|
}
|
2018-01-03 17:28:08 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strtolower($comp) !== strtolower($pathparts[$i])) { $match = false; break; }
|
|
|
|
}
|
2017-11-09 17:43:34 +01:00
|
|
|
}
|
2018-01-03 17:28:08 +01:00
|
|
|
if (!$match) continue;
|
|
|
|
|
2018-02-03 14:43:41 +01:00
|
|
|
$opt = [ 'controllerOptions' => $ctrlOpt, 'uri' => $requri ];
|
2018-01-03 17:28:08 +01:00
|
|
|
foreach($rule['options'] as $optname => $optvalue)
|
2017-11-09 17:43:34 +01:00
|
|
|
{
|
2018-01-03 17:28:08 +01:00
|
|
|
$value = $optvalue;
|
|
|
|
|
|
|
|
if ($value === '%GET%')
|
|
|
|
{
|
|
|
|
if (!isset($_GET[$optname])) { $match = false; break; }
|
|
|
|
$value = $_GET[$optname];
|
|
|
|
}
|
|
|
|
else if ($value === '%POST%')
|
|
|
|
{
|
|
|
|
if (!isset($_POST[$optname])) { $match = false; break; }
|
|
|
|
$value = $_POST[$optname];
|
|
|
|
}
|
|
|
|
else if ($value === '%URL%')
|
|
|
|
{
|
|
|
|
if (!isset($urlparams[$optname])) { $match = false; break; }
|
2018-01-20 03:05:15 +01:00
|
|
|
$value = urldecode($urlparams[$optname]);
|
2018-01-03 17:28:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$opt[strtolower($optname)] = $value;
|
2017-11-09 17:43:34 +01:00
|
|
|
}
|
2018-01-03 17:28:08 +01:00
|
|
|
if (!$match) continue;
|
|
|
|
|
2018-02-03 14:43:41 +01:00
|
|
|
if (in_array('disabled', $ctrlOpt)) continue;
|
2018-01-21 19:07:43 +01:00
|
|
|
|
2018-02-03 14:43:41 +01:00
|
|
|
if (in_array('password', $ctrlOpt))
|
2018-01-21 19:07:43 +01:00
|
|
|
{
|
2018-01-21 19:35:49 +01:00
|
|
|
if (!isLoggedInByCookie())
|
2018-01-21 19:07:43 +01:00
|
|
|
{
|
|
|
|
$opt['login_target'] = $path;
|
|
|
|
$target = 'pages/login.php';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-03 13:47:38 +01:00
|
|
|
$is_http = (!isset($_SERVER['HTTPS'])) || empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off";
|
|
|
|
|
2018-02-03 14:43:41 +01:00
|
|
|
if (isProd() && $is_http && !in_array('http', $ctrlOpt))
|
2018-02-03 13:47:38 +01:00
|
|
|
{
|
|
|
|
ob_clean();
|
|
|
|
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
|
|
|
header('HTTP/1.1 301 Moved Permanently');
|
|
|
|
header('Location: ' . $redirect);
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2018-01-03 17:28:08 +01:00
|
|
|
$OPTIONS = $opt;
|
2018-01-21 19:07:43 +01:00
|
|
|
include $target;
|
2018-01-03 17:28:08 +01:00
|
|
|
return;
|
|
|
|
|
2017-11-09 17:43:34 +01:00
|
|
|
}
|
2018-01-03 17:28:08 +01:00
|
|
|
|
2017-11-09 17:43:34 +01:00
|
|
|
{
|
2018-01-03 17:28:08 +01:00
|
|
|
// [404] - Page Not Found
|
|
|
|
$OPTIONS = [];
|
|
|
|
httpError('404', 'Page not found');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
|
|
|
if (isProd())
|
|
|
|
{
|
2018-01-28 14:30:19 +01:00
|
|
|
sendExceptionMail($e);
|
2018-01-03 17:28:08 +01:00
|
|
|
httpError('500 ', 'Internal server error');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-22 23:45:39 +01:00
|
|
|
if (isset($e->xdebug_message)) echo '<table class="xdebug-error xe-uncaught-exception" dir="ltr" border="1" cellspacing="0" cellpadding="1">'.$e->xdebug_message.'</table>';
|
|
|
|
else echo nl2br($e);
|
2017-11-09 17:43:34 +01:00
|
|
|
}
|
|
|
|
|
2017-10-21 23:04:06 +02:00
|
|
|
}
|
2017-12-04 17:45:10 +01:00
|
|
|
|
2018-01-20 03:05:15 +01:00
|
|
|
//TODO euler insert+show 32bit | 64bit mode
|
2018-02-13 18:27:33 +01:00
|
|
|
//TODO support for different color schemes
|
|
|
|
// should be possible to change with just a few constant in config.scss
|
2018-03-03 16:12:44 +01:00
|
|
|
// a (little) bit more hue in default scheme
|