mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-22 14:24:07 -07:00
Create main.php
This commit is contained in:
parent
2a71edda37
commit
071e0d29a2
1 changed files with 38 additions and 0 deletions
38
func/main.php
Normal file
38
func/main.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$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);
|
||||||
|
|
||||||
|
function myvesta_throw_error($code, $message) {
|
||||||
|
echo "ERROR: ".$message."\n";
|
||||||
|
if (defined('myvesta_exit_on_error')) exit($code);
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
|
|
||||||
|
function myvesta_fix_backslashes($s) {
|
||||||
|
$s=str_replace("\\n", "\n", $s);
|
||||||
|
$s=str_replace("\\r", "\r", $s);
|
||||||
|
$s=str_replace("\\t", "\t", $s);
|
||||||
|
return $s;
|
||||||
|
}
|
||||||
|
|
||||||
|
function myvesta_check_args ($requried_arguments, $arguments) {
|
||||||
|
global $argv;
|
||||||
|
$argument_counter=count($argv);
|
||||||
|
$argument_counter--;
|
||||||
|
if ($argument_counter<$requried_arguments) {
|
||||||
|
$command=$argv[0];
|
||||||
|
$command=str_replace('/usr/local/vesta/bin/', '', $command);
|
||||||
|
$arguments=str_replace(" ", "' '", $arguments);
|
||||||
|
$arguments="'".$arguments."'";
|
||||||
|
return myvesta_throw_error(1, "Usage: $command $arguments");
|
||||||
|
}
|
||||||
|
$argument_arr=explode(" ", $arguments);
|
||||||
|
$i=1;
|
||||||
|
foreach ($argument_arr as $argument) {
|
||||||
|
$GLOBALS[$argument]=myvesta_fix_backslashes($argv[$i]);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue