forked from iocron/gitwebhook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
34 lines (27 loc) · 1.04 KB
/
index.php
File metadata and controls
34 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// Requirements / Includes
require_once(__DIR__."/lib/gitwebhook.php");
// Config / Default Settings
$configFile = __DIR__."/configs/config.json";
if(!file_exists($configFile)) {
$errMsg = "[ERROR]: The Gitwebhook Config File ({$configFile}) doesn't exist (or the path is not accessible)!";
if(ini_get('display_errors') != "1") echo "{$errMsg}";
throw new Exception("{$errMsg}");
}
$config = json_decode(file_get_contents($configFile),true);
if(!is_readable($configFile)) {
$errMsg = "[ERROR]: The Gitwebhook Config File ({$configFile}) is not accessible / readable.";
if(ini_get('display_errors') != "1") echo "{$errMsg}";
throw new Exception("{$errMsg}");
}
if(empty($config) || !is_array($config)) {
$errMsg = "[ERROR]: The Gitwebhook Config File ({$configFile}) is not a valid JSON File.";
if(ini_get('display_errors') != "1") echo "{$errMsg}";
throw new Exception("{$errMsg}");
}
// Gitwebhook
$webhook = new Gitwebhook($config);
$validate = $webhook->validateInit();
if($validate) {
$webhook->handle();
}