X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=web%2Fapp%2Fdata%2Fmodules%2Fxml%2Fmw_data_config.php;fp=web%2Fapp%2Fdata%2Fmodules%2Fxml%2Fmw_data_config.php;h=359a16cdd766aacfaa719e9159a4adb71d121dad;hb=29b6377f43bf4477e04b57069cf779ac1b913bdb;hp=98d4607caf5e80a83055616864377a09b82e8dc3;hpb=a21fbfe1301f83b72d2815899ff334445b7830cf;p=mtweb diff --git a/web/app/data/modules/xml/mw_data_config.php b/web/app/data/modules/xml/mw_data_config.php index 98d4607..359a16c 100644 --- a/web/app/data/modules/xml/mw_data_config.php +++ b/web/app/data/modules/xml/mw_data_config.php @@ -1,28 +1,27 @@ sgbd(); + function config($key = null){ + $sgbd = $this->sgbd(); $value = false; - if($rst = $sgbd->open_data("config")) - { if(isset($key)) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if($v_rst["key"] == $key) - { $value = $v_rst["value"]; + if($rst = $sgbd->open_data("config")){ + if(isset($key)){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if($v_rst["key"] == $key){ + $value = $v_rst["value"]; } } else $value = null; } } - else - { $value = array(); - while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(is_array($v_rst)) foreach($v_rst as $key => $_value) - { $value[$key] = $_value; + else{ + $value = array(); + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(is_array($v_rst)) foreach($v_rst as $key => $_value){ + $value[$key] = $_value; break; } } @@ -35,16 +34,16 @@ return $value; } - function config_exists($key) - { $sgbd = $this->sgbd(); + function config_exists($key){ + $sgbd = $this->sgbd(); $exists = 0; - if($rst = $sgbd->open_data("config")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst[$key])) $exists++; + if($rst = $sgbd->open_data("config")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst[$key])) $exists++; } - else - { $exists = false; + else{ + $exists = false; break; } } @@ -54,42 +53,42 @@ return $exists; } - function set_config($key, $value) - { $sgbd = $this->sgbd(); + function set_config($key, $value){ + $sgbd = $this->sgbd(); $FOUND = false; - if($rst = $sgbd->open_data("config")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(array_key_exists($key, $v_rst)) - { $FOUND = $sgbd->set_data("config", $v_rst["id"], array($key => $value)); + if($rst = $sgbd->open_data("config")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(array_key_exists($key, $v_rst)){ + $FOUND = $sgbd->set_data("config", $v_rst["id"], array($key => $value)); break; } } - else - { $FOUND = null; + else{ + $FOUND = null; break; } } $sgbd->close_data($rst); } else $FOUND = null; - if(isset($FOUND)) - { if($FOUND) return true; - else - { if($sgbd->add_data("config", array($key => $value))) return true; + if(isset($FOUND)){ + if($FOUND) return true; + else{ + if($sgbd->add_data("config", array($key => $value))) return true; } } return false; } - function del_config($key) - { $ids = array(); + function del_config($key){ + $ids = array(); $sgbd = $this->sgbd(); - if($rst = $sgbd->open_data("config")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst[$key]) && isset($v_rst["id"])) - { $ids[] = $v_rst["id"]; + if($rst = $sgbd->open_data("config")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst[$key]) && isset($v_rst["id"])){ + $ids[] = $v_rst["id"]; } } else $ids = false;