draft_post.php
File Type: php
File Location: monofiles/
File name: draft_post.php
<?php
//Change a 'posted' file to 'draft'
include_once 'data_connect.php';
//if the filename is given through the GET parameter...
if (isset($_GET['editfile'])) {
$nu_file = $_GET['editfile'];
// ...if file exists...
if (file_exists($nu_file)) {
//...get the 'normal' and 'nu' xml files
$normal_file = str_replace('nu','',$nu_file);
//check if the normal file is there
if (file_exists($normal_file)){
// update the information of the normal file
$_draft = new SimpleXMLElement($normal_file,null,true);
$_draft->postinfo->post->type = 'Draft';
//$_draft->postinfo->post->path = '';
$_draft->postinfo->post->ptime = '';
$_draft->postinfo->post->modifed = time();
//get the creators name
$creator = $_draft->postinfo->post->createdby;
//if the post is created by the user or the user has admin rights...
if ( (get_account($_SESSION['userID'])['rights'] == 'administrator') || ($creator == $_SESSION['userID']) ) {
//delete the nu file
unlink ($nu_file);
//save normal file
$_draft->asXML($normal_file);
//keep the latest saved version of a post
$cfile = 'autosaves/content/nu'.$normal_file.'.htm';
if (is_file($cfile)) {
$ccfile = file_get_contents($cfile);
file_put_contents('autosaves/content/'.$normal_file.'.htm',$ccfile);
}
// delete the post file
if (isset($_GET['link'])){
$pl = '../'.$_GET['link'].'.php';
if (file_exists($pl))
unlink($pl);
$message = '<div id="action-confirm"><span>Post changed to draft</span></div>';
//plugin
insert('rssburn');
}
}
}
}
}
?>