PATH:
home
/
njujpgyl
/
public_html
<?php // xml_manager.php require_once 'config.php'; class XMLManager { private $xml_file; private $xml; public function __construct($xml_file = XML_FILE) { $this->xml_file = $xml_file; if (file_exists($xml_file)) { $this->xml = simplexml_load_file($xml_file); } else { // Create basic XML structure $this->xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><areas></areas>'); // Add default areas $delhi = $this->xml->addChild('area'); $delhi->addAttribute('name', 'Delhi'); $delhi->addAttribute('slug', 'delhi'); $delhi->addAttribute('phone', '911234567890'); $delhi->addAttribute('email', 'info@delhigal.com'); $delhi->addAttribute('priority', '1'); $ncr = $this->xml->addChild('area'); $ncr->addAttribute('name', 'NCR'); $ncr->addAttribute('slug', 'ncr'); $ncr->addAttribute('phone', '911234567891'); $ncr->addAttribute('email', 'info@delhigal.com'); $ncr->addAttribute('priority', '1'); $this->saveXML(); } } public function addArea($parent_slug, $name, $slug, $phone, $email, $priority) { $parent = $this->findAreaNode($this->xml, $parent_slug); if ($parent) { $new_area = $parent->addChild('area'); $new_area->addAttribute('name', htmlspecialchars($name)); $new_area->addAttribute('slug', htmlspecialchars($slug)); $new_area->addAttribute('phone', htmlspecialchars($phone)); $new_area->addAttribute('email', htmlspecialchars($email)); $new_area->addAttribute('priority', htmlspecialchars($priority)); return $this->saveXML(); } return false; } public function editArea($slug, $name, $phone, $email, $priority) { $area = $this->findAreaNode($this->xml, $slug); if ($area) { $area['name'] = htmlspecialchars($name); $area['phone'] = htmlspecialchars($phone); $area['email'] = htmlspecialchars($email); $area['priority'] = htmlspecialchars($priority); return $this->saveXML(); } return false; } public function deleteArea($slug) { $area = $this->findAreaNode($this->xml, $slug); if ($area && $this->hasChildren($area)) { throw new Exception("Cannot delete area that has child areas! Please delete child areas first."); } if (in_array($slug, ['delhi', 'ncr'])) { throw new Exception("Cannot delete root areas!"); } if ($this->deleteAreaRecursive($this->xml, $slug)) { return $this->saveXML(); } else { throw new Exception("Area not found or cannot be deleted!"); } } public function getAllAreas() { $areas = []; $this->getAllAreasRecursive($this->xml, $areas); return $areas; } public function findAreaBySlug($slug) { return $this->findAreaNode($this->xml, $slug); } // Private helper methods private function findAreaNode($xml, $slug, &$parent = null) { foreach ($xml->area as $area) { $attributes = $area->attributes(); if ((string)$attributes['slug'] === $slug) { return $area; } if ($area->area && $area->area->count() > 0) { $found = $this->findAreaNode($area, $slug, $parent); if ($found) { if (!$parent) $parent = $area; return $found; } } } return null; } private function hasChildren($area) { return $area->area && $area->area->count() > 0; } private function deleteAreaRecursive($xml, $slug) { foreach ($xml->area as $area) { $attributes = $area->attributes(); if ((string)$attributes['slug'] === $slug) { $dom = dom_import_simplexml($area); $dom->parentNode->removeChild($dom); return true; } if ($area->area && $area->area->count() > 0) { if ($this->deleteAreaRecursive($area, $slug)) { return true; } } } return false; } private function getAllAreasRecursive($xml, &$areas = [], $level = 0) { foreach ($xml->area as $area) { $attributes = $area->attributes(); $prefix = str_repeat('-- ', $level); $areas[(string)$attributes['slug']] = [ 'name' => $prefix . (string)$attributes['name'], 'has_children' => $this->hasChildren($area), 'node' => $area ]; if ($area->area && $area->area->count() > 0) { $this->getAllAreasRecursive($area, $areas, $level + 1); } } } private function saveXML() { $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($this->xml->asXML()); return file_put_contents($this->xml_file, $dom->saveXML()) !== false; } }
[+]
..
[+]
cgi-bin
[-] delhigal.zip
[edit]
[+]
content1
[+]
image
[-] .ftpquota
[edit]
[-] 404.php
[edit]
[-] android-chrome-192x192.png
[edit]
[-] android-chrome-512x512.png
[edit]
[-] apple-touch-icon.png
[edit]
[-] arealist.xml
[edit]
[-] auth.php
[edit]
[-] cache.php
[edit]
[-] config.php
[edit]
[-] content_manager.php
[edit]
[-] error_log
[edit]
[-] favicon.ico
[edit]
[-] favicon-16x16.png
[edit]
[-] favicon-32x32.png
[edit]
[-] frontpage.php
[edit]
[-] functions.php
[edit]
[-] google2fabcdaeda4836e4.html
[edit]
[-] index.php
[edit]
[-] index1.html
[edit]
[-] index1.php
[edit]
[-] login.php
[edit]
[-] logout.php
[edit]
[-] robots.txt
[edit]
[-] style.css
[edit]
[-] template.php
[edit]
[-] template-footer.php
[edit]
[-] template-header.php
[edit]
[-] test.php
[edit]
[-] xml_manager.php
[edit]
[+]
.well-known
[+]
cache
[+]
content
[-] error_logs.php
[edit]
[-] _
[edit]