$error) { if ($i == 0) { $error_msg = $error; } else { $error_msg = $error_msg . ", " . $error; } } $_SESSION["error_msg"] = sprintf(_('Field "%s" can not be blank.'), $error_msg); } // Protect input $v_package = quoteshellarg($_POST["v_package"]); $v_package_new = quoteshellarg($_POST["v_package_new"]); $v_web_template = quoteshellarg($_POST["v_web_template"]); if (!empty($_SESSION["WEB_BACKEND"])) { $v_backend_template = quoteshellarg($_POST["v_backend_template"]); } if (!empty($_SESSION["PROXY_SYSTEM"])) { $v_proxy_template = quoteshellarg($_POST["v_proxy_template"]); } $v_dns_template = quoteshellarg($_POST["v_dns_template"]); if (!empty($_POST["v_shell"])) { $v_shell = quoteshellarg($_POST["v_shell"]); } else { $v_shell = "nologin"; } $v_web_domains = quoteshellarg($_POST["v_web_domains"]); $v_web_aliases = quoteshellarg($_POST["v_web_aliases"]); $v_dns_domains = quoteshellarg($_POST["v_dns_domains"]); $v_dns_records = quoteshellarg($_POST["v_dns_records"]); $v_mail_domains = quoteshellarg($_POST["v_mail_domains"]); $v_mail_accounts = quoteshellarg($_POST["v_mail_accounts"]); $v_ratelimit = quoteshellarg($_POST["v_ratelimit"]); $v_databases = quoteshellarg($_POST["v_databases"]); $v_cron_jobs = quoteshellarg($_POST["v_cron_jobs"]); $v_backups = quoteshellarg($_POST["v_backups"]); $v_disk_quota = quoteshellarg($_POST["v_disk_quota"]); $v_bandwidth = quoteshellarg($_POST["v_bandwidth"]); $v_ns1 = !empty($_POST["v_ns1"]) ? trim($_POST["v_ns1"], ".") : ""; $v_ns2 = !empty($_POST["v_ns2"]) ? trim($_POST["v_ns2"], ".") : ""; $v_ns3 = !empty($_POST["v_ns3"]) ? trim($_POST["v_ns3"], ".") : ""; $v_ns4 = !empty($_POST["v_ns4"]) ? trim($_POST["v_ns4"], ".") : ""; $v_ns5 = !empty($_POST["v_ns5"]) ? trim($_POST["v_ns5"], ".") : ""; $v_ns6 = !empty($_POST["v_ns6"]) ? trim($_POST["v_ns6"], ".") : ""; $v_ns7 = !empty($_POST["v_ns7"]) ? trim($_POST["v_ns7"], ".") : ""; $v_ns8 = !empty($_POST["v_ns8"]) ? trim($_POST["v_ns8"], ".") : ""; $v_ns = $v_ns1 . "," . $v_ns2; if (!empty($v_ns3)) { $v_ns .= "," . $v_ns3; } if (!empty($v_ns4)) { $v_ns .= "," . $v_ns4; } if (!empty($v_ns5)) { $v_ns .= "," . $v_ns5; } if (!empty($v_ns6)) { $v_ns .= "," . $v_ns6; } if (!empty($v_ns7)) { $v_ns .= "," . $v_ns7; } if (!empty($v_ns8)) { $v_ns .= "," . $v_ns8; } $v_ns = quoteshellarg($v_ns); $v_time = quoteshellarg(date("H:i:s")); $v_date = quoteshellarg(date("Y-m-d")); // Save package file on a fs $pkg = "WEB_TEMPLATE=" . $v_web_template . "\n"; $pkg .= "BACKEND_TEMPLATE=" . $v_backend_template . "\n"; $pkg .= "PROXY_TEMPLATE=" . $v_proxy_template . "\n"; $pkg .= "DNS_TEMPLATE=" . $v_dns_template . "\n"; $pkg .= "WEB_DOMAINS=" . $v_web_domains . "\n"; $pkg .= "WEB_ALIASES=" . $v_web_aliases . "\n"; $pkg .= "DNS_DOMAINS=" . $v_dns_domains . "\n"; $pkg .= "DNS_RECORDS=" . $v_dns_records . "\n"; $pkg .= "MAIL_DOMAINS=" . $v_mail_domains . "\n"; $pkg .= "MAIL_ACCOUNTS=" . $v_mail_accounts . "\n"; $pkg .= "RATE_LIMIT=" . $v_ratelimit . "\n"; $pkg .= "DATABASES=" . $v_databases . "\n"; $pkg .= "CRON_JOBS=" . $v_cron_jobs . "\n"; $pkg .= "DISK_QUOTA=" . $v_disk_quota . "\n"; $pkg .= "BANDWIDTH=" . $v_bandwidth . "\n"; $pkg .= "NS=" . $v_ns . "\n"; $pkg .= "SHELL=" . $v_shell . "\n"; $pkg .= "BACKUPS=" . $v_backups . "\n"; $pkg .= "TIME=" . $v_time . "\n"; $pkg .= "DATE=" . $v_date . "\n"; $tmpfile = tempnam("/tmp/", "hst_"); $fp = fopen($tmpfile, "w"); fwrite($fp, $pkg); exec( HESTIA_CMD . "v-add-user-package " . $tmpfile . " " . $v_package . " yes", $output, $return_var, ); check_return_code($return_var, $output); unset($output); fclose($fp); unlink($tmpfile); // Propagate new package exec(HESTIA_CMD . "v-update-user-package " . $v_package . " 'json'", $output, $return_var); check_return_code($return_var, $output); unset($output); if ($v_package_new != $v_package) { exec( HESTIA_CMD . "v-rename-user-package " . $v_package . " " . $v_package_new, $output, $return_var, ); check_return_code($return_var, $output); unset($output); } // Set success message if (empty($_SESSION["error_msg"])) { $_SESSION["ok_msg"] = _("Changes have been saved."); } } // Render page render_page($user, $TAB, "edit_package"); // Flush session messages unset($_SESSION["error_msg"]); unset($_SESSION["ok_msg"]);