![]() |
Xataface 2.0
Xataface Application Framework
|
00001 Index: Application.php 00002 =================================================================== 00003 --- Application.php (revision 2469) 00004 +++ Application.php (revision 2476) 00005 @@ -18,12 +18,6 @@ 00006 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00007 *------------------------------------------------------------------------------- 00008 */ 00009 - 00010 - 00013 - 00014 - 00015 if ( !function_exists('sys_get_temp_dir') ) 00016 { 00017 // Based on http://www.phpit.net/ 00018 @@ -306,14 +300,6 @@ 00019 if ( !is_array($conf) ) $conf = array(); 00020 if ( is_readable(DATAFACE_SITE_PATH.'/conf.ini') ){ 00021 $conf = array_merge(parse_ini_file(DATAFACE_SITE_PATH.'/conf.ini', true), $conf); 00022 - if ( @$conf['__include__'] ){ 00023 - $includes = array_map('trim',explode(',', $conf['__include__'])); 00024 - foreach ($includes as $i){ 00025 - if ( is_readable($i) ){ 00026 - $conf = array_merge($conf, parse_ini_file($i, true)); 00027 - } 00028 - } 00029 - } 00030 } 00031 00032 00033 @@ -645,12 +631,6 @@ 00034 } else { 00035 $query = array_merge($_GET, $_POST); 00036 } 00037 - if ( isset($query['-action']) ){ 00038 - $query['-action'] = basename($query['-action']); 00039 - } 00040 - if ( isset($query['-table']) ){ 00041 - $query['-table'] = basename($query['-table']); 00042 - } 00043 $this->rawQuery = $query; 00044 00045 if ( !isset( $query['-table'] ) ) $query['-table'] = $this->_conf['default_table']; 00046 @@ -845,63 +825,69 @@ 00047 // set the garbage collector - who will clean the session files - 00048 // to our custom timeout 00049 ini_set('session.gc_maxlifetime', $garbage_timeout); 00050 - 00051 - // we need a distinct directory for the session files, 00052 - // otherwise another garbage collector with a lower gc_maxlifetime 00053 - // will clean our files aswell - but in an own directory, we only 00054 - // clean sessions with our "own" garbage collector (which has a 00055 - // custom timeout/maxlifetime set each time one of our scripts is 00056 - // executed) 00057 - strstr(strtoupper(substr(@$_SERVER["OS"], 0, 3)), "WIN") ? 00058 - $sep = "\\" : $sep = "/"; 00059 - $sessdir = session_save_path(); //ini_get('session.save_path'); 00060 - $levels = ''; 00061 - if (strpos($sessdir, ";") !== FALSE){ 00062 - $levels = substr($sessdir, 0, strpos($sessdir, ";")).';'; 00063 - $sessdir = substr($sessdir, strpos($sessdir, ";")+1); 00064 - } 00065 - if ( !$sessdir ) $sessdir = sys_get_temp_dir(); //'/tmp'; 00066 - if ( $sessdir and $sessdir{strlen($sessdir)-1} == '/' ) $sessdir = substr($sessdir,0, strlen($sessdir)-1); 00067 - 00068 - if ( @$conf['subdir'] ) $subdir = $conf['subdir']; 00069 - else $subdir = md5(DATAFACE_SITE_PATH); 00070 - if ( !$subdir ) $subdir = 'dataface'; 00071 - $sessdir .= "/".$subdir; 00072 - 00073 - 00074 - if (!is_dir($sessdir)) { 00075 - $res = @mkdir($sessdir, 0777); 00076 - if ( !$res ){ 00077 - import('Dataface/Error.php'); 00078 - echo "<h2>Configuration Required</h2> 00079 - <p>Dataface was unable to create the directory '$sessdir' 00080 - to store its session files.</p> 00081 - <h3>Possible reasons for this:</h3> 00082 - <ul> 00083 - <li>The script does not have permission to create the directory.</li> 00084 - <li>The server is operating in safe mode.</li> 00085 - </ul> 00086 - <h3>Possible Solutions for this:</h3> 00087 - <ul> 00088 - <li>Make the ".dirname($sessdir)." writable by the web server. E.g. chmod 0777 ".dirname($sessdir).".</li> 00089 - <li>Manually create the '$sessdir' directory and make it writable by the web server.</li> 00090 - <li>Change the session save path to a directory to which you have write permissions by adding the following to the 00091 - beginning of your application's index.php file: 00092 - <code><pre>session_save_path('/path/to/dir');</pre></code> 00093 - </li> 00094 - <li>If none of these solves the problem, visit the Dataface forum 00095 - at <a href=\"http://xataface.com/forum\">http://xataface.com/forum</a> 00096 - and ask for help. 00097 - </li> 00098 - </ul> 00099 - <h3>Debugging Information:</h3> 00100 - <div> 00101 - ".Dataface_Error::printStackTrace()."</div>"; 00102 - exit; 00103 + if ( ini_get('session.save_handler') == 'files' ){ 00104 + // we need a distinct directory for the session files, 00105 + // otherwise another garbage collector with a lower gc_maxlifetime 00106 + // will clean our files aswell - but in an own directory, we only 00107 + // clean sessions with our "own" garbage collector (which has a 00108 + // custom timeout/maxlifetime set each time one of our scripts is 00109 + // executed) 00110 + strstr(strtoupper(substr(@$_SERVER["OS"], 0, 3)), "WIN") ? 00111 + $sep = "\\" : $sep = "/"; 00112 + $sessdir = session_save_path(); //ini_get('session.save_path'); 00113 + $levels = ''; 00114 + if (strpos($sessdir, ";") !== FALSE){ 00115 + $levels = substr($sessdir, 0, strpos($sessdir, ";")).';'; 00116 + $sessdir = substr($sessdir, strpos($sessdir, ";")+1); 00117 } 00118 + if ( !$sessdir ) $sessdir = sys_get_temp_dir(); //'/tmp'; 00119 + if ( $sessdir and $sessdir{strlen($sessdir)-1} == '/' ) $sessdir = substr($sessdir,0, strlen($sessdir)-1); 00120 + 00121 + if ( @$conf['subdir'] ) $subdir = $conf['subdir']; 00122 + else $subdir = md5(DATAFACE_SITE_PATH); 00123 + if ( !$subdir ) $subdir = 'dataface'; 00124 + $sessdir .= "/".$subdir; 00125 + 00126 + 00127 + if (!is_dir($sessdir)) { 00128 + $res = @mkdir($sessdir, 0777); 00129 + if ( !$res ){ 00130 + import('Dataface/Error.php'); 00131 + echo "<h2>Configuration Required</h2> 00132 + <p>Dataface was unable to create the directory '$sessdir' 00133 + to store its session files.</p> 00134 + <h3>Possible reasons for this:</h3> 00135 + <ul> 00136 + <li>The script does not have permission to create the directory.</li> 00137 + <li>The server is operating in safe mode.</li> 00138 + </ul> 00139 + <h3>Possible Solutions for this:</h3> 00140 + <ul> 00141 + <li>Make the ".dirname($sessdir)." writable by the web server. E.g. chmod 0777 ".dirname($sessdir).".</li> 00142 + <li>Manually create the '$sessdir' directory and make it writable by the web server.</li> 00143 + <li>Change the session save path to a directory to which you have write permissions by adding the following to the 00144 + beginning of your application's index.php file: 00145 + <code><pre>session_save_path('/path/to/dir');</pre></code> 00146 + </li> 00147 + <li>If none of these solves the problem, visit the Dataface forum 00148 + at <a href=\"http://xataface.com/forum\">http://xataface.com/forum</a> 00149 + and ask for help. 00150 + </li> 00151 + </ul> 00152 + <h3>Debugging Information:</h3> 00153 + <div> 00154 + ".Dataface_Error::printStackTrace()."</div>"; 00155 + exit; 00156 + } 00157 + } 00158 + session_save_path($levels.$sessdir); 00159 + } else { 00160 + // We need to set a unique session name if we're not changing the directory 00161 + if ( !@$conf['session_name'] ){ 00162 + $conf['session_name'] = md5(DATAFACE_SITE_PATH); 00163 + } 00164 } 00165 - session_save_path($levels.$sessdir); 00166 - 00167 + if ( @$conf['session_name'] ) session_name($conf['session_name']); 00168 session_start(); // start the session 00169 header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'); 00170 00171 @@ -982,15 +968,8 @@ 00172 import('Dataface/PermissionsTool.php'); 00173 import('Dataface/Table.php'); 00174 00175 - if ( isset($this->_conf['_modules']) and count($this->_conf['_modules']) > 0 ){ 00176 - $mt = Dataface_ModuleTool::getInstance(); 00177 - foreach ($this->_conf['_modules'] as $modname=>$modpath){ 00178 - $mt->loadModule($modname); 00179 - 00180 - } 00181 - } 00182 00183 - $this->fireEvent('beforeHandleRequest'); 00184 + 00185 $applicationDelegate = $this->getDelegate(); 00186 if ( isset($applicationDelegate) and method_exists($applicationDelegate, 'beforeHandleRequest') ){ 00187 // Do whatever we need to do before the request is handled. 00188 @@ -1040,7 +1019,6 @@ 00189 if ( isset($applicationDelegate) and method_exists($applicationDelegate, 'getPreferences') ){ 00190 $this->prefs = array_merge($this->prefs, $applicationDelegate->getPreferences()); 00191 } 00192 - $this->prefs = array_map('intval', $this->prefs); 00193 00194 // Check to make sure that this table hasn't been disallowed 00195 $disallowed = false; 00196 @@ -1171,7 +1149,7 @@ 00197 } else { 00198 $locations = array(); 00199 00200 - $locations[ Dataface_Table::getBasePath($query['-table']).'/tables/'.basename($query['-table']).'/actions/'.basename($query['-action']).'.php' ] = 'tables_'.$query['-table'].'_actions_'.$query['-action']; 00201 + $locations[ DATAFACE_SITE_PATH.'/tables/'.basename($query['-table']).'/actions/'.basename($query['-action']).'.php' ] = 'tables_'.$query['-table'].'_actions_'.$query['-action']; 00202 $locations[ DATAFACE_SITE_PATH.'/actions/'.basename($query['-action']).'.php' ] = 'actions_'.$query['-action']; 00203 00204 if ( isset($this->_conf['_modules']) and count($this->_conf['_modules']) > 0 ){