To be merge into trunk :

]  :  ]
3065:3070
3061:3063
3056:3059
3051:3055

From Stable-1.0
This commit is contained in:
Benjamin Sonntag 2011-06-17 10:32:21 +00:00
parent 391ef496d0
commit 8485d8e20d
15 changed files with 142 additions and 40 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -1,6 +1,6 @@
<div class="menu-box">
<div class="menu-title">
<img src="/admin/images/lang.png" alt="<?php __("Langues"); ?>" />&nbsp;<a href="javascript:menulang_show();"><?php __("Langues"); ?></a></div>
<img src="/admin/images/lang.png" alt="<?php __("Langues"); ?>" />&nbsp;<a href="javascript:menulang_toggle();"><?php __("Langues"); ?></a></div>
<div class="menu-content" id="menu-lang">
<ul>
<?php foreach($locales as $l) { ?>
@ -10,8 +10,8 @@
</div>
</div>
<script type="text/javascript">
$("#menu-lang").hide();
function menulang_show() {
$("#menu-lang").show();
function menulang_toggle() {
$("#menu-lang").toggle();
}
menulang_toggle();
</script>

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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<br />";
ereg(".*\.([^\.]*)",$domain,$out);
preg_match("#.*\.([^\.]*)#",$domain,$out);
$ext=$out[1];
// pour ajouter un nouveau TLD, utiliser le code ci-dessous.
// echo "ext: $ext<br />";
@ -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;

View File

@ -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]*)#",
"<a href=\"javascript:help(\\1);\"><img src=\"/admin/aide/help.png\" width=\"17\" height=\"17\" style=\"vertical-align: middle;\" alt=\""._("Help")."\" /></a>",$hlp);
echo "<p class=\"hlp\">".$hlp."</p>";
return true;

View File

@ -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;
}

7
debian/changelog vendored
View File

@ -5,7 +5,12 @@ alternc (1.1) stable; urgency=low
-- Alan Garcia <fufroma@mailfr.com> 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 <benjamin@alternc.org> 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

View File

@ -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

View File

@ -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')
;

View File

@ -0,0 +1,36 @@
#!/usr/bin/php
<?php
// We check that mysql php module is loaded
if(!function_exists('mysql_connect')) {
if(!dl("mysql.so"))
exit(1);
}
// we don't check our AlternC session
if(!chdir("/var/alternc/bureau"))
exit(1);
require("/var/alternc/bureau/class/config_nochk.php");
// we go super-admin
$admin->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();
?>

View File

@ -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 ...

View File

@ -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")