From d56461251222d758c23aad0efbb897a362817abf Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 26 Jan 2018 14:05:47 +0100 Subject: [PATCH] upd: lib.cyclic-hash{decr,source/decr.php} > added optional arg 'revert' to `incr` instead of `decr` --- lib/cyclic-hash/decr | 2 +- lib/cyclic-hash/source/decr.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/cyclic-hash/decr b/lib/cyclic-hash/decr index 41f572b..6f0c053 100755 --- a/lib/cyclic-hash/decr +++ b/lib/cyclic-hash/decr @@ -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; diff --git a/lib/cyclic-hash/source/decr.php b/lib/cyclic-hash/source/decr.php index 37ba7dc..fd8d1de 100755 --- a/lib/cyclic-hash/source/decr.php +++ b/lib/cyclic-hash/source/decr.php @@ -1,5 +1,5 @@ 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") ){ @@ -74,7 +74,7 @@ /* [4] If cannot decrement, use new secret and generate next =========================================================*/ }else{ - + // Generate new secret $secret = $next.':999:'.generate_secret(); @@ -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); ?>