From 42c026a6182205b60bc10ff14ac619d6696adc61 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Mon, 18 Dec 2017 15:02:53 +0100 Subject: [PATCH] Add notification to webhook on new updates. --- index.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/index.php b/index.php index 55bb26b..cd4be50 100644 --- a/index.php +++ b/index.php @@ -42,6 +42,25 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($g->tv) { $sqlw = new SQLiteWriter(); $result = $sqlw->addGotu($g, $file_date); + if ($result !== false) { + $config = parse_ini_file(__DIR__ . '/config.ini'); + $type = 'FULL'; + if ($g->fv) { + $type = 'OTA (from ' . $g->fv . ')'; + } + $data = array( + 'content' => 'New ' . $type . ' update for ' . $g->ref . ' found: ' . $g->tv, + ); + $options = array( + 'http' => array( + 'header' => "Content-Type: application/x-www-form-urlencoded\r\n", + 'method' => 'POST', + 'content' => http_build_query($data), + ), + ); + $ctx = stream_context_create($options); + $notify_ok = file_get_contents($config['NOTIFY_WEBHOOK'], false, $ctx); + } // I don't care if we can use the data or not. Maybe we can use it later (backup copy). }