From 0bf05fe76345ca89d355e1aaf12860199fe4fd56 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 17 Jul 2017 19:10:50 +0200 Subject: [PATCH] Allowing SSL on lib/api/update and lib/api/sync --- lib/api/source/deploy.php | 39 +++++++++++++++++++++++++++++++++++++++ lib/api/source/sync.php | 1 + lib/api/source/update.php | 1 + 3 files changed, 41 insertions(+) diff --git a/lib/api/source/deploy.php b/lib/api/source/deploy.php index dd366d7..2706676 100755 --- a/lib/api/source/deploy.php +++ b/lib/api/source/deploy.php @@ -165,6 +165,45 @@ } + slog('History succesfully truncated', 'api:deploy', 'update'); + return 0; + + + + /* [7] Remove features' entries + =========================================================*/ + /* (0) We are done if @sync */ + if( $sync ){ + slog('Post-sync deployment -> no history truncate', 'api:deploy', 'update'); + return 0; + } + + /* (1) Check history entries count */ + if( !isset($arr_r['saved']) || !is_array($arr_r['saved']) ){ + slog('No \'saved\' found in api.response file', 'api:deploy', 'update'); + return 127; + } + + /* (2) Check history count */ + if( !isset($arr_r['saved']['history']) || !is_numeric($arr_r['saved']['history']) ){ + slog('No \'actions\'.\'history\' found in api.response file', 'api:deploy', 'update'); + return 127; + } + + /* (3) Fetch number of entries */ + $saved = intval($arr_r['saved']['history']); + $saved = $saved < 0 ? 0 : $saved; // prevent negative + + /* (4) Truncate the log file */ + $truncated = syscall(SOURCE_DIR."/lib/file/truncate mfrc522 {$saved}"); + + /* (5) Manage error */ + if( $truncated === false ){ + slog('History cannot be truncated', 'api:deploy', 'update'); + return 127; + } + + slog('History succesfully truncated', 'api:deploy', 'update'); return 0; } diff --git a/lib/api/source/sync.php b/lib/api/source/sync.php index 38f40bf..2b8b045 100755 --- a/lib/api/source/sync.php +++ b/lib/api/source/sync.php @@ -68,6 +68,7 @@ /* (3) Additional options */ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // allow SSL diff --git a/lib/api/source/update.php b/lib/api/source/update.php index 2b0f360..ab92e5c 100755 --- a/lib/api/source/update.php +++ b/lib/api/source/update.php @@ -56,6 +56,7 @@ /* (3) Additional options */ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // allow SSL