Check requrements

This commit is contained in:
Sándor 2021-05-21 15:50:37 +02:00
parent abb80b89af
commit 1319b4349a

View File

@ -1,13 +1,6 @@
#!/usr/bin/php
<?php
// Settings
if (!file_exists(__DIR__.'/config.json'))
logger(1, 'Config file not found', 1, true);
if (!$_set = @json_decode(@file_get_contents(__DIR__.'/config.json')))
logger(1, 'Unable to load or parse configuration file', 1, true);
/* -------------------------------------------------------------- */
// Basic functions
@ -21,10 +14,13 @@ function logger($tabs = 1, $txt, $lvl = 1, $exit = false)
exit;
return true;
}
function is_dir_empty($dir) {
function is_dir_empty($dir)
{
if (!is_readable($dir)) return NULL;
return (count(scandir($dir)) == 2);
}
function notify($sub, $msg, $loglevel = 1)
{
global $_set;
@ -35,6 +31,18 @@ function notify($sub, $msg, $loglevel = 1)
logger($loglevel, 'Unable to send notification E-mail');
}
// Check requirements
if (!function_exists('curl_init'))
logger(1, 'cURL is required but not available', 1, true);
if (!function_exists('json_decode'))
logger(1, 'json_decode is required but not available', 1, true);
// Settings
if (!file_exists(__DIR__.'/config.json'))
logger(1, 'Config file not found', 1, true);
if (!$_set = @json_decode(@file_get_contents(__DIR__.'/config.json')))
logger(1, 'Unable to load or parse configuration file', 1, true);
// Loop indefinitely
while (true) :