function drawAdminTools_Ftp($domain, $adm_path) { global $adm_login; global $adm_pass; global $edit_domain; global $edftp_account; global $addrlink; global $conf_hide_password; global $conf_domain_based_ftp_logins; global $pro_mysql_ftp_table; global $pro_mysql_admin_table; checkLoginPassAndDomain($adm_login, $adm_pass, $domain["name"]); $q = "SELECT restricted_ftp_path,ftp_login_flag FROM {$pro_mysql_admin_table} WHERE adm_login='******';"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 1) { die("adm_login {$adm_login} not found line " . __LINE__ . " file " . __FILE__); } $a = mysql_fetch_array($r); if ($a["ftp_login_flag"] == "no") { die("adm_login {$adm_login} had no rights to edit FTP accounts line " . __LINE__ . " file " . __FILE__); } $txt = ""; // Build the popup values and display values arrays $path_popup_vals = array(); $path_popup_disp = array(); if ($a["restricted_ftp_path"] != "yes") { $path_popup_vals[] = "{$adm_path}"; $path_popup_disp[] = "/"; $path_popup_vals[] = "{$adm_path}/{$edit_domain}"; $path_popup_disp[] = "/{$edit_domain}"; } $nbr_subdomains = sizeof($domain["subdomains"]); for ($i = 0; $i < $nbr_subdomains; $i++) { $sub_name = $domain["subdomains"][$i]["name"]; if ($a["restricted_ftp_path"] != "yes") { $path_popup_vals[] = "{$adm_path}/{$edit_domain}/subdomains/{$sub_name}"; $path_popup_disp[] = "/{$edit_domain}/subdomains/{$sub_name}"; } $path_popup_vals[] = "{$adm_path}/{$edit_domain}/subdomains/{$sub_name}/html"; $path_popup_disp[] = "/{$edit_domain}/subdomains/{$sub_name}/html"; } // Just create the list editor now... $dsc = array("title" => _("List of your FTP accounts: "), "new_item_title" => _("New FTP account: "), "new_item_link" => _("new FTP account"), "edit_item_title" => _("FTP account configuration: "), "table_name" => $pro_mysql_ftp_table, "action" => "ftp_access_editor", "forward" => array("adm_login", "adm_pass", "addrlink"), "id_fld" => "id", "list_fld_show" => "login", "max_item" => $domain["max_ftp"], "num_item_txt" => _("Number of active ftp accounts:"), "create_item_callback" => "ftpAccountsCallback", "where_list" => array("hostname" => $domain["name"]), "check_unique" => array("login"), "check_unique_msg" => _("There is already a ftp login by that name"), "check_unique_use_where_list" => "no", "order_by" => "login", "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "login" => array("type" => "text", "check" => "dtc_login_or_email", "legend" => _("Login: "******"password" => array("type" => "password", "check" => "dtc_pass", "legend" => _("Password: "******"homedir" => array("type" => "popup", "values" => $path_popup_vals, "display_replace" => $path_popup_disp, "legend" => _("Path: ")))); if ($conf_domain_based_ftp_logins == "yes") { $dsc["cols"]["login"]["happen_domain"] = "@" . $domain["name"]; } $txt .= dtcListItemsEdit($dsc); return $txt; }
function drawAdminTools_Aliases($domain) { global $adm_login; global $adm_pass; global $edit_domain; global $edit_mailbox; global $addrlink; global $pro_mysql_pop_table; global $pro_mysql_mailaliasgroup_table; checkLoginPassAndDomain($adm_login, $adm_pass, $domain["name"]); $out = ""; $dsc = array("title" => _("List of your mail groups"), "new_item_title" => _("Create New Mail Group"), "new_item_link" => _("Create Mail Group"), "edit_item_title" => _("Edit Mail Group"), "table_name" => $pro_mysql_mailaliasgroup_table, "action" => "aliasgroup", "forward" => array("adm_login", "adm_pass", "addrlink"), "id_fld" => "autoinc", "list_fld_show" => "id", "max_item" => $domain["max_email"], "num_item_txt" => _("Number of active mailboxes:"), "create_item_callback" => "emailAliasesCreateCallback", "delete_item_callback" => "emailAliasesDeleteCallback", "edit_item_callback" => "emailAliasesEditCallback", "order_by" => "id", "where_list" => array("domain_parent" => $domain["name"]), "cols" => array("autoinc" => array("type" => "id", "display" => "no", "legend" => _("Login:"******"id" => array("type" => "text", "check" => "dtc_login_or_email", "disable_edit" => "yes", "happen" => "@" . $domain["name"], "legend" => _("Email:")), "delivery_group" => array("type" => "textarea", "check" => "mail_alias_group", "legend" => _("Delivery Group:"), "cols" => "40", "rows" => "7")), "check_unique" => array("id"), "check_unique_msg" => _("Email address is already in use!")); $list_items = dtcListItemsEdit($dsc); // We have to query again, in case something has changed $q = "SELECT id FROM {$pro_mysql_mailaliasgroup_table} WHERE domain_parent='" . $domain["name"] . "';"; $r = mysql_query($q) or die("Cannot query {$q} line: " . __LINE__ . " file " . __FILE__ . " sql said:" . mysql_error()); $n = mysql_num_rows($r); $out .= $list_items; $out .= helpLink("PmWiki/Email-Accounts"); return $out; }
$result = mysql_query($query) or die("Cannot execute query \"{$query}\" !!!" . mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows != 1) { die("Client id not found in client table !"); } $row = mysql_fetch_array($result); $funds = $row["dolar"]; $funds += $_REQUEST["refund_amount"]; $query = "UPDATE {$pro_mysql_client_table} SET dolar='{$funds}' WHERE id='{$id_client}';"; $result = mysql_query($query) or die("Cannot execute query \"{$query}\" !!!" . mysql_error()); } else { die("You don't have a client ID !!!"); } } if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "registry_renew_domain") { checkLoginPassAndDomain($adm_login, $adm_pass, $edit_domain); if (!isRandomNum($_REQUEST["num_years"]) || strlen($_REQUEST["num_years"]) != 1) { echo _("Number of years is not a number between 1 and 9."); } else { $q = "SELECT id_client FROM {$pro_mysql_admin_table} WHERE adm_login='******';"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 1) { die("ID client not found line " . __LINE__ . " file " . __FILE__); } $admin = mysql_fetch_array($r); $id_client = $admin["id_client"]; $q = "SELECT * FROM {$pro_mysql_client_table} WHERE id='{$id_client}';"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 1) {
function drawAdminTools_NameServers($admin) { global $adm_login; global $adm_pass; global $addrlink; global $pro_mysql_subdomain_table; global $pro_mysql_nameservers_table; global $pro_mysql_domain_table; $out = ""; if (isset($_REQUEST["subdomain"])) { $subdomain = $_REQUEST["subdomain"]; } if (isset($_REQUEST["domain_name"])) { $domain_name = $_REQUEST["domain_name"]; } if (isset($_REQUEST["ip"])) { $ip = $_REQUEST["ip"]; } if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "new_nameserver") { checkLoginPassAndDomain($adm_login, $adm_pass, $domain_name); $regz = registry_add_nameserver($adm_login, $adm_pass, $subdomain, $domain_name, $ip); if ($regz["is_success"] == 1) { $out .= "<font color=\"green\"><b>" . _("Registration of your name server was succesful") . "</b></font><br>\n" . _("Server said: ") . "<i>" . $regz["response_text"] . "</i><br>"; $query = "SELECT * FROM {$pro_mysql_subdomain_table} WHERE domain_name='{$domain_name}' AND subdomain_name='{$subdomain}';"; $result = mysql_query($query) or die("Cannot query \"query\" !!!" . mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows == 0) { $query = "INSERT INTO {$pro_mysql_subdomain_table} (id,\ndomain_name,subdomain_name,webalizer_generate,ip)VALUES('','{$domain_name}','{$subdomain}','no','{$ip}');"; } else { if ($num_rows == 1) { $query = "UPDATE {$pro_mysql_subdomain_table} SET ip='{$ip}'\n\t\t\t\t\tWHERE domain_name='{$domain_name}' AND subdomain_name='{$subdomain}' LIMIT 1;"; } else { die("Subdomain table problem: twice the same subdomain !"); } } mysql_query($query) or die("Cannot query: \"{$query}\" !!!" . mysql_error()); $query = "INSERT INTO {$pro_mysql_nameservers_table}(id,\nowner,domain_name,subdomain,ip)VALUES(\n'','{$adm_login}','{$domain_name}','{$subdomain}','{$ip}');"; mysql_query($query) or die("Cannot query: \"{$query}\" !!!" . mysql_error()); } else { $out .= "<font color=\"red\"><b>" . _("Registration of your name server failed") . "</b></font><br>\n" . _("Server said: ") . "<i>" . $regz["response_text"] . "</i><br>"; } } if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "edit_nameserver") { checkLoginPassAndDomain($adm_login, $adm_pass, $domain_name); $regz = registry_modify_nameserver($adm_login, $adm_pass, $subdomain, $domain_name, $ip); if ($regz["is_success"] == 1) { $out .= "<font color=\"green\"><b>" . _("Addition of name server was succesfull") . "</b></font><br>\n" . _("Server said: ") . "<i>" . $regz["response_text"] . "</i><br>"; $query = "UPDATE {$pro_mysql_subdomain_table} SET ip='{$ip}'\n\t\t\t\tWHERE domain_name='{$domain_name}' AND subdomain_name='{$subdomain}' LIMIT 1;"; mysql_query($query) or die("Cannot query: \"{$query}\" !!!" . mysql_error()); $query = "UPDATE {$pro_mysql_nameservers_table} SET ip='{$ip}'\n\t\t\t\tWHERE domain_name='{$domain_name}' AND subdomain='{$subdomain}' LIMIT 1;"; mysql_query($query) or die("Cannot query: \"{$query}\" !!!" . mysql_error()); } else { $out .= "<font color=\"red\"><b>" . _("Addition of name server failed") . "</b></font><br>\n" . _("Server said: ") . "<i>" . $regz["response_text"] . "</i><br>"; } } if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "delete_nameserver") { checkLoginPassAndDomain($adm_login, $adm_pass, $domain_name); $regz = registry_delete_nameserver($adm_login, $adm_pass, $subdomain, $domain_name); if ($regz["is_success"] == 1) { $out .= "<font color=\"green\"><b>" . _("Deletion of name server was succesful") . "</b></font><br>\n" . _("Server said: ") . "<i>" . $regz["response_text"] . "</i><br>"; $query = "DELETE FROM {$pro_mysql_nameservers_table}\n\t\t\t\tWHERE domain_name='{$domain_name}' AND subdomain='{$subdomain}' LIMIT 1"; mysql_query($query) or die("Cannot query: \"{$query}\" !!!" . mysql_error()); } else { $out .= "<font color=\"red\"><b>" . _("Deletion of name server failed") . "</b></font><br>\n" . _("Server said: ") . "<i>" . $regz["response_text"] . "</i><br>"; } } $out .= "<b><u>" . _("List of your registred name-servers:") . "</u></b><br>"; $query = "SELECT * FROM {$pro_mysql_nameservers_table} WHERE owner='{$adm_login}';"; $result = mysql_query($query) or die("Cannot query \"{$query}\" !!!" . mysql_error()); $num_rows = mysql_num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $row = mysql_fetch_array($result); if ($i > 0) { $out .= " - "; } $out .= "<a href=\"" . $_SERVER["PHP_SELF"] . "?adm_login={$adm_login}&adm_pass={$adm_pass}&addrlink={$addrlink}&edit_id=" . $row["id"] . "\">" . $row["subdomain"] . "." . $row["domain_name"] . "</a>"; } if (isset($_REQUEST["edit_id"]) && $_REQUEST["edit_id"] != "") { $query = "SELECT * FROM {$pro_mysql_nameservers_table} WHERE id='" . $_REQUEST["edit_id"] . "' AND owner='{$adm_login}';"; $result = mysql_query($query) or die("Cannot query \"{$query}\" !!!" . mysql_error()); if (mysql_num_rows($result) != 1) { die("Nameserver not found !!!"); } $row = mysql_fetch_array($result); $out .= "<br><br><a href=\"" . $_SERVER["PHP_SELF"] . "?adm_login={$adm_login}&adm_pass={$adm_pass}&addrlink={$addrlink}\">New name server</a><br>\n<b><u>" . _("Edit a name server:") . "</u></b><br>\n<form action=\"" . $_SERVER["PHP_SELF"] . "\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\"> \n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\"> \n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\"> \n<input type=\"hidden\" name=\"action\" value=\"edit_nameserver\">\n<input type=\"hidden\" name=\"domain_name\" value=\"" . $row["domain_name"] . "\">\n<input type=\"hidden\" name=\"subdomain\" value=\"" . $row["subdomain"] . "\">\n" . _("Name server hostname: ") . $row["subdomain"] . "." . $row["domain_name"] . "<br>\n<input type=\"hidden\" name=\"edit_id\" value=\"" . $_REQUEST["edit_id"] . "\">\n" . _("IP address of name server:") . "<input type=\"text\" name=\"ip\" value=\"" . $row["ip"] . "\">\n<input type=\"submit\" value=\"Ok\">\n</form>\n<form action=\"" . $_SERVER["PHP_SELF"] . "\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\"> \n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\"> \n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\"> \n<input type=\"hidden\" name=\"action\" value=\"delete_nameserver\">\n<input type=\"hidden\" name=\"domain_name\" value=\"" . $row["domain_name"] . "\">\n<input type=\"hidden\" name=\"subdomain\" value=\"" . $row["subdomain"] . "\">\n<input type=\"hidden\" name=\"delete_id\" value=\"" . $_REQUEST["edit_id"] . "\">\n<input type=\"submit\" value=\"" . _("Delete name server") . "\">\n</form>\n"; } else { $out .= "<br><br><b><u>" . _("Register a new name server:") . "</u></b><br>\n\t\t" . _("What subzone do you want to use (example: ns1):") . "\n<form action=\"" . $_SERVER["PHP_SELF"] . "\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\"> \n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\"> \n<input type=\"hidden\" name=\"action\" value=\"new_nameserver\">\n<input type=\"text\" name=\"subdomain\" value=\"\"><br>"; $query = "SELECT * FROM {$pro_mysql_domain_table} WHERE owner='{$adm_login}';"; $result = mysql_query($query) or die("Cannot query: \"{$query}\" !!!" . mysql_error()); $num_rows = mysql_num_rows($result); $out .= _("Select one of your domain-names for registering an additional name server to the registries:") . "<br>\n\t\t<select name=\"domain_name\">"; for ($i = 0; $i < $num_rows; $i++) { $row = mysql_fetch_array($result); $out .= "<option value=\"" . $row["name"] . "\">" . $row["name"] . "</option>"; } $out .= "</select><br>\n\t\t\t" . _("IP address of name server:") . "\n\t\t\t<input type=\"text\" name=\"ip\" value=\"\"><br>"; $out .= "<input type=\"submit\" value=\"Ok\">\n</form>\n<br>"; } return $out; }
function deleteUserDomain($adm_login, $adm_pass, $deluserdomain, $delete_directories = false) { global $pro_mysql_admin_table; global $pro_mysql_pop_table; global $pro_mysql_mailaliasgroup_table; global $pro_mysql_ftp_table; global $pro_mysql_subdomain_table; global $pro_mysql_domain_table; global $pro_mysql_list_table; global $pro_mysql_fetchmail_table; global $pro_mysql_cronjob_table; global $conf_demo_version; global $conf_root_admin_random_pass; global $conf_pass_expire; checkLoginPassAndDomain($adm_login, $adm_pass, $deluserdomain); $adm_query = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';"; $result = mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" line " . __LINE__ . " file " . __FILE__ . "sql said " . mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows != 1) { die("User not found for deletion of domain {$deluserdomain} !!!"); } $row = mysql_fetch_array($result); $the_admin_path = $row["path"]; // Delete all mail groups $adm_query = "DELETE FROM {$pro_mysql_mailaliasgroup_table} WHERE domain_parent='{$deluserdomain}';"; mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" !!!"); // Delete all mail accounts $adm_query = "DELETE FROM {$pro_mysql_pop_table} WHERE mbox_host='{$deluserdomain}';"; mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" !!!"); $adm_query = "DELETE FROM {$pro_mysql_fetchmail_table} WHERE domain_name='{$deluserdomain}';"; mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" !!!"); // Delete all mailboxs $adm_query = "DELETE FROM {$pro_mysql_ftp_table} WHERE hostname='{$deluserdomain}';"; mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" !!!"); // Delete all subdomains $domupdate_query = "DELETE FROM {$pro_mysql_subdomain_table} WHERE domain_name='{$deluserdomain}';"; $domupdate_result = mysql_query($domupdate_query) or die("Cannot execute query \"{$domupdate_query}\""); // Delete the domain $adm_query = "DELETE FROM {$pro_mysql_domain_table} WHERE name='{$deluserdomain}' LIMIT 1;"; mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" !!!"); // Delete all mailing lists $adm_query = "DELETE FROM {$pro_mysql_list_table} WHERE domain='{$deluserdomain}';"; mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" !!!"); // Delete the files of the domain name if ($delete_directories == true && $conf_demo_version == "no") { system("rm -rf {$the_admin_path}/{$deluserdomain}"); } // We now check if there are still some domains in the admin account // if there are none, then we shall delete the symlinks $adm_query = "SELECT name FROM {$pro_mysql_domain_table} WHERE owner='{$adm_login}';"; $r = mysql_query($adm_query) or die("Cannot execute query \"{$adm_query}\" line " . __LINE__ . " file " . __FILE__); $n = mysql_num_rows($r); if ($n == 0) { $folder_list = "{$the_admin_path}/lib {$the_admin_path}/dev {$the_admin_path}/etc {$the_admin_path}/sbin {$the_admin_path}/tmp {$the_admin_path}/usr {$the_admin_path}/var {$the_admin_path}/bin {$the_admin_path}/libexec"; $mystring = exec("uname -m", $out, $ret); $arch = $out[0]; if ($arch == "x86_64") { $folder_list .= " {$the_admin_path}/lib64"; } system("rm -rf " . $folder_list); } $adm_query = "UPDATE {$pro_mysql_cronjob_table} SET qmail_newu='yes',restart_qmail='yes',reload_named='yes',\n\trestart_apache='yes',gen_vhosts='yes',gen_named='yes',gen_qmail='yes',gen_webalizer='yes',gen_backup='yes',gen_ssh='yes',gen_fetchmail='yes' WHERE 1;"; mysql_query($adm_query); triggerDomainListUpdate(); }
function drawAdminTools_Emails($domain) { global $adm_login; global $adm_pass; global $edit_domain; global $edit_mailbox; global $addrlink; global $cyrus_used; global $cyrus_default_quota; global $CYRUS; global $conf_hide_password; global $pro_mysql_pop_table; checkLoginPassAndDomain($adm_login, $adm_pass, $domain["name"]); $out = ""; $dsc = array("title" => _("List of your mailboxes:"), "new_item_title" => _("New mailbox"), "new_item_link" => _("new mailbox"), "edit_item_title" => _("Mailbox configuration:"), "table_name" => $pro_mysql_pop_table, "action" => "pop_access_editor", "forward" => array("adm_login", "adm_pass", "addrlink"), "id_fld" => "autoinc", "list_fld_show" => "id", "max_item" => $domain["max_email"], "num_item_txt" => _("Number of active mailboxes:"), "create_item_callback" => "emailAccountsCreateCallback", "delete_item_callback" => "emailAccountsDeleteCallback", "edit_item_callback" => "emailAccountsEditCallback", "where_list" => array("mbox_host" => $domain["name"]), "check_unique" => array("id"), "check_unique_msg" => _("There is already a mailbox by that name"), "order_by" => "id", "cols" => array("autoinc" => array("type" => "id", "display" => "no", "legend" => _("Login:"******"id" => array("type" => "text", "disable_edit" => "yes", "check" => "dtc_login_or_email", "happen" => "@" . $domain["name"], "legend" => _("Login:"******"memo" => array("type" => "text", "help" => _("This text is just a memo for yourself, and will not really be used."), "legend" => _("Name:")), "passwd" => array("type" => "password", "check" => "dtc_pass", "legend" => _("Password:"******"spam_mailbox_enable" => array("type" => "checkbox", "help" => _("If selected, spams will be sent in a SPAM folder and wont reach your inbox. Later you can check this folder with the webmail or using IMAP."), "values" => array("yes", "no"), "legend" => _("Enable SPAM filtering: ")), "spam_mailbox" => array("type" => "text", "help" => _("Name of the SPAM folder to receive the spam (the above option has to be activated)."), "default" => "SPAM", "legend" => _("SPAM mailbox destination: ")))); if ($cyrus_used) { $dsc["cols"]["quota_size"] = array("type" => "text", "check" => "number", "default" => "{$cyrus_default_quota}", "legend" => _("Mailbox quota: ")); $dsc["cols"]["quota_used"] = array("type" => "readonly", "hide_create" => "yes", "callback" => "getCyrusUsedQuota", "happen" => _("MBytes"), "legend" => _("Used quota: ")); } else { $dsc["cols"]["quota_size"] = array("type" => "text", "check" => "max_value_2096", "default" => "10", "happen" => _("MBytes"), "help" => _("Setting BOTH the number of files and overall mailbox size to zero will disable quota."), "legend" => _("Mailbox quota: ")); $dsc["cols"]["quota_files"] = array("type" => "text", "check" => "number", "default" => "1024", "happen" => _("files"), "legend" => _("Mailbox max files quota: ")); $dsc["cols"]["redirect1"] = array("type" => "text", "check" => "email", "can_be_empty" => "yes", "empty_makes_sql_null" => "yes", "legend" => _("Redirection 1: ")); $dsc["cols"]["redirect2"] = array("type" => "text", "check" => "email", "can_be_empty" => "yes", "empty_makes_sql_null" => "yes", "legend" => _("Redirection 2: ")); $dsc["cols"]["localdeliver"] = array("type" => "checkbox", "values" => array("yes", "no"), "legend" => _("Deliver messages locally in INBOX: ")); $dsc["cols"]["vacation_flag"] = array("type" => "checkbox", "values" => array("yes", "no"), "default" => "no", "legend" => _("Check to send a bounce message (vacation): ")); $dsc["cols"]["vacation_text"] = array("type" => "textarea", "legend" => _("Bounce message content: "), "cols" => "40", "rows" => "7"); } $list_items = dtcListItemsEdit($dsc); // We have to query again, in case something has changed $q = "SELECT id FROM {$pro_mysql_pop_table} WHERE mbox_host='" . $domain["name"] . "';"; $r = mysql_query($q) or die("Cannot query {$q} line: " . __LINE__ . " file " . __FILE__ . " sql said:" . mysql_error()); $n = mysql_num_rows($r); $catch_popup = "<option value=\"no-mail-account\">" . _("No catch-all") . "</option>"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); if ($a["id"] == $domain["catchall_email"]) { $selected = " selected "; } else { $selected = " "; } $catch_popup .= "<option value=\"" . $a["id"] . "\" {$selected}>" . $a["id"] . "</option>"; } $out .= "<b><u>" . _("Catch-all email set to deliver to") . ":</u></b><br>"; $out .= "<form action=\"" . $_SERVER["PHP_SELF"] . "\">\n\t<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n\t<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n\t<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">\n\t<input type=\"hidden\" name=\"edit_domain\" value=\"{$edit_domain}\">\n\tCatchall: <input type=\"hidden\" name=\"action\" value=\"set_catchall_account\">\n\t<select name=\"catchall_popup\">{$catch_popup}</select><input type=\"image\" src=\"gfx/stock_apply_20.png\">\n</form>"; $out .= $list_items; $out .= helpLink("PmWiki/Email-Accounts"); return $out; }
function drawAdminTools_PackageInstaller($domain, $adm_path) { global $adm_login; global $adm_pass; global $edit_domain; global $addrlink; global $dtcshared_path; global $pro_mysql_subdomain_table; global $conf_mysql_db; global $conf_user_mysql_type; global $conf_user_mysql_host; global $conf_user_mysql_root_login; global $conf_user_mysql_root_pass; global $package_installer_console; global $dtcpkg_db_login; global $pkg_info; $txt = ""; $dir = $dtcshared_path . "/package-installer"; if (isset($_REQUEST["action"]) && ($_REQUEST["action"] == "do_install" || $_REQUEST["action"] == "prepareinstall")) { $pkg_path = $dir . "/" . $_REQUEST["pkg"]; $dtc_pkg_info = $pkg_path . "/dtc-pkg-info.php"; if (!file_exists($dtc_pkg_info)) { die("Package {$dtc_pkg_info} not found line " . __LINE__ . " file " . __FILE__); } include $dtc_pkg_info; } if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "do_install") { $pkg_path = $dir . "/" . $_REQUEST["pkg"]; $dtc_pkg_install = $pkg_path . "/dtc-pkg-install.php"; if (file_exists($dtc_pkg_install)) { include $dtc_pkg_install; } // Check if user has enough rights checkLoginPassAndDomain($adm_login, $adm_pass, $edit_domain); checkSubdomainFormat($_REQUEST["subdomain"]); $admin_path = getAdminPath($adm_login); $target = "{$admin_path}/{$edit_domain}/subdomains/" . $_REQUEST["subdomain"] . "/html"; if (!is_dir($target)) { die("Destination directory does not exists line " . __LINE__ . " file " . __FILE__); } // Unpack the distribution package in target folder if ($pkg_info["unpack_type"] == "tar.gz") { $cmd = "tar -C {$target} -xvzf {$pkg_path}/" . $pkg_info["file"]; $x = "=> tar -C {$target} -xvzf {$pkg_path}/" . $pkg_info["file"] . "\n"; exec($cmd, $exec_out, $return_val); } else { if ($pkg_info["unpack_type"] == "tar.bz2") { $cmd = "tar -C {$target} -xvjf {$pkg_path}/" . $pkg_info["file"]; $x = "=> tar -xvjf " . $pkg_info["file"] . "\n"; exec($cmd, $exec_out, $return_val); } else { die("Package methode not supported yet"); } } // Rename folder to the destination folder name (eg remove version out of package.X.X.X folder name if exists) if (isset($pkg_info["renamedir_to"]) && isset($pkg_info["resulting_dir"]) && $pkg_info["resulting_dir"] != $pkg_info["renamedir_to"]) { $cmd = "mv {$target}/" . $pkg_info["resulting_dir"] . " {$target}/" . $pkg_info["renamedir_to"]; $x .= "=> Moving " . $pkg_info["resulting_dir"] . " to " . $pkg_info["renamedir_to"] . "<br>"; exec($cmd, $exec_out, $return_val); } // https://dtc.gpl-host.com/dtc/index.php?adm_login=zigo&adm_pass=toto&addrlink=gpl-host.com/package-installer&action=prepareinstall&pkg=phpbb // Move the folder to the requested name dtcpkg_directory=bla if ($pkg_info["can_select_directory"] == "yes") { if ($_REQUEST["dtcpkg_directory"] == "") { $cmd = "mv {$target}/" . $pkg_info["renamedir_to"] . "/* {$target}/"; $x .= "=> Moving " . $pkg_info["renamedir_to"] . " to folder /<br>"; exec($cmd, $exec_out, $return_val); $realtarget = "{$target}"; } else { $cmd = "mv {$target}/" . $pkg_info["renamedir_to"] . " {$target}/" . $_REQUEST["dtcpkg_directory"]; $x .= "=> Moving " . $pkg_info["renamedir_to"] . " to " . $_REQUEST["dtcpkg_directory"] . "<br>"; exec($cmd, $exec_out, $return_val); $realtarget = "{$target}/" . $_REQUEST["dtcpkg_directory"]; } } if ($conf_user_mysql_type == "distant") { $newid = mysql_connect($conf_user_mysql_host, $conf_user_mysql_root_login, $conf_user_mysql_root_pass) or die("Cannot connect to user host"); } // Get the database infos beffore calling the custom package installer $q = "SELECT DISTINCT db.Db,db.User FROM mysql.user,mysql.db WHERE user.dtcowner='{$adm_login}' AND db.User=user.User AND db.Db='" . $_REQUEST["database_name"] . "';"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 1) { die("Cannot find database line " . __LINE__ . " file " . __FILE__); } $a = mysql_fetch_array($r); $dtcpkg_db_login = $a["User"]; if ($conf_user_mysql_type == "distant") { mysql_close($newid) or die("Cannot disconnect to user database"); connect2base(); } // Call the package specific installer php script $install_ret = do_package_install(); // reselect the current dtc db in case another have been set mysql_select_db($conf_mysql_db); if ($install_ret == 0) { $package_installer_console .= "Install successful !<br>"; } $nbr_remove = sizeof($pkg_info["remove_folder_path"]); if ($nbr_remove > 0) { // print_r($pkg_info["remove_folder_path"]); $nbr_remove = sizeof($pkg_info["remove_folder_path"]); $package_installer_console .= "Removing install folders...<br>"; for ($i = 0; $i < $nbr_remove; $i++) { $cmd = "rm -r {$realtarget}/" . $pkg_info["remove_folder_path"][$i]; // $package_installer_console .= $cmd."<br>"; exec($cmd, $exec_out, $return_val); } } // Print the results $txt .= "<h3>Installation of " . $pkg_info["name"] . ":</h3><br><pre>" . $x . $package_installer_console . "</pre>"; return $txt; } if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "prepareinstall") { $txt = "<h3>You are about to install " . $pkg_info["name"] . ":</h3><br>\n\t\t<u>Description:</u> " . $pkg_info["long_desc"] . "<br>\n\t\t<u>Version:</u> " . $pkg_info["version"] . "<br><br>"; $txt .= "<form action=\"" . $_SERVER["PHP_SELF"] . "\">\n\t\t<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n\t\t<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n\t\t<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">"; if ($pkg_info["need_database"] == "yes") { $txt .= "<h3>Choose a database name for setup:</h3><br>"; if ($conf_user_mysql_type == "distant") { $newid = mysql_connect($conf_user_mysql_host, $conf_user_mysql_root_login, $conf_user_mysql_root_pass) or die("Cannot connect to user SQL host"); } mysql_select_db("mysql") or die("Cannot select db: mysql"); $q = "SELECT db.Db,db.User FROM user,db\n\t\t\tWHERE user.dtcowner='{$adm_login}'\n\t\t\tAND db.User=user.User"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n < 1) { $txt .= "You don't have any database yet. Please create one using the database tool\n\t\t\t\t(click database in the menu, then create a user and a database for this user)."; if ($conf_user_mysql_type == "distant") { mysql_close($newid) or die("Cannot disconnect to user database"); connect2base(); } mysql_select_db($conf_mysql_db); return $txt; } $txt .= "Database name: <select name=\"database_name\">"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $txt .= "<option value=\"" . $a["Db"] . "\">" . $a["Db"] . " (login: "******"User"] . ")" . "</option>"; } $txt .= "</select><br>\n\t\t\t\tDatabase password: <input type=\"password\" name=\"dtcpkg_db_pass\" value=\"\"><br><br>"; if ($conf_user_mysql_type == "distant") { mysql_close($newid) or die("Cannot disconnect to user database"); connect2base(); } mysql_select_db($conf_mysql_db) or die("Cannot select db: {$conf_mysql_db} line " . __LINE__ . " file " . __FILE__); } if ($pkg_info["need_admin_email"] == "yes") { $txt .= "<h3>Enter email for the admin of this package:</h3><br>"; $txt .= "Email: <input type=\"text\" name=\"dtcpkg_email\" value=\"\"><br><br>"; } if ($pkg_info["need_admin_login"] == "yes") { $txt .= "<h3>Enter login informations for the admin of this package:</h3><br>"; $txt .= "Login: <input type=\"text\" name=\"dtcpkg_login\" value=\"\"><br>"; if ($pkg_info["need_admin_pass"] == "yes") { $txt .= "Pass: <input type=\"text\" name=\"dtcpkg_pass\" value=\"\"><br>"; } $txt .= "<br>"; } $txt .= "<h3>Choose the subdomain and install :</h3><br>"; $txt .= "<input type=\"hidden\" name=\"action\" value=\"do_install\">\n\t\t<input type=\"hidden\" name=\"pkg\" value=\"" . $_REQUEST["pkg"] . "\">\n\t\tSubdomain: <select name=\"subdomain\">"; // echo "<pre>"; // print_r($domain); // echo "</pre>"; $n = sizeof($domain["subdomains"]); for ($i = 0; $i < $n; $i++) { $txt .= "<option value=\"" . $domain["subdomains"][$i]["name"] . "\">" . $domain["subdomains"][$i]["name"] . "</option>"; } $txt .= "</select><br><br>"; if ($pkg_info["can_select_directory"] == "yes") { $txt .= "<h3>Enter the directory where you want to install this package:</h3><br>"; $txt .= "Directory (blank for /): <input type=\"text\" name=\"dtcpkg_directory\" value=\"\"><br><br>"; } $txt .= "<input type=\"submit\" value=\"Install\">"; $txt .= "</form>"; return $txt; } $txt = "<h3>" . _("Choose a package to install") . ":</h3>"; $txt .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\">"; $txt .= "<tr><td>" . _("Package name") . "</td><td>" . _("Description") . "</td><td>" . _("Package version") . "</td><td>" . _("Need a database") . "</td><td>" . _("Unpack size") . "</td><td>" . _("Install") . "</td></tr>"; $packages = array(); if (is_dir($dir) && ($dh = opendir($dir))) { while (($file = readdir($dh)) !== false) { if (is_dir($dir . "/" . $file) && $file != "." && $file != "..") { $packages[] = $file; } } closedir($dh); } sort($packages); foreach ($packages as $package) { if (file_exists($dir . "/" . $package . "/dtc-pkg-info.php")) { include $dir . "/" . $package . "/dtc-pkg-info.php"; $txt .= "<tr><td>" . $pkg_info["name"] . "</td>\n\t\t\t\t<td>" . $pkg_info["short_desc"] . "</td>\n\t\t\t\t<td>" . $pkg_info["version"] . "</td>\n\t\t\t\t<td>" . $pkg_info["need_database"] . "</td>\n\t\t\t\t<td style=\"white-space:nowrap;text-align=right\" nowrap>" . smartByte($pkg_info["unpack_disk_usage"]) . "</td>\n\t\t\t\t<td><a href=\"" . $_SERVER["PHP_SELF"] . "?adm_login={$adm_login}&adm_pass={$adm_pass}&addrlink={$addrlink}&action=prepareinstall&pkg={$package}\">" . _("Install") . "</a></td></tr>"; } } $txt .= "</table>"; return $txt; }
function drawAdminTools_Subdomain($admin, $domain) { global $adm_login; global $adm_pass; global $edit_domain; global $addrlink; global $conf_administrative_site; global $conf_hide_password; global $edit_a_subdomain; global $dtcshared_path; global $pro_mysql_nameservers_table; global $pro_mysql_subdomain_table; global $pro_mysql_ssl_ips_table; $txt = ""; checkLoginPassAndDomain($adm_login, $adm_pass, $domain["name"]); $nbr_subdomain = sizeof($domain["subdomains"]); $max_subdomain = $domain["max_subdomain"]; // Let's start a form ! $frm = "<form action=\"?\" methode=\"post\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"adm_login\" value=\"{$adm_login}\">\n<input type=\"hidden\" name=\"adm_pass\" value=\"{$adm_pass}\">\n<input type=\"hidden\" name=\"addrlink\" value=\"{$addrlink}\">\n<input type=\"hidden\" name=\"edit_domain\" value=\"{$edit_domain}\">\n<input type=\"hidden\" name=\"whatdoiedit\" value=\"subdomains\">"; $txt .= $frm; // Popup for choosing default subdomain. $subdomains = $domain["subdomains"]; $txt .= "<table><tr><td align=\"right\">"; $txt .= _("Default subdomain: ") . "</td><td><select name=\"subdomaindefault_name\">"; for ($i = 0; $i < $nbr_subdomain; $i++) { $sub = $subdomains[$i]["name"]; if ($domain["default_subdomain"] == "{$sub}") { $txt .= "<option value=\"{$sub}\" selected>{$sub}</option>"; } else { $txt .= "<option value=\"{$sub}\">{$sub}</option>"; } } $txt .= "</select></td></tr>"; // Radio to choose wildcard or not if ($domain["wildcard_dns"] == "yes") { $yes_flag = " checked "; $no_flag = " "; } else { $yes_flag = " "; $no_flag = " checked "; } $txt .= "<tr><td align=\"right\">" . _("Use as wildcard for the domain:") . " </td><td><input type=\"radio\" name=\"wildcard_dns\" value=\"yes\"{$yes_flag}>" . _("Yes") . "<input type=\"radio\" name=\"wildcard_dns\" value=\"no\"{$no_flag}>" . _("No") . "</td></tr>"; // Radio to activate the ServerAlias on the default subdomain if ($domain["default_sub_server_alias"] == "yes") { $yes_flag = " checked "; $no_flag = " "; } else { $yes_flag = " "; $no_flag = " checked "; } $txt .= "<tr><td align=\"right\">" . _("Generate a ServerAlias for the root of the domain:") . " </td><td><input type=\"radio\" name=\"default_sub_server_alias\" value=\"yes\"{$yes_flag}>" . _("Yes") . "<input type=\"radio\" name=\"default_sub_server_alias\" value=\"no\"{$no_flag}>" . _("No") . "</td></tr>"; // Apply button $txt .= "<tr><td></td><td><input type=\"hidden\" name=\"subdomaindefault\" value=\"Ok\"><input type=\"image\" src=\"gfx/stock_apply_20.png\"></td></tr></table></form>"; $txt .= $frm . ""; $dsc = array("title" => _("List of your subdomains: "), "new_item_title" => _("Create a subdomain: "), "new_item_link" => _("New subdomain"), "edit_item_title" => _("Edit one of your subdomains"), "table_name" => $pro_mysql_subdomain_table, "action" => "subdomain_editor", "forward" => array("adm_login", "adm_pass", "addrlink"), "id_fld" => "id", "list_fld_show" => "subdomain_name", "max_item" => $max_subdomain, "num_item_txt" => _("Number of active subdomains:"), "create_item_callback" => "subdomainCreateDirsCallBack", "delete_item_callback" => "subdomainDeleteDirsCallBack", "edit_item_callback" => "subdomainEditCallBack", "order_by" => "subdomain_name", "where_list" => array("domain_name" => $domain["name"]), "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "subdomain_name" => array("type" => "text", "check" => "subdomain", "disable_edit" => "yes", "legend" => _("Subdomain name: ")), "ip" => array("type" => "text", "check" => "subdomain_or_ip", "can_be_empty" => "yes", "empty_makes_default" => "yes", "legend" => _("IP address or CNAME: ")), "ip6" => array("type" => "text", "check" => "ip6", "can_be_empty" => "yes", "empty_makes_default" => "yes", "legend" => _("IPv6 address: ")), "generate_vhost" => array("type" => "radio", "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "legend" => _("Generate a vhost entry for this subdomain:")), "add_default_charset" => array("type" => "popup", "values" => array("dtc-wont-add", "Off", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "ISO-8859-11", "ISO-8859-12", "ISO-8859-13", "ISO-8859-14", "ISO-8859-15", "ISO-8859-16", "ISO-2022-JP", "ISO-2022-KR", "ISO-2022-CN", "Big5", "cn-Big5", "WINDOWS-1251", "CP866", "KOI8", "KOI8-E", "KOI8-r", "KOI8-U", "KOI8-ru", "ISO-10646-UCS-2", "ISO-10646-UCS-4", "UTF-7", "UTF-8", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-32", "UTF-32BE", "UTF-32LE", "euc-cn", "euc-gb", "euc-jp", "euc-kr", "EUC-TW", "gb2312", "iso-10646-ucs-2", "iso-10646-ucs-4", "shift_jis"), "legend" => "AddDefaultCharset"), "srv_record" => array("type" => "text", "can_be_empty" => "yes", "legend" => _("This subdomain is a service (SRV)<br>entry for the following port: ")), "srv_record_protocol" => array("type" => "radio", "values" => array("tcp", "udp", "sctp"), "default" => "tcp", "legend" => _("SRV protocol: ")), "register_globals" => array("type" => "radio", "values" => array("yes", "no"), "default" => "no", "display_replace" => array(_("Yes"), _("No")), "legend" => _("Use register_globals=1: ")), "associated_txt_record" => array("type" => "text", "legend" => _("TXT field of the subdomain: ")), "nameserver_for" => array("type" => "text", "check" => "domain_or_ip", "can_be_empty" => "yes", "legend" => _("This subdomain is a nameserver (NS)<br>entry for the following subdomain: ")))); if ($domain["safe_mode"] == "no") { $dsc["cols"]["safe_mode"] = array("type" => "radio", "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "legend" => "PHP safe mode: "); } if ($domain["sbox_protect"] == "no") { $dsc["cols"]["sbox_protect"] = array("type" => "radio", "values" => array("yes", "no"), "display_replace" => array(_("Yes"), _("No")), "legend" => _("Sbox cgi-bin protection: ")); } // Get all SSL IPs asigned to this customer $q = "SELECT * FROM {$pro_mysql_ssl_ips_table} WHERE adm_login='******' AND available='no';"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 0) { $ssl_ips = array(); $ssl_ips[] = "none"; // Check if some SSL certs are free, or used by current subdomain for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $nbr_domains = sizeof($admin["data"]); $used_by = "none"; for ($j = 0; $j < $nbr_domains; $j++) { $nbr_subdomains = sizeof($admin["data"][$j]["subdomains"]); for ($k = 0; $k < $nbr_subdomains; $k++) { if ($admin["data"][$j]["subdomains"][$k]["ssl_ip"] == $a["ip_addr"]) { // The cert is used by current subdomain if (isset($_REQUEST["item"]) && isset($_REQUEST["subaction"]) && $_REQUEST["subaction"] == "subdomain_editor_edit_item" && $_REQUEST["item"] == $admin["data"][$j]["subdomains"][$k]["id"]) { $ssl_ips[] = $a["ip_addr"]; // The cert is used by another subdomain, don't show it... } else { $used_by = $admin["data"][$j]["name"] . $admin["data"][$j]["subdomains"][$k]["name"]; } } } } if ($used_by == "none") { $ssl_ips[] = $a["ip_addr"]; } } $dsc["cols"]["ssl_ip"] = array("type" => "popup", "values" => $ssl_ips, "legend" => _("Use an SSL vhost using this IP: ")); } // Check to see if there is some SSL IPs for that customer $q = "SELECT * FROM {$pro_mysql_ssl_ips_table} WHERE adm_login='******' AND available='no';"; $r = mysql_query($q) or die("Cannot query \"{$q}\" line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $dsc["cols"]["login"] = array("type" => "text", "check" => "dtc_login", "empty_makes_sql_null" => "yes", "can_be_empty" => "yes", "legend" => _("Dynamic IP update login: "******"cols"]["pass"] = array("type" => "password", "check" => "dtc_pass", "empty_makes_sql_null" => "yes", "can_be_empty" => "yes", "legend" => _("Dynamic IP update password: "******"<br>" . _("Windows users (and UNIX users running WINE) can update their IP address dynamically by downloading and installing the following open source DTC client:") . "<br>" . "<a href=\"http://www.gplhost.com/DTC-Dynamic_IP_updater.exe\">DTC-Dynamic_IP_updater.exe</a><br>" . _("For unix users, a simple wget command in a cron joe like below will do. Something like this:") . "<br>" . htmlspecialchars("wget https://" . $conf_administrative_site . "/dtc/dynip.php?login=MYLOGIN&pass=MYPASS&domain=" . $domain["name"] . "&ip=1.2.3.4") . "<br>"; $txt .= helpLink("PmWiki/Subdomains"); return $txt; }