upd: lib.cyclic-hash{decr,source/decr.php} > added optional arg 'revert' to `incr` instead of `decr`

This commit is contained in:
xdrm-brackets 2018-01-26 14:05:47 +01:00
parent 2eeb4ed6ff
commit d564612512
2 changed files with 10 additions and 7 deletions

View File

@ -1,3 +1,3 @@
#!/bin/sh
/usr/bin/env php $(realpath $(dirname $0))/source/decr.php;
/usr/bin/env php $(realpath $(dirname $0))/source/decr.php $1;

View File

@ -24,7 +24,7 @@
function cyclichash_decr(){
function cyclichash_decr($decr_factor=-1){
/* [2] Fetch necessary data
=========================================================*/
@ -59,7 +59,7 @@
if( $depth > 1 ){
/* (1) Decrement the depth */
$depth--;
$depth += $decr_factor;
/* (2) Try to override the secret file */
if( @file_put_contents(SECRET_CONF, "$key:$depth:$next") ){
@ -94,7 +94,10 @@
}
echo cyclichash_decr();
// IF received 'revert' as $1 -> increment ELSE decrement (default)
$decr_factor = ( $argc < 2 || $argv[1] != 'revert' ) ? -1 : +1;
echo cyclichash_decr($decr_factor);
?>