diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2009-01-05 21:48:01 -0500 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2009-01-05 21:48:01 -0500 |
commit | 1cb945e201704062e9940f327464f4b31a861f20 (patch) | |
tree | e2e8ddc9d4681c605621ed1132168cdb7b9eb93b /includes/session.php | |
parent | 9ba37f4643f825052c002bda16884ccc73f57ebc (diff) | |
download | fourisland-1cb945e201704062e9940f327464f4b31a861f20.tar.gz fourisland-1cb945e201704062e9940f327464f4b31a861f20.tar.bz2 fourisland-1cb945e201704062e9940f327464f4b31a861f20.zip |
Changed comments' user index
Previously, the comments table referenced users by username. However, if user ever changed their username, everything would become messed up. To fix this, the index has been changed to the user ID. This change obviously requires maintenance: This SQL must be run: "ALTER TABLE `comments` ADD `user_id` INT( 11 ) NOT NULL AFTER `page_id`;" This PHP will generate some SQL that must be run: <?php $getusers = "SELECT DISTINCT username FROM comments WHERE is_anon = 0"; $getusers2 = mysql_query($getusers); while ($getusers3 = mysql_fetch_array($getusers2)) { $getuser = "SELECT * FROM phpbb_users WHERE username = \"" . $getusers3['username'] . "\""; $getuser2 = mysql_query($getuser); $getuser3 = mysql_fetch_array($getuser2); echo("UPDATE comments SET user_id = " . $getuser3['user_id'] . " WHERE username = \"" . $getuser3['username'] . "\" AND is_anon = 0;<BR>"); } $getusers = "SELECT * FROM anon_commenters"; $getusers2 = mysql_query($getusers); while ($getusers3 = mysql_fetch_array($getusers2)) { echo("UPDATE comments SET user_id = " . $getusers3['id'] . " WHERE username = \"" . $getusers3['username'] . "\" AND is_anon = 1;<BR>"); } ?> This SQL must be run: "ALTER TABLE `comments` DROP `username`;"
Diffstat (limited to 'includes/session.php')
-rwxr-xr-x | includes/session.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/includes/session.php b/includes/session.php index 19ad24e..94c919a 100755 --- a/includes/session.php +++ b/includes/session.php | |||
@@ -38,6 +38,24 @@ function getSessionID() | |||
38 | return false; | 38 | return false; |
39 | } | 39 | } |
40 | 40 | ||
41 | function getSessionUserID() | ||
42 | { | ||
43 | $getconfig = "SELECT * FROM phpbb_config WHERE config_name LIKE \"cookie_name\""; | ||
44 | $getconfig2 = mysql_query($getconfig); | ||
45 | $getconfig3 = mysql_fetch_array($getconfig2); | ||
46 | |||
47 | if (isset($_COOKIE[$getconfig3['config_value'] . '_sid'])) | ||
48 | { | ||
49 | $getsession = "SELECT * FROM phpbb_sessions WHERE session_id LIKE \"" . mysql_real_escape_string($_COOKIE[$getconfig3['config_value'] . '_sid']) . "\""; | ||
50 | $getsession2 = mysql_query($getsession) or die($getsession); | ||
51 | $getsession3 = mysql_fetch_array($getsession2); | ||
52 | |||
53 | return $getsession3['session_user_id']; | ||
54 | } | ||
55 | |||
56 | return false; | ||
57 | } | ||
58 | |||
41 | function getSessionUsername() | 59 | function getSessionUsername() |
42 | { | 60 | { |
43 | $getconfig = "SELECT * FROM phpbb_config WHERE config_name LIKE \"cookie_name\""; | 61 | $getconfig = "SELECT * FROM phpbb_config WHERE config_name LIKE \"cookie_name\""; |