* Edit Backups * * View the current backup of a given page * * @package GetSimple * @subpackage Backups */ # setup $load['plugin'] = true; include 'inc/common.php'; login_cookie_check(); exec_action('load-backup-edit'); # get page url to display if ($_GET['id'] != '') { $id = $_GET['id']; $file = getBackupName($id, 'xml'); $draft = isset($_GET['draft']); // (bool) using draft pages if ($draft) { $path = GSBACKUPSPATH . getRelPath(GSDATADRAFTSPATH, GSDATAPATH); } else { $path = GSBACKUPSPATH . getRelPath(GSDATAPAGESPATH, GSDATAPATH); } // backups/pages/ if (!filepath_is_safe($path . $file, $path)) { die; } $data = getXML($path . $file); $title = htmldecode($data->title); $pubDate = $data->pubDate; $parent = $data->parent;
/** * Delete Pages Backup File * * @since 3.4 * * @param string $id File ID to delete * @return bool success */ function delete_page_backup($id) { $filepath = GSBACKUPSPATH . getRelPath(GSDATAPAGESPATH, GSDATAPATH); // backups/pages/ $file = $filepath . getBackupName($id, 'xml'); if (filepath_is_safe($file, $filepath)) { return delete_file($file); } }
/** * Delete Pages Backup File * * @since 3.4 * * @param string $id File ID to delete * @return bool success */ function delete_page_backup($id) { $bakpagespath = GSBACKUPSPATH . getRelPath(GSDATAPAGESPATH, GSDATAPATH); // backups/pages/ return delete_file($bakpagespath . getBackupName($id, 'xml')); }
public function page_save() { $bakpagespath = GSBACKUPSPATH . getRelPath(GSDATAPAGESPATH, GSDATAPATH); // backups/pages/ if ($this->auth()) { $id = (string) $this->xml->data->slug; $thisfile = GSDATAPAGESPATH . getBackupName($id, 'xml'); if (file_exists($thisfile)) { $page = getXML($thisfile); $page->content = safe_slash_html($this->xml->data->content); $page->title = safe_slash_html($this->xml->data->title); $page->pubDate = date('r'); $bakfile = $bakpagespath . getBackupName($id, 'xml'); copy_file($thisfile, $bakfile); $status = XMLsave($page, $thisfile); if ($status) { touch($thisfile); $wrapper = array('status' => 'success', 'message' => 'page_save ok', 'response' => $page); } else { $wrapper = array('status' => 'error', 'message' => 'There was an error saving your page'); } return json_encode($wrapper); } else { $error = array('status' => 'error', 'message' => sprintf(i18n_r('API_ERR_NOPAGE'), $id)); return json_encode($error); } } }