X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fconfig.php;h=4cff38090c2e5bdd585de562d81fa1c5bb7a67f7;hb=9b6e91086b29554fd04362f6c87ea148718e8b1c;hp=f565ab1178e6c2cb10708ae33bfb67272829b67d;hpb=bdf42473a0341f291cd256323d122aa80bb0cb0b;p=friendica.git diff --git a/include/config.php b/include/config.php old mode 100644 new mode 100755 index f565ab1178..4cff38090c --- a/include/config.php +++ b/include/config.php @@ -80,6 +80,7 @@ function set_config($family,$key,$value) { // manage array value $dbvalue = (is_array($value)?serialize($value):$value); + $dbvalue = (is_bool($value) ? intval($value) : $value); if(get_config($family,$key,true) === false) { $a->config[$family][$key] = $value; @@ -145,8 +146,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] = '!!'; @@ -161,7 +163,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; @@ -177,20 +179,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)