2015-07-15 11:42:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Router
|
|
|
|
*
|
|
|
|
* (only displayable pages here)
|
|
|
|
*/
|
|
|
|
class Router
|
|
|
|
{
|
2018-06-08 12:50:49 +02:00
|
|
|
public static $AJAX_THUMB_UPDATE = 'ajax_thumb_update';
|
|
|
|
|
2015-07-15 11:42:15 +02:00
|
|
|
public static $PAGE_LOGIN = 'login';
|
|
|
|
|
|
|
|
public static $PAGE_PICWALL = 'picwall';
|
|
|
|
|
|
|
|
public static $PAGE_TAGCLOUD = 'tagcloud';
|
|
|
|
|
2017-03-25 15:59:01 +01:00
|
|
|
public static $PAGE_TAGLIST = 'taglist';
|
|
|
|
|
2015-12-07 11:25:11 +01:00
|
|
|
public static $PAGE_DAILY = 'daily';
|
|
|
|
|
2016-03-10 18:48:21 +01:00
|
|
|
public static $PAGE_FEED_ATOM = 'atom';
|
|
|
|
|
|
|
|
public static $PAGE_FEED_RSS = 'rss';
|
|
|
|
|
2015-07-15 11:42:15 +02:00
|
|
|
public static $PAGE_TOOLS = 'tools';
|
|
|
|
|
|
|
|
public static $PAGE_CHANGEPASSWORD = 'changepasswd';
|
|
|
|
|
|
|
|
public static $PAGE_CONFIGURE = 'configure';
|
|
|
|
|
|
|
|
public static $PAGE_CHANGETAG = 'changetag';
|
|
|
|
|
|
|
|
public static $PAGE_ADDLINK = 'addlink';
|
|
|
|
|
|
|
|
public static $PAGE_EDITLINK = 'edit_link';
|
|
|
|
|
2016-11-05 14:13:18 +01:00
|
|
|
public static $PAGE_DELETELINK = 'delete_link';
|
|
|
|
|
2015-07-15 11:42:15 +02:00
|
|
|
public static $PAGE_EXPORT = 'export';
|
|
|
|
|
|
|
|
public static $PAGE_IMPORT = 'import';
|
|
|
|
|
2015-11-13 19:32:35 +01:00
|
|
|
public static $PAGE_OPENSEARCH = 'opensearch';
|
|
|
|
|
2015-07-15 11:42:15 +02:00
|
|
|
public static $PAGE_LINKLIST = 'linklist';
|
|
|
|
|
2015-11-18 17:40:42 +01:00
|
|
|
public static $PAGE_PLUGINSADMIN = 'pluginadmin';
|
|
|
|
|
|
|
|
public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin';
|
|
|
|
|
2018-06-08 12:50:49 +02:00
|
|
|
public static $PAGE_THUMBS_UPDATE = 'thumbs_update';
|
|
|
|
|
2017-03-25 15:54:18 +01:00
|
|
|
public static $GET_TOKEN = 'token';
|
|
|
|
|
2015-07-15 11:42:15 +02:00
|
|
|
/**
|
|
|
|
* Reproducing renderPage() if hell, to avoid regression.
|
|
|
|
*
|
|
|
|
* This highlights how bad this needs to be rewrite,
|
|
|
|
* but let's focus on plugins for now.
|
|
|
|
*
|
|
|
|
* @param string $query $_SERVER['QUERY_STRING'].
|
|
|
|
* @param array $get $_SERVER['GET'].
|
|
|
|
* @param bool $loggedIn true if authenticated user.
|
|
|
|
*
|
2016-03-12 16:08:01 +01:00
|
|
|
* @return string page found.
|
2015-07-15 11:42:15 +02:00
|
|
|
*/
|
|
|
|
public static function findPage($query, $get, $loggedIn)
|
|
|
|
{
|
|
|
|
$loggedIn = ($loggedIn === true) ? true : false;
|
|
|
|
|
|
|
|
if (empty($query) && !isset($get['edit_link']) && !isset($get['post'])) {
|
|
|
|
return self::$PAGE_LINKLIST;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_LOGIN) && $loggedIn === false) {
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_LOGIN;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_PICWALL)) {
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_PICWALL;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_TAGCLOUD)) {
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_TAGCLOUD;
|
|
|
|
}
|
|
|
|
|
2017-03-25 15:59:01 +01:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_TAGLIST)) {
|
|
|
|
return self::$PAGE_TAGLIST;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_OPENSEARCH)) {
|
2015-11-13 19:32:35 +01:00
|
|
|
return self::$PAGE_OPENSEARCH;
|
|
|
|
}
|
|
|
|
|
2015-12-07 11:25:11 +01:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_DAILY)) {
|
|
|
|
return self::$PAGE_DAILY;
|
|
|
|
}
|
|
|
|
|
2016-03-10 18:48:21 +01:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_FEED_ATOM)) {
|
|
|
|
return self::$PAGE_FEED_ATOM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (startsWith($query, 'do='. self::$PAGE_FEED_RSS)) {
|
|
|
|
return self::$PAGE_FEED_RSS;
|
|
|
|
}
|
|
|
|
|
2018-06-08 12:50:49 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_THUMBS_UPDATE)) {
|
|
|
|
return self::$PAGE_THUMBS_UPDATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (startsWith($query, 'do='. self::$AJAX_THUMB_UPDATE)) {
|
|
|
|
return self::$AJAX_THUMB_UPDATE;
|
|
|
|
}
|
|
|
|
|
2015-07-15 11:42:15 +02:00
|
|
|
// At this point, only loggedin pages.
|
|
|
|
if (!$loggedIn) {
|
|
|
|
return self::$PAGE_LINKLIST;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_TOOLS)) {
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_TOOLS;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_CHANGEPASSWORD)) {
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_CHANGEPASSWORD;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_CONFIGURE)) {
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_CONFIGURE;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_CHANGETAG)) {
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_CHANGETAG;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_ADDLINK)) {
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_ADDLINK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($get['edit_link']) || isset($get['post'])) {
|
|
|
|
return self::$PAGE_EDITLINK;
|
|
|
|
}
|
|
|
|
|
2016-11-05 14:13:18 +01:00
|
|
|
if (isset($get['delete_link'])) {
|
|
|
|
return self::$PAGE_DELETELINK;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_EXPORT)) {
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_EXPORT;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_IMPORT)) {
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_IMPORT;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_PLUGINSADMIN)) {
|
2015-11-18 17:40:42 +01:00
|
|
|
return self::$PAGE_PLUGINSADMIN;
|
|
|
|
}
|
|
|
|
|
2016-05-10 23:31:41 +02:00
|
|
|
if (startsWith($query, 'do='. self::$PAGE_SAVE_PLUGINSADMIN)) {
|
2015-11-18 17:40:42 +01:00
|
|
|
return self::$PAGE_SAVE_PLUGINSADMIN;
|
|
|
|
}
|
|
|
|
|
2017-03-25 15:54:18 +01:00
|
|
|
if (startsWith($query, 'do='. self::$GET_TOKEN)) {
|
|
|
|
return self::$GET_TOKEN;
|
|
|
|
}
|
|
|
|
|
2015-07-15 11:42:15 +02:00
|
|
|
return self::$PAGE_LINKLIST;
|
|
|
|
}
|
2016-08-13 14:22:22 +02:00
|
|
|
}
|