general.php
File Type: php
File Location: monofiles/
File name: general.php
<?php
include_once 'data_connect.php';
include 'log.php';
if(get_account($_SESSION['userID'])['rights'] != 'administrator'){
header('Location:generaluser.php');
exit();
}
if (isset($_POST['formsubmitted'])) {
// Settings file
if (simplexml_load_file('filesinfo/settings.xml') === false)
exit('Error: The settings file is corrupt');
$settingsinfo = new SimpleXMLElement('filesinfo/settings.xml',null,true);
// Values
if ($_POST['title'] != ($settingsinfo->general->title))
$website_title = strip_tags($_POST['title']);
if ($_POST['description'] != ($settingsinfo->general->description))
$website_description = htmlspecialchars(strip_tags($_POST['description']),ENT_COMPAT);
if ($_POST['quicknote'] != ($settingsinfo->general->note))
$quick_note = htmlspecialchars($_POST['quicknote'],ENT_COMPAT);
if ($_POST['maximagesize'] != ($settingsinfo->general->maximagesize)) {
$max = $_POST['maximagesize'];
if ((!ctype_digit($max)) || ($max < 0) || ($max > 20000))
$error = '"Max upload image size" was not valid';
}
$num_of_posts = array('Results in homepage'=>'indexposts','Posts in homepage'=>'proposts','Results per page'=>'ppageposts');
foreach($num_of_posts as $ermes=>$name) {
if(isset($_POST[$name])) {
if ($_POST[$name] != $settingsinfo->general->$name->results) {
$$name = $_POST[$name];
if ((!ctype_digit($$name)) || ($$name < 0) || ($$name > 1000)) {
$error = '"'.$ermes.'" was not valid';
break;
}
}
}
}
//date format
$settingsinfo->general->dateshow = $_POST['dateshow'];
// Panel appearance is user based
// Re assign a POST value means it is later used in 'update_account' function
$usid = $_SESSION['userID'];
foreach (glob('style/'.$usid.'/*.css') as $cssfile)
unlink($cssfile);
if ($_POST['panel'] != 'light') {
$nstyle = file_get_contents('cm'.$_POST['panel'].'.css');
file_put_contents('style/'.$usid.'/cm'.$_POST['panel'].'.css',$nstyle);
}
$_POST['userdescription'] = (isset($_POST['userdescription'])) ? strip_tags($_POST['userdescription']) : ' '; // re assign a POST value
if (strlen($_POST['userdescription']) > 400)
$error = 'Editor description was too big';
// user based settings
$on_off_personal = array('signposts','pluginsmenushow');
foreach($on_off_personal as $onoff) {
if ($_POST[$onoff] != 'on')
$_POST[$onoff] = 'off';
}
// administrator based settings
$on_off_values = array('tagshow','makenote');
foreach($on_off_values as $onoff) {
$val = $_POST[$onoff];
if ($val != 'on')
$val = 'off';
$settingsinfo->general->$onoff = $val;
}
$textual_values = array('maximagesize'=>$max,'indexposts'=>$indexposts,'proposts'=>$proposts,'ppageposts'=>$ppageposts,'note'=> $quick_note,'description'=>$website_description,'title'=>$website_title,'ppage'=>$ppp);
foreach($textual_values as $tag=>$val) {
if ($val != '') {
if (!isset($error)) {
if (array_search($tag,$num_of_posts) !== false) {
$settingsinfo->general->$tag->results = $val;
if($tag != 'proposts')
$settingsinfo->general->$tag->lastmod = time();
}
else
$settingsinfo->general->$tag = $val;
if ($tag == 'ppage')
rename('../'.$oldpp.'.php','../'.$ppp.'.php');
}
}
}
// the error message
$error_meg = '<div id="error-confirm"><span>'.$error.'</span></div>';
// If there were no errors...
if (!isset($error)) {
//mod time
$settingsinfo->general->modified = time();
//update user account
update_account($_SESSION['userID'],'set');
//update settings
$settingsinfo->asXML('filesinfo/settings.xml');
$_SESSION['settingsset'] = 'set';
header('Location:general.php');
exit();
}
else {
$_SESSION['ERROR'] = $error_meg;
header('Location:general.php');
exit();
}
}
$sess = array('usericon','backgroundicon');
foreach($sess as $sv)
if(isset($_SESSION[$sv]))
unset($_SESSION[$sv]);
$settingsXML = simplexml_load_file('filesinfo/settings.xml');
// Date format
$dates = array('F d, l, Y','d F, Y','l, d F, Y','D d F, Y','d M Y','d.m.Y','m.d.Y','none(turn off)','off');
$cssval = array_search((string)$settingsXML->general->dateshow,$dates)
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Settings</title>
<link rel="stylesheet" type="text/css" href="cmstyle.css">
<?php
$rt = 'style/'.$_SESSION['userID'];
$styles = array('cmdark.css');
foreach ($styles as $css){
if (is_file($rt.'/'.$css)) {
$panel = $css;
print '<link rel="stylesheet" type="text/css" href="'.$rt.'/'.$css.'">'.PHP_EOL;
break;
}
else
$panel = 'light';
}
// minimenu plugin is inserted here as well, because of the way general.php checks for appearance changes every time.
include_once 'plugin.php';
insert('minimenu')
?>
<style type="text/css">
@charset "utf-8";
#dinp-<?php print $cssval+1 ?>:checked + label:before{opacity:.5;<?php print ($panel == 'light') ? 'box-shadow:inset 0 0 0 2px #f7f7f7;background-color:#999;' : 'background-color:#aaa;box-shadow:inset 0 0 0 2px #222' ?>}
#dinp-<?php print $cssval+1 ?> + label{opacity:.5}
#dinp-<?php print $cssval+1 ?>:checked + label{opacity:1}
</style>
<script type="text/javascript">
function tognote(){
togsw = document.getElementById('note-on');
noteinp = document.getElementById('quick-note');
if (togsw.checked == false)
noteinp.setAttribute('disabled','true');
else
noteinp.removeAttribute('disabled');
}
</script>
</head>
<body>
<?php
include 'mypanel.php'
?>
<div class="main">
<h1>Settings</h1>
<div class="center-container">
<?php
if (isset($_SESSION['ERROR'])) {
echo $_SESSION['ERROR'];
unset ($_SESSION['ERROR']);
}
if (isset($_SESSION['settingsset'])) {
echo '<div id="action-confirm"><span>Settings saved</span></div>';
unset($_SESSION['settingsset']);
}
$website_title = $settingsXML->general->title;
$website_description = $settingsXML->general->description;
$note = $settingsXML->general->note;
$makenote = $settingsXML->general->makenote;
$posts = $settingsXML->general->indexposts->results;
$maxsize = $settingsXML->general->maximagesize;
$date = $settingsXML->general->dateshow;
$theme = $settingsXML->general->theme;
$tags = $settingsXML->general->tagshow;
// User based settings load
$acc_info = get_account($_SESSION['userID']);
$signposts = $acc_info['signposts'];
$description = $acc_info['description'];
$plgs = $acc_info['plugins menu']
?>
<div id="settings">
<!-- Form -->
<form action="general.php" method="post">
<!-- Website settings -->
<div class="website">
<h3>Website settings</h3>
<!-- Title -->
<label for="website-title" class="lab-5">Title</label>
<input name="title" type="text" id="website-title" class="inp-2" value="<?php print $website_title ?>">
<div class="clear-s"></div>
<!--
Description -->
<label for="website-description" class="lab-5">Description</label>
<input name="description" type="text" id="website-description" class="inp-2" title="Website description" value="<?php print $website_description ?>">
<div class="clear-s" style="height:50px"></div>
<!--
Date format (previous Date show) -->
<h4 style="font-weight:normal;font-size:15px">Date format</h4>
<?php
$off = array_pop($dates);
$turnoff = array_pop($dates);
$date_inp = '<input name="dateshow" class="inp-65" type="radio" ';
$cid = 1;
foreach($dates as $dopt) {
$check = ($date == $dopt) ? 'checked' : '';
if ($dopt == 'F d, l, Y')
if ($date == 'on')
$check = 'checked';
print $date_inp.'id="dinp-'.$cid.'" value="'.$dopt.'" '.$check.'><label for="dinp-'.$cid.'" class="lab-5">'.date($dopt).'</label><br>';
$cid++;
}
$offch = ($date == $off || $date == $turnoff) ? 'checked' : '';
print $date_inp.'id="dinp-'.$cid.'" value="none(turn off)" '.$offch.'><label for="dinp-'.$cid. '" class="lab-5">none(turn off)</label>'
?>
<div class="clear-s" style="height:50px"></div>
<!--
Announcement note -->
<input name="makenote" id="note-on" type="checkbox" class="inp-5" onclick="tognote();" value="on"<?php if ($makenote == 'on') print ' checked' ?>>
<label for="note-on" title="Make a quick announcement" class="lab-5">Make an announcement from the top of your pages</label>
<input name="quicknote" type="text" id="quick-note" class="inp-2" title="Quick note" value="<?php print $note ?>"<?php if ($makenote != 'on') print ' disabled="true"'?>>
<div class="clear-s"></div>
<!--
Tags show -->
<input name="tagshow" type="checkbox" id="tag-show" class="inp-5" value="on"<?php if ($tags == 'on') print ' checked' ?>>
<label for="tag-show" class="lab-5">Show Tags</label>
<div class="clear-s" style="height:50px"></div>
<!--
Results per page -->
<label for="results-in-homepage" class="lab-5"> Results in home page: </label>
<input name="indexposts" type="text" id="results-in-homepage" class="inp-4" value="<?php print $posts ?>">
<!-- qmark description -->
<span class="qmark">?<span class="details">Write '0' to completely remove from home page.</span></span>
<div class="clear"></div>
<!-- END -->
</div>
<!-- Control panel settings -->
<div class="control-panel">
<h3>Control panel settings</h3>
<!-- Upload image size -->
<label for="maxupload" class="lab-5"> Max upload image size: </label>
<input name="maximagesize" type="text" id="maxupload" class="inp-7" value="<?php print $maxsize ?>">kb
<div class="clear-s"></div><br>
<!--
Color theme -->
<label class="lab-5" style="margin-right:12px">Color theme: </label>
<input name="panel" type="radio" id="rd-1" class="inp-65" value="light" title="Standard"<?php if ($panel == 'light') print ' checked' ?>>
<label for="rd-1">Light</label>
<input name="panel" type="radio" id="rd-3" class="inp-65" value="dark" title="Dark"<?php if ($panel == 'cmdark.css') print ' checked' ?>>
<label for="rd-3" style="margin-left:10px">Dark</label><br>
<br>
<br>
<!-- plugins menu option -->
<input name="pluginsmenushow" type="checkbox" id="plg-show" class="inp-5" value="on"<?php if ($plgs == 'on') print ' checked' ?>>
<label for="plg-show" class="lab-5">Plugins menu always expanded</label>
<div class="clear-s"></div>
<!-- Refresh system -->
<a class="setlink" href="refresh.php" target="_blank">System refresh</a><br>
<span style="font-size:12px">Check system files health.</span>
<!-- qmark description -->
<span class="qmark">?<span class="details">This is going to: <li>- adjust the file counters,</li><li>- recover accidentally deleted pages</li></span></span>
</div>
<!-- User settings -->
<div class="user-settings">
<h3>User settings</h3>
<!-- Sign posts -->
<input id="signposts" name="signposts" type="checkbox" value="on" class="inp-9"<?php if ($signposts == 'on') print ' checked' ?>>
<label for="signposts" class="lab-5">Sign posts</label>
<div class="clear-s"></div>
<!--
User description -->
<label for="description" class="lab-5">Some information about yourself:</label>
<input name="userdescription" type="text" id="description" class="inp-76" value="<?php print $description ?>">
<div class="clear"></div>
<!-- END
User icon -->
<div>
<div>User icon</div>
<!-- upload iframe -->
<iframe src="upload_icon.php" name="user-image" id="user-image"></iframe>
<input type="button" value="Open folder" class="openbutton" id="open-folder" title="Open user images folder" onclick="opendiv();">
</div>
<div id="userfolder" class="closedfolder">
<div id="close-folder" onclick="closediv();">X</div>
<div class="spinner">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
<iframe id="icons-folder" name="icons-folder" src=""></iframe>
</div>
<script type="text/javascript">
function opendiv(){
var d = document.getElementById("userfolder");
if ( d.className == "closedfolder" ){
d.className = "openedfolder";
document.getElementById("icons-folder").setAttribute("src","icon-set.php");}
}
function closediv() {
var d = document.getElementById("userfolder");
var ifr = document.getElementById("user-image");
if ( d.className == "openedfolder" ){
d.className = "closedfolder";
ifr.src = ifr.src; }
}
</script>
</div>
<!--
Change login pasword -->
<a href="password_change.php" class="setlink">Change your log in password</a><br>
<!-- SAVE -->
<input id="general-submit" class="stylish-button" type="submit" value="Save settings" name="formsubmitted">
</form>
</div>
</div>
</div>
</body>
</html>