2019-12-28 22:42:25 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
global $API_OPTIONS;
|
2019-12-29 00:02:38 +01:00
|
|
|
global $OPTIONS;
|
2019-12-28 22:42:25 +01:00
|
|
|
|
|
|
|
require_once (__DIR__ . '/../internals/base.php');
|
|
|
|
require_once (__DIR__ . '/../internals/database.php');
|
|
|
|
|
2019-12-29 00:02:38 +01:00
|
|
|
if (!isset($API_OPTIONS['target'])) httpDie(400, "Wrong parameters.");
|
2019-12-28 22:42:25 +01:00
|
|
|
|
|
|
|
$hook = $API_OPTIONS['target'];
|
2019-12-29 00:02:38 +01:00
|
|
|
$uri = $OPTIONS['uri'];
|
2019-12-28 22:42:25 +01:00
|
|
|
|
|
|
|
$cmd = "";
|
|
|
|
|
|
|
|
if ($hook == 'website_mikescher') $cmd = 'git pull';
|
|
|
|
else if ($hook == 'griddominance') $cmd = 'update-gdapi';
|
2019-12-29 00:02:38 +01:00
|
|
|
else httpDie(400, "Unknown webhook: $hook");
|
2019-12-28 22:42:25 +01:00
|
|
|
|
|
|
|
$std = shell_exec($cmd);
|
|
|
|
|
|
|
|
$content = "REQUEST: " . $uri . "\r\n\r\n" .
|
|
|
|
"IP: " . get_client_ip() . "\r\n\r\n" .
|
|
|
|
"TARGET: " . $hook . "\r\n\r\n" .
|
|
|
|
"OUTPUT: " . $std . "\r\n\r\n";
|
|
|
|
|
|
|
|
sendMail("Webhook '$hook' triggered", $content, 'virtualadmin@mikescher.de', 'webserver-info@mikescher.com');
|