/** * Function to move a given customer to a given admin/reseller * and update all its references accordingly * * @param int $id customer-id * @param int $adminid target-admin-id * * @return true on sucess, error-message on failure */ function moveCustomerToAdmin($id = 0, $adminid = 0) { if ($id <= 0 || $adminid <= 0) { return "no valid id's given"; } // get current admin-id $cAdmin_stmt = Database::prepare("\n\t\tSELECT `adminid` FROM `" . TABLE_PANEL_CUSTOMERS . "`\n\t\tWHERE `customerid` = :cid\n\t"); $cAdmin = Database::pexecute_first($cAdmin_stmt, array('cid' => $id)); // Update customer entry $updCustomer_stmt = Database::prepare("\n\t\tUPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `adminid` = :adminid WHERE `customerid` = :cid\n\t"); Database::pexecute($updCustomer_stmt, array('adminid' => $cAdmin['adminid'], 'cid' => $id)); // Update customer-domains $updDomains_stmt = Database::prepare("\n\t\tUPDATE `" . TABLE_PANEL_DOMAINS . "` SET `adminid` = :adminid WHERE `customerid` = :cid\n\t"); Database::pexecute($updDomains_stmt, array('adminid' => $cAdmin['adminid'], 'cid' => $id)); // Update customer-tickets $updTickets_stmt = Database::prepare("\n\t\tUPDATE `" . TABLE_PANEL_TICKETS . "` SET `adminid` = :adminid WHERE `customerid` = :cid\n\t"); Database::pexecute($updTickets_stmt, array('adminid' => $cAdmin['adminid'], 'cid' => $id)); // now, recalculate the resource-usage for the old and the new admin updateCounters(false); return true; }
if (isset($_POST['send']) && $_POST['send'] == 'send') { $customerid = intval($_POST['customerid']); $separator = validate($_POST['separator'], 'separator'); $offset = (int) validate($_POST['offset'], 'offset', "/[0-9]/i"); $file_name = $_FILES['file']['tmp_name']; $result = array(); try { $bulk = new DomainBulkAction($file_name, $customerid); $result = $bulk->doImport($separator, $offset); } catch (Exception $e) { standard_error('domain_import_error', $e->getMessage()); } // @FIXME find a way to display $result['notice'] here somehow, // as it might be important if you've reached your maximum allocation of domains // update customer/admin counters updateCounters(false); $result_str = $result['imported'] . ' / ' . $result['all']; standard_success('domain_import_successfully', $result_str, array('filename' => $filename, 'action' => '', 'page' => 'domains')); } else { $customers = makeoption($lng['panel']['please_choose'], 0, 0, true); $result_customers_stmt = Database::prepare("\n\t\t\t\tSELECT `customerid`, `loginname`, `name`, `firstname`, `company`\n\t\t\t\tFROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int) $userinfo['adminid'] . "' ") . " ORDER BY `name` ASC"); $params = array(); if ($userinfo['customers_see_all'] == '0') { $params['adminid'] = $userinfo['adminid']; } Database::pexecute($result_customers_stmt, $params); while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) { $customers .= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']); } $domain_import_data = (include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_import.php'); $domain_import_form = htmlform::genHTMLForm($domain_import_data);
inserttask('1'); inserttask('5'); inserttask('9'); inserttask('10'); # Using nameserver, insert a task which rebuilds the server config if ($settings['system']['bind_enable']) { inserttask('4'); } standard_success('rebuildingconfigs', '', array('filename' => 'admin_index.php')); } else { ask_yesno('admin_configs_reallyrebuild', $filename, array('page' => $page)); } } elseif ($page == 'updatecounters' && $userinfo['change_serversettings'] == '1') { if (isset($_POST['send']) && $_POST['send'] == 'send') { $log->logAction(ADM_ACTION, LOG_INFO, "updated resource-counters"); $updatecounters = updateCounters(true); $customers = ''; foreach ($updatecounters['customers'] as $customerid => $customer) { eval("\$customers.=\"" . getTemplate("settings/updatecounters_row_customer") . "\";"); } $admins = ''; foreach ($updatecounters['admins'] as $adminid => $admin) { eval("\$admins.=\"" . getTemplate("settings/updatecounters_row_admin") . "\";"); } eval("echo \"" . getTemplate("settings/updatecounters") . "\";"); } else { ask_yesno('admin_counters_reallyupdate', $filename, array('page' => $page)); } } elseif ($page == 'wipecleartextmailpws' && $userinfo['change_serversettings'] == '1') { if (isset($_POST['send']) && $_POST['send'] == 'send') { $log->logAction(ADM_ACTION, LOG_WARNING, "wiped all cleartext mail passwords");
Settings::Set('system.dbversion', (int) $result['value'], false); } else { Settings::Set('system.dbversion', 0, false); } } } if (hasUpdates($version)) { $successful_update = false; $message = ''; if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['update_preconfig']) && isset($_POST['update_changesagreed']) && intval($_POST['update_changesagreed']) != 0 || !isset($_POST['update_preconfig'])) { eval("echo \"" . getTemplate('update/update_start') . "\";"); include_once './install/updatesql.php'; $redirect_url = 'admin_index.php?s=' . $s; eval("echo \"" . getTemplate('update/update_end') . "\";"); updateCounters(); inserttask('1'); @chmod('./lib/userdata.inc.php', 0440); $successful_update = true; } else { $message = '<br /><strong style="color: red">You have to agree that you have read the update notifications.</strong>'; } } if (!$successful_update) { $current_version = Settings::Get('panel.version'); $new_version = $version; $ui_text = $lng['update']['update_information']['part_a']; $ui_text = str_replace('%curversion', $current_version, $ui_text); $ui_text = str_replace('%newversion', $new_version, $ui_text); $update_information = $ui_text; include_once './install/updates/preconfig.php';