Commit 6a632098 authored by Benjamin Sonntag's avatar Benjamin Sonntag

Merge branch 'master' of alternc.org:alternc

parents 9560fd9d 91f8745d
......@@ -361,13 +361,13 @@ function actmoveto_not_empty() {
} else {
echo "<td>&nbsp;";
}
$e = $bro->is_extractable($R,$c[$i]["name"]);
$e = $bro->is_extractable($c[$i]["name"]);
if ($e) {
echo " <a href=\"bro_main.php?actextract=1&amp;fileextract=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R)."\">";
echo _("Extract");
echo "</a>";
}
$ez = $bro->is_sqlfile($R,$c[$i]["name"]);
$ez = $bro->is_sqlfile($c[$i]["name"]);
if ($ez) {
echo " <a href=\"javascript:;\" onClick=\"$('#rest_db_$i').toggle();\">";
echo _("Restore SQL");
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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 appelle par membres quand un membre est effac.
* @param integer $uid Numro de membre effac.
* @access private
*/
function alternc_del_member() {
......
......@@ -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 donnes. (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 affiche 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 Numro de fichier d'aide afficher.
* @return TRUE si l'aide contextuelle a t trouve, FALSE sinon
* @return boolean TRUE si l'aide contextuelle a t trouve, 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");
......
......@@ -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);
}
......
variable:
\ No newline at end of file
......@@ -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);
}
/**
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment