![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: index.php 183 2008-07-21 01:22:03Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/index.php $ */ 2 3 /* 4 Copyright (c) 2007-2008 The web2Project Development Team <w2p-developers@web2project.net> 5 Copyright (c) 2003-2005 The dotProject Development Team <core-developers@dotproject.net> 6 7 This file is part of web2Project. 8 9 web2Project is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2 of the License, or 12 (at your option) any later version. 13 14 web2Project 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 web2Project; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 */ 23 24 // If you experience a 'white screen of death' or other problems, 25 // uncomment the following line of code: 26 //error_reporting( E_ALL ); 27 28 $loginFromPage = 'index.php'; 29 require_once 'base.php'; 30 31 clearstatcache(); 32 if (is_file(W2P_BASE_DIR . '/includes/config.php')) { 33 require_once W2P_BASE_DIR . '/includes/config.php'; 34 } else { 35 echo '<html><head><meta http-equiv="refresh" content="5; URL=' . W2P_BASE_URL . '/install/index.php"></head><body>'; 36 echo 'Fatal Error. You haven\'t created a config file yet.<br/><a href="./install/index.php">' . 'Click Here To Start Installation and Create One!</a> (forwarded in 5 sec.)</body></html>'; 37 exit(); 38 } 39 40 if (!isset($GLOBALS['OS_WIN'])) { 41 $GLOBALS['OS_WIN'] = (stristr(PHP_OS, 'WIN') !== false); 42 } 43 44 // tweak for pathname consistence on windows machines 45 require_once W2P_BASE_DIR . '/includes/main_functions.php'; 46 require_once W2P_BASE_DIR . '/includes/db_adodb.php'; 47 48 require_once W2P_BASE_DIR . '/classes/ui.class.php'; 49 require_once W2P_BASE_DIR . '/classes/permissions.class.php'; 50 require_once W2P_BASE_DIR . '/includes/session.php'; 51 52 // don't output anything. Usefull for fileviewer.php, gantt.php, etc. 53 $suppressHeaders = w2PgetParam($_GET, 'suppressHeaders', false); 54 55 // manage the session variable(s) 56 w2PsessionStart(array('AppUI')); 57 58 // write the HTML headers 59 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past 60 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified 61 header('Cache-Control: no-cache, must-revalidate, no-store, post-check=0, pre-check=0'); // HTTP/1.1 62 header('Pragma: no-cache'); // HTTP/1.0 63 64 // check if session has previously been initialised 65 if (!isset($_SESSION['AppUI']) || isset($_GET['logout'])) { 66 if (isset($_GET['logout']) && isset($_SESSION['AppUI']->user_id)) { 67 $AppUI = &$_SESSION['AppUI']; 68 $user_id = $AppUI->user_id; 69 addHistory('login', $AppUI->user_id, 'logout', $AppUI->user_first_name . ' ' . $AppUI->user_last_name); 70 } 71 72 $_SESSION['AppUI'] = new CAppUI; 73 } 74 $AppUI = &$_SESSION['AppUI']; 75 $last_insert_id = $AppUI->last_insert_id; 76 77 $AppUI->checkStyle(); 78 79 // load the commonly used classes 80 require_once ($AppUI->getSystemClass('date')); 81 require_once ($AppUI->getSystemClass('w2p')); 82 require_once ($AppUI->getSystemClass('query')); 83 84 //Now that we have $AppUI lets add our ajax functions in 85 //require_once ($AppUI->getSystemClass('ajax')); 86 87 //Function for update lost action in user_access_log 88 $AppUI->updateLastAction($last_insert_id); 89 // load default preferences if not logged in 90 if ($AppUI->doLogin()) { 91 $AppUI->loadPrefs(0); 92 } 93 94 //Function register logout in user_acces_log 95 if (isset($user_id) && isset($_GET['logout'])) { 96 $AppUI->registerLogout($user_id); 97 } 98 99 // check is the user needs a new password 100 if (w2PgetParam($_POST, 'lostpass', 0)) { 101 $uistyle = w2PgetConfig('host_style'); 102 $AppUI->setUserLocale(); 103 @include_once W2P_BASE_DIR . '/locales/' . $AppUI->user_locale . '/locales.php'; 104 include_once W2P_BASE_DIR . '/locales/core.php'; 105 setlocale(LC_TIME, $AppUI->user_lang); 106 if (w2PgetParam($_POST, 'sendpass', 0)) { 107 require W2P_BASE_DIR . '/includes/sendpass.php'; 108 sendNewPass(); 109 } else { 110 require W2P_BASE_DIR . '/style/' . $uistyle . '/lostpass.php'; 111 } 112 exit(); 113 } 114 115 // check if the user is trying to log in 116 // Note the change to REQUEST instead of POST. This is so that we can 117 // support alternative authentication methods such as the PostNuke 118 // and HTTP auth methods now supported. 119 if (isset($_REQUEST['login'])) { 120 $username = w2PgetCleanParam($_POST, 'username', ''); 121 $password = w2PgetCleanParam($_POST, 'password', ''); 122 $redirect = w2PgetCleanParam($_POST, 'redirect', ''); 123 $AppUI->setUserLocale(); 124 @include_once (W2P_BASE_DIR . '/locales/' . $AppUI->user_locale . '/locales.php'); 125 include_once W2P_BASE_DIR . '/locales/core.php'; 126 $ok = $AppUI->login($username, $password); 127 if (!$ok) { 128 $AppUI->setMsg('Login Failed', UI_MSG_ERROR); 129 } else { 130 //Register login in user_acces_log 131 $AppUI->registerLogin(); 132 } 133 addHistory('login', $AppUI->user_id, 'login', $AppUI->user_first_name . ' ' . $AppUI->user_last_name); 134 $AppUI->redirect('' . $redirect); 135 } 136 137 // supported since PHP 4.2 138 // w2PwriteDebug( var_export( $AppUI, true ), 'AppUI', __FILE__, __LINE__ ); 139 140 // set the default ui style 141 $uistyle = $AppUI->getPref('UISTYLE') ? $AppUI->getPref('UISTYLE') : w2PgetConfig('host_style'); 142 143 // clear out main url parameters 144 $m = ''; 145 $a = ''; 146 $u = ''; 147 148 // check if we are logged in 149 if ($AppUI->doLogin()) { 150 // load basic locale settings 151 $AppUI->setUserLocale(); 152 @include_once ('./locales/' . $AppUI->user_locale . '/locales.php'); 153 include_once ('./locales/core.php'); 154 setlocale(LC_TIME, $AppUI->user_lang); 155 $redirect = $_SERVER['QUERY_STRING'] ? strip_tags($_SERVER['QUERY_STRING']) : ''; 156 if (strpos($redirect, 'logout') !== false) { 157 $redirect = ''; 158 } 159 160 if (isset($locale_char_set)) { 161 header('Content-type: text/html;charset=' . $locale_char_set); 162 } 163 164 require W2P_BASE_DIR . '/style/' . $uistyle . '/login.php'; 165 // destroy the current session and output login page 166 session_unset(); 167 session_destroy(); 168 exit; 169 } 170 $AppUI->setUserLocale(); 171 172 // bring in the rest of the support and localisation files 173 $perms = &$AppUI->acl(); 174 175 $def_a = 'index'; 176 if (!isset($_GET['m']) && !empty($w2Pconfig['default_view_m'])) { 177 if (!$perms->checkModule($w2Pconfig['default_view_m'], 'view', $AppUI->user_id)) { 178 $m = 'public'; 179 $def_a = 'welcome'; 180 } else { 181 $m = $w2Pconfig['default_view_m']; 182 $def_a = !empty($w2Pconfig['default_view_a']) ? $w2Pconfig['default_view_a'] : $def_a; 183 $tab = $w2Pconfig['default_view_tab']; 184 } 185 } else { 186 // set the module from the url 187 $m = $AppUI->checkFileName(w2PgetCleanParam($_GET, 'm', getReadableModule())); 188 } 189 // set the action from the url 190 $a = $AppUI->checkFileName(w2PgetCleanParam($_GET, 'a', $def_a)); 191 if ($m == 'projects' && $a == 'view' && $w2Pconfig['projectdesigner_view_project'] && !w2PgetParam($_GET, 'bypass') && !(isset($_GET['tab']))) { 192 if ($AppUI->isActiveModule('projectdesigner')) { 193 $m = 'projectdesigner'; 194 $a = 'index'; 195 } 196 } 197 198 /* This check for $u implies that a file located in a subdirectory of higher depth than 1 199 * in relation to the module base can't be executed. So it would'nt be possible to 200 * run for example the file module/directory1/directory2/file.php 201 * Also it won't be possible to run modules/module/abc.zyz.class.php for that dots are 202 * not allowed in the request parameters. 203 */ 204 205 $u = $AppUI->checkFileName(w2PgetCleanParam($_GET, 'u', '')); 206 207 // load module based locale settings 208 @include_once W2P_BASE_DIR . '/locales/' . $AppUI->user_locale . '/locales.php'; 209 include_once W2P_BASE_DIR . '/locales/core.php'; 210 211 setlocale(LC_TIME, $AppUI->user_lang); 212 $m_config = w2PgetConfig($m); 213 214 // TODO: canRead/Edit assignements should be moved into each file 215 216 // check overall module permissions 217 // these can be further modified by the included action files 218 $canAccess = $perms->checkModule($m, 'access'); 219 $canRead = $perms->checkModule($m, 'view'); 220 $canEdit = $perms->checkModule($m, 'edit'); 221 $canAuthor = $perms->checkModule($m, 'add'); 222 $canDelete = $perms->checkModule($m, 'delete'); 223 224 if (!$suppressHeaders) { 225 // output the character set header 226 if (isset($locale_char_set)) { 227 header('Content-type: text/html;charset=' . $locale_char_set); 228 } 229 } 230 231 // include the module class file - we use file_exists instead of @ so 232 // that any parse errors in the file are reported, rather than errors 233 // further down the track. 234 $modclass = $AppUI->getModuleClass($m); 235 if (file_exists($modclass)) { 236 include_once ($modclass); 237 } 238 if ($u && file_exists(W2P_BASE_DIR . '/modules/' . $m . '/' . $u . '/' . $u . '.class.php')) { 239 include_once W2P_BASE_DIR . '/modules/' . $m . '/' . $u . '/' . $u . '.class.php'; 240 } 241 242 // include the module ajax file - we use file_exists instead of @ so 243 // that any parse errors in the file are reported, rather than errors 244 // further down the track. 245 $modajax = $AppUI->getModuleAjax($m); 246 if (file_exists($modajax)) { 247 include_once ($modajax); 248 } 249 if ($u && file_exists(W2P_BASE_DIR . '/modules/' . $m . '/' . $u . '/' . $u . '.ajax.php')) { 250 include_once W2P_BASE_DIR . '/modules/' . $m . '/' . $u . '/' . $u . '.ajax.php'; 251 } 252 253 // do some db work if dosql is set 254 // TODO - MUST MOVE THESE INTO THE MODULE DIRECTORY 255 if (isset($_REQUEST['dosql'])) { 256 //require('./dosql/' . $_REQUEST['dosql'] . '.php'); 257 require W2P_BASE_DIR . '/modules/' . $m . '/' . ($u ? ($u . '/') : '') . $AppUI->checkFileName($_REQUEST['dosql']) . '.php'; 258 } 259 260 // start output proper 261 include W2P_BASE_DIR . '/style/' . $uistyle . '/overrides.php'; 262 ob_start(); 263 if (!$suppressHeaders) { 264 require W2P_BASE_DIR . '/style/' . $uistyle . '/header.php'; 265 } 266 267 if (W2P_PERFORMANCE_DEBUG) { 268 $w2p_performance_setuptime = (array_sum(explode(' ', microtime())) - $w2p_performance_time); 269 } 270 271 //Set up extra tabs 272 if (!isset($_SESSION['all_tabs'][$m])) { 273 // For some reason on some systems if you don't set this up 274 // first you get recursive pointers to the all_tabs array, creating 275 // phantom tabs. 276 if (!isset($_SESSION['all_tabs'])) { 277 $_SESSION['all_tabs'] = array(); 278 } 279 $_SESSION['all_tabs'][$m] = array(); 280 $all_tabs = &$_SESSION['all_tabs'][$m]; 281 foreach ($AppUI->getActiveModules() as $dir => $module) { 282 if (!$perms->checkModule($dir, 'access')) { 283 continue; 284 } 285 $modules_tabs = $AppUI->readFiles(W2P_BASE_DIR . '/modules/' . $dir . '/', '^' . $m . '_tab.*\.php'); 286 foreach ($modules_tabs as $tab) { 287 // Get the name as the subextension 288 // cut the module_tab. and the .php parts of the filename 289 // (begining and end) 290 $nameparts = explode('.', $tab); 291 $filename = substr($tab, 0, -4); 292 if (count($nameparts) > 3) { 293 $file = $nameparts[1]; 294 if (!isset($all_tabs[$file])) { 295 $all_tabs[$file] = array(); 296 } 297 $arr = &$all_tabs[$file]; 298 $name = $nameparts[2]; 299 } else { 300 $arr = &$all_tabs; 301 $name = $nameparts[1]; 302 } 303 $arr[] = array('name' => ucfirst(str_replace('_', ' ', $name)), 'file' => W2P_BASE_DIR . '/modules/' . $dir . '/' . $filename, 'module' => $dir); 304 305 /* 306 ** Don't forget to unset $arr again! $arr is likely to be used in the sequel declaring 307 ** any temporary array. This may lead to strange bugs with disappearing tabs (cf. #1767). 308 ** @author: gregorerhardt @date: 20070203 309 */ 310 unset($arr); 311 } 312 } 313 } else { 314 $all_tabs = &$_SESSION['all_tabs'][$m]; 315 } 316 317 //Set up extra crumbs 318 if (!isset($_SESSION['all_crumbs'][$m])) { 319 // For some reason on some systems if you don't set this up 320 // first you get recursive pointers to the all_crumbs array, creating 321 // phantom crumbs. 322 if (!isset($_SESSION['all_crumbs'])) { 323 $_SESSION['all_crumbs'] = array(); 324 } 325 $_SESSION['all_crumbs'][$m] = array(); 326 $all_crumbs = &$_SESSION['all_crumbs'][$m]; 327 foreach ($AppUI->getActiveModules() as $dir => $module) { 328 if (!$perms->checkModule($dir, 'access')) { 329 continue; 330 } 331 $modules_crumbs = $AppUI->readFiles(W2P_BASE_DIR . '/modules/' . $dir . '/', '^' . $m . '_crumb.*\.php'); 332 foreach ($modules_crumbs as $tab) { 333 // Get the name as the subextension 334 // cut the module_tab. and the .php parts of the filename 335 // (begining and end) 336 $nameparts = explode('.', $tab); 337 $filename = substr($tab, 0, -4); 338 if (count($nameparts) > 3) { 339 $file = $nameparts[1]; 340 if (!isset($all_crumbs[$file])) { 341 $all_crumbs[$file] = array(); 342 } 343 $arr = &$all_crumbs[$file]; 344 $name = $nameparts[2]; 345 } else { 346 $arr = &$all_crumbs; 347 $name = $nameparts[1]; 348 } 349 $arr[] = array('name' => ucfirst(str_replace('_', ' ', $name)), 'file' => W2P_BASE_DIR . '/modules/' . $dir . '/' . $filename, 'module' => $dir); 350 351 unset($arr); 352 } 353 } 354 } else { 355 $all_crumbs = &$_SESSION['all_crumbs'][$m]; 356 } 357 358 $module_file = W2P_BASE_DIR . '/modules/' . $m . '/' . ($u ? ($u . '/') : '') . $a . '.php'; 359 if (file_exists($module_file)) { 360 require $module_file; 361 } else { 362 // TODO: make this part of the public module? 363 // TODO: internationalise the string. 364 $titleBlock = new CTitleBlock('Warning', 'log-error.gif'); 365 $titleBlock->show(); 366 367 if (function_exists('styleRenderBoxTop')) { 368 echo styleRenderBoxTop(); 369 } 370 echo '<table width="100%" cellspacing="0" cellpadding="3" border="0" class="std">'; 371 echo '<tr>'; 372 echo ' <td>'; 373 echo $AppUI->_('Missing file. Possible Module "' . $m . '" missing!'); 374 echo ' </td>'; 375 echo '</tr>'; 376 echo '</table>'; 377 } 378 if (!$suppressHeaders) { 379 echo '<iframe name="thread" src="' . W2P_BASE_URL . '/modules/index.html" width="0" height="0" frameborder="0"></iframe>'; 380 echo '<iframe name="thread2" src="' . W2P_BASE_URL . '/modules/index.html" width="0" height="0" frameborder="0"></iframe>'; 381 require W2P_BASE_DIR . '/style/' . $uistyle . '/footer.php'; 382 if (W2P_PERFORMANCE_DEBUG) { 383 $db_info = $db->ServerInfo(); 384 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">web2Project ' . $AppUI->getVersion() . '</p>'); 385 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">PHP version nr: ' . phpversion() . '</p>'); 386 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">DB provider and version nr: ' . $db->dataProvider . ' ' . $db_info['version'] . '</p>'); 387 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">DB Table Prefix: "' . w2PgetConfig('dbprefix') . '"</p>'); 388 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">PHP Max. Execution Time: ' . ini_get('max_execution_time') . ' seconds</p>'); 389 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">Memory Limit: ' . (ini_get('memory_limit') ? str_replace('M', ' Mb', ini_get('memory_limit')) : 'Not Defined') . '</p>'); 390 if (function_exists('memory_get_usage')) { 391 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">Memory Used: ' . sprintf('%01.2f Mb', memory_get_usage() / pow(1024, 2)) . '</p>'); 392 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">Memory Unused: ' . sprintf('%01d Kb', (memory_get_usage() - $w2p_performance_memory_marker) / 1024) . '</p>'); 393 } 394 if (function_exists('memory_get_peak_usage')) { 395 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">Memory Peak: ' . sprintf('%01d Kb', (memory_get_peak_usage() - $w2p_performance_memory_marker) / 1024) . '</p>'); 396 } 397 printf('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">Setup in %.3f seconds</p>', $w2p_performance_setuptime); 398 printf('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">ACLs checked in %.3f seconds</p>', $w2p_performance_acltime); 399 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">ACLs nr of checks: ' . $w2p_performance_aclchecks . '</p>'); 400 printf('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">w2P Data checked in %.3f seconds</p>', $w2p_performance_dbtime); 401 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">w2P DBQueries executed: ' . $w2p_performance_dbqueries . ' queries</p>'); 402 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">w2P Old Queries executed: ' . $w2p_performance_old_dbqueries . ' queries</p>'); 403 print ('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">w2P Total Queries executed: ' . (int)($w2p_performance_old_dbqueries + $w2p_performance_dbqueries) . ' queries</p>'); 404 printf('<p style="margin: 0px;font-size: 7pt; text-align: center; color: #000000">Page generated in %.3f seconds</p>', (array_sum(explode(' ', microtime())) - $w2p_performance_time)); 405 } 406 echo '</div>'; 407 echo ' 408 <!--AJAX loading messagebox --> 409 <div id="loadingMessage" style="alpha(opacity=100);opacity:1;position: fixed; left: 50%; top: 0;display: none;"> 410 <table width="80" cellpadding="3" cellspacing="3" border="0"> 411 <tr> 412 <td> 413 <b>' . $AppUI->_('Loading') . '</b> 414 </td> 415 <td>'; 416 echo w2PshowImage('progress.gif', '10', '10', 'spinner', 'Loading...'); 417 echo ' 418 </td> 419 </tr> 420 </table> 421 </div> 422 <!--End AJAX loading messagebox -->'; 423 } 424 ob_end_flush(); 425 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Aug 21 03:00:13 2008 | Cross-referenced by PHPXref 0.7 |