X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fconfig.php;h=12fc9cafc99b61699fe172d635673277ff79b2fd;hb=3ac7c4e8599266aba69bf521c7ba94393df3c728;hp=fe675bc33f38416b938b691aea8516571fba20ea;hpb=8b31ff15f51c6936daedf28cc88c753214b569e0;p=friendica.git diff --git a/include/config.php b/include/config.php index fe675bc33f..12fc9cafc9 100644 --- a/include/config.php +++ b/include/config.php @@ -1,5 +1,18 @@ config[$family][$key] = $value; $ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ", @@ -132,8 +144,9 @@ function get_pconfig($uid,$family, $key, $instore = false) { ); if(count($ret)) { - $a->config[$uid][$family][$key] = $ret[0]['v']; - return $ret[0]['v']; + $val = (preg_match("|^a:[0-9]+:{.*}$|", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']); + $a->config[$uid][$family][$key] = $val; + return $val; } else { $a->config[$uid][$family][$key] = '!!'; @@ -148,7 +161,7 @@ function del_config($family,$key) { if(x($a->config[$family],$key)) unset($a->config[$family][$key]); $ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1", - dbesc($cat), + dbesc($family), dbesc($key) ); return $ret; @@ -164,20 +177,23 @@ function set_pconfig($uid,$family,$key,$value) { global $a; + // manage array value + $dbvalue = (is_array($value)?serialize($value):$value); + if(get_pconfig($uid,$family,$key,true) === false) { $a->config[$uid][$family][$key] = $value; $ret = q("INSERT INTO `pconfig` ( `uid`, `cat`, `k`, `v` ) VALUES ( %d, '%s', '%s', '%s' ) ", intval($uid), dbesc($family), dbesc($key), - dbesc($value) + dbesc($dbvalue) ); if($ret) return $value; return $ret; } $ret = q("UPDATE `pconfig` SET `v` = '%s' WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1", - dbesc($value), + dbesc($dbvalue), intval($uid), dbesc($family), dbesc($key)