getRoute(); /* * * Handle SSL options * ********************************************************/ $serv=strtolower($_SERVER["SERVER_NAME"]); if (!isset($thisRoute['ssl'])) { if ($_SERVER['HTTPS']!='' && $_SERVER['HTTPS']!='off') header('Location: http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']); } else { if (gettype($thisRoute['ssl'])=='string' && $thisRoute['ssl']=='either') { // do nothing } else if (gettype($thisRoute['ssl'])=='boolean' && $thisRoute['ssl']==false) { // do nothing header('Location: http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']); } else { if (is_array($CONFIG['SSLAvailable']) && isset($thisRoute['ssl']) && ($thisRoute['ssl']==true)) { if (in_array($serv,$CONFIG['SSLAvailable']) && ($_SERVER['HTTPS']=='' || $_SERVER['HTTPS']=='off')) { header('Location: https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']); exit; } } else if (!isset($thisRoute['ssl']) && ($_SERVER['HTTPS']!='' && $_SERVER['HTTPS']!='off')) { header('Location: http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']); exit; } } } // Convenience arrays $routeParts=$route->getRouteArray(); $allRoutes=$route->getRouteArray(); if (isset($_GET['logout'])) { dlog('unset cookie: qpuser',5); unset($userData); setcookie('qpuser',NULL,0,'/'); session_destroy(); $_SESSION['twitterLogin']=NULL; $loggedIn=null; $_SESSION['loggedIn']=NULL; unset($_SESSION); } // Controllers are optional if (isset($thisRoute['login'])) { if (!$userData) { header('Location: /login'); exit; } } $pageNotFound = false; if (isset($thisRoute['isAdmin'])) { if (!$userData) { $pageNotFound=true; } else { if (!isAdmin()) { $pageNotFound=true; } } } if (isset($thisRoute['browser'])) { if (!isset($_COOKIE['browserMismatch']) || $_COOKIE['browserMismatch']!='allow') { if (!checkBrowser($thisRoute['browser'])) { if (isset($thisRoute['browserMismatch'])) { header('Location: '.$thisRoute['browserMismatch']); exit; } } } } if ($pageNotFound || !$thisRoute) { header("Status: 404 Not Found"); header("HTTP/1.0 404 Not Found"); $thisRoute['route']='404'; $thisRoute['template']='page'; $thisRoute['header']=false; } else { # Strings: route default if (file_exists('strings/'.$thisRoute['route'].'Strings.php')) include 'strings/'.$thisRoute['route'].'Strings.php'; # Strings: defined in route if (isset($thisRoute['strings'])) { if (!is_array($thisRoute['strings'])) $thisRoute['strings']=Array($thisRoute['strings']); foreach($thisRoute['strings'] as $thisInclude) { if (file_exists('strings/'.$thisInclude.'Strings.php')) include 'strings/'.$thisInclude.'Strings.php'; } } # Class: route default if (file_exists('class/'.$thisRoute['route'].'Class.php')) include 'class/'.$thisRoute['route'].'Class.php'; # Functions: route default if (file_exists('function/'.$thisRoute['route'].'Functions.php')) include 'function/'.$thisRoute['route'].'Functions.php'; # Functions: defined in route if (isset($thisRoute['functions'])) { if (!is_array($thisRoute['functions'])) $thisRoute['functions']=Array($thisRoute['functions']); foreach($thisRoute['functions'] as $thisInclude) { if (file_exists('function/'.$thisInclude.'Functions.php')) include 'function/'.$thisInclude.'Functions.php'; } } # Controller: route default if (file_exists('controller/'.$thisRoute['route'].'Controller.php')) include 'controller/'.$thisRoute['route'].'Controller.php'; if (!$loadModels) { if (is_array($models)) { // load models foreach($models as $thisModel) { include 'model/'.$thisModel.'.php'; } } } } // Page Titles if (isset($thisRoute['pageTitle'])) { $pageMetaTitle = $thisRoute['pageTitle'] . ' – RinkGeek'; } if (!file_exists('templates/'.$thisRoute['template'].'.tmpl.php')) { header("Status: 404 Not Found"); header("HTTP/1.0 404 Not Found"); print "RinkGeek: bad configuration"; $msg="SERVER: \n".print_r($_SERVER,true); mail('dev@d27n.com', 'Bad Request', $msg, 'From: system@rinkgeek.com\r\n'); exit; } else { require_once('templates/'.$thisRoute['template'].'.tmpl.php'); } ?>