diff options
-rw-r--r-- | database/database.mssql | 2 | ||||
-rw-r--r-- | database/database.mysql | 2 | ||||
-rw-r--r-- | database/database.pgsql | 2 | ||||
-rw-r--r-- | includes/common.inc | 2 | ||||
-rw-r--r-- | modules/node.module | 8 | ||||
-rw-r--r-- | modules/node/node.module | 8 | ||||
-rw-r--r-- | modules/user.module | 35 | ||||
-rw-r--r-- | modules/user/user.module | 35 | ||||
-rw-r--r-- | update.php | 7 |
9 files changed, 42 insertions, 59 deletions
diff --git a/database/database.mssql b/database/database.mssql index 091d3a021..1701fdade 100644 --- a/database/database.mssql +++ b/database/database.mssql @@ -472,7 +472,7 @@ INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Intern INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2002-05-15";'); INSERT INTO variable(name,value) VALUES('theme_default','s:6:"marvin";'); -INSERT INTO users(uid,name,mail) VALUES(0,'Anonymous','root@localhost'); +INSERT INTO users(uid,name,mail,rid) VALUES(0,'Anonymous','root@localhost','1'); INSERT INTO blocks(module,delta,status,custom,region,weight,path) VALUES('user', 0, 1, 0, 1, 0, ''); INSERT INTO blocks(module,delta,status,custom,region,weight,path) VALUES('user', 1, 1, 0, 1, 0, ''); diff --git a/database/database.mysql b/database/database.mysql index 959f15c28..accb2ac22 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -578,7 +578,7 @@ INSERT INTO system VALUES ('modules/page.module','page','module','',1); INSERT INTO system VALUES ('modules/story.module','story','module','',1); INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1); INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1); -INSERT INTO users (uid, name, mail) VALUES ('0', 'Anonymous', 'root@localhost'); +INSERT INTO users (uid, name, mail, rid) VALUES ('0', 'Anonymous', 'root@localhost', '1'); REPLACE variable SET name='update_start', value='s:10:"2003-04-19;"'; REPLACE variable SET name='theme_default', value='s:6:"marvin";'; diff --git a/database/database.pgsql b/database/database.pgsql index 5bffed0c7..559293d17 100644 --- a/database/database.pgsql +++ b/database/database.pgsql @@ -580,7 +580,7 @@ INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Intern INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-04-19";'); INSERT INTO variable(name,value) VALUES('theme_default','s:6:"marvin";'); -INSERT INTO users(uid,name,mail) VALUES(0,'Anonymous','root@localhost'); +INSERT INTO users(uid,name,mail,rid) VALUES(0,'Anonymous','root@localhost', '1'); INSERT INTO blocks(module,delta,status) VALUES('user', '0', '1'); INSERT INTO blocks(module,delta,status) VALUES('user', '1', '1'); diff --git a/includes/common.inc b/includes/common.inc index cae9f0661..341f1da2b 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -670,7 +670,7 @@ function format_rss_channel($title, $link, $description, $items, $language = "en $output .= " <description>". drupal_specialchars($description) ."</description>\n"; $output .= " <language>". drupal_specialchars(strip_tags($language)) ."</language>\n"; foreach ($args as $key => $value) { - $output .= "<$key>". drupal_specialchars(strip_tags($value)) ."</$key>"; + $output .= " <$key>". drupal_specialchars(strip_tags($value)) ."</$key>\n"; } $output .= $items; $output .= "</channel>\n"; diff --git a/modules/node.module b/modules/node.module index 978b01839..77667b614 100644 --- a/modules/node.module +++ b/modules/node.module @@ -983,19 +983,19 @@ function node_feed($nodes = 0, $channel = array()) { /* ** Load the specified node: */ - + $item = node_load(array("nid" => $node->nid)); - + /* ** Transform the node information into an RSS item: */ - + $items .= format_rss_item($item->title, url(node_url($node)), ($item->teaser ? $item->teaser : $item->body)); /* ** Determine the publication date: */ - + if ($item->updated > $pubdate) { $pubdate = $item->updated; } diff --git a/modules/node/node.module b/modules/node/node.module index 978b01839..77667b614 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -983,19 +983,19 @@ function node_feed($nodes = 0, $channel = array()) { /* ** Load the specified node: */ - + $item = node_load(array("nid" => $node->nid)); - + /* ** Transform the node information into an RSS item: */ - + $items .= format_rss_item($item->title, url(node_url($node)), ($item->teaser ? $item->teaser : $item->body)); /* ** Determine the publication date: */ - + if ($item->updated > $pubdate) { $pubdate = $item->updated; } diff --git a/modules/user.module b/modules/user.module index 2759ff4d7..bb13b1e62 100644 --- a/modules/user.module +++ b/modules/user.module @@ -37,8 +37,13 @@ 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 hostname = '%s', session = '%s', timestamp = %d WHERE sid = '$key'", $_SERVER["REMOTE_ADDR"], $value, time()); + 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()); + } return ''; } @@ -142,7 +147,7 @@ function user_save($account, $array = array()) { } else { $array["timestamp"] = time(); - $array["uid"] = db_next_id("user_uid"); + $array["uid"] = db_next_id("users_uid"); foreach ($array as $key => $value) { if ($key == "pass") { @@ -587,7 +592,7 @@ function user_login($edit = array(), $msg = "") { ** Try to log in the user locally: */ - if (!$user) { + if (!$user->uid) { $name = $edit["name"]; $pass = $edit["pass"]; $user = user_load(array("name" => $name, "pass" => $pass, "status" => 1)); @@ -607,7 +612,7 @@ function user_login($edit = array(), $msg = "") { ** When possible, determine corrosponding external auth source. Invoke source, and login user if successful: */ - if (!$user && $server && $result = user_get_authmaps("$name@$server")) { + if (!$user->uid && $server && $result = user_get_authmaps("$name@$server")) { if (module_invoke(key($result), "auth", $name, $pass, $server)) { $user = user_external_load("$name@$server"); watchdog("user", "external load: $name@$server, module: ". key($result)); @@ -621,7 +626,7 @@ function user_login($edit = array(), $msg = "") { ** Try each external authentication source in series. Register user if successful. */ - else if (!$user && $server) { + else if (!$user->uid && $server) { foreach (module_list() as $module) { if (module_hook($module, "auth")) { if (module_invoke($module, "auth", $name, $pass, $server)) { @@ -638,24 +643,8 @@ function user_login($edit = array(), $msg = "") { if ($user->uid) { watchdog("user", "session opened for '$user->name'"); - /* - ** Write session ID to database: - ** (TODO: Currently we only save the session if a user is logged in. - ** we should also add support for anonymous user sessions.) - */ - - if ($user->uid) { - // update the user's session if it already exists - db_query("UPDATE {sessions} SET timestamp = '%d' WHERE sid = '%s'", time(), session_id()); - - // if no changes, this is a new session to be added - if (!db_affected_rows()) { - db_query("INSERT INTO {sessions} (uid, sid, hostname, timestamp) values(%d, '%s', '%s', %d)", $user->uid, session_id(), $_SERVER["REMOTE_ADDR"], time()); - } - - // also update the user table timestamp noting user has logged in - db_query("UPDATE {users} SET timestamp = '%d' WHERE uid = '%s'", time(), $user->uid); - } + // update the user table timestamp noting user has logged in + db_query("UPDATE {users} SET timestamp = '%d' WHERE uid = '%s'", time(), $user->uid); /* ** If the user wants to be remembered, set the proper cookie such diff --git a/modules/user/user.module b/modules/user/user.module index 2759ff4d7..bb13b1e62 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -37,8 +37,13 @@ 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 hostname = '%s', session = '%s', timestamp = %d WHERE sid = '$key'", $_SERVER["REMOTE_ADDR"], $value, time()); + 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()); + } return ''; } @@ -142,7 +147,7 @@ function user_save($account, $array = array()) { } else { $array["timestamp"] = time(); - $array["uid"] = db_next_id("user_uid"); + $array["uid"] = db_next_id("users_uid"); foreach ($array as $key => $value) { if ($key == "pass") { @@ -587,7 +592,7 @@ function user_login($edit = array(), $msg = "") { ** Try to log in the user locally: */ - if (!$user) { + if (!$user->uid) { $name = $edit["name"]; $pass = $edit["pass"]; $user = user_load(array("name" => $name, "pass" => $pass, "status" => 1)); @@ -607,7 +612,7 @@ function user_login($edit = array(), $msg = "") { ** When possible, determine corrosponding external auth source. Invoke source, and login user if successful: */ - if (!$user && $server && $result = user_get_authmaps("$name@$server")) { + if (!$user->uid && $server && $result = user_get_authmaps("$name@$server")) { if (module_invoke(key($result), "auth", $name, $pass, $server)) { $user = user_external_load("$name@$server"); watchdog("user", "external load: $name@$server, module: ". key($result)); @@ -621,7 +626,7 @@ function user_login($edit = array(), $msg = "") { ** Try each external authentication source in series. Register user if successful. */ - else if (!$user && $server) { + else if (!$user->uid && $server) { foreach (module_list() as $module) { if (module_hook($module, "auth")) { if (module_invoke($module, "auth", $name, $pass, $server)) { @@ -638,24 +643,8 @@ function user_login($edit = array(), $msg = "") { if ($user->uid) { watchdog("user", "session opened for '$user->name'"); - /* - ** Write session ID to database: - ** (TODO: Currently we only save the session if a user is logged in. - ** we should also add support for anonymous user sessions.) - */ - - if ($user->uid) { - // update the user's session if it already exists - db_query("UPDATE {sessions} SET timestamp = '%d' WHERE sid = '%s'", time(), session_id()); - - // if no changes, this is a new session to be added - if (!db_affected_rows()) { - db_query("INSERT INTO {sessions} (uid, sid, hostname, timestamp) values(%d, '%s', '%s', %d)", $user->uid, session_id(), $_SERVER["REMOTE_ADDR"], time()); - } - - // also update the user table timestamp noting user has logged in - db_query("UPDATE {users} SET timestamp = '%d' WHERE uid = '%s'", time(), $user->uid); - } + // update the user table timestamp noting user has logged in + db_query("UPDATE {users} SET timestamp = '%d' WHERE uid = '%s'", time(), $user->uid); /* ** If the user wants to be remembered, set the proper cookie such diff --git a/update.php b/update.php index 03eb29f47..d4fef9ffc 100644 --- a/update.php +++ b/update.php @@ -44,7 +44,8 @@ $mysql_updates = array( "2003-08-15" => "update_60", "2003-08-20" => "update_61", "2003-08-27" => "update_62", - "2003-09-09" => "update_63" + "2003-09-09" => "update_63", + "2003-09-10" => "update_64" ); function update_32() { @@ -388,6 +389,10 @@ function update_63() { update_sql("INSERT INTO sequences (name, id) VALUES ('users_uid', '$users')"); } +function update_64() { + update_sql("UPDATE users SET rid = 1 WHERE uid = 0"); +} + /* ** System functions */ |