while (file_exists($newfile)) { $count++; $newfile = GSDATAPAGESPATH . $_GET['id'] . "-" . $count . ".xml"; } } $newurl = $_GET['id'] . '-' . $count; # do the copy $status = copy($path . $_GET['id'] . '.xml', $path . $newurl . '.xml'); if ($status) { $newxml = getXML($path . $newurl . '.xml'); $newxml->url = $newurl; $newxml->title = $newxml->title . ' [' . i18n_r('COPY') . ']'; $newxml->pubDate = date('r'); $status = XMLsave($newxml, $path . $newurl . '.xml'); if ($status) { create_pagesxml('true'); header('Location: pages.php?upd=clone-success&id=' . $newurl); } else { $error = sprintf(i18n_r('CLONE_ERROR'), $_GET['id']); header('Location: pages.php?error=' . $error); } } else { $error = sprintf(i18n_r('CLONE_ERROR'), $_GET['id']); header('Location: pages.php?error=' . $error); } } getPagesXmlValues(); $count = 0; foreach ($pagesArray as $page) { if ($page['parent'] != '') { $parentdata = getXML(GSDATAPAGESPATH . $page['parent'] . '.xml');
/** * Get Cached Pages XML Values * * Loads the Cached XML data into the Array $pagesArray * If the file does not exist it is created the first time. * * @since 3.1 * */ function getPagesXmlValues($chkcount = true) { global $pagesArray; $pagesArray = array(); $file = GSDATAOTHERPATH . "pages.xml"; if (file_exists($file)) { // load the xml file and setup the array. $thisfile = file_get_contents($file); $data = simplexml_load_string($thisfile); $pages = $data->item; foreach ($pages as $page) { $key = $page->url; $pagesArray[(string) $key] = array(); foreach ($page->children() as $opt => $val) { $pagesArray[(string) $key][(string) $opt] = (string) $val; } } $path = GSDATAPAGESPATH; $dir_handle = @opendir($path) or die("Unable to open {$path}"); $filenames = array(); while ($filename = readdir($dir_handle)) { $ext = substr($filename, strrpos($filename, '.') + 1); if ($ext == "xml") { $filenames[] = $filename; } } if ($chkcount == true) { if (count($pagesArray) != count($filenames)) { create_pagesxml('true'); getPagesXmlValues(false); } } } else { create_pagesxml(true); getPagesXmlValues(false); } }
/** * Get Cached Pages XML Values * * Loads the Cached XML data into the Array $pagesArray * If the file does not exist it is created the first time. * * @since 3.1 * */ function getPagesXmlValues($chkcount = false) { global $pagesArray; // debugLog(__FUNCTION__.": chkcount - " .(int)$chkcount); // if page cache not load load it if (!$pagesArray) { $pagesArray = array(); $file = GSDATAOTHERPATH . "pages.xml"; if (file_exists($file)) { // load the xml file and setup the array. // debugLog(__FUNCTION__.": load pages.xml"); $thisfile = file_get_contents($file); $data = simplexml_load_string($thisfile); $pages = $data->item; foreach ($pages as $page) { $key = $page->url; $pagesArray[(string) $key] = array(); foreach ($page->children() as $opt => $val) { $pagesArray[(string) $key][(string) $opt] = (string) $val; } } } else { // no page cache, regen and then load it // debugLog(__FUNCTION__.": pages.xml not exist"); if (create_pagesxml(true)) { getPagesXmlValues(false); } return; } } // if checking cache sync, regen cache if pages differ. if ($chkcount == true) { $path = GSDATAPAGESPATH; $dir_handle = @opendir($path) or die("getPageXmlValues: Unable to open {$path}"); $filenames = array(); while ($filename = readdir($dir_handle)) { $ext = substr($filename, strrpos($filename, '.') + 1); if ($ext == "xml") { $filenames[] = $filename; } } if (count($pagesArray) != count($filenames)) { // debugLog(__FUNCTION__.": count differs regen pages.xml"); if (create_pagesxml(true)) { getPagesXmlValues(false); } } } }
$private = $xml->xpath('/item/private'); $oldprivate = (string) $private[0]; if ($oldprivate == null) { $private[0][0] = "Y"; echo "P1"; } else { $private[0][0] = ''; echo "P0"; } $bakfile = GSBACKUPSPATH . "pages/" . $id . ".bak.xml"; copy($file, $bakfile); XMLsave($xml, $file); create_pagesxml(true); } if (check_nonce($nonce, "menu", "toggle.php")) { $file = GSDATAPAGESPATH . $id . ".xml"; $xml = getXML($file); $status = $xml->xpath('/item/menuStatus'); $oldstatus = (string) $status[0]; if ($oldstatus == null) { $status[0][0] = "Y"; echo "M1"; } else { $status[0][0] = ''; echo "M0"; } $bakfile = GSBACKUPSPATH . "pages/" . $id . ".bak.xml"; copy($file, $bakfile); XMLsave($xml, $file); create_pagesxml(true); }