-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
34 lines (30 loc) · 1.15 KB
/
index.php
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)){
$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}");
}
} else {
$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}");
}
// Gitwebhook
$webhook = new Gitwebhook($config);
$webhookData = $webhook->getData();
$validate = $webhook->validateInit();
if($validate){
$webhook->handle();
}
?>