Guest User

Untitled

a guest
Jul 30th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL | E_STRICT);
  4. ini_set('display_startup_errors', 1);
  5. ini_set('display_errors', 1);
  6.  
  7. require_once(APPLICATION . '/login.php');
  8.  
  9. $denySections = array();
  10. $ajaxSections = array('ajaxlogout', 'ajaxlogin');
  11. $excludeSections = array('login' => 1, 'logout' => 1);
  12.  
  13. $globalSections = $data['main_menu']; // Pull section data from languages files
  14. $memberSections = $data['members_menu'];
  15. $activatedSections = $data['active_menu'];
  16. $adminSections = $data['admin_menu'];
  17.  
  18. $categories = array('member', 'admin');
  19.  
  20. if (in_array($section, $ajaxSections)) {
  21. include(ROOT . "/ajax/$section.php");
  22. return;
  23. }
  24.  
  25.  
  26. $default = new Skin('home.html', '/templates');
  27. $default->setMenuStructure('ul', '', '<li class="{class}"><a href="{anchor}">{text}</a></li>');
  28.  
  29. //if (isset($excludeSections[$section])):
  30. if (isset($_POST['action'])) {
  31. switch($_POST['action']) {
  32. case 'login':
  33.  
  34. $l = Login::getInstance();
  35.  
  36. if (defined('LOGIN') && LOGIN == false) {
  37. $default->set('error', 'Login is currently disabled');
  38. $default->setInclude('content_page', 'error.html');
  39. break;
  40. }
  41.  
  42. if ($l->isLogged()) {
  43. $default->set('error', 'You are already logged in');
  44. $default->setInclude('content_page', 'error.html');
  45. break;
  46. }
  47.  
  48.  
  49. $user = (isset($_POST['username']) ? $_POST['username'] : '');
  50. $pass = (isset($_POST['password']) ? $_POST['password'] : '');
  51.  
  52. if (!$l->validUser($user) || !$l->validPass($pass))
  53. $result = false;
  54. else
  55. $result = $l->Process($user, $pass, true);
  56.  
  57. if ($result === true)
  58. $default->setInclude('content_page', 'main.html');
  59. else {
  60. $default->set('error', 'Invalid Credentials');
  61. $default->setInclude('content_page', 'error.html');
  62. }
  63.  
  64. break;
  65. case 'logout':
  66. Login::getInstance()->Logout();
  67. default:
  68. break; // will ultimately show the home page
  69. }
  70. }
  71.  
  72. // if access = 0 check if page is login (Or any guest only pages)
  73. $access = (Login::getInstance()->isLogged() == true ? Session::getInstance()->get('account_status') : GUEST);
  74.  
  75. $homePage = 'main.html';
  76.  
  77. if (is_int($access) && $access > 0) {
  78. $default->setInclude('login', 'logged.html');
  79. $removeLinks = array('aanmelden', 'inloggen');
  80.  
  81. switch ($access) {
  82. case MEMBER:
  83. $globalSections = array_merge($globalSections, $memberSections);
  84. $default->addMenu('members_menu');
  85. $homePage = 'member/activate.html';
  86. $default->set('top_display', 'block');
  87. break;
  88. case ACTIVATED:
  89. $globalSections = array_merge($globalSections, $activatedSections);
  90. $default->addMenu('active_menu');
  91. $homePage = 'member/main.html';
  92. $default->set('top_display', 'none');
  93. break;
  94. case ADMIN:
  95. $globalSections = array_merge($globalSections, $activatedSections, $adminSections);
  96. $default->addMenu('admin_menu');
  97. $default->addMenu('active_menu');
  98. $default->set('top_display', 'none');
  99. $homePage = 'admin/main.html';
  100. break;
  101. default:
  102. $homePage = 'main.html';
  103. }
  104. } else {
  105. if (defined('SHOW_LOGIN') && SHOW_LOGIN == true)
  106. $default->setInclude('login', 'login.html');
  107.  
  108. $homePage = 'main.html';
  109. }
  110.  
  111. $default->addMenu('main_menu');
  112.  
  113. if (isset($removeLinks) && count($removeLinks) > 0)
  114. $data['main_menu'] = array_diff_key($data['main_menu'],array_flip($removeLinks));
  115.  
  116. $default->translate($data);
  117. $default->setViewAccess($access);
  118. $default->set('logged', ($access > 0 ? true : false)); // Login::getInstance()->isLogged()
  119.  
  120. if (!$default->_isincluded('content_page')) {
  121. if (count($arrSection) > 2 && in_array($section, $categories) && isset($globalSections[$arrSection[2]]))
  122. $section = next($arrSection); // update pointer and get correct page if were in a sub cat
  123. if (!in_array($section, $denySections) && isset($globalSections[$section])) {
  124. $s = $globalSections[$section];
  125. $default->setInclude('content_page', $s['path'], $s['cache'], $s['view']);
  126. }
  127. else $default->setInclude('content_page', $homePage);
  128. }
  129.  
  130. $tSection = (isset($globalSections[$section]) ? $section : 'home');
  131. $default->set('title', ucfirst($tSection) . ' :: ' . (defined('TITLE') ? TITLE : 'I haven\'t configured this site properly!'));
  132.  
  133. $default->show();
  134.  
  135. ?>
Add Comment
Please, Sign In to add comment