X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=mw%2Fapp%2Fdata%2Fimpl%2Fxml%2Fmw_xml_data.php;fp=mw%2Fapp%2Fdata%2Fimpl%2Fxml%2Fmw_xml_data.php;h=0000000000000000000000000000000000000000;hb=ad9756b0b72852c82165e824570f21b039fcb359;hp=1148da95458d656708b3fc498ecb10c6b054231e;hpb=8da84cf3aa4d10d91f19b6df06ce4c5e9fcb79da;p=mtweb diff --git a/mw/app/data/impl/xml/mw_xml_data.php b/mw/app/data/impl/xml/mw_xml_data.php deleted file mode 100644 index 1148da9..0000000 --- a/mw/app/data/impl/xml/mw_xml_data.php +++ /dev/null @@ -1,108 +0,0 @@ -host = $host.(substr($host, -1) != "/" ? "/" : ""); - $this->base = $base.(substr($base, -1) != "/" ? "/" : ""); - $this->cache = array(); - } - - public function host(){ - return $this->host; - } - - public function base(){ - return $this->base; - } - - public function use_cache(){ - return true; - } - - public function set_cache($data_name, $data, $data_id){ - if($this->use_cache()){ - $this->cache[$data_name] = $data; - $this->cache[$data_name]["id"] = $data_id; - } - } - - public function get_data($data_path, $data_id){ - $data_name = $this->data_name($data_path, $data_id); - if(isset($this->cache[$data_name])) return $this->cache[$data_name]; - if($this->buffer = @file_get_contents($data_name)){ - if(($data = $this->parse_data()) !== false){ - $this->set_cache($data_name, $data, $data_id); - $data["id"] = $data_id; - return $data; - } - } - return false; - } - - public function add_data($data_path, $data_id, $data){ - return $this->_set_data($data_path, $data_id, $data); - } - - public function set_data($data_path, $data_id, $data){ - return $this->_set_data($data_path, $data_id, $data); - } - - public function _set_data($data_path, $data_id, $data){ - if($fh = @fopen($this->data_name($data_path, $data_id), "w")){ - $this->buffer = $this->serialize_data($data); - if(@fwrite($fh, $this->buffer) !== false){ - @fclose($fh); - $this->buffer = null; - $data_name = $this->data_name($data_path, $data_id); - $this->set_cache($data_name, $data, $data_id); - return $data_id; - } - else{ - @fclose($fh); - $this->buffer = null; - } - } - return null; - } - - public function del_data($data_path, $data_id){ - $data_name = $this->data_name($data_path, $data_id); - if(isset($this->cache[$data_name])) unset($this->cache[$data_name]); - return @unlink($this->data_name($data_path, $data_id)); - } - - public function data_name($data_path, $data_id){ - return $this->host.$this->base.$data_path.$data_id.".xml"; - } - - public function parse_data(){ - if(!isset($this->sxml)) $this->sxml = new sxml(); - $this->sxml->parse($this->buffer); - if(isset($this->sxml->data["tuple"][0])){ - $this->buffer = $this->sxml->data["tuple"][0]; - $v_rst = array(); - foreach($this->buffer["subs"] as $key => $value){ - $v_rst[$key] = $value[0]["data"]; - } - return $v_rst; - } - return false; - } - - public function serialize_data($data){ - $this->buffer = "\n"; - foreach($data as $key => $value){ - if(isset($value)) $this->buffer .= " <".$key.">\n"; - } - $this->buffer .= "\n"; - return $this->buffer; - } - - }