Skip to content
This repository
Newer
Older
100644 263 lines (213 sloc) 9.365 kb
1df120b4 »
2003-08-24 - massive attack: s/<?/<?php/g - that was causing problems on some fu…
1 <?php
5739f6c6 »
2004-09-18 - LMS-1.5
2
58033b95 »
2003-04-11 - new
3 /*
e2f8752c »
2005-12-07 - /1.7/1.9/
4 * LMS version 1.9-cvs
58033b95 »
2003-04-11 - new
5 *
895bfbd8 »
2006-01-16 - year change
6 * (C) Copyright 2001-2006 LMS Developers
58033b95 »
2003-04-11 - new
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
6bbfca44 »
2005-08-18 - deleted unused lines
27 // REPLACE THIS WITH PATH TO YOUR CONFIG FILE
58033b95 »
2003-04-11 - new
28
3c8db30f »
2003-10-27 - czesc hopaki, wpadlem cos zepsuc w 1.1 ;-)
29 $CONFIG_FILE = (is_readable('lms.ini')) ? 'lms.ini' : '/etc/lms/lms.ini';
58033b95 »
2003-04-11 - new
30
31 // PLEASE DO NOT MODIFY ANYTHING BELOW THIS LINE UNLESS YOU KNOW
32 // *EXACTLY* WHAT ARE YOU DOING!!!
62a52c7f »
2003-11-11 function for ini file parsing, compatible with almsd ini value strings
33 // *******************************************************************
a9eb9e89 »
2004-03-30 - test
34
58033b95 »
2003-04-11 - new
35 // Parse configuration file
d1c0bd81 »
2003-12-01 - tsave (nowe faktury)
36 function lms_parse_ini_file($filename, $process_sections = false)
37 {
38 $ini_array = array();
dc09f9a4 »
2004-08-31 - allow_call_time_pass_reference=Off allowed
39 $section = '';
d1c0bd81 »
2003-12-01 - tsave (nowe faktury)
40 $lines = file($filename);
41 foreach($lines as $line)
42 {
43 $line = trim($line);
44
dc09f9a4 »
2004-08-31 - allow_call_time_pass_reference=Off allowed
45 if($line == '' || $line[0] == ';' || $line[0] == '#')
6b3291ed »
2003-11-14 nowa funkcja parsuj±ca konfig
46 continue;
d1c0bd81 »
2003-12-01 - tsave (nowe faktury)
47
dc09f9a4 »
2004-08-31 - allow_call_time_pass_reference=Off allowed
48 list($sec_name) = sscanf($line, "[%[^]]");
49
50 if( $sec_name )
51 $section = trim($sec_name);
d1c0bd81 »
2003-12-01 - tsave (nowe faktury)
52 else
53 {
dc09f9a4 »
2004-08-31 - allow_call_time_pass_reference=Off allowed
54 list($property, $value) = sscanf($line, "%[^=] = '%[^']'");
55 if ( !$property || !$value )
56 {
57 list($property, $value) = sscanf($line, "%[^=] = \"%[^\"]\"");
58 if ( !$property || !$value )
59 {
60 list($property, $value) = sscanf($line, "%[^=] = %[^;#]");
61 if( !$property || !$value )
d1c0bd81 »
2003-12-01 - tsave (nowe faktury)
62 continue;
b6c0830a »
2003-12-04 - mala poprawka parsera uwzgledniajaca puste zmienne np.""
63 else
64 $value = trim($value, "\"'");
dc09f9a4 »
2004-08-31 - allow_call_time_pass_reference=Off allowed
65 }
66 }
67
d1c0bd81 »
2003-12-01 - tsave (nowe faktury)
68 $property = trim($property);
69 $value = trim($value);
70
71 if($process_sections)
dc09f9a4 »
2004-08-31 - allow_call_time_pass_reference=Off allowed
72 $ini_array[$section][$property] = $value;
d1c0bd81 »
2003-12-01 - tsave (nowe faktury)
73 else
74 $ini_array[$property] = $value;
75 }
6b3291ed »
2003-11-14 nowa funkcja parsuj±ca konfig
76 }
d1c0bd81 »
2003-12-01 - tsave (nowe faktury)
77
78 return $ini_array;
62a52c7f »
2003-11-11 function for ini file parsing, compatible with almsd ini value strings
79 }
58033b95 »
2003-04-11 - new
80
62a52c7f »
2003-11-11 function for ini file parsing, compatible with almsd ini value strings
81 foreach(lms_parse_ini_file($CONFIG_FILE, true) as $key => $val)
4e898903 »
2005-05-27 - s/$_CONFIG/$CONFIG/ (and few related fixes)
82 $CONFIG[$key] = $val;
58033b95 »
2003-04-11 - new
83
a69a55f7 »
2003-06-21 - try ./lms.ini instead of /etc/lms/lms.ini first
84 // Check for configuration vars and set default values
4e898903 »
2005-05-27 - s/$_CONFIG/$CONFIG/ (and few related fixes)
85 $CONFIG['directories']['sys_dir'] = (!isset($CONFIG['directories']['sys_dir']) ? getcwd() : $CONFIG['directories']['sys_dir']);
86 $CONFIG['directories']['backup_dir'] = (!isset($CONFIG['directories']['backup_dir']) ? $CONFIG['directories']['sys_dir'].'/backups' : $CONFIG['directories']['backup_dir']);
925b2d3e »
2005-07-20 - documents archive
87 $CONFIG['directories']['doc_dir'] = (!isset($CONFIG['directories']['doc_dir']) ? $CONFIG['directories']['sys_dir'].'/documents' : $CONFIG['directories']['doc_dir']);
4e898903 »
2005-05-27 - s/$_CONFIG/$CONFIG/ (and few related fixes)
88 $CONFIG['directories']['lib_dir'] = (!isset($CONFIG['directories']['lib_dir']) ? $CONFIG['directories']['sys_dir'].'/lib' : $CONFIG['directories']['lib_dir']);
89 $CONFIG['directories']['modules_dir'] = (!isset($CONFIG['directories']['modules_dir']) ? $CONFIG['directories']['sys_dir'].'/modules' : $CONFIG['directories']['modules_dir']);
90 $CONFIG['directories']['config_templates_dir'] = (!isset($CONFIG['directories']['config_templates_dir']) ? $CONFIG['directories']['sys_dir'].'/config_templates' : $CONFIG['directories']['config_templates_dir']);
91 $CONFIG['directories']['smarty_dir'] = (!isset($CONFIG['directories']['smarty_dir']) ? (is_readable('/usr/share/php/smarty/libs/Smarty.class.php') ? '/usr/share/php/smarty/libs' : $CONFIG['directories']['lib_dir'].'/Smarty') : $CONFIG['directories']['smarty_dir']);
92 $CONFIG['directories']['smarty_compile_dir'] = (!isset($CONFIG['directories']['smarty_compile_dir']) ? $CONFIG['directories']['sys_dir'].'/templates_c' : $CONFIG['directories']['smarty_compile_dir']);
93 $CONFIG['directories']['smarty_templates_dir'] = (!isset($CONFIG['directories']['smarty_templates_dir']) ? $CONFIG['directories']['sys_dir'].'/templates' : $CONFIG['directories']['smarty_templates_dir']);
94
95 foreach(lms_parse_ini_file($CONFIG['directories']['lib_dir'].'/config_defaults.ini', TRUE) as $section => $values)
1224d754 »
2003-12-04 - porządki
96 foreach($values as $key => $val)
4e898903 »
2005-05-27 - s/$_CONFIG/$CONFIG/ (and few related fixes)
97 if(! isset($CONFIG[$section][$key]))
98 $CONFIG[$section][$key] = $val;
99
100 $_SYSTEM_DIR = $CONFIG['directories']['sys_dir'];
101 $_BACKUP_DIR = $CONFIG['directories']['backup_dir'];
925b2d3e »
2005-07-20 - documents archive
102 $_DOC_DIR = $CONFIG['directories']['doc_dir'];
4e898903 »
2005-05-27 - s/$_CONFIG/$CONFIG/ (and few related fixes)
103 $_LIB_DIR = $CONFIG['directories']['lib_dir'];
104 $_MODULES_DIR = $CONFIG['directories']['modules_dir'];
105 $_SMARTY_DIR = $CONFIG['directories']['smarty_dir'];
106 $_SMARTY_COMPILE_DIR = $CONFIG['directories']['smarty_compile_dir'];
107 $_SMARTY_TEMPLATES_DIR = $CONFIG['directories']['smarty_templates_dir'];
108 $_DBTYPE = $CONFIG['database']['type'];
109 $_DBHOST = $CONFIG['database']['host'];
110 $_DBUSER = $CONFIG['database']['user'];
111 $_DBPASS = $CONFIG['database']['password'];
112 $_DBNAME = $CONFIG['database']['database'];
58033b95 »
2003-04-11 - new
113
9c081416 »
2005-01-25 - some of system error messages are only in english
114 require_once($_LIB_DIR.'/checkdirs.php');
115 require_once($_LIB_DIR.'/checkconfig.php');
58033b95 »
2003-04-11 - new
116
bb6f55f6 »
2004-12-19 - trans() and multilanguage staff
117 // Init database
58033b95 »
2003-04-11 - new
118
9c081416 »
2005-01-25 - some of system error messages are only in english
119 require_once($_LIB_DIR.'/LMSDB.php');
120
28065a6f »
2003-10-02 - code cleanups
121 $DB = DBInit($_DBTYPE, $_DBHOST, $_DBUSER, $_DBPASS, $_DBNAME);
e8cdf8fc »
2003-08-18 - temporary save
122
3155943c »
2005-02-28 - added file dbencoding.php (changes needed because of phpui/lang option
123 // Enable/disable data encoding conversion
4b4c79d1 »
2004-11-26 - konfiguracja lms-ui
124 // Call any of upgrade process before anything else
cf30c0b9 »
2004-03-03 - added EXPERIMENTAL automagical upgrade feature :-)
125
3155943c »
2005-02-28 - added file dbencoding.php (changes needed because of phpui/lang option
126 require_once($_LIB_DIR.'/dbencoding.php');
cf30c0b9 »
2004-03-03 - added EXPERIMENTAL automagical upgrade feature :-)
127 require_once($_LIB_DIR.'/upgradedb.php');
128
074d1af4 »
2005-02-17 - pdf invoices: fixed encoding (more iconv())
129 // Initialize templates engine (must be before locale settings)
130
131 require_once($_SMARTY_DIR.'/Smarty.class.php');
132
133 $SMARTY = new Smarty;
134
93ed3091 »
2005-05-05 - Smarty version checking moved up (we don't need translated error me…
135 // test for proper version of Smarty
136
137 if(version_compare('2.6.0', $SMARTY->_version) > 0)
138 die('<B>Old version of Smarty engine! You must get newest from <A HREF="http://smarty.php.net/distributions/Smarty-2.6.8.tar.gz">http://smarty.php.net/distributions/Smarty-2.6.8.tar.gz</A></B>');
139
4b4c79d1 »
2004-11-26 - konfiguracja lms-ui
140 // Read configuration of LMS-UI from database
141
142 if($cfg = $DB->GetAll('SELECT section, var, value FROM uiconfig WHERE disabled=0'))
143 foreach($cfg as $row)
4e898903 »
2005-05-27 - s/$_CONFIG/$CONFIG/ (and few related fixes)
144 $CONFIG[$row['section']][$row['var']] = $row['value'];
4b4c79d1 »
2004-11-26 - konfiguracja lms-ui
145
7d6a08b0 »
2005-01-25 - SSL redirect moved after reading of force_ssl option from database
146 // Redirect to SSL
147
4e898903 »
2005-05-27 - s/$_CONFIG/$CONFIG/ (and few related fixes)
148 $_FORCE_SSL = (isset($CONFIG['phpui']['force_ssl']) ? chkconfig($CONFIG['phpui']['force_ssl']) : FALSE);
7d6a08b0 »
2005-01-25 - SSL redirect moved after reading of force_ssl option from database
149
150 if($_FORCE_SSL && $_SERVER['HTTPS'] != 'on')
151 {
152 header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
153 exit(0);
154 }
155
fee4c739 »
2004-12-20 - fixed sequence of including required files
156 // Include required files (including sequence is important)
58033b95 »
2003-04-11 - new
157
3155943c »
2005-02-28 - added file dbencoding.php (changes needed because of phpui/lang option
158 require_once($_LIB_DIR.'/language.php');
fee4c739 »
2004-12-20 - fixed sequence of including required files
159 require_once($_LIB_DIR.'/unstrip.php');
443ff664 »
2005-07-23 - added definitions.php (with some constants, doctypes and periods de…
160 require_once($_LIB_DIR.'/definitions.php');
bdb79a2e »
2005-08-04 - Document Numbering Plans (part II)
161 require_once($_LIB_DIR.'/common.php');
e656ec8c »
2005-08-09 - fixed includes order
162 require_once($_LIB_DIR.'/checkip.php');
b23aed96 »
2004-12-20 - translated menu and changes in translation function files
163 require_once($_LIB_DIR.'/LMS.class.php');
d716386c »
2005-03-09 - SESSION has been splited into two separate classes:
164 require_once($_LIB_DIR.'/Auth.class.php');
fee4c739 »
2004-12-20 - fixed sequence of including required files
165 require_once($_LIB_DIR.'/accesstable.php');
d716386c »
2005-03-09 - SESSION has been splited into two separate classes:
166 require_once($_LIB_DIR.'/Session.class.php');
fee4c739 »
2004-12-20 - fixed sequence of including required files
167
d716386c »
2005-03-09 - SESSION has been splited into two separate classes:
168 // Initialize Session, Auth and LMS classes
58033b95 »
2003-04-11 - new
169
addaf8ab »
2005-06-30 - make Session class more indenpendent (it's doesn't require whole CO…
170 $SESSION = new Session($DB, $CONFIG['phpui']['timeout']);
d716386c »
2005-03-09 - SESSION has been splited into two separate classes:
171 $AUTH = new Auth($DB, $SESSION);
4e898903 »
2005-05-27 - s/$_CONFIG/$CONFIG/ (and few related fixes)
172 $LMS = new LMS($DB, $AUTH, $CONFIG);
db847d3d »
2004-12-21 - money_format
173 $LMS->lang = $_language;
58033b95 »
2003-04-11 - new
174
fee4c739 »
2004-12-20 - fixed sequence of including required files
175 // set some template and layout variables
176
b23aed96 »
2004-12-20 - translated menu and changes in translation function files
177 $SMARTY->assign_by_ref('_LANG', $_LANG);
178 $SMARTY->assign_by_ref('LANGDEFS', $LANGDEFS);
179 $SMARTY->assign_by_ref('_language', $LMS->lang);
d1451574 »
2004-12-22 - doc regen
180 $SMARTY->assign('_dochref', is_dir('doc/html/'.$LMS->lang) ? 'doc/html/'.$LMS->lang.'/' : 'doc/html/en/');
4e898903 »
2005-05-27 - s/$_CONFIG/$CONFIG/ (and few related fixes)
181 $SMARTY->assign('_config',$CONFIG);
6e2d8ae8 »
2004-12-22 - improved missing_string behaviour
182 $SMARTY->template_dir = $_SMARTY_TEMPLATES_DIR;
183 $SMARTY->compile_dir = $_SMARTY_COMPILE_DIR;
4e898903 »
2005-05-27 - s/$_CONFIG/$CONFIG/ (and few related fixes)
184 $SMARTY->debugging = (isset($CONFIG['phpui']['smarty_debug']) ? chkconfig($CONFIG['phpui']['smarty_debug']) : FALSE);
056ba3b1 »
2005-04-21 - some code cleanup for error_reporting = E_ALL
185 $SMARTY->_tpl_vars['missing_strings'] = array();
6e2d8ae8 »
2004-12-22 - improved missing_string behaviour
186 require_once($_LIB_DIR.'/smarty_addons.php');
f2be41e8 »
2005-09-19 - few fixes with menu (Userpanel detection and sorting moved to menu.…
187 require_once($_LIB_DIR.'/menu.php');
bb6f55f6 »
2004-12-19 - trans() and multilanguage staff
188
d716386c »
2005-03-09 - SESSION has been splited into two separate classes:
189 $layout['logname'] = $AUTH->logname;
190 $layout['logid'] = $AUTH->id;
28065a6f »
2003-10-02 - code cleanups
191 $layout['lmsdbv'] = $DB->_version;
fc165500 »
2003-08-06 - cleanups
192 $layout['smarty_version'] = $SMARTY->_version;
28065a6f »
2003-10-02 - code cleanups
193 $layout['hostname'] = hostname();
e2f8752c »
2005-12-07 - /1.7/1.9/
194 $layout['lmsv'] = '1.9-cvs';
20ff8e87 »
2005-04-14 - fixed height of left menu
195 $layout['lmsvr'] = $LMS->_revision.'/'.$AUTH->_revision;
149015f7 »
2004-03-11 - more friendly handling of database errors (ALEC, test it on Postgres)
196 $layout['dberrors'] =& $DB->errors;
58033b95 »
2003-04-11 - new
197
4be6b0f3 »
2005-03-11 - temporary, for new menu
198 $SMARTY->assign_by_ref('newmenu', $menu);
b324d9cc »
2004-03-11 - assign_by_ref
199 $SMARTY->assign_by_ref('layout', $layout);
58033b95 »
2003-04-11 - new
200
fc165500 »
2003-08-06 - cleanups
201 header('X-Powered-By: LMS/'.$layout['lmsv']);
627ed8f9 »
2005-04-21 - error_reporting = E_ALL
202
c012ba01 »
2005-04-22 - error_reporting = E_ALL fixes
203 $error = NULL; // initialize error variable needed for (almost) all modules
ed5e0f12 »
2006-03-24 - fixed few "Undefined index" notices
204 $layout['popup'] = isset($_GET['popup']) ? true : false;
627ed8f9 »
2005-04-21 - error_reporting = E_ALL
205
d716386c »
2005-03-09 - SESSION has been splited into two separate classes:
206 if($AUTH->islogged)
58033b95 »
2003-04-11 - new
207 {
056ba3b1 »
2005-04-21 - some code cleanup for error_reporting = E_ALL
208 $module = (isset($_GET['m']) ? $_GET['m'] : '');
209 $deny = FALSE;
f293f778 »
2006-01-19 - added option phpui/default_module
210
211 if($module == '')
212 {
213 $module = $CONFIG['phpui']['default_module'];
214 $SMARTY->assign('warning',!chkconfig($CONFIG['phpui']['disable_devel_warning']));
215 }
58033b95 »
2003-04-11 - new
216
01c21339 »
2003-04-20 - zbyt dużo slashy nigdy nie zaszkodzi ;>
217 if (file_exists($_MODULES_DIR.'/'.$module.'.php'))
58033b95 »
2003-04-11 - new
218 {
28065a6f »
2003-10-02 - code cleanups
219 if(eregi($access['allow'], $module))
2250df90 »
2003-04-20 - przymiarki do różnych poziomów dostępu
220 $allow = TRUE;
221 else{
f48f1cc0 »
2005-05-27 - revolution continues (s/admin/user/ s/Admin/User/)
222 $rights = $LMS->GetUserRights($AUTH->id);
2250df90 »
2003-04-20 - przymiarki do różnych poziomów dostępu
223 if($rights)
224 foreach($rights as $level)
28065a6f »
2003-10-02 - code cleanups
225 if(isset($access['table'][$level]['deny_reg']) && eregi($access['table'][$level]['deny_reg'], $module))
2250df90 »
2003-04-20 - przymiarki do różnych poziomów dostępu
226 $deny = TRUE;
28065a6f »
2003-10-02 - code cleanups
227 elseif(isset($access['table'][$level]['allow_reg']) && eregi($access['table'][$level]['allow_reg'], $module))
2250df90 »
2003-04-20 - przymiarki do różnych poziomów dostępu
228 $allow = TRUE;
229 }
230
231 if($allow && ! $deny)
232 {
28065a6f »
2003-10-02 - code cleanups
233 $layout['module'] = $module;
01c21339 »
2003-04-20 - zbyt dużo slashy nigdy nie zaszkodzi ;>
234 include($_MODULES_DIR.'/'.$module.'.php');
b4ff3c99 »
2003-11-27 - no i leftmenu poleciało w niepamięć ;-)
235 }
236 else
01c21339 »
2003-04-20 - zbyt dużo slashy nigdy nie zaszkodzi ;>
237 $SMARTY->display('noaccess.html');
b4ff3c99 »
2003-11-27 - no i leftmenu poleciało w niepamięć ;-)
238 }
239 else
240 {
28065a6f »
2003-10-02 - code cleanups
241 $layout['module'] = 'notfound';
3d3dd3e9 »
2004-12-20 - translation
242 $layout['pagetitle'] = trans('Error!');
28065a6f »
2003-10-02 - code cleanups
243 $SMARTY->assign('layout', $layout);
244 $SMARTY->assign('server', $_SERVER);
245 $SMARTY->display('notfound.html');
58033b95 »
2003-04-11 - new
246 }
247
6fbf472b »
2005-03-10 - hopefully every $_SESSION reference has been removed and nothing wi…
248 if($SESSION->get('lastmodule') != $module)
249 $SESSION->save('lastmodule', $module);
58033b95 »
2003-04-11 - new
250 }
251 else
252 {
d716386c »
2005-03-09 - SESSION has been splited into two separate classes:
253 $SMARTY->assign('error', $AUTH->error);
28065a6f »
2003-10-02 - code cleanups
254 $SMARTY->assign('target','?'.$_SERVER['QUERY_STRING']);
01c21339 »
2003-04-20 - zbyt dużo slashy nigdy nie zaszkodzi ;>
255 $SMARTY->display('login.html');
58033b95 »
2003-04-11 - new
256
257 }
7dc7c6eb »
2004-03-14 - added support for adding start and enddate to phpui
258
d716386c »
2005-03-09 - SESSION has been splited into two separate classes:
259 $SESSION->close();
2c208e3b »
2003-09-10 - LMSDB::Destroy();
260 $DB->Destroy();
285d720c »
2005-03-10 - raised up required smarty version
261
58033b95 »
2003-04-11 - new
262 ?>
Something went wrong with that request. Please try again.