pages.php
File Type: php
File Location: monofiles/
File name: pages.php
<?php
include_once 'data_connect.php';
include 'log.php';
if(get_account($_SESSION['userID'])['rights'] != 'administrator'){
header('Location:panel.php');
exit();
}
if (isset($_GET['max'])) {
$settingsXML = simplexml_load_file('filesinfo/settings.xml');
$lastmod = $settingsXML->general->savedpages->lastmod;
if ((isset($_GET['at'])) && ($_GET['at'] < $lastmod) )
header('Location:pages.php');
}
if (isset($_GET['page'])) {
$del = $_GET['savedpage'];
if (file_exists($del)) {
unlink($del);
$confirm_deleted = true;
$sum = get_log()['pages'];
$sum -= 1;
update_log('pages',$sum);
}
$_delete_ = $_GET['page'];
if (file_exists('../'.$_delete_.'.php'))
unlink('../'.$_delete_.'.php');
}
?>
<!doctype html>
<html>
<head>
<title>Pages</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="cmstyle.css">
<?php include 'csstheme.php' ?>
<script type="text/javascript">
function conf(form){
return confirm('Delete page?');
}
</script>
</head>
<body><?php
include 'mypanel.php';
if (isset($confirm_deleted))
echo '<div id="action-confirm"><span>Page deleted</span></div>'
?>
<div class="main">
<h1>Pages</h1>
<div class="headpages">
<a href="createpage.php" class="addnew" title="New Page">+</a>
</div>
<div id="main-container">
<div class="results-set results-set-pages">
<div class="normal-res">
<span style="font-size:12px">results </span>
<?php
//Sort results
//GET parameter for res-set.php
$gt = array('sortbytitle','sortbyalpha','sortbyrev');
foreach($gt as $set) {
if (isset($_GET[$set])) {
$snes = '&sort='.$set.'&sortval='.$_GET[$set];
break;
}
else
$snes = '';
}
$ra = array(5,10,20,50,100,200);
$x = get_account($_SESSION['userID'])['results_pages'];
$c=1;
foreach($ra as $res) {
$d = $c < 6 ? ' | ' : '';
echo ($x != $res) ? '<a href="res-set.php?pagesperpage='.$res.$snes.'">'.$res.'</a>'.$d : $res.$d;
$c++;
}
?>
</div>
</div>
<div class="resultspages">
<div class="pbar">
<span style="width:61%;padding-left:10px;text-align:left;float:left"><a href="pages.php?sortby<?php
if (isset($_GET['sortbytitle']))
print 'alpha=1" class="sort1';
elseif (isset($_GET['sortbyalpha']))
print 'title=1" class="sort2';
else print 'title=1'
?>">Title</a></span>
<span style="width:90px"><a href="pages.php<?php
if (isset($_GET['sortbyrev']))
print '" class="sort2' ;
elseif ( !isset($_GET['sortbytitle']) && !isset($_GET['sortbyalpha']) )
print '?sortbyrev=1" class="sort1'
?>">Last modified</a></span>
</div>
<?php
$array_xml = array();
$array_param = array();
$directory = new DirectoryIterator('savedpages/');
$num = 1;
foreach ($directory as $fileinfo) {
if ($fileinfo->isFile()) {
$name = $fileinfo->getFilename();
$sp = simplexml_load_file('savedpages/'.$name);
$mtime = $sp->pageinfo->page->modified;
$array_xml[]= 'savedpages/'.$name;
$array_param[] = (isset($_GET['sortbytitle']) || isset($_GET['sortbyalpha'])) ? strtolower($sp->pageinfo->page->title).$num : $mtime;
}
$num++;
}
$array_res = array_combine($array_param,$array_xml);
if ( isset($_GET['sortbyrev']) || isset($_GET['sortbytitle']) )
// normal order
ksort($array_res);
else
// reverse order
krsort($array_res);
include 'navinfo.php';
$c=0;
$r=0;
include 'en_code.php';
include 'dateform.php';
foreach($array_res as $file) {
if(filesize($file) > 100) {
if (($c >= $first) && ($c < $last)) {
$r++;
$fxml = simplexml_load_file($file);
$title = $fxml->pageinfo->page->title;
$filename = $fxml->pageinfo->page->filename;
$utime = (int)$fxml->pageinfo->page->modified;
$ftime = date_form($utime);
if ($title == '')
$title = '(no title)';
$cssbg = (($c % 2) == 1) ? ' -bg' : '';
echo '<div class="savedfile'.$cssbg.'">
<span class="page-title">'.load_xml($title).'</span>
<div class="page-options"><a href="createpage.php?savedname='.$file.'" class="options-button" title="Edit page">Edit Page</a>
<a href="javascript:" onclick="if (conf(this)) window.location.href=\'?page='.$filename.'&savedpage='.$file.'&max='.$ofp.'\'" class="options-button not" title="Delete page">Delete</a>
<a href="../'.$filename.'.php" class="options-button" title="Visit page" target="_blank">Visit</a>
</div>
<div class="lastmod" title="'.date("H:i",$utime).'">'.$ftime.'</div>
</div>';
}
}
$c++;
}
?>
<div id="res-nav">
<?php
include 'pagenav.php'
?>
</div>
</div>
</div>
</div>
</body>
</html>