Rose.S Posted August 17, 2008 Share Posted August 17, 2008 Hello, This function is used in my admin page code, but, when I am publish the website, I got this error Fatal error: Call to undefined function: domxml_open_file() in /home/fatimaab/public_html/lib/xml4.php on line 20 This is my localhost info: Server version: 4.0.27-standard Protocol version: 10 MySQL client version: 4.1.22 I do not know what should I do to fix this!!! and my admin page is not working because of this. I attached the page code to help u figuring out where he problem is, or, If there is any code that must be added to make this work. Thanks <? class XML4 { var $file = ''; var $doc = null; var $root = null; var $rootName = 'root'; var $catRoot = ''; var $gallDirName = ''; function XML4($iFile = '', $rootName = 'root', $catRoot = '', $gallDirName = '') { $this->rootName = $rootName; $this->catRoot = $catRoot; $this->gallDirName = $gallDirName; $this->file = $iFile; if (file_exists($iFile)) { $this->doc = domxml_open_file($iFile); $this->root = $this->doc->document_element(); }else{ $this->doc = domxml_new_doc('1.0'); $root = $this->doc->create_element($rootName); $this->doc->append_child($root); $this->root = $root; $this->save(); } } function getCatId() { $cats = $this->doc->get_elements_by_tagname('gallery'); $lastCat = $cats[count($cats)-1]; if ($lastCat != null){ return $lastCat->get_attribute('id'); }else{ return 0; } } function addCat($cat = '') { if ($cat == '') return false; $id = $this->getCatId(); $id++; $el = $this->doc->create_element('gallery'); $el->set_attribute('id', $id); $el->set_attribute('name', $cat); @mkdir($this->catRoot.$this->gallDirName.'/'.$id.'/'); $el->set_attribute('path', $this->gallDirName.'/'.$id.'/'); $this->root->append_child($el); $this->save(); return $id; } function updateCat($id, $name) { $cat = $this->getCat($id); $cat->set_attribute('name', $name); $this->save(); } function delCat($id = '') { if ($id == '') return false; $list = $this->root->get_elements_by_tagname('gallery'); if (count($list) > 0) { foreach ($list as $v) { if ($v->get_attribute('id') == $id) { //delete all files from dir $path = $this->catRoot.$v->get_attribute('path'); if ($dh = @opendir($path)) { while (($file = readdir($dh)) !== false) { @unlink($path.$file); } closedir($dh); } //delete dir @rmdir($path); //delete cat $this->root->remove_child($v); $this->save(); } } } } function getCategories() { $list = $this->root->get_elements_by_tagname('gallery'); $res = array(); if (count($list) > 0) { foreach ($list as $v) { $res[] = array( 'id' => $v->get_attribute('id'), 'name' => $v->get_attribute('name'), 'path' => $v->get_attribute('path') ); } } return $res; } function getCat($id) { if ($id == '') return array(); $list = $this->root->get_elements_by_tagname('gallery'); if (count($list) > 0) { foreach ($list as $v) { if ($v->get_attribute('id') == $id){ return $v; } } } return null; } function getCatValue($id) { if ($id == '') return array(); $list = $this->root->get_elements_by_tagname('gallery'); if (count($list) > 0) { foreach ($list as $v) { if ($v->get_attribute('id') == $id){ return array( 'id' => $v->get_attribute('id'), 'name' => $v->get_attribute('name'), 'path' => $v->get_attribute('path') ); } } } return array(); } function addImage($data) { $cat = $this->getCat($data['cat']); $el = $this->doc->create_element('image'); $el->set_attribute('id', $data['id']); $el->set_attribute('thumb', $data['thumb']); $el->set_attribute('img', $data['img']); $el->set_attribute('title', $data['title']); $el->set_attribute('description', $data['desc']); $el->set_attribute('seriesTitle', $data['seriesTitle']); $cat->append_child($el); $this->save(); return true; } function updateImage($cat, $id, $data) { if ($img = $this->getImage($cat, $id)){ $img->set_attribute('title', $data[0]); $img->set_attribute('seriesTitle', $data[1]); $img->set_attribute('description', $data[2]); $this->save(); return true; }else{ return false; } } function getImageId($cat) { $cat = $this->getCat($cat); if ($cat == null) return null; $imgs = $cat->get_elements_by_tagname('image'); $imgs = $imgs[count($imgs)-1]; if ($imgs != null){ return $imgs->get_attribute('id'); }else{ return 0; } } function getImage($cat, $id) { if ($cat == '' || $id == '') return null; $cat = $this->getCat($cat); $images = $cat->get_elements_by_tagname('image'); if (count($images) > 0) { foreach ($images as $v) { if ($v->get_attribute('id') == $id){ return $v; } } } return null; } function getImageValue($cat, $id) { if ($cat == '' || $id == '') return array(); $cat = $this->getCat($cat); $path = $cat->get_attribute('id'); $images = $cat->get_elements_by_tagname('image'); if (count($images) > 0) { foreach ($images as $v) { if ($v->get_attribute('id') == $id){ return array( 'id' => $v->get_attribute('id'), 'thumb' => $path.'/'.$v->get_attribute('thumb'), 'img' => $path.'/'.$v->get_attribute('img'), 'title' => $v->get_attribute('title'), 'desc' => $v->get_attribute('description'), 'seriesTitle' => $v->get_attribute('seriesTitle') ); } } } return array(); } function getImages($catId) { $cat = $this->getCat($catId); $res = array(); $images = $cat->get_elements_by_tagname('image'); if (count($images) > 0) { foreach ($images as $v) { $id = $v->get_attribute('id'); $res[] = array( 'id' => $v->get_attribute('id'), 'thumb' => $path.'/'.$v->get_attribute('thumb'), 'img' => $path.'/'.$v->get_attribute('img'), 'title' => $v->get_attribute('title'), 'desc' => $v->get_attribute('description'), 'seriesTitle' => $v->get_attribute('seriesTitle') ); } } return $res; } function deleteImage($cat, $img) { $cat = $this->getCat($cat); $images = $cat->get_elements_by_tagname('image'); if (count($images) > 0) { foreach ($images as $v) { if ($v->get_attribute('id') == $img){ //delete images $path = $this->catRoot.$cat->get_attribute('path'); @unlink($path.$v->get_attribute('thumb')); @unlink($path.$v->get_attribute('img')); // $cat->remove_child($v); $this->save(); break; } } } } function save($file = '') { if ($file == '') $this->doc->dump_file($this->file); else $this->doc->dump_file($file); } function getXML() { return $this->doc->dump_mem(); } } ?> Link to comment https://forums.phpfreaks.com/topic/120111-domxml_open_file-problem/ Share on other sites More sharing options...
trq Posted August 17, 2008 Share Posted August 17, 2008 Your version of php does not support or does not have domxml_open_file() built in. Link to comment https://forums.phpfreaks.com/topic/120111-domxml_open_file-problem/#findComment-618766 Share on other sites More sharing options...
Rose.S Posted August 17, 2008 Author Share Posted August 17, 2008 Your version of php does not support or does not have domxml_open_file() built in. What can I use instead? I can not change the hosting domain now. It is already paid. I need to change the code to fit that PHP version. and I need this pages to work soon Thanks Link to comment https://forums.phpfreaks.com/topic/120111-domxml_open_file-problem/#findComment-618782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.