[Fixed] Removed use of STATES_CONF : relation between GLOBAL_STATE <=> CHIP_STATE
This commit is contained in:
parent
e044ad028b
commit
78fe237d8a
|
@ -6,13 +6,11 @@
|
|||
|
||||
$f_auth;
|
||||
$f_accesslog;
|
||||
$f_states;
|
||||
$f_actions;
|
||||
|
||||
$state = [];
|
||||
$state = null;
|
||||
|
||||
$actions = [];
|
||||
$states = [];
|
||||
|
||||
$last_user = null;
|
||||
$timeout = 0;
|
||||
|
@ -82,7 +80,7 @@
|
|||
global $timeout;
|
||||
|
||||
/* (2) Caches */
|
||||
global $actions, $states, $state;
|
||||
global $actions, $state;
|
||||
|
||||
/* (3) Log history file descriptor */
|
||||
global $f_accesslog;
|
||||
|
@ -218,7 +216,7 @@
|
|||
global $f_auth, $f_accesslog;
|
||||
|
||||
/* (2) Caches */
|
||||
global $actions, $states, $state;
|
||||
global $actions, $state;
|
||||
|
||||
|
||||
|
||||
|
@ -226,7 +224,6 @@
|
|||
=========================================================*/
|
||||
/* (1) Read accesses */
|
||||
$f_auth = new SplFileObject(AUTH_CONF, 'r');
|
||||
$f_states = new SplFileObject(STATES_CONF, 'r');
|
||||
$f_actions = new SplFileObject(ACTIONS_CONF, 'r');
|
||||
$f_gstate = @file_get_contents(STATE_CONF);
|
||||
|
||||
|
@ -264,43 +261,24 @@
|
|||
|
||||
|
||||
|
||||
/* [3] Parse STATES and cache them
|
||||
=========================================================*/
|
||||
/* (1) Parse each line */
|
||||
while( $f_states->eof() ){
|
||||
|
||||
/* (2) Try to parse line */
|
||||
$parsed = json_decode($f_states->fgets(), true);
|
||||
|
||||
/* (2) Ignore if parse error */
|
||||
if( is_null($parsed) )
|
||||
continue;
|
||||
|
||||
/* (3) Add entry to cache */
|
||||
$states[] = $parsed;
|
||||
|
||||
}
|
||||
|
||||
/* (4) Free file descriptor */
|
||||
$f_states = null;
|
||||
|
||||
|
||||
|
||||
/* [4] Cache global state
|
||||
/* [3] Cache global state
|
||||
=========================================================*/
|
||||
/* (1) Check file */
|
||||
if( $f_gstate === false )
|
||||
return false;
|
||||
return 127;
|
||||
|
||||
/* (2) Remove surrounding spaces */
|
||||
$f_gstate = preg_replace('@^\s+@', '', $f_gstate);
|
||||
$f_gstate = preg_replace('@\s+$@', '', $f_gstate);
|
||||
|
||||
/* (3) For each character create an entry */
|
||||
for( $c = 0 ; $c < strlen($f_gstate) ; $c++ )
|
||||
$state[] = $c;
|
||||
$state = str_split($f_gstate);
|
||||
|
||||
/* (4) Manage error */
|
||||
if( is_null($state) )
|
||||
return 127;
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -316,7 +294,7 @@
|
|||
global $timeout;
|
||||
|
||||
/* (2) Caches */
|
||||
global $actions, $states, $state;
|
||||
global $actions, $state;
|
||||
|
||||
|
||||
|
||||
|
@ -411,7 +389,7 @@
|
|||
$exec = mfrc522_setup();
|
||||
|
||||
/* (2) Manage error */
|
||||
if( $exec === false ){
|
||||
if( $exec != 0 ){
|
||||
slog('cannot set up the daemon', 'mfrc522:loop');
|
||||
echo $exec;
|
||||
die($exec);
|
||||
|
|
Loading…
Reference in New Issue