# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . class router { function router () { ob_start('ob_gzhandler'); ob_start('do_header'); register_shutdown_function('do_footer'); $this->route(); } function route () { if (defined('SHARED_HOST')) { if (!$_SERVER['PATH_INFO']) $route = $_SERVER['ORIG_PATH_INFO']; else if (!$_SERVER['ORIG_PATH_INFO']) $route = $_SERVER['PHP_SELF']; else $route = $_SERVER['PATH_INFO']; } else $route = $_SERVER['PATH_INFO']; $route = ereg_replace('^\/', '', $route); $route = ereg_replace('\/$', '', $route); if(empty($route)) $route = 'home'; $this->route_request($route); } function route_request($route) { @list($MODULE, $PARAMS, $EXTRA) = explode('/', $route, 3); define('MODULE', $MODULE); define('PARAMS', $PARAMS); define('EXTRA', $EXTRA); switch(MODULE) { case 'home': $file = 'pages/homepage.php'; break; case 'api': $file = 'includes/api_old.php'; break; case 'register': $file = 'pages/register.php'; break; case 'login': $file = 'pages/login.php'; break; case 'logout': $file = 'pages/logout.php'; break; case 'notes': case 'public': $file = 'pages/notes.php'; break; case 'settings': $file = 'pages/settings.php'; break; case 'ajax': $file = 'pages/ajax.php'; break; case 'post': $file = 'pages/post.php'; break; case 'tag': $file = 'pages/tag.php'; break; case 'statuses': case 'favorites': case 'favorites.json': case 'favorites.xml': case 'followers': case 'favorites.rss': case 'direct_messages': case 'direct_messages.json': case 'direct_messages.xml': case 'direct_messages.rss': case 'account': case 'users': case 'followers': case 'friends': $file = 'includes/api.php'; break; case 'download': $file = 'pages/download.php'; break; case 'cron': $file = 'pages/cron.php'; break; case 'search': $file = 'pages/search.php'; break; case 'following': $file = 'pages/following.php'; break; case 'my_followers': $file = 'pages/followers.php'; break; case 'rss': $file = 'pages/rss.php'; break; case 'invite': $file = 'pages/invite.php'; break; case 'report': $file = 'pages/report.php'; break; case 'mobile': $file = 'pages/mobile.php'; break; case 'faq': $file = 'pages/faq.php'; break; case 'tos': $file = 'tos.php'; break; case 'trouble_login': $file = 'pages/trouble_login.php'; break; default: $file = 'pages/user.php'; break; } require $file; } } ?>