Changeset 773
- Timestamp:
- 01/15/07 01:07:18 (2 years ago)
- Files:
-
- trunk/extras/12_to_1214_update.php (modified) (1 diff)
- trunk/upload/include/functions.php (modified) (4 diffs)
- trunk/upload/install.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/extras/12_to_1214_update.php
r603 r773 124 124 } 125 125 126 // We need to add a unique index to avoid users having multiple rows in the online table 127 if ($db_type == 'mysql' || $db_type == 'mysqli') 128 { 129 $result = $db->query('SHOW INDEX FROM '.$db->prefix.'online') or error('Unable to check DB structure.', __FILE__, __LINE__, $db->error()); 130 131 if ($db->num_rows($result) == 1) 132 $db->query('ALTER TABLE '.$db->prefix.'online ADD UNIQUE INDEX '.$db->prefix.'online_user_id_ident_idx(user_id,ident)') or error('Unable to alter DB structure.', __FILE__, __LINE__, $db->error()); 133 } 126 134 127 135 // This feels like a good time to synchronize the forums trunk/upload/include/functions.php
r602 r773 28 28 function check_cookie(&$pun_user) 29 29 { 30 global $db, $ pun_config, $cookie_name, $cookie_seed;30 global $db, $db_type, $pun_config, $cookie_name, $cookie_seed; 31 31 32 32 $now = time(); … … 76 76 // Update the online list 77 77 if (!$pun_user['logged']) 78 $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); 78 { 79 $pun_user['logged'] = $now; 80 81 // With MySQL/MySQLi, REPLACE INTO avoids a user having two rows in the online table 82 switch ($db_type) 83 { 84 case 'mysql': 85 case 'mysqli': 86 $db->query('REPLACE INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); 87 break; 88 89 default: 90 $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); 91 break; 92 } 93 } 79 94 else 80 95 { … … 103 118 function set_default_user() 104 119 { 105 global $db, $ pun_user, $pun_config;120 global $db, $db_type, $pun_user, $pun_config; 106 121 107 122 $remote_addr = get_remote_address(); … … 116 131 // Update online list 117 132 if (!$pun_user['logged']) 118 $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES(1, \''.$db->escape($remote_addr).'\', '.time().')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); 133 { 134 $pun_user['logged'] = time(); 135 136 // With MySQL/MySQLi, REPLACE INTO avoids a user having two rows in the online table 137 switch ($db_type) 138 { 139 case 'mysql': 140 case 'mysqli': 141 $db->query('REPLACE INTO '.$db->prefix.'online (user_id, ident, logged) VALUES(1, \''.$db->escape($remote_addr).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); 142 break; 143 144 default: 145 $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES(1, \''.$db->escape($remote_addr).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); 146 break; 147 } 148 } 119 149 else 120 150 $db->query('UPDATE '.$db->prefix.'online SET logged='.time().' WHERE ident=\''.$db->escape($remote_addr).'\'') or error('Unable to update online list', __FILE__, __LINE__, $db->error()); trunk/upload/install.php
r603 r773 1235 1235 case 'mysqli': 1236 1236 // We use MySQL's ALTER TABLE ... ADD INDEX syntax instead of CREATE INDEX to avoid problems with users lacking the INDEX privilege 1237 $queries[] = 'ALTER TABLE '.$db_prefix.'online ADD UNIQUE INDEX '.$db_prefix.'online_user_id_ident_idx(user_id,ident)'; 1237 1238 $queries[] = 'ALTER TABLE '.$db_prefix.'online ADD INDEX '.$db_prefix.'online_user_id_idx(user_id)'; 1238 1239 $queries[] = 'ALTER TABLE '.$db_prefix.'posts ADD INDEX '.$db_prefix.'posts_topic_id_idx(topic_id)';
