Merge branch 'master' of alternc.org:alternc
This commit is contained in:
commit
6a632098a5
|
@ -361,13 +361,13 @@ function actmoveto_not_empty() {
|
||||||
} else {
|
} else {
|
||||||
echo "<td> ";
|
echo "<td> ";
|
||||||
}
|
}
|
||||||
$e = $bro->is_extractable($R,$c[$i]["name"]);
|
$e = $bro->is_extractable($c[$i]["name"]);
|
||||||
if ($e) {
|
if ($e) {
|
||||||
echo " <a href=\"bro_main.php?actextract=1&fileextract=".urlencode($c[$i]["name"])."&R=".urlencode($R)."\">";
|
echo " <a href=\"bro_main.php?actextract=1&fileextract=".urlencode($c[$i]["name"])."&R=".urlencode($R)."\">";
|
||||||
echo _("Extract");
|
echo _("Extract");
|
||||||
echo "</a>";
|
echo "</a>";
|
||||||
}
|
}
|
||||||
$ez = $bro->is_sqlfile($R,$c[$i]["name"]);
|
$ez = $bro->is_sqlfile($c[$i]["name"]);
|
||||||
if ($ez) {
|
if ($ez) {
|
||||||
echo " <a href=\"javascript:;\" onClick=\"$('#rest_db_$i').toggle();\">";
|
echo " <a href=\"javascript:;\" onClick=\"$('#rest_db_$i').toggle();\">";
|
||||||
echo _("Restore SQL");
|
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
|
* Return a HTML snippet representing an extraction function only if the mimetype of $name is supported
|
||||||
*
|
*
|
||||||
* @param string $dir
|
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function is_extractable($dir,$name) {
|
function is_extractable($name) {
|
||||||
if ($parts = explode(".", $name)) {
|
if ($parts = explode(".", $name)) {
|
||||||
$ext = array_pop($parts);
|
$ext = array_pop($parts);
|
||||||
switch ($ext) {
|
switch ($ext) {
|
||||||
|
@ -929,10 +928,10 @@ class m_bro {
|
||||||
* @param type $name
|
* @param type $name
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function is_sqlfile($dir,$name) {
|
function is_sqlfile($name) {
|
||||||
if ($parts = explode(".", $name)) {
|
if ($parts = explode(".", $name)) {
|
||||||
$ext = array_pop($parts);
|
$ext = array_pop($parts);
|
||||||
$ext2 = array_pop($parts) . '.'.$ext;
|
$ext2 = array_pop($parts) . '.'.$ext;
|
||||||
if ( $ext == 'sql' or $ext2 == 'sql.gz') return true;
|
if ( $ext == 'sql' or $ext2 == 'sql.gz') return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -180,6 +180,9 @@ class m_dom {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param integer $type
|
||||||
|
*/
|
||||||
function domains_type_target_values($type = null) {
|
function domains_type_target_values($type = null) {
|
||||||
global $db, $err, $cuid;
|
global $db, $err, $cuid;
|
||||||
$err->log("dom", "domains_type_target_values");
|
$err->log("dom", "domains_type_target_values");
|
||||||
|
@ -825,6 +828,9 @@ class m_dom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $domain
|
||||||
|
*/
|
||||||
function domdefaultdir($domain) {
|
function domdefaultdir($domain) {
|
||||||
global $bro, $cuid;
|
global $bro, $cuid;
|
||||||
$dest_root = $bro->get_userid_root($cuid);
|
$dest_root = $bro->get_userid_root($cuid);
|
||||||
|
@ -1476,7 +1482,7 @@ class m_dom {
|
||||||
$domaine = $this->get_domain_byid($dom_id);
|
$domaine = $this->get_domain_byid($dom_id);
|
||||||
$d = $this->get_domain_all($domaine);
|
$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();
|
$this->unlock();
|
||||||
return $j;
|
return $j;
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,11 @@ class m_ftp {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the login is fine (syntax)
|
/**
|
||||||
|
* Check if the login is fine (syntax)
|
||||||
|
*
|
||||||
|
* @param string $l
|
||||||
|
*/
|
||||||
function check_login($l) {
|
function check_login($l) {
|
||||||
global $err;
|
global $err;
|
||||||
|
|
||||||
|
@ -419,7 +423,6 @@ class m_ftp {
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Fonction appellée par membres quand un membre est effacé.
|
/** Fonction appellée par membres quand un membre est effacé.
|
||||||
* @param integer $uid Numéro de membre effacé.
|
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function alternc_del_member() {
|
function alternc_del_member() {
|
||||||
|
|
|
@ -209,6 +209,9 @@ class m_mem {
|
||||||
return md5("$i--".$db->f('pass'));
|
return md5("$i--".$db->f('pass'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param boolean $t
|
||||||
|
*/
|
||||||
function authip_tokencheck($t) {
|
function authip_tokencheck($t) {
|
||||||
if ($t==$this->authip_token() || $t==$this->authip_token(true) ) return true;
|
if ($t==$this->authip_token() || $t==$this->authip_token(true) ) return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -234,7 +237,7 @@ class m_mem {
|
||||||
* et AVANT d'émettre des données. (un cookie peut être envoyé)
|
* et AVANT d'émettre des données. (un cookie peut être envoyé)
|
||||||
* @global string $session Le cookie de session eventuel
|
* @global string $session Le cookie de session eventuel
|
||||||
* @global string $username/password le login/pass de l'utilisateur
|
* @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() {
|
function checkid() {
|
||||||
global $db,$err,$cuid,$restrictip,$authip;
|
global $db,$err,$cuid,$restrictip,$authip;
|
||||||
|
@ -310,7 +313,7 @@ class m_mem {
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Retourne a l'identite d'origine de l'utilisateur apres su.
|
/** 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() {
|
function unsu() {
|
||||||
global $cuid,$mysql;
|
global $cuid,$mysql;
|
||||||
|
@ -524,7 +527,7 @@ Cordially.
|
||||||
* @param string $COOKIE Cookie envoyé par mail
|
* @param string $COOKIE Cookie envoyé par mail
|
||||||
* @param string $KEY clé affichée à l'écran
|
* @param string $KEY clé affichée à l'écran
|
||||||
* @param integer $uid Utilisateur concerné (on est hors session)
|
* @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) {
|
function ChangeMail2($COOKIE,$KEY,$uid) {
|
||||||
global $err,$db,$L_HOSTING,$L_FQDN;
|
global $err,$db,$L_HOSTING,$L_FQDN;
|
||||||
|
@ -567,7 +570,7 @@ Cordially.
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Affiche (echo) l'aide contextuelle
|
/** Affiche (echo) l'aide contextuelle
|
||||||
* @param integer $file Numéro de fichier d'aide à afficher.
|
* @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) {
|
function show_help($file,$force=false) {
|
||||||
global $err;
|
global $err;
|
||||||
|
@ -586,6 +589,9 @@ Cordially.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param integer $uid
|
||||||
|
*/
|
||||||
function get_creator_by_uid($uid) {
|
function get_creator_by_uid($uid) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$err->log("dom","get_creator_by_uid");
|
$err->log("dom","get_creator_by_uid");
|
||||||
|
|
|
@ -39,6 +39,11 @@ class m_variables {
|
||||||
var $replace_array = array();
|
var $replace_array = array();
|
||||||
var $cache_conf = 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
|
* @global string $L_FQDN
|
||||||
|
@ -170,10 +175,17 @@ class m_variables {
|
||||||
|
|
||||||
// Replace needed vars
|
// Replace needed vars
|
||||||
foreach ($variables as $vv => $hh) {
|
foreach ($variables as $vv => $hh) {
|
||||||
if (!isset($hh['value']) || empty($hh['value'])) {
|
if (!isset($hh['value']) || empty($hh['value'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$variables[$vv]['value'] = strtr($hh['value'], $this->replace_array );
|
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])) {
|
if ($var && isset($variables[$var])) {
|
||||||
|
@ -199,23 +211,30 @@ class m_variables {
|
||||||
/**
|
/**
|
||||||
* Return a persistent variable.
|
* Return a persistent variable.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name The name of the variable to return.
|
||||||
* The name of the variable to return.
|
* @param mixed $default The default value to use if this variable has never been set.
|
||||||
* @param mixed $default
|
* @param string $createit_comment If variable doesn't exist, create it with the default value
|
||||||
* The default value to use if this variable has never been set.
|
* and createit_comment value as comment
|
||||||
* @param string $createit_comment
|
* @param array $type An array defining the variable definition
|
||||||
* If variable doesn't exist, create it with the default value
|
* ex: array("ns1"=>array('desc'=>'ns name','type'=>'string'),"ip"=>array("desc"=>"here an ip", "type"=>"ip")
|
||||||
* and createit_comment value as comment
|
* ex: array('desc'=>'ns name','type'=>'string')
|
||||||
* @return mixed
|
* Types can be either
|
||||||
* The value of the variable.
|
* 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();
|
$this->variable_init_maybe();
|
||||||
|
|
||||||
if (isset($this->cache_conf[$name])) {
|
// Attempts to retrieve $name
|
||||||
return $this->cache_conf[$name]['value'];
|
if (array_key_exists("$name", $this->cache_conf) && !is_null($this->cache_conf["$name"])) {
|
||||||
} elseif (!is_null($createit_comment)) {
|
return $this->cache_conf["$name"]["value"];
|
||||||
|
}
|
||||||
|
if (!is_null($createit_comment)) {
|
||||||
$this->variable_update_or_create($name, $default, 'DEFAULT', 'null', 'null', $createit_comment, $type);
|
$this->variable_update_or_create($name, $default, 'DEFAULT', 'null', 'null', $createit_comment, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
variable:
|
|
@ -14,7 +14,19 @@ class m_variablesTest extends AlterncTest
|
||||||
*/
|
*/
|
||||||
public function getDataSet()
|
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");
|
$result = $this->object->variable_get("phpunit");
|
||||||
$this->assertStringMatchesFormat("phpunit",$result);
|
$this->assertStringMatchesFormat("phpunit",$result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers m_variables::variable_get
|
||||||
|
*/
|
||||||
|
public function testVariable_getOldWay()
|
||||||
|
{
|
||||||
|
|
||||||
/*
|
$this->object->variable_get('phpunit', 'phpunit-default','phpunit-comment');
|
||||||
// Check old way
|
$result = $this->object->variable_get('phpunit');
|
||||||
$this->object->variable_get('phpunit1', 'toto','plop');
|
$this->assertSame("phpunit-default",$result);
|
||||||
$result = $this->object->variable_get('phpunit1');
|
|
||||||
$this->assertSame("toto",$result);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers m_variables::variable_get
|
||||||
|
*/
|
||||||
|
public function testVariable_getNewWayString()
|
||||||
|
{
|
||||||
|
|
||||||
// New way
|
// New way
|
||||||
$this->object->variable_get('phpunit2', 'here','comment', array('desc'=>'Want a string','type'=>'string'));
|
$this->object->variable_get('phpunit', 'phpunit-default','comment', array('desc'=>'Want a string','type'=>'string'));
|
||||||
$result = $this->object->variable_get('phpunit2');
|
$result = $this->object->variable_get('phpunit');
|
||||||
$this->assertSame("here",$result);
|
$this->assertSame("phpunit-default",$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);
|
* @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.
|
// EXPERIMENTAL : user data export.
|
||||||
die('Proof of concept');
|
die('Proof of concept');
|
||||||
|
|
||||||
include("config.php");
|
require_once("/usr/share/alternc/panel/class/config_nochk.php");
|
||||||
|
|
||||||
sem_release($alternc_sem);
|
sem_release($alternc_sem);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue