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