1
0
www.mikescher.com/www/commands/server_gitwebhook.php

35 lines
970 B
PHP
Raw Permalink Normal View History

<?php
2020-01-16 13:21:14 +01:00
require_once (__DIR__ . '/../internals/website.php');
2020-01-16 13:21:14 +01:00
/** @var PageFrameOptions $FRAME_OPTIONS */ global $FRAME_OPTIONS;
/** @var URLRoute $ROUTE */ global $ROUTE;
/** @var Website $SITE */ global $SITE;
2020-01-16 13:21:14 +01:00
if (!isset($API_OPTIONS['target'])) { $FRAME_OPTIONS->forceResult(400, "Wrong parameters."); return; }
$hook = $API_OPTIONS['target'];
2020-01-16 13:21:14 +01:00
$uri = $ROUTE->full_url;
$cmd = "";
2020-01-16 13:21:14 +01:00
if ($hook == 'website_mikescher')
$cmd = 'git pull';
else if ($hook == 'griddominance')
$cmd = 'update-gdapi';
else
{
$FRAME_OPTIONS->forceResult(400, "Unknown webhook: $hook");
return;
}
$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');
2019-12-29 00:26:57 +01:00
echo "{ 'status': 'ok', 'message': 'Webhook '$hook' triggered' }";