Skip to content

Commit 80d5dd9

Browse files
committed
check_return_code function
1 parent 8f9c727 commit 80d5dd9

File tree

16 files changed

+285
-712
lines changed

16 files changed

+285
-712
lines changed

web/add/cron/index.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,10 @@
4444
exec (VESTA_CMD."v-add-cron-job ".$user." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var);
4545
$v_type = $_POST['v_type'];
4646
$v_charset = $_POST['v_charset'];
47-
if ($return_var != 0) {
48-
$error = implode('<br>', $output);
49-
if (empty($error)) $error = __('Error code:',$return_var);
50-
$_SESSION['error_msg'] = $error;
51-
unset($v_password);
52-
unset($output);
53-
} else {
47+
check_return_code($return_var,$output);
48+
unset($v_password);
49+
unset($output);
50+
if (empty($_SESSION['error_msg'])) {
5451
$_SESSION['ok_msg'] = __('CRON_CREATED_OK');
5552
unset($v_min);
5653
unset($v_hour);

web/add/db/index.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,9 @@
6262
exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var);
6363
$v_type = $_POST['v_type'];
6464
$v_charset = $_POST['v_charset'];
65-
if ($return_var != 0) {
66-
$error = implode('<br>', $output);
67-
if (empty($error)) $error = __('Error code:',$return_var);
68-
$_SESSION['error_msg'] = $error;
69-
unset($v_password);
70-
unset($output);
71-
}
72-
if ((!empty($v_db_email)) && ($return_var == 0)) {
65+
check_return_code($return_var,$output);
66+
unset($output);
67+
if ((!empty($v_db_email)) && (empty($_SESSION['error_msg']))) {
7368
list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]);
7469
if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpmyadmin/";
7570
if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phppgadmin/";
@@ -80,13 +75,14 @@
8075
$mailtext = __('DATABASE_READY',$user."_".$_POST['v_database'],$user."_".$_POST['v_dbuser'],$_POST['v_password'],$db_admin_link);
8176
send_email($to, $subject, $mailtext, $from);
8277
}
83-
$_SESSION['ok_msg'] = __('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']);
84-
unset($v_database);
85-
unset($v_dbuser);
86-
unset($v_password);
87-
unset($v_type);
88-
unset($v_charset);
89-
unset($output);
78+
if (empty($_SESSION['error_msg'])) {
79+
$_SESSION['ok_msg'] = __('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']);
80+
unset($v_database);
81+
unset($v_dbuser);
82+
unset($v_password);
83+
unset($v_type);
84+
unset($v_charset);
85+
}
9086
}
9187
}
9288

web/add/dns/index.php

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,22 @@
4141
} else {
4242
// Add DNS
4343
exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip." ".$v_ns1." ".$v_ns2." ".$v_ns3." ".$v_ns4, $output, $return_var);
44-
if ($return_var != 0) {
45-
$error = implode('<br>', $output);
46-
if (empty($error)) $error = __('Error code:',$return_var);
47-
$_SESSION['error_msg'] = $error;
48-
}
44+
check_return_code($return_var,$output);
4945
unset($output);
5046

5147
// Change Expiriation date
5248
if ((!empty($_POST['v_exp'])) && ($_POST['v_exp'] != date('Y-m-d', strtotime('+1 year')))) {
5349
$v_exp = escapeshellarg($_POST['v_exp']);
5450
exec (VESTA_CMD."v-change-dns-domain-exp ".$user." ".$v_domain." ".$v_exp, $output, $return_var);
55-
if ($return_var != 0) {
56-
$error = implode('<br>', $output);
57-
if (empty($error)) $error = __('Error code:',$return_var);
58-
$_SESSION['error_msg'] = $error;
59-
}
51+
check_return_code($return_var,$output);
6052
unset($output);
6153
}
6254

6355
// Change TTL
64-
if ((!empty($_POST['v_ttl'])) && ($_POST['v_ttl'] != '14400')) {
56+
if ((!empty($_POST['v_ttl'])) && ($_POST['v_ttl'] != '14400') && (empty($_SESSION['error_msg']))) {
6557
$v_ttl = escapeshellarg($_POST['v_ttl']);
6658
exec (VESTA_CMD."v-change-dns-domain-ttl ".$user." ".$v_domain." ".$v_ttl, $output, $return_var);
67-
if ($return_var != 0) {
68-
$error = implode('<br>', $output);
69-
if (empty($error)) $error = __('Error code:',$return_var);
70-
$_SESSION['error_msg'] = $error;
71-
}
59+
check_return_code($return_var,$output);
7260
unset($output);
7361
}
7462

@@ -108,11 +96,7 @@
10896
// Add DNS Record
10997
exec (VESTA_CMD."v-add-dns-record ".$user." ".$v_domain." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority, $output, $return_var);
11098
$v_type = $_POST['v_type'];
111-
if ($return_var != 0) {
112-
$error = implode('<br>', $output);
113-
if (empty($error)) $error = __('Error code:',$return_var);
114-
$_SESSION['error_msg'] = $error;
115-
}
99+
check_return_code($return_var,$output);
116100
unset($output);
117101
if (empty($_SESSION['error_msg'])) {
118102
$_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',$_POST[v_rec],$_POST[v_domain]);

web/add/ip/index.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,14 @@
5555
exec (VESTA_CMD."v-add-sys-ip ".$v_ip." ".$v_netmask." ".$v_interface." ".$v_owner." '".$ip_status."' ".$v_name." ".$v_nat, $output, $return_var);
5656
$v_owner = $_POST['v_owner'];
5757
$v_interface = $_POST['v_interface'];
58-
if ($return_var != 0) {
59-
$error = implode('<br>', $output);
60-
if (empty($error)) $error = __('Error code:',$return_var);
61-
$_SESSION['error_msg'] = $error;
62-
unset($v_password);
63-
unset($output);
64-
} else {
58+
check_return_code($return_var,$output);
59+
unset($output);
60+
if (empty($_SESSION['error_msg'])) {
6561
$_SESSION['ok_msg'] = __('IP_CREATED_OK',$_POST['v_ip'],$_POST['v_ip']);
6662
unset($v_ip);
6763
unset($v_netmask);
6864
unset($v_name);
6965
unset($v_nat);
70-
unset($output);
7166
}
7267
}
7368
}

0 commit comments

Comments
 (0)