/** * @author ryan <*****@*****.**> */ function _init() { $config = $GLOBALS['config']; Sdb::setConfig($config['db']); // login $GLOBALS['user'] = $user = User::loggingUser(); // but the var here should be long such as $logging_user if ($user === false) { $has_login = false; } else { $has_login = true; } $GLOBALS['has_login'] = $has_login; // login check $controller = $GLOBALS['controller']; if (in_array($controller, $config['login_page']) && !$has_login) { redirect("login?back={$controller}/{$target}"); } $GLOBALS['nav'] = $navs = build_nav($config['navs']['admin']); $page['description'] = $config['description']; $page['keywords'] = $config['keywords']; }
<?php !defined('IN_PTF') && exit('ILLEGAL EXECUTION'); /** * @file init * @author ryan <*****@*****.**> */ // db config Pdb::setConfig($config['db']); // login $user = User::loggingUser(); // but the var here should be long such as $logging_user if ($user === false) { $has_login = false; } else { $has_login = true; $user_type = $user->type; $type = strtolower($user_type); // $type is a temp var ${$type} = $user->instance(); switch ($user_type) { case 'Customer': $cart = $customer->cart(); break; case 'Admin': case 'SuperAdmin': $page['styles'][] = 'admin'; break; default: throw new Exception('unrecognize type: ' . $user_type); break;