upd: lib.cyclic-hash{decr,source/decr.php} > added optional arg 'revert' to `incr` instead of `decr`
This commit is contained in:
parent
2eeb4ed6ff
commit
d564612512
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
/usr/bin/env php $(realpath $(dirname $0))/source/decr.php;
|
/usr/bin/env php $(realpath $(dirname $0))/source/decr.php $1;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function cyclichash_decr(){
|
function cyclichash_decr($decr_factor=-1){
|
||||||
|
|
||||||
/* [2] Fetch necessary data
|
/* [2] Fetch necessary data
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
if( $depth > 1 ){
|
if( $depth > 1 ){
|
||||||
|
|
||||||
/* (1) Decrement the depth */
|
/* (1) Decrement the depth */
|
||||||
$depth--;
|
$depth += $decr_factor;
|
||||||
|
|
||||||
/* (2) Try to override the secret file */
|
/* (2) Try to override the secret file */
|
||||||
if( @file_put_contents(SECRET_CONF, "$key:$depth:$next") ){
|
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);
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue