Merge branch '1.0-local' into 1.0
This commit is contained in:
commit
d9be4061aa
|
@ -5,7 +5,6 @@
|
|||
require_once __DIR__.'/../../include/php/const';
|
||||
|
||||
$f_auth;
|
||||
$f_gstate;
|
||||
$f_accesslog;
|
||||
$f_actions;
|
||||
|
||||
|
@ -26,8 +25,8 @@
|
|||
*/
|
||||
function get_gstate(){
|
||||
|
||||
/* (1) Export global file descriptor */
|
||||
global $f_gstate;
|
||||
/* (1) Initialize file descriptor */
|
||||
$f_gstate = new SplFileObject(STATE_CONF, 'r');
|
||||
|
||||
/* (2) Read first line */
|
||||
$f_gstate->seek(0);
|
||||
|
@ -36,11 +35,13 @@
|
|||
$state = preg_replace('@^\s+@', '', $state);
|
||||
$state = preg_replace('@\s+$@', '', $state);
|
||||
|
||||
/* (3) Check data */
|
||||
/* (3) Free file descriptor */
|
||||
|
||||
/* (4) Check data */
|
||||
if( strlen($state) < 1 )
|
||||
return false;
|
||||
|
||||
/* (4) Return global state */
|
||||
/* (5) Return global state */
|
||||
return $state;
|
||||
}
|
||||
|
||||
|
@ -111,7 +112,6 @@
|
|||
global $f_accesslog;
|
||||
|
||||
/* (5) Update global state */
|
||||
global $f_gstate;
|
||||
$state = get_gstate();
|
||||
|
||||
// manage error
|
||||
|
@ -211,8 +211,7 @@
|
|||
|
||||
|
||||
/* (2) Update the state file */
|
||||
$f_gstate->seek(0);
|
||||
$written = $f_gstate->fwrite($state);
|
||||
$written = @file_put_contents(STATE_CONF, $state);
|
||||
|
||||
/* (3) Manage error */
|
||||
if( $written === false )
|
||||
|
@ -251,7 +250,7 @@
|
|||
/* [0] Initialize global variables
|
||||
=========================================================*/
|
||||
/* (1) File descriptiors */
|
||||
global $f_auth, $f_accesslog, $f_gstate;
|
||||
global $f_auth, $f_accesslog;
|
||||
|
||||
/* (2) Caches */
|
||||
global $actions;
|
||||
|
@ -263,7 +262,6 @@
|
|||
/* (1) Read accesses */
|
||||
$f_auth = new SplFileObject(AUTH_CONF, 'r');
|
||||
$f_actions = new SplFileObject(ACTIONS_CONF, 'r');
|
||||
$f_gstate = new SplFileObject(STATE_CONF, 'r+');
|
||||
|
||||
/* (2) Append accesses (logs) */
|
||||
$f_accesslog = new SplFileObject(DEFAULT_DATA, 'a');
|
||||
|
|
Loading…
Reference in New Issue