From d9e24d9703bd9d3c99353fcb98bac880b25db5f7 Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Wed, 26 Mar 2014 18:24:36 +0000
Subject: [PATCH 01/17] On retente le #1576
---
install/mysql.sql | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/install/mysql.sql b/install/mysql.sql
index 8016bee3..89afe0f7 100644
--- a/install/mysql.sql
+++ b/install/mysql.sql
@@ -216,14 +216,13 @@ CREATE TABLE IF NOT EXISTS sub_domaines (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
compte int(10) unsigned NOT NULL default '0',
domaine varchar(255) NOT NULL default '',
- sub varchar(100) NOT NULL default '',
+ sub varchar(255) NOT NULL default '',
valeur varchar(255) default NULL,
type varchar(30) NOT NULL default 'LOCAL',
web_action enum ('OK','UPDATE','DELETE') NOT NULL default 'UPDATE',
web_result varchar(255) not null default '',
enable enum ('ENABLED', 'ENABLE', 'DISABLED', 'DISABLE') NOT NULL DEFAULT 'ENABLED',
- PRIMARY KEY (id),
- UNIQUE (compte,domaine,sub,type,valeur)
+ PRIMARY KEY (id)
-- ,FOREIGN KEY (type) REFERENCES (domaines_type)
) ENGINE=MyISAM;
From 5bf6c6875c3c00edaa4b6efb6e21027b1964f3d1 Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Wed, 26 Mar 2014 18:45:44 +0000
Subject: [PATCH 02/17] Et encore...
---
install/mysql.sql | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/install/mysql.sql b/install/mysql.sql
index 89afe0f7..c889867b 100644
--- a/install/mysql.sql
+++ b/install/mysql.sql
@@ -715,8 +715,7 @@ CREATE TABLE IF NOT EXISTS `default_subdomains` (
`domain_type_parameter` varchar(255) NOT NULL,
`concerned` enum('BOTH','MAIN','SLAVE') NOT NULL DEFAULT 'MAIN',
`enabled` boolean not null default true,
- PRIMARY KEY (`id`),
- UNIQUE KEY `unique_row` (`sub`,`domain_type`,`domain_type_parameter`,`concerned`)
+ PRIMARY KEY (`id`)
) ENGINE=MyISAM COMMENT='Contains the defaults subdomains created on domains creation';
INSERT IGNORE INTO `default_subdomains` (`sub`, `domain_type`, `domain_type_parameter`, `concerned`) VALUES
From dfd0080c2c346558e82827adfb019e1b96e3b3a5 Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 27 Mar 2014 09:03:22 +0000
Subject: [PATCH 03/17] Debut de test unit pour 1580
---
.gitattributes | 1 +
phpunit/tests/_datasets/domaines.yml | 11 +++++++++++
phpunit/tests/_datasets/membres.yml | 5 +++--
phpunit/tests/bureau/class/m_mailTest.php | 17 ++++++++++++-----
4 files changed, 27 insertions(+), 7 deletions(-)
create mode 100644 phpunit/tests/_datasets/domaines.yml
diff --git a/.gitattributes b/.gitattributes
index 24120ce7..0f418af0 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -605,6 +605,7 @@ nightlybuild/READMEFIRST -text
nightlybuild/build.sh -text
nightlybuild/mchroot.sh -text
nightlybuild/nightly.key -text
+phpunit/tests/_datasets/domaines.yml -text
po/alternc-admintools.pot -text
po/fr/LC_MESSAGES/.svnignore -text
po/fr/LC_MESSAGES/alternc-admintools.po -text
diff --git a/phpunit/tests/_datasets/domaines.yml b/phpunit/tests/_datasets/domaines.yml
new file mode 100644
index 00000000..a3f60c96
--- /dev/null
+++ b/phpunit/tests/_datasets/domaines.yml
@@ -0,0 +1,11 @@
+domaines:
+ -
+ id : 1
+ compte : 2001
+ domaine : example.tld
+ gesdns : 1
+ gesmx : 1
+ noerase : 0
+ dns_action : OK
+ dns_result : 0
+ zonettl : 86400
diff --git a/phpunit/tests/_datasets/membres.yml b/phpunit/tests/_datasets/membres.yml
index 78186af3..07c70f6c 100644
--- a/phpunit/tests/_datasets/membres.yml
+++ b/phpunit/tests/_datasets/membres.yml
@@ -1,6 +1,6 @@
membres:
-
- uid : 0
+ uid : 2000
login : admin
pass : admin
enabled : 1
@@ -11,6 +11,7 @@ membres:
lastfail : 0
lastip : 127.0.0.1
-
+ uid : 2001
login : phpunit
pass : phpunit
enabled : 1
@@ -19,4 +20,4 @@ membres:
show_help : 1
lastlogin : 2014-01-01 00:00:00
lastfail : 0
- lastip : 127.0.0.1
\ No newline at end of file
+ lastip : 127.0.0.1
diff --git a/phpunit/tests/bureau/class/m_mailTest.php b/phpunit/tests/bureau/class/m_mailTest.php
index fa684f02..258f177e 100644
--- a/phpunit/tests/bureau/class/m_mailTest.php
+++ b/phpunit/tests/bureau/class/m_mailTest.php
@@ -2,7 +2,7 @@
/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:58.
*/
-class m_mailTest extends PHPUnit_Framework_TestCase
+class m_mailTest extends AlterncTest
{
/**
* @var m_mail
@@ -19,6 +19,15 @@ class m_mailTest extends PHPUnit_Framework_TestCase
$this->object = new m_mail;
}
+ /**
+ * @return PHPUnit_Extensions_Database_DataSet_IDataSet
+ */
+ public function getDataSet()
+ {
+ return parent::loadDataSet("domaines.yml");
+ }
+
+
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
@@ -310,10 +319,8 @@ class m_mailTest extends PHPUnit_Framework_TestCase
*/
public function testCreate_alias()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ // Test #1580
+ $this->object->
}
/**
From 492dd25c5ad36de404b0e68f3c1ccec2d68bc379 Mon Sep 17 00:00:00 2001
From: alban
Date: Thu, 27 Mar 2014 10:20:26 +0100
Subject: [PATCH 04/17] [fix] unit tests composite datasets
---
phpunit/lib/AlterncTest.php | 18 +++++++++++++-----
phpunit/tests/_datasets/domaines.yml | 18 +++++++++---------
phpunit/tests/bureau/class/m_mailTest.php | 1 -
3 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/phpunit/lib/AlterncTest.php b/phpunit/lib/AlterncTest.php
index 421aa4ae..36faa47c 100644
--- a/phpunit/lib/AlterncTest.php
+++ b/phpunit/lib/AlterncTest.php
@@ -21,13 +21,21 @@ abstract class AlterncTest extends PHPUnit_Extensions_Database_TestCase
* @return \PHPUnit_Extensions_Database_DataSet_YamlDataSet
* @throws \Exception
*/
- public function loadDataSet($file_name)
+ public function loadDataSet($fileList)
{
- $file = PHPUNIT_DATASETS_PATH."/$file_name";
- if( !is_file($file) ){
- throw new \Exception("missing $file");
+ if( !is_array($fileList)){
+ $fileList = array($fileList);
}
- $dataSet = new PHPUnit_Extensions_Database_DataSet_YamlDataSet($file);
+ $datasetList = array();
+ foreach ($fileList as $file_name) {
+ $file = PHPUNIT_DATASETS_PATH."/$file_name";
+ if( !is_file($file) ){
+ throw new \Exception("missing $file");
+ }
+ $dataSet = new PHPUnit_Extensions_Database_DataSet_YamlDataSet($file);
+ $datasetList[] = $dataSet;
+ }
+ $compositeDataSet = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet($datasetList);
return $dataSet;
}
diff --git a/phpunit/tests/_datasets/domaines.yml b/phpunit/tests/_datasets/domaines.yml
index a3f60c96..17399e98 100644
--- a/phpunit/tests/_datasets/domaines.yml
+++ b/phpunit/tests/_datasets/domaines.yml
@@ -1,11 +1,11 @@
domaines:
-
- id : 1
- compte : 2001
- domaine : example.tld
- gesdns : 1
- gesmx : 1
- noerase : 0
- dns_action : OK
- dns_result : 0
- zonettl : 86400
+ id : 1
+ compte : 2001
+ domaine : example.tld
+ gesdns : 1
+ gesmx : 1
+ noerase : 0
+ dns_action : OK
+ dns_result : 0
+ zonettl : 86400
diff --git a/phpunit/tests/bureau/class/m_mailTest.php b/phpunit/tests/bureau/class/m_mailTest.php
index 258f177e..abc11a81 100644
--- a/phpunit/tests/bureau/class/m_mailTest.php
+++ b/phpunit/tests/bureau/class/m_mailTest.php
@@ -320,7 +320,6 @@ class m_mailTest extends AlterncTest
public function testCreate_alias()
{
// Test #1580
- $this->object->
}
/**
From 93a4123489d2520061fdeaf5e1925ccfe7000fb8 Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 27 Mar 2014 09:23:39 +0000
Subject: [PATCH 05/17] Fix #1580
---
bureau/class/m_mail.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/bureau/class/m_mail.php b/bureau/class/m_mail.php
index 6673b404..5ebb1569 100644
--- a/bureau/class/m_mail.php
+++ b/bureau/class/m_mail.php
@@ -669,6 +669,7 @@ ORDER BY
$db->query("UPDATE mailbox SET quota=".intval($quotamb)." WHERE address_id=".$mail_id.";");
}
+ $recipients=preg_replace('/[\r\t\s]/', "\n", $recipients); // Handle space AND new line
$r=explode("\n",$recipients);
$red="";
foreach($r as $m) {
From 8d59c84598f6c66112dc1b7bfcee977f64c5a820 Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 27 Mar 2014 09:50:46 +0000
Subject: [PATCH 06/17] Favicon devient configurable
---
bureau/admin/head.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/bureau/admin/head.php b/bureau/admin/head.php
index 04badcfd..4e4d031e 100644
--- a/bureau/admin/head.php
+++ b/bureau/admin/head.php
@@ -37,14 +37,17 @@ if (!isset($charset) || ! $charset) $charset="UTF-8";
if (file_exists("styles/style-custom.css") ) {
echo '';
}
+
+$favicon = variable_get('favicon', 'favicon.ico' ,'You can specify a favicon, for example /images/my_logo.ico', array(array('desc'=>'URL','type'=>'string')));
+
?>
-
-
+
+
From 6e7fc679007be4fdc465f8fb9237a61f252defd1 Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 27 Mar 2014 09:57:34 +0000
Subject: [PATCH 07/17] Corrige un bug d'affichage du tableau de variables
---
bureau/class/m_variables.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bureau/class/m_variables.php b/bureau/class/m_variables.php
index 19efe050..942b5fcf 100644
--- a/bureau/class/m_variables.php
+++ b/bureau/class/m_variables.php
@@ -134,7 +134,7 @@ class m_variables {
case 'DEFAULT':
// $variables = $this->variable_merge(array(),$arr_var['DEFAULT'][NULL]);
- $variablesList = current($arr_var["DEFAULT"]);
+ $variablesList = current($arr_var["DEFAULT"]);
$variables = $this->variable_merge(array(),$variablesList);
break;
case 'GLOBAL':
@@ -372,7 +372,7 @@ class m_variables {
$output = "";
if (isset($tab[$strata][$id][$varname]['value'])) {
$v = $tab[$strata][$id][$varname]['value'];
- $output .= $this->display_valueraw_html($v, $varname);
+ $output .= $this->display_valueraw_html($v, $varname, false);
} else {
$output .= ""._("None defined")."";
}
From 0dbd16bbbd59dae056bffc21083748a1e0936aac Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 27 Mar 2014 10:03:48 +0000
Subject: [PATCH 08/17] Corrige qques pb d'affichage
---
bureau/admin/adm_var_edit.php | 8 ++++----
bureau/admin/adm_variables.php | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/bureau/admin/adm_var_edit.php b/bureau/admin/adm_var_edit.php
index c6a34f6b..7684ae58 100644
--- a/bureau/admin/adm_var_edit.php
+++ b/bureau/admin/adm_var_edit.php
@@ -251,7 +251,7 @@ foreach ( $variables->strata_order as $strata) {
foreach ($allvars['FQDN_CREATOR'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." → ";
- echo ""; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "";
+ echo ""; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "";
edit_var($ttv[$var]);
}
echo "
";
@@ -267,7 +267,7 @@ foreach ( $variables->strata_order as $strata) {
foreach ($allvars['FQDN'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $panel_url[$ttk])." → ";
- echo ""; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "";
+ echo ""; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "";
edit_var($ttv[$var]);
}
echo "
";
@@ -283,7 +283,7 @@ foreach ( $variables->strata_order as $strata) {
foreach ($allvars['CREATOR'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." → ";
- echo ""; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "";
+ echo ""; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "";
edit_var($ttv[$var]);
}
echo "
";
@@ -299,7 +299,7 @@ foreach ( $variables->strata_order as $strata) {
foreach ($allvars['MEMBER'] as $ttk => $ttv ) {
if ( isset($ttv[$var]) && is_array( $ttv[$var])) {
echo sprintf(_("Overwritted by %s"), $members[$ttk]['login'])." → ";
- echo ""; echo $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "";
+ echo ""; $variables->display_valueraw_html($ttv[$var]['value'], $var);echo "";
edit_var($ttv[$var]);
}
echo "
";
diff --git a/bureau/admin/adm_variables.php b/bureau/admin/adm_variables.php
index 714a16ba..7559e5cb 100644
--- a/bureau/admin/adm_variables.php
+++ b/bureau/admin/adm_variables.php
@@ -92,7 +92,7 @@ echo _("See the vars for the account")." ";
echo "";
echo " "._("logged via")." ";
echo " ";
-echo "";
+echo "";
?>
From e63de8a4038af96046665136150cca0d503647e2 Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 27 Mar 2014 11:16:31 +0000
Subject: [PATCH 09/17] Fix spoolsize pour le web
---
.gitattributes | 1 +
etc/alternc/alternc-sudoers | 2 +-
src/quota_get_all | 29 +++++++++++++++++++++++++++++
src/spoolsize.php | 22 ++++++++++++++++------
4 files changed, 47 insertions(+), 7 deletions(-)
create mode 100755 src/quota_get_all
diff --git a/.gitattributes b/.gitattributes
index 0f418af0..a57a8bcb 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -664,6 +664,7 @@ src/quota-warning.sh -text
src/quota_delete -text
src/quota_edit -text
src/quota_get -text
+src/quota_get_all -text
src/quota_init -text
src/rebuild_all_webconf.sh -text
src/sendmail -text
diff --git a/etc/alternc/alternc-sudoers b/etc/alternc/alternc-sudoers
index 2ca01f0b..82baf029 100644
--- a/etc/alternc/alternc-sudoers
+++ b/etc/alternc/alternc-sudoers
@@ -1,2 +1,2 @@
-alterncpanel ALL = NOPASSWD : /usr/bin/quota, /usr/sbin/setquota, /usr/lib/alternc/fixperms.sh, /usr/lib/alternc/mem_add, /usr/lib/alternc/mem_del, /usr/lib/alternc/quota_edit, /usr/lib/alternc/quota_get, /usr/lib/alternc/du.pl, /usr/lib/alternc/update_mails.sh
+alterncpanel ALL = NOPASSWD : /usr/bin/quota, /usr/sbin/setquota, /usr/lib/alternc/fixperms.sh, /usr/lib/alternc/mem_add, /usr/lib/alternc/mem_del, /usr/lib/alternc/quota_edit, /usr/lib/alternc/quota_get, /usr/lib/alternc/du.pl, /usr/lib/alternc/update_mails.sh, /usr/sbin/repquota
vmail ALL = NOPASSWD : /usr/lib/dovecot/deliver
diff --git a/src/quota_get_all b/src/quota_get_all
new file mode 100755
index 00000000..1a07770d
--- /dev/null
+++ b/src/quota_get_all
@@ -0,0 +1,29 @@
+#!/bin/bash
+# List quotas of all users in 3 columns :
+# id used quota
+
+source /etc/alternc/local.sh
+
+#checking if quotas are installed
+command -v /usr/sbin/repquota >/dev/null || { echo "Quotas uninstalled"; exit 0; }
+
+get_quota() {
+ quotadir="$1"
+ if [ "$quotadir" = "/" ] ; then
+ sudo repquota -g -v -n -p "$quotadir" 2>/dev/null || (echo "Error: can't get quota"; exit 1)
+ else
+ sudo repquota -g -v -n -p "$quotadir" 2>/dev/null || get_quota "$(dirname $quotadir)"
+ fi
+}
+
+#Â Some help : this is what we must parse
+# Block limits File limits
+#Group used soft hard grace used soft hard grace
+#----------------------------------------------------------------------
+#root -- 1612116 0 0 96181 0 0
+#adm -- 14532 0 0 226 0 0
+
+get_quota "$ALTERNC_HTML" | egrep "^\#[0-9]+"|while read gid blank bused bsoft bhard bgrace fused fsoft fhard fgrace ; do
+ echo ${gid/\#/} $bused $bhard
+done
+
diff --git a/src/spoolsize.php b/src/spoolsize.php
index cbcef6a0..b5088a77 100644
--- a/src/spoolsize.php
+++ b/src/spoolsize.php
@@ -6,12 +6,22 @@ require_once("/usr/share/alternc/panel/class/config_nochk.php");
global $db;
echo "\n---------------------------\n Generating size-cache for web accounts\n\n";
-$r=mysql_query("SELECT uid,login FROM membres;");
-while ($c=mysql_fetch_array($r)) {
- echo $c["login"]; flush();
- $size=exec("sudo /usr/lib/alternc/du.pl ".ALTERNC_HTML."/".substr($c["login"],0,1)."/".$c["login"]);
- $db->query("REPLACE INTO size_web SET uid='".$c["uid"]."',size='$size';");
- echo " done ($size KB) \n"; flush();
+exec("/usr/lib/alternc/quota_get_all", $list_quota_tmp);
+$list_quota=array();
+foreach ($list_quota_tmp as $qt) {
+ $qt = explode(" ", $qt);
+ $list_quota[$qt[0]] = array('used'=>$qt[1], 'quota'=>$qt[2]);
+}
+
+if ($db->query("SELECT uid,login FROM membres;")) {
+ $db2 = new DB_system();
+ while ($db->next_record()) {
+ if (isset($list_quota[$db->f('uid')])) {
+ $qu=$list_quota[$db->f('uid')];
+ $db2->query("INSERT OR REPLACE INTO size_web SET uid='".intval($db->f('uid'))."',size='".intval($qu['used'])."';");
+ echo $db->f('login')." (".$qu['used']." B)\n";
+ }
+ }
}
echo "\n---------------------------\n Generating size-cache for MySQL databases\n\n";
From 8e93341cd33287bdb9d300541b9395cc7ae39987 Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 27 Mar 2014 13:50:44 +0000
Subject: [PATCH 10/17] Some cosmetics
---
bureau/admin/adm_mxaccount.php | 2 +-
bureau/admin/adm_var_edit.php | 2 +-
bureau/class/class_system_bind.php | 2 +-
bureau/class/m_action.php | 2 +-
bureau/class/m_admin.php | 19 +++++++++++--------
bureau/class/m_bro.php | 4 ++--
bureau/class/m_dom.php | 8 ++++++--
phpunit/lib/AlterncTest.php | 5 ++++-
src/fix_dovecot_quota.php | 3 +++
9 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/bureau/admin/adm_mxaccount.php b/bureau/admin/adm_mxaccount.php
index 6df1875a..408d9145 100644
--- a/bureau/admin/adm_mxaccount.php
+++ b/bureau/admin/adm_mxaccount.php
@@ -51,7 +51,7 @@ if ($newlogin) {
// Add an account
if ($mail->add_slave_account($newlogin,$newpass)) {
$error=_("The requested account address has been created. It is now allowed.");
- $newlogin=false;$newpass=false;
+ $newlogin='';$newpass='';
}
}
diff --git a/bureau/admin/adm_var_edit.php b/bureau/admin/adm_var_edit.php
index 7684ae58..f4c1dc8f 100644
--- a/bureau/admin/adm_var_edit.php
+++ b/bureau/admin/adm_var_edit.php
@@ -138,7 +138,7 @@ function var_input($infotype, $name, $value='') {
break;
case "boolean":
echo ""; // This way, there is allways something send, even if checkbox is unchecked
- echo "";
+ echo "";
break;
default:
echo "WTF ? Dunno what to do with a ".$infotype['type'];
diff --git a/bureau/class/class_system_bind.php b/bureau/class/class_system_bind.php
index cd2ffac9..9596af07 100644
--- a/bureau/class/class_system_bind.php
+++ b/bureau/class/class_system_bind.php
@@ -143,7 +143,7 @@ class system_bind {
*
* @global m_dom $dom
* @param string $domain
- * @return string
+ * @return array
*/
function get_domain_summary($domain=false) {
global $dom;
diff --git a/bureau/class/m_action.php b/bureau/class/m_action.php
index 23b720b9..a1bec46d 100644
--- a/bureau/class/m_action.php
+++ b/bureau/class/m_action.php
@@ -50,7 +50,7 @@ class m_action {
function do_action() {
global $err, $L_INOTIFY_DO_ACTION;
$err->log("action", "do_action");
- if( ! touch($L_INOTIFY_DO_ACTION) ){
+ if( ! @touch($L_INOTIFY_DO_ACTION) ){
return FALSE;
}
return TRUE;
diff --git a/bureau/class/m_admin.php b/bureau/class/m_admin.php
index b592043d..53ee8f88 100644
--- a/bureau/class/m_admin.php
+++ b/bureau/class/m_admin.php
@@ -569,11 +569,11 @@ class m_admin {
* @param int $duration
* @param string $notes
* @param integer $force
- * @param boolean $create_dom
+ * @param string $create_dom
* @param int $db_server_id
* @return boolean Returns FALSE if an error occurs, TRUE if not.
*/
- function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom=false, $db_server_id) {
+ function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom='', $db_server_id) {
global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks,$action;
$err->log("admin","add_mem",$login."/".$mail);
if (!$this->enabled) {
@@ -1135,7 +1135,7 @@ EOF;
function checkalldom() {
global $db,$L_NS1,$L_NS2,$L_MX,$L_PUBLIC_IP;
$checked=array();
- $r=$db->query("SELECT * FROM domaines ORDER BY domaine;");
+ $db->query("SELECT * FROM domaines ORDER BY domaine;");
$dl=array();
while ($db->next_record()) {
$dl[$db->Record["domaine"]]=$db->Record;
@@ -1179,10 +1179,14 @@ EOF;
// Check the IP:
$out=array();
exec("dig +short A ".escapeshellarg($d["sub"].(($d["sub"]!="")?".":"").$c["domaine"]),$out);
- if (!in_array($L_PUBLIC_IP,$out)) {
- $errstr.="subdomain '".$d["sub"]."' don't point to $L_PUBLIC_IP but to ".implode(",",$out)."\n";
- $errno=1;
- }
+ if (! is_array($out)) { // exec dig can fail
+ $errno=1; $errstr.="Fail to get the DNS information. Try again.\n";
+ } else {
+ if (!in_array($L_PUBLIC_IP,$out)) {
+ $errstr.="subdomain '".$d["sub"]."' don't point to $L_PUBLIC_IP but to ".implode(",",$out)."\n";
+ $errno=1;
+ }
+ }
}
}
}
@@ -1362,7 +1366,6 @@ EOF;
global $db,$classes,$hooks;
$tmp1=array();
$tmp2=array();
- $tmp3=array();
$policies=array();
$db->query("SELECT * FROM policy;");
while ($db->next_record()) {
diff --git a/bureau/class/m_bro.php b/bureau/class/m_bro.php
index b25bdeb1..b9afbd11 100644
--- a/bureau/class/m_bro.php
+++ b/bureau/class/m_bro.php
@@ -99,12 +99,12 @@ class m_bro {
* @param string $dir
* @global m_mem $mem
* @param string $dir Dossier absolu que l'on souhaite vérifier
- * @param integer $strip
+ * @param boolean $strip
* @return false|string Retourne le nom du dossier vrifi, relatif au
* dossier de l'utilisateur courant, ventuellement corrig.
* ou FALSE si le dossier n'est pas dans le dossier de l'utilisateur.
*/
- function convertabsolute($dir,$strip=1) {
+ function convertabsolute($dir,$strip=true) {
global $mem;
$root=$this->get_user_root($mem->user["login"]);
// Sauvegarde du chemin de base.
diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php
index 3fce3abb..cadb44b3 100644
--- a/bureau/class/m_dom.php
+++ b/bureau/class/m_dom.php
@@ -435,7 +435,7 @@ class m_dom {
$this->lock();
// function add_domain($domain,$dns,$noerase=0,$force=0,$isslave=0,$slavedom="")
- if (! $this->add_domain($domain, true, false, 1) ) {
+ if (! $this->add_domain($domain, true, false, true) ) {
$err->raise('dom', "Error adding domain");
return false;
}
@@ -652,7 +652,7 @@ class m_dom {
* force ne devrait être utilisé que par le super-admin.
$ @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
*/
- function add_domain($domain,$dns,$noerase=0,$force=0,$isslave=0,$slavedom="") {
+ function add_domain($domain,$dns,$noerase=false,$force=false,$isslave=false,$slavedom="") {
global $db,$err,$quota,$classes,$L_MX,$L_FQDN,$tld,$cuid,$bro,$hooks;
$err->log("dom","add_domain",$domain);
@@ -1608,6 +1608,10 @@ class m_dom {
return $res;
}
+ /**
+ *
+ * @return array
+ */
function get_domain_all_summary() {
global $db,$err;
$res=array();
diff --git a/phpunit/lib/AlterncTest.php b/phpunit/lib/AlterncTest.php
index 36faa47c..a2188044 100644
--- a/phpunit/lib/AlterncTest.php
+++ b/phpunit/lib/AlterncTest.php
@@ -23,6 +23,9 @@ abstract class AlterncTest extends PHPUnit_Extensions_Database_TestCase
*/
public function loadDataSet($fileList)
{
+ if (empty($fileList)) {
+ throw new \Exception("No files specified");
+ }
if( !is_array($fileList)){
$fileList = array($fileList);
}
@@ -41,4 +44,4 @@ abstract class AlterncTest extends PHPUnit_Extensions_Database_TestCase
-}
\ No newline at end of file
+}
diff --git a/src/fix_dovecot_quota.php b/src/fix_dovecot_quota.php
index 668788f0..9095e8c5 100755
--- a/src/fix_dovecot_quota.php
+++ b/src/fix_dovecot_quota.php
@@ -25,6 +25,8 @@ if ( $nb != 1 ){
}
#we check that for that type only one option is specified
+# FIXME je doute que ca fasse un truc pertinent ce morceau
+$nb2=0;
foreach($options as $opt => $val){
$nb2=count($options[$opt]);
}
@@ -61,6 +63,7 @@ function FixQuotaDovecot($conditions){
}
#We construct a sql query to get the mailbox root based on the option.
+// FIXME where does $opt come from ??
switch($opt){
case "m":
if (!filter_var($val,FILTER_VALIDATE_EMAIL)) {
From 0729df438ed14b21ac670f1aec8b0ddada12d2bb Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 27 Mar 2014 14:17:02 +0000
Subject: [PATCH 11/17] Cosmetics
---
bureau/class/m_bro.php | 38 +++++++++++++++++++-------------------
bureau/class/m_dom.php | 6 +++---
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/bureau/class/m_bro.php b/bureau/class/m_bro.php
index b9afbd11..838f33d7 100644
--- a/bureau/class/m_bro.php
+++ b/bureau/class/m_bro.php
@@ -200,7 +200,7 @@ class m_bro {
function filelist($dir="", $showdirsize = false) {
global $db,$cuid,$err;
$db->query("UPDATE browser SET lastdir='$dir' WHERE uid='$cuid';");
- $absolute=$this->convertabsolute($dir,0);
+ $absolute=$this->convertabsolute($dir,false);
if (!$absolute || !file_exists($absolute)) {
$err->raise('bro',_("This directory do not exist"));
return false;
@@ -391,7 +391,7 @@ class m_bro {
function CreateDir($dir,$file) {
global $db,$cuid,$err;
$file=ssla($file);
- $absolute=$this->convertabsolute($dir."/".$file,0);
+ $absolute=$this->convertabsolute($dir."/".$file,false);
#echo "$absolute";
if ($absolute && (!file_exists($absolute))) {
if (!mkdir($absolute,00777,true)) {
@@ -420,7 +420,7 @@ class m_bro {
function CreateFile($dir,$file) {
global $db,$err,$cuid;
$file=ssla($file);
- $absolute=$this->convertabsolute($dir."/".$file,0);
+ $absolute=$this->convertabsolute($dir."/".$file,false);
if (!$absolute || file_exists($absolute)) {
$err->raise("bro",_("File or folder name is incorrect"));
return false;
@@ -448,7 +448,7 @@ class m_bro {
function DeleteFile($file_list,$R) {
global $err, $mem;
$root=realpath(getuserpath());
- $absolute=$this->convertabsolute($R,0);
+ $absolute=$this->convertabsolute($R,false);
if (!$absolute && strpos($root,$absolute) === 0 && strlen($absolute) > (strlen($root)+1) ) {
$err->raise("bro",_("File or folder name is incorrect"));
return false;
@@ -474,7 +474,7 @@ class m_bro {
*/
function RenameFile($R,$old,$new) {
global $err;
- $absolute=$this->convertabsolute($R,0);
+ $absolute=$this->convertabsolute($R,false);
if (!$absolute) {
$err->raise("bro",_("File or folder name is incorrect"));
return false;
@@ -508,7 +508,7 @@ class m_bro {
*/
function MoveFile($d,$old,$new) {
global $err;
- $old=$this->convertabsolute($old,0);
+ $old=$this->convertabsolute($old,false);
if (!$old) {
$err->raise("bro",_("File or folder name is incorrect"));
return false;
@@ -517,7 +517,7 @@ class m_bro {
if ($new[0] != '/') {
$new = $old . '/' . $new;
}
- $new = $this->convertabsolute($new,0);
+ $new = $this->convertabsolute($new,false);
if (!$new) {
$err->raise("bro",_("File or folder name is incorrect"));
@@ -548,7 +548,7 @@ class m_bro {
*/
function ChangePermissions($R,$d,$perm,$verbose=false) {
global $err;
- $absolute=$this->convertabsolute($R,0);
+ $absolute=$this->convertabsolute($R,false);
if (!$absolute) {
$err->raise("bro",_("File or folder name is incorrect"));
return false;
@@ -591,7 +591,7 @@ class m_bro {
*/
function UploadFile($R) {
global $_FILES,$err,$cuid,$action;
- $absolute=$this->convertabsolute($R,0);
+ $absolute=$this->convertabsolute($R,false);
if (!$absolute) {
$err->raise("bro",_("File or folder name is incorrect"));
return false;
@@ -647,11 +647,11 @@ class m_bro {
*/
function ExtractFile($file, $dest=null) {
global $err,$cuid,$mem,$action;
- $file = $this->convertabsolute($file,0);
+ $file = $this->convertabsolute($file,false);
if (is_null($dest)) {
$dest = dirname($file);
} else {
- $dest = $this->convertabsolute($dest,0);
+ $dest = $this->convertabsolute($dest,false);
}
if (!$file || !$dest) {
$err->raise("bro",_("File or folder name is incorrect"));
@@ -696,12 +696,12 @@ class m_bro {
*/
function CopyFile($d,$old,$new) {
global $err;
- $old=$this->convertabsolute($old,0);
+ $old=$this->convertabsolute($old,false);
if (!$old) {
$err->raise("bro",_("File or folder name is incorrect"));
return false;
}
- $new=$this->convertabsolute($new,0);
+ $new=$this->convertabsolute($new,false);
if (!$new) {
$err->raise("bro",_("File or folder name is incorrect"));
return false;
@@ -757,7 +757,7 @@ class m_bro {
* @return string Le code HTML ainsi obtenu.
*/
function PathList($path,$action, $justparent=false) {
- $path=$this->convertabsolute($path,1);
+ $path=$this->convertabsolute($path,true);
$a=explode("/",$path);
if (!is_array($a)) $a=array($a);
$c='';
@@ -789,7 +789,7 @@ class m_bro {
*/
function content($R,$file) {
global $err;
- $absolute=$this->convertabsolute($R,0);
+ $absolute=$this->convertabsolute($R,false);
if (!strpos($file,"/")) {
$absolute.="/".$file;
if (file_exists($absolute)) {
@@ -987,7 +987,7 @@ class m_bro {
*/
function save($file,$R,$texte) {
global $err;
- $absolute=$this->convertabsolute($R,0);
+ $absolute=$this->convertabsolute($R,false);
if (!strpos($file,"/")) {
$absolute.="/".$file;
if (file_exists($absolute)) {
@@ -1015,7 +1015,7 @@ class m_bro {
header("Content-Disposition: attachment; filename=".$mem->user["login"].".Z");
header("Content-Type: application/x-Z");
header("Content-Transfer-Encoding: binary");
- $d=escapeshellarg(".".$this->convertabsolute($dir,1));
+ $d=escapeshellarg(".".$this->convertabsolute($dir,true));
set_time_limit(0);
passthru("/bin/tar -cZ -C ".getuserpath()."/".$mem->user["login"]."/ $d");
}
@@ -1033,7 +1033,7 @@ class m_bro {
header("Content-Disposition: attachment; filename=".$mem->user["login"].".tgz");
header("Content-Type: application/x-tgz");
header("Content-Transfer-Encoding: binary");
- $d=escapeshellarg(".".$this->convertabsolute($dir,1));
+ $d=escapeshellarg(".".$this->convertabsolute($dir,true));
set_time_limit(0);
passthru("/bin/tar -cz -C ".getuserpath()."/ $d");
}
@@ -1051,7 +1051,7 @@ class m_bro {
header("Content-Disposition: attachment; filename=".$mem->user["login"].".tar.bz2");
header("Content-Type: application/x-bzip2");
header("Content-Transfer-Encoding: binary");
- $d=escapeshellarg(".".$this->convertabsolute($dir,1));
+ $d=escapeshellarg(".".$this->convertabsolute($dir,true));
set_time_limit(0);
passthru("/bin/tar -cj -C ".getuserpath()."/ $d");
}
diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php
index cadb44b3..524d610d 100644
--- a/bureau/class/m_dom.php
+++ b/bureau/class/m_dom.php
@@ -646,9 +646,9 @@ class m_dom {
* appellée lors de l'installation d'un nouveau domaine.
*
* @param string $dom nom fqdn du domaine à installer
- * @param integer $dns 1 ou 0 pour héberger le DNS du domaine ou pas.
- * @param integer $noerase 1 ou 0 pour rendre le domaine inamovible ou non
- * @param integer $force 1 ou 0, si 1, n'effectue pas les tests de DNS.
+ * @param boolean $dns 1 ou 0 pour héberger le DNS du domaine ou pas.
+ * @param boolean $noerase 1 ou 0 pour rendre le domaine inamovible ou non
+ * @param boolean $force 1 ou 0, si 1, n'effectue pas les tests de DNS.
* force ne devrait être utilisé que par le super-admin.
$ @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
*/
From ec8d8b1344c16db9d3bea95b261f247b1cfac96d Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 27 Mar 2014 15:04:30 +0000
Subject: [PATCH 12/17] Premier jet pour ROundcube avec l'utilisateur apache
normal
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Résoud les pb d'upgrade et de cron
---
.gitattributes | 1 -
roundcube/roundcube-install | 18 +----
roundcube/templates/apache2/roundcube.conf | 70 +++++++++----------
.../templates/logrotate.d/roundcube-core | 15 ----
4 files changed, 36 insertions(+), 68 deletions(-)
delete mode 100644 roundcube/templates/logrotate.d/roundcube-core
diff --git a/.gitattributes b/.gitattributes
index a57a8bcb..5cdc900d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -615,7 +615,6 @@ roundcube/class/m_roundcube.php -text
roundcube/roundcube-install -text
roundcube/roundcube_alternc_logo.png -text
roundcube/templates/apache2/roundcube.conf -text
-roundcube/templates/logrotate.d/roundcube-core -text
roundcube/templates/roundcube/main.inc.php -text
roundcube/templates/roundcube/plugins/managesieve/config.inc.php -text
roundcube/templates/roundcube/plugins/password/config.inc.php -text
diff --git a/roundcube/roundcube-install b/roundcube/roundcube-install
index f2613a8c..de12c6c9 100644
--- a/roundcube/roundcube-install
+++ b/roundcube/roundcube-install
@@ -28,7 +28,7 @@ then
# cp -f /etc/alternc/templates/roundcube/avelsieve-config.php /etc/alternc/templates/roundcube/apache.conf /etc/roundcube/
# cp -f /etc/alternc/templates/javascript-common/javascript-common.conf /etc/javascript-common/
- LOGIN="2000_roundcube"
+ LOGIN="0000_roundcube"
PASSWORD="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)'`"
DESKEY="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..24)'`"
@@ -40,7 +40,6 @@ then
# Configuration template location
TEMPLATE_DIR="/etc/alternc/templates"
CONFIG_FILES="etc/roundcube/main.inc.php etc/roundcube/plugins/password/config.inc.php etc/roundcube/plugins/managesieve/config.inc.php"
- LOGROTATE_FILES="etc/logrotate.d/roundcube-core"
cat > $SED_SCRIPT < /$file
- fi
- done
-
echo " Done"
. /usr/lib/alternc/functions.sh
@@ -99,10 +90,3 @@ EOF
fi
-#This is necessary because upgrading roundcube from 7.1 to 7.2 changes this setting
-if [ "$1" = "end" ]; then
- chown alternc-roundcube:root /etc/roundcube/main.inc.php
-fi
-
-
-
diff --git a/roundcube/templates/apache2/roundcube.conf b/roundcube/templates/apache2/roundcube.conf
index 1f6b46a5..cf762418 100644
--- a/roundcube/templates/apache2/roundcube.conf
+++ b/roundcube/templates/apache2/roundcube.conf
@@ -1,46 +1,46 @@
ServerName %%fqdn%%
- AssignUserId alternc-roundcube nogroup
- SetEnv LOGIN "%%UID%%-%%LOGIN%%"
+ AssignUserId www-data www-data
+ SetEnv LOGIN "0000-roundcube"
DocumentRoot /var/lib/roundcube
-# Access to tinymce files
-
- Options Indexes MultiViews FollowSymLinks
- AllowOverride None
- Order allow,deny
- allow from all
-
-
-
- Options +FollowSymLinks
- # This is needed to parse /var/lib/roundcube/.htaccess. See its
- # content before setting AllowOverride to None.
- AllowOverride All
- order allow,deny
- allow from all
-
-
-# Protecting basic directories:
-
- Options -FollowSymLinks
+ # Access to tinymce files
+
+ Options Indexes MultiViews FollowSymLinks
AllowOverride None
-
+ Order allow,deny
+ allow from all
+
-
- Options -FollowSymLinks
- AllowOverride None
- Order allow,deny
- Deny from all
-
+
+ Options +FollowSymLinks
+ # This is needed to parse /var/lib/roundcube/.htaccess. See its
+ # content before setting AllowOverride to None.
+ AllowOverride All
+ order allow,deny
+ allow from all
+
-
- Options -FollowSymLinks
- AllowOverride None
- Order allow,deny
- Deny from all
-
+ # Protecting basic directories:
+
+ Options -FollowSymLinks
+ AllowOverride None
+
+
+
+ Options -FollowSymLinks
+ AllowOverride None
+ Order allow,deny
+ Deny from all
+
+
+
+ Options -FollowSymLinks
+ AllowOverride None
+ Order allow,deny
+ Deny from all
+
Alias /javascript /usr/share/javascript/
diff --git a/roundcube/templates/logrotate.d/roundcube-core b/roundcube/templates/logrotate.d/roundcube-core
deleted file mode 100644
index c5a9e8f6..00000000
--- a/roundcube/templates/logrotate.d/roundcube-core
+++ /dev/null
@@ -1,15 +0,0 @@
-######
-# Configuration file of Roundcube's logrotate for AlternC
-#
-# /!\ WARNING /!\ Do not edit this file, edit the one in
-# /etc/alternc/templates/logrotate.d/ and launch alternc.install again.
-######
-
-/var/log/roundcube/password /var/log/roundcube/errors /var/log/roundcube/sendmail /var/log/roundcube/userlogins {
- create 0640 alternc-roundcube root
- compress
- missingok
- notifempty
- rotate 52
- weekly
-}
From b2eb4e3016e8caae3024dd63b43380931ccf5907 Mon Sep 17 00:00:00 2001
From: alban
Date: Thu, 27 Mar 2014 16:02:52 +0100
Subject: [PATCH 13/17] [fix] adds missing global
---
phpunit/bootstrap.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php
index df86f135..f9d459c9 100644
--- a/phpunit/bootstrap.php
+++ b/phpunit/bootstrap.php
@@ -156,4 +156,4 @@ $mem = new \m_mem();
$err = new \m_err();
$authip = new \m_authip();
$hooks = new \m_hooks();
-
+$bro = new \m_bro();
From 590223878ebf4a81583428ac61fb6fc9fe3d54b3 Mon Sep 17 00:00:00 2001
From: alban
Date: Thu, 27 Mar 2014 16:03:34 +0100
Subject: [PATCH 14/17] [fix] #1545 htaccess files
---
bureau/admin/hta_del.php | 9 +++---
phpunit/tests/bureau/class/m_htaTest.php | 35 ++++++++++++++++++++----
2 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/bureau/admin/hta_del.php b/bureau/admin/hta_del.php
index 52ffe975..48a7e9ea 100644
--- a/bureau/admin/hta_del.php
+++ b/bureau/admin/hta_del.php
@@ -35,11 +35,12 @@ reset($_POST);
while (list($key,$val)=each($_POST)) {
if (substr($key,0,4)=="del_") {
// Effacement du dossier $val
- $r=$hta->DelDir($val);
- if (!$r) {
- $error.=$err->errstr()."
";
+// $r=$hta->DelDir($val);
+ $return = $hta->DelDir($val);
+ if (!$return) {
+ $error.= $err->errstr()."
";
} else {
- $error.=sprintf(_("The protected folder %s has been successfully unprotected"),$val)."
";
+ $error.= sprintf(_("The protected folder %s has been successfully unprotected"),$val)."
";
}
}
}
diff --git a/phpunit/tests/bureau/class/m_htaTest.php b/phpunit/tests/bureau/class/m_htaTest.php
index fe2a6a68..25ecbda6 100644
--- a/phpunit/tests/bureau/class/m_htaTest.php
+++ b/phpunit/tests/bureau/class/m_htaTest.php
@@ -9,6 +9,9 @@ class m_htaTest extends PHPUnit_Framework_TestCase
*/
protected $object;
+ const PATH_HTACCESS = "/tmp/.htaccess";
+ const PATH_HTPASSWD = "/tmp/.htpasswd";
+
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
@@ -16,6 +19,10 @@ class m_htaTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
parent::setUp();
+ touch(self::PATH_HTACCESS);
+ touch(self::PATH_HTPASSWD);
+ $file_content = "AuthUserFile \"/tmp/.htpasswd\"\nAuthName \"Restricted area\"\nAuthType Basic\nrequire valid-user\n";
+ file_put_contents(self::PATH_HTACCESS,$file_content);
$this->object = new m_hta;
}
@@ -26,6 +33,12 @@ class m_htaTest extends PHPUnit_Framework_TestCase
protected function tearDown()
{
parent::tearDown();
+ if(file_exists(self::PATH_HTACCESS)){
+ unlink (self::PATH_HTACCESS);
+ }
+ if(file_exists(self::PATH_HTPASSWD)){
+ unlink (self::PATH_HTPASSWD);
+ }
}
/**
@@ -114,14 +127,26 @@ class m_htaTest extends PHPUnit_Framework_TestCase
/**
* @covers m_hta::DelDir
- * @todo Implement testDelDir().
*/
public function testDelDir()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $result = $this->object->DelDir("/tmp",TRUE);
+ $this->assertTrue($result);
+ $this->assertFileNotExists(self::PATH_HTACCESS);
+ $this->assertFileNotExists(self::PATH_HTPASSWD);
+ }
+
+ /**
+ * @covers m_hta::DelDir
+ */
+ public function testDelDirNotEmpty()
+ {
+ file_put_contents(self::PATH_HTACCESS, "\nphpunit", FILE_APPEND);
+ $result = $this->object->DelDir("/tmp",TRUE);
+ $this->assertTrue($result);
+ $this->assertFileExists(self::PATH_HTACCESS);
+ $this->assertFileNotExists(self::PATH_HTPASSWD);
+ $this->assertTrue("phpunit" == trim(file_get_contents(self::PATH_HTACCESS)));
}
/**
From 0f48d94c04e7e7909ca1c047c573ff0b35bb9443 Mon Sep 17 00:00:00 2001
From: alban
Date: Thu, 27 Mar 2014 16:04:21 +0100
Subject: [PATCH 15/17] =?UTF-8?q?[fix]=C2=A0cosmetic=20changes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
bureau/class/functions.php | 191 +++++++++-----------
bureau/class/m_bro.php | 348 +++++++++++++++++++------------------
bureau/class/m_hta.php | 247 ++++++++++++++++----------
3 files changed, 421 insertions(+), 365 deletions(-)
diff --git a/bureau/class/functions.php b/bureau/class/functions.php
index c099c315..892061b2 100644
--- a/bureau/class/functions.php
+++ b/bureau/class/functions.php
@@ -44,7 +44,7 @@ function fl($str) { return str_replace("<","<",str_replace("\"",""",$str
* @param struing $type
* @return mixed
*/
-function variable_get($name, $default = null, $createit_comment = null, $type=null) {
+function variable_get($name, $default = null, $createit_comment = null, $type = null) {
global $variables;
return $variables->variable_get($name, $default, $createit_comment, $type);
}
@@ -66,16 +66,16 @@ function variable_get($name, $default = null, $createit_comment = null, $type=nu
*/
function checkhostallow($domain,$dns) {
global $L_NS1,$L_NS2,$db,$dom;
- $sizefound=0;
- $found="";
+ $sizefound = 0;
+ $found = "";
$db->query("SELECT tld,mode FROM tld;");
while ($db->next_record()) {
- list($key,$val)=$db->Record;
+ list($key,$val) = $db->Record;
if (substr($domain,-1-strlen($key))==".".$key) {
if ($sizefound2) // OK, in the case 3 4 5
return $found;
- $n1=false; $n2=false;
- for ($i=0;$iquery("SELECT tld,mode FROM tld;");
while ($db->next_record()) {
- list($key,$val)=$db->Record;
+ list($key,$val) = $db->Record;
if (substr($domain,-1-strlen($key))==".".$key) {
if ($sizefound255)
return 1;
- $members=explode(".", $fqdn);
- if (count($members)>1) $ret=0; else $ret=4;
+ $members = explode(".", $fqdn);
+ if (count($members)>1) $ret = 0; else $ret = 4;
reset($members);
while (list ($key, $val) = each ($members)) {
if (strlen($val)>63)
@@ -262,10 +262,10 @@ function checkfqdn($fqdn) {
*/
function checkuserpath($path) {
global $mem;
- $user=$mem->user["login"];
- $usar=substr($user,0,1);
+ $user = $mem->user["login"];
+ $usar = substr($user,0,1);
if (substr($path,0,1)!="/")
- $path="/".$path;
+ $path = "/".$path;
$rpath = realpath(ALTERNC_HTML."/$usar/$user$path");
if (!$rpath) { // if file or directory does not exist
@@ -310,7 +310,7 @@ function cbox($test, $echo = TRUE) {
if ($test) {
$return = " checked=\"checked\"";
} else {
- $return='';
+ $return = '';
}
if( $echo ){
echo $return;
@@ -331,7 +331,7 @@ function selected($bool, $echo = TRUE) {
if ($bool) {
$return = " selected=\"selected\"";
} else {
- $return='';
+ $return = '';
}
if( $echo ){
echo $return;
@@ -347,7 +347,7 @@ function selected($bool, $echo = TRUE) {
* @param integer $affiche
* @return string
*/
-function ecif($test,$tr,$fa="",$affiche=1) {
+function ecif($test,$tr,$fa = "",$affiche = 1) {
if ($test){
$retour = $tr;
}
@@ -375,7 +375,7 @@ function __($str) {
* @param string $fa
* @return string
*/
-function ife($test,$tr,$fa="") {
+function ife($test,$tr,$fa = "") {
if ($test){
return $tr;
}
@@ -388,33 +388,33 @@ function ife($test,$tr,$fa="") {
* @param integer $html
* @return string
*/
-function format_size($size,$html=0) {
+function format_size($size,$html = 0) {
// Retourne une taille formatt�e en Octets, Kilo-octets, M�ga-octets ou Giga-Octets, avec 2 d�cimales.
if ("-" == $size) {
return $size;
}
- $size=(float)$size;
+ $size = (float)$size;
if ($size<1024) {
- $r=$size;
+ $r = $size;
if ($size!=1) {
$r.=" "._("Bytes");
} else {
$r.=" "._("Byte");
}
} else {
- $size=$size/1024;
+ $size = $size/1024;
if ($size<1024) {
- $r=round($size,2)." "._("Kb");
+ $r = round($size,2)." "._("Kb");
} else {
- $size=$size/1024;
+ $size = $size/1024;
if ($size<1024) {
- $r=round($size,2)." "._("Mb");
+ $r = round($size,2)." "._("Mb");
} else {
- $size=$size/1024;
+ $size = $size/1024;
if ($size<1024) {
- $r=round($size,2)." "._("Gb");
+ $r = round($size,2)." "._("Gb");
} else {
- $r=round($size/1024,2)." "._("Tb");
+ $r = round($size/1024,2)." "._("Tb");
}
}
}
@@ -448,17 +448,17 @@ function linkhelp($hid) {
* @return string
*/
function format_date($format,$date) {
- $d=substr($date,8,2);
- $m=substr($date,5,2);
- $y=substr($date,0,4);
- $h=substr($date,11,2);
- $i=substr($date,14,2);
+ $d = substr($date,8,2);
+ $m = substr($date,5,2);
+ $y = substr($date,0,4);
+ $h = substr($date,11,2);
+ $i = substr($date,14,2);
if ($h>12) {
- $hh=$h-12;
- $am="pm";
+ $hh = $h-12;
+ $am = "pm";
} else {
- $hh=$h;
- $am="am";
+ $hh = $h;
+ $am = "am";
}
return sprintf($format,$d,$m,$y,$h,$i,$hh,$am);
}
@@ -482,13 +482,13 @@ function ssla($str) {
* @return string Retourne le mot de passe crypt�
* @access private
*/
- function _md5cr($pass,$salt="") {
+ function _md5cr($pass,$salt = "") {
if (!$salt) {
- $chars="./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- for ($i=0;$i<12;$i++) {
+ $chars = "./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ for ($i = 0;$i<12;$i++) {
$salt.=substr($chars,(mt_rand(0,strlen($chars))),1);
}
- $salt="$1$".$salt;
+ $salt = "$1$".$salt;
}
return crypt($pass,$salt);
}
@@ -536,7 +536,7 @@ function pretty_months($months) {
* @return string Code html pour le drop-down
* @access private
*/
-function duration_list($name, $selected=0) {
+function duration_list($name, $selected = 0) {
$res = "