1
0
mirror of https://github.com/mbirth/tcl_update_db.git synced 2024-11-09 23:06:45 +00:00

Add notification to webhook on new updates.

This commit is contained in:
Markus Birth 2017-12-18 15:02:53 +01:00
parent f37b98cbee
commit 42c026a618
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A

View File

@ -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).
}