52 $db->query(
"SELECT su FROM membres WHERE uid=?;", array(
$cuid));
56 $this->tldmode = array(
57 0 => _(
"This TLD is forbidden"),
58 1 => _(
"primary DNS is checked in WHOIS db"),
59 2 => _(
"primary & secondary DNS are checked in WHOIS db"),
60 3 => _(
"Domain must exist, but don't do any DNS check"),
61 4 => _(
"Domain can be installed, no check at all"),
62 5 => _(
"Domain can be installed, force NO DNS hosting"),
64 $this->archive =
variable_get(
'archive_del_data',
'',
'If folder specified html folder of deleted user is archived, else it is deleted. ');
77 global
$mem,
$cuid, $debug_alternc, $L_INOTIFY_UPDATE_DOMAIN;
78 if (!
$mem->checkRight()) {
82 'title' => _(
"Administration"),
84 'class' =>
'adminmenu',
89 'txt' => _(
"Manage AlternC accounts"),
90 'url' =>
'adm_list.php',
91 'class' =>
'adminmenu'
94 'txt' => _(
"User Quotas"),
95 'url' =>
'quotas_users.php?mode=4',
96 'class' =>
'adminmenu'
102 $obj[
'links'][] = array(
103 'txt' => _(
"Admin Control Panel"),
104 'url' =>
'adm_panel.php',
105 'class' =>
'adminmenu'
107 $obj[
'links'][] = array(
108 'txt' => _(
"PhpMyAdmin"),
109 'url' =>
'sql_pma_sso.php',
110 'class' =>
'adminmenu',
111 'target' =>
'_blank',
113 $obj[
'links'][] = array(
114 'txt' => ($debug_alternc->status) ? _(
"Switch debug Off") : _(
"Switch debug On"),
115 'url' =>
"alternc_debugme.php?enable=" . ($debug_alternc->status ?
"0" :
"1"),
116 'class' =>
'adminmenu'
118 if (empty($L_INOTIFY_UPDATE_DOMAIN) || file_exists(
"$L_INOTIFY_UPDATE_DOMAIN")) {
119 $obj[
'links'][] = array(
120 'txt' => _(
"Applying..."),
121 'url' =>
'javascript:alert(\'' . _(
"Domain changes are already applying") .
'\');
',
122 'class' => 'adminmenu
',
125 $obj['links
'][] = array(
126 'txt
' => _("Apply changes"),
127 'url
' => 'adm_update_domains.php
',
128 'class' => 'adminmenu
',
129 'onclick
' => 'return confirm(
"' . addslashes(_("Server configuration changes are applied every 5 minutes. Do you want to
do it right now?
")) . '");
',
131 } // L_INOTIFY_UPDATE_DOMAIN
144 function alternc_password_policy() {
145 return array("adm" => "Administration section");
152 function stop_if_jobs_locked() {
153 if (file_exists(ALTERNC_LOCK_JOBS)) {
154 echo "There is a file " . ALTERNC_LOCK_JOBS . "\n";
155 echo "So no jobs are allowed\n";
156 echo "Did you launch alternc.install ?\n";
169 function get_uid_by_login($login) {
171 $db->query("SELECT uid FROM membres WHERE login= ?;", array($login));
172 if (!$db->next_record()) {
175 return $db->f('uid
');
186 function get_login_by_uid($uid) {
188 $db->query("SELECT login FROM membres WHERE uid= ?;", array($uid));
189 if (!$db->next_record()) {
192 return $db->f('login
');
212 function get($uid, $recheck = false) {
213 global $msg, $db, $lst_users_properties;
214 $msg->debug("admin","get",$uid);
215 if (!$this->enabled) {
216 $msg->raise("ERROR", "admin", _("-- Only administrators can access this page! --"));
220 if (!isset($lst_users_properties) || empty($lst_users_properties) || !is_array($lst_users_properties) || $recheck) {
221 $lst_users_properties = array();
227 parent.login as parentlogin,
228 dbs.name as db_server_name,
229 m.renewed + INTERVAL m.duration MONTH as expiry,
231 WHEN m.duration IS NULL THEN 0
232 WHEN m.renewed + INTERVAL m.duration MONTH <= NOW() THEN 3
233 WHEN m.renewed <= NOW() THEN 2
237 LEFT JOIN membres as parent ON (parent.uid = m.creator)
238 LEFT JOIN db_servers as dbs ON (m.db_server_id = dbs.id)
239 LEFT JOIN local as l ON (m.uid = l.uid) ;");
240 while ($db->next_record()) {
241 $lst_users_properties[$db->f('muid
')] = $db->Record;
245 if (!isset($lst_users_properties[$uid])) {
247 // don't exist, but is not a forced check. Do a forced check
248 return $this->
get(
$uid,
true);
250 $msg->raise(
"ERROR",
"admin", _(
"Account not found"));
254 return $lst_users_properties[
$uid];
270 $msg->debug(
"admin",
"get_creator",
$uid);
272 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can access this page! --"));
276 $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));
278 if (
$db->num_rows()) {
282 $msg->raise(
"ERROR",
"admin", _(
"Account not found"));
286 $db->query(
"SELECT * FROM local WHERE uid= ?;", array(
$uid));
287 if (
$db->num_rows()) {
295 $db->query(
"SELECT count(*) as nbcreated FROM membres WHERE creator= ?;", array(
$uid));
296 if (
$db->num_rows()) {
316 $db->query(
"SELECT COUNT(*) AS cnt FROM membres WHERE su=1");
318 return (
$db->f(
"cnt") == 1);
343 function get_list($all = 0, $creator = 0, $pattern = FALSE, $pattern_type = FALSE) {
345 $msg->debug(
"admin",
"get_list");
347 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can access this page! --"));
350 $db =
new DB_System();
355 if ($pattern_type ===
'domaine') {
357 $request =
'SELECT compte AS uid FROM domaines WHERE 1';
359 if ($pattern && preg_match(
'/[.a-zA-Z0-9]+/', $pattern)) {
360 $request .= sprintf(
' AND domaine LIKE "%%%s%%"', $pattern);
363 $request .= sprintf(
' AND compte in (select uid from membres where creator = "%s" ) ', $creator);
365 if (
$mem->user[
'uid'] != 2000 && !$all) {
366 $request .= sprintf(
' AND compte in (select uid from membres where creator = "%s") ',
$cuid);
370 }
elseif ($pattern_type ===
'login') {
372 $request =
'SELECT uid FROM membres WHERE 1';
374 if ($pattern && preg_match(
'/[a-zA-Z0-9]+/', $pattern)) {
375 $request .= sprintf(
' AND login LIKE "%%%s%%"', $pattern);
378 $request .= sprintf(
' AND creator = "%s"', $creator);
380 if (
$mem->user[
'uid'] != 2000 && !$all) {
385 $msg->raise(
"ERROR",
"admin", _(
"Invalid pattern type provided. Are you even performing a legitimate action?"));
391 $request =
"SELECT uid FROM membres WHERE creator='" . $creator .
"' ORDER BY login;";
392 }
elseif (
$mem->user[
'uid'] == 2000 || $all) {
393 $request =
"SELECT uid FROM membres ORDER BY login;";
395 $request =
"SELECT uid FROM membres WHERE creator='" .
$cuid .
"' ORDER BY login;";
401 if (
$db->num_rows()) {
403 while (
$db->next_record()) {
404 $c[
$db->f(
"uid")] = $this->
get(
$db->f(
"uid"));
427 $msg->log(
"admin",
"mailallmembers");
429 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can access this page! --"));
432 $subject = trim($subject);
433 $message = trim($message);
436 if (empty($subject) || empty($message) || empty($from)) {
437 $msg->raise(
"ERROR",
"admin", _(
"Subject, message and sender are mandatory"));
442 $msg->raise(
"ERROR",
"admin", _(
"Sender is syntaxically incorrect"));
446 @set_time_limit(1200);
447 $db->query(
"SELECT DISTINCT mail FROM membres WHERE mail!='';");
448 while (
$db->next_record()) {
451 mail(
$db->f(
'mail'), $subject, $message,
null,
"-f$from");
473 $msg->debug(
"admin",
"get_creator_list");
475 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can access this page! --"));
479 $db =
new DB_System();
480 $db->query(
"SELECT DISTINCT creator FROM membres WHERE creator <> 0 ORDER BY creator ASC;");
481 if (
$db->num_rows()) {
482 while (
$db->next_record()) {
486 $creators2 = array();
487 foreach ($creators as $cc) {
488 $creators2[$cc[
'uid']] = $cc;
509 $db->query(
"SELECT creator FROM membres WHERE uid= ?;", array(
$uid));
511 if (
$db->Record[
"creator"] !=
$cuid) {
512 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can access this page! --"));
533 $msg->log(
"admin",
"add_shared_domain", $u .
"/" . $domain_name);
535 if (!
$mem->checkright()) {
536 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can do that! --"));
541 if ((!in_array($domain_name,
$dom->enum_domains()))&&($domain_name!=
variable_get(
"hosting_tld"))) {
542 $msg->raise(
"ERROR",
"admin", _(
"You don't seem to be allowed to delegate this domain"));
543 $msg->log(
"admin",
"add_shared_domain",
"domain not allowed");
548 $domain_name = preg_replace(
"/^\.\.*/",
"", $domain_name);
554 $dns=($domain_name==
variable_get(
"hosting_tld")) ? 0 : 1;
555 $dom->add_domain(
$mem->user[
'login'] .
"." . $domain_name, $dns, 1, 1);
593 function add_mem(
$login, $pass, $nom, $prenom, $mail, $canpass = 1, $type =
'default', $duration = 0, $notes =
"", $force = 0, $create_dom =
'', $db_server_id) {
595 $msg->log(
"admin",
"add_mem",
$login .
"/" . $mail);
597 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can access this page! --"));
600 if (empty($db_server_id)) {
601 $msg->raise(
"ERROR",
"admin", _(
"Missing db_server field"));
604 if ((
$login ==
"") || ($pass ==
"")) {
605 $msg->raise(
"ERROR",
"admin", _(
"Please fill all mandatory fields"));
610 $msg->raise(
"ERROR",
"admin", _(
"Please fill all mandatory fields"));
615 $msg->raise(
"ERROR",
"admin", _(
"Please enter a valid email address"));
620 if (!preg_match(
"#^[a-z0-9]+$#",
$login)) {
621 $msg->raise(
"ERROR",
"admin", _(
"Login can only contains characters a-z and 0-9"));
624 if (strlen(
$login) > 14) {
628 $msg->raise(
"ERROR",
"admin", _(
"The login is too long (14 chars max)"));
633 $msg->raise(
"ERROR",
"admin", _(
"Login can only contains characters a-z, 0-9 and -"));
636 $pass = password_hash($pass, PASSWORD_BCRYPT);
637 $db =
new DB_System();
639 $db->query(
"SELECT count(*) AS cnt FROM membres WHERE login= ?;", array(
$login));
641 if (!
$db->f(
"cnt")) {
642 $db->query(
"SELECT max(m.uid)+1 as nextid FROM membres m");
643 if (!
$db->next_record()) {
651 $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));
652 $db->query(
"INSERT INTO local(uid,nom,prenom) VALUES(?, ?, ?);", array(
$uid, $nom, $prenom));
655 $action->fix_user(
$uid);
660 $hooks->invoke(
"alternc_add_member");
662 $hooks->invoke(
"hook_admin_add_member", array(), array(
'quota'));
663 $hooks->invoke(
"hook_admin_add_member");
666 if (!empty($create_dom)) {
672 $msg->raise(
"ERROR",
"admin", _(
"This login already exists"));
690 $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'));
694 $db =
new DB_System();
695 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))) {
696 $msg->raise(
"ERROR",
"admin", sprintf(_(
"query failed: %s "),
$db->Error));
699 if (
$db->next_record()) {
702 A new AlternC account was created on %fqdn by %creator.
709 createor: %creator (%cuid)
710 can change password: %canpass
714 $mail = strtr($mail, array(
'%fqdn' => $L_FQDN,
715 '%creator' =>
$db->Record[
'parentlogin'],
716 '%uid' =>
$db->Record[
'uid'],
717 '%login' =>
$db->Record[
'login'],
718 '%mail' =>
$db->Record[
'mail'],
719 '%cuid' =>
$db->Record[
'creator'],
720 '%canpass' =>
$db->Record[
'canpass'],
721 '%type' =>
$db->Record[
'type'],
722 '%notes' =>
$db->Record[
'notes']));
723 $subject = sprintf(_(
"New account %s from %s on %s"),
$db->Record[
'login'],
$db->Record[
'parentlogin'], $L_HOSTING);
724 if (mail($dest, $subject, $mail,
"From: postmaster@$L_FQDN")) {
728 $msg->raise(
"ERROR",
"admin", sprintf(_(
"Cannot send email to %s"), $dest));
732 $msg->raise(
"ERROR",
"admin", sprintf(_(
"Query failed: %s"),
$db->Error));
762 function update_mem(
$uid, $mail, $nom, $prenom, $pass,
$enabled, $canpass, $type =
'default', $duration = 0, $notes =
"", $reset_quotas =
false) {
765 $msg->log(
"admin",
"update_mem",
$uid);
768 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can access this page! --"));
771 $db =
new DB_System();
774 $pass = password_hash($pass, PASSWORD_BCRYPT);
775 $second_query =
"UPDATE membres SET mail= ?, canpass= ?, enabled= ?, `type`= ?, notes= ? , pass = ? WHERE uid= ?;";
776 $second_query_args = array($mail, $canpass,
$enabled, $type, $notes, $pass,
$uid);
778 $second_query =
"UPDATE membres SET mail= ?, canpass= ?, enabled= ?, `type`= ?, notes= ? WHERE uid= ?;";
779 $second_query_args = array($mail, $canpass,
$enabled, $type, $notes,
$uid);
782 $old_mem = $this->
get(
$uid);
785 ($db->query(
"UPDATE local SET nom= ?, prenom= ? WHERE uid=?;", array($nom, $prenom,
$uid))) &&
786 (
$db->query($second_query, $second_query_args))
788 if ($reset_quotas ==
"on" || $type != $old_mem[
'type']) {
790 $quota->synchronise_user_profile();
795 $msg->raise(
"ERROR",
"admin", _(
"Account not found"));
813 $msg->log(
"admin",
"lock_mem",
$uid);
815 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can access this page! --"));
818 $db =
new DB_System();
819 if (
$db->query(
"UPDATE membres SET enabled='0' WHERE uid= ?;", array(
$uid))) {
822 $msg->raise(
"ERROR",
"admin", _(
"Account not found"));
841 $msg->log(
"admin",
"unlock_mem",
$uid);
843 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can access this page! --"));
846 $db =
new DB_System();
847 if (
$db->query(
"UPDATE membres SET enabled='1' WHERE uid= ?;", array(
$uid))) {
850 $msg->raise(
"ERROR",
"admin", _(
"Account not found"));
873 $msg->log(
"admin",
"del_mem",
$uid);
876 $msg->raise(
"ERROR",
"admin", _(
"-- Only administrators can access this page! --"));
879 $db =
new DB_System();
880 $tt = $this->
get(
$uid);
886 $dom->admin_del_member();
888 # New way of deleting or backup delted user html folders using action class
890 $action->archive($path);
892 $hooks->invoke(
"alternc_del_member");
893 $hooks->invoke(
"hook_admin_del_member");
895 if ((
$db->query(
"DELETE FROM membres WHERE uid= ?;", array(
$uid))) &&
896 (
$db->query(
"DELETE FROM local WHERE uid= ?;", array(
$uid)))) {
899 $db->query(
"UPDATE membres SET creator=2000 WHERE creator= ?;", array(
$uid));
902 $msg->raise(
"ERROR",
"admin", _(
"Account not found"));
923 $periods = intval($periods);
927 if (
$db->query(
"UPDATE membres SET renewed = renewed + INTERVAL (duration * ?) MONTH WHERE uid= ?;", array($periods,
$uid))) {
930 $msg->raise(
"ERROR",
"admin", _(
"Account not found"));
948 if ($duration == 0) {
949 if (
$db->query(
"UPDATE membres SET duration = NULL, renewed = NULL WHERE uid= ?;", array(
$uid))) {
953 if (
$db->query(
"UPDATE membres SET duration = ? WHERE uid= ?", array($duration,
$uid)) &&
954 $db->query(
"UPDATE membres SET renewed = NOW() WHERE uid= ? and renewed is null;", array(
$uid))) {
959 $msg->raise(
"ERROR",
"admin", _(
"Account not found"));
971 $jj = $this->
get(
$uid);
972 if (isset($jj) && isset($jj[
'expiry']) && !empty($jj[
'expiry'])) {
973 return $jj[
'expiry'];
990 $jj = $this->
get(
$uid);
992 if (isset($jj) && isset($jj[
'status']) && !empty($jj[
'status'])) {
993 return $jj[
'status'];
1009 if (!
$db->query(
"SELECT *, m.renewed + INTERVAL duration MONTH 'expiry'," .
1010 " CASE WHEN m.duration IS NULL THEN 0" .
1011 " WHEN m.renewed + INTERVAL m.duration MONTH <= NOW() THEN 3" .
1012 " WHEN m.renewed <= NOW() THEN 2" .
1013 " ELSE 1 END 'status' FROM membres m, local l" .
1014 " WHERE m.uid = l.uid" .
1015 " HAVING status=2 or status=3 ORDER BY status DESC, expiry;")) {
1019 while (
$db->next_record()) {
1037 $db->query(
"SELECT su FROM membres WHERE uid= ?;", array(
$uid));
1038 if (!
$db->next_record()) {
1039 $msg->raise(
"ERROR",
"admin", _(
"Account not found"));
1042 if (
$db->Record[
"su"] != 0) {
1043 $msg->raise(
"ERROR",
"admin", _(
"This account is ALREADY an administrator account"));
1046 $db->query(
"UPDATE membres SET su=1 WHERE uid= ?;", array(
$uid));
1061 $db->query(
"SELECT su FROM membres WHERE uid= ?;", array(
$uid));
1062 if (!
$db->next_record()) {
1063 $msg->raise(
"ERROR",
"admin", _(
"Account not found"));
1066 if (
$db->Record[
"su"] != 1) {
1067 $msg->raise(
"ERROR",
"admin", _(
"This account is NOT an administrator account!"));
1070 $db->query(
"UPDATE membres SET su=0 WHERE uid= ?;", array(
$uid));
1090 $db->query(
"SELECT tld,mode FROM tld ORDER BY tld;");
1092 while (
$db->next_record()) {
1111 $cachefile =
"/tmp/alternc_dig_check_cache";
1114 if (!
$forcecheck && file_exists($cachefile) && filemtime($cachefile) + $cachetime > time()) {
1115 $checked = unserialize(file_get_contents($cachefile));
1119 file_put_contents($cachefile, serialize($checked));
1123 $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 ";
1124 $query_args = array();
1126 $query .=
" WHERE domaine not like ?";
1127 array_push($query_args,
"%.".$hosting_tld);
1129 $query .=
" ORDER BY domaine;";
1132 while (
$db->next_record()) {
1135 $tmp[
"errstr"] = $checked[$tmp[
"domaine"]][
"errstr"];
1136 $tmp[
"errno"] = $checked[$tmp[
"domaine"]][
"errno"];
1155 global
$db, $L_NS1, $L_NS2, $L_MX, $L_PUBLIC_IP;
1158 $query =
"SELECT * FROM domaines ";
1159 $query_args = array();
1161 $query .=
" WHERE domaine not like ?";
1162 array_push($query_args,
"%.".$hosting_tld);
1164 $query .=
" ORDER BY domaine";
1167 while (
$db->next_record()) {
1168 $dl[
$db->Record[
"domaine"]] =
$db->Record;
1175 foreach (
$dl as
$c) {
1181 if (
$c[
"gesdns"] == 1) {
1184 exec(
"dig +short NS " . escapeshellarg(
$c[
"domaine"]), $out);
1185 if (count($out) == 0) {
1188 if (!in_array($L_NS1 .
".", $out) || !in_array($L_NS2 .
".", $out)) {
1190 $errstr.=sprintf(_(
"NS for this domain are not %s and %s BUT %s"),
1191 $L_NS1, $L_NS2, implode(
",", $out)) .
"\n";
1196 if (!$dontexist&&(!$lazycheck||!
$c[
"gesdns"])) {
1197 if (
$c[
"gesmx"] == 1) {
1199 exec(
"dig +short MX " . escapeshellarg(
$c[
"domaine"]), $out);
1201 foreach ($out as $o) {
1202 list(
$t, $out2[]) = explode(
" ", $o);
1204 if (!in_array($L_MX .
".", $out2)) {
1206 $errstr.=sprintf(_(
"MX is not %s BUT %s"), $L_MX, implode(
",", $out2)).
"\n";
1211 $db->query(
"SELECT * FROM sub_domaines WHERE domaine=? ORDER BY sub;", array(
$c[
"domaine"]));
1212 while (
$db->next_record()) {
1214 if (
$d[
"type"] ==
'VHOST') {
1217 exec(
"dig +short A " . escapeshellarg(
$d[
"sub"] . ((
$d[
"sub"] !=
"") ?
"." :
"") .
$c[
"domaine"]), $out);
1218 if (!is_array($out)) {
1220 $errstr.=_(
"Fail to get the DNS information. Try again.").
"\n";
1222 if (!in_array($L_PUBLIC_IP, $out)) {
1223 $errstr.=sprintf(_(
"subdomain '%s' doesn't point to %s but to '%s'"),
$d[
"sub"], $L_PUBLIC_IP, implode(
",", $out)).
"\n" ;
1232 $errstr = _(
"Domain doesn't exist anymore !");
1236 $checked[
$c[
"domaine"]] = array(
"errno" => $errno,
"errstr" =>
$errstr);
1255 $db->query(
"SELECT compte FROM domaines WHERE domaine= ?;", array(
$domain));
1256 if (!
$db->next_record()) {
1257 $msg->raise(
"ERROR",
"dom", _(
"Domain '%s' not found."),
$domain);
1260 $db->query(
"UPDATE domaines SET noerase=1-noerase WHERE domaine= ?;", array(
$domain));
1275 $db->query(
"SELECT mode FROM tld WHERE tld= ?;", array($tld));
1276 if (!
$db->next_record()) {
1277 $msg->raise(
"ERROR",
"admin", _(
"This TLD does not exist"));
1280 return $db->Record[
"mode"];
1290 for (
$i = 0;
$i < count($this->tldmode);
$i++) {
1291 echo
"<option value=\"$i\"";
1292 if ($current ==
$i) {
1293 echo
" selected=\"selected\"";
1295 echo
">" . _($this->tldmode[
$i]) .
"</option>\n";
1313 $db->query(
"SELECT tld FROM tld WHERE tld= ?;", array($tld));
1314 if (!
$db->next_record()) {
1315 $msg->raise(
"ERROR",
"admin", _(
"This TLD does not exist"));
1318 $db->query(
"DELETE FROM tld WHERE tld= ?;", array($tld));
1339 $msg->raise(
"ERROR",
"admin", _(
"The TLD name is mandatory"));
1344 $db->query(
"SELECT tld FROM tld WHERE tld= ?;", array($tld));
1345 if (
$db->next_record()) {
1346 $msg->raise(
"ERROR",
"admin", _(
"This TLD already exist"));
1349 if (substr($tld, 0, 1) ==
".") {
1350 $tld = substr($tld, 1);
1356 $db->query(
"INSERT INTO tld (tld,mode) VALUES (?,?);", array($tld,
$mode));
1374 $db->query(
"SELECT tld FROM tld WHERE tld= ?;", array($tld));
1375 if (!
$db->next_record()) {
1376 $msg->raise(
"ERROR",
"admin", _(
"This TLD does not exist"));
1383 $db->query(
"UPDATE tld SET mode= ? WHERE tld= ?;", array(
$mode, $tld));
1396 $db->query(
"SELECT login FROM membres WHERE uid=2000;");
1398 return $db->f(
"login");
1414 $policies = array();
1415 $db->query(
"SELECT * FROM policy;");
1416 while (
$db->next_record()) {
1417 $tmp1[
$db->Record[
"name"]] =
$db->Record;
1419 $tmp3 =
$hooks->invoke(
"alternc_password_policy");
1420 foreach ($tmp3 as $v) {
1421 foreach ($v as $l => $m) {
1425 foreach ($tmp2 as $k => $v) {
1426 if (!isset($tmp1[$k])) {
1428 $db->query(
"INSERT INTO policy SET name= ?, minsize=0, maxsize=64, classcount=0, allowlogin=0;", array($k));
1430 "minsize" => 0,
"maxsize" => 64,
"classcount" => 0,
"allowlogin" => 0
1433 $policies[$k] = $tmp1[$k];
1434 $policies[$k][
"description"] = _($v);
1437 foreach ($tmp1 as $k => $v) {
1439 $db->query(
"DELETE FROM policy WHERE name= ?;", array($k));
1456 function editPolicy($policy, $minsize, $maxsize, $classcount, $allowlogin) {
1458 $minsize = intval($minsize);
1459 $maxsize = intval($maxsize);
1460 $classcount = intval($classcount);
1461 $allowlogin = intval($allowlogin);
1463 $db->query(
"SELECT * FROM policy WHERE name= ?;", array($policy));
1464 if (!
$db->next_record()) {
1467 if ($minsize < 0 || $minsize > 64 || $maxsize < 0 || $maxsize > 64 || $maxsize < $minsize || $classcount < 0 || $classcount > 4) {
1470 $allowlogin = ($allowlogin) ? 1 : 0;
1471 $db->query(
"UPDATE policy SET minsize= ?, maxsize= ?, classcount= ?, allowlogin= ? WHERE name= ?;", array($minsize, $maxsize, $classcount, $allowlogin, $policy));
1489 $msg->raise(
"ALERT",
"admin", _(
"Please enter a login"));
1493 $msg->raise(
"ALERT",
"admin", _(
"Please enter a password"));
1498 if (!$pol[$policy]) {
1499 $msg->raise(
"ERROR",
"admin", _(
"-- Program error -- The requested password policy does not exist!"));
1502 $pol = $pol[$policy];
1506 if ($plen < $pol[
"minsize"] && !($canbeempty && empty(
$password))) {
1507 $msg->raise(
"ERROR",
"admin", _(
"The password length is too short according to the password policy"));
1511 if ($plen > $pol[
"maxsize"] && !($canbeempty && empty(
$password))) {
1512 $msg->raise(
"ERROR",
"admin", _(
"The password is too long according to the password policy"));
1516 if (!$pol[
"allowlogin"]) {
1518 $logins = preg_split(
"/[@_-]/",
$login);
1520 foreach ($logins as $l) {
1525 $msg->raise(
"ERROR",
"admin", _(
"The password policy prevents you to use your login name inside your password or the other way around"));
1531 if ($pol[
"classcount"] > 0 && !($canbeempty && empty(
$password))) {
1532 $cls = array(0, 0, 0, 0, 0);
1535 if (strpos(
"abcdefghijklmnopqrstuvwxyz",
$p) !==
false) {
1537 }
elseif (strpos(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
$p) !==
false) {
1539 }
elseif (strpos(
"0123456789",
$p) !==
false) {
1541 }
elseif (strpos(
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`',
$p) !==
false) {
1547 $clc = array_sum($cls);
1548 if ($clc < $pol[
"classcount"]) {
1549 $msg->raise(
"ERROR",
"admin", _(
"Your password contains not enough different classes of character, between low-case, up-case, figures and special characters."));
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
Manage the AlternC's account administration (create/edit/delete)
update_mem($uid, $mail, $nom, $prenom, $pass, $enabled, $canpass, $type='default', $duration=0, $notes="", $reset_quotas=false)
Edit an account.
edittld($tld, $mode)
Modify a TLD of the list of the authorized TLDs.
gettld($tld)
Add a new TLD to the list of the authorized TLDs.
editPolicy($policy, $minsize, $maxsize, $classcount, $allowlogin)
Change a password policy for one kind of password.
listtld()
List of the authorized TLDs Returns the list of the authorized TLDs and also the way they are authori...
hook_menu()
Hook function called by the menu class to add menu to the left panel.
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.
add_shared_domain($u, $domain_name)
When the admin want to delegate a subdomain to an account.
renew_get_expiry($uid)
Get the expiry date for an account.
dom_list($alsocheck=false, $forcecheck=false)
List the hosted domains on this server.
renew_get_expiring_accounts()
Get the expired/about to expire accounts.
get_creator($uid)
Returns the known information about a specific hosted account.
checkcreator($uid)
Check if I am the creator of the member $uid.
addtld($tld, $mode)
Add a TLD to the list of the authorized TLDs during the installation.
checkalldom()
Check all the domains for their NS MX and IPs.
del_mem($uid)
Deletes an account Deletes the specified account.
get_creator_list()
Returns an array with the known information about resellers (uid, login, number of accounts) Does not...
su2normal($uid)
Turns a super-admin account into a common account.
listPasswordPolicies()
List the password policies currently installed in the policy table.
mailallmembers($subject, $message, $from)
Send an email to all AlternC's accounts.
__construct()
Constructor.
hook_admin_add_member()
AlternC's standard function called when a user is created This sends an email if configured through t...
renew_get_status($uid)
Get the expiry status for an account.
$tldmode
List of the controls made for each TLD.
checkPolicy($policy, $login, $password, $canbeempty=false)
$enabled
$enabled tells if the logged user is super-admin or not
lock_mem($uid)
Lock an account.
selecttldmode($current=false)
Prints the list of the actually authorized TLDs.
dom_lock($domain)
Lock / Unlock a domain.
renew_update($uid, $duration)
Update the duration information for an account.
get_list($all=0, $creator=0, $pattern=FALSE, $pattern_type=FALSE)
@TODO :EM: those request should have been escaped Returns the list of the hosted accounts
unlock_mem($uid)
UnLock an account.
normal2su($uid)
Turns a common account into a super-admin account.
renew_mem($uid, $periods=1)
Renew an account.
getadmin()
Get the login name of the main administrator account.
deltld($tld)
Deletes the specified tld in the list of the authorized TLDs Note : This function does not delete the...
checkmail($mail)
Check an email address, use filter_var with emails, which works great ;)
getuserpath($user=null)
get the home of the user
if(empty($site_name)) elseif($piwik->site_add( $site_name, $site_urls))
foreach($domaines_user as $domaine) $t
if(empty($_POST['key'])||empty($_POST['val'])) $key