Merge branch '1.0-local' into 1.0

This commit is contained in:
xdrm-brackets 2017-02-21 15:59:33 +01:00
commit c12129f02c
3 changed files with 13 additions and 16 deletions

View File

@ -27,15 +27,15 @@
} }
/* (3) Try new hash if available */ /* (3) Try new hash if available */
$new = syscall(SOURCE_DIR.'/lib/cyclic-hash/new'); $new_hash = syscall(SOURCE_DIR.'/lib/cyclic-hash/new');
if( $new === false ){ if( $new_hash === false ){
slog("cyclic-hash:new returned $new EXIT_STATUS", 'api:sync','update'); slog("cyclic-hash:new returned $new EXIT_STATUS", 'api:sync','update');
return 127; return 127;
} }
/* (4) Fetch data */ /* (4) Fetch data */
$data = json_decode(syscall(SOURCE_DIR.'/lib/api/fetch')); $data = json_decode(syscall(SOURCE_DIR.'/lib/api/fetch'), true);
if( is_null($data) ){ if( is_null($data) ){
slog("api:fetch returned unreadable content", 'api:sync','update'); slog("api:fetch returned unreadable content", 'api:sync','update');
@ -62,16 +62,9 @@
/* [3] Manage post data /* [3] Manage post data
=========================================================*/ =========================================================*/
/* (1) Set post data */ /* (1) Set post data */
$postarray = [ $postarray = [ 'data' => json_encode($data) ];
'token' => $hash,
'data' => json_encode($data)
];
/* (2) Add renew if renew */ /* (2) Set postdata raw to curl */
if( strlen($new) == 128 )
$postarray['renew'] = $new;
/* (3) Set postdata raw to curl */
curl_setopt($curl, CURLOPT_POSTFIELDS, $postarray); curl_setopt($curl, CURLOPT_POSTFIELDS, $postarray);
@ -87,9 +80,13 @@
$wh_tok = preg_replace('/\s/', '', $wh_tok); $wh_tok = preg_replace('/\s/', '', $wh_tok);
/* (2) Set Auth header digest */ /* (2) Calculate @new_hash (default value) */
if( strlen($new_hash) != 128 )
$new_hash = $hash;
/* (3) Set Auth header digest */
curl_setopt($curl, CURLOPT_HTTPHEADER, [ curl_setopt($curl, CURLOPT_HTTPHEADER, [
"Authorization: Digest $wh_tok" "Authorization: Digest {$wh_tok}{$hash}{$new_hash}"
]); ]);

View File

@ -32,7 +32,7 @@ test -d /sys/class/gpio/gpio$1 || echo $1 > /sys/class/gpio/export;
# [4] Set mode to OUT # [4] Set mode to OUT
#========================================================# #========================================================#
icat /sys/class/gpio/gpio$1/direction | grep -v "in" && echo "in" > /sys/class/gpio/gpio$1/direction; cat /sys/class/gpio/gpio$1/direction | grep -v "in" && echo "in" > /sys/class/gpio/gpio$1/direction;

View File

@ -32,7 +32,7 @@ test -d /sys/class/gpio/gpio$1 || echo $1 > /sys/class/gpio/export;
# [4] Set mode to OUT # [4] Set mode to OUT
#========================================================# #========================================================#
icat /sys/class/gpio/gpio$1/direction | grep -v "out" && echo "out" > /sys/class/gpio/gpio$1/direction; cat /sys/class/gpio/gpio$1/direction | grep -v "out" && echo "out" > /sys/class/gpio/gpio$1/direction;