generaluser.php

File Type: php File Location: monofiles/ File name: generaluser.php
<?php

    
include_once 'data_connect.php';
    include 
'log.php';
    
    if(
get_account($_SESSION['userID'])['rights'] == 'administrator'){
        
header('Location:general.php');
        exit();
    }
    if (isset(
$_POST['formsubmitted'])) {
        
    
        
// Panel appearance
        
        
$usid $_SESSION['userID'];
        
        foreach(
glob('style/'.$usid.'/*.css') as $cssfile)
                
unlink($cssfile);
                
        if (
$_POST['panel'] != 'black'){
            
$nstyle file_get_contents('cm'.$_POST['panel'].'.css');
            
file_put_contents('style/'.$usid.'/cm'.$_POST['panel'].'.css',$nstyle);
        }
        
        
        
        
$ed_desc get_account($_SESSION['userID'])['description'];
    
        if (
$_POST['description'] != $ed_desc) {
                
            
$_POST['description'] = strip_tags($_POST['description']); // re assign a POST value
            
            
if (strlen($_POST['description']) > 400)
                
$message '<div id="error-confirm"><span>Editor description is too big</span></div>';
        }

        
        
$on_off_personal = array('signposts','sidemenu');
        foreach(
$on_off_personal as $onoff) {                
                
                if (
$_POST[$onoff] != 'on')
                    
$_POST[$onoff] = 'off';
        }
        

        if (!isset(
$message)) {
                        
            if (isset(
$_SESSION['usericon']))
                
$_POST['iconset'] = $_SESSION['usericon'];

            
update_account($_SESSION['userID'],'set');
                
            
            
$_SESSION['settingsset'] = 'set';
            
header('Location:generaluser.php');
            exit();
        }
    }
    
    
$sess = array('usericon','backgroundicon');
    foreach(
$sess as $sv)
        if(isset(
$_SESSION[$sv]))
            unset(
$_SESSION[$sv]);
?>
<!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';
    }

?>
</head>
<body>
<?php
        
include 'mypanel.php'
?>
<div class="main">
<h1>Settings</h1>
<div class="center-container">
<?php
    
    
if (isset($message))
        
        echo 
$message;
    
        if (isset(
$_SESSION['settingsset'])) {
        
            echo 
'<div id="action-confirm"><span>Settings saved</span></div>';
        
            unset(
$_SESSION['settingsset']);
        }
        
    
    
$signposts $acc_info['signposts'];
    
$description $acc_info['description'];
    
?>
<form action="generaluser.php" method="post">
<div id="settings">
    
    <!-- Control panel settings -->
                    
                    <div class="control-panel">
                        
                        <h3>Control panel settings</h3>
                        
                        
                        <!-- Color theme -->
                        
                        <label class="lab-5" style="margin-right:40px">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:45px">Dark</label>
                        
                        <!-- END -->
                        
                        
                    </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>
                        
                        <!-- END
                        
                        
                        
                        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" style="margin-left:0"></iframe>
                            <input type="button" value="Open folder" class="openbutton" id="open-folder" title="Open user images folder" style="margin-left:0" 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>
                    
                    <!-- END 
                    
                    
                    Change login pasword -->
                    
                    <a href="password_change.php" class="setlink">Change your log in password</a>
                    
                    <!-- END
                    
                    
                    
                    SAVE -->
                    <input id="general-submit" class="stylish-button" type="submit" value="Save" name="formsubmitted">

                </div>
            </form>
        </div>
    </div>
</body>
</html>