newpage.php

File Type: php File Location: monofiles/ File name: newpage.php
<?php
    
include_once 'data_connect.php'
?>
<!doctype html>
<html>
<head>
<title>Post</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="cmstyle.css">
<style type="text/css">@charset "utf-8"; .main{left:0;max-width:initial}</style>
<?php include 'csstheme.php' ?>
<script type="text/javascript">
    function loadc() {
        var _code = document.getElementById("output").value;
        document.getElementById("editor").innerHTML = _code;
    }
</script>
<script type="text/javascript" src="javascript/save.js"></script>
<script type="text/javascript">
    function warning(){
    var d = document.getElementById("page"); 
    if ( d.className == "nocontent" ){
    d.className = d.className + " warn";
    }
}    
</script>
</head>
<body>
<?php

    
include 'mypanel.php';

    
$oscategory '-';

    
    if ( isset(
$_GET['savedname'])) {
    
    
        
$savedfile $_GET['savedname'];

        
        if (!
file_exists($savedfile)) {
            
            print 
'<div class="menuholder" style="margin-left:280px">Error: Information about the file cannot be found</div>';
            exit;
        
        }
        
        
        
        
$xmlfile simplexml_load_file($savedfile);
        
        
        
// Check if access is allowed
        
if ( ($_SESSION['userID'] == $xmlfile->postinfo->post->createdby) || (get_account($_SESSION['userID'])['rights'] == 'administrator') ) {



            
$osbase basename($savedfile,".xml");

            
// headline
            
$ostitle $xmlfile->postinfo->post->title;

            
// filename
            
$osfilename $xmlfile->postinfo->post->filename;

            
//description
            
$osmetadescription $xmlfile->postinfo->post->description;
            
            
            
// tags
            
if ($xmlfile->postinfo->post->tags !== false)
                
$ostags $xmlfile->postinfo->post->tags;
            
            
            
// category
            
$oscategory = ($xmlfile->postinfo->post->category !== false) ? $xmlfile->postinfo->post->category '-';



            
// post content
            
$htmname str_replace('nu','',$osbase);
            
            
$html_content 'autosaves/content/'.$htmname.'.htm';
            
            
            if (
is_file('autosaves/content/nu'.$htmname.'.htm'))
                
$html_content 'autosaves/content/nu'.$htmname.'.htm';
        }
        
        

        else {
        print 
'<div class="menuholder" style="margin-left:280px">Oops! You cannot edit this file.</div>';
        exit;
        }
        
}

    include 
'en_code.php'

?>
    <div class="main">
        
        <form action="post.php" method="post" id="mainform" target="resultt"></form>
        
        <div id="action-block">

        
        
            <!-- iframe -->
            <div id="result-block">
                <iframe name="resultt" id="result" src="<?php echo (isset($oscategory)) ? 'post.php' 'pagepost.php' ?>" onload="iframeLoad();"></iframe>
            </div>
        
        
        
            <!-- Update or Post -->
            <input name="postbutton" type="submit" class="stylish-button" id="pd" value="<?php
                
                
if((isset($savedfile)) && (strpos($savedfile,'nu') !== false))
                    echo 
'Update';
                else 
                echo 
'Post'

            
?>" form="mainform">
            
            
            
            <!-- Save -->
            <input name="savebutton" type="submit" id="sd" class="stylish-button" value="Save" onClick="postsave();" form="mainform">
            <input type="text" id="uuid" name="uniqueid" value="<?php

            
echo (!isset($osbase)) ? time() : $osbase;

            
?>" form="mainform" hidden>
            
            
            
            <!-- Title input -->
            <textarea name="title" class="grow" id="headline" form="mainform" placeholder="Title"><?php
            
if(isset($ostitle))

                print 
load_xml($ostitle);
                        
            
?></textarea>
        
        
        
            
                <?php
                
include 'text-editor.php'
                
?>
                <div class="clear"></div>
            </div>
        
            <!-- Meta & info -->
            <div class="newpageright">
                
                
                
                <!-- Filename -->
                <div class="postinfo">Filename</div>
                <textarea type="text" name="filename" id="filename" form="mainform"><?php        

                
if(isset($osfilename))

                    print 
$osfilename

                ?>
</textarea>
                
                
                
                <!-- Meta description -->
                <div class="postinfo">Meta description</div>
                
                <textarea type="text" name="metadescription" id="metades" form="mainform"><?php

                    
if (isset($osmetadescription))
                        
                        print 
$osmetadescription ;
                    
                
?></textarea>
                
                <div class="clear"></div>
                
                
                
                <!-- Tags -->
                <div class="postinfo">Tags (separate with ',')</div>
                
                <textarea type="text" name="tags" id="tags" form="mainform"><?php 
                    
                    
if (isset($ostags))
                        print 
$ostags
                
                ?>
</textarea>
                
                
                
                <div class="clear"></div>
                
                
                
                <!-- Categories -->
                <div class="postinfo">Category</div>
                
                <div class="categories">
                    
                    <select name="category" class="selcat" onchange="warning();" form="mainform">
                        <option value=<?php print '"'.$oscategory.'">'.$oscategory ?></option>
                        <?php 
                        
if ($oscategory != '-'
                            print 
'<option value="-">-</option>'

                        
$folders glob('../category/*',GLOB_ONLYDIR);
                        foreach(
$folders as $catname){
                            
                            
$name file_get_contents($catname.'/name.txt');
                            
                            if (
$name != $oscategory)
                                echo 
'<option value="'.$name.'">'.$name.'</option>';    
                        }
                        
?>
                    </select>
                    
                </div>
                
            </div>
        
            <div style="height:100px;clear:both"></div>
        
        </div>
        <script type="text/javascript">
        document.getElementById("pd").onclick = function(){
            postsave();
            document.getElementById("page").setAttribute("class","nocontent");
        }
        </script>
        <script type="text/javascript">
            document.getElementById("filename").onkeyup = function() { warning(); }
            document.getElementById("filename").onpaste = function() { warning(); }
            document.getElementById("headline").onkeyup = function() { warning(); }
            document.getElementById("headline").onpaste = function() { warning(); }
            document.getElementById("output").onkeyup =  function()  { warning(); }
            document.getElementById("output").onpaste =  function()  { warning(); }
            document.getElementById("metades").onkeyup =  function()  { warning(); }
            document.getElementById("metades").onpaste =  function()  { warning(); }
            document.getElementById("tags").onkeyup =  function()  { warning(); }
            document.getElementById("tags").onpaste =  function()  { warning(); }
        </script>
        <script type="text/javascript">
        window.onbeforeunload = function(e) {
            if (document.querySelector(".warn") !== null) return false;
        }

        addEventListener("load",loadc);

        </script>
    </div>
</body>
</html>