public function serverhasrestore($servertype) { global $dbh, $postvar, $getvar, $instance; $restoreserver = server::createServer(0, $servertype); if (method_exists($restoreserver, "restore")) { return true; } else { return false; } }
$domain_array['DOMAIN'] = $postvar['cdom']; if (empty($domain_array['DOMAIN'])) { $domain_array['DOMAIN'] = $postvar['csub']; } $order_form_array['TOS'] = $dbh->config("tos"); $order_form_array['TZADJUST'] = main::tzlist($tz_default); $order_form_array['COUNTRIES'] = main::countries(1, $postvar['country']); //1 = Make it a drop down instead of pulling an array. The second part makes it set it's default. $ptype = type::packagetype($getvar['package']); $order_form_array['TYPESPECIFIC'] = type::orderForm($ptype); if ($getvar['domsub'] == "dom") { $order_form_array['DOMORSUB'] = style::replaceVar("tpl/order/domain.tpl", $domain_array); } else { $pack = $getvar['package']; $server_type = type::packageserver($pack); $serverfile = server::createServer($server_type); $can_create_subs = $serverfile->subdomains; if ($can_create_subs == false) { $maincontent = main::table("Subdomain Error", "Sorry, but the server for this package doesn't allow subdomains to be used without a unique domain present on the account. If you'd like to\n use a domain, please go back and select the domain option."); } else { $subdomains_query = $dbh->select("subdomains", array("server", "=", $server_type), array("subdomain", "ASC"), 0, 1); while ($subdomains_data = $dbh->fetch_array($subdomains_query)) { $subdomains[] = array($subdomains_data['domain'], $subdomains_data['domain']); } if ($postvar['csub2']) { $subtld = $postvar['csub2']; } else { $subtld = $subdomains[0]['domain']; } $subdomain_array['SUBDOMTLDLIST'] = main::dropdown("csub2", $subdomains, $subtld); $order_form_array['DOMORSUB'] = style::replaceVar("tpl/order/subdomain.tpl", $subdomain_array);
public function do_upgrade($upgradeid, $mode, $no_errors_out = 0) { global $dbh, $postvar, $getvar, $instance; //$mode // //Init - When the upgrade info is added, we call this function. //Update - When cron or an admin does something with this function, we check to see if various tasks are ready to be performed. //Flag meaning: // //IMMEDIATE UPGRADE FLAGS // //0 - Upgrade is immediate. //5 - If admin approves the upgrade, then the upgrade will be immediate. // //6 - If admin approves the upgrade, then the new account will be created on the new server and the // admin will know that they are moving to a new server so they can manually close the old account // when they're ready. // //7 - The new account on the new server will be immediately created and the admin will be notified that // the user is switching servers. // //NEXT MONTH UPGRADE FLAGS // //1 - Cron will upgrade them next month. //2 - If admin approves this, then it will be set to 1 for cron to upgrade them next month. //3 - The admin will be notified that the user wishes to be upgraded and if they approve it, // then an account on the new server will be created so they can migrate to the new server. // the admin can opt to switch the account over before next month if they both agree and the // switch will be made in the admin area manually. // //4 - Cron will create a new account on the new server next month and inform the admin that the // user is changing to the new server. // $upgrade_data = $dbh->select("upgrade", array("id", "=", $upgradeid)); $userid = $upgrade_data['uid']; $newpack = $upgrade_data['newpack']; $flags = $upgrade_data['flags']; $created = $upgrade_data['created']; $coupcode = $upgrade_data['coupcode']; $user_data = main::uidtopack($userid); $current_pack_type = $user_data['packages']['type']; $current_pack_name = $user_data['packages']['name']; $current_pack_id = $user_data['packages']['id']; $user_info = $dbh->select("users", array("id", "=", $userid)); $user_email = $user_info['email']; $username = $user_info['user']; $new_plan_data = $dbh->select("packages", array("id", "=", $newpack)); $newpack_name = $new_plan_data['name']; $new_plan_additional = type::additional($newpack); $new_server_data = $dbh->select("servers", array("id", "=", $new_plan_data['server'])); $new_server_name = $new_server_data['name']; $old_server_data = $dbh->select("servers", array("id", "=", $user_data['packages']['server'])); $old_server_name = $old_server_data['name']; switch ($flags) { case "0": $upgrade = 1; break; case "1": $upgrade_today = self::upgrade_today($current_pack_type, $userid); if ($upgrade_today) { $upgrade = 1; } break; case "2": if ($mode = "Init") { $admin_approval = 1; } else { //If its already the day for the upgrade, then we can do the upgrade now. $upgrade_today = self::upgrade_today($current_pack_type, $userid); if ($upgrade_today) { $upgrade = 1; } if (!$upgrade) { $dbh->update("upgrade", array("flags" => "1"), array("id", "=", $upgradeid), "1"); } } break; case "3": if ($mode = "Init") { $admin_approval = 1; $new_server = 1; } else { //If its already the day for the upgrade, then we can do the upgrade now. $upgrade_today = self::upgrade_today($current_pack_type, $userid); if ($upgrade_today) { $upgrade = 1; $new_server = 1; } if (!$upgrade) { $dbh->update("upgrade", array("flags", "=", "4"), array("id", "=", $upgradeid), "1"); } } break; case "4": //If its already the day for the upgrade, then we can do the upgrade now. $upgrade_today = self::upgrade_today($current_pack_type, $userid); if ($upgrade_today) { $upgrade = 1; $new_server = 1; $admin_inform = 1; } break; case "5": if ($mode = "Init") { $admin_approval = 1; $immediate = 1; } else { $upgrade = 1; } break; case "6": if ($mode = "Init") { $admin_approval = 1; $new_server = 1; $immediate = 1; } else { $upgrade = 1; $new_server = 1; } break; case "7": $upgrade = 1; $new_server = 1; $admin_inform = 1; break; } $adminmsg_array['USER'] = $username; $adminmsg_array['NEWPLAN'] = $newpack_name; $adminmsg_array['OLDPLAN'] = $current_pack_name; $adminmsg_array['NEWSERVER'] = $new_server_name; $adminmsg_array['OLDSERVER'] = $old_server_name; if ($immediate) { $adminmsg_array['NEXTMONTH_IMMEDIATELY'] = "immediately"; } else { $adminmsg_array['NEXTMONTH_IMMEDIATELY'] = "next billing cycle"; } $url = $dbh->config("url"); if (ADMINDIR) { $admin_dir = ADMINDIR; } else { $admin_dir = "admin"; } $adminmsg_array['APPROVE_LINK'] = $url . $admin_dir . "/?page=users&sub=upgrade"; if ($upgrade) { if ($new_plan_data['type'] == "paid") { $new_invoice_text = " A new invoice has been generated."; if ($current_pack_type == "paid" && $user_data['additional']['monthly'] >= $new_plan_additional['monthly']) { unset($new_invoice_text); } } $serverfile = server::createServer($newpack); if ($new_server) { $new_serv_pass_for_email = time(); $domsub = "sub"; //Checks to see if the domain contains 3 or more segments and fails if there are more than 3 and if the last one two aren't TLD portions, it fails, //so we can see if this is a subdomain this way. if (check::domain($user_data['user_data']['domain'])) { $domsub = "dom"; } $done = $serverfile->signup(type::packageserver($newpack), $new_plan_data['reseller'], $username, $user_email, $new_serv_pass_for_email, $user_data['user_data']['domain'], type::packageBackend($newpack), $domsub); if ($done === true) { if ($new_plan_data['reseller']) { $uemaildata = email::emailTemplate("upgrade-newserv-resell-welcome"); } else { $uemaildata = email::emailTemplate("upgrade-newserv-welcome"); } $change_tht = 1; main::errors("Your upgrade request has been completed. An email has been sent to you detailing your upgraded account on the new server." . $new_invoice_text); } else { return false; } } else { if ($serverfile->canupgrade) { $done = $serverfile->do_upgrade($new_plan_data['server'], type::packageBackend($newpack), $username); if ($done === true) { if ($new_plan_data['reseller']) { $uemaildata = email::emailTemplate("upgrade-resell-welcome"); } else { $uemaildata = email::emailTemplate("upgrade-welcome"); } $change_tht = 1; main::errors("Your upgrade request has been completed. An email has been sent to you detailing your upgraded account." . $new_invoice_text); } else { return false; } } else { $emaildata = email::emailTemplate("manual-upgrade-request"); main::errors("Your upgrade request has been added and the administrator has been emailed."); } } if ($uemaildata) { $welcomeemail_array['USER'] = $username; $welcomeemail_array['EMAIL'] = $user_email; $welcomeemail_array['PACKAGE'] = $newpack_name; $welcomeemail_array['SERVERIP'] = $new_server_data['ip']; $welcomeemail_array['LNAME'] = $user_info['lastname']; $welcomeemail_array['FNAME'] = $user_info['firstname']; $welcomeemail_array['CPPORT'] = $new_server_data['port']; $welcomeemail_array['PASS'] = $new_serv_pass_for_email; $welcomeemail_array['RESELLERPORT'] = $new_server_data['resellerport']; $welcomeemail_array['NAMESERVERS'] = nl2br($new_server_data['nameservers']); $welcomeemail_array['DOMAIN'] = $user_data['user_data']['domain']; email::send($user_email, $uemaildata['subject'], $uemaildata['content'], $welcomeemail_array); } } else { main::errors("Your upgrade request has been added."); } //Now we need to send the admin a dozen emails. lol FIRE! Nah, we'll only ever send them one email at a time. ;) if ($admin_approval) { if ($new_server) { $emaildata = email::emailTemplate("upgrade-newserv-adminval"); } else { $emaildata = email::emailTemplate("upgrade-adminval"); } } if ($admin_inform) { $emaildata = email::emailTemplate("notify-upgrade-new-server"); } if (!$emaildata && $change_tht) { $emaildata = email::emailTemplate("notify-upgrade"); } if ($emaildata) { email::staff($emaildata['subject'], $emaildata['content'], $adminmsg_array); } if ($change_tht) { main::thtlog("Client Upgraded", "Upgraded from " . $current_pack_name . " to " . $newpack_name, $userid, ""); if ($current_pack_type == "paid") { unset($where); $where[] = array("uid", "=", $userid, "AND"); $where[] = array("pid", "=", ""); $dbh->update("invoices", array("pid" => $current_pack_id), $where); } if ($new_plan_data['type'] != "p2h") { $dbh->delete("coupons_p2h", array("uid", "=", $userid)); } $user_pack_data = $user_data['user_data']; $users_update = array("pid" => $newpack, "domain" => $user_pack_data['domain'], "additional" => $user_pack_data['additional']); $dbh->update("users", $users_update, array("id", "=", $userid), "1"); $dbh->update("users_bak", $users_update, array("id", "=", $userid), "1"); if ($current_pack_type == "paid") { unset($where); $where[] = array("user", "=", $userid, "AND"); $where[] = array("disabled", "=", "0"); $coupons_used_query = $dbh->select("coupons_used", $where, 0, 0, 1); while ($coupons_used_data = $dbh->fetch_array($coupons_used_query)) { $had_coupons .= $coupons_used_data['coupcode'] . ","; $couponvals .= $coupons_used_data['paiddisc'] . ","; } $had_coupons = substr($had_coupons, 0, strlen($had_coupons) - 1); $couponvals = substr($couponvals, 0, strlen($couponvals) - 1); if (!$had_coupons) { $had_coupons = "0"; $couponvals = "0"; } $invoices_update = array("changed_plan" => "1", "hadcoupons" => $had_coupons, "couponvals" => $couponvals); unset($where); $where[] = array("uid", "=", $userid, "AND"); $where[] = array("hadcoupons", "=", ""); $dbh->update("invoices", $invoices_update, $where); } $multi_coupons = $dbh->config("multicoupons"); if ($coupcode || $new_plan_data['type'] == "free") { if (!$multi_coupons || $new_plan_data['type'] == "free") { $coupons_used_update = array("disabled" => "2", "datedisabled" => time()); $dbh->update("coupons_used", $coupons_used_update, array("user", "=", $userid)); } } if ($new_plan_data['type'] != "free") { if ($new_plan_data['type'] == "paid") { unset($where); $where[] = array("uid", "=", $userid, "AND"); $where[] = array("pid", "=", $current_pack_id); $last_invoice = $dbh->select("invoices", $where, array("id", "DESC"), "1"); if ($user_data['additional']['monthly'] < $new_plan_additional['monthly'] && $current_pack_type == "paid" && $last_invoice) { unset($where); $where[] = array("uid", "=", $userid, "AND"); $where[] = array("pid", "=", $current_pack_id); $last_invoice = $dbh->select("invoices", $where, array("id", "DESC"), "1"); if (!$multi_coupons) { unset($where); $where[] = array("user", "=", $userid, "AND"); $where[] = array("disabled", "=", "0"); $current_coupon = $dbh->select("coupons_used", $where); $coupcode = $current_coupon['coupcode']; coupons::remove_coupon($current_coupon['id'], $newpack, $last_invoice['id'], $userid); } else { unset($where); $where[] = array("user", "=", $userid, "AND"); $where[] = array("disabled", "=", "0"); $coupons_used_query = $dbh->select("coupons_used", $where, 0, 0, 1); while ($coupons_used_data = $dbh->fetch_array($coupons_used_query)) { $use_coupons[] = $coupons_used_data['coupcode']; coupons::remove_coupon($coupons_used_data['id'], $newpack, $last_invoice['id'], $userid); } } unset($where); $where[] = array("uid", "=", $userid, "AND"); $where[] = array("pid", "=", $current_pack_id); $last_invoice = $dbh->select("invoices", $where, array("id", "DESC"), "1"); $invoice_update_array = array("amount" => $new_plan_additional['monthly'], "due" => $last_invoice['due'] + 7 * 24 * 60 * 60, "pid" => $newpack, "hadcoupons" => "", "couponvals" => "", "changed_plan" => "0", "is_paid" => "0"); $where[] = array("id", "=", $last_invoice['id']); $dbh->update("invoices", $invoice_update_array, $where); } else { $amount = $new_plan_additional['monthly']; if (!$coupcode) { unset($where); $where[] = array("user", "=", $userid, "AND"); $where[] = array("disabled", "=", "0"); $coupcode = $dbh->select("coupons_used", $where); $coupcode = $coupcode['coupcode']; } $coupon_data = coupons::coupon_data($coupcode); $coupon_data['paiddisc'] = coupons::percent_to_value("paid", "paidtype", "paiddisc", $amount); if ($multi_coupons) { $amount = coupons::get_discount("paid", $amount, $userid) - $coupon_data['paiddisc']; } else { $amount = max(0, $amount - $coupon_data['paiddisc']); } $due = time() + 2592000; $notes = "Your hosting package invoice for this billing cycle. Package: " . $newpack_name; invoice::create($userid, $amount, $due, $notes); $last_invoice = $dbh->select("invoices", array("uid", "=", $userid), array("id", "DESC"), "1"); $dbh->update("invoices", array("pid" => $newpack), array("id", "=", $last_invoice['id']), "1"); unset($where); $where[] = array("uid", "=", $userid, "AND"); $where[] = array("pid", "=", $newpack); $last_invoice = $dbh->select("invoices", $where, array("id", "DESC"), "1"); if (!$multi_coupons) { unset($where); $where[] = array("user", "=", $userid, "AND"); $where[] = array("disabled", "=", "0"); $current_coupon = $dbh->select("coupons_used", $where); coupons::remove_coupon($current_coupon['id'], $newpack, $last_invoice['id'], $userid); } else { unset($where); $where[] = array("user", "=", $userid, "AND"); $where[] = array("disabled", "=", "0"); $coupons_used_query = $dbh->select("coupons_used", $where, 0, 0, 1); while ($coupons_used_data = $dbh->fetch_array($coupons_used_query)) { $use_coupons[] = $coupons_used_data['coupcode']; coupons::remove_coupon($coupons_used_data['id'], $newpack, $last_invoice['id'], $userid); } } } } unset($where); $where[] = array("uid", "=", $userid, "AND"); $where[] = array("pid", "=", $newpack); $last_invoice = $dbh->select("invoices", $where, array("id", "DESC"), "1"); if ($coupcode) { $coupon_data = $dbh->select("coupons", array("coupcode", "=", $coupcode)); coupons::use_coupon($coupon_data['id'], $newpack, $last_invoice['id'], $userid, "orders"); } if ($multi_coupons && $use_coupons) { for ($i = 0; $i < count($use_coupons); $i++) { $coupcode = $use_coupons[$i]; $coupon_data = $dbh->select("coupons", array("coupcode", "=", $coupcode)); coupons::use_coupon($coupon_data['id'], $newpack, $last_invoice['id'], $userid, "orders"); } } } //We now remove the upgrade stub. $dbh->delete("upgrade", array("uid", "=", $userid)); } unset($where); $where[] = array("amount", "=", "0", "OR"); $where[] = array("amount", "=", "0.00"); $dbh->update("invoices", array("is_paid" => "1"), $where); if (!$no_errors_out) { echo "<ERRORS>"; } }
public function content() { global $dbh, $postvar, $getvar, $instance; switch ($getvar['sub']) { default: if ($_POST['add']) { $no_check_array = array("resellerport", "welcome", "nstmp", "passtoo", "resellerid"); check::empty_fields($no_check_array); if (!main::errors()) { $servers_insert = array("ip" => $postvar['ip'], "resellerport" => $postvar['resellerport'], "port" => $postvar['port'], "nameservers" => $postvar['nameservers'], "name" => $postvar['name'], "host" => $postvar['host'], "user" => $postvar['user'], "accesshash" => $postvar['hash'], "type" => $postvar['type'], "dnstemplate" => $postvar['nstmp'], "welcome" => $postvar['welcome'], "pass" => $postvar['pass'], "reseller_id" => $postvar['resellerid'], "https" => $postvar['https'], "apiport" => $postvar['apiport']); $dbh->insert("servers", $servers_insert); main::errors("Server has been added!"); } } if ($_POST['addtype'] || $_POST['add']) { $serverfile = server::createServer(0, $postvar['type']); $server_fields = $serverfile->acp_form(); $add_server_array['SERVER_FIELDS'] = $server_fields; $add_server_array['TYPE'] = $postvar['type']; echo style::replaceVar("tpl/admin/servers/add-server.tpl", $add_server_array); break; } $files = main::folderFiles(INC . "/servers/"); foreach ($files as $value) { include INC . "/servers/" . $value; $fname = explode(".", $value); $stype = new $fname[0](); $values[] = array($stype->name, $fname[0]); } $server_type_array['TYPE'] = main::dropDown("type", $values, 0); echo style::replaceVar("tpl/admin/servers/server-type.tpl", $server_type_array); break; case "view": if (isset($getvar['do'])) { $servers_query = $dbh->select("servers", array("id", "=", $getvar['do']), 0, 0, 1); if ($dbh->num_rows($servers_query) == 0) { echo "That server doesn't exist!"; } else { if ($_POST) { check::empty_fields(); if (!main::errors()) { $servers_update = array("name" => $postvar['name'], "host" => $postvar['host'], "reseller_id" => $postvar['resellerid'], "user" => $postvar['user'], "pass" => $postvar['pass'], "accesshash" => $postvar['hash'], "port" => $postvar['port'], "resellerport" => $postvar['resellerport'], "nameservers" => $postvar['nameservers'], "ip" => $postvar['ip'], "dnstemplate" => $postvar['nstmp'], "welcome" => $postvar['welcome'], "https" => $postvar['https'], "apiport" => $postvar['apiport']); $dbh->update("servers", $servers_update, array("id", "=", $getvar['do']), 1); //Server edit complete main::done(); } } $servers_data = $dbh->fetch_array($servers_query); $serverfile = server::createServer(0, $servers_data['type']); $server_fields = $serverfile->acp_form($getvar['do']); $edit_server_array['NAME'] = $servers_data['name']; $edit_server_array['HOST'] = $servers_data['host']; $edit_server_array['SERVERIP'] = $servers_data['ip']; $edit_server_array['RESELLERPORT'] = $servers_data['resellerport']; $edit_server_array['PORT'] = $servers_data['port']; $edit_server_array['NAMESERVERS'] = $servers_data['nameservers']; $edit_server_array['SERVER_FIELDS'] = $server_fields; echo style::replaceVar("tpl/admin/servers/edit-server.tpl", $edit_server_array); } } else { $servers_query = $dbh->select("servers"); if ($dbh->num_rows($servers_query) == 0) { echo "There are no servers to view!"; } else { echo "<ERRORS>"; while ($servers_data = $dbh->fetch_array($servers_query)) { echo main::sub("<strong>" . $servers_data['name'] . "</strong>", '<a href="?page=servers&sub=view&do=' . $servers_data['id'] . '"><img src="' . URL . 'themes/icons/magnifier.png"></a>'); } } } break; case "delete": if ($getvar['do']) { $dbh->delete("servers", array("id", "=", $getvar['do'])); main::errors("Server Deleted!"); } $servers_query = $dbh->select("servers"); if ($dbh->num_rows($servers_query) == 0) { echo "There are no servers to delete!"; } else { echo "<ERRORS>"; while ($servers_data = $dbh->fetch_array($servers_query)) { echo main::sub("<strong>" . $servers_data['name'] . "</strong>", '<a href="?page=servers&sub=delete&do=' . $servers_data['id'] . '"><img src="' . URL . 'themes/icons/delete.png"></a>'); } } break; case "test": if (isset($getvar["do"])) { $result = server::testConnection($getvar["do"]); if ($result === true) { echo '<div style="text-align:center;padding-top:10px;">' . style::notice(true, "Connected to the server successfully!") . "</div>"; } else { echo '<div style="text-align:center;">' . style::notice(false, "Couldn't connect to the server...") . "</div>"; echo '<strong>Error:</strong><pre>' . (string) $result . '</pre>'; } } else { $servers_query = $dbh->select("servers"); if ($dbh->num_rows($servers_query) == 0) { echo "There are no servers to view!"; } else { echo "Caution: Some servers are set to automatically ban the IP address of this server (" . $_SERVER['SERVER_ADDR'] . ") after a certain number of failed logins.<br />"; while ($servers_data = $dbh->fetch_array($servers_query)) { echo main::sub("<strong>" . $servers_data['name'] . "</strong>", '<a href="?page=servers&sub=test&do=' . $servers_data['id'] . '"><img src="' . URL . 'themes/icons/server_chart.png"></a>'); } } } break; case "status": $server_status_array['EXTRA'] = ''; if (!main::canRun('shell_exec')) { $server_status_array['EXTRA'] = 'Some statistics could not be provided because shell_exec has been disabled.<br>'; } $server = $_SERVER['HTTP_HOST']; $server_status_array['OS'] = php_uname(); $server_status_array['DISTRO'] = ''; if (php_uname('s') == 'Linux') { $distro = main::getLinuxDistro(); if ($distro) { $server_status_array['DISTRO'] = '<tr><td><strong>Linux Distro:</strong></td><td> ' . $distro . ' </td></tr>'; } } $server_status_array['SOFTWARE'] = getenv('SERVER_SOFTWARE'); $server_status_array['PHP_VERSION'] = phpversion(); $server_status_array['MYSQL_VERSION'] = ''; $mysqlVersion = $dbh->version(); if ($mysqlVersion) { $server_status_array['MYSQL_VERSION'] = '<tr><td><strong>MySQL Version:</strong><br><br></td><td> ' . $mysqlVersion . ' <br><br></td></tr>'; } $server_status_array['SERVER'] = $server; echo style::replaceVar('tpl/admin/servers/server-status.tpl', $server_status_array); break; case "phpinfo": echo server::show_phpinfo(); break; } }
public function content() { global $dbh, $postvar, $getvar, $instance; switch ($getvar['sub']) { default: if ($_POST['add']) { $no_check_array = array("admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody"); check::empty_fields($no_check_array); $ZserverID = $postvar['server']; unset($where); $where[] = array("id", "=", $ZserverID, "AND"); $where[] = array("type", "=", "zpanel"); $servers_query = $dbh->select("servers", $where, 0, 0, 1); if ($dbh->num_rows($servers_query) == 1) { $zpanel_srv = 1; } //Hack to make sure the Group ID isn't 0 on ZPanel if ($zpanel_srv && ($postvar["groupid"] == 0 || $postvar["backend"] == 0)) { main::errors(" ZPanel server packages must include a Group ID for the package and the a backend package ID that's greater than 0. See the info bubbles for help."); } if ($postvar["monthly"] && !is_numeric($postvar["monthly"]) || $postvar["signup"] && !is_numeric($postvar["signup"])) { main::errors("Please enter a positive number for the cost or posts fields."); } if (!main::errors()) { $not_additional_array = array("add", "name", "backend", "description", "type", "server", "admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody", $GLOBALS['csrf']['input-name']); foreach ($postvar as $key => $value) { if (!in_array($key, $not_additional_array)) { if ($n) { $additional .= ","; } $additional .= $key . "=" . str_replace(array(" ", ","), array("", "."), $value); $n++; } } $packages_insert = array("name" => $postvar['name'], "backend" => $postvar['backend'], "description" => $postvar['description'], "type" => $postvar['type'], "server" => $postvar['server'], "admin" => $postvar['admin'], "is_hidden" => $postvar['hidden'], "is_disabled" => $postvar['disabled'], "additional" => $additional, "reseller" => $postvar['reseller'], "groupid" => $postvar['groupid'], "send_email" => $postvar['sendwelcome'], "email_subject" => $postvar['welcomesubject'], "email_body" => $postvar['welcomebody']); $dbh->insert("packages", $packages_insert); main::errors("Package has been added!<br>"); } } if ($_POST['packserver'] || $_POST['add']) { $servers_data = $dbh->select("servers", array("id", "=", $postvar['server']), 0, "1"); $serverfile = server::createServer(0, $servers_data['type']); $package_fields = $serverfile->acp_packages_form(); $add_package_array['TYPE_FORM'] = type::acpPadd($postvar['type']); $add_package_array['TYPE'] = $postvar['type']; $add_package_array['PACKAGES_FIELDS'] = $package_fields; $add_package_array['SERVER'] = $postvar['server']; echo style::replaceVar("tpl/admin/packages/add-package.tpl", $add_package_array); break; } $servers_query = $dbh->select("servers"); if ($dbh->num_rows($servers_query) == 0) { echo "There are no servers, you need to add a server first!"; return; } while ($servers_data = $dbh->fetch_array($servers_query)) { $values[] = array($servers_data['name'], $servers_data['id']); } $p2h_query = $dbh->select("p2h"); $p2h_data = $dbh->num_rows($p2h_query); if ($p2h_data != "0") { $package_server_array['P2HOPTION'] = '<option value="p2h">Post 2 Host</option>'; } else { $package_server_array['P2HOPTION'] == ""; } $package_server_array['SERVER'] = main::dropDown("server", $values); echo "This will only add the package to THT, not create the package on the backend for you.<br><br>"; echo style::replaceVar("tpl/admin/packages/package-server.tpl", $package_server_array); break; case "edit": if (isset($getvar['do'])) { $packages_query = $dbh->select("packages", array("id", "=", $getvar['do']), 0, 0, 1); if ($dbh->num_rows($packages_query) == 0) { echo "That package doesn't exist!"; } else { if ($_POST) { $no_check_array = array("admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody"); check::empty_fields($no_check_array); $ZserverID = $postvar['server']; unset($where); $where[] = array("id", "=", $ZserverID, "AND"); $where[] = array("type", "=", "zpanel"); $servers_query = $dbh->select("servers", $where, 0, 0, 1); if ($dbh->num_rows($servers_query) == 1) { $zpanel_srv = 1; } //Hack to make sure the Group ID isn't 0 on ZPanel if ($zpanel_srv && ($postvar["groupid"] == 0 || $postvar["backend"] == 0)) { main::errors(" ZPanel server packages must include a Group ID for the package and the a backend package ID that's greater than 0. See the info bubbles for help."); } if ($postvar["monthly"] && !is_numeric($postvar["monthly"]) || $postvar["signup"] && !is_numeric($postvar["signup"])) { main::errors("Please enter a positive number for the cost or posts fields."); } if (!main::errors()) { $not_additional_array = array("edit", "name", "backend", "description", "type", "server", "admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody", $GLOBALS['csrf']['input-name']); foreach ($postvar as $key => $value) { if (!in_array($key, $not_additional_array)) { if ($n) { $additional .= ","; } $additional .= $key . "=" . str_replace(array(" ", ","), array("", "."), $value); $n++; } } if ($postvar['sendwelcome'] && (!$postvar['welcomesubject'] || !$postvar['welcomebody'])) { $serverid = $postvar['server']; $server_type_data = $dbh->select("servers", array("id", "=", $serverid)); $server_type = $server_type_data['type']; if ($server_type == "zpanel") { include INC . "/servers/" . $server_type . ".php"; $server = new $server_type(); $server_subject_def = server::email_subject; $server_body_def = server::email_body; if (!$postvar['welcomesubject']) { $postvar['welcomesubject'] = $server_subject_def; } if (!$postvar['welcomebody']) { $postvar['welcomebody'] = $server_body_def; } } } $packages_update = array("name" => $postvar['name'], "backend" => $postvar['backend'], "description" => $postvar['description'], "server" => $postvar['server'], "admin" => $postvar['admin'], "additional" => $additional, "reseller" => $postvar['reseller'], "is_hidden" => $postvar['hidden'], "is_disabled" => $postvar['disabled'], "type" => $postvar['type'], "groupid" => $postvar['groupid'], "send_email" => $postvar['sendwelcome'], "email_subject" => $postvar['welcomesubject'], "email_body" => $postvar['welcomebody']); $dbh->update("packages", $packages_update, array("id", "=", $getvar['do'])); //Package edit complete. main::done(); } } $packages_data = $dbh->fetch_array($packages_query); $edit_package_array['BACKEND'] = $packages_data['backend']; $edit_package_array['DESCRIPTION'] = $packages_data['description']; $edit_package_array['NAME'] = $packages_data['name']; $edit_package_array['URL'] = $dbh->config("url"); $edit_package_array['ID'] = $packages_data['id']; if ($packages_data['admin'] == 1) { $edit_package_array['ADMIN_CHECKED'] = 'checked="checked"'; } else { $edit_package_array['ADMIN_CHECKED'] = ""; } if ($packages_data['reseller'] == 1) { $edit_package_array['RESELLER_CHECKED'] = 'checked="checked"'; } else { $edit_package_array['RESELLER_CHECKED'] = ""; } if ($packages_data['is_hidden'] == 1) { $edit_package_array['HIDDEN_CHECKED'] = 'checked="checked"'; } else { $edit_package_array['HIDDEN_CHECKED'] = ""; } if ($packages_data['is_disabled'] == 1) { $edit_package_array['DISABLED_CHECKED'] = 'checked="checked"'; } else { $edit_package_array['DISABLED_CHECKED'] = ""; } $serverfile = server::createServer($getvar['do']); $package_fields = $serverfile->acp_packages_form($getvar['do']); $edit_package_array['PACKAGES_FIELDS'] = $package_fields; $p2h_query = $dbh->select("p2h"); $p2h_data = $dbh->num_rows($p2h_query); $edit_package_array['TYPE'] = $packages_data['type']; $additional = $packages_data['additional']; $edit_package_array['TYPE_FORM'] = type::acpPedit($packages_data['type'], $additional, $packages_data['type']); if ($packages_data['type'] == "p2h" && $p2h_data == "0") { $edit_package_array['TYPE_FORM'] = ""; } $servers_query = $dbh->select("servers"); while ($servers_data = $dbh->fetch_array($servers_query)) { $values[] = array($servers_data['name'], $servers_data['id']); } $edit_package_array['SERVER'] = $packages_data['server']; echo "This will only edit the package on THT, not edit the package on the backend for you.<br><br>"; echo style::replaceVar("tpl/admin/packages/edit-package.tpl", $edit_package_array); } } else { $packages_query = $dbh->select("packages"); if ($dbh->num_rows($packages_query) == 0) { echo "There are no packages to edit!"; } else { echo "<ERRORS>"; while ($packages_data = $dbh->fetch_array($packages_query)) { echo main::sub("<strong>" . $packages_data['name'] . "</strong>", '<a href="?page=packages&sub=edit&do=' . $packages_data['id'] . '"><img src="' . URL . 'themes/icons/pencil.png"></a>'); $n++; } } } break; case "delete": if ($getvar['do']) { $dbh->delete("packages", array("id", "=", $getvar['do'])); main::errors("Package has been Deleted.<br>"); } $packages_query = $dbh->select("packages"); if ($dbh->num_rows($packages_query) == 0) { echo "There are no packages to delete."; } else { echo "<ERRORS>This will only delete the package on THT, not delete the package on the backend for you.<br><br>"; while ($packages_data = $dbh->fetch_array($packages_query)) { echo main::sub("<strong>" . $packages_data['name'] . "</strong>", '<a href="?page=packages&sub=delete&do=' . $packages_data['id'] . '"><img src="' . URL . 'themes/icons/delete.png"></a>'); $n++; } } break; } }