Alternc  latest
Alternc logiel libre pour l'hébergement
 All Classes Namespaces Files Functions Variables Pages
m_admin Class Reference

Manage the AlternC's account administration (create/edit/delete) More...

Public Member Functions

 m_admin ()
 Constructor. More...
 
 hook_menu ()
 
 stop_if_jobs_locked ()
 
 get_uid_by_login ($login)
 return the uid of an alternc account More...
 
 get_login_by_uid ($uid)
 return the name of an alternc account More...
 
 get ($uid, $recheck=false)
 Returns the known information about a hosted account. More...
 
 get_creator ($uid)
 Returns the known information about a specific hosted account. More...
 
 onesu ()
 
 get_list ($all=0, $creator=0, $pattern=FALSE, $pattern_type=FALSE)
 :EM: those request should have been escaped Returns the list of the hosted accounts More...
 
 mailallmembers ($subject, $message, $from)
 Send an email to all AlternC's accounts. More...
 
 get_creator_list ()
 Returns an array with the known information about resellers (uid, login, number of accounts) Does not include account 2000 in the list. More...
 
 checkcreator ($uid)
 Check if I am the creator of the member $uid. More...
 
 add_shared_domain ($u, $domain_name)
 When the admin want to delegate a subdomain to an account. More...
 
 add_mem ($login, $pass, $nom, $prenom, $mail, $canpass=1, $type= 'default', $duration=0, $notes="", $force=0, $create_dom= '', $db_server_id)
 Creates a new hosted account. More...
 
 hook_admin_add_member ()
 AlternC's standard function called when a user is created This sends an email if configured through the interface. More...
 
 update_mem ($uid, $mail, $nom, $prenom, $pass, $enabled, $canpass, $type= 'default', $duration=0, $notes="", $reset_quotas=false)
 Edit an account. More...
 
 lock_mem ($uid)
 Lock an account. More...
 
 unlock_mem ($uid)
 UnLock an account. More...
 
 del_mem ($uid)
 Deletes an account Deletes the specified account. More...
 
 renew_mem ($uid, $periods=1)
 Renew an account. More...
 
 renew_update ($uid, $duration)
 Update the duration information for an account. More...
 
 renew_get_expiry ($uid)
 Get the expiry date for an account. More...
 
 renew_get_status ($uid)
 Get the expiry status for an account. More...
 
 renew_get_expiring_accounts ()
 Get the expired/about to expire accounts. More...
 
 normal2su ($uid)
 Turns a common account into a super-admin account. More...
 
 su2normal ($uid)
 Turns a super-admin account into a common account. More...
 
 listtld ()
 List of the authorized TLDs Returns the list of the authorized TLDs and also the way they are authorized. More...
 
 dom_list ($alsocheck=false, $forcecheck=false)
 List the hosted domains on this server. More...
 
 checkalldom ()
 Check all the domains for their NS MX and IPs. More...
 
 dom_lock ($domain)
 Lock / Unlock a domain. More...
 
 gettld ($tld)
 Add a new TLD to the list of the authorized TLDs. More...
 
 selecttldmode ($current=false)
 Prints the list of the actually authorized TLDs. More...
 
 deltld ($tld)
 Deletes the specified tld in the list of the authorized TLDs Note : This function does not delete the domains depending on this TLD. More...
 
 addtld ($tld, $mode)
 Add a TLD to the list of the authorized TLDs during the installation. More...
 
 edittld ($tld, $mode)
 Modify a TLD of the list of the authorized TLDs. More...
 
 getadmin ()
 Get the login name of the main administrator account. More...
 
 listPasswordPolicies ()
 List the password policies currently installed in the policy table. More...
 
 editPolicy ($policy, $minsize, $maxsize, $classcount, $allowlogin)
 Change a password policy for one kind of password. More...
 
 checkPolicy ($policy, $login, $password)
 
 hook_upnp_list ()
 hook function called by AlternC-upnp to know which open tcp or udp ports this class requires or suggests More...
 

Public Attributes

 $enabled = 0
 $enabled tells if the logged user is super-admin or not More...
 
 $tldmode = array()
 List of the controls made for each TLD. More...
 
 $archive = ''
 

Detailed Description

Manage the AlternC's account administration (create/edit/delete)

Definition at line 32 of file m_admin.php.

Member Function Documentation

m_admin::add_mem (   $login,
  $pass,
  $nom,
  $prenom,
  $mail,
  $canpass = 1,
  $type = 'default',
  $duration = 0,
  $notes = "",
  $force = 0,
  $create_dom = '',
  $db_server_id 
)

Creates a new hosted account.

Creates a new hosted account (in the tables membres and local). Prevents any manipulation of the account if the account $mid is not super-admin.

Parameters
globalm_err $err
globalm_quota $quota
globalarray $classes
globalint $cuid
globalm_mem $mem
globalstring $L_MYSQL_DATABASE
globalstring $L_MYSQL_LOGIN
globalm_hooks $hooks
globalm_action $action
string$loginLogin name like [a-z][a-z0-9]*
string$passPassword (max. 64 characters)
string$nomName of the account owner
string$prenomFirst name of the account owner
string$mailEmail address of the account owner, useful to get one's lost password
integer$canpass
string$typeAccount type for quotas
int$duration
string$notes
integer$force
string$create_dom
int$db_server_id
Returns
boolean Returns FALSE if an error occurs, TRUE if not.

Definition at line 578 of file m_admin.php.

References $cuid, $db, $err, $force, $hooks, $L_MYSQL_DATABASE, $L_MYSQL_LOGIN, $mem, $uid, _md5cr(), add_shared_domain(), checkmail(), enabled, getuserpath(), and renew_update().

578  {
579  global $err, $cuid, $mem, $L_MYSQL_DATABASE, $L_MYSQL_LOGIN, $hooks, $action;
580  $err->log("admin", "add_mem", $login . "/" . $mail);
581  if (!$this->enabled) {
582  $err->raise("admin", _("-- Only administrators can access this page! --"));
583  return false;
584  }
585  if (empty($db_server_id)) {
586  $err->raise("admin", _("Missing db_server field"));
587  return false;
588  }
589  if (($login == "") || ($pass == "")) {
590  $err->raise("admin", _("Please fill all mandatory fields"));
591  return false;
592  }
593  if (!$force) {
594  if ($mail == "") {
595  $err->raise("admin", _("Please fill all mandatory fields"));
596  return false;
597  }
598  //@todo remove cf functions.php
599  if (checkmail($mail) != 0) {
600  $err->raise("admin", _("Please enter a valid email address"));
601  return false;
602  }
603  }
604  $login = strtolower($login);
605  if (!preg_match("#^[a-z0-9]+$#", $login)) { //$
606  $err->raise("admin", _("Login can only contains characters a-z and 0-9"));
607  return false;
608  }
609  if (strlen($login) > 14) {
610  // Not an arbitrary value : MySQL user names can be up to 16 characters long
611  // If we want to allow people to create a few mysql_user (and we want to!)
612  // we have to limit the login lenght
613  $err->raise("admin", _("The login is too long (14 chars max)"));
614  return false;
615  }
616  // Some login are not allowed...
617  if ($login == $L_MYSQL_DATABASE || $login == $L_MYSQL_LOGIN || $login == "mysql" || $login == "root") {
618  $err->raise("admin", _("Login can only contains characters a-z, 0-9 and -"));
619  return false;
620  }
621  $pass = _md5cr($pass);
622  $db = new DB_System();
623  // Already exist?
624  $db->query("SELECT count(*) AS cnt FROM membres WHERE login= ?;", array($login));
625  $db->next_record();
626  if (!$db->f("cnt")) {
627  $db->query("SELECT max(m.uid)+1 as nextid FROM membres m");
628  if (!$db->next_record()) {
629  $uid = 2000;
630  } else {
631  $uid = $db->Record["nextid"];
632  if ($uid <= 2000) {
633  $uid = 2000;
634  }
635  }
636  $db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created,notes,db_server_id) VALUES (?, ?, ?, ?, ?, ?, ?, NOW(), ?, ?);", array($uid, $login, $pass, $mail, $cuid, $canpass, $type, $notes, $db_server_id));
637  $db->query("INSERT INTO local(uid,nom,prenom) VALUES(?, ?, ?);", array($uid, $nom, $prenom));
638  $this->renew_update($uid, $duration);
639  $action->create_dir(getuserpath("$login"));
640  $action->fix_user($uid);
641 
642  // Triggering hooks
643  $mem->su($uid);
644 
645  $hooks->invoke("alternc_add_member");
646  // New hook way
647  $hooks->invoke("hook_admin_add_member", array(), array('quota')); // First !!! The quota !!! Eitherway, we can't be sure to be able to create all
648  $hooks->invoke("hook_admin_add_member");
649  $mem->unsu();
650 
651  if (!empty($create_dom)) {
652  $this->add_shared_domain($uid, $create_dom);
653  }
654 
655  return $uid;
656  } else {
657  $err->raise("admin", _("This login already exists"));
658  return false;
659  }
660  }
$hooks
Definition: bootstrap.php:74
add_shared_domain($u, $domain_name)
When the admin want to delegate a subdomain to an account.
Definition: m_admin.php:515
$uid
global $L_MYSQL_DATABASE
Definition: bootstrap.php:22
global $db
Definition: bootstrap.php:22
_md5cr($pass, $salt="")
Hashe un mot de passe en clair en MD5 avec un salt al�atoire.
Definition: functions.php:513
global $L_MYSQL_LOGIN
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
getuserpath($user=null)
get the home of the user
Definition: functions.php:318
$cuid
Definition: bootstrap.php:43
renew_update($uid, $duration)
Update the duration information for an account.
Definition: m_admin.php:925
checkmail($mail)
Check an email address, use filter_var with emails, which works great ;)
Definition: functions.php:236
$admin enabled
Definition: newone.php:43
$mem
Definition: bootstrap.php:71
m_admin::add_shared_domain (   $u,
  $domain_name 
)

When the admin want to delegate a subdomain to an account.

Parameters
globalm_mysql $db
globalm_err $err
globalm_dom $dom
globalm_mem $mem
globalint $cuid
string$u
string$domain_name
Returns
boolean

Definition at line 515 of file m_admin.php.

References $dom, $err, $mem, and variable_get().

Referenced by add_mem().

515  {
516  global $err, $dom, $mem;
517  $err->log("admin", "add_shared_domain", $u . "/" . $domain_name);
518 
519  if (!$mem->checkright()) {
520  $err->raise("admin", _("-- Only administrators can do that! --"));
521  return false;
522  }
523 
524  // Check if this domain exist on this admin account
525  if ((!in_array($domain_name, $dom->enum_domains()))&&($domaine_name!=variable_get("hosting_tld"))) {
526  $err->raise("admin", _("You don't seem to be allowed to delegate this domain"));
527  $err->log("admin", "add_shared_domain", "domain not allowed");
528  return false;
529  }
530 
531  // Clean the domain_name
532  $domain_name = preg_replace("/^\.\.*/", "", $domain_name);
533 
534  $mem->su($u);
535  $dom->lock();
536  // option : 1=hébergement dns, 1=noerase, empeche de modifier, 1=force
537  // we do not allow DNS modification for hosting_tld
538  $dns=($domaine_name==variable_get("hosting_tld")) ? 0 : 1;
539  $dom->add_domain($mem->user['login'] . "." . $domain_name, $dns, 1, 1);
540  $dom->unlock();
541  $mem->unsu();
542  return true;
543  }
$err
Definition: bootstrap.php:72
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
Definition: variables.php:90
$dom
Definition: whois_test.php:10
$mem
Definition: bootstrap.php:71
m_admin::addtld (   $tld,
  $mode 
)

Add a TLD to the list of the authorized TLDs during the installation.

Note: If you check in the whois, be sure that m_domains knows how to name the whois of the specified domain!

Parameters
globalm_mysql $db
globalm_err $err
string$tldstring TLD we want to authorize
boolean$modeControls to make on this TLD.
Returns
boolean TRUE if the TLD has been successfully added. FALSE if not.

Definition at line 1307 of file m_admin.php.

References $db, $err, and $mode.

1307  {
1308  global $db, $err;
1309  if (!$tld) {
1310  $err->raise("admin", _("The TLD name is mandatory"));
1311  return false;
1312  }
1313  $tld = trim($tld);
1314 
1315  $db->query("SELECT tld FROM tld WHERE tld= ?;", array($tld));
1316  if ($db->next_record()) {
1317  $err->raise("admin", _("This TLD already exist"));
1318  return false;
1319  }
1320  if (substr($tld, 0, 1) == ".") {
1321  $tld = substr($tld, 1);
1322  }
1323  $mode = intval($mode);
1324  if ($mode == 0) {
1325  $mode = "0";
1326  }
1327  $db->query("INSERT INTO tld (tld,mode) VALUES (?,?);", array($tld, $mode));
1328  return true;
1329  }
$mode
Definition: adm_tldedit.php:42
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_admin::checkalldom ( )

Check all the domains for their NS MX and IPs.

Parameters
globalm_mysql $db
globalstring $L_NS1
globalstring $L_NS2
globalstring $L_MX
globalstring $L_PUBLIC_IP
Returns
int

Definition at line 1128 of file m_admin.php.

References $c, $d, $db, $dl, $errstr, $query, $t, and variable_get().

Referenced by dom_list().

1128  {
1129  global $db, $L_NS1, $L_NS2, $L_MX, $L_PUBLIC_IP;
1130  $checked = array();
1131 
1132  $query = "SELECT * FROM domaines ";
1133  $query_args = array();
1134  if($hosting_tld = variable_get("hosting_tld")){
1135  $query .= " WHERE domaine not like ?";
1136  array_push($query_args, "%.".$hosting_tld);
1137  }
1138  $query .= " ORDER BY domaine";
1139  $db->query($query, $query_args);
1140  $dl = array();
1141  while ($db->next_record()) {
1142  $dl[$db->Record["domaine"]] = $db->Record;
1143  }
1144 
1145  // won't search for MX and subdomains record if DNS is hosted here
1146  $lazycheck=1;
1147 
1148  sort($dl);
1149  foreach ($dl as $c) {
1150  // For each domain check its type:
1151  $errno = 0;
1152  $errstr = "";
1153  $dontexist = false;
1154  // Check the domain.
1155  if ($c["gesdns"] == 1) {
1156  // Check the NS pointing to us
1157  $out = array();
1158  exec("dig +short NS " . escapeshellarg($c["domaine"]), $out);
1159  if (count($out) == 0) {
1160  $dontexist = true;
1161  } else {
1162  if (!in_array($L_NS1 . ".", $out) || !in_array($L_NS2 . ".", $out)) {
1163  $errno = 1;
1164  $errstr.=sprintf(_("NS for this domain are not %s and %s BUT %s"),
1165  $L_NS1, $L_NS2, implode(",", $out)) . "\n";
1166  }
1167  }
1168  }
1169 
1170  if (!$dontexist&&(!$lazycheck||!$c["gesdns"])) {
1171  if ($c["gesmx"] == 1) {
1172  $out = array();
1173  exec("dig +short MX " . escapeshellarg($c["domaine"]), $out);
1174  $out2 = array();
1175  foreach ($out as $o) {
1176  list($t, $out2[]) = explode(" ", $o);
1177  }
1178  if (!in_array($L_MX . ".", $out2)) {
1179  $errno = 1;
1180  $errstr.=sprintf(_("MX is not %s BUT %s"), $L_MX, implode(",", $out2))."\n";
1181  }
1182  }
1183 
1184  // We list all subdomains and check they are pointing to us.
1185  $db->query("SELECT * FROM sub_domaines WHERE domaine=? ORDER BY sub;", array($c["domaine"]));
1186  while ($db->next_record()) {
1187  $d = $db->Record;
1188  if ($d["type"] == 'VHOST') {
1189  // Check the IP:
1190  $out = array();
1191  exec("dig +short A " . escapeshellarg($d["sub"] . (($d["sub"] != "") ? "." : "") . $c["domaine"]), $out);
1192  if (!is_array($out)) { // exec dig can fail
1193  $errno = 1;
1194  $errstr.=_("Fail to get the DNS information. Try again.")."\n";
1195  } else {
1196  if (!in_array($L_PUBLIC_IP, $out)) {
1197  $errstr.=sprintf(_("subdomain '%s' doesn't point to %s but to '%s'"), $d["sub"], $L_PUBLIC_IP, implode(",", $out))."\n" ;
1198  $errno = 1;
1199  }
1200  }
1201  }
1202  }
1203  }
1204  if ($dontexist) {
1205  $errno = 2;
1206  $errstr = _("Domain doesn't exist anymore !");
1207  }
1208  if ($errno == 0)
1209  $errstr = "OK";
1210  $checked[$c["domaine"]] = array("errno" => $errno, "errstr" => $errstr);
1211  }
1212  return $checked;
1213  }
global $db
Definition: bootstrap.php:22
$query
Definition: 3.0.0~3.php:43
$t
Definition: dom_editdns.php:58
$dl
Definition: dom_add.php:65
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
Definition: variables.php:90
$c
Definition: bootstrap.php:47
$errstr
Definition: change.php:62
$d
m_admin::checkcreator (   $uid)

Check if I am the creator of the member $uid.

Parameters
globaltype $err
globaltype $mem
globaltype $db
globaltype $cuid
int$uida unique integer identifying the account
Returns
boolean TRUE if I am the creator of that account. FALSE else.

Definition at line 489 of file m_admin.php.

References $cuid, $db, $err, and $uid.

489  {
490  global $err, $db, $cuid;
491  if ($cuid == 2000) {
492  return true;
493  }
494  $db->query("SELECT creator FROM membres WHERE uid= ?;", array($uid));
495  $db->next_record();
496  if ($db->Record["creator"] != $cuid) {
497  $err->raise("admin", _("-- Only administrators can access this page! --"));
498  return false;
499  }
500  return true;
501  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
m_admin::checkPolicy (   $policy,
  $login,
  $password 
)
Parameters
globalm_mysql $db
globalm_err $err
string$policyName of the policy to check for
string$loginThe login that will be set
string$passwordThe password we have to check
Returns
boolean TRUE if the password if OK for this login and this policy, FALSE if it is not.

Definition at line 1451 of file m_admin.php.

References $err, $i, $p, $password, and listPasswordPolicies().

1451  {
1452  global $err;
1453 
1454  if (empty($login)) {
1455  $err->raise("admin", _("Please enter a login"));
1456  return false;
1457  }
1458  if (empty($password)) {
1459  $err->raise("admin", _("Please enter a password"));
1460  return false;
1461  }
1462 
1463  $pol = $this->listPasswordPolicies();
1464  if (!$pol[$policy]) {
1465  $err->raise("admin", _("-- Program error -- The requested password policy does not exist!"));
1466  return false;
1467  }
1468  $pol = $pol[$policy];
1469  // Ok, now let's check it :
1470  $plen = strlen($password);
1471 
1472  if ($plen < $pol["minsize"]) {
1473  $err->raise("admin", _("The password length is too short according to the password policy"));
1474  return false;
1475  }
1476 
1477  if ($plen > $pol["maxsize"]) {
1478  $err->raise("admin", _("The password is too long according to the password policy"));
1479  return false;
1480  }
1481 
1482  if (!$pol["allowlogin"]) {
1483  // We do misc check on password versus login :
1484  $logins = preg_split("/[@_-]/", $login);
1485  $logins[] = $login;
1486  foreach ($logins as $l) {
1487  if (!$l) {
1488  continue;
1489  }
1490  if (strpos($password, $l) !== false || strpos($l, $password) !== false) {
1491  $err->raise("admin", _("The password policy prevents you to use your login name inside your password or the other way around"));
1492  return false;
1493  }
1494  }
1495  }
1496 
1497  if ($pol["classcount"] > 0) {
1498  $cls = array(0, 0, 0, 0, 0);
1499  for ($i = 0; $i < strlen($password); $i++) {
1500  $p = substr($password, $i, 1);
1501  if (strpos("abcdefghijklmnopqrstuvwxyz", $p) !== false) {
1502  $cls[0] = 1;
1503  } elseif (strpos("ABCDEFGHIJKLMNOPQRSTUVWXYZ", $p) !== false) {
1504  $cls[1] = 1;
1505  } elseif (strpos("0123456789", $p) !== false) {
1506  $cls[2] = 1;
1507  } elseif (strpos('!"#$%&\'()*+,-./:;<=>?@[\\]^_`', $p) !== false) {
1508  $cls[3] = 1;
1509  } else {
1510  $cls[4] = 1;
1511  }
1512  } // foreach
1513  $clc = array_sum($cls);
1514  if ($clc < $pol["classcount"]) {
1515  $err->raise("admin", _("Your password contains not enough different classes of character, between low-case, up-case, figures and special characters."));
1516  return false;
1517  }
1518  }
1519  return true; // congratulations !
1520  }
listPasswordPolicies()
List the password policies currently installed in the policy table.
Definition: m_admin.php:1378
$err
Definition: bootstrap.php:72
$p
Definition: bro_editor.php:50
$password
Definition: bootstrap.php:85
m_admin::del_mem (   $uid)

Deletes an account Deletes the specified account.

Prevents any manipulation of the account if the account $mid is not super-admin.

Parameters
globalm_err $err
globalm_quota $quota
globalarray $classes
globalint $cuid
globalm_mem $mem
globalm_dom $dom
globalm_hooks $hooks
globalm_action $action
int$uidThe uid number of the account
Returns
boolean Returns FALSE if an error occurs, TRUE if not.

Definition at line 853 of file m_admin.php.

References $db, $dom, $err, $hooks, $mem, $uid, enabled, and getuserpath().

853  {
854  global $err, $mem, $dom, $hooks, $action;
855  $err->log("admin", "del_mem", $uid);
856 
857  if (!$this->enabled) {
858  $err->raise("admin", _("-- Only administrators can access this page! --"));
859  return false;
860  }
861  $db = new DB_System();
862  $tt = $this->get($uid);
863 
864  $mem->su($uid);
865  // This script may take a long time on big accounts, let's give us some time ... Fixes 1132
866  @set_time_limit(0);
867  // WE MUST call m_dom before all others because of conflicts ...
868  $dom->hook_admin_del_member();
869 
870  # New way of deleting or backup delted user html folders using action class
871  $path = getuserpath($tt['login']);
872  $action->archive($path);
873 
874  $hooks->invoke("alternc_del_member");
875  $hooks->invoke("hook_admin_del_member");
876 
877  if (($db->query("DELETE FROM membres WHERE uid= ?;", array($uid))) &&
878  ($db->query("DELETE FROM local WHERE uid= ?;", array($uid)))) {
879  $mem->unsu();
880  // If this user was (one day) an administrator one, he may have a list of his own accounts. Let's associate those accounts to nobody as a creator.
881  $db->query("UPDATE membres SET creator=2000 WHERE creator= ?;", array($uid));
882  return true;
883  } else {
884  $err->raise("admin", _("Account not found"));
885  $mem->unsu();
886  return false;
887  }
888  }
$hooks
Definition: bootstrap.php:74
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
getuserpath($user=null)
get the home of the user
Definition: functions.php:318
$dom
Definition: whois_test.php:10
$admin enabled
Definition: newone.php:43
$mem
Definition: bootstrap.php:71
m_admin::deltld (   $tld)

Deletes the specified tld in the list of the authorized TLDs Note : This function does not delete the domains depending on this TLD.

Parameters
globalm_mysql $db
globalm_err $err
string$tldThe TLD you want to delete
Returns
boolean returns true if the TLD has been deleted, or false if an error occured.

Definition at line 1281 of file m_admin.php.

References $db, and $err.

1281  {
1282  global $db, $err;
1283  $db->query("SELECT tld FROM tld WHERE tld= ?;", array($tld));
1284  if (!$db->next_record()) {
1285  $err->raise("admin", _("This TLD does not exist"));
1286  return false;
1287  }
1288  $db->query("DELETE FROM tld WHERE tld= ?;", array($tld));
1289  return true;
1290  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_admin::dom_list (   $alsocheck = false,
  $forcecheck = false 
)

List the hosted domains on this server.

Return the list of hosted domains on this server, (an array of associative arrays)

Parameters
globalm_mysql $db
boolean$alsocheckReturns also errstr and errno telling the domains dig checks
boolean$forcecheckForce the check of dig domain even if a cache exists.
Returns
array $r[$i] / [domaine][member][noerase][gesdns][gesmx]

Definition at line 1084 of file m_admin.php.

References $c, $db, $forcecheck, $query, checkalldom(), and variable_get().

1084  {
1085  global $db;
1086  $cachefile = "/tmp/alternc_dig_check_cache";
1087  $cachetime = 3600; // The dns cache file can be up to 1H old
1088  if ($alsocheck) {
1089  if (!$forcecheck && file_exists($cachefile) && filemtime($cachefile) + $cachetime > time()) {
1090  $checked = unserialize(file_get_contents($cachefile));
1091  } else {
1092  // TODO : do the check here (cf checkdom.php) and store it in $checked
1093  $checked = $this->checkalldom();
1094  file_put_contents($cachefile, serialize($checked));
1095  }
1096  }
1097 
1098  $query = "SELECT m.uid,m.login,d.domaine,d.gesdns,d.gesmx,d.noerase FROM domaines d LEFT JOIN membres m ON m.uid=d.compte ";
1099  $query_args = array();
1100  if($hosting_tld = variable_get("hosting_tld")){
1101  $query .= " WHERE domaine not like ?";
1102  array_push($query_args, "%.".$hosting_tld);
1103  }
1104  $query .= " ORDER BY domaine;";
1105  $db->query($query, $query_args);
1106  $c = array();
1107  while ($db->next_record()) {
1108  $tmp = $db->Record;
1109  if ($alsocheck) {
1110  $tmp["errstr"] = $checked[$tmp["domaine"]]["errstr"];
1111  $tmp["errno"] = $checked[$tmp["domaine"]]["errno"];
1112  }
1113  $c[] = $tmp;
1114  }
1115  return $c;
1116  }
$forcecheck
Definition: adm_doms.php:54
global $db
Definition: bootstrap.php:22
$query
Definition: 3.0.0~3.php:43
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
Definition: variables.php:90
$c
Definition: bootstrap.php:47
checkalldom()
Check all the domains for their NS MX and IPs.
Definition: m_admin.php:1128
m_admin::dom_lock (   $domain)

Lock / Unlock a domain.

Lock (or unlock) a domain, so that the member will be (not be) able to delete it from its account

Parameters
globalm_mysql $db
globalm_err $err
string$domainDomain name to lock / unlock
Returns
boolean TRUE if the domain has been locked/unlocked or FALSE if it does not exist.

Definition at line 1226 of file m_admin.php.

References $db, $domain, and $err.

1226  {
1227  global $db, $err;
1228  $db->query("SELECT compte FROM domaines WHERE domaine= ?;", array($domain));
1229  if (!$db->next_record()) {
1230  $err->raise("dom", _("Domain '%s' not found."), $domain);
1231  return false;
1232  }
1233  $db->query("UPDATE domaines SET noerase=1-noerase WHERE domaine= ?;", array($domain));
1234  return true;
1235  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$domain
Definition: dom_import.php:40
m_admin::editPolicy (   $policy,
  $minsize,
  $maxsize,
  $classcount,
  $allowlogin 
)

Change a password policy for one kind of password.

Parameters
globalm_mysql $db
string$policyName of the policy to edit
int$minsizeMinimum Password size
int$maxsizeMaximum Password size
int$classcountHow many class of characters must this password have
boolean$allowloginDo we allow the password to be like the login ?
Returns
boolean if the policy has been edited, or FALSE if an error occured.

Definition at line 1423 of file m_admin.php.

References $db.

1423  {
1424  global $db;
1425  $minsize = intval($minsize);
1426  $maxsize = intval($maxsize);
1427  $classcount = intval($classcount);
1428  $allowlogin = intval($allowlogin);
1429 
1430  $db->query("SELECT * FROM policy WHERE name= ?;", array($policy));
1431  if (!$db->next_record()) {
1432  return false; // Policy not found
1433  }
1434  if ($minsize < 0 || $minsize > 64 || $maxsize < 0 || $maxsize > 64 || $maxsize < $minsize || $classcount < 0 || $classcount > 4) {
1435  return false; // Incorrect policy ...
1436  }
1437  $allowlogin = ($allowlogin) ? 1 : 0;
1438  $db->query("UPDATE policy SET minsize= ?, maxsize= ?, classcount= ?, allowlogin= ? WHERE name= ?;", array($minsize, $maxsize, $classcount, $allowlogin, $policy));
1439  return true;
1440  }
global $db
Definition: bootstrap.php:22
m_admin::edittld (   $tld,
  $mode 
)

Modify a TLD of the list of the authorized TLDs.

Parameters
globalm_mysql $db
globalm_err $err
string$tldTLD we want to modify
int$modeControls to make on this TLD.
Returns
boolean TRUE if the TLD has been successfully modified. FALSE if not.

Definition at line 1342 of file m_admin.php.

References $db, $err, and $mode.

1342  {
1343  global $db, $err;
1344  $db->query("SELECT tld FROM tld WHERE tld= ?;", array($tld));
1345  if (!$db->next_record()) {
1346  $err->raise("admin", _("This TLD does not exist"));
1347  return false;
1348  }
1349  $mode = intval($mode);
1350  if ($mode == 0) {
1351  $mode = "0";
1352  }
1353  $db->query("UPDATE tld SET mode= ? WHERE tld= ?;", array($mode, $tld));
1354  return true;
1355  }
$mode
Definition: adm_tldedit.php:42
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_admin::get (   $uid,
  $recheck = false 
)

Returns the known information about a hosted account.

Returns all what we know about an account (contents of the tables membres et local) Ckecks if the account is super-admin

Parameters
globaltype $err
globaltype $db
globalstring $lst_users_properties
int$uida unique integer identifying the account
boolean$recheck
Returns
array|boolean an associative array containing all the fields of the table membres and local of the corresponding account. Returns FALSE if an error occurs.

Definition at line 203 of file m_admin.php.

203  {
204  global $err, $db, $lst_users_properties;
205  // $err->log("admin","get",$uid);
206  if (!$this->enabled) {
207  $err->raise("admin", _("-- Only administrators can access this page! --"));
208  return false;
209  }
210 
211  if (!isset($lst_users_properties) || empty($lst_users_properties) || !is_array($lst_users_properties) || $recheck) {
212  $lst_users_properties = array();
213  $db->query("
214  SELECT
215  m.uid as muid,
216  l.*,
217  m.*,
218  parent.login as parentlogin,
219  dbs.name as db_server_name,
220  m.renewed + INTERVAL m.duration MONTH as expiry,
221  CASE
222  WHEN m.duration IS NULL THEN 0
223  WHEN m.renewed + INTERVAL m.duration MONTH <= NOW() THEN 3
224  WHEN m.renewed <= NOW() THEN 2
225  ELSE 1 END 'status'
226 
227  FROM membres as m
228  LEFT JOIN membres as parent ON (parent.uid = m.creator)
229  LEFT JOIN db_servers as dbs ON (m.db_server_id = dbs.id)
230  LEFT JOIN local as l ON (m.uid = l.uid) ;");
231  while ($db->next_record()) {
232  $lst_users_properties[$db->f('muid')] = $db->Record;
233  }
234  }
235 
236  if (!isset($lst_users_properties[$uid])) {
237  if (!$recheck) {
238  // don't exist, but is not a forced check. Do a forced check
239  return $this->get($uid, true);
240  }
241  $err->raise("admin", _("Account not found"));
242  return false;
243  }
244 
245  return $lst_users_properties[$uid];
246  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$admin enabled
Definition: newone.php:43
m_admin::get_creator (   $uid)

Returns the known information about a specific hosted account.

Similar to get_list() but for creators/resellers.

Parameters
globaltype $err
globaltype $db
int$uid
Returns
boolean

Definition at line 258 of file m_admin.php.

References $c, $db, $err, $key, $uid, $val, each(), and enabled.

Referenced by get_creator_list().

258  {
259  global $err, $db;
260  // $err->log("admin","get",$uid);
261  if (!$this->enabled) {
262  $err->raise("admin", _("-- Only administrators can access this page! --"));
263  return false;
264  }
265 
266  $db->query("SELECT m.*, parent.login as parentlogin FROM membres as m LEFT JOIN membres as parent ON (parent.uid = m.creator) WHERE m.uid= ?;", array($uid));
267 
268  if ($db->num_rows()) {
269  $db->next_record();
270  $c = $db->Record;
271  } else {
272  $err->raise("admin", _("Account not found"));
273  return false;
274  }
275 
276  $db->query("SELECT * FROM local WHERE uid= ?;", array($uid));
277  if ($db->num_rows()) {
278  $db->next_record();
279  reset($db->Record);
280  while (list($key, $val) = each($db->Record)) {
281  $c[$key] = $val;
282  }
283  }
284 
285  $db->query("SELECT count(*) as nbcreated FROM membres WHERE creator= ?;", array($uid));
286  if ($db->num_rows()) {
287  $db->next_record();
288  reset($db->Record);
289  while (list($key, $val) = each($db->Record)) {
290  $c[$key] = $val;
291  }
292  }
293 
294  return $c;
295  }
$val
Definition: tempovars.php:15
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
x each(["height","width"], function(e, n){x.cssHooks[n]={get:function(e, r, i){return r?0===e.offsetWidth &&Xt.test(x.css(e,"display"))?x.swap(e, Qt, function(){return sn(e, n, i)}):sn(e, n, i):t}, set:function(e, t, r){var i=r &&Rt(e);return on(e, t, r?an(e, n, r, x.support.boxSizing &&"border-box"===x.css(e,"boxSizing",!1, i), i):0)}}})
if(empty($_POST['key'])||empty($_POST['val'])) $key
Definition: tempovars.php:14
$c
Definition: bootstrap.php:47
$admin enabled
Definition: newone.php:43
m_admin::get_creator_list ( )

Returns an array with the known information about resellers (uid, login, number of accounts) Does not include account 2000 in the list.

May only be called by the admin account (2000) If there are no reseller accounts, returns an empty array.

Parameters
globaltype $err
globaltype $mem
globaltype $cuid
Returns
boolean

Definition at line 454 of file m_admin.php.

References $cuid, $db, $err, enabled, and get_creator().

454  {
455  global $err, $cuid;
456 
457  $creators = array();
458 
459  $err->log("admin", "get_reseller_list");
460  if (!$this->enabled || $cuid != 2000) {
461  $err->raise("admin", _("-- Only administrators can access this page! --"));
462  return false;
463  }
464 
465  $db = new DB_System();
466  $db->query("SELECT DISTINCT creator FROM membres WHERE creator <> 0 ORDER BY creator ASC;");
467  if ($db->num_rows()) {
468  while ($db->next_record()) {
469  $creators[] = $this->get_creator($db->f("creator"));
470  }
471  }
472  $creators2 = array();
473  foreach ($creators as $cc) {
474  $creators2[$cc['uid']] = $cc;
475  }
476  return $creators2;
477  }
get_creator($uid)
Returns the known information about a specific hosted account.
Definition: m_admin.php:258
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
$admin enabled
Definition: newone.php:43
m_admin::get_list (   $all = 0,
  $creator = 0,
  $pattern = FALSE,
  $pattern_type = FALSE 
)

:EM: those request should have been escaped Returns the list of the hosted accounts

Returns all what we know about ALL the accounts (contents of the tables membres et local) Check for super-admin accounts

Parameters
return
globaltype $err
globaltype $mem
globaltype $cuid
integer$all
integer$creator
string$pattern
string$pattern_type
Returns
boolean | array an associative array containing all the fields of the table membres and local of all the accounts. Returns FALSE if an error occurs.

Definition at line 331 of file m_admin.php.

References $c, $cuid, $db, $err, $mem, and enabled.

331  {
332  global $err, $mem, $cuid;
333  $err->log("admin", "get_list");
334  if (!$this->enabled) {
335  $err->raise("admin", _("-- Only administrators can access this page! --"));
336  return false;
337  }
338  $db = new DB_System();
339 
340 
341  if ($pattern) {
342 
343  if ($pattern_type === 'domaine') {
344 
345  $request = 'SELECT compte AS uid FROM domaines WHERE 1';
346 
347  if ($pattern && preg_match('/[.a-zA-Z0-9]+/', $pattern)) {
348  $request .= sprintf(' AND domaine LIKE "%%%s%%"', $pattern);
349  }
350  if ($creator) {
351  $request .= sprintf(' AND compte in (select uid from membres where creator = "%s" ) ', $creator);
352  }
353  if ($mem->user['uid'] != 2000 && !$all) {
354  $request .= sprintf(' AND compte in (select uid from membres where creator = "%s") ', $cuid);
355  }
356 
357  $request .= ' GROUP BY uid';
358  } elseif ($pattern_type === 'login') {
359 
360  $request = 'SELECT uid FROM membres WHERE 1';
361 
362  if ($pattern && preg_match('/[a-zA-Z0-9]+/', $pattern)) {
363  $request .= sprintf(' AND login LIKE "%%%s%%"', $pattern);
364  }
365  if ($creator) {
366  $request .= sprintf(' AND creator = "%s"', $creator);
367  }
368  if ($mem->user['uid'] != 2000 && !$all) {
369  $request .= sprintf(' AND creator = "%s"', $cuid);
370  }
371  $request .= ' ORDER BY login;';
372  } else {
373  $err->raise("admin", _("Invalid pattern type provided. Are you even performing a legitimate action?"));
374  return FALSE;
375  }
376  } else {
377  if ($creator) {
378  // Limit listing to a specific reseller
379  $request = "SELECT uid FROM membres WHERE creator='" . $creator . "' ORDER BY login;";
380  } elseif ($mem->user['uid'] == 2000 || $all) {
381  $request = "SELECT uid FROM membres ORDER BY login;";
382  } else {
383  $request = "SELECT uid FROM membres WHERE creator='" . $cuid . "' ORDER BY login;";
384  }
385  }
386 
387  $db->query($request);
388 
389  if ($db->num_rows()) {
390  $c = array();
391  while ($db->next_record()) {
392  $c[$db->f("uid")] = $this->get($db->f("uid"));
393  }
394  return $c;
395  } else {
396  return false;
397  }
398  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
$c
Definition: bootstrap.php:47
$admin enabled
Definition: newone.php:43
$mem
Definition: bootstrap.php:71
m_admin::get_login_by_uid (   $uid)

return the name of an alternc account

Parameters
globaltype $db
type$uid
Returns
null if missing

Definition at line 178 of file m_admin.php.

178  {
179  global $db;
180  $db->query("SELECT login FROM membres WHERE uid= ?;", array($uid));
181  if (!$db->next_record()) {
182  return null;
183  }
184  return $db->f('login');
185  }
$uid
global $db
Definition: bootstrap.php:22
PR null
Definition: lang-css.js:1
m_admin::get_uid_by_login (   $login)

return the uid of an alternc account

Parameters
globaltype $db
type$login
Returns
null

Definition at line 162 of file m_admin.php.

162  {
163  global $db;
164  $db->query("SELECT uid FROM membres WHERE login= ?;", array($login));
165  if (!$db->next_record()) {
166  return null;
167  }
168  return $db->f('uid');
169  }
global $db
Definition: bootstrap.php:22
PR null
Definition: lang-css.js:1
m_admin::getadmin ( )

Get the login name of the main administrator account.

Parameters
globalm_mysql $db
Returns
string the login name of admin, like 'root' for older alterncs

Definition at line 1363 of file m_admin.php.

References $db.

1363  {
1364  global $db;
1365  $db->query("SELECT login FROM membres WHERE uid = '2000';");
1366  $db->next_record();
1367  return $db->f("login");
1368  }
global $db
Definition: bootstrap.php:22
m_admin::gettld (   $tld)

Add a new TLD to the list of the authorized TLDs.

Parameters
globalm_mysql $db
globalm_err $err
string$tldtop-level domain to add (org, com...)
Returns
boolean TRUE if the tld has been successfully added, FALSE if not.

Definition at line 1245 of file m_admin.php.

References $db, and $err.

1245  {
1246  global $db, $err;
1247  $db->query("SELECT mode FROM tld WHERE tld= ?;", array($tld));
1248  if (!$db->next_record()) {
1249  $err->raise("admin", _("This TLD does not exist"));
1250  return false;
1251  }
1252  return $db->Record["mode"];
1253  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_admin::hook_admin_add_member ( )

AlternC's standard function called when a user is created This sends an email if configured through the interface.

Parameters
globalm_err $err
globalint $cuid
globalstring $L_FQDN
globalstring $L_HOSTING
Returns
boolean

Definition at line 672 of file m_admin.php.

References $cuid, $db, $err, cuid, on(), and variable_get().

672  {
673  global $err, $cuid, $L_FQDN, $L_HOSTING;
674  $dest = variable_get('new_email', '0', 'An email will be sent to this address when new accounts are created if set.', array('desc' => 'Enabled', 'type' => 'boolean'));
675  if (!$dest) {
676  return false;
677  }
678  $db = new DB_System();
679  if (!$db->query("SELECT m.*, parent.login as parentlogin FROM membres m LEFT JOIN membres parent ON parent.uid=m.creator WHERE m.uid= ?", array($cuid))) {
680  $err->raise("admin", sprintf(_("query failed: %s "), $db->Error));
681  return false;
682  }
683  if ($db->next_record()) {
684  // TODO: put that string into gettext !
685  $mail = <<<EOF
686 A new AlternC account was created on %fqdn by %creator.
687 
688 Account details
689 ---------------
690 
691 login: %login (%uid)
692 email: %mail
693 createor: %creator (%cuid)
694 can change password: %canpass
695 type: %type
696 notes: %notes
697 EOF;
698  $mail = strtr($mail, array('%fqdn' => $L_FQDN,
699  '%creator' => $db->Record['parentlogin'],
700  '%uid' => $db->Record['uid'],
701  '%login' => $db->Record['login'],
702  '%mail' => $db->Record['mail'],
703  '%cuid' => $db->Record['creator'],
704  '%canpass' => $db->Record['canpass'],
705  '%type' => $db->Record['type'],
706  '%notes' => $db->Record['notes']));
707  $subject = sprintf(_("New account %s from %s on %s"), $db->Record['login'], $db->Record['parentlogin'], $L_HOSTING);
708  if (mail($dest, $subject, $mail, "From: postmaster@$L_FQDN")) {
709  //sprintf(_("Email successfully sent to %s"), $dest);
710  return true;
711  } else {
712  $err->raise("admin", sprintf(_("Cannot send email to %s"), $dest));
713  return false;
714  }
715  } else {
716  $err->raise("admin", sprintf(_("Query failed: %s"), $db->Error));
717  return false;
718  }
719  }
if(preg_match("#^/api/auth/( if[^/\?]*)[/\?]?#", $_SERVER["REQUEST_URI"], $mat)) if ($_SERVER["REQUEST_URI"]=="/api/post")(preg_match("#^/api/rest/([^/]*)/([^/\?]*)[/\?]?#", $_SERVER["REQUEST_URI"], $mat))
Main code: either we are authenticating or calling one of the APIs or asking for some documentation...
Definition: index.php:176
function getComputedStyle(Rt=function(t){return e.getComputedStyle(t, null)}, Wt=function(e, n, r){var i, o, a, s=r||Rt(e), l=s?s.getPropertyValue(n)||s[n]:t, u=e.style;return s &&(""!==l||x.contains(e.ownerDocument, e)||(l=x.style(e, n)), Yt.test(l)&&Ut.test(n)&&(i=u.width, o=u.minWidth, a=u.maxWidth, u.minWidth=u.maxWidth=u.width=l, l=s.width, u.width=i, u.minWidth=o, u.maxWidth=a)), l}) on(e, t, n)
function s
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
Definition: variables.php:90
print cuid
Definition: mail_add.php:100
m_admin::hook_menu ( )
Parameters
globaltype $mem
globaltype $cuid
globaltype $debug_alternc
globaltype $L_INOTIFY_UPDATE_DOMAIN
Returns
boolean|string

Definition at line 80 of file m_admin.php.

References $cuid, and $mem.

80  {
81  global $mem, $cuid, $debug_alternc, $L_INOTIFY_UPDATE_DOMAIN;
82  if (!$mem->checkRight()) {
83  return false;
84  }
85  $obj = array(
86  'title' => _("Administration"),
87  'ico' => 'images/admin.png',
88  'link' => 'toggle',
89  'class' => 'adminmenu',
90  'pos' => 10,
91  'links' =>
92  array(
93  array(
94  'txt' => _("Manage AlternC accounts"),
95  'url' => 'adm_list.php',
96  'class' => 'adminmenu'
97  ),
98  array(
99  'txt' => _("User Quotas"),
100  'url' => 'quotas_users.php?mode=4',
101  'class' => 'adminmenu'
102  ),
103  )
104  );
105 
106  if ($cuid == 2000) {
107  $obj['links'][] = array(
108  'txt' => _("Admin Control Panel"),
109  'url' => 'adm_panel.php',
110  'class' => 'adminmenu'
111  );
112  $obj['links'][] = array(
113  'txt' => _("PhpMyAdmin"),
114  'url' => '/alternc-sql/',
115  'class' => 'adminmenu',
116  'target' => '_blank',
117  );
118  $obj['links'][] = array(
119  'txt' => ($debug_alternc->status) ? _("Switch debug Off") : _("Switch debug On"),
120  'url' => "alternc_debugme.php?enable=" . ($debug_alternc->status ? "0" : "1"),
121  'class' => 'adminmenu'
122  );
123  if (empty($L_INOTIFY_UPDATE_DOMAIN) || file_exists("$L_INOTIFY_UPDATE_DOMAIN")) {
124  $obj['links'][] = array(
125  'txt' => _("Applying..."),
126  'url' => 'javascript:alert(\'' . _("Domain changes are already applying") . '\');',
127  'class' => 'adminmenu',
128  );
129  } else {
130  $obj['links'][] = array(
131  'txt' => _("Apply changes"),
132  'url' => 'adm_update_domains.php',
133  'class' => 'adminmenu',
134  'onclick' => 'return confirm("' . addslashes(_("Server configuration changes are applied every 5 minutes. Do you want to do it right now?")) . '");',
135  );
136  } // L_INOTIFY_UPDATE_DOMAIN
137  } // cuid == 2000
138 
139 
140  return $obj;
141  }
$cuid
Definition: bootstrap.php:43
$mem
Definition: bootstrap.php:71
m_admin::hook_upnp_list ( )

hook function called by AlternC-upnp to know which open tcp or udp ports this class requires or suggests

private

Returns
array a key => value list of port protocol name mandatory values

Definition at line 1529 of file m_admin.php.

1529  {
1530  return array(
1531  "http" => array("port" => 80, "protocol" => "tcp", "mandatory" => 1),
1532  "https" => array("port" => 443, "protocol" => "tcp", "mandatory" => 0),
1533  "ssh" => array("port" => 22, "protocol" => "tcp", "mandatory" => 0),
1534  );
1535  }
m_admin::listPasswordPolicies ( )

List the password policies currently installed in the policy table.

Parameters
globalm_mysql $db
globalarray $classes
globalm_hooks $hooks
Returns
array an indexed array of associative array from the MySQL "policy" table

Definition at line 1378 of file m_admin.php.

References $db, and $hooks.

Referenced by checkPolicy().

1378  {
1379  global $db, $hooks;
1380  $tmp1 = array();
1381  $tmp2 = array();
1382  $policies = array();
1383  $db->query("SELECT * FROM policy;");
1384  while ($db->next_record()) {
1385  $tmp1[$db->Record["name"]] = $db->Record;
1386  }
1387  $tmp3 = $hooks->invoke("alternc_password_policy");
1388  foreach ($tmp3 as $v) {
1389  foreach ($v as $l => $m) {
1390  $tmp2[$l] = $m;
1391  }
1392  }
1393  foreach ($tmp2 as $k => $v) {
1394  if (!isset($tmp1[$k])) {
1395  // Default policy :
1396  $db->query("INSERT INTO policy SET name= ?, minsize=0, maxsize=64, classcount=0, allowlogin=0;", array($k));
1397  $tmp1[$k] = array(
1398  "minsize" => 0, "maxsize" => 64, "classcount" => 0, "allowlogin" => 0
1399  );
1400  }
1401  $policies[$k] = $tmp1[$k];
1402  $policies[$k]["description"] = _($v);
1403  unset($tmp1[$k]);
1404  }
1405  foreach ($tmp1 as $k => $v) {
1406  // Delete disabled modules :
1407  $db->query("DELETE FROM policy WHERE name= ?;", array($k));
1408  }
1409  return $policies;
1410  }
$hooks
Definition: bootstrap.php:74
global $db
Definition: bootstrap.php:22
m_admin::listtld ( )

List of the authorized TLDs Returns the list of the authorized TLDs and also the way they are authorized.

A TLD is the last members (or the last two) of a domain. For example, "com", "org" etc... AlternC keeps a table containing the list of the TLDs authorized to be installed on the server with the instructions to validate the installation of a domain for each TLD (if necessary).

Parameters
globalm_mysql $db
Returns
array An associative array like $r["tld"], $r["mode"] where tld is the tld and mode is the authorized mode.

Definition at line 1064 of file m_admin.php.

References $c, and $db.

1064  {
1065  global $db;
1066  $db->query("SELECT tld,mode FROM tld ORDER BY tld;");
1067  $c = array();
1068  while ($db->next_record()) {
1069  $c[] = $db->Record;
1070  }
1071  return $c;
1072  }
global $db
Definition: bootstrap.php:22
$c
Definition: bootstrap.php:47
m_admin::lock_mem (   $uid)

Lock an account.

Lock an account and prevent the user to access its account.

Parameters
globalm_err $err
globalm_mysql $db
int$uidThe uid number of the account
Returns
boolean Returns FALSE if an error occurs, TRUE if not.

Definition at line 793 of file m_admin.php.

References $db, $err, $uid, and enabled.

793  {
794  global $err, $db;
795  $err->log("admin", "lock_mem", $uid);
796  if (!$this->enabled) {
797  $err->raise("admin", _("-- Only administrators can access this page! --"));
798  return false;
799  }
800  $db = new DB_System();
801  if ($db->query("UPDATE membres SET enabled='0' WHERE uid= ?;", array($uid))) {
802  return true;
803  } else {
804  $err->raise("admin", _("Account not found"));
805  return false;
806  }
807  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$admin enabled
Definition: newone.php:43
m_admin::m_admin ( )

Constructor.

Parameters
globaltype $db
globaltype $cuid

Definition at line 55 of file m_admin.php.

References $cuid, $db, enabled, and variable_get().

55  {
56  global $db, $cuid;
57  $db->query("SELECT su FROM membres WHERE uid=?;", array($cuid));
58  $db->next_record();
59  $this->enabled = $db->f("su");
60 
61  $this->tldmode = array(
62  0 => _("This TLD is forbidden"),
63  1 => _("primary DNS is checked in WHOIS db"),
64  2 => _("primary & secondary DNS are checked in WHOIS db"),
65  3 => _("Domain must exist, but don't do any DNS check"),
66  4 => _("Domain can be installed, no check at all"),
67  5 => _("Domain can be installed, force NO DNS hosting"),
68  );
69  $this->archive = variable_get('archive_del_data', '', 'If folder specified html folder of deleted user is archived, else it is deleted. ');
70  }
global $db
Definition: bootstrap.php:22
$cuid
Definition: bootstrap.php:43
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
Definition: variables.php:90
$admin enabled
Definition: newone.php:43
m_admin::mailallmembers (   $subject,
  $message,
  $from 
)

Send an email to all AlternC's accounts.

Parameters
globaltype $err
globaltype $mem
globaltype $cuid
globaltype $db
string$subjectSubject of the email to send
string$messageMessage to send
string$fromExpeditor of that email
Returns
boolean

Definition at line 412 of file m_admin.php.

References $db, $err, checkmail(), enabled, and null.

412  {
413  global $err, $db;
414  $err->log("admin", "mailallmembers");
415  if (!$this->enabled) {
416  $err->raise("admin", _("-- Only administrators can access this page! --"));
417  return false;
418  }
419  $subject = trim($subject);
420  $message = trim($message);
421  $from = trim($from);
422 
423  if (empty($subject) || empty($message) || empty($from)) {
424  $err->raise("admin", _("Subject, message and sender are mandatory"));
425  return false;
426  }
427  //@todo remove cf functions.php
428  if (checkmail($from) != 0) {
429  $err->raise("admin", _("Sender is syntaxically incorrect"));
430  return false;
431  }
432 
433  @set_time_limit(1200);
434  $db->query("SELECT DISTINCT mail FROM membres WHERE mail!='';");
435  while ($db->next_record()) {
436  // Can't do BCC due to postfix limitation
437  // FIXME: use phpmailer, far better for mass-mailing than sendmail (reply-to issue among others)
438  mail($db->f('mail'), $subject, $message, null, "-f$from");
439  }
440  return true;
441  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
PR null
Definition: lang-css.js:1
checkmail($mail)
Check an email address, use filter_var with emails, which works great ;)
Definition: functions.php:236
$admin enabled
Definition: newone.php:43
m_admin::normal2su (   $uid)

Turns a common account into a super-admin account.

Parameters
globalm_err $err
globalm_mysql $db
int$uidThe uid number of the account
Returns
boolean

Definition at line 1013 of file m_admin.php.

References $db, $err, and $uid.

1013  {
1014  global $err, $db;
1015  $db->query("SELECT su FROM membres WHERE uid= ?;", array($uid));
1016  if (!$db->next_record()) {
1017  $err->raise("admin", _("Account not found"));
1018  return false;
1019  }
1020  if ($db->Record["su"] != 0) {
1021  $err->raise("admin", _("This account is ALREADY an administrator account"));
1022  return false;
1023  }
1024  $db->query("UPDATE membres SET su=1 WHERE uid= ?;", array($uid));
1025  return true;
1026  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_admin::onesu ( )
Parameters
globaltype $db
Returns
boolean TRUE if there is only one admin account (allow the program to prevent the destruction of the last admin account)

Definition at line 303 of file m_admin.php.

References $db.

303  {
304  global $db;
305  $db->query("SELECT COUNT(*) AS cnt FROM membres WHERE su=1");
306  $db->next_record();
307  return ($db->f("cnt") == 1);
308  }
global $db
Definition: bootstrap.php:22
m_admin::renew_get_expiring_accounts ( )

Get the expired/about to expire accounts.

Parameters
globalm_mysql $db
Returns
array The recordset of the corresponding accounts

Definition at line 985 of file m_admin.php.

References $db, and $res.

985  {
986  global $db;
987 
988  if (!$db->query("SELECT *, m.renewed + INTERVAL duration MONTH 'expiry'," .
989  " CASE WHEN m.duration IS NULL THEN 0" .
990  " WHEN m.renewed + INTERVAL m.duration MONTH <= NOW() THEN 3" .
991  " WHEN m.renewed <= NOW() THEN 2" .
992  " ELSE 1 END 'status' FROM membres m, local l" .
993  " WHERE m.uid = l.uid" .
994  " HAVING status=2 or status=3 ORDER BY status DESC, expiry;")) {
995  return false;
996  } else {
997  $res = array();
998  while ($db->next_record()) {
999  $res[] = $db->Record;
1000  }
1001  return $res;
1002  }
1003  }
global $db
Definition: bootstrap.php:22
$res
Definition: index.php:127
m_admin::renew_get_expiry (   $uid)

Get the expiry date for an account.

Parameters
int$uidThe uid number of the account
Returns
string The expiry date, a string as printed by MySQL

Definition at line 949 of file m_admin.php.

References $uid.

949  {
950  $jj = $this->get($uid);
951  if (isset($jj) && isset($jj['expiry']) && !empty($jj['expiry'])) {
952  return $jj['expiry'];
953  }
954  return '';
955  }
$uid
m_admin::renew_get_status (   $uid)

Get the expiry status for an account.

Parameters
int$uidThe uid number of the account
Returns
integer The expiry status: 0: account does not expire 1: expires in more than duration, 2: expires within the duration 3: has expired past the duration

Definition at line 969 of file m_admin.php.

References $uid.

969  {
970  $jj = $this->get($uid);
971 
972  if (isset($jj) && isset($jj['status']) && !empty($jj['status'])) {
973  return $jj['status'];
974  }
975 
976  return 0;
977  }
$uid
m_admin::renew_mem (   $uid,
  $periods = 1 
)

Renew an account.

Renew an account for its duration

Parameters
globalm_err $err
globalm_mysql $db
int$uidThe uid number of the account
int$periodsThe new duration, in months, of the account
Returns
boolean Returns FALSE if an error occurs, TRUE if not.

Definition at line 901 of file m_admin.php.

References $db, $err, and $uid.

901  {
902  global $err, $db;
903 
904  $periods = intval($periods);
905  if ($periods == 0) {
906  return false;
907  }
908  if ($db->query("UPDATE membres SET renewed = renewed + INTERVAL (duration * ?) MONTH WHERE uid= ?;", array($periods, $uid))) {
909  return true;
910  } else {
911  $err->raise("admin", _("Account not found"));
912  return false;
913  }
914  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_admin::renew_update (   $uid,
  $duration 
)

Update the duration information for an account.

Parameters
globalm_err $err
globalm_mysql $db
int$uidThe uid number of the account
int$durationThe new duration, in months, of the account
Returns
boolean Returns FALSE if an error occurs, TRUE if not.

Definition at line 925 of file m_admin.php.

References $db, $err, and $uid.

Referenced by add_mem(), and update_mem().

925  {
926  global $err, $db;
927 
928  if ($duration == 0) {
929  if ($db->query("UPDATE membres SET duration = NULL, renewed = NULL WHERE uid= ?;", array($uid))) {
930  return true;
931  }
932  } else {
933  if ($db->query("UPDATE membres SET duration = ? WHERE uid= ?", array($duration, $uid)) &&
934  $db->query("UPDATE membres SET renewed = NOW() WHERE uid= ? and renewed is null;", array($uid))) {
935  return true;
936  }
937  }
938 
939  $err->raise("admin", _("Account not found"));
940  return false;
941  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_admin::selecttldmode (   $current = false)

Prints the list of the actually authorized TLDs.

Parameters
boolean$currentValue to select in the list

Definition at line 1260 of file m_admin.php.

References $i.

1260  {
1261  for ($i = 0; $i < count($this->tldmode); $i++) {
1262  echo "<option value=\"$i\"";
1263  if ($current == $i) {
1264  echo " selected=\"selected\"";
1265  }
1266  echo ">" . _($this->tldmode[$i]) . "</option>\n";
1267  }
1268  }
m_admin::stop_if_jobs_locked ( )

Definition at line 146 of file m_admin.php.

146  {
147  if (file_exists(ALTERNC_LOCK_JOBS)) {
148  echo "There is a file " . ALTERNC_LOCK_JOBS . "\n";
149  echo "So no jobs are allowed\n";
150  echo "Did you launch alternc.install ?\n";
151  die();
152  }
153  }
const ALTERNC_LOCK_JOBS
Definition: bootstrap.php:16
m_admin::su2normal (   $uid)

Turns a super-admin account into a common account.

Parameters
globalm_err $err
globalm_mysql $db
int$uidThe uid number of the account
Returns
boolean Returns FALSE if an error occurs, TRUE if not.

Definition at line 1036 of file m_admin.php.

References $db, $err, and $uid.

1036  {
1037  global $err, $db;
1038  $db->query("SELECT su FROM membres WHERE uid= ?;", array($uid));
1039  if (!$db->next_record()) {
1040  $err->raise("admin", _("Account not found"));
1041  return false;
1042  }
1043  if ($db->Record["su"] != 1) {
1044  $err->raise("admin", _("This account is NOT an administrator account!"));
1045  return false;
1046  }
1047  $db->query("UPDATE membres SET su=0 WHERE uid= ?;", array($uid));
1048  return true;
1049  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_admin::unlock_mem (   $uid)

UnLock an account.

UnLock an account and prevent the user to access its account.

Parameters
globalm_err $err
globalm_mysql $db
int$uidThe uid number of the account
Returns
boolean Returns FALSE if an error occurs, TRUE if not.

Definition at line 820 of file m_admin.php.

References $db, $err, $uid, and enabled.

820  {
821  global $err, $db;
822  $err->log("admin", "unlock_mem", $uid);
823  if (!$this->enabled) {
824  $err->raise("admin", _("-- Only administrators can access this page! --"));
825  return false;
826  }
827  $db = new DB_System();
828  if ($db->query("UPDATE membres SET enabled='1' WHERE uid= ?;", array($uid))) {
829  return true;
830  } else {
831  $err->raise("admin", _("Account not found"));
832  return false;
833  }
834  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$admin enabled
Definition: newone.php:43
m_admin::update_mem (   $uid,
  $mail,
  $nom,
  $prenom,
  $pass,
  $enabled,
  $canpass,
  $type = 'default',
  $duration = 0,
  $notes = "",
  $reset_quotas = false 
)

Edit an account.

Change an account (in the tables membres and local). Prevents any manipulation of the account if the account $mid is not super-admin.

Parameters
globalm_err $err
globalm_mysql $db
globalint $cuid
globalm_quota $quota
int$uidThe uid number of the account we want to modify
string$mailNew email address of the account owner
string$nomNew name of the account owner
string$prenomNew first name of the account owner
string$passNew password (max. 64 characters)
string$enabled(value: 0 or 1) activates or desactivates the
boolean$canpass
int$typeNew type of account
int$duration
string$notes
boolean$reset_quotas
Returns
boolean Returns FALSE if an error occurs, TRUE if not

Definition at line 745 of file m_admin.php.

References $db, $err, $uid, _md5cr(), enabled, and renew_update().

745  {
746  global $err, $db, $quota;
747 
748  $err->log("admin", "update_mem", $uid);
749 
750  if (!$this->enabled) {
751  $err->raise("admin", _("-- Only administrators can access this page! --"));
752  return false;
753  }
754  $db = new DB_System();
755 
756  if ($pass) {
757  $pass = _md5cr($pass);
758  $second_query = "UPDATE membres SET mail= ?, canpass= ?, enabled= ?, `type`= ?, notes= ? , pass = ? WHERE uid= ?;";
759  $second_query_args = array($mail, $canpass, $enabled, $type, $notes, $pass, $uid);
760  } else {
761  $second_query = "UPDATE membres SET mail= ?, canpass= ?, enabled= ?, `type`= ?, notes= ? WHERE uid= ?;";
762  $second_query_args = array($mail, $canpass, $enabled, $type, $notes, $uid);
763  }
764 
765  $old_mem = $this->get($uid);
766 
767  if(
768  ($db->query("UPDATE local SET nom= ?, prenom= ? WHERE uid=?;", array($nom, $prenom, $uid))) &&
769  ($db->query($second_query, $second_query_args))
770  ){
771  if ($reset_quotas == "on" || $type != $old_mem['type']) {
772  $quota->addquotas();
773  $quota->synchronise_user_profile();
774  }
775  $this->renew_update($uid, $duration);
776  return true;
777  } else {
778  $err->raise("admin", _("Account not found"));
779  return false;
780  }
781  }
$uid
global $db
Definition: bootstrap.php:22
_md5cr($pass, $salt="")
Hashe un mot de passe en clair en MD5 avec un salt al�atoire.
Definition: functions.php:513
$err
Definition: bootstrap.php:72
renew_update($uid, $duration)
Update the duration information for an account.
Definition: m_admin.php:925
$admin enabled
Definition: newone.php:43
$enabled
$enabled tells if the logged user is super-admin or not
Definition: m_admin.php:37

Member Data Documentation

m_admin::$archive = ''

Definition at line 47 of file m_admin.php.

m_admin::$enabled = 0

$enabled tells if the logged user is super-admin or not

Definition at line 37 of file m_admin.php.

m_admin::$tldmode = array()

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.

Definition at line 46 of file m_admin.php.


The documentation for this class was generated from the following file: