From 98cc47e654b3ee101f96d70fb62b05089cf1fbb8 Mon Sep 17 00:00:00 2001 From: myvesta <38690722+myvesta@users.noreply.github.com> Date: Sun, 30 Aug 2020 05:05:49 +0200 Subject: [PATCH] Update main.php --- func/main.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/func/main.php b/func/main.php index 16c5fef6..bb628082 100644 --- a/func/main.php +++ b/func/main.php @@ -3,11 +3,16 @@ $myvesta_current_user=exec('whoami', $myvesta_output, $myvesta_return_var); if ($myvesta_current_user != 'root') {echo "ERROR: You must be root to execute this script\n"; exit(1);} -define('myvesta_exit_on_error', true); +$myvesta_exit_on_error=true; +define('MYVESTA_ERROR_PERMISSION_DENIED', 1); +define('MYVESTA_ERROR_MISSING_ARGUMENTS', 2); +define('MYVESTA_ERROR_FILE_DOES_NOT_EXISTS', 3); +define('MYVESTA_ERROR_STRING_DOES_NOT_EXISTS', 4); function myvesta_throw_error($code, $message) { + global $myvesta_exit_on_error; echo "ERROR: ".$message."\n"; - if (defined('myvesta_exit_on_error')) myvesta_exit($code); + if ($myvesta_exit_on_error) myvesta_exit($code); return $code; } @@ -27,7 +32,7 @@ function myvesta_check_args ($requried_arguments, $arguments) { if ($argument_counter<$requried_arguments) { $arguments=str_replace(" ", "' '", $arguments); $arguments="'".$arguments."'"; - return myvesta_throw_error(1, "Usage: $command $arguments"); + return myvesta_throw_error(MYVESTA_ERROR_MISSING_ARGUMENTS, "Usage: $command $arguments"); } $argument_arr=explode(" ", $arguments); $i=1;