X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=web%2Fapp%2Fdata%2Fimpl%2Fxml%2Fmw_xml_data.php;fp=web%2Fapp%2Fdata%2Fimpl%2Fxml%2Fmw_xml_data.php;h=0000000000000000000000000000000000000000;hb=36ed114046cbe3d72a3589230e9f306a54fcc79d;hp=0b6c8cd0adb0efa0f5019b1d360a1af80430f345;hpb=281c96e95451269f2614684b8de5be25862c8374;p=mtweb diff --git a/web/app/data/impl/xml/mw_xml_data.php b/web/app/data/impl/xml/mw_xml_data.php deleted file mode 100644 index 0b6c8cd..0000000 --- a/web/app/data/impl/xml/mw_xml_data.php +++ /dev/null @@ -1,112 +0,0 @@ -host = $host.(substr($host, -1) != "/" ? "/" : ""); - $this->base = $base.(substr($base, -1) != "/" ? "/" : ""); - $this->cache = array(); - } - - function host(){ - return $this->host; - } - - function base(){ - return $this->base; - } - - function use_cache(){ - return true; - } - - function set_cache($data_name, $data, $data_id){ - if($this->use_cache()){ - $this->cache[$data_name] = $data; - $this->cache[$data_name]["id"] = $data_id; - } - } - - 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; - } - - function add_data($data_path, $data_id, $data){ - return $this->_set_data($data_path, $data_id, $data); - } - - function set_data($data_path, $data_id, $data){ - return $this->_set_data($data_path, $data_id, $data); - } - - 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; - } - - 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)); - } - - function data_name($data_path, $data_id){ - return $this->host.$this->base.$data_path.$data_id.".xml"; - } - - 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; - } - - 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; - } - - } - -?> \ No newline at end of file