1 ){ /* (1) Decrement the depth */ $depth--; /* (2) Try to override the secret file */ if( @file_put_contents(SECRET_CONF, "$key:$depth:$next") ){ slog("Secret depth decremented to $depth", 'cyclic-hash:decr', 'update'); return 0; }else{ slog("Error while decrementing secret depth", 'cyclic-hash:decr', 'update'); return 127; } /* [4] If cannot decrement, use new secret and generate next =========================================================*/ }else{ // Generate new secret $secret = $next.':999:'.generate_secret(); // Try to override the secret file if( @file_put_contents(SECRET_CONF, $secret) ){ slog("Random secret generated successfully", 'cyclic-hash:decr', 'update'); return 0; }else{ slog("Error while generating new random secret", 'cyclic-hash:decr', 'update'); return 127; } } return 0; } echo cyclichash_decr(); ?>