proper spaces in admin

This commit is contained in:
Benjamin Sonntag 2015-06-08 19:21:34 +02:00
parent 350750fe32
commit d6980d7664
1 changed files with 1428 additions and 1457 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
/* /*
---------------------------------------------------------------------- ----------------------------------------------------------------------
AlternC - Web Hosting System AlternC - Web Hosting System
@ -29,21 +30,20 @@
* Manage the AlternC's account administration (create/edit/delete) * Manage the AlternC's account administration (create/edit/delete)
*/ */
class m_admin { class m_admin {
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** $enabled tells if the logged user is super-admin or not /** $enabled tells if the logged user is super-admin or not
*/ */
var $enabled = 0; var $enabled = 0;
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** List of the controls made for each TLD /** List of the controls made for each TLD
* *
* $tldmode is used by the administration panel, while choosing * $tldmode is used by the administration panel, while choosing
* the authorized TLDs. It's an array of strings explaining the current state of the TLD. * the authorized TLDs. It's an array of strings explaining the current state of the TLD.
*/ */
public $tldmode = array(); public $tldmode = array();
var $archive = ''; var $archive = '';
/** /**
@ -68,6 +68,7 @@ class m_admin {
); );
$this->archive = variable_get('archive_del_data', '', 'If folder specified html folder of deleted user is archived, else it is deleted. '); $this->archive = variable_get('archive_del_data', '', 'If folder specified html folder of deleted user is archived, else it is deleted. ');
} }
/** /**
* *
* @global type $mem * @global type $mem
@ -78,7 +79,8 @@ class m_admin {
*/ */
function hook_menu() { function hook_menu() {
global $mem, $cuid, $debug_alternc, $L_INOTIFY_UPDATE_DOMAIN; global $mem, $cuid, $debug_alternc, $L_INOTIFY_UPDATE_DOMAIN;
if (!$mem->checkRight()) return false; if (!$mem->checkRight())
return false;
$obj = array( $obj = array(
'title' => _("Administration"), 'title' => _("Administration"),
@ -102,43 +104,36 @@ class m_admin {
); );
if ($cuid == 2000) { if ($cuid == 2000) {
$obj['links'][] = $obj['links'][] = array(
array(
'txt' => _("Admin Control Panel"), 'txt' => _("Admin Control Panel"),
'url' => 'adm_panel.php', 'url' => 'adm_panel.php',
'class' => 'adminmenu' 'class' => 'adminmenu'
); );
$obj['links'][] = $obj['links'][] = array(
array(
'txt' => _("PhpMyAdmin"), 'txt' => _("PhpMyAdmin"),
'url' => '/alternc-sql/', 'url' => '/alternc-sql/',
'class' => 'adminmenu', 'class' => 'adminmenu',
'target' => '_blank', 'target' => '_blank',
); );
$obj['links'][] = $obj['links'][] = array(
array(
'txt' => ($debug_alternc->status) ? _("Switch debug Off") : _("Switch debug On"), 'txt' => ($debug_alternc->status) ? _("Switch debug Off") : _("Switch debug On"),
'url' => "alternc_debugme.php?enable=" . ($debug_alternc->status ? "0" : "1"), 'url' => "alternc_debugme.php?enable=" . ($debug_alternc->status ? "0" : "1"),
'class' => 'adminmenu' 'class' => 'adminmenu'
); );
if (empty($L_INOTIFY_UPDATE_DOMAIN) || file_exists("$L_INOTIFY_UPDATE_DOMAIN")) { if (empty($L_INOTIFY_UPDATE_DOMAIN) || file_exists("$L_INOTIFY_UPDATE_DOMAIN")) {
$obj['links'][] = $obj['links'][] = array(
array(
'txt' => _("Applying..."), 'txt' => _("Applying..."),
'url' => 'javascript:alert(\'' . _("Domain changes are already applying") . '\');', 'url' => 'javascript:alert(\'' . _("Domain changes are already applying") . '\');',
'class' => 'adminmenu', 'class' => 'adminmenu',
); );
} else { } else {
$obj['links'][] = $obj['links'][] = array(
array(
'txt' => _("Apply changes"), 'txt' => _("Apply changes"),
'url' => 'adm_update_domains.php', 'url' => 'adm_update_domains.php',
'class' => 'adminmenu', 'class' => 'adminmenu',
'onclick' => 'return confirm("' . addslashes(_("Server configuration changes are applied every 5 minutes. Do you want to do it right now?")) . '");', 'onclick' => 'return confirm("' . addslashes(_("Server configuration changes are applied every 5 minutes. Do you want to do it right now?")) . '");',
); );
} // L_INOTIFY_UPDATE_DOMAIN } // L_INOTIFY_UPDATE_DOMAIN
} // cuid == 2000 } // cuid == 2000
@ -250,7 +245,6 @@ class m_admin {
return $lst_users_properties[$uid]; return $lst_users_properties[$uid];
} }
/** /**
* Returns the known information about a specific hosted account * Returns the known information about a specific hosted account
* *
@ -300,7 +294,6 @@ class m_admin {
return $c; return $c;
} }
/** /**
* *
* @global type $db * @global type $db
@ -314,7 +307,6 @@ class m_admin {
return ($db->f("cnt") == 1); return ($db->f("cnt") == 1);
} }
/** /**
* Returns the list of the hosted accounts * Returns the list of the hosted accounts
* *
@ -362,7 +354,6 @@ class m_admin {
$request .= ' GROUP BY uid'; $request .= ' GROUP BY uid';
} elseif ($pattern_type === 'login') { } elseif ($pattern_type === 'login') {
$request = 'SELECT uid FROM membres WHERE 1'; $request = 'SELECT uid FROM membres WHERE 1';
@ -377,18 +368,14 @@ class m_admin {
$request .= sprintf(' AND creator = "%s"', $cuid); $request .= sprintf(' AND creator = "%s"', $cuid);
$request .= ' ORDER BY login;'; $request .= ' ORDER BY login;';
} else { } else {
$err->raise("admin", _("Invalid pattern type provided. Are you even performing a legitimate action?")); $err->raise("admin", _("Invalid pattern type provided. Are you even performing a legitimate action?"));
return FALSE; return FALSE;
} }
} else { } else {
if ($creator) if ($creator) {
{
// Limit listing to a specific reseller // Limit listing to a specific reseller
$request = "SELECT uid FROM membres WHERE creator='" . $creator . "' ORDER BY login;"; $request = "SELECT uid FROM membres WHERE creator='" . $creator . "' ORDER BY login;";
} elseif ($mem->user['uid'] == 2000 || $all) { } elseif ($mem->user['uid'] == 2000 || $all) {
@ -411,7 +398,6 @@ class m_admin {
} }
} }
/** /**
* Send an email to all AlternC's accounts * Send an email to all AlternC's accounts
* *
@ -455,7 +441,6 @@ class m_admin {
return true; return true;
} }
/** /**
* Returns an array with the known information about resellers (uid, login, number of accounts) * Returns an array with the known information about resellers (uid, login, number of accounts)
* Does not include account 2000 in the list. * Does not include account 2000 in the list.
@ -557,6 +542,7 @@ class m_admin {
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Creates a new hosted account /** Creates a new hosted account
* *
* Creates a new hosted account (in the tables <code>membres</code> * Creates a new hosted account (in the tables <code>membres</code>
@ -643,7 +629,8 @@ class m_admin {
$uid = 2000; $uid = 2000;
} else { } else {
$uid = $db->Record["nextid"]; $uid = $db->Record["nextid"];
if ($uid<=2000) $uid=2000; if ($uid <= 2000)
$uid = 2000;
} }
$db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created,notes,db_server_id) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes', '$db_server_id');"); $db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created,notes,db_server_id) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes', '$db_server_id');");
$db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');"); $db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');");
@ -737,7 +724,6 @@ EOF;
} }
} }
/** /**
* Edit an account * Edit an account
* *
@ -783,22 +769,19 @@ EOF;
$old_mem = $this->get($uid); $old_mem = $this->get($uid);
if (($db->query("UPDATE local SET nom='$nom', prenom='$prenom' WHERE uid='$uid';")) if (($db->query("UPDATE local SET nom='$nom', prenom='$prenom' WHERE uid='$uid';")) && ($db->query("UPDATE membres SET mail='$mail', canpass='$canpass', enabled='$enabled', `type`='$type', notes='$notes' $ssq WHERE uid='$uid';"))) {
&&($db->query("UPDATE membres SET mail='$mail', canpass='$canpass', enabled='$enabled', `type`='$type', notes='$notes' $ssq WHERE uid='$uid';"))){
if ($reset_quotas == "on" || $type != $old_mem['type']) { if ($reset_quotas == "on" || $type != $old_mem['type']) {
$quota->addquotas(); $quota->addquotas();
$quota->synchronise_user_profile(); $quota->synchronise_user_profile();
} }
$this->renew_update($uid, $duration); $this->renew_update($uid, $duration);
return true; return true;
} } else {
else {
$err->raise("admin", _("Account not found")); $err->raise("admin", _("Account not found"));
return false; return false;
} }
} }
/** /**
* Lock an account * Lock an account
* *
@ -819,14 +802,12 @@ EOF;
$db = new DB_System(); $db = new DB_System();
if ($db->query("UPDATE membres SET enabled='0' WHERE uid='$uid';")) { if ($db->query("UPDATE membres SET enabled='0' WHERE uid='$uid';")) {
return true; return true;
} } else {
else {
$err->raise("admin", _("Account not found")); $err->raise("admin", _("Account not found"));
return false; return false;
} }
} }
/** /**
* UnLock an account * UnLock an account
* *
@ -848,15 +829,14 @@ EOF;
$db = new DB_System(); $db = new DB_System();
if ($db->query("UPDATE membres SET enabled='1' WHERE uid='$uid';")) { if ($db->query("UPDATE membres SET enabled='1' WHERE uid='$uid';")) {
return true; return true;
} } else {
else {
$err->raise("admin", _("Account not found")); $err->raise("admin", _("Account not found"));
return false; return false;
} }
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Deletes an account /** Deletes an account
* Deletes the specified account. Prevents any manipulation of the account if * Deletes the specified account. Prevents any manipulation of the account if
* the account $mid is not super-admin. * the account $mid is not super-admin.
@ -909,7 +889,6 @@ EOF;
} }
} }
/** /**
* Renew an account * Renew an account
* *
@ -937,7 +916,6 @@ EOF;
} }
} }
/** /**
* Update the duration information for an account * Update the duration information for an account
* *
@ -963,7 +941,6 @@ EOF;
return false; return false;
} }
/** /**
* Get the expiry date for an account * Get the expiry date for an account
* *
@ -978,8 +955,8 @@ EOF;
return ''; return '';
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** /**
* Get the expiry status for an account * Get the expiry status for an account
* *
@ -1000,7 +977,6 @@ EOF;
return 0; return 0;
} }
/** /**
* Get the expired/about to expire accounts. * Get the expired/about to expire accounts.
* *
@ -1026,7 +1002,6 @@ EOF;
} }
} }
/** /**
* Turns a common account into a super-admin account * Turns a common account into a super-admin account
* *
@ -1074,7 +1049,6 @@ EOF;
return true; return true;
} }
/** /**
* List of the authorized TLDs * List of the authorized TLDs
* Returns the list of the authorized TLDs and also the way they are * Returns the list of the authorized TLDs and also the way they are
@ -1098,7 +1072,6 @@ EOF;
return $c; return $c;
} }
/** /**
* List the hosted domains on this server * List the hosted domains on this server
* *
@ -1135,7 +1108,6 @@ EOF;
return $c; return $c;
} }
/** /**
* Check all the domains for their NS MX and IPs * Check all the domains for their NS MX and IPs
* *
@ -1169,7 +1141,8 @@ EOF;
$dontexist = true; $dontexist = true;
} else { } else {
if (!in_array($L_NS1 . ".", $out) || !in_array($L_NS2 . ".", $out)) { if (!in_array($L_NS1 . ".", $out) || !in_array($L_NS2 . ".", $out)) {
$errno=1; $errstr.="NS for this domain are not $L_NS1 and $L_NS2 BUT ".implode(",",$out)."\n"; $errno = 1;
$errstr.="NS for this domain are not $L_NS1 and $L_NS2 BUT " . implode(",", $out) . "\n";
} }
} }
} }
@ -1181,7 +1154,8 @@ EOF;
list($t, $out2[]) = explode(" ", $o); list($t, $out2[]) = explode(" ", $o);
} }
if (!in_array($L_MX . ".", $out2)) { if (!in_array($L_MX . ".", $out2)) {
$errno=1; $errstr.="MX is not $L_MX BUT ".implode(",",$out2)."\n"; $errno = 1;
$errstr.="MX is not $L_MX BUT " . implode(",", $out2) . "\n";
} }
} }
if (!$dontexist) { if (!$dontexist) {
@ -1194,7 +1168,8 @@ EOF;
$out = array(); $out = array();
exec("dig +short A " . escapeshellarg($d["sub"] . (($d["sub"] != "") ? "." : "") . $c["domaine"]), $out); exec("dig +short A " . escapeshellarg($d["sub"] . (($d["sub"] != "") ? "." : "") . $c["domaine"]), $out);
if (!is_array($out)) { // exec dig can fail if (!is_array($out)) { // exec dig can fail
$errno=1; $errstr.="Fail to get the DNS information. Try again.\n"; $errno = 1;
$errstr.="Fail to get the DNS information. Try again.\n";
} else { } else {
if (!in_array($L_PUBLIC_IP, $out)) { if (!in_array($L_PUBLIC_IP, $out)) {
$errstr.="subdomain '" . $d["sub"] . "' don't point to $L_PUBLIC_IP but to " . implode(",", $out) . "\n"; $errstr.="subdomain '" . $d["sub"] . "' don't point to $L_PUBLIC_IP but to " . implode(",", $out) . "\n";
@ -1208,13 +1183,13 @@ EOF;
$errno = 2; $errno = 2;
$errstr = "Domain don't exist anymore !"; $errstr = "Domain don't exist anymore !";
} }
if ($errno==0) $errstr="OK"; if ($errno == 0)
$errstr = "OK";
$checked[$c["domaine"]] = array("errno" => $errno, "errstr" => $errstr); $checked[$c["domaine"]] = array("errno" => $errno, "errstr" => $errstr);
} }
return $checked; return $checked;
} }
/** /**
* Lock / Unlock a domain * Lock / Unlock a domain
* *
@ -1237,7 +1212,6 @@ EOF;
return true; return true;
} }
/** /**
* Add a new TLD to the list of the authorized TLDs * Add a new TLD to the list of the authorized TLDs
* *
@ -1256,7 +1230,6 @@ EOF;
return $db->Record["mode"]; return $db->Record["mode"];
} }
/** /**
* Prints the list of the actually authorized TLDs * Prints the list of the actually authorized TLDs
* *
@ -1265,12 +1238,12 @@ EOF;
function selecttldmode($current = false) { function selecttldmode($current = false) {
for ($i = 0; $i < count($this->tldmode); $i++) { for ($i = 0; $i < count($this->tldmode); $i++) {
echo "<option value=\"$i\""; echo "<option value=\"$i\"";
if ($current==$i) echo " selected=\"selected\""; if ($current == $i)
echo " selected=\"selected\"";
echo ">" . _($this->tldmode[$i]) . "</option>\n"; echo ">" . _($this->tldmode[$i]) . "</option>\n";
} }
} }
/** /**
* Deletes the specified tld in the list of the authorized TLDs * Deletes the specified tld in the list of the authorized TLDs
* <b>Note</b> : This function does not delete the domains depending * <b>Note</b> : This function does not delete the domains depending
@ -1293,8 +1266,8 @@ EOF;
return true; return true;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Add a TLD to the list of the authorized TLDs during the installation /** Add a TLD to the list of the authorized TLDs during the installation
* *
* <b>Note: </b> If you check in the whois, be sure that * <b>Note: </b> If you check in the whois, be sure that
@ -1321,14 +1294,15 @@ EOF;
$err->raise("admin", _("This TLD already exist")); $err->raise("admin", _("This TLD already exist"));
return false; return false;
} }
if (substr($tld,0,1)==".") $tld=substr($tld,1); if (substr($tld, 0, 1) == ".")
$tld = substr($tld, 1);
$mode = intval($mode); $mode = intval($mode);
if ($mode==0) $mode="0"; if ($mode == 0)
$mode = "0";
$db->query("INSERT INTO tld (tld,mode) VALUES ('$tld','$mode');"); $db->query("INSERT INTO tld (tld,mode) VALUES ('$tld','$mode');");
return true; return true;
} }
/** /**
* Modify a TLD of the list of the authorized TLDs * Modify a TLD of the list of the authorized TLDs
* *
@ -1348,12 +1322,12 @@ EOF;
return false; return false;
} }
$mode = intval($mode); $mode = intval($mode);
if ($mode==0) $mode="0"; if ($mode == 0)
$mode = "0";
$db->query("UPDATE tld SET mode='$mode' WHERE tld='$tld';"); $db->query("UPDATE tld SET mode='$mode' WHERE tld='$tld';");
return true; return true;
} }
/** /**
* Get the login name of the main administrator account * Get the login name of the main administrator account
* *
@ -1367,7 +1341,6 @@ EOF;
return $db->f("login"); return $db->f("login");
} }
/** /**
* List the password policies currently installed in the policy table * List the password policies currently installed in the policy table
* *
@ -1420,7 +1393,6 @@ EOF;
return $policies; return $policies;
} }
/** /**
* Change a password policy for one kind of password * Change a password policy for one kind of password
* *
@ -1451,7 +1423,6 @@ EOF;
return true; return true;
} }
/** /**
* *
* @global m_mysql $db * @global m_mysql $db
@ -1529,7 +1500,6 @@ EOF;
return true; // congratulations ! return true; // congratulations !
} }
/** /**
* hook function called by AlternC-upnp to know which open * hook function called by AlternC-upnp to know which open
* tcp or udp ports this class requires or suggests * tcp or udp ports this class requires or suggests
@ -1545,6 +1515,7 @@ EOF;
); );
} }
}
} /* Classe ADMIN */ /* Classe ADMIN */