Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 248 lines (200 sloc) 8.389 kB
1df120b - massive attack: s/<?/<?php/g - that was causing problems on some fu…
Łukasz Jarosław Mozer authored
1 <?php
5739f6c @alecpl - LMS-1.5
alecpl authored
2
58033b9 - new
Łukasz Jarosław Mozer authored
3 /*
5739f6c @alecpl - LMS-1.5
alecpl authored
4 * LMS version 1.5-cvs
58033b9 - new
Łukasz Jarosław Mozer authored
5 *
6 * (C) Copyright 2001-2003 LMS Developers
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
27 // REPLACE THIS WITH PATH TO YOU CONFIG FILE
28
3c8db30 - czesc hopaki, wpadlem cos zepsuc w 1.1 ;-)
Radosław Antoniuk authored
29 $CONFIG_FILE = (is_readable('lms.ini')) ? 'lms.ini' : '/etc/lms/lms.ini';
58033b9 - new
Łukasz Jarosław Mozer authored
30
31 // PLEASE DO NOT MODIFY ANYTHING BELOW THIS LINE UNLESS YOU KNOW
32 // *EXACTLY* WHAT ARE YOU DOING!!!
62a52c7 @alecpl function for ini file parsing, compatible with almsd ini value strings
alecpl authored
33 // *******************************************************************
a9eb9e8 - test
Łukasz Jarosław Mozer authored
34
58033b9 - new
Łukasz Jarosław Mozer authored
35 ini_set('session.name','LMSSESSIONID');
36
37 // Parse configuration file
a9eb9e8 - test
Łukasz Jarosław Mozer authored
38
d1c0bd8 - tsave (nowe faktury)
Łukasz Jarosław Mozer authored
39 function lms_parse_ini_file($filename, $process_sections = false)
40 {
41 $ini_array = array();
dc09f9a @alecpl - allow_call_time_pass_reference=Off allowed
alecpl authored
42 $section = '';
d1c0bd8 - tsave (nowe faktury)
Łukasz Jarosław Mozer authored
43 $lines = file($filename);
44 foreach($lines as $line)
45 {
46 $line = trim($line);
47
dc09f9a @alecpl - allow_call_time_pass_reference=Off allowed
alecpl authored
48 if($line == '' || $line[0] == ';' || $line[0] == '#')
6b3291e @alecpl nowa funkcja parsuj�ca konfig
alecpl authored
49 continue;
d1c0bd8 - tsave (nowe faktury)
Łukasz Jarosław Mozer authored
50
dc09f9a @alecpl - allow_call_time_pass_reference=Off allowed
alecpl authored
51 list($sec_name) = sscanf($line, "[%[^]]");
52
53 if( $sec_name )
54 $section = trim($sec_name);
d1c0bd8 - tsave (nowe faktury)
Łukasz Jarosław Mozer authored
55 else
56 {
dc09f9a @alecpl - allow_call_time_pass_reference=Off allowed
alecpl authored
57 list($property, $value) = sscanf($line, "%[^=] = '%[^']'");
58 if ( !$property || !$value )
59 {
60 list($property, $value) = sscanf($line, "%[^=] = \"%[^\"]\"");
61 if ( !$property || !$value )
62 {
63 list($property, $value) = sscanf($line, "%[^=] = %[^;#]");
64 if( !$property || !$value )
d1c0bd8 - tsave (nowe faktury)
Łukasz Jarosław Mozer authored
65 continue;
b6c0830 @alecpl - mala poprawka parsera uwzgledniajaca puste zmienne np.""
alecpl authored
66 else
67 $value = trim($value, "\"'");
dc09f9a @alecpl - allow_call_time_pass_reference=Off allowed
alecpl authored
68 }
69 }
70
d1c0bd8 - tsave (nowe faktury)
Łukasz Jarosław Mozer authored
71 $property = trim($property);
72 $value = trim($value);
73
74 if($process_sections)
dc09f9a @alecpl - allow_call_time_pass_reference=Off allowed
alecpl authored
75 $ini_array[$section][$property] = $value;
d1c0bd8 - tsave (nowe faktury)
Łukasz Jarosław Mozer authored
76 else
77 $ini_array[$property] = $value;
78 }
6b3291e @alecpl nowa funkcja parsuj�ca konfig
alecpl authored
79 }
d1c0bd8 - tsave (nowe faktury)
Łukasz Jarosław Mozer authored
80
81 return $ini_array;
62a52c7 @alecpl function for ini file parsing, compatible with almsd ini value strings
alecpl authored
82 }
58033b9 - new
Łukasz Jarosław Mozer authored
83
62a52c7 @alecpl function for ini file parsing, compatible with almsd ini value strings
alecpl authored
84 foreach(lms_parse_ini_file($CONFIG_FILE, true) as $key => $val)
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
85 $_CONFIG[$key] = $val;
58033b9 - new
Łukasz Jarosław Mozer authored
86
a69a55f - try ./lms.ini instead of /etc/lms/lms.ini first
Łukasz Jarosław Mozer authored
87 // Check for configuration vars and set default values
c93c4b0 - small changes in $_CONFIG handling
Łukasz Jarosław Mozer authored
88 $_CONFIG['directories']['sys_dir'] = (! $_CONFIG['directories']['sys_dir'] ? getcwd() : $_CONFIG['directories']['sys_dir']);
89 $_CONFIG['directories']['backup_dir'] = (! $_CONFIG['directories']['backup_dir'] ? $_CONFIG['directories']['sys_dir'].'/backups' : $_CONFIG['directories']['backup_dir']);
90 $_CONFIG['directories']['lib_dir'] = (! $_CONFIG['directories']['lib_dir'] ? $_CONFIG['directories']['sys_dir'].'/lib' : $_CONFIG['directories']['lib_dir']);
91 $_CONFIG['directories']['modules_dir'] = (! $_CONFIG['directories']['modules_dir'] ? $_CONFIG['directories']['sys_dir'].'/modules' : $_CONFIG['directories']['modules_dir']);
ec14c4f - generator config�w
Łukasz Jarosław Mozer authored
92 $_CONFIG['directories']['config_templates_dir'] = (! $_CONFIG['directories']['config_templates_dir'] ? $_CONFIG['directories']['sys_dir'].'/config_templates' : $_CONFIG['directories']['config_templates_dir']);
1224d75 - porz�dki
Łukasz Jarosław Mozer authored
93 $_CONFIG['directories']['smarty_dir'] = (! $_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']);
c93c4b0 - small changes in $_CONFIG handling
Łukasz Jarosław Mozer authored
94 $_CONFIG['directories']['smarty_compile_dir'] = (! $_CONFIG['directories']['smarty_compile_dir'] ? $_CONFIG['directories']['sys_dir'].'/templates_c' : $_CONFIG['directories']['smarty_compile_dir']);
95 $_CONFIG['directories']['smarty_templates_dir'] = (! $_CONFIG['directories']['smarty_templates_dir'] ? $_CONFIG['directories']['sys_dir'].'/templates' : $_CONFIG['directories']['smarty_templates_dir']);
1224d75 - porz�dki
Łukasz Jarosław Mozer authored
96
97 foreach(lms_parse_ini_file($_CONFIG['directories']['lib_dir'].'/config_defaults.ini', TRUE) as $section => $values)
98 foreach($values as $key => $val)
99 if(! isset($_CONFIG[$section][$key]))
100 $_CONFIG[$section][$key] = $val;
c93c4b0 - small changes in $_CONFIG handling
Łukasz Jarosław Mozer authored
101
102 $_SYSTEM_DIR = $_CONFIG['directories']['sys_dir'];
103 $_BACKUP_DIR = $_CONFIG['directories']['backup_dir'];
104 $_LIB_DIR = $_CONFIG['directories']['lib_dir'];
105 $_MODULES_DIR = $_CONFIG['directories']['modules_dir'];
106 $_SMARTY_DIR = $_CONFIG['directories']['smarty_dir'];
107 $_SMARTY_COMPILE_DIR = $_CONFIG['directories']['smarty_compile_dir'];
108 $_SMARTY_TEMPLATES_DIR = $_CONFIG['directories']['smarty_templates_dir'];
109 $_DBTYPE = $_CONFIG['database']['type'];
110 $_DBHOST = $_CONFIG['database']['host'];
111 $_DBUSER = $_CONFIG['database']['user'];
112 $_DBPASS = $_CONFIG['database']['password'];
113 $_DBNAME = $_CONFIG['database']['database'];
58033b9 - new
Łukasz Jarosław Mozer authored
114
115 // include required files
116
01c2133 - zbyt du�o slashy nigdy nie zaszkodzi ;>
Łukasz Jarosław Mozer authored
117 require_once($_LIB_DIR.'/common.php');
118 require_once($_LIB_DIR.'/checkip.php');
119 require_once($_LIB_DIR.'/checkdirs.php');
120 require_once($_LIB_DIR.'/unstrip.php');
121 require_once($_SMARTY_DIR.'/Smarty.class.php');
1a6a87d - temporary save - adodb no longer needed
Łukasz Jarosław Mozer authored
122 require_once($_LIB_DIR.'/LMSDB.php');
01c2133 - zbyt du�o slashy nigdy nie zaszkodzi ;>
Łukasz Jarosław Mozer authored
123 require_once($_LIB_DIR.'/LMS.class.php');
124 require_once($_LIB_DIR.'/Session.class.php');
125 require_once($_LIB_DIR.'/accesstable.php');
bb6f55f @alecpl - trans() and multilanguage staff
alecpl authored
126
127 // Init database
58033b9 - new
Łukasz Jarosław Mozer authored
128
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
129 $DB = DBInit($_DBTYPE, $_DBHOST, $_DBUSER, $_DBPASS, $_DBNAME);
e8cdf8f - temporary save
Łukasz Jarosław Mozer authored
130
4b4c79d @alecpl - konfiguracja lms-ui
alecpl authored
131 // Call any of upgrade process before anything else
cf30c0b - added EXPERIMENTAL automagical upgrade feature :-)
Łukasz Jarosław Mozer authored
132
133 require_once($_LIB_DIR.'/upgradedb.php');
134
4b4c79d @alecpl - konfiguracja lms-ui
alecpl authored
135 // Read configuration of LMS-UI from database
136
137 if($cfg = $DB->GetAll('SELECT section, var, value FROM uiconfig WHERE disabled=0'))
138 foreach($cfg as $row)
139 $_CONFIG[$row['section']][$row['var']] = $row['value'];
140
141 $_TIMEOUT = $_CONFIG['phpui']['timeout'];
142 $_FORCE_SSL = chkconfig($_CONFIG['phpui']['force_ssl']);
143
144 // Redirect to SSL
145
146 if($_FORCE_SSL && $_SERVER['HTTPS'] != 'on')
147 {
148 header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
149 exit(0);
150 }
151
bb6f55f @alecpl - trans() and multilanguage staff
alecpl authored
152 // Initialize session and template classes
58033b9 - new
Łukasz Jarosław Mozer authored
153
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
154 $SESSION = new Session($DB, $_TIMEOUT);
58033b9 - new
Łukasz Jarosław Mozer authored
155
5d2aa1d @alecpl nie wiem czy to tak mia�o by�, ale teraz dziala
alecpl authored
156 $LMS = new LMS($DB, $SESSION, $_CONFIG);
c93c4b0 - small changes in $_CONFIG handling
Łukasz Jarosław Mozer authored
157 $LMS->CONFIG = $_CONFIG;
58033b9 - new
Łukasz Jarosław Mozer authored
158
159 $SMARTY = new Smarty;
ec14c4f - generator config�w
Łukasz Jarosław Mozer authored
160 $SMARTY->assign('_config',$_CONFIG);
58033b9 - new
Łukasz Jarosław Mozer authored
161
162 // test for proper version of Smarty
163
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
164 if(version_compare('2.5.0', $SMARTY->_version) > 0)
1acc0dc - Smarty 2.5.0 required
Łukasz Jarosław Mozer authored
165 die('<B>Niepoprawna wersja engine Smarty! Proszê sci±gn±æ nowszê wersjê spod adresu <A HREF="http://smarty.php.net/distributions/Smarty-2.5.0.tar.gz">http://smarty.php.net/distributions/Smarty-2.5.0.tar.gz</A>!</B>');
58033b9 - new
Łukasz Jarosław Mozer authored
166
167 $SMARTY->template_dir = $_SMARTY_TEMPLATES_DIR;
168 $SMARTY->compile_dir = $_SMARTY_COMPILE_DIR;
fc16550 - cleanups
Łukasz Jarosław Mozer authored
169 $SMARTY->debugging = chkconfig($_CONFIG['phpui']['smarty_debug']);
38e65e0 - dodane rozszerzenie do smartyego. WHAZAA! Jeszcze mniej roboty w pe…
Łukasz Jarosław Mozer authored
170 require_once($_LIB_DIR.'/smarty_addons.php');
58033b9 - new
Łukasz Jarosław Mozer authored
171
bb6f55f @alecpl - trans() and multilanguage staff
alecpl authored
172 // set locales
173 require_once($_LIB_DIR.'/language.php');
174
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
175 $layout['logname'] = $SESSION->logname;
176 $layout['logid'] = $SESSION->id;
5739f6c @alecpl - LMS-1.5
alecpl authored
177 $layout['lmsv'] = '1.5-cvs ('.$LMS->_revision.'/'.$SESSION->_revision.')';
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
178 $layout['lmsdbv'] = $DB->_version;
fc16550 - cleanups
Łukasz Jarosław Mozer authored
179 $layout['smarty_version'] = $SMARTY->_version;
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
180 $layout['uptime'] = uptime();
181 $layout['hostname'] = hostname();
5739f6c @alecpl - LMS-1.5
alecpl authored
182 $layout['lmsvs'] = '1.5-cvs';
149015f - more friendly handling of database errors (ALEC, test it on Postgres)
Łukasz Jarosław Mozer authored
183 $layout['dberrors'] =& $DB->errors;
58033b9 - new
Łukasz Jarosław Mozer authored
184
b324d9c - assign_by_ref
Łukasz Jarosław Mozer authored
185 $SMARTY->assign_by_ref('menu', $LMS->MENU);
186 $SMARTY->assign_by_ref('layout', $layout);
58033b9 - new
Łukasz Jarosław Mozer authored
187
fc16550 - cleanups
Łukasz Jarosław Mozer authored
188 header('X-Powered-By: LMS/'.$layout['lmsv']);
ab5dfd2 - �adny customer interface
Łukasz Jarosław Mozer authored
189 if($SESSION->islogged)
58033b9 - new
Łukasz Jarosław Mozer authored
190 {
191
01c2133 - zbyt du�o slashy nigdy nie zaszkodzi ;>
Łukasz Jarosław Mozer authored
192 if($SESSION->passwd == '')
193 $SMARTY->assign('emptypasswd',TRUE);
58033b9 - new
Łukasz Jarosław Mozer authored
194
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
195 $module = $_GET['m'];
58033b9 - new
Łukasz Jarosław Mozer authored
196
01c2133 - zbyt du�o slashy nigdy nie zaszkodzi ;>
Łukasz Jarosław Mozer authored
197 if (file_exists($_MODULES_DIR.'/'.$module.'.php'))
58033b9 - new
Łukasz Jarosław Mozer authored
198 {
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
199 if(eregi($access['allow'], $module))
2250df9 - przymiarki do r�nych poziom�w dost�pu
Łukasz Jarosław Mozer authored
200 $allow = TRUE;
201 else{
202 $rights = $LMS->GetAdminRights($SESSION->id);
203 if($rights)
204 foreach($rights as $level)
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
205 if(isset($access['table'][$level]['deny_reg']) && eregi($access['table'][$level]['deny_reg'], $module))
2250df9 - przymiarki do r�nych poziom�w dost�pu
Łukasz Jarosław Mozer authored
206 $deny = TRUE;
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
207 elseif(isset($access['table'][$level]['allow_reg']) && eregi($access['table'][$level]['allow_reg'], $module))
2250df9 - przymiarki do r�nych poziom�w dost�pu
Łukasz Jarosław Mozer authored
208 $allow = TRUE;
209 }
210
211 if($allow && ! $deny)
212 {
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
213 $layout['module'] = $module;
01c2133 - zbyt du�o slashy nigdy nie zaszkodzi ;>
Łukasz Jarosław Mozer authored
214 include($_MODULES_DIR.'/'.$module.'.php');
b4ff3c9 - no i leftmenu polecia�o w niepami�� ;-)
Łukasz Jarosław Mozer authored
215 }
216 else
01c2133 - zbyt du�o slashy nigdy nie zaszkodzi ;>
Łukasz Jarosław Mozer authored
217 $SMARTY->display('noaccess.html');
b4ff3c9 - no i leftmenu polecia�o w niepami�� ;-)
Łukasz Jarosław Mozer authored
218 }
219 elseif($module == '')
220 {
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
221 $layout['module'] = 'welcome';
0bfbf07 - development warning will be always in HEAD branch
Łukasz Jarosław Mozer authored
222 $SMARTY->assign('warning',!chkconfig($_CONFIG['phpui']['disable_devel_warning']));
58033b9 - new
Łukasz Jarosław Mozer authored
223 include($_MODULES_DIR.'/welcome.php');
b4ff3c9 - no i leftmenu polecia�o w niepami�� ;-)
Łukasz Jarosław Mozer authored
224 }
225 else
226 {
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
227 $layout['module'] = 'notfound';
228 $layout['pagetitle'] = 'B³±d!';
229 $SMARTY->assign('layout', $layout);
230 $SMARTY->assign('server', $_SERVER);
231 $SMARTY->display('notfound.html');
58033b9 - new
Łukasz Jarosław Mozer authored
232 }
233
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
234 if($_SESSION['lastmodule'] != $module)
235 $_SESSION['lastmodule'] = $module;
58033b9 - new
Łukasz Jarosław Mozer authored
236 }
237 else
238 {
28065a6 - code cleanups
Łukasz Jarosław Mozer authored
239 $SMARTY->assign('error', $SESSION->error);
240 $SMARTY->assign('target','?'.$_SERVER['QUERY_STRING']);
01c2133 - zbyt du�o slashy nigdy nie zaszkodzi ;>
Łukasz Jarosław Mozer authored
241 $SMARTY->display('login.html');
58033b9 - new
Łukasz Jarosław Mozer authored
242
243 }
7dc7c6e - added support for adding start and enddate to phpui
Łukasz Jarosław Mozer authored
244
2c208e3 - LMSDB::Destroy();
Łukasz Jarosław Mozer authored
245 $DB->Destroy();
7dc7c6e - added support for adding start and enddate to phpui
Łukasz Jarosław Mozer authored
246
58033b9 - new
Łukasz Jarosław Mozer authored
247 ?>
Something went wrong with that request. Please try again.