PageRenderTime 73ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/community/www/administrator.php

https://github.com/svn2github/efront-lms
PHP | 408 lines | 276 code | 37 blank | 95 comment | 103 complexity | 669856dd3003b0052e844e3d2c7b832c MD5 | raw file
Possible License(s): BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0
  1. <?php
  2. /**
  3. * Administrator main page
  4. *
  5. * This page performs all administrative functions.
  6. * @package eFront
  7. * @version 3.6.0
  8. */
  9. session_cache_limiter('none'); //Initialize session
  10. session_start();
  11. $path = "../libraries/"; //Define default path
  12. /** The configuration file.*/
  13. require_once $path."configuration.php";
  14. $benchmark = new EfrontBenchmark($debug_TimeStart);
  15. $benchmark -> set('init');
  16. //Set headers in order to eliminate browser cache (especially IE's)
  17. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  18. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  19. //pr($_SESSION);
  20. //If the page is shown as a popup, make sure it remains in such mode
  21. if (!isset($_GET['reset_popup']) && (isset($_GET['popup']) || isset($_POST['popup']) || (isset($_SERVER['HTTP_REFERER']) && strpos(strtolower($_SERVER['HTTP_REFERER']), 'popup') !== false && strpos(strtolower($_SERVER['HTTP_REFERER']), 'reset_popup') === false && !strpos(strtolower($_SERVER['HTTP_REFERER']), 'evaluation')))) {
  22. output_add_rewrite_var('popup', 1);
  23. $smarty -> assign("T_POPUP_MODE", true);
  24. $popup = 1;
  25. }
  26. $message = $message_type = $search_message = '' ; //Initialize messages, because if register_globals is turned on, some messages will be displayed twice
  27. $load_editor = false;
  28. $loadScripts = array();
  29. try {
  30. $currentUser = EfrontUser :: checkUserAccess('administrator');
  31. $smarty -> assign("T_CURRENT_USER", $currentUser);
  32. } catch (Exception $e) {
  33. if ($e -> getCode() == EfrontUserException :: USER_NOT_LOGGED_IN && !isset($_GET['ajax'])) {
  34. setcookie('c_request', htmlspecialchars_decode(basename($_SERVER['REQUEST_URI'])), time() + 300, false, false, false, true);
  35. }
  36. eF_redirect("index.php?ctg=expired");
  37. exit;
  38. }
  39. if (isset($_SESSION['s_index_comply'])) {
  40. eF_redirect("index.php?ctg=".$_SESSION['s_index_comply']);
  41. exit;
  42. }
  43. if (!isset($_GET['ajax']) && !isset($_GET['postAjaxRequest']) && !isset($popup) && !isset($_GET['tabberajax'])) {
  44. $_SESSION['previousMainUrl'] = $_SERVER['REQUEST_URI'];
  45. }
  46. if (isset($_COOKIE['c_request']) && $_COOKIE['c_request']) {
  47. setcookie('c_request', '', time() - 86400);
  48. if (mb_strpos($_COOKIE['c_request'], '.php') !== false) {
  49. $urlParts = parse_url($_COOKIE['c_request']);
  50. if (basename($urlParts['path']) == 'administrator.php') {
  51. eF_redirect($_COOKIE['c_request']);
  52. }
  53. } else {
  54. eF_redirect($_SESSION['s_type'].'.php?'.$_COOKIE['c_request']);
  55. }
  56. }
  57. $smarty->assign("T_HOME_LINK", "administrator.php"); //leave here for modules to know
  58. try {
  59. $loadedModules = $currentUser -> getModules();
  60. $module_css_array = array();
  61. $module_js_array = array();
  62. // Include module languages
  63. foreach ($loadedModules as $module) {
  64. // The $setLanguage variable is defined in globals.php
  65. $mod_lang_file = $module -> getLanguageFile($setLanguage);
  66. if (is_file ($mod_lang_file)) {
  67. require_once $mod_lang_file;
  68. }
  69. // Get module css
  70. if($mod_css_file = $module -> getModuleCSS()) {
  71. if (is_file ($mod_css_file)) {
  72. // Get the relative path
  73. if ($position = strpos($mod_css_file, "modules")) {
  74. $mod_css_file = substr($mod_css_file, $position);
  75. }
  76. $module_css_array[] = $mod_css_file;
  77. }
  78. }
  79. // Get module js
  80. if($mod_js_file = $module -> getModuleJS()) {
  81. if (is_file($mod_js_file)) {
  82. // Get the relative path
  83. if ($position = strpos($mod_js_file, "modules")) {
  84. $mod_js_file = substr($mod_js_file, $position);
  85. }
  86. $module_js_array[] = $mod_js_file;
  87. }
  88. }
  89. // Run onNewPageLoad code of the module (if such is defined)
  90. $module -> onNewPageLoad();
  91. }
  92. } catch (Exception $e) {
  93. handleNormalFlowExceptions($e);
  94. }
  95. /*Added Session variable for search results*/
  96. $_SESSION['referer'] = $_SERVER['REQUEST_URI'];
  97. /*Horizontal menus*/
  98. $onlineUsers = EfrontUser :: getUsersOnline($GLOBALS['configuration']['autologout_time'] * 60);
  99. if ($GLOBALS['currentTheme'] -> options['sidebar_interface']) {
  100. $smarty -> assign("T_ONLINE_USERS_LIST", $onlineUsers);
  101. if ($accounts = unserialize($currentUser -> user['additional_accounts'])) {
  102. $result = eF_getTableData("users", "login, user_type", 'login in ("'.implode('","', array_values($accounts)).'")');
  103. $smarty -> assign("T_MAPPED_ACCOUNTS", $result);
  104. }
  105. }
  106. refreshLogin();//Important: It must be called AFTER EfrontUser :: getUsersOnline
  107. !isset($_GET['ctg']) || !eF_checkParameter($_GET['ctg'], 'alnum_general') ? $ctg = "control_panel" : $ctg = $_GET['ctg'];
  108. $smarty -> assign("T_CTG", $ctg); //As soon as we derive the current ctg, assign it to smarty.
  109. $smarty -> assign("T_OP", isset($_GET['op']) ? $_GET['op'] : false);
  110. //Create shorthands for user type, to avoid long variable names
  111. $_student_ = $_professor_ = $_admin_ = 0;
  112. if ((isset($_SESSION['s_lesson_user_type']) && $_SESSION['s_lesson_user_type'] == 'student') || (!isset($_SESSION['s_lesson_user_type']) && $_SESSION['s_type'] == 'student')) {
  113. $_student_ = 1;
  114. } else if ((isset($_SESSION['s_lesson_user_type']) && $_SESSION['s_lesson_user_type'] == 'professor') || (!isset($_SESSION['s_lesson_user_type']) && $_SESSION['s_type'] == 'professor')) {
  115. $_professor_ = 1;
  116. } else {
  117. $_admin_ = 1;
  118. }
  119. $smarty -> assign("_student_", $_student_);
  120. $smarty -> assign("_professor_", $_professor_);
  121. $smarty -> assign("_admin_", $_admin_);
  122. try {
  123. if ($ctg == 'control_panel') {
  124. /***/
  125. require_once ("control_panel.php");
  126. }
  127. elseif ($ctg == 'landing_page') {
  128. /***/
  129. require_once ("landing_page.php");
  130. }
  131. elseif ($ctg == 'social') {
  132. /***/
  133. require_once ("social.php");
  134. }
  135. elseif ($ctg == 'languages') {
  136. /***/
  137. require_once ("languages.php");
  138. }
  139. elseif ($ctg == 'forum') {
  140. /***/
  141. require_once("includes/forum.php");
  142. }
  143. elseif ($ctg == 'messages') {
  144. /***/
  145. require_once("includes/messages.php");
  146. }
  147. elseif ($ctg == 'backup') {
  148. /***/
  149. require_once ("backup.php");
  150. }
  151. elseif ($ctg == 'news') {
  152. /***/
  153. require_once ("news.php");
  154. }
  155. elseif ($ctg == 'user_profile') {
  156. /***/
  157. require_once ("user_profile.php");
  158. }
  159. elseif ($ctg == 'import_export') {
  160. /***/
  161. require_once ("import_export.php");
  162. }
  163. elseif ($ctg == 'system_config') {
  164. /***/
  165. require_once ("includes/system_config.php");
  166. }
  167. elseif ($ctg == 'personal') {
  168. /**This part is used to display the user's personal information*/
  169. include "includes/personal.php";
  170. }
  171. elseif ($ctg == 'maintenance') {
  172. /***/
  173. require_once ("maintenance.php");
  174. }
  175. elseif ($ctg == 'versionkey') {
  176. /***/
  177. require_once ("versionkey.php");
  178. }
  179. elseif ($ctg == 'curriculums') {
  180. /***/
  181. require_once ("curriculums.php");
  182. }
  183. elseif ($ctg == 'payments') {
  184. /***/
  185. require_once ("payments.php");
  186. }
  187. elseif ($ctg == 'modules') {
  188. /***/
  189. require_once ("includes/modules.php");
  190. }
  191. elseif ($ctg == 'users') {
  192. /***/
  193. require_once ("users.php");
  194. }
  195. elseif ($ctg == 'lessons') {
  196. /***/
  197. require_once ("lessons.php");
  198. }
  199. elseif ($ctg == 'directions') {
  200. /***/
  201. require_once "categories.php";
  202. }
  203. elseif ($ctg == 'archive') {
  204. /***/
  205. require_once "archive.php";
  206. }
  207. elseif ($ctg == 'courses') {
  208. /***/
  209. require_once "courses.php";
  210. }
  211. elseif ($ctg == "file_manager") {
  212. //This page has a file manager, so bring it on with the correct options
  213. $basedir = $currentUser -> getDirectory();
  214. //Default options for the file manager
  215. $options = array('share' => false,
  216. 'lessons_ID' => false,
  217. 'metadata' => 0);
  218. //Default url for the file manager
  219. $url = basename($_SERVER['PHP_SELF']).'?ctg=file_manager';
  220. $extraFileTools = array(array('image' => 'images/16x16/arrow_right.png', 'title' => _INSERTEDITOR, 'action' => 'insert_editor'));
  221. include "file_manager.php";
  222. }
  223. elseif ($ctg == 'logout_user') {
  224. /**Online users list and log out functionality*/
  225. require_once 'logout_user.php';
  226. }
  227. elseif ($ctg == 'user_types') {
  228. /**Custom user types page*/
  229. require_once 'user_types.php';
  230. }
  231. elseif ($ctg == 'user_groups') {
  232. /**User groups page*/
  233. require_once 'includes/groups.php';
  234. }
  235. elseif ($ctg == 'calendar') {
  236. if ($currentUser -> coreAccess['calendar'] != 'hidden' && $GLOBALS['configuration']['disable_calendar'] != 1) {
  237. /***/
  238. require_once "calendar.php";
  239. } else {
  240. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  241. }
  242. }
  243. elseif ($ctg == 'search_courses') {
  244. /**Search courses is used to find the course users that fulfill an arbitrary number of criteria */
  245. require_once "search_courses.php";
  246. }
  247. elseif ($ctg == 'search_users') {
  248. }
  249. elseif ($ctg == 'digests') {
  250. /** Email digests feature */
  251. require_once "digests.php";
  252. }
  253. elseif ($ctg == 'statistics') {
  254. if (isset($currentUser -> coreAccess['statistics']) && $currentUser -> coreAccess['statistics'] == 'hidden') {
  255. eF_redirect("".basename($_SERVER['PHP_SELF'])."?ctg=control_panel&message=".urlencode(_UNAUTHORIZEDACCESS)."&message_type=failure");
  256. }
  257. /** Statistics is the page that calculates and displays the system statistics.*/
  258. require_once "statistics.php";
  259. }
  260. elseif ($ctg == 'module_hcd') {
  261. /***/
  262. require_once "module_hcd.php";
  263. }
  264. elseif ($ctg == 'themes') {
  265. /***/
  266. require_once "themes.php";
  267. }
  268. else if ($ctg == 'tests') {
  269. /***/
  270. require_once "module_tests.php";
  271. /**Ranking tests */
  272. require_once "tests.php";
  273. }
  274. else if ($ctg == 'facebook') {
  275. /***/
  276. require_once "module_facebook.php";
  277. }
  278. elseif ($ctg == 'module') {
  279. /***/
  280. require_once "module.php";
  281. }
  282. /*
  283. $fields_log = array ('users_LOGIN' => $_SESSION['s_login'], //This is the log entry array
  284. 'timestamp' => time(),
  285. 'action' => 'lastmove',
  286. 'comments' => 0,
  287. 'session_ip' => eF_encodeIP($_SERVER['REMOTE_ADDR']));
  288. eF_deleteTableData("logs", "users_LOGIN='".$_SESSION['s_login']."' AND action='lastmove'"); //Only one lastmove action interests us, so delete any other
  289. eF_insertTableData("logs", $fields_log);
  290. */
  291. } catch (Exception $e) {
  292. handleNormalFlowExceptions($e);
  293. }
  294. if (detectBrowser() == 'mobile') {
  295. $load_editor = false;
  296. }
  297. $smarty -> assign("T_HEADER_EDITOR", $load_editor); //Specify whether we need to load the editor
  298. if (isset($_GET['refresh']) || isset($_GET['refresh_side'])) {
  299. $smarty -> assign("T_REFRESH_SIDE","true");
  300. }
  301. /*
  302. * Check if you should input the JS code to
  303. * trigger sending the next notificatoin emails
  304. * Since 3.6.0
  305. */
  306. if (EfrontNotification::shouldSendNextNotifications()) {
  307. $smarty -> assign("T_TRIGGER_NEXT_NOTIFICATIONS_SEND", 1);
  308. $_SESSION['send_next_notifications_now'] = 0; // the msg that triggered the immediate send should be sent now
  309. }
  310. $smarty -> assign("T_MODULE_CSS", $module_css_array);
  311. $smarty -> assign("T_MODULE_JS", $module_js_array);
  312. foreach ($loadedModules as $module) {
  313. $loadScripts = array_merge($loadScripts, $module -> addScripts());
  314. }
  315. //Main scripts, such as prototype
  316. $mainScripts = getMainScripts();
  317. $smarty -> assign("T_HEADER_MAIN_SCRIPTS", implode(",", $mainScripts));
  318. //Operation/file specific scripts
  319. $loadScripts = array_diff($loadScripts, $mainScripts); //Clear out duplicates
  320. $smarty -> assign("T_HEADER_LOAD_SCRIPTS", implode(",", array_unique($loadScripts))); //array_unique, so it doesn't send duplicate entries
  321. $smartyClosingFiles = array();
  322. foreach ($loadedModules as $module) {
  323. if ($smartyClosingFile = $module -> onPageFinishLoadingSmartyTpl()) {
  324. $smartyClosingFiles[] = $smartyClosingFile;
  325. }
  326. }
  327. $smarty -> assign("T_PAGE_FINISH_MODULES", $smartyClosingFiles);
  328. $smarty -> assign("T_CURRENT_CTG", $ctg);
  329. $smarty -> assign("T_MENUCTG", $ctg);
  330. //$smarty -> assign("T_MENU", eF_getMenu());
  331. //$smarty -> assign("T_QUERIES", $numberOfQueries);
  332. if ($_SESSION['s_message']) {
  333. $message .= urldecode($_SESSION['s_message']);
  334. $message_type = $_SESSION['s_message_type'];
  335. unset($_SESSION['s_message']);
  336. unset($_SESSION['s_message_type']);
  337. }
  338. $smarty -> assign("T_MESSAGE", $message);
  339. $smarty -> assign("T_MESSAGE_TYPE", $message_type);
  340. $smarty -> assign("T_SEARCH_MESSAGE", $search_message);
  341. $smarty -> assign("T_TEST_MESSAGE", 'Test Message');
  342. if (!isset($_GET['edit_block'])) { // when updating a unit we must preserve the innerlink
  343. $smarty -> load_filter('output', 'eF_template_setEditorOffset');
  344. }
  345. $benchmark -> set('script');
  346. $smarty -> display('administrator.tpl');
  347. $benchmark -> set('smarty');
  348. $benchmark -> stop();
  349. $output = $benchmark -> display();
  350. if (G_DEBUG) {
  351. echo $output;
  352. }
  353. ?>