| [ PHPXref.com ] | [ Generated: Sun Jul 20 20:26:56 2008 ] | [ Streber pm 0.052 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 # streber - a php5 based project management system (c) 2005 Thomas Mann / thomas@pixtur.de 3 # Distributed under the terms and conditions of the GPL as stated in _docs/license.html 4 5 /** 6 * Welcome to the source-code. This is a good point to start reading. 7 * 8 * This is index.php - the master-control-page. There are NO other php-pages, except from 9 * install.php (which should have been delete in normal process). 10 * 11 * index.php does... 12 * 13 * - initialize the profiler 14 * - include config and customize 15 * - include core-components 16 * - authenticate the user 17 * - render a page (which means calling a function defined in a file at pages/*.inc) 18 * 19 * If you want to read more source-code try... 20 * 21 * - pages/_pagehandles.inc - a list of definiation of all posibible pages, it's required rights, etc. 22 * - pages/home.inc - example, how a normal page looks like 23 * - pages/effort.inc - example, how a form-workflow looks like 24 * - lists/list_efforts.inc - example for listing objects 25 * - db/class_effort.inc - exampel for back-end definition of object-types 26 * - render/page.inc - rending of html-code 27 * 28 */ 29 30 31 error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_STRICT 32 |E_PARSE|E_CORE_ERROR|E_CORE_WARNING|E_COMPILE_ERROR 33 ); 34 35 ### start timing for profiler ### 36 global $TIME_START; 37 $TIME_START=microtime(1); 38 $DB_ITEMS_LOADED=0; 39 40 ### bypassing date & timezone-related warnings with php 5.1 41 if (function_exists('date_default_timezone_set')) { 42 $tz= @date_default_timezone_get(); 43 date_default_timezone_set($tz); 44 } 45 46 47 /** 48 * create a function to make sure we are starting at index.php 49 */ 50 function startedIndexPhp() {return true; } # define function 51 52 53 54 /** 55 * include misc functions (php4) 56 */ 57 require_once "std/common.inc"; 58 require_once "std/errorhandler.inc"; 59 60 ini_set('zend.ze1_compatibility_mode', 0); 61 62 63 ### clean global namespace from register globals ### 64 if (@ini_get('register_globals')) { 65 foreach ($_REQUEST as $key => $value) { 66 unset($GLOBALS[$key]); 67 } 68 } 69 70 71 /** 72 * filter get and post-vars 73 * 74 * We don't not distinguish security between post-,get- and cookie-vars 75 * because any of them can be easily forged. We create a joined assoc array 76 * and filter for too long variables. All security-checks 77 * or done later in db- and field-classes. 78 * 79 * passed parames should always used like; 80 * 81 * $f_person_name= get('person_name'); 82 * 83 */ 84 clearRequestVars(); 85 addRequestVars($_GET); 86 addRequestVars($_POST); 87 addRequestVars($_COOKIE); 88 89 90 91 /** 92 * include configuration 93 **/ 94 { 95 require_once ("conf/defines.inc"); 96 require_once ("conf/conf.inc"); 97 98 ### if no db_settings start installaion ### 99 if(!file_exists(confGet('DIR_SETTINGS').confGet('FILE_DB_SETTINGS'))) { 100 header("location:install/install.php"); 101 exit; 102 } 103 else { 104 require_once(confGet('DIR_SETTINGS').confGet('FILE_DB_SETTINGS')); 105 } 106 107 ### include user-settings ## 108 require_once ('customize.inc'); 109 } 110 111 /** 112 * run profiler and output measures in footer? 113 */ 114 if(confGet('USE_PROFILER')) { 115 require_once ("std/profiler.inc"); 116 } 117 else { 118 ### define empty functions ### 119 function measure_start($id){}; 120 function measure_stop($id){}; 121 function render_measures(){return '';}; 122 } 123 124 125 measure_start('time_complete'); # measure complete time (stops before profiling) 126 measure_start('core_includes'); # measure time for including core-components 127 128 129 $db_type = confGet('DB_TYPE'); 130 if(file_exists("db/db_".$db_type."_class.php")){ 131 require_once("db/db_".$db_type."_class.php"); 132 }else{ 133 134 } 135 136 /** 137 * include the core-classes (php5) 138 */ 139 require_once "db/db.inc"; 140 require_once "std/class_auth.inc"; 141 require_once "db/db_item.inc"; 142 measure_stop('core_includes'); 143 144 145 146 measure_start('authorize'); 147 $cookie_authorized = $auth->getUserByCookie(); 148 measure_stop('authorize'); 149 150 measure_start('language'); 151 if($cookie_authorized) { 152 153 if(isset($auth->cur_user->language) 154 && $auth->cur_user->language != "" 155 && $auth->cur_user->language != "en" 156 ) { 157 setLang($auth->cur_user->language); 158 } 159 } 160 else { 161 setLang(confGet('DEFAULT_LANGUAGE')); 162 } 163 build_person_fields(); 164 165 measure_stop('language'); 166 167 measure_start('plugins'); 168 169 require_once "std/constant_names.inc"; 170 require_once "render/render_page.inc"; 171 require_once "std/class_pagehandler.inc"; 172 require_once "pages/_handles.inc"; # already requires language-support 173 174 measure_stop('plugins'); 175 176 177 measure_start('init2'); 178 179 180 181 /** 182 * cache some db-elements 183 * 184 * those assoc. arrays hold references to objects from database 185 * like $id => object 186 * 187 * @@@ add to db/class_project db/class_task 188 */ 189 global $cache_projects; 190 $cache_projects=array(); 191 192 global $cache_tasks; 193 $cache_tasks=array(); 194 195 196 197 ### if index.php was called without target, check environment ### 198 if(!$go=get('go')) { 199 200 require_once ('std/check_version.inc'); 201 validateEnvironment(); 202 } 203 204 205 206 207 208 ### user NOT logged in ### 209 if(!$cookie_authorized) { 210 211 ### submitting login ### 212 if($go == 'loginFormSubmit') { 213 214 $PH->show('loginFormSubmit'); 215 } 216 217 ### valid for anonymous ### 218 else if( isset($PH->hash[$go]) && $PH->hash[$go]->valid_for_anonymous) { 219 $PH->show($go); 220 } 221 else if(get('tuid') && isset($PH->hash[$go]) && $PH->hash[$go]->valid_for_tuid) { 222 if($auth->getUserByCookie(get('tuid'))) { 223 $PH->show($go); 224 } 225 else { 226 $PH->messages[]=__("Sorry, but this activation code is no longer valid. If you already have an account, you could enter you name and use the <b>forgot password link</b> below."); 227 $PH->show('loginForm'); 228 } 229 230 } 231 232 ### all other request lead to login-form ### 233 else{ 234 235 236 ### check if we have a proper environment and if db is online ### 237 238 ### check php-version and database (we don't want to show exceptions and php-errors) ### 239 240 ### warn if install-dir present ### 241 if(file_exists('install')) { 242 $PH->messages[]="<b>Install-directory still present.</b> This is a massive security issue (<a href='".confGet('STREBER_WIKI_URL')."installation'>read more</a>)" 243 .'<ul><li><a href="install/remove_install_dir.php">remove install directory now.</a></ul>'; 244 245 } 246 247 ### render login-form ### 248 $PH->show('loginForm'); 249 250 ### stop here ### 251 exit; 252 } 253 } 254 255 ### user logged in by Cookie ### 256 else { 257 258 if(isset($g_languages[$auth->cur_user->language])) { 259 setLang($auth->cur_user->language); 260 } 261 262 $go=get('go'); 263 264 ### if no target-page show home ### 265 if(!$go) { 266 267 ### if user has only one project go there ### 268 $projects=$auth->cur_user->getProjects(); 269 if(count($projects) == 1) { 270 $PH->messages[]= sprintf(confGet('MESSAGE_WELCOME_ONEPROJECT'), $auth->cur_user->name,$projects[0]->name); 271 $PH->show('projView',array('prj'=>$projects[0]->id)); 272 } 273 else { 274 $PH->messages[]=confGet('MESSAGE_WELCOME_HOME'); 275 $PH->show('home',array()); 276 } 277 } 278 279 280 ### error-page if invalid target-page#### 281 else if(!isset($PH->hash[$go])) { 282 $PH->show('error'); 283 } 284 285 ### render target-page ### 286 else { 287 288 $PH->show($go); 289 } 290 } 291 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |