diff --git a/.gitattributes b/.gitattributes
index 107fd914..0d0c481c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -432,6 +432,7 @@ install/upgrades/0.9.5.sql -text
install/upgrades/0.9.6.sql -text
install/upgrades/0.9.7.sql -text
install/upgrades/0.9.9.sql -text
+install/upgrades/1.0.1.php -text
install/upgrades/1.0.sql -text
install/upgrades/1.1.sql -text
install/upgrades/README -text
diff --git a/bureau/admin/menu_lang.php b/bureau/admin/menu_lang.php
index 1afcb674..5faebb34 100644
--- a/bureau/admin/menu_lang.php
+++ b/bureau/admin/menu_lang.php
@@ -1,6 +1,6 @@
diff --git a/bureau/class/config.php b/bureau/class/config.php
index 981790e3..fa073fd2 100644
--- a/bureau/class/config.php
+++ b/bureau/class/config.php
@@ -131,7 +131,7 @@ $classes=array();
/* CLASSES PHP : automatic include : */
$c=opendir($root."class/");
while ($di=readdir($c)) {
- if (ereg("^m_(.*)\\.php$",$di,$match)) { // $
+ if (preg_match("#^m_(.*)\\.php$#",$di,$match)) { // $
$name1="m_".$match[1];
$name2=$match[1];
$classes[]=$name2;
diff --git a/bureau/class/config_real.php b/bureau/class/config_real.php
index 6a770acb..16d644b1 100644
--- a/bureau/class/config_real.php
+++ b/bureau/class/config_real.php
@@ -84,7 +84,7 @@ $classes=array();
/* CLASSES PHP : automatic include : */
$c=opendir($root."class/");
while ($di=readdir($c)) {
- if (ereg("^m_(.*)\\.php$",$di,$match)) { // $
+ if (preg_match("#^m_(.*)\\.php$#",$di,$match)) { // $
$name1="m_".$match[1];
$name2=$match[1];
$classes[]=$name2;
diff --git a/bureau/class/functions.php b/bureau/class/functions.php
index f3ce2a7b..239978e6 100644
--- a/bureau/class/functions.php
+++ b/bureau/class/functions.php
@@ -190,7 +190,7 @@ function checkfqdn($fqdn) {
// Note: a.foo.net is a valid domain
// Note: RFC1035 tells us that a domain should not start by a digit, but every registrar allows such a domain to be created ... too bad.
- if (!eregi("^[a-z0-9]([a-z0-9-]*[a-z0-9])?$",$val)) {
+ if (!preg_match("#^[a-z0-9]([a-z0-9-]*[a-z0-9])?$#i",$val)) {
return 3;
}
}
diff --git a/bureau/class/m_admin.php b/bureau/class/m_admin.php
index fa3571ee..ccc7c1c5 100644
--- a/bureau/class/m_admin.php
+++ b/bureau/class/m_admin.php
@@ -328,7 +328,7 @@ class m_admin {
}
// Vérification de la conformité du login
$login=strtolower($login);
- if (!ereg("^[a-z0-9]*$",$login)) { //$
+ if (!preg_match("#^[a-z0-9]*$#",$login)) { //$
$err->raise("admin", "Login can only contains characters a-z and 0-9");
return false;
}
diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php
index eb0d6244..aa6ac616 100644
--- a/bureau/class/m_dom.php
+++ b/bureau/class/m_dom.php
@@ -453,7 +453,7 @@ class m_dom {
$err->log("dom","whois",$domain);
// pour ajouter un nouveau TLD, utiliser le code ci-dessous.
// echo "whois : $domain
";
- ereg(".*\.([^\.]*)",$domain,$out);
+ preg_match("#.*\.([^\.]*)#",$domain,$out);
$ext=$out[1];
// pour ajouter un nouveau TLD, utiliser le code ci-dessous.
// echo "ext: $ext
";
@@ -464,7 +464,7 @@ class m_dom {
$state=0;
while (!feof($fp)) {
$ligne = fgets($fp,128);
- if (ereg('^whois:[[:space:]]+.*$', $ligne)) { $serveur=preg_replace('/whois:\ */','',$ligne,1); }
+ if (preg_match('#^whois:#', $ligne)) { $serveur=preg_replace('/whois:\ */','',$ligne,1); }
}
}
@@ -495,15 +495,15 @@ class m_dom {
case "biz":
case "name":
case "cc":
- if (ereg("Name Server:", $ligne)) {
+ if (preg_match("#Name Server:#", $ligne)) {
$found = true;
- $tmp=strtolower(ereg_replace(chr(10), "",ereg_replace(chr(13),"",ereg_replace(" ","", ereg_replace("Name Server:","", $ligne)))));
+ $tmp=strtolower(str_replace(chr(10), "",str_replace(chr(13),"",str_replace(" ","", str_replace("Name Server:","", $ligne)))));
if ($tmp)
$server[]=$tmp;
}
break;
case "cx":
- $ligne = ereg_replace(chr(10), "",ereg_replace(chr(13),"",ereg_replace(" ","", $ligne)));
+ $ligne = str_replace(chr(10), "",str_replace(chr(13),"",str_replace(" ","", $ligne)));
if ($ligne=="" && $state==1)
$state=2;
if ($state==1)
@@ -536,7 +536,7 @@ class m_dom {
}
break;
case "it":
- if (ereg("nserver:", $ligne)) {
+ if (preg_match("#nserver:#", $ligne)) {
$found=true;
$tmp=strtolower(preg_replace("/nserver:\s*[^ ]*\s*([^\s]*)$/","\\1", $ligne));
if ($tmp)
@@ -545,20 +545,20 @@ class m_dom {
break;
case "fr":
case "re":
- if (ereg("nserver:", $ligne)) {
+ if (preg_match("#nserver:#", $ligne)) {
$found=true;
- $tmp=strtolower(preg_replace("/nserver:\s*([^\s]*)\s*.*$/","\\1", $ligne));
+ $tmp=strtolower(preg_replace("#nserver:\s*([^\s]*)\s*.*$#","\\1", $ligne));
if ($tmp)
$server[]=$tmp;
}
break;
case "ca":
case "ws";
- if (ereg('^[[:space:]]*Name servers:[[:space:]]*$', $ligne)) {
+ if (preg_match('#Name servers#', $ligne)) {
// found the server
$state = 1;
} elseif ($state) {
- if (ereg('^[^%]', $ligne) && $ligne = ereg_replace('[[:space:]]', "", $ligne)) {
+ if (preg_match('#^[^%]#', $ligne) && $ligne = preg_replace('#[[:space:]]#', "", $ligne)) {
// first non-whitespace line is considered to be the nameservers themselves
$found = true;
$server[] = $ligne;
@@ -566,7 +566,7 @@ class m_dom {
}
break;
case "coop":
- if (preg_match('/Host Name:\s*([^\s]+)/', $ligne, $matches)) {
+ if (preg_match('#Host Name:\s*([^\s]+)#', $ligne, $matches)) {
$found = true;
$server[] = $matches[1];
}
@@ -941,7 +941,7 @@ class m_dom {
*/
function edit_domain($dom,$dns,$gesmx,$force=0) {
global $db,$err,$L_MX,$classes,$cuid;
- $err->log("dom","edit_domain",$dom);
+ $err->log("dom","edit_domain",$dom."/".$dns."/".$gesmx);
// Locked ?
if (!$this->islocked && !$force) {
$err->raise("dom",3);
@@ -1016,7 +1016,7 @@ class m_dom {
}
}
- $db->query("UPDATE domaines SET gesdns='$dns', mx='$mx', gesmx='$gesmx' WHERE domaine='$dom'");
+ $db->query("UPDATE domaines SET gesdns='$dns', gesmx='$gesmx' WHERE domaine='$dom'");
$db->query("UPDATE domaines set dns_action='UPDATE' where domaine='$dom';");
return true;
diff --git a/bureau/class/m_mem.php b/bureau/class/m_mem.php
index 4427905b..d7f78aaa 100644
--- a/bureau/class/m_mem.php
+++ b/bureau/class/m_mem.php
@@ -533,8 +533,8 @@ Cordialement.
if ($this->user["show_help"] || $force) {
$hlp=_("hlp_$file");
if ($hlp!="hlp_$file") {
- $hlp=ereg_replace(
- "HELPID_([0-9]*)",
+ $hlp=preg_replace(
+ "#HELPID_([0-9]*)#",
"",$hlp);
echo "".$hlp."
";
return true;
diff --git a/bureau/class/m_mysql.php b/bureau/class/m_mysql.php
index b8b9a759..42e39acf 100644
--- a/bureau/class/m_mysql.php
+++ b/bureau/class/m_mysql.php
@@ -194,7 +194,7 @@ class m_mysql {
$err->raise("mysql",1);
return false;
}
- if (!ereg("^[0-9a-z]*$",$dbn)) {
+ if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
$err->raise("mysql",2);
return false;
}
@@ -277,7 +277,7 @@ class m_mysql {
function put_mysql_backup($dbn,$bck_mode,$bck_history,$bck_gzip,$bck_dir) {
global $db,$err,$mem,$bro,$cuid;
$err->log("mysql","put_mysql_backup");
- if (!ereg("^[0-9a-z]*$",$dbn)) {
+ if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
$err->raise("mysql",2);
return false;
}
@@ -502,7 +502,7 @@ class m_mysql {
$err->raise("mysql",13);
return false;
}
- if (!ereg("^[0-9a-z]",$usern)) {
+ if (!preg_match("#^[0-9a-z]#",$usern)) {
$err->raise("mysql",14);
return false;
}
@@ -578,7 +578,7 @@ class m_mysql {
function del_user($user) {
global $db,$err,$mem,$cuid,$L_MYSQL_DATABASE;
$err->log("mysql","del_user",$user);
- if (!ereg("^[0-9a-z]",$user)) {
+ if (!preg_match("#^[0-9a-z]#",$user)) {
$err->raise("mysql",14);
return false;
}
diff --git a/debian/changelog b/debian/changelog
index bb947f69..58c10324 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,7 +5,12 @@ alternc (1.1) stable; urgency=low
-- Alan Garcia Wed, 25 May 2011 09:24:30 +0200
-alternc (1.0~rc3) stable; urgency=low
+alternc (1.0.1) stable; urgency=high
+ * Bugfix : upgrades from 0.* to 1.0 was not working for MX fields, Fixed.
+
+ -- Benjamin Sonntag Thu, 14 Jun 2011 17:59:50 +0200
+
+alternc (1.0) stable; urgency=low
* Major patch
* Web & DNS file generation rebuild from scratch
* Drop of apache 1 support
diff --git a/etc/alternc/apache2.conf b/etc/alternc/apache2.conf
index 09ce76d5..7ff9a368 100644
--- a/etc/alternc/apache2.conf
+++ b/etc/alternc/apache2.conf
@@ -30,7 +30,7 @@ ScriptAlias /cgi-bin/ /var/alternc/cgi-bin/
php_admin_flag safe_mode_gid off
php_admin_flag safe_mode off
php_admin_flag register_globals on
- AddDefaultCharset ISO-8859-1
+ AddDefaultCharset UTF-8
# modules such as mailman or awstats needs to write into other folders, we have to remove this :
# php_admin_value open_basedir /etc/alternc/:/var/run/alternc/:/var/alternc/bureau/:/var/alternc/html/:/var/alternc/tmp:/tmp:/usr/share/php/:/var/cache/alternc-webalizer/:/etc/locale.gen
diff --git a/install/mysql.sql b/install/mysql.sql
index ce594f2b..df44c942 100644
--- a/install/mysql.sql
+++ b/install/mysql.sql
@@ -523,8 +523,8 @@ PRIMARY KEY ( `name` )
) COMMENT = 'Type of domains allowed';
INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, only_dns, need_dns, advanced, enable) values
-('vhost','Locally hosted', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false, false, 'ALL'),
-('url','URL redirection', 'URL', '%SUB% IN A @@PUBLIC_IP@@','txt', true, true, false, 'ALL'),
+('vhost','Locally hosted', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt,defmx,defmx2,mx,mx2', false, false, false, 'ALL'),
+('url','URL redirection', 'URL', '%SUB% IN A @@PUBLIC_IP@@','txt,defmx,defmx2', true, true, false, 'ALL'),
('ip','IPv4 redirect', 'IP', '%SUB% IN A %TARGET%','url,ip,ipv6,txt,mx,mx2,defmx,defmx2', false, true, false, 'ALL'),
('webmail', 'Webmail access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false, false, 'ALL'),
('ipv6','IPv6 redirect', 'IPV6', '%SUB% IN AAAA %TARGET%','ip,ipv6,webmail,txt,mx,mx2,defmx,defmx2',true, true, true , 'ALL'),
@@ -532,9 +532,9 @@ INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibil
('txt', 'TXT DNS entry', 'TXT', '%SUB% IN TXT "%TARGET%"','vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2,defmx,defmx2',true, true, true, 'ALL'),
('mx', 'MX DNS entry', 'DOMAIN', '%SUB% IN MX 5 %TARGET%', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2',true, false, true, 'ALL'),
('mx2', 'secondary MX DNS entry', 'DOMAIN', '%SUB% IN MX 10 %TARGET%', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2',true, false, true, 'ALL'),
-('defmx', 'Default mail server', 'NONE', '%SUB% IN MX 5 @@DEFAULT_MX@@', 'vhost,url,ip,webmail,ipv6,cname,txt,defmx2',true, false, true, 'ADMIN'),
-('defmx2', 'Default backup mail server', 'NONE', '%SUB% IN MX 10 @@DEFAULT_SECONDARY_MX@@', 'vhost,url,ip,webmail,ipv6,cname,txt,defmx',true, false, true, 'ADMIN'),
-('panel', 'AlternC panel access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2',true, false, true, 'ALL')
+('defmx', 'Default mail server', 'NONE', '%SUB% IN MX 5 @@DEFAULT_MX@@.', 'vhost,url,ip,webmail,ipv6,cname,txt,defmx2',true, false, true, 'ADMIN'),
+('defmx2', 'Default backup mail server', 'NONE', '%SUB% IN MX 10 @@DEFAULT_SECONDARY_MX@@.', 'vhost,url,ip,webmail,ipv6,cname,txt,defmx',true, false, true, 'ADMIN'),
+('panel', 'AlternC panel access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2,defmx,defmx2',true, false, true, 'ALL')
;
diff --git a/install/upgrades/1.0.1.php b/install/upgrades/1.0.1.php
new file mode 100644
index 00000000..9946732e
--- /dev/null
+++ b/install/upgrades/1.0.1.php
@@ -0,0 +1,36 @@
+#!/usr/bin/php
+enabled=1;
+$dom->lock();
+
+// And we process the database changes :
+$db->query("SELECT * FROM domaines;");
+$domains=array();
+while ($db->next_record()) {
+ $domains[]=array("dom"=>$db->Record["domaine"],"gesmx"=>$db->Record["gesmx"],"mx"=>$db->Record["mx"]);
+}
+foreach($domains as $v) {
+ if ($v["gesmx"]) {
+ $dom->alternc_add_mx_domain($v["dom"]);
+ } else {
+ $dom->set_sub_domain($v["dom"],"","mx",$v["mx"]);
+ }
+}
+
+$dom->unlock();
+
+
+?>
\ No newline at end of file
diff --git a/install/upgrades/1.0.sql b/install/upgrades/1.0.sql
index 9b872cb7..636c285e 100644
--- a/install/upgrades/1.0.sql
+++ b/install/upgrades/1.0.sql
@@ -1,3 +1,57 @@
+--
+-- Because of problems with people using AlternC pre1 ,
+-- we include 0.9.10.sql in this file
+
+ALTER IGNORE TABLE `membres` ADD COLUMN `notes` TEXT NOT NULL AFTER `type`;
+
+CREATE TABLE IF NOT EXISTS `policy` (
+ `name` varchar(64) NOT NULL,
+ `minsize` tinyint(3) unsigned NOT NULL,
+ `maxsize` tinyint(3) unsigned NOT NULL,
+ `classcount` tinyint(3) unsigned NOT NULL,
+ `allowlogin` tinyint(3) unsigned NOT NULL,
+ PRIMARY KEY (`name`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='The password policies for services';
+
+
+INSERT IGNORE INTO `variable` (`name` ,`value` ,`comment`)
+VALUES (
+'subadmin_restriction', '',
+'This variable set the way the account list works for accounts other than "admin" (2000). 0 (default) = admin other than admin/2000 can see their own account, but not the other one 1 = admin other than admin/2000 can see any account by clicking the ''show all accounts'' link. '
+);
+
+--
+-- TABLES de mémorisation de la taille des dossiers db/listes
+
+CREATE TABLE IF NOT EXISTS `size_db` (
+ `db` varchar(255) NOT NULL default '',
+ `size` int(10) unsigned NOT NULL default '0',
+ `ts` timestamp(14) NOT NULL,
+ PRIMARY KEY (`db`),
+ KEY `ts` (`ts`)
+) TYPE=MyISAM COMMENT='MySQL Database used space';
+
+
+CREATE TABLE IF NOT EXISTS `size_mailman` (
+ `list` varchar(255) NOT NULL default '',
+ `uid` int(11) NOT NULL default '0',
+ `size` int(10) unsigned NOT NULL default '0',
+ `ts` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ PRIMARY KEY (`list`),
+ KEY `ts` (`ts`),
+ KEY `uid` (`uid`)
+) ENGINE=MyISAM COMMENT='Mailman Lists used space';
+
+-- IPv6 compatibility :
+ALTER TABLE `slaveip` CHANGE `ip` `ip` VARCHAR(40);
+ALTER TABLE `sessions` CHANGE `ip` `ip` VARCHAR( 40 ) NULL;
+
+-- type subdomain evolution
+ALTER TABLE `sub_domaines` CHANGE `type` `type` VARCHAR(30);
+ALTER TABLE `sub_domaines_standby` CHANGE `type` `type` VARCHAR(30);
+
+-- END OF 0.9.10.sql
+
-- Alter table to allow use of ipv6, cname and txt in dns record
ALTER TABLE sub_domaines DROP PRIMARY KEY;
ALTER TABLE sub_domaines ADD CONSTRAINT pk_SubDomaines PRIMARY KEY (compte,domaine,sub,type,valeur);
@@ -20,8 +74,8 @@ PRIMARY KEY ( `name` )
) COMMENT = 'Type of domains allowed';
INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, only_dns, need_dns, advanced, enable) values
-('vhost','Locally hosted', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false, false, 'ALL'),
-('url','URL redirection', 'URL', '%SUB% IN A @@PUBLIC_IP@@','txt', true, true, false, 'ALL'),
+('vhost','Locally hosted', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'txt,defmx,defmx2,mx,mx2', false, false, false, 'ALL'),
+('url','URL redirection', 'URL', '%SUB% IN A @@PUBLIC_IP@@','txt,defmx,defmx2', true, true, false, 'ALL'),
('ip','IPv4 redirect', 'IP', '%SUB% IN A %TARGET%','url,ip,ipv6,txt,mx,mx2,defmx,defmx2', false, true, false, 'ALL'),
('webmail', 'Webmail access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt', false, false, false, 'ALL'),
('ipv6','IPv6 redirect', 'IPV6', '%SUB% IN AAAA %TARGET%','ip,ipv6,webmail,txt,mx,mx2,defmx,defmx2',true, true, true , 'ALL'),
@@ -29,9 +83,9 @@ INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibil
('txt', 'TXT DNS entry', 'TXT', '%SUB% IN TXT "%TARGET%"','vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2,defmx,defmx2',true, true, true, 'ALL'),
('mx', 'MX DNS entry', 'DOMAIN', '%SUB% IN MX 5 %TARGET%', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2',true, false, true, 'ALL'),
('mx2', 'secondary MX DNS entry', 'DOMAIN', '%SUB% IN MX 10 %TARGET%', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2',true, false, true, 'ALL'),
-('defmx', 'Default mail server', 'NONE', '%SUB% IN MX 5 @@DEFAULT_MX@@', 'vhost,url,ip,webmail,ipv6,cname,txt,defmx2',true, false, true, 'ADMIN'),
-('defmx2', 'Default backup mail server', 'NONE', '%SUB% IN MX 10 @@DEFAULT_SECONDARY_MX@@', 'vhost,url,ip,webmail,ipv6,cname,txt,defmx',true, false, true, 'ADMIN'),
-('panel', 'AlternC panel access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2',true, false, true, 'ALL')
+('defmx', 'Default mail server', 'NONE', '%SUB% IN MX 5 @@DEFAULT_MX@@.', 'vhost,url,ip,webmail,ipv6,cname,txt,defmx2',true, false, true, 'ADMIN'),
+('defmx2', 'Default backup mail server', 'NONE', '%SUB% IN MX 10 @@DEFAULT_SECONDARY_MX@@.', 'vhost,url,ip,webmail,ipv6,cname,txt,defmx',true, false, true, 'ADMIN'),
+('panel', 'AlternC panel access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,ip,webmail,ipv6,cname,txt,mx,mx2,defmx,defmx2',true, false, true, 'ALL')
;
-- Changing standby use
@@ -53,5 +107,6 @@ UPDATE sub_domaines SET type='TXT' WHERE type='6';
UPDATE sub_domaines SET web_action='UPDATE';
-- not needed : it's now a subdomain with defmx and/or defmx2 type (this type is admin-only) :
-ALTER TABLE `domaines` DROP `mx` ;
+-- ALTER TABLE `domaines` DROP `mx` ;
+-- BUT we will remove it in a distant future version : we need it for the migration to take place fluently ...
diff --git a/src/functions_dns.sh b/src/functions_dns.sh
index 78e5fa59..ef0aebca 100755
--- a/src/functions_dns.sh
+++ b/src/functions_dns.sh
@@ -109,6 +109,11 @@ dns_regenerate() {
s/%%ns2%%/$NS2_HOSTNAME/g;
s/%%DEFAULT_MX%%/$DEFAULT_MX/g;
s/%%DEFAULT_SECONDARY_MX%%/$DEFAULT_SECONDARY_MX/g;
+ s/@@fqdn@@/$FQDN/g;
+ s/@@ns1@@/$NS1_HOSTNAME/g;
+ s/@@ns2@@/$NS2_HOSTNAME/g;
+ s/@@DEFAULT_MX@@/$DEFAULT_MX/g;
+ s/@@DEFAULT_SECONDARY_MX@@/$DEFAULT_SECONDARY_MX/g;
s/@@DOMAINE@@/$domain/g;
s/@@SERIAL@@/$serial/g;
s/@@PUBLIC_IP@@/$PUBLIC_IP/g")