'.Misc::GetRequest('csrf_token')); Misc::Redirect('/', Misc::RedirectTemp); } //init translation Translate::Init(); //user handling if (IsSet($_SESSION['usr_id']) && $_SESSION['usr_id'] != '') { $GLOBALS['user'] = new UserLib($_SESSION['usr_id']); } else { UserLib::Autologin(); } $class = (Misc::GetRequest('comp')!=''?Misc::GetRequest('comp'):'glob'); $method = (Misc::GetRequest('action')!=''?Misc::GetRequest('action'):'index'); //enable debug? $_SESSION['debug'] = (IsSet($_SESSION['debug'])?$_SESSION['debug']:false); if ($_SESSION['debug'] && UserLib::IsGroupAdmin()) { DB::$debug = true; } //"paywall", prevent access to most pages or go on and check if we should output view if (!UserLib::IsLoggedIn() && !in_array($class.'_'.$method, $GLOBALS['public_pages']) && strpos($_SERVER['REQUEST_URI'], '/api/') !== 0) { Misc::Redirect('/usr/login.htm?referer='.urlencode($_SERVER['REQUEST_URI'])); exit(); } else if (Misc::GetRequest('output') == 'false' || strpos($_SERVER['REQUEST_URI'], '/api/') === 0) { $GLOBALS['render_page'] = false; } else { $GLOBALS['render_page'] = true; } if (file_exists($_SERVER['DOCUMENT_ROOT'].'/models/'.$class.'.php')) { require_once($_SERVER['DOCUMENT_ROOT'].'/models/'.$class.'.php'); $model = new $class(); if (method_exists($model,$method)) { if ($GLOBALS['render_page']) { if (file_exists($_SERVER['DOCUMENT_ROOT'].'/views/'.$class.'_'.$method.'.tpl')) { RenderPage($_SERVER['DOCUMENT_ROOT'].'/views/'.$class.'_'.$method.'.tpl',$model->$method(),(Misc::GetRequest('standalone')=='true'?true:false)); } else { Misc::Redirect($GLOBALS['lang_pfx'].'/error.htm'); } } else { $model->$method(); } } else { Misc::Redirect($GLOBALS['lang_pfx'].'/error.htm'); } } else { Misc::Redirect($GLOBALS['lang_pfx'].'/error.htm'); } function RenderPage($view,$vars,$standalone) { extract($vars,EXTR_PREFIX_ALL,'tpl'); if (!IsSet($tpl_msg_success) && Misc::GetRequest('msg_success') != '') { $tpl_msg_success = urldecode(Misc::GetRequest('msg_success')); } if (!IsSet($tpl_msg_error) && Misc::GetRequest('msg_error') != '') { $tpl_msg_error = urldecode(Misc::GetRequest('msg_error')); } if (!IsSet($tpl_msg_success) && IsSet($_SESSION['msg_success']) && $_SESSION['msg_success'] != '') { $tpl_msg_success = $_SESSION['msg_success']; unset($_SESSION['msg_success']); } if (!IsSet($tpl_msg_error) && IsSet($_SESSION['msg_error']) && $_SESSION['msg_error'] != '') { $tpl_msg_error = $_SESSION['msg_error']; unset($_SESSION['msg_error']); } //set headers? if (IsSet($tpl_ov_no_index) && $tpl_ov_no_index == '1') { header('X-Robots-Tag: noindex'); } if (!$standalone) { require_once($_SERVER['DOCUMENT_ROOT'].'/includes/header.inc.php'); } require_once($view); if (!$standalone) { require_once($_SERVER['DOCUMENT_ROOT'].'/includes/footer.inc.php'); } } ?>