diff --git a/bureau/admin/bro_main.php b/bureau/admin/bro_main.php
index d4483642..3c133057 100644
--- a/bureau/admin/bro_main.php
+++ b/bureau/admin/bro_main.php
@@ -361,13 +361,13 @@ function actmoveto_not_empty() {
} else {
echo "
";
}
- $e = $bro->is_extractable($R,$c[$i]["name"]);
+ $e = $bro->is_extractable($c[$i]["name"]);
if ($e) {
echo " ";
echo _("Extract");
echo "";
}
- $ez = $bro->is_sqlfile($R,$c[$i]["name"]);
+ $ez = $bro->is_sqlfile($c[$i]["name"]);
if ($ez) {
echo " ";
echo _("Restore SQL");
diff --git a/bureau/class/m_bro.php b/bureau/class/m_bro.php
index 20a53ccc..8835a695 100644
--- a/bureau/class/m_bro.php
+++ b/bureau/class/m_bro.php
@@ -894,11 +894,10 @@ class m_bro {
/**
* Return a HTML snippet representing an extraction function only if the mimetype of $name is supported
*
- * @param string $dir
* @param string $name
* @return boolean
*/
- function is_extractable($dir,$name) {
+ function is_extractable($name) {
if ($parts = explode(".", $name)) {
$ext = array_pop($parts);
switch ($ext) {
@@ -929,10 +928,10 @@ class m_bro {
* @param type $name
* @return boolean
*/
- function is_sqlfile($dir,$name) {
+ function is_sqlfile($name) {
if ($parts = explode(".", $name)) {
- $ext = array_pop($parts);
- $ext2 = array_pop($parts) . '.'.$ext;
+ $ext = array_pop($parts);
+ $ext2 = array_pop($parts) . '.'.$ext;
if ( $ext == 'sql' or $ext2 == 'sql.gz') return true;
}
return false;
diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php
index 7838da80..6dcc8283 100644
--- a/bureau/class/m_dom.php
+++ b/bureau/class/m_dom.php
@@ -180,6 +180,9 @@ class m_dom {
return $r;
}
+ /**
+ * @param integer $type
+ */
function domains_type_target_values($type = null) {
global $db, $err, $cuid;
$err->log("dom", "domains_type_target_values");
@@ -825,6 +828,9 @@ class m_dom {
}
}
+ /**
+ * @param string $domain
+ */
function domdefaultdir($domain) {
global $bro, $cuid;
$dest_root = $bro->get_userid_root($cuid);
@@ -1476,7 +1482,7 @@ class m_dom {
$domaine = $this->get_domain_byid($dom_id);
$d = $this->get_domain_all($domaine);
- $j = $this->edit_domain($domaine, $d['dns'], $d['mail'], 0, $ttl);
+ $j = $this->edit_domain($domaine, $d['dns'], $d['mail'], false, $ttl);
$this->unlock();
return $j;
}
diff --git a/bureau/class/m_ftp.php b/bureau/class/m_ftp.php
index 598a574d..48f7c2ce 100644
--- a/bureau/class/m_ftp.php
+++ b/bureau/class/m_ftp.php
@@ -205,7 +205,11 @@ class m_ftp {
return $r;
}
- // Check if the login is fine (syntax)
+ /**
+ * Check if the login is fine (syntax)
+ *
+ * @param string $l
+ */
function check_login($l) {
global $err;
@@ -419,7 +423,6 @@ class m_ftp {
/* ----------------------------------------------------------------- */
/** Fonction appellée par membres quand un membre est effacé.
- * @param integer $uid Numéro de membre effacé.
* @access private
*/
function alternc_del_member() {
diff --git a/bureau/class/m_mem.php b/bureau/class/m_mem.php
index b48b60a8..aecd7431 100644
--- a/bureau/class/m_mem.php
+++ b/bureau/class/m_mem.php
@@ -209,6 +209,9 @@ class m_mem {
return md5("$i--".$db->f('pass'));
}
+ /**
+ * @param boolean $t
+ */
function authip_tokencheck($t) {
if ($t==$this->authip_token() || $t==$this->authip_token(true) ) return true;
return false;
@@ -234,7 +237,7 @@ class m_mem {
* et AVANT d'émettre des données. (un cookie peut être envoyé)
* @global string $session Le cookie de session eventuel
* @global string $username/password le login/pass de l'utilisateur
- * @return TRUE si la session est correcte, FALSE sinon.
+ * @return boolean TRUE si la session est correcte, FALSE sinon.
*/
function checkid() {
global $db,$err,$cuid,$restrictip,$authip;
@@ -310,7 +313,7 @@ class m_mem {
/* ----------------------------------------------------------------- */
/** Retourne a l'identite d'origine de l'utilisateur apres su.
- * @return TRUE si la session est correcte, FALSE sinon.
+ * @return boolean TRUE si la session est correcte, FALSE sinon.
*/
function unsu() {
global $cuid,$mysql;
@@ -524,7 +527,7 @@ Cordially.
* @param string $COOKIE Cookie envoyé par mail
* @param string $KEY clé affichée à l'écran
* @param integer $uid Utilisateur concerné (on est hors session)
- * @return TRUE si le mail a bien été modifié, FALSE sinon
+ * @return boolean TRUE si le mail a bien été modifié, FALSE sinon
*/
function ChangeMail2($COOKIE,$KEY,$uid) {
global $err,$db,$L_HOSTING,$L_FQDN;
@@ -567,7 +570,7 @@ Cordially.
/* ----------------------------------------------------------------- */
/** Affiche (echo) l'aide contextuelle
* @param integer $file Numéro de fichier d'aide à afficher.
- * @return TRUE si l'aide contextuelle a été trouvée, FALSE sinon
+ * @return boolean TRUE si l'aide contextuelle a été trouvée, FALSE sinon
*/
function show_help($file,$force=false) {
global $err;
@@ -586,6 +589,9 @@ Cordially.
}
}
+ /**
+ * @param integer $uid
+ */
function get_creator_by_uid($uid) {
global $db,$err;
$err->log("dom","get_creator_by_uid");
diff --git a/bureau/class/m_variables.php b/bureau/class/m_variables.php
index 8aecf835..06c3dcaf 100644
--- a/bureau/class/m_variables.php
+++ b/bureau/class/m_variables.php
@@ -39,6 +39,11 @@ class m_variables {
var $replace_array = array();
var $cache_conf = array();
+ const TYPE_STRING = "string";
+ const TYPE_BOOLEAN = "boolean";
+ const TYPE_INTEGER = "integer";
+ const TYPE_IP = "ip";
+
/**
*
* @global string $L_FQDN
@@ -170,10 +175,17 @@ class m_variables {
// Replace needed vars
foreach ($variables as $vv => $hh) {
- if (!isset($hh['value']) || empty($hh['value'])) {
- continue;
- }
- $variables[$vv]['value'] = strtr($hh['value'], $this->replace_array );
+ if (!isset($hh['value']) || empty($hh['value'])) {
+ continue;
+ }
+ if( is_array($hh['value'])){
+ foreach($hh["value"] as $key => $val){
+ $variables[$vv]['value'][$key] = strtr($hh['value'][$key], $this->replace_array );
+ }
+ }
+ else{
+ $variables[$vv]['value'] = strtr($hh['value'], $this->replace_array );
+ }
}
if ($var && isset($variables[$var])) {
@@ -199,23 +211,30 @@ class m_variables {
/**
* Return a persistent variable.
*
- * @param string $name
- * The name of the variable to return.
- * @param mixed $default
- * The default value to use if this variable has never been set.
- * @param string $createit_comment
- * If variable doesn't exist, create it with the default value
- * and createit_comment value as comment
- * @return mixed
- * The value of the variable.
+ * @param string $name The name of the variable to return.
+ * @param mixed $default The default value to use if this variable has never been set.
+ * @param string $createit_comment If variable doesn't exist, create it with the default value
+ * and createit_comment value as comment
+ * @param array $type An array defining the variable definition
+ * ex: array("ns1"=>array('desc'=>'ns name','type'=>'string'),"ip"=>array("desc"=>"here an ip", "type"=>"ip")
+ * ex: array('desc'=>'ns name','type'=>'string')
+ * Types can be either
+ * self::TYPE_BOOLEAN
+ * self::TYPE_INTEGER
+ * self::TYPE_IP
+ * self::TYPE_STRING
+ *
+ * @return mixed The value of the variable.
*/
- function variable_get($name, $default = null, $createit_comment = null, $type=null) {
+ function variable_get($name, $default = null, $createit_comment = null, $type = null) {
$this->variable_init_maybe();
- if (isset($this->cache_conf[$name])) {
- return $this->cache_conf[$name]['value'];
- } elseif (!is_null($createit_comment)) {
+ // Attempts to retrieve $name
+ if (array_key_exists("$name", $this->cache_conf) && !is_null($this->cache_conf["$name"])) {
+ return $this->cache_conf["$name"]["value"];
+ }
+ if (!is_null($createit_comment)) {
$this->variable_update_or_create($name, $default, 'DEFAULT', 'null', 'null', $createit_comment, $type);
}
diff --git a/phpunit/tests/_datasets/variables-empty.yml b/phpunit/tests/_datasets/variables-empty.yml
new file mode 100644
index 00000000..34e7ca41
--- /dev/null
+++ b/phpunit/tests/_datasets/variables-empty.yml
@@ -0,0 +1 @@
+variable:
\ No newline at end of file
diff --git a/phpunit/tests/bureau/class/m_variablesTest.php b/phpunit/tests/bureau/class/m_variablesTest.php
index 8e5774e0..4cf6a814 100644
--- a/phpunit/tests/bureau/class/m_variablesTest.php
+++ b/phpunit/tests/bureau/class/m_variablesTest.php
@@ -14,7 +14,19 @@ class m_variablesTest extends AlterncTest
*/
public function getDataSet()
{
- return parent::loadDataSet("variables.yml");
+ $list = array(
+ "testVariable_getNewWayArray" => "variables-empty.yml",
+ "testVariable_getNewWayString" => "variables-empty.yml",
+ "testVariable_getOldWay" => "variables-empty.yml",
+ "default" => "variables.yml"
+ );
+ if (isset($list[$this->getName()])) {
+ $dataset_file = $list[$this->getName()];
+ } else {
+ $dataset_file = "variables.yml";
+ }
+ return parent::loadDataSet($dataset_file);
+
}
/**
@@ -72,22 +84,41 @@ class m_variablesTest extends AlterncTest
{
$result = $this->object->variable_get("phpunit");
$this->assertStringMatchesFormat("phpunit",$result);
+ }
+
+ /**
+ * @covers m_variables::variable_get
+ */
+ public function testVariable_getOldWay()
+ {
-/*
- // Check old way
- $this->object->variable_get('phpunit1', 'toto','plop');
- $result = $this->object->variable_get('phpunit1');
- $this->assertSame("toto",$result);
+ $this->object->variable_get('phpunit', 'phpunit-default','phpunit-comment');
+ $result = $this->object->variable_get('phpunit');
+ $this->assertSame("phpunit-default",$result);
+
+ }
+
+ /**
+ * @covers m_variables::variable_get
+ */
+ public function testVariable_getNewWayString()
+ {
// New way
- $this->object->variable_get('phpunit2', 'here','comment', array('desc'=>'Want a string','type'=>'string'));
- $result = $this->object->variable_get('phpunit2');
- $this->assertSame("here",$result);
-
- $this->object->variable_get('phpunit3', array("ns1"=>'ns1.tld',"ip"=>"1.2.3.4"),'comment', array("ns1"=>array('desc'=>'ns name','type'=>'string'),"ip"=>array("desc"=>"here an ip", "type"=>"ip")));
- $result = $this->object->variable_get('phpunit2');
- $this->assertSame(array('ns1'=>"ns1.tld", "ip"=>"1.2.3.4"),$result);
-*/
+ $this->object->variable_get('phpunit', 'phpunit-default','comment', array('desc'=>'Want a string','type'=>'string'));
+ $result = $this->object->variable_get('phpunit');
+ $this->assertSame("phpunit-default",$result);
+ }
+
+ /**
+ * @covers m_variables::variable_get
+ */
+ public function testVariable_getNewWayArray()
+ {
+ $phpunitArray = array("ns1"=>'ns1.tld',"ip"=>"1.2.3.4");
+ $this->object->variable_get('phpunit', $phpunitArray,'phpunit-comment', array("ns1"=>array('desc'=>'ns name','type'=>'string'),"ip"=>array("desc"=>"here an ip", "type"=>"ip")));
+ $result = $this->object->variable_get('phpunit');
+ $this->assertSame($phpunitArray,$result);
}
/**
diff --git a/src/export_account.php b/src/export_account.php
index 3f21f853..aed1ae1f 100644
--- a/src/export_account.php
+++ b/src/export_account.php
@@ -4,7 +4,7 @@
// EXPERIMENTAL : user data export.
die('Proof of concept');
-include("config.php");
+require_once("/usr/share/alternc/panel/class/config_nochk.php");
sem_release($alternc_sem);
|