All user/ pages require authentication against database users.

This commit is contained in:
Elyrith 2013-08-10 01:38:23 -04:00
parent 4dd163139f
commit 18a067a902
5 changed files with 12 additions and 6 deletions

View File

@ -1,9 +1,6 @@
<?php <?php
if (!$_COOKIE['session'] && ($_POST['do'] !== "authenticate")) { if ( $_COOKIE['session'] ) { // Do nothing
echo "Please login:"; } else if ($_POST['do'] == "authenticate") {
include "login_form.inc";
break;
} else {
require "dbconnect.php"; require "dbconnect.php";
$sql = "SELECT id,username FROM users WHERE username='$_POST[username]' and password=PASSWORD('$_POST[password]')"; $sql = "SELECT id,username FROM users WHERE username='$_POST[username]' and password=PASSWORD('$_POST[password]')";
@ -13,7 +10,7 @@ if (!$_COOKIE['session'] && ($_POST['do'] !== "authenticate")) {
if (mysql_num_rows($result) === 1) { if (mysql_num_rows($result) === 1) {
unset($_POST['do']); unset($_POST['do']);
$_COOKIE['session'] = 1; $_COOKIE['session'] = '1';
setcookie('session',$_COOKIE['session']); setcookie('session',$_COOKIE['session']);
} else { } else {
unset($_POST['do']); unset($_POST['do']);
@ -22,5 +19,9 @@ if (!$_COOKIE['session'] && ($_POST['do'] !== "authenticate")) {
include("login_form.inc"); include("login_form.inc");
break; break;
} }
} else {
echo "Please login:";
include "login_form.inc";
break;
} }
?> ?>

View File

@ -1,6 +1,7 @@
<?php <?php
require "../includes/htmlcode.php"; require "../includes/htmlcode.php";
start_html("Find post to edit"); start_html("Find post to edit");
include "../includes/login.inc";
?> ?>
<h1>Find post to edit</h1> <h1>Find post to edit</h1>

View File

@ -6,6 +6,8 @@ require "../includes/dbconnect.php";
require "../includes/htmlcode.php"; require "../includes/htmlcode.php";
start_html("Edit post"); start_html("Edit post");
include "../includes/login.inc";
print "<h1>Edit post</h1>"; print "<h1>Edit post</h1>";
$query = "SELECT * FROM blog WHERE date='$_GET[date]' AND title='$_GET[title]'"; $query = "SELECT * FROM blog WHERE date='$_GET[date]' AND title='$_GET[title]'";

View File

@ -1,6 +1,7 @@
<?php <?php
require "../includes/htmlcode.php"; require "../includes/htmlcode.php";
start_html("simlog user interface"); start_html("simlog user interface");
include "../includes/login.inc";
?> ?>
<h1>simplog user interface</h1> <h1>simplog user interface</h1>

View File

@ -6,6 +6,7 @@ require "../includes/dbconnect.php";
require "../includes/htmlcode.php"; require "../includes/htmlcode.php";
start_html("Post updated"); start_html("Post updated");
include "../includes/login.inc";
$query = "UPDATE blog SET date='$_POST[date]', title='$_POST[title]', $query = "UPDATE blog SET date='$_POST[date]', title='$_POST[title]',