Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 318 lines (255 sloc) 12.55 kB
1df120b - massive attack: s/<?/<?php/g - that was causing problems on some fu…
Łukasz Jarosław Mozer authored
1 <?php
6d762ce @alecpl - fix
alecpl authored
2
58033b9 - new
Łukasz Jarosław Mozer authored
3 /*
12dbd28 @lmsgit mass version change from 1.11-cvs to 1.11-git
authored
4 * LMS version 1.11-git
58033b9 - new
Łukasz Jarosław Mozer authored
5 *
be94799 @lmsgit portability and formatting
authored
6 * (C) Copyright 2001-2015 LMS Developers
58033b9 - new
Łukasz Jarosław Mozer authored
7 *
8 * Please, see the doc/AUTHORS for more information about authors!
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License Version 2 as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 * USA.
23 *
24 * $Id$
25 */
26
6bbfca4 @alecpl - deleted unused lines
alecpl authored
27 // REPLACE THIS WITH PATH TO YOUR CONFIG FILE
be94799 @lmsgit portability and formatting
authored
28 $CONFIG_FILE = DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'lms' . DIRECTORY_SEPARATOR . 'lms.ini';
58033b9 - new
Łukasz Jarosław Mozer authored
29
30 // PLEASE DO NOT MODIFY ANYTHING BELOW THIS LINE UNLESS YOU KNOW
31 // *EXACTLY* WHAT ARE YOU DOING!!!
62a52c7 @alecpl function for ini file parsing, compatible with almsd ini value strings
alecpl authored
32 // *******************************************************************
ccc83c8 - modified a little bit config file scanning.
Łukasz Jarosław Mozer authored
33
1816352 @alecpl - Add sql queries execution time debuging, some improvements
alecpl authored
34 define('START_TIME', microtime(true));
9ee88f8 @alecpl - fix: GetCustomer() can be used by contribs
alecpl authored
35 define('LMS-UI', true);
47cdc17 @alecpl - set error_reporting appropriate for LMS
alecpl authored
36 ini_set('error_reporting', E_ALL&~E_NOTICE);
a9eb9e8 - test
Łukasz Jarosław Mozer authored
37
114042d @lmsgit restored old but often used sequence of searching lms.ini file
authored
38 // find alternative config files:
be94799 @lmsgit portability and formatting
authored
39 if (is_readable('lms.ini'))
114042d @lmsgit restored old but often used sequence of searching lms.ini file
authored
40 $CONFIG_FILE = 'lms.ini';
be94799 @lmsgit portability and formatting
authored
41 elseif (is_readable(DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'lms' . DIRECTORY_SEPARATOR . 'lms-' . $_SERVER['HTTP_HOST'] . '.ini'))
42 $CONFIG_FILE = DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'lms' . DIRECTORY_SEPARATOR . 'lms-' . $_SERVER['HTTP_HOST'] . '.ini';
43 elseif (!is_readable($CONFIG_FILE))
114042d @lmsgit restored old but often used sequence of searching lms.ini file
authored
44 die('Unable to read configuration file ['.$CONFIG_FILE.']!');
55cbb80 @maciejlew Fixes config file loading
maciejlew authored
45
46 define('CONFIG_FILE', $CONFIG_FILE);
9ef7b76 @maniac777 re-add virtual host dependend config file functionality
maniac777 authored
47
52b9781 @maciejlew CONFIG_FILE path as constant in index.php
maciejlew authored
48 $CONFIG = (array) parse_ini_file(CONFIG_FILE, true);
58033b9 - new
Łukasz Jarosław Mozer authored
49
a69a55f - try ./lms.ini instead of /etc/lms/lms.ini first
Łukasz Jarosław Mozer authored
50 // Check for configuration vars and set default values
4e89890 @alecpl - s/$_CONFIG/$CONFIG/ (and few related fixes)
alecpl authored
51 $CONFIG['directories']['sys_dir'] = (!isset($CONFIG['directories']['sys_dir']) ? getcwd() : $CONFIG['directories']['sys_dir']);
be94799 @lmsgit portability and formatting
authored
52 $CONFIG['directories']['lib_dir'] = (!isset($CONFIG['directories']['lib_dir']) ? $CONFIG['directories']['sys_dir'] . DIRECTORY_SEPARATOR . 'lib' : $CONFIG['directories']['lib_dir']);
53 $CONFIG['directories']['doc_dir'] = (!isset($CONFIG['directories']['doc_dir']) ? $CONFIG['directories']['sys_dir'] . DIRECTORY_SEPARATOR . 'documents' : $CONFIG['directories']['doc_dir']);
54 $CONFIG['directories']['modules_dir'] = (!isset($CONFIG['directories']['modules_dir']) ? $CONFIG['directories']['sys_dir'] . DIRECTORY_SEPARATOR . 'modules' : $CONFIG['directories']['modules_dir']);
55 $CONFIG['directories']['backup_dir'] = (!isset($CONFIG['directories']['backup_dir']) ? $CONFIG['directories']['sys_dir'] . DIRECTORY_SEPARATOR . 'backups' : $CONFIG['directories']['backup_dir']);
56 $CONFIG['directories']['config_templates_dir'] = (!isset($CONFIG['directories']['config_templates_dir']) ? $CONFIG['directories']['sys_dir'] . DIRECTORY_SEPARATOR . 'config_templates' : $CONFIG['directories']['config_templates_dir']);
57 $CONFIG['directories']['smarty_compile_dir'] = (!isset($CONFIG['directories']['smarty_compile_dir']) ? $CONFIG['directories']['sys_dir'] . DIRECTORY_SEPARATOR . 'templates_c' : $CONFIG['directories']['smarty_compile_dir']);
58 $CONFIG['directories']['smarty_templates_dir'] = (!isset($CONFIG['directories']['smarty_templates_dir']) ? $CONFIG['directories']['sys_dir'] . DIRECTORY_SEPARATOR . 'templates' : $CONFIG['directories']['smarty_templates_dir']);
59 $CONFIG['directories']['plugin_dir'] = (!isset($CONFIG['directories']['plugin_dir']) ? $CONFIG['directories']['sys_dir'] . DIRECTORY_SEPARATOR . 'plugins' : $CONFIG['directories']['plugin_dir']);
c96a049 @lmsgit restored plugins_dir setting and PLUGINS_DIR define, but as fallback …
authored
60 $CONFIG['directories']['plugins_dir'] = $CONFIG['directories']['plugin_dir'];
be94799 @lmsgit portability and formatting
authored
61 $CONFIG['directories']['vendor_dir'] = (!isset($CONFIG['directories']['vendor_dir']) ? $CONFIG['directories']['sys_dir'] . DIRECTORY_SEPARATOR . 'vendor' : $CONFIG['directories']['vendor_dir']);
4e89890 @alecpl - s/$_CONFIG/$CONFIG/ (and few related fixes)
alecpl authored
62
d8ee885 @alecpl - fixed some remote file inclusion vulnerabilities when register_globals
alecpl authored
63 define('SYS_DIR', $CONFIG['directories']['sys_dir']);
64 define('LIB_DIR', $CONFIG['directories']['lib_dir']);
65 define('DOC_DIR', $CONFIG['directories']['doc_dir']);
66 define('BACKUP_DIR', $CONFIG['directories']['backup_dir']);
67 define('MODULES_DIR', $CONFIG['directories']['modules_dir']);
68 define('SMARTY_COMPILE_DIR', $CONFIG['directories']['smarty_compile_dir']);
69 define('SMARTY_TEMPLATES_DIR', $CONFIG['directories']['smarty_templates_dir']);
44cf632 @lmsgit s/plugins_dir/plugin_dir/gi
authored
70 define('PLUGIN_DIR', $CONFIG['directories']['plugin_dir']);
c96a049 @lmsgit restored plugins_dir setting and PLUGINS_DIR define, but as fallback …
authored
71 define('PLUGINS_DIR', $CONFIG['directories']['plugin_dir']);
3413a0f @maciejlew LMSPluginManager
maciejlew authored
72 define('VENDOR_DIR', $CONFIG['directories']['vendor_dir']);
d8ee885 @alecpl - fixed some remote file inclusion vulnerabilities when register_globals
alecpl authored
73
be94799 @lmsgit portability and formatting
authored
74 // Load autoloader
75 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'autoloader.php');
72e3caf @alecpl - merge checkconfig.php and config_defaults.ini into config.php
alecpl authored
76
87f6db0 @maciejlew Autoload function moved to separate file
maciejlew authored
77 // Do some checks and load config defaults
be94799 @lmsgit portability and formatting
authored
78 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'checkdirs.php');
79 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'config.php');
72e3caf @alecpl - merge checkconfig.php and config_defaults.ini into config.php
alecpl authored
80
81 // Init database
1816352 @alecpl - Add sql queries execution time debuging, some improvements
alecpl authored
82
b093b4e @maciejlew DBInit function replaced by LMSDB class
maciejlew authored
83 $DB = null;
9c08141 @alecpl - some of system error messages are only in english
alecpl authored
84
b093b4e @maciejlew DBInit function replaced by LMSDB class
maciejlew authored
85 try {
be94799 @lmsgit portability and formatting
authored
86 $DB = LMSDB::getInstance();
b093b4e @maciejlew DBInit function replaced by LMSDB class
maciejlew authored
87 } catch (Exception $ex) {
be94799 @lmsgit portability and formatting
authored
88 trigger_error($ex->getMessage(), E_USER_WARNING);
89 // can't working without database
90 die("Fatal error: cannot connect to database!<BR>");
2843334 @alecpl - DB drivers: in postgresql driver added @-operator and changed
alecpl authored
91 }
92
4b4c79d @alecpl - konfiguracja lms-ui
alecpl authored
93 // Call any of upgrade process before anything else
cf30c0b - added EXPERIMENTAL automagical upgrade feature :-)
Łukasz Jarosław Mozer authored
94
be94799 @lmsgit portability and formatting
authored
95 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'upgradedb.php');
cf30c0b - added EXPERIMENTAL automagical upgrade feature :-)
Łukasz Jarosław Mozer authored
96
074d1af @alecpl - pdf invoices: fixed encoding (more iconv())
alecpl authored
97 // Initialize templates engine (must be before locale settings)
98 $SMARTY = new Smarty;
99
93ed309 @alecpl - Smarty version checking moved up (we don't need translated error me…
alecpl authored
100 // test for proper version of Smarty
101
46e3904 @alecpl - Use defined() instead of constant() to suppress PHP warning
alecpl authored
102 if (defined('Smarty::SMARTY_VERSION'))
8266e8e @lmsgit adjusted smarty version checking to newer smarty versions
authored
103 $ver_chunks = preg_split('/[- ]/', preg_replace('/^smarty-/i', '', Smarty::SMARTY_VERSION), -1, PREG_SPLIT_NO_EMPTY);
c88d8a7 @lmsgit - ported to Smarty 3
authored
104 else
105 $ver_chunks = NULL;
8266e8e @lmsgit adjusted smarty version checking to newer smarty versions
authored
106 if (count($ver_chunks) < 1 || version_compare('3.1', $ver_chunks[0]) > 0)
92bbba7 @maniac777 move plugins to other direcotry
maniac777 authored
107 die('<B>Wrong version of Smarty engine! We support only Smarty-3.x greater than 3.1.</B>');
c88d8a7 @lmsgit - ported to Smarty 3
authored
108
8266e8e @lmsgit adjusted smarty version checking to newer smarty versions
authored
109 define('SMARTY_VERSION', $ver_chunks[0]);
c88d8a7 @lmsgit - ported to Smarty 3
authored
110
92bbba7 @maniac777 move plugins to other direcotry
maniac777 authored
111 // add LMS's custom plugins directory
be94799 @lmsgit portability and formatting
authored
112 $SMARTY->addPluginsDir(LIB_DIR . DIRECTORY_SEPARATOR . 'SmartyPlugins');
92bbba7 @maniac777 move plugins to other direcotry
maniac777 authored
113
c88d8a7 @lmsgit - ported to Smarty 3
authored
114 // uncomment this line if you're not gonna change template files no more
115 //$SMARTY->compile_check = false;
93ed309 @alecpl - Smarty version checking moved up (we don't need translated error me…
alecpl authored
116
7d6a08b @alecpl - SSL redirect moved after reading of force_ssl option from database
alecpl authored
117 // Redirect to SSL
118
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
119 $_FORCE_SSL = ConfigHelper::checkConfig('phpui.force_ssl');
be94799 @lmsgit portability and formatting
authored
120 if($_FORCE_SSL && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
7d6a08b @alecpl - SSL redirect moved after reading of force_ssl option from database
alecpl authored
121 header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
122 exit(0);
123 }
124
fee4c73 @alecpl - fixed sequence of including required files
alecpl authored
125 // Include required files (including sequence is important)
58033b9 - new
Łukasz Jarosław Mozer authored
126
be94799 @lmsgit portability and formatting
authored
127 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'language.php');
128 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'unstrip.php');
129 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'definitions.php');
130 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'common.php');
131 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'checkip.php');
132 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'accesstable.php');
133 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'SYSLOG.class.php');
834d580 @lmsgit transaction logging engine introduced
authored
134
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
135 if (ConfigHelper::checkConfig('phpui.logging') && class_exists('SYSLOG')) {
834d580 @lmsgit transaction logging engine introduced
authored
136 $SYSLOG = new SYSLOG($DB);
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
137 } else {
834d580 @lmsgit transaction logging engine introduced
authored
138 $SYSLOG = null;
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
139 }
fee4c73 @alecpl - fixed sequence of including required files
alecpl authored
140
d716386 - SESSION has been splited into two separate classes:
Łukasz Jarosław Mozer authored
141 // Initialize Session, Auth and LMS classes
58033b9 - new
Łukasz Jarosław Mozer authored
142
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
143 $SESSION = new Session($DB, ConfigHelper::getConfig('phpui.timeout'));
834d580 @lmsgit transaction logging engine introduced
authored
144 $AUTH = new Auth($DB, $SESSION, $SYSLOG);
145 if ($SYSLOG)
146 $SYSLOG->SetAuth($AUTH);
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
147 $LMS = new LMS($DB, $AUTH, $SYSLOG);
bec9893 @lmsgit - phpui->lang controls system language
authored
148 $LMS->ui_lang = $_ui_language;
db847d3 @alecpl - money_format
alecpl authored
149 $LMS->lang = $_language;
58033b9 - new
Łukasz Jarosław Mozer authored
150
3bad62f @lmsgit s/LMSPluginsManager/LMSPluginManager/g
authored
151 $plugin_manager = new LMSPluginManager();
152 $LMS->setPluginManager($plugin_manager);
3413a0f @maciejlew LMSPluginManager
maciejlew authored
153
54a52a3 @prezeskk integrate swekey hardware auth
prezeskk authored
154 // Initialize Swekey class
155
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
156 if (ConfigHelper::checkConfig('phpui.use_swekey')) {
be94799 @lmsgit portability and formatting
authored
157 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'swekey' . DIRECTORY_SEPARATOR . 'lms_integration.php');
fbf62e1 @prezeskk end of swekey integration
prezeskk authored
158 $LMS_SWEKEY = new LmsSwekeyIntegration($DB, $AUTH, $LMS);
159 $SMARTY->assign('lms_swekey', $LMS_SWEKEY->GetIntegrationScript($AUTH->id));
160 }
54a52a3 @prezeskk integrate swekey hardware auth
prezeskk authored
161
c82ca77 @alecpl - small improvements: removed 'nomenu', skip menu loading for popups,…
alecpl authored
162 // Set some template and layout variables
fee4c73 @alecpl - fixed sequence of including required files
alecpl authored
163
562409c @lmsgit phpui.custom_templates_dir allows to select used template set
authored
164 $SMARTY->setTemplateDir(null);
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
165 $custom_templates_dir = ConfigHelper::getConfig('phpui.custom_templates_dir');
be94799 @lmsgit portability and formatting
authored
166 if (!empty($custom_templates_dir) && file_exists(SMARTY_TEMPLATES_DIR . DIRECTORY_SEPARATOR . $custom_templates_dir)
167 && !is_file(SMARTY_TEMPLATES_DIR . DIRECTORY_SEPARATOR . $custom_templates_dir))
168 $SMARTY->AddTemplateDir(SMARTY_TEMPLATES_DIR . DIRECTORY_SEPARATOR . $custom_templates_dir);
562409c @lmsgit phpui.custom_templates_dir allows to select used template set
authored
169 $SMARTY->AddTemplateDir(
170 array(
be94799 @lmsgit portability and formatting
authored
171 SMARTY_TEMPLATES_DIR . DIRECTORY_SEPARATOR . 'default',
562409c @lmsgit phpui.custom_templates_dir allows to select used template set
authored
172 SMARTY_TEMPLATES_DIR,
173 )
174 );
175 $SMARTY->setCompileDir(SMARTY_COMPILE_DIR);
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
176 $SMARTY->debugging = ConfigHelper::checkConfig('phpui.smarty_debug');
bb6f55f @alecpl - trans() and multilanguage staff
alecpl authored
177
d716386 - SESSION has been splited into two separate classes:
Łukasz Jarosław Mozer authored
178 $layout['logname'] = $AUTH->logname;
179 $layout['logid'] = $AUTH->id;
bc06451 @maciejlew Getter for LMSDB version property
maciejlew authored
180 $layout['lmsdbv'] = $DB->GetVersion();
c88d8a7 @lmsgit - ported to Smarty 3
authored
181 $layout['smarty_version'] = SMARTY_VERSION;
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
182 $layout['hostname'] = hostname();
3be10f8 @lmsgit temporary commented out version and revision numbers; they don't work…
authored
183 $layout['lmsv'] = '1.11-git';
184 //$layout['lmsvr'] = $LMS->_revision.'/'.$AUTH->_revision;
185 $layout['lmsvr'] = '';
1111488 @maciejlew Removes by reference DB errors assignment
maciejlew authored
186 $layout['dberrors'] = $DB->GetErrors();
1816352 @alecpl - Add sql queries execution time debuging, some improvements
alecpl authored
187 $layout['dbdebug'] = $_DBDEBUG;
c82ca77 @alecpl - small improvements: removed 'nomenu', skip menu loading for popups,…
alecpl authored
188 $layout['popup'] = isset($_GET['popup']) ? true : false;
58033b9 - new
Łukasz Jarosław Mozer authored
189
c88d8a7 @lmsgit - ported to Smarty 3
authored
190 $SMARTY->assignByRef('layout', $layout);
191 $SMARTY->assignByRef('LANGDEFS', $LANGDEFS);
192 $SMARTY->assignByRef('_ui_language', $LMS->ui_lang);
193 $SMARTY->assignByRef('_language', $LMS->lang);
c82ca77 @alecpl - small improvements: removed 'nomenu', skip menu loading for popups,…
alecpl authored
194
195 $error = NULL; // initialize error variable needed for (almost) all modules
196
197 // Load menu
198
199 if(!$layout['popup'])
200 {
be94799 @lmsgit portability and formatting
authored
201 require_once(LIB_DIR . DIRECTORY_SEPARATOR . 'menu.php');
336ee66 @maciejlew Menu hook in index.php
maciejlew authored
202
203 $menu = $plugin_manager->executeHook('menu_initialized', $menu);
204
c82ca77 @alecpl - small improvements: removed 'nomenu', skip menu loading for popups,…
alecpl authored
205 $SMARTY->assign('newmenu', $menu);
206 }
58033b9 - new
Łukasz Jarosław Mozer authored
207
fc16550 - cleanups
Łukasz Jarosław Mozer authored
208 header('X-Powered-By: LMS/'.$layout['lmsv']);
627ed8f @alecpl - error_reporting = E_ALL
alecpl authored
209
38d7bc1 @maciejlew Allows plugins to determine their own modules directory
maciejlew authored
210 $modules_dirs = array(MODULES_DIR);
211 $modules_dirs = $plugin_manager->executeHook('modules_dir_initialized', $modules_dirs);
212
0153164 @maciejlew Allows plugins to modify LMS object
maciejlew authored
213 $plugin_manager->executeHook('lms_initialized', $LMS);
214
09f7d66 @maciejlew Allows plugins to modify SMARTY object
maciejlew authored
215 $plugin_manager->executeHook('smarty_initialized', $SMARTY);
216
c82ca77 @alecpl - small improvements: removed 'nomenu', skip menu loading for popups,…
alecpl authored
217 // Check privileges and execute modules
d80ab53 @lmsgit new simple plugin which allows to use one-time sms passwords
authored
218 if ($AUTH->islogged) {
219 // Load plugin files and register hook callbacks
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
220 $plugins = preg_split('/[;,\s\t\n]+/', ConfigHelper::getConfig('phpui.plugins'), -1, PREG_SPLIT_NO_EMPTY);
d80ab53 @lmsgit new simple plugin which allows to use one-time sms passwords
authored
221 if (!empty($plugins))
222 foreach ($plugins as $plugin_name)
be94799 @lmsgit portability and formatting
authored
223 if(is_readable(LIB_DIR . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $plugin_name . '.php'))
224 require LIB_DIR . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $plugin_name . '.php';
d80ab53 @lmsgit new simple plugin which allows to use one-time sms passwords
authored
225
226 $res = $LMS->ExecHook('access_table_init', array('accesstable' => $access['table']));
227 if (isset($res['accesstable']))
228 $access['table'] = $res['accesstable'];
d06f572 @maciejlew Loads user rights to LMSConfig
maciejlew authored
229
230 LMSConfig::getConfig(array(
231 'force' => true,
232 'force_user_rights_only' => true,
233 'access_table' => $access['table'],
234 'user_id' => $AUTH->id,
235 ));
d80ab53 @lmsgit new simple plugin which allows to use one-time sms passwords
authored
236
993b163 @alecpl - Security fix: Add module name validation
alecpl authored
237 $module = isset($_GET['m']) ? preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['m']) : '';
828abe1 @alecpl - fixed notice
alecpl authored
238 $deny = $allow = FALSE;
f293f77 @alecpl - added option phpui/default_module
alecpl authored
239
d80ab53 @lmsgit new simple plugin which allows to use one-time sms passwords
authored
240 $res = $LMS->ExecHook('module_load_before', array('module' => $module));
241 if ($res['abort']) {
242 $SESSION->close();
243 $DB->Destroy();
244 die;
245 }
246 $module = $res['module'];
247
8dce4e7 @lmsgit implemented simple password expiration mechanism
authored
248 if ($AUTH->passwdrequiredchange)
249 $module = 'chpasswd';
250
251 if ($module == '')
f293f77 @alecpl - added option phpui/default_module
alecpl authored
252 {
4e6af94 @maciejlew LMSConfig integration
maciejlew authored
253 $module = ConfigHelper::getConfig('phpui.default_module');
f293f77 @alecpl - added option phpui/default_module
alecpl authored
254 }
6b38263 @alecpl - Removed devel warning
alecpl authored
255
38d7bc1 @maciejlew Allows plugins to determine their own modules directory
maciejlew authored
256 $module_dir = null;
257 foreach ($modules_dirs as $suspected_module_dir) {
be94799 @lmsgit portability and formatting
authored
258 if (file_exists($suspected_module_dir . DIRECTORY_SEPARATOR . $module . '.php')) {
38d7bc1 @maciejlew Allows plugins to determine their own modules directory
maciejlew authored
259 $module_dir = $suspected_module_dir;
260 break;
261 }
262 }
263
264 if ($module_dir !== null)
58033b9 - new
Łukasz Jarosław Mozer authored
265 {
70b8394 @lmsgit small user permission revolution: if user has deny permission defined…
authored
266 $global_allow = !$AUTH->id || (!empty($access['allow']) && preg_match('/'.$access['allow'].'/i', $module));
0def470 @alecpl - POSIX Regex functions (deprecated in PHP-5.3) replaced with PCRE/St…
alecpl authored
267
70b8394 @lmsgit small user permission revolution: if user has deny permission defined…
authored
268 if ($AUTH->id && ($rights = $LMS->GetUserRights($AUTH->id)))
269 foreach ($rights as $level)
2756025 @lmsgit - added user privilleges framework: you can define privilleges in acc…
authored
270 {
2286100 @alecpl - Improved configuration handling in templates
alecpl authored
271
70b8394 @lmsgit small user permission revolution: if user has deny permission defined…
authored
272 if (!$global_allow && !$deny && isset($access['table'][$level]['deny_reg']))
273 $deny = (bool) preg_match('/'.$access['table'][$level]['deny_reg'].'/i', $module);
274 elseif (!$allow && isset($access['table'][$level]['allow_reg']))
275 $allow = (bool) preg_match('/'.$access['table'][$level]['allow_reg'].'/i', $module);
c61cc5a @alecpl - assign config array by reference
alecpl authored
276
2756025 @lmsgit - added user privilleges framework: you can define privilleges in acc…
authored
277 }
0def470 @alecpl - POSIX Regex functions (deprecated in PHP-5.3) replaced with PCRE/St…
alecpl authored
278
834d580 @lmsgit transaction logging engine introduced
authored
279 if ($SYSLOG)
280 $SYSLOG->NewTransaction($module);
281
70b8394 @lmsgit small user permission revolution: if user has deny permission defined…
authored
282 if ($global_allow || ($allow && !$deny))
2250df9 - przymiarki do r�nych poziom�w dost�pu
Łukasz Jarosław Mozer authored
283 {
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
284 $layout['module'] = $module;
e82f064 @alecpl - views.php functionality moved to LMS class
alecpl authored
285 $LMS->InitUI();
ad65ace @maciejlew Adds global "on load" hook
maciejlew authored
286 $LMS->executeHook($module.'_on_load');
be94799 @lmsgit portability and formatting
authored
287 include($module_dir . DIRECTORY_SEPARATOR . $module . '.php');
834d580 @lmsgit transaction logging engine introduced
authored
288 } else {
289 if ($SYSLOG)
290 $SYSLOG->AddMessage(SYSLOG_RES_USER, SYSLOG_OPER_USERNOACCESS,
291 array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_USER] => $AUTH->id), array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_USER]));
01c2133 - zbyt du�o slashy nigdy nie zaszkodzi ;>
Łukasz Jarosław Mozer authored
292 $SMARTY->display('noaccess.html');
834d580 @lmsgit transaction logging engine introduced
authored
293 }
b4ff3c9 - no i leftmenu polecia�o w niepami�� ;-)
Łukasz Jarosław Mozer authored
294 }
295 else
296 {
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
297 $layout['module'] = 'notfound';
3d3dd3e @alecpl - translation
alecpl authored
298 $layout['pagetitle'] = trans('Error!');
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
299 $SMARTY->assign('layout', $layout);
300 $SMARTY->assign('server', $_SERVER);
301 $SMARTY->display('notfound.html');
58033b9 - new
Łukasz Jarosław Mozer authored
302 }
46e3904 @alecpl - Use defined() instead of constant() to suppress PHP warning
alecpl authored
303
6fbf472 - hopefully every $_SESSION reference has been removed and nothing wi…
Łukasz Jarosław Mozer authored
304 if($SESSION->get('lastmodule') != $module)
305 $SESSION->save('lastmodule', $module);
58033b9 - new
Łukasz Jarosław Mozer authored
306 }
307 else
308 {
d716386 - SESSION has been splited into two separate classes:
Łukasz Jarosław Mozer authored
309 $SMARTY->assign('error', $AUTH->error);
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
310 $SMARTY->assign('target','?'.$_SERVER['QUERY_STRING']);
01c2133 - zbyt du�o slashy nigdy nie zaszkodzi ;>
Łukasz Jarosław Mozer authored
311 $SMARTY->display('login.html');
58033b9 - new
Łukasz Jarosław Mozer authored
312 }
7dc7c6e - added support for adding start and enddate to phpui
Łukasz Jarosław Mozer authored
313
d716386 - SESSION has been splited into two separate classes:
Łukasz Jarosław Mozer authored
314 $SESSION->close();
2c208e3 - LMSDB::Destroy();
Łukasz Jarosław Mozer authored
315 $DB->Destroy();
285d720 - raised up required smarty version
Łukasz Jarosław Mozer authored
316
58033b9 - new
Łukasz Jarosław Mozer authored
317 ?>
Something went wrong with that request. Please try again.