Commit 2ffa04f5 authored by Kjartan's avatar Kjartan

- Fixes bug #4100: First visit to site results in 'access denied' page.

- Fixed sess_write().
- Removed dead code in index.php.
parent fe9a6afa
......@@ -16,7 +16,14 @@ function sess_close() {
function sess_read($key) {
global $user;
$result = db_query_range("SELECT u.*, s.*, r.name AS role FROM {users} u INNER JOIN {role} r ON u.rid = r.rid INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '". check_query($key) ."' AND u.status < 3", 0, 1);
if ($key) {
$result = db_query_range("SELECT u.*, s.*, r.name AS role FROM {users} u INNER JOIN {role} r ON u.rid = r.rid INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '%s' AND u.status < 3", $key, 0, 1);
}
if (!db_num_rows($result)) {
$result = db_query("SELECT u.*, r.name AS role FROM {users} u INNER JOIN {role} r ON u.rid = r.rid WHERE u.uid = 0");
}
$user = db_fetch_object($result);
if ($user->data && $data = unserialize($user->data)) {
foreach ($data as $key => $value) {
......@@ -32,7 +39,7 @@ function sess_read($key) {
function sess_write($key, $value) {
global $user;
db_query("UPDATE {sessions} SET uid = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '$key'", $user->uid, $_SERVER["REMOTE_ADDR"], $value, time());
db_query("UPDATE {sessions} SET uid = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, $_SERVER["REMOTE_ADDR"], $value, time(), $key);
if (!db_affected_rows()) {
db_query("INSERT INTO {sessions} (uid, sid, hostname, session, timestamp) values(%d, '%s', '%s', '%s', %d)", $user->uid, $key, $_SERVER["REMOTE_ADDR"], $value, time());
......@@ -62,5 +69,4 @@ function sess_gc($lifetime) {
}
?>
\ No newline at end of file
......@@ -32,13 +32,8 @@
module_invoke($mod, "page");
}
else {
if (module_hook(variable_get("site_frontpage", "node"), "page")) {
module_invoke(variable_get("site_frontpage", "node"), "page");
}
else {
print theme("header");
print theme("footer");
}
print theme("header");
print theme("footer");
}
}
......
......@@ -15,7 +15,6 @@ function user_external_load($authname) {
}
function user_load($array = array()) {
/*
** Dynamically compose a SQL query:
*/
......@@ -121,7 +120,6 @@ function user_save($account, $array = array()) {
}
function user_validate_name($name) {
/*
** Verify the syntax of the given name:
*/
......@@ -150,7 +148,6 @@ function user_validate_authmap($account, $authname, $module) {
}
function user_password($length = 10) {
/*
** Generate a random alphanumeric password.
*/
......@@ -650,7 +647,6 @@ function user_logout() {
}
drupal_goto(url());
}
function user_pass($edit = array()) {
......
......@@ -15,7 +15,6 @@ function user_external_load($authname) {
}
function user_load($array = array()) {
/*
** Dynamically compose a SQL query:
*/
......@@ -121,7 +120,6 @@ function user_save($account, $array = array()) {
}
function user_validate_name($name) {
/*
** Verify the syntax of the given name:
*/
......@@ -150,7 +148,6 @@ function user_validate_authmap($account, $authname, $module) {
}
function user_password($length = 10) {
/*
** Generate a random alphanumeric password.
*/
......@@ -650,7 +647,6 @@ function user_logout() {
}
drupal_goto(url());
}
function user_pass($edit = array()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment