Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL | E_STRICT);
- ini_set('display_startup_errors', 1);
- ini_set('display_errors', 1);
- require_once(APPLICATION . '/login.php');
- $denySections = array();
- $ajaxSections = array('ajaxlogout', 'ajaxlogin');
- $excludeSections = array('login' => 1, 'logout' => 1);
- $globalSections = $data['main_menu']; // Pull section data from languages files
- $memberSections = $data['members_menu'];
- $activatedSections = $data['active_menu'];
- $adminSections = $data['admin_menu'];
- $categories = array('member', 'admin');
- if (in_array($section, $ajaxSections)) {
- include(ROOT . "/ajax/$section.php");
- return;
- }
- $default = new Skin('home.html', '/templates');
- $default->setMenuStructure('ul', '', '<li class="{class}"><a href="{anchor}">{text}</a></li>');
- //if (isset($excludeSections[$section])):
- if (isset($_POST['action'])) {
- switch($_POST['action']) {
- case 'login':
- $l = Login::getInstance();
- if (defined('LOGIN') && LOGIN == false) {
- $default->set('error', 'Login is currently disabled');
- $default->setInclude('content_page', 'error.html');
- break;
- }
- if ($l->isLogged()) {
- $default->set('error', 'You are already logged in');
- $default->setInclude('content_page', 'error.html');
- break;
- }
- $user = (isset($_POST['username']) ? $_POST['username'] : '');
- $pass = (isset($_POST['password']) ? $_POST['password'] : '');
- if (!$l->validUser($user) || !$l->validPass($pass))
- $result = false;
- else
- $result = $l->Process($user, $pass, true);
- if ($result === true)
- $default->setInclude('content_page', 'main.html');
- else {
- $default->set('error', 'Invalid Credentials');
- $default->setInclude('content_page', 'error.html');
- }
- break;
- case 'logout':
- Login::getInstance()->Logout();
- default:
- break; // will ultimately show the home page
- }
- }
- // if access = 0 check if page is login (Or any guest only pages)
- $access = (Login::getInstance()->isLogged() == true ? Session::getInstance()->get('account_status') : GUEST);
- $homePage = 'main.html';
- if (is_int($access) && $access > 0) {
- $default->setInclude('login', 'logged.html');
- $removeLinks = array('aanmelden', 'inloggen');
- switch ($access) {
- case MEMBER:
- $globalSections = array_merge($globalSections, $memberSections);
- $default->addMenu('members_menu');
- $homePage = 'member/activate.html';
- $default->set('top_display', 'block');
- break;
- case ACTIVATED:
- $globalSections = array_merge($globalSections, $activatedSections);
- $default->addMenu('active_menu');
- $homePage = 'member/main.html';
- $default->set('top_display', 'none');
- break;
- case ADMIN:
- $globalSections = array_merge($globalSections, $activatedSections, $adminSections);
- $default->addMenu('admin_menu');
- $default->addMenu('active_menu');
- $default->set('top_display', 'none');
- $homePage = 'admin/main.html';
- break;
- default:
- $homePage = 'main.html';
- }
- } else {
- if (defined('SHOW_LOGIN') && SHOW_LOGIN == true)
- $default->setInclude('login', 'login.html');
- $homePage = 'main.html';
- }
- $default->addMenu('main_menu');
- if (isset($removeLinks) && count($removeLinks) > 0)
- $data['main_menu'] = array_diff_key($data['main_menu'],array_flip($removeLinks));
- $default->translate($data);
- $default->setViewAccess($access);
- $default->set('logged', ($access > 0 ? true : false)); // Login::getInstance()->isLogged()
- if (!$default->_isincluded('content_page')) {
- if (count($arrSection) > 2 && in_array($section, $categories) && isset($globalSections[$arrSection[2]]))
- $section = next($arrSection); // update pointer and get correct page if were in a sub cat
- if (!in_array($section, $denySections) && isset($globalSections[$section])) {
- $s = $globalSections[$section];
- $default->setInclude('content_page', $s['path'], $s['cache'], $s['view']);
- }
- else $default->setInclude('content_page', $homePage);
- }
- $tSection = (isset($globalSections[$section]) ? $section : 'home');
- $default->set('title', ucfirst($tSection) . ' :: ' . (defined('TITLE') ? TITLE : 'I haven\'t configured this site properly!'));
- $default->show();
- ?>
Add Comment
Please, Sign In to add comment