From e01ec143188055b7e6414bda2c1fcacc19ab3581 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 18 Feb 2017 18:43:04 +0100 Subject: [PATCH 1/2] update non-local links --- lib/include/bash/const | 8 ++++---- lib/include/php/const | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/include/bash/const b/lib/include/bash/const index e288965..5c742d7 100755 --- a/lib/include/bash/const +++ b/lib/include/bash/const @@ -3,13 +3,13 @@ # RESET OUTPUT BUFFER # MAIN DIRECTORIES -#export ROOT_DIR="/home/sats/satsd"; -export ROOT_DIR="/home/xdrm-brackets/SANDBOX/sats-local"; +export ROOT_DIR="/home/sats/satsd"; +#export ROOT_DIR="/home/xdrm-brackets/SANDBOX/sats-local"; export LOG_DIR="$ROOT_DIR/log"; export DATA_DIR="$ROOT_DIR/data"; export CONF_DIR="$ROOT_DIR/conf"; -#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="$ROOT_DIR/source"; +#export SOURCE_DIR="/home/xdrm-brackets/Desktop/git.xdr/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats"; export TMP_DIR="$ROOT_DIR/tmp"; # CONFIGURATION FILES diff --git a/lib/include/php/const b/lib/include/php/const index 29db023..a25e726 100755 --- a/lib/include/php/const +++ b/lib/include/php/const @@ -3,17 +3,17 @@ # RESET OUTPUT BUFFER # MAIN DIRECTORIES - #define('ROOT_DIR', '/home/sats/satsd'); - define('ROOT_DIR', '/home/xdrm-brackets/SANDBOX/sats-local'); + define('ROOT_DIR', '/home/sats/satsd'); + #define('ROOT_DIR', '/home/xdrm-brackets/SANDBOX/sats-local'); define('LOG_DIR', ROOT_DIR.'/log'); define('DATA_DIR', ROOT_DIR.'/data'); 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.xdr/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats'); define('TMP_DIR', ROOT_DIR.'/tmp'); # CONFIGURATION FILES - define('SECRET_CONF', '/home/xdrm-brackets/Desktop/git.xdr/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats'); + define('SECRET_CONF', CONF_DIR.'/machine.secret'); define('STATE_CONF', CONF_DIR.'/machine.state'); define('BRANCH_CONF', CONF_DIR.'/machine.branch'); define('ID_CONF', CONF_DIR.'/machine.id'); From 78fe237d8a28328a82c27316bc4e67b6303a2a3e Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 23 Feb 2017 15:12:01 +0100 Subject: [PATCH 2/2] [Fixed] Removed use of STATES_CONF : relation between GLOBAL_STATE <=> CHIP_STATE --- lib/mfrc522/source/loop.php | 48 ++++++++++--------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/lib/mfrc522/source/loop.php b/lib/mfrc522/source/loop.php index a7f66e9..e6a48a7 100755 --- a/lib/mfrc522/source/loop.php +++ b/lib/mfrc522/source/loop.php @@ -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);