From 68d82b9218f677488fc75f327d2fda55ef6d8827 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 30 Jan 2017 10:59:52 +0100 Subject: [PATCH] Fixed log flag for api/cyclic-hash --- lib/api/source/sync.php | 12 ++++++------ lib/cyclic-hash/source/decr.php | 12 ++++++------ lib/cyclic-hash/source/hash.php | 2 +- lib/cyclic-hash/source/new.php | 6 +++--- lib/include/php/func | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/api/source/sync.php b/lib/api/source/sync.php index f33d8b3..8bb9a10 100755 --- a/lib/api/source/sync.php +++ b/lib/api/source/sync.php @@ -10,7 +10,7 @@ $url = @file_get_contents(URL_CONF); if( $url === false ){ - slog("Cannot find server's api url", 'api:sync'); + slog("Cannot find server's api url", 'api:sync','update'); return 127; } @@ -18,7 +18,7 @@ $hash = syscall(SOURCE_DIR.'/lib/cyclic-hash/hash'); if( strlen($hash) != 128 ){ - slog("Wrong cyclic-hash:hash hash length (".strlen($hash).")", 'api:sync'); + slog("Wrong cyclic-hash:hash hash length (".strlen($hash).")", 'api:sync','update'); return 127; } @@ -26,7 +26,7 @@ $new = syscall(SOURCE_DIR.'/lib/cyclic-hash/new'); if( $new === false ){ - slog("cyclic-hash:new returned $new EXIT_STATUS", 'api:sync'); + slog("cyclic-hash:new returned $new EXIT_STATUS", 'api:sync','update'); return 127; } @@ -37,7 +37,7 @@ $data = json_decode(syscall(SOURCE_DIR.'/lib/api/fetch')); if( is_null($data) ){ - slog("api:fetch returned unreadable content", 'api:sync'); + slog("api:fetch returned unreadable content", 'api:sync','update'); $data = []; } @@ -99,7 +99,7 @@ /* (3) Return response as result */ if( $response === false ){ - slog("Request error", 'api:sync'); + slog("Request error", 'api:sync','update'); return 127; } @@ -110,7 +110,7 @@ $decr = syscall(SOURCE_DIR.'/lib/cyclic-hash/decr'); if( $decr === false ){ - slog("cyclic-hash:decr returned $decr EXIT_STATUS", 'api:sync'); + slog("cyclic-hash:decr returned $decr EXIT_STATUS", 'api:sync','update'); return 127; } diff --git a/lib/cyclic-hash/source/decr.php b/lib/cyclic-hash/source/decr.php index df1cb36..37ba7dc 100755 --- a/lib/cyclic-hash/source/decr.php +++ b/lib/cyclic-hash/source/decr.php @@ -40,10 +40,10 @@ // Try to override the secret file if( @file_put_contents(SECRET_CONF, $secret) ){ - slog("Random secret generated successfully", 'cyclic-hash:decr'); + slog("Random secret generated successfully", 'cyclic-hash:decr', 'update'); return 0; }else{ - slog("Error while generating new random secret", 'cyclic-hash:decr'); + slog("Error while generating new random secret", 'cyclic-hash:decr', 'update'); return 127; } } @@ -63,10 +63,10 @@ /* (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'); + slog("Secret depth decremented to $depth", 'cyclic-hash:decr', 'update'); return 0; }else{ - slog("Error while decrementing secret depth", 'cyclic-hash:decr'); + slog("Error while decrementing secret depth", 'cyclic-hash:decr', 'update'); return 127; } @@ -80,10 +80,10 @@ // Try to override the secret file if( @file_put_contents(SECRET_CONF, $secret) ){ - slog("Random secret generated successfully", 'cyclic-hash:decr'); + slog("Random secret generated successfully", 'cyclic-hash:decr', 'update'); return 0; }else{ - slog("Error while generating new random secret", 'cyclic-hash:decr'); + slog("Error while generating new random secret", 'cyclic-hash:decr', 'update'); return 127; } diff --git a/lib/cyclic-hash/source/hash.php b/lib/cyclic-hash/source/hash.php index b50c1c7..6de2c23 100755 --- a/lib/cyclic-hash/source/hash.php +++ b/lib/cyclic-hash/source/hash.php @@ -31,7 +31,7 @@ $hash = hash('sha512', $hash); - slog("Returning hash with $depth depth", 'cyclic-hash:hash'); + slog("Returning hash with $depth depth", 'cyclic-hash:hash', 'update'); return $hash; } diff --git a/lib/cyclic-hash/source/new.php b/lib/cyclic-hash/source/new.php index 8f8d18d..5de266c 100755 --- a/lib/cyclic-hash/source/new.php +++ b/lib/cyclic-hash/source/new.php @@ -14,7 +14,7 @@ /* (2) Check secret file format */ if( !is_string($secret) || !preg_match("/^(.{".SECRET_SIZE."}):(\d+):(.{".SECRET_SIZE."})$/", $secret, $match) ){ - slog("Error while reading secret", 'cyclic-hash:new'); + slog("Error while reading secret", 'cyclic-hash:new', 'update'); return 127; } @@ -26,7 +26,7 @@ /* (4) Die if not token not changed */ if( $depth > 1 ){ - slog("No new secret with $depth depth", 'cyclic-hash:new'); + slog("No new secret with $depth depth", 'cyclic-hash:new', 'update'); return 0; } @@ -40,7 +40,7 @@ for( $d = 0 ; $d < 1000 ; $d++ ) $newhash = hash('sha512', $newhash); - slog("New secret with $depth depth", 'cyclic-hash:new'); + slog("New secret with $depth depth", 'cyclic-hash:new', 'update'); return $newhash; } diff --git a/lib/include/php/func b/lib/include/php/func index 59dbc10..efddc46 100755 --- a/lib/include/php/func +++ b/lib/include/php/func @@ -21,7 +21,7 @@ /* [2] Log management =========================================================*/ - function slog($message="unknown error...", $feature="default", $flag="daemon"){ + function slog($message="unknown error", $feature="main", $flag="daemon"){ file_put_contents(LOG_DIR."/$flag.log", time()." [$feature] $message\n", FILE_APPEND);