Files
xxx/publish/addeditor.php
T
tim a00c1b4c9d Fix some issues with secure cookies being overwritten by insecure site.
Now, /publish/{edit,addeditor,login,logout} must be accessed via
https://; other pages should not be (but can be).
2014-04-24 09:56:25 +02:00

85 lines
2.5 KiB
PHP

<?
if ( ! isset($_SERVER['HTTPS'])) {
header('Location: https://' . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI']);
}
require_once("../session.lib.php");
$added = FALSE;
if (!isset($_SESSION['editor'])) {
header("Location: https://xxx.org.za/publish/login");
return;
} else if (isset($_POST['adduser'])) {
require_once('../open_db.lib.php');
open_db('open');
$table = "editors";
$username = $db->real_escape_string($_POST['username']);
$password = crypt($_POST['password']);
$email = $db->real_escape_string($_POST['email']);
$query = "INSERT INTO $table SET".
"`username` = '".$username."', ".
"`password` = '".$password."', ".
"`email` = '".$email."'; ";
if ($result = $db->query($query)) {
$added = TRUE;
$is_admin = TRUE;
}
open_db('close');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" value="text/html; charset=UTF-8" />
<title>x.x.x: add editor</title>
<link rel="shortcut icon" href="/favicon.png">
<link rel="icon" href="/favicon.png">
<link rel='stylesheet' type='text/css' href='/style.css'>
<link rel='stylesheet' type='text/css' href='/publish/style.css'>
<link rel="alternate" type="application/rss+xml" title="xxx.org.za RSS feed" href="/feed" />
</head>
<? flush(); ?>
<body>
<div id="container">
<!-- Include siderbar here -->
<? include_once('../sidebar.inc.php'); ?>
<!-- Continue with main page stuff -->
<div id="main">
<div id="maintext">
<H1>add editor</H1>
<? if ($added) { ?>
<p>Added editor <?= $username ?></p>
<? } else { ?>
<form action="https://xxx.org.za<?= $_SERVER['REQUEST_URI'] ?>" method="post">
<label for="username">Username: </label>
<input type="text" id="username" name="username" />
<br class="clear" />
<label for="password">Password: </label>
<input type="password" id="password" name="password" />
<br class="clear" />
<label for="email">Email: </label>
<input type="text" id="email" name="email" />
<br class="clear" />
<div class="submission">
<button type="submit" id="adduser" name="adduser" value="1">Add editor</button>
</div>
</form>
<? } ?>
</div> <!-- maintext -->
</div> <!-- main -->
</div> <!-- container -->
<!-- Include bottom bar here -->
<? include('../bottombar.inc.php'); ?>
<!-- Finis -->
</body>
</html>