diff --git a/deploy.php b/deploy.php new file mode 100644 index 0000000..0a87147 --- /dev/null +++ b/deploy.php @@ -0,0 +1,132 @@ + + + + 701 Meh + + +

Meh

+

Error 701: Meh (as specified by the RFC for 700 http codes)

+
+
Apache (Ubuntu) Server at admin.strassenkind.ip
+ + + "; + exit(); + } + +// get content type +$content_type = isset($_SERVER['CONTENT_TYPE']) ? strtolower(trim($_SERVER['CONTENT_TYPE'])) : ''; + +if ($content_type != 'application/json') { + error_log('WebHook usage FAILED - not application/json - Content type: '. $content_type); + echo " + + + 756 Insufficiently Polite + + +

Insufficiently Polite

+

Error 756: Insufficiently polite (as specified by the RFC for 700 http codes)

+
+
Apache (Ubuntu) Server at admin.strassenkind.ip
+ + + "; + exit(); + } + +// get payload +$payload = trim(file_get_contents("php://input")); + +if (empty($payload)) { + error_log('WebHook usage FAILED - no payload'); + echo " + + + 768 Accidentally Took Sleeping Pills Instead Of Migraine Pills During Crunch Week + + +

Accidentally Took Sleeping Pills Instead Of Migraine Pills During Crunch Week

+

Error 768: Accidentally Took Sleeping Pills Instead Of Migraine Pills During Crunch Week (as specified by the RFC for 700 http codes)

+
+
Apache (Ubuntu) Server at admin.strassenkind.ip
+ + + "; + exit(); + } + +// get header signature +$header_signature = isset($_SERVER['HTTP_X_GITEA_SIGNATURE']) ? $_SERVER['HTTP_X_GITEA_SIGNATURE'] : ''; + +if (empty($header_signature)) { + error_log('WebHook usage FAILED - header signature missing'); + echo " + + + 787 Further Funding Required + + +

Further Funding Required

+

Error 701: Further Funding Required (as specified by the RFC for 700 http codes)

+
+
Apache (Ubuntu) Server at admin.strassenkind.ip
+ + + "; + exit(); + } + +// calculate payload signature +$payload_signature = hash_hmac('sha256', $payload, $secret_key, false); + +// check payload signature against header signature +if ($header_signature != $payload_signature) { + error_log('WebHook usage FAILED - payload signature'); + echo " + + + 776 Error on the Exception + + +

Error on the Exception

+

Error 776: Error on the Exception (as specified by the RFC for 700 http codes)

+
+
Apache (Ubuntu) Server at admin.strassenkind.ip
+ + + "; + exit(); + } + +// convert json to array +$decoded = json_decode($payload, true); + +// check for json decode errors +if (json_last_error() !== JSON_ERROR_NONE) { + error_log('WebHook usage FAILED - json decode - '. json_last_error()); + echo " + + + 705 I wrote the code and missed the necessary validation by an oversight + + +

I wrote the code and missed the necessary validation by an oversight

+

Error 705: I wrote the code and missed the necessary validation by an oversight (as specified by the RFC for 700 http codes)

+
+
Apache (Ubuntu) Server at admin.strassenkind.ip
+ + + "; + exit(); + } + +// success, do something +system("/var/www/git/deploy-now " . $decoded['repository']['name'] . " " . $decoded['repository']['ssh_url'] . " >>stdout.log 2>>stderr.log &");