Merge branch '1.0' into 1.0-local

This commit is contained in:
xdrm-brackets 2017-02-23 15:24:09 +01:00
commit 40a8e895c4
3 changed files with 21 additions and 43 deletions

View File

@ -3,13 +3,13 @@
# RESET OUTPUT BUFFER # RESET OUTPUT BUFFER
# MAIN DIRECTORIES # MAIN DIRECTORIES
#export ROOT_DIR="/home/sats/satsd"; export ROOT_DIR="/home/sats/satsd";
export ROOT_DIR="/home/xdrm-brackets/SANDBOX/sats-local"; #export ROOT_DIR="/home/xdrm-brackets/SANDBOX/sats-local";
export LOG_DIR="$ROOT_DIR/log"; export LOG_DIR="$ROOT_DIR/log";
export DATA_DIR="$ROOT_DIR/data"; export DATA_DIR="$ROOT_DIR/data";
export CONF_DIR="$ROOT_DIR/conf"; export CONF_DIR="$ROOT_DIR/conf";
#export SOURCE_DIR="$ROOT_DIR/source"; export SOURCE_DIR="$ROOT_DIR/source";
export SOURCE_DIR="/home/xdrm-brackets/Desktop/git.xdr/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats"; #export SOURCE_DIR="/home/xdrm-brackets/Desktop/git.xdr/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats";
export TMP_DIR="$ROOT_DIR/tmp"; export TMP_DIR="$ROOT_DIR/tmp";

View File

@ -3,13 +3,13 @@
# RESET OUTPUT BUFFER # RESET OUTPUT BUFFER
# MAIN DIRECTORIES # MAIN DIRECTORIES
#define('ROOT_DIR', '/home/sats/satsd'); define('ROOT_DIR', '/home/sats/satsd');
define('ROOT_DIR', '/home/xdrm-brackets/SANDBOX/sats-local'); #define('ROOT_DIR', '/home/xdrm-brackets/SANDBOX/sats-local');
define('LOG_DIR', ROOT_DIR.'/log'); define('LOG_DIR', ROOT_DIR.'/log');
define('DATA_DIR', ROOT_DIR.'/data'); define('DATA_DIR', ROOT_DIR.'/data');
define('CONF_DIR', ROOT_DIR.'/conf'); define('CONF_DIR', ROOT_DIR.'/conf');
#define('SOURCE_DIR', ROOT_DIR.'/source'); define('SOURCE_DIR', ROOT_DIR.'/source');
define('SOURCE_DIR', '/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats'); #define('SOURCE_DIR', '/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats');
define('TMP_DIR', ROOT_DIR.'/tmp'); define('TMP_DIR', ROOT_DIR.'/tmp');
# CONFIGURATION FILES # CONFIGURATION FILES

View File

@ -6,13 +6,11 @@
$f_auth; $f_auth;
$f_accesslog; $f_accesslog;
$f_states;
$f_actions; $f_actions;
$state = []; $state = null;
$actions = []; $actions = [];
$states = [];
$last_user = null; $last_user = null;
$timeout = 0; $timeout = 0;
@ -82,7 +80,7 @@
global $timeout; global $timeout;
/* (2) Caches */ /* (2) Caches */
global $actions, $states, $state; global $actions, $state;
/* (3) Log history file descriptor */ /* (3) Log history file descriptor */
global $f_accesslog; global $f_accesslog;
@ -218,7 +216,7 @@
global $f_auth, $f_accesslog; global $f_auth, $f_accesslog;
/* (2) Caches */ /* (2) Caches */
global $actions, $states, $state; global $actions, $state;
@ -226,7 +224,6 @@
=========================================================*/ =========================================================*/
/* (1) Read accesses */ /* (1) Read accesses */
$f_auth = new SplFileObject(AUTH_CONF, 'r'); $f_auth = new SplFileObject(AUTH_CONF, 'r');
$f_states = new SplFileObject(STATES_CONF, 'r');
$f_actions = new SplFileObject(ACTIONS_CONF, 'r'); $f_actions = new SplFileObject(ACTIONS_CONF, 'r');
$f_gstate = @file_get_contents(STATE_CONF); $f_gstate = @file_get_contents(STATE_CONF);
@ -264,43 +261,24 @@
/* [3] Parse STATES and cache them /* [3] Cache global state
=========================================================*/
/* (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
=========================================================*/ =========================================================*/
/* (1) Check file */ /* (1) Check file */
if( $f_gstate === false ) if( $f_gstate === false )
return false; return 127;
/* (2) Remove surrounding spaces */ /* (2) Remove surrounding spaces */
$f_gstate = preg_replace('@^\s+@', '', $f_gstate); $f_gstate = preg_replace('@^\s+@', '', $f_gstate);
$f_gstate = preg_replace('@\s+$@', '', $f_gstate); $f_gstate = preg_replace('@\s+$@', '', $f_gstate);
/* (3) For each character create an entry */ /* (3) For each character create an entry */
for( $c = 0 ; $c < strlen($f_gstate) ; $c++ ) $state = str_split($f_gstate);
$state[] = $c;
return true; /* (4) Manage error */
if( is_null($state) )
return 127;
return 0;
} }
@ -316,7 +294,7 @@
global $timeout; global $timeout;
/* (2) Caches */ /* (2) Caches */
global $actions, $states, $state; global $actions, $state;
@ -411,7 +389,7 @@
$exec = mfrc522_setup(); $exec = mfrc522_setup();
/* (2) Manage error */ /* (2) Manage error */
if( $exec === false ){ if( $exec != 0 ){
slog('cannot set up the daemon', 'mfrc522:loop'); slog('cannot set up the daemon', 'mfrc522:loop');
echo $exec; echo $exec;
die($exec); die($exec);