function log_out($type = 'user') { return FW4_User::log_out($type); }
private static function route() { // Set the PHP locale to correspond to our defined language. if (language() == 'en') { setlocale(LC_ALL, 'en_US'); } else { if (language() == 'nl') { setlocale(LC_ALL, 'nl_BE'); } else { if (language() == 'fr') { setlocale(LC_ALL, 'fr_FR'); } else { if (language() == 'de') { setlocale(LC_ALL, 'de_DE'); } } } } // Show the login page if requested if (segment(0) == 'login') { return self::login(); } // Show the forgot pass page if requested if (segment(0) == 'forgot') { return self::forgotpass(); } // Show the forgot pass page if requested if (segment(0) == 'reset-password' && strlen(segment(1)) > 24 && ($user = where('password_code = %s', segment(1))->get_row('user'))) { return self::resetpass($user); } // Rebuild search index if requested if (segment(0) == 'rebuild_search_index') { FW4_Structure::rebuild_search_index(); redirect(url(ADMINDIR, false)); } // User should be logged in. If not, demand login. if (!FW4_User::is_logged_in()) { redirect(url(ADMINDIR . '/login', false)); } // User is logged in. Make sure he's an admin. if (!FW4_User::is_admin()) { FW4_User::log_out(); redirect(url(ADMINDIR . '/login', false)); } // Log out if requested if (segment(0) == 'logout') { FW4_User::log_out(); redirect(url(ADMINDIR . '/login', false)); } // If not viewing any specific page. Redirect to the first one. // If at some point we'd like to implement a dashboard, this would be the place to show it. if (!count(segments())) { $pages = self::get_pages(); $page = array_shift($pages); redirect(url(ADMINDIR . '/' . $page['name'], false)); } // If the user is viewing a special page (like a popup), show it. if (substr(segment(0), 0, 1) == '_' && file_exists(BASEPATH . 'admin/special/' . substr(segment(0), 1) . '.php')) { include BASEPATH . 'admin/special/' . substr(segment(0), 1) . '.php'; return true; } // Check if this is an AJAX request. if (substr(segment(0), 0, 5) == 'ajax_') { $segments = segments(); call_user_func_array(get_class() . '::' . array_shift($segments), $segments); return true; } return self::handle_item(segments()); }