update via webhook
This commit is contained in:
parent
fd893db541
commit
fe5f066621
@ -40,6 +40,7 @@ $URL_RULES =
|
|||||||
[ 'url' => ['api', 'test'], 'target' => 'pages/api_test.php', 'options' => [ '_opt' => 'http', ], ],
|
[ 'url' => ['api', 'test'], 'target' => 'pages/api_test.php', 'options' => [ '_opt' => 'http', ], ],
|
||||||
[ 'url' => ['api', 'setselfadress'], 'target' => 'pages/api_setselfadress.php', 'options' => [ '_opt' => 'http', ], ],
|
[ 'url' => ['api', 'setselfadress'], 'target' => 'pages/api_setselfadress.php', 'options' => [ '_opt' => 'http', ], ],
|
||||||
[ 'url' => ['api', 'statsping'], 'target' => 'pages/api_stats.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%', 'ClientID' => '%GET%', 'Version' => '%GET%', 'ProviderStr' => '%GET%', 'ProviderID' => '%GET%', 'NoteCount' => '%GET%', ], ],
|
[ 'url' => ['api', 'statsping'], 'target' => 'pages/api_stats.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%', 'ClientID' => '%GET%', 'Version' => '%GET%', 'ProviderStr' => '%GET%', 'ProviderID' => '%GET%', 'NoteCount' => '%GET%', ], ],
|
||||||
|
[ 'url' => ['api', 'webhook', '${target}'], 'target' => 'pages/api_webhook.php', 'options' => [ '_opt' => 'http', 'target' => '%URL%', 'secret' => '%GET%', ],],
|
||||||
|
|
||||||
[ 'url' => ['admin'], 'target' => 'pages/admin.php', 'options' => [ '_opt' => 'password'], ],
|
[ 'url' => ['admin'], 'target' => 'pages/admin.php', 'options' => [ '_opt' => 'password'], ],
|
||||||
[ 'url' => ['admin', 'cmd', '?{cmd}'], 'target' => 'pages/admin_cmd.php', 'options' => [ '_opt' => 'password', 'cmd' => '%URL%'], ],
|
[ 'url' => ['admin', 'cmd', '?{cmd}'], 'target' => 'pages/admin_cmd.php', 'options' => [ '_opt' => 'password', 'cmd' => '%URL%'], ],
|
||||||
|
28
www/pages/api_webhook.php
Normal file
28
www/pages/api_webhook.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
global $OPTIONS;
|
||||||
|
|
||||||
|
require_once (__DIR__ . '/../internals/base.php');
|
||||||
|
require_once (__DIR__ . '/../internals/database.php');
|
||||||
|
|
||||||
|
$hook = $OPTIONS['target'];
|
||||||
|
$secret = $OPTIONS['secret'];
|
||||||
|
$uri = $OPTIONS['uri'];
|
||||||
|
|
||||||
|
if ($secret !== $CONFIG['webhook_secret']) die('Unauthorized.');
|
||||||
|
|
||||||
|
$cmd = "";
|
||||||
|
|
||||||
|
if ($hook == 'website_mikescher') $cmd = 'git pull';
|
||||||
|
else if ($hook == 'griddominance') $cmd = 'update-gdapi';
|
||||||
|
else throw new Exception("Unknown webhook: $hook");
|
||||||
|
|
||||||
|
|
||||||
|
$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-error@mikescher.com');
|
Loading…
Reference in New Issue
Block a user