X-Git-Url: http://git.dj3c1t.com/index.cgi?a=blobdiff_plain;f=mw%2Fapp%2Fdata%2Fmodules%2Fshare%2Fmw_data_config.php;fp=mw%2Fapp%2Fdata%2Fmodules%2Fshare%2Fmw_data_config.php;h=2a8ae5177c806f43b4571d79bc32c3501718da1b;hb=422d883e3ed8ee55ee41e3b7826f32b79cea646d;hp=0000000000000000000000000000000000000000;hpb=e1b64e4088232b9d7b4acb2dc24279bb38fcafba;p=mtweb diff --git a/mw/app/data/modules/share/mw_data_config.php b/mw/app/data/modules/share/mw_data_config.php new file mode 100644 index 0000000..2a8ae51 --- /dev/null +++ b/mw/app/data/modules/share/mw_data_config.php @@ -0,0 +1,103 @@ +data_read( + array( + "table_name" => "config", + "index_name" => "key", + "index_value" => $key + ) + ) + ) === false + ) return false; + if(isset($config["value"])) $value = $config["value"]; + } + else{ + $value = array(); + if( + ( + $config_list = $this->data_list( + array( + "table_name" => "config", + "index_name" => "key" + ) + ) + ) === false + ) return false; + foreach($config_list["list"] as $config) $value[$config["key"]] = $config["value"]; + } + return $value; + } + + function config_exists($key){ + if( + ( + $config = $this->data_read( + array( + "table_name" => "config", + "index_name" => "key", + "index_value" => $key + ) + ) + ) === false + ) return false; + return $config ? 1 : 0; + } + + function set_config($key, $value){ + if( + ( + $config = $this->data_read( + array( + "table_name" => "config", + "index_name" => "key", + "index_value" => $key + ) + ) + ) === false + ) return false; + if($config){ + return $this->data_update( + array( + "table_name" => "config", + "index_name" => "key", + "index_value" => $key, + "values" => array( + "value" => $value + ) + ) + ); + } + else{ + return $this->data_insert( + array( + "table_name" => "config", + "values" => array( + "key" => $key, + "value" => $value + ) + ) + ); + } + } + + function del_config($key){ + return $this->data_delete( + array( + "table_name" => "config", + "index_name" => "key", + "index_value" => $key + ) + ); + } + + } + +?> \ No newline at end of file