105 lines
2.7 KiB
PHP
105 lines
2.7 KiB
PHP
<?php
|
|
if ( ! isset($_SERVER['HTTPS'])) {
|
|
header('Location: https://' . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI']);
|
|
exit;
|
|
}
|
|
require_once("../session.lib.php");
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>x.x.x [add]</title>
|
|
<link rel="icon" href="favicon.png" />
|
|
<link rel="shortcut icon" href="favicon.png" />
|
|
<link rel="stylesheet" type="text/css" href="../style.css" />
|
|
<link rel='stylesheet' type='text/css' href='../publish/style.css' />
|
|
<script type="text/javascript" src="../utilities.js"></script>
|
|
<link rel="alternate" type="application/rss+xml" title="xxx.org.za RSS feed" href="/feed" />
|
|
<?php include_once('tinymce_init.inc.php'); ?>
|
|
<?php if (!$is_admin ) { ?>
|
|
<script src="https://www.google.com/recaptcha/api.js"></script>
|
|
<?php } ?>
|
|
</head>
|
|
<?php
|
|
flush();
|
|
require_once("../get_data.lib.php");
|
|
open_db('open');
|
|
require_once("../navigation.lib.php");
|
|
require_once("./post.lib.php");
|
|
$editable = TRUE;
|
|
?>
|
|
<body>
|
|
<div id='container'>
|
|
<?php include_once("../sidebar.inc.php"); ?>
|
|
<div id='main'>
|
|
<div id='maintext'>
|
|
|
|
<h1>submit</h1>
|
|
|
|
<?php
|
|
/* Authenticated admin user allowed to: check the queue
|
|
edit article on the queue
|
|
optionally preview
|
|
post article to database
|
|
--------------------------
|
|
choose existing article
|
|
edit existing article
|
|
optionally preview
|
|
update article in database
|
|
--------------------------
|
|
write new article
|
|
preview (required)
|
|
post article to database
|
|
--------------------------
|
|
Ordinary web users can: write article
|
|
preview (required)
|
|
submit to the queue
|
|
|
|
*/
|
|
|
|
if (isset($_POST['action']))
|
|
$action = strtolower($_POST['action']);
|
|
else
|
|
$action = NULL;
|
|
|
|
// A POST without a valid CSRF token only gets a preview
|
|
if ($action && !csrf_valid()) {
|
|
$validate['csrf'] = 'Your session has expired. Please check your story, then send it again.';
|
|
$action = 'preview';
|
|
}
|
|
|
|
switch ($action) {
|
|
case 'post': // post to database
|
|
case 'save': // post to queue
|
|
case 'submit': // post to queue
|
|
if (validate_data() && count($validate) === 0) {
|
|
$id = save_data();
|
|
echo display_stories($id);
|
|
} else {
|
|
$action = 'preview';
|
|
include('./preview.inc.php');
|
|
}
|
|
break;
|
|
case 'preview': // preview before posting
|
|
validate_data();
|
|
include('./preview.inc.php');
|
|
break;
|
|
default: // write a new article
|
|
include('./write.inc.php');
|
|
break;
|
|
}
|
|
|
|
?>
|
|
|
|
</div> <!-- maintext -->
|
|
</div> <!-- main -->
|
|
</div> <!-- container -->
|
|
<?php include_once("../bottombar.inc.php"); ?>
|
|
|
|
<?php open_db('close'); ?>
|
|
|
|
</body>
|
|
</html>
|