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).
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<div id="bottom"><p>
|
<div id="bottom"><p>
|
||||||
All stories and submissions <a class="whitefont" href="about">©</a> 2003–<? echo gmdate("Y"); ?> their respective authors.
|
All stories and submissions <a class="whitefont" href="about">©</a> 2003–<? echo gmdate("Y"); ?> their respective authors.
|
||||||
</p></div>
|
</p></div>
|
||||||
|
<? $_SESSION['referrer'] = $_SERVER['REQUEST_URI']; ?>
|
||||||
<? include_once('google.inc.php'); ?>
|
<? include_once('google.inc.php'); ?>
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<?
|
<?
|
||||||
|
if ( ! isset($_SERVER['HTTPS'])) {
|
||||||
|
header('Location: https://' . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI']);
|
||||||
|
}
|
||||||
require_once("../session.lib.php");
|
require_once("../session.lib.php");
|
||||||
$added = FALSE;
|
$added = FALSE;
|
||||||
if (!isset($_SESSION['editor'])) {
|
if (!isset($_SESSION['editor'])) {
|
||||||
|
|||||||
+4
-1
@@ -1,7 +1,11 @@
|
|||||||
<?
|
<?
|
||||||
|
if ( ! isset($_SERVER['HTTPS'])) {
|
||||||
|
header('Location: https://' . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI']);
|
||||||
|
}
|
||||||
require_once("../session.lib.php");
|
require_once("../session.lib.php");
|
||||||
if (!isset($_SESSION['editor'])) {
|
if (!isset($_SESSION['editor'])) {
|
||||||
$is_admin = FALSE;
|
$is_admin = FALSE;
|
||||||
|
session_write_close();
|
||||||
header("Location: https://xxx.org.za/publish/login");
|
header("Location: https://xxx.org.za/publish/login");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -28,7 +32,6 @@ if (!isset($_SESSION['editor'])) {
|
|||||||
$editable = TRUE;
|
$editable = TRUE;
|
||||||
$id = get_id();
|
$id = get_id();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id='container'>
|
<div id='container'>
|
||||||
|
|||||||
+12
-4
@@ -1,11 +1,15 @@
|
|||||||
<?
|
<?
|
||||||
|
if ( ! isset($_SERVER['HTTPS'])) {
|
||||||
|
header('Location: https://' . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI']);
|
||||||
|
}
|
||||||
require_once("../session.lib.php");
|
require_once("../session.lib.php");
|
||||||
$denied = NULL;
|
$denied = NULL;
|
||||||
$is_admin = NULL;
|
$is_admin = NULL;
|
||||||
if (isset($_SESSION['editor'])) {
|
if (isset($_SESSION['editor'])) {
|
||||||
header("Location: http://xxx.org.za/publish/edit");
|
session_write_close();
|
||||||
|
header("Location: https://xxx.org.za/publish/edit");
|
||||||
|
return;
|
||||||
} else if (isset($_POST['login'])) {
|
} else if (isset($_POST['login'])) {
|
||||||
|
|
||||||
include_once('../open_db.lib.php');
|
include_once('../open_db.lib.php');
|
||||||
$table = "editors";
|
$table = "editors";
|
||||||
open_db('open');
|
open_db('open');
|
||||||
@@ -17,7 +21,8 @@ if (isset($_SESSION['editor'])) {
|
|||||||
$getid = $db->query($query) or die("Query failed: ".$db->error());
|
$getid = $db->query($query) or die("Query failed: ".$db->error());
|
||||||
$row = $getid->fetch_assoc();
|
$row = $getid->fetch_assoc();
|
||||||
|
|
||||||
if (isset($row)) $stored_password = $row['password'];
|
if (isset($row))
|
||||||
|
$stored_password = $row['password'];
|
||||||
else $denied = TRUE;
|
else $denied = TRUE;
|
||||||
$getid->close();
|
$getid->close();
|
||||||
open_db('close');
|
open_db('close');
|
||||||
@@ -35,10 +40,13 @@ if (isset($_SESSION['editor'])) {
|
|||||||
$url .= $_SERVER['HTTP_HOST'];
|
$url .= $_SERVER['HTTP_HOST'];
|
||||||
$url .= $_SESSION['referrer'];
|
$url .= $_SESSION['referrer'];
|
||||||
unset($_SESSION['referrer']);
|
unset($_SESSION['referrer']);
|
||||||
|
session_write_close();
|
||||||
header("Location: $url");
|
header("Location: $url");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
header("Location: http://xxx.org.za/publish/edit");
|
session_write_close();
|
||||||
|
header("Location: https://xxx.org.za/publish/edit");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -1,4 +1,7 @@
|
|||||||
<?
|
<?
|
||||||
|
if ( ! isset($_SERVER['HTTPS'])) {
|
||||||
|
header('Location: https://' . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI']);
|
||||||
|
}
|
||||||
require_once("../session.lib.php");
|
require_once("../session.lib.php");
|
||||||
if (isset($_SESSION['editor'])) {
|
if (isset($_SESSION['editor'])) {
|
||||||
if (isset($_COOKIE[session_name()])) {
|
if (isset($_COOKIE[session_name()])) {
|
||||||
@@ -18,7 +21,7 @@ if (isset($_SESSION['referrer'])) {
|
|||||||
header("Location: $url");
|
header("Location: $url");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
header("Location: /");
|
header("Location: http://xxx.org.za/");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
input#remember {
|
input#remember {
|
||||||
margin-left: -2px;
|
margin-left: -2px;
|
||||||
margin-top: 7px;
|
margin-top: 7px;
|
||||||
|
width: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#story {
|
#story {
|
||||||
|
|||||||
+16
-12
@@ -1,17 +1,21 @@
|
|||||||
<?
|
<?
|
||||||
require_once(realpath(dirname(__FILE__) . '/open_db.lib.php'));
|
require_once(realpath(dirname(__FILE__) . '/open_db.lib.php'));
|
||||||
session_cache_limiter('none');
|
|
||||||
session_set_cookie_params(strtotime('+1 year'), '/', '.xxx.org.za', TRUE, TRUE);
|
if (isset($_SERVER['HTTPS'])) {
|
||||||
session_start();
|
session_cache_limiter('private');
|
||||||
$_SESSION['referrer'] = $_SERVER['REQUEST_URI'];
|
session_set_cookie_params(strtotime('+1 year'), '/', '.xxx.org.za', TRUE, TRUE);
|
||||||
if (isset($_SESSION['editor'])) {
|
session_start();
|
||||||
$is_admin = TRUE;
|
|
||||||
$username = $_SESSION['editor'];
|
if (isset($_SESSION['editor'])) {
|
||||||
} elseif (check_persistent_login()) {
|
$is_admin = TRUE;
|
||||||
$is_admin = TRUE;
|
$username = $_SESSION['editor'];
|
||||||
$username = $_SESSION['editor'];
|
} elseif (check_persistent_login()) {
|
||||||
} else {
|
// check_persistent_login() sets $_SESSION['editor']
|
||||||
$is_admin = FALSE;
|
$is_admin = TRUE;
|
||||||
|
$username = $_SESSION['editor'];
|
||||||
|
} else {
|
||||||
|
$is_admin = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_persistent_login() {
|
function check_persistent_login() {
|
||||||
|
|||||||
Reference in New Issue
Block a user