$value) { if(strtoupper($header) == 'X-FORWARDED-FOR') { $_SERVER['REMOTE_ADDR'] = $value; } } } require_once 'framework.php'; main(); safe_exit(); function main() { if($_SERVER['HTTP_HOST'] != 'www.tonic.com' && defined('IS_PRODUCTION')) { web::redirect('http://www.tonic.com' . $_SERVER['REQUEST_URI'], true); } if(web::is_mobile() && web::get_path(0) != 'mobile' && !isset($_COOKIE['already_mobile'])) { web::redirect('/mobile/'); } user::init(); web::append_title('Tonic'); // route $paths[''] = 'home'; $paths['t'] = 'index'; $paths['user'] = 'user'; $paths['profile'] = 'profile'; $paths['me'] = 'user'; $paths['all'] = 'all'; $paths['following'] = 'following'; $paths['forgot'] = 'forgot'; $paths['social'] = 'social'; $paths['stats'] = 'stats'; $paths['post'] = 'post'; $paths['deed'] = 'action'; $paths['p'] = 'action'; $paths['images'] = 'images'; $paths['placement'] = 'placement'; $paths['tag'] = 'tag'; $paths['mobile'] = 'mobile'; $paths['edit'] = 'post'; $paths['login'] = 'login'; $paths['about'] = 'about'; foreach($paths as $path => $view) { if(web::get_path(0) == $path) { echo run_view($view); return; } } if(web::get_path(0) == 'images' || web::get_path(0) == 'image') { web::redirect('http://images.tonic.com/legacy_all/' . web::get_path(1), true); } if(web::get_path(0) == 'file') { web::redirect('http://images.tonic.com/legacy/' . web::get_path(1) . '.jpg', true); } if(web::get_path(0) == 'imagetext') { web::redirect('http://images.tonic.com/legacy_all/' . web::get_path(1), true); } if(web::get_path(0) == 'article') { web::redirect('http://blog.tonic.com/' . web::get_path(1), true); } if(web::get_path(0) == 'deed') { web::redirect('http://www.tonic.com/p/' . web::get_path(1), true); } $profiles = array_flip(array( 'people', 'cause', 'subject', 'placeholder', 'company', 'place', )); if(isset($profiles[web::get_path(0)])) { web::redirect('/t/' . web::get_path(1) . '/', true); } echo run_view('404'); } function PAGE_START() { ob_start(); define('IS_HTML_PAGE', 1); ?> <?=web::output_title()?> " /> 0) { ?> $value) { ?> $value) { ?>
"; } echo debug::write_query_log(); return ob_get_clean(); } function run_view($file) { try { ob_start(); $start_time = microtime(true); include_once rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../view/view.' . $file . '.php'; $body = ob_get_clean(); return PAGE_START() . $body . PAGE_END() . output_general_info(); } catch (Exception $e) { } }