Changeset 663
- Timestamp:
- 12/01/06 23:11:32 (2 years ago)
- Files:
-
- branches/punbb-1.3-dev/extras/db_update.php (modified) (1 diff)
- branches/punbb-1.3-dev/upload/include/functions.php (modified) (2 diffs)
- branches/punbb-1.3-dev/upload/install.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/punbb-1.3-dev/extras/db_update.php
r659 r663 322 322 } 323 323 324 // We need to add a unique index to avoid users having multiple rows in the online table 325 if ($db_type == 'mysql' || $db_type == 'mysqli') 326 { 327 $result = $db->query('SHOW INDEX FROM '.$db->prefix.'online WHERE Key_name = "'.$db->prefix.'online_user_id_ident_idx"') or error('Unable to check DB structure.', __FILE__, __LINE__, $db->error()); 328 329 if ($db->num_rows($result) == 0) 330 $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()); 331 } 332 324 333 // Finally, we update the version number 325 334 $db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$update_to.'\' WHERE conf_name=\'o_cur_version\'') or error('Unable to update version.', __FILE__, __LINE__, $db->error()); branches/punbb-1.3-dev/upload/include/functions.php
r662 r663 102 102 { 103 103 $pun_user['logged'] = $now; 104 $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()); 105 104 105 // With MySQL/MySQLi, REPLACE INTO avoids a user having two rows in the online table 106 switch ($db_type) 107 { 108 case 'mysql': 109 case 'mysqli': 110 $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()); 111 break; 112 113 default: 114 $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()); 115 break; 116 } 117 106 118 // Reset tracked topics 107 119 set_tracked_topics(null); … … 146 158 // Update online list 147 159 if (!$pun_user['logged']) 148 $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()); 160 { 161 // With MySQL/MySQLi, REPLACE INTO avoids a user having two rows in the online table 162 switch ($db_type) 163 { 164 case 'mysql': 165 case 'mysqli': 166 $db->query('REPLACE 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()); 167 break; 168 169 default: 170 $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()); 171 break; 172 } 173 } 149 174 else 150 175 $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()); branches/punbb-1.3-dev/upload/install.php
r652 r663 1307 1307 case 'mysqli': 1308 1308 // We use MySQL's ALTER TABLE ... ADD INDEX syntax instead of CREATE INDEX to avoid problems with users lacking the INDEX privilege 1309 $queries[] = 'ALTER TABLE '.$db_prefix.'online ADD UNIQUE INDEX '.$db_prefix.'online_user_id_ident_idx(user_id,ident)'; 1309 1310 $queries[] = 'ALTER TABLE '.$db_prefix.'online ADD INDEX '.$db_prefix.'online_user_id_idx(user_id)'; 1310 1311 $queries[] = 'ALTER TABLE '.$db_prefix.'posts ADD INDEX '.$db_prefix.'posts_topic_id_idx(topic_id)';
