upgrade_1-0.sql 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026
  1. /* ATTENTION: You don't need to run or use this file! The upgrade.php script does everything for you! */
  2. /******************************************************************************/
  3. --- Creating new tables and inserting default data...
  4. /******************************************************************************/
  5. ---# Creating "themes"...
  6. CREATE TABLE IF NOT EXISTS {$db_prefix}themes (
  7. ID_MEMBER mediumint(8) NOT NULL default '0',
  8. ID_THEME tinyint(4) unsigned NOT NULL default '1',
  9. variable tinytext NOT NULL default '',
  10. value text NOT NULL default '',
  11. PRIMARY KEY (ID_MEMBER, ID_THEME, variable(30))
  12. ) ENGINE=MyISAM;
  13. ALTER TABLE {$db_prefix}themes
  14. CHANGE COLUMN ID_MEMBER ID_MEMBER mediumint(8) NOT NULL default '0';
  15. ALTER TABLE {$db_prefix}themes
  16. CHANGE COLUMN value value text NOT NULL default '';
  17. INSERT IGNORE INTO {$db_prefix}themes
  18. (ID_MEMBER, ID_THEME, variable, value)
  19. VALUES (0, 1, 'name', 'SMF Default Theme'),
  20. (0, 1, 'theme_url', '{$boardurl}/Themes/default'),
  21. (0, 1, 'images_url', '{$boardurl}/Themes/default/images'),
  22. (0, 1, 'theme_dir', '{$sboarddir}/Themes/default'),
  23. (0, 1, 'allow_no_censored', '0'),
  24. (0, 1, 'additional_options_collapsable', '1'),
  25. (0, 2, 'name', 'Classic YaBB SE Theme'),
  26. (0, 2, 'theme_url', '{$boardurl}/Themes/classic'),
  27. (0, 2, 'images_url', '{$boardurl}/Themes/classic/images'),
  28. (0, 2, 'theme_dir', '{$sboarddir}/Themes/classic');
  29. ---#
  30. ---# Creating "collapsed_categories"...
  31. CREATE TABLE IF NOT EXISTS {$db_prefix}collapsed_categories (
  32. ID_CAT tinyint(4) unsigned NOT NULL default '0',
  33. ID_MEMBER mediumint(8) unsigned NOT NULL default '0',
  34. PRIMARY KEY (ID_CAT, ID_MEMBER)
  35. ) ENGINE=MyISAM;
  36. ---#
  37. ---# Creating and verifying "permissions"...
  38. CREATE TABLE IF NOT EXISTS {$db_prefix}permissions (
  39. ID_GROUP smallint(6) NOT NULL default '0',
  40. permission varchar(30) NOT NULL default '',
  41. addDeny tinyint(4) NOT NULL default '1',
  42. PRIMARY KEY (ID_GROUP, permission)
  43. ) ENGINE=MyISAM;
  44. ALTER TABLE {$db_prefix}permissions
  45. ADD addDeny tinyint(4) NOT NULL default '1';
  46. ALTER TABLE {$db_prefix}permissions
  47. CHANGE COLUMN permission permission varchar(30) NOT NULL default '';
  48. UPDATE IGNORE {$db_prefix}permissions
  49. SET
  50. permission = REPLACE(permission, 'profile_own_identity', 'profile_identity_own'),
  51. permission = REPLACE(permission, 'profile_any_identity', 'profile_identity_any'),
  52. permission = REPLACE(permission, 'profile_own_extra', 'profile_extra_own'),
  53. permission = REPLACE(permission, 'profile_any_extra', 'profile_extra_any'),
  54. permission = REPLACE(permission, 'profile_own_title', 'profile_title_own'),
  55. permission = REPLACE(permission, 'profile_any_title', 'profile_title_any'),
  56. permission = REPLACE(permission, 'im_read', 'pm_read'),
  57. permission = REPLACE(permission, 'im_send', 'pm_send');
  58. ---#
  59. ---# Inserting data into "permissions"...
  60. INSERT INTO {$db_prefix}permissions
  61. (ID_GROUP, permission)
  62. VALUES (-1, 'search_posts'), (-1, 'calendar_view'), (-1, 'view_stats'), (-1, 'profile_view_any'),
  63. (2, 'calendar_post'), (2, 'calendar_edit_any'), (2, 'calendar_edit_own');
  64. ---#
  65. ---# Creating and verifying "board_permissions"...
  66. CREATE TABLE IF NOT EXISTS {$db_prefix}board_permissions (
  67. ID_GROUP smallint(6) NOT NULL default '0',
  68. ID_BOARD smallint(5) unsigned NOT NULL default '0',
  69. permission varchar(30) NOT NULL default '',
  70. addDeny tinyint(4) NOT NULL default '1',
  71. PRIMARY KEY (ID_GROUP, ID_BOARD, permission)
  72. ) ENGINE=MyISAM;
  73. ALTER TABLE {$db_prefix}board_permissions
  74. ADD addDeny tinyint(4) NOT NULL default '1';
  75. ALTER TABLE {$db_prefix}board_permissions
  76. CHANGE COLUMN permission permission varchar(30) NOT NULL default '';
  77. ---#
  78. ---# Inserting data into "board_permissions"...
  79. INSERT INTO {$db_prefix}board_permissions
  80. (ID_GROUP, ID_BOARD, permission)
  81. VALUES (-1, 0, 'poll_view'), (3, 0, 'make_sticky'), (3, 0, 'lock_any'),
  82. (3, 0, 'remove_any'), (3, 0, 'move_any'), (3, 0, 'merge_any'), (3, 0, 'split_any'),
  83. (3, 0, 'delete_any'), (3, 0, 'modify_any'), (2, 0, 'make_sticky'), (2, 0, 'lock_any'),
  84. (2, 0, 'remove_any'), (2, 0, 'move_any'), (2, 0, 'merge_any'), (2, 0, 'split_any'),
  85. (2, 0, 'delete_any'), (2, 0, 'modify_any'), (2, 0, 'poll_lock_any'), (2, 0, 'poll_lock_any'),
  86. (2, 0, 'poll_add_any'), (2, 0, 'poll_remove_any'), (2, 0, 'poll_remove_any');
  87. INSERT IGNORE INTO {$db_prefix}board_permissions
  88. (ID_GROUP, ID_BOARD, permission)
  89. VALUES (3, 0, 'moderate_board'), (2, 0, 'moderate_board');
  90. ---#
  91. ---# Creating "moderators"...
  92. CREATE TABLE IF NOT EXISTS {$db_prefix}moderators (
  93. ID_BOARD smallint(5) unsigned NOT NULL default '0',
  94. ID_MEMBER mediumint(8) unsigned NOT NULL default '0',
  95. PRIMARY KEY (ID_BOARD, ID_MEMBER)
  96. ) ENGINE=MyISAM;
  97. ---#
  98. ---# Creating "attachments"...
  99. CREATE TABLE IF NOT EXISTS {$db_prefix}attachments (
  100. ID_ATTACH int(11) unsigned NOT NULL auto_increment,
  101. ID_MSG int(10) unsigned NOT NULL default '0',
  102. ID_MEMBER int(10) unsigned NOT NULL default '0',
  103. filename tinytext NOT NULL default '',
  104. size int(10) unsigned NOT NULL default '0',
  105. downloads mediumint(8) unsigned NOT NULL default '0',
  106. PRIMARY KEY (ID_ATTACH),
  107. UNIQUE ID_MEMBER (ID_MEMBER, ID_ATTACH),
  108. KEY ID_MSG (ID_MSG)
  109. ) ENGINE=MyISAM;
  110. ---#
  111. ---# Creating "log_notify"...
  112. CREATE TABLE IF NOT EXISTS {$db_prefix}log_notify (
  113. ID_MEMBER mediumint(8) unsigned NOT NULL default '0',
  114. ID_TOPIC mediumint(8) unsigned NOT NULL default '0',
  115. ID_BOARD smallint(5) unsigned NOT NULL default '0',
  116. sent tinyint(1) unsigned NOT NULL default '0',
  117. PRIMARY KEY (ID_MEMBER, ID_TOPIC, ID_BOARD)
  118. ) ENGINE=MyISAM;
  119. ---#
  120. ---# Creating "log_polls"...
  121. CREATE TABLE IF NOT EXISTS {$db_prefix}log_polls (
  122. ID_POLL mediumint(8) unsigned NOT NULL default '0',
  123. ID_MEMBER mediumint(8) unsigned NOT NULL default '0',
  124. ID_CHOICE tinyint(4) unsigned NOT NULL default '0',
  125. PRIMARY KEY (ID_POLL, ID_MEMBER, ID_CHOICE)
  126. ) ENGINE=MyISAM;
  127. ---#
  128. ---# Creating "log_actions"...
  129. CREATE TABLE IF NOT EXISTS {$db_prefix}log_actions (
  130. ID_ACTION int(10) unsigned NOT NULL auto_increment,
  131. logTime int(10) unsigned NOT NULL default '0',
  132. ID_MEMBER mediumint(8) unsigned NOT NULL default '0',
  133. IP tinytext NOT NULL default '',
  134. action varchar(30) NOT NULL default '',
  135. extra text NOT NULL default '',
  136. PRIMARY KEY (ID_ACTION),
  137. KEY logTime (logTime),
  138. KEY ID_MEMBER (ID_MEMBER)
  139. ) ENGINE=MyISAM;
  140. ---#
  141. ---# Creating "poll_choices"...
  142. CREATE TABLE IF NOT EXISTS {$db_prefix}poll_choices (
  143. ID_POLL mediumint(8) unsigned NOT NULL default '0',
  144. ID_CHOICE tinyint(4) unsigned NOT NULL default '0',
  145. label tinytext NOT NULL default '',
  146. votes smallint(5) unsigned NOT NULL default '0',
  147. PRIMARY KEY (ID_POLL, ID_CHOICE)
  148. ) ENGINE=MyISAM;
  149. ---#
  150. ---# Creating "smileys"...
  151. CREATE TABLE IF NOT EXISTS {$db_prefix}smileys (
  152. id_smiley smallint(5) unsigned NOT NULL auto_increment,
  153. code varchar(30) NOT NULL default '',
  154. filename varchar(48) NOT NULL default '',
  155. description varchar(80) NOT NULL default '',
  156. smileyRow tinyint(4) unsigned NOT NULL default '0',
  157. smileyOrder tinyint(4) unsigned NOT NULL default '0',
  158. hidden tinyint(4) unsigned NOT NULL default '0',
  159. PRIMARY KEY (id_smiley),
  160. KEY smileyOrder (smileyOrder)
  161. ) ENGINE=MyISAM;
  162. ---#
  163. ---# Loading default smileys...
  164. INSERT IGNORE INTO {$db_prefix}smileys
  165. (id_smiley, code, filename, description, smileyOrder, hidden)
  166. VALUES (1, ':)', 'smiley.gif', 'Smiley', 0, 0),
  167. (2, ';)', 'wink.gif', 'Wink', 1, 0),
  168. (3, ':D', 'cheesy.gif', 'Cheesy', 2, 0),
  169. (4, ';D', 'grin.gif', 'Grin', 3, 0),
  170. (5, '>:(', 'angry.gif', 'Angry', 4, 0),
  171. (6, ':(', 'sad.gif', 'Sad', 5, 0),
  172. (7, ':o', 'shocked.gif', 'Shocked', 6, 0),
  173. (8, '8)', 'cool.gif', 'Cool', 7, 0),
  174. (9, '???', 'huh.gif', 'Huh', 8, 0),
  175. (10, '::)', 'rolleyes.gif', 'Roll Eyes', 9, 0),
  176. (11, ':P', 'tongue.gif', 'Tongue', 10, 0),
  177. (12, ':-[', 'embarassed.gif', 'Embarrassed', 11, 0),
  178. (13, ':-X', 'lipsrsealed.gif', 'Lips Sealed', 12, 0),
  179. (14, ':-\\', 'undecided.gif', 'Undecided', 13, 0),
  180. (15, ':-*', 'kiss.gif', 'Kiss', 14, 0),
  181. (16, ':\'(', 'cry.gif', 'Cry', 15, 0),
  182. (17, '>:D', 'evil.gif', 'Evil', 16, 1),
  183. (18, '^-^', 'azn.gif', 'Azn', 17, 1),
  184. (19, 'O0', 'afro.gif', 'Afro', 18, 1);
  185. ---#
  186. ---# Dropping "log_search" and recreating it...
  187. DROP TABLE IF EXISTS {$db_prefix}log_search;
  188. CREATE TABLE {$db_prefix}log_search (
  189. ID_SEARCH tinyint(3) unsigned NOT NULL default '0',
  190. ID_TOPIC mediumint(8) unsigned NOT NULL default '0',
  191. ID_MSG int(10) unsigned NOT NULL default '0',
  192. relevance smallint(5) unsigned NOT NULL default '0',
  193. num_matches smallint(5) unsigned NOT NULL default '0',
  194. PRIMARY KEY (ID_SEARCH, ID_TOPIC)
  195. ) ENGINE=MyISAM;
  196. ---#
  197. ---# Dropping "sessions" and recreating it...
  198. DROP TABLE IF EXISTS {$db_prefix}sessions;
  199. CREATE TABLE {$db_prefix}sessions (
  200. session_id char(32) NOT NULL,
  201. last_update int(10) unsigned NOT NULL,
  202. data text NOT NULL,
  203. PRIMARY KEY (session_id)
  204. ) ENGINE=MyISAM;
  205. ---#
  206. ---# Verifying "settings"...
  207. ALTER IGNORE TABLE {$db_prefix}settings
  208. DROP PRIMARY KEY,
  209. ADD PRIMARY KEY (variable(30));
  210. ---#
  211. /******************************************************************************/
  212. --- Converting activity logs...
  213. /******************************************************************************/
  214. ---# Converting "log_online"...
  215. DROP TABLE IF EXISTS {$db_prefix}log_online;
  216. CREATE TABLE {$db_prefix}log_online (
  217. session char(32) NOT NULL default ' ',
  218. logTime timestamp,
  219. ID_MEMBER mediumint(8) unsigned NOT NULL default '0',
  220. ip int(11) unsigned NOT NULL default '0',
  221. url text NOT NULL default '',
  222. PRIMARY KEY (session),
  223. KEY online (logTime, ID_MEMBER),
  224. KEY ID_MEMBER (ID_MEMBER)
  225. ) ENGINE=MyISAM;
  226. ---#
  227. ---# Converting "log_floodcontrol"...
  228. DROP TABLE IF EXISTS {$db_prefix}log_floodcontrol;
  229. CREATE TABLE {$db_prefix}log_floodcontrol (
  230. ip tinytext NOT NULL default '',
  231. logTime int(10) unsigned NOT NULL default '0',
  232. PRIMARY KEY (ip(16)),
  233. KEY logTime (logTime)
  234. ) ENGINE=MyISAM;
  235. ---#
  236. ---# Converting "log_karma"...
  237. DROP TABLE IF EXISTS {$db_prefix}log_karma;
  238. CREATE TABLE {$db_prefix}log_karma (
  239. ID_TARGET mediumint(8) unsigned NOT NULL default '0',
  240. ID_EXECUTOR mediumint(8) unsigned NOT NULL default '0',
  241. logTime int(10) unsigned NOT NULL default '0',
  242. action tinyint(4) NOT NULL default '0',
  243. PRIMARY KEY (ID_TARGET, ID_EXECUTOR),
  244. KEY logTime (logTime)
  245. ) ENGINE=MyISAM;
  246. ---#
  247. ---# Retiring "log_clicks"...
  248. DROP TABLE IF EXISTS {$db_prefix}log_clicks;
  249. ---#
  250. ---# Converting "log_notify"...
  251. INSERT INTO {$db_prefix}log_notify
  252. SELECT ID_MEMBER, ID_TOPIC, 0, notificationSent
  253. FROM {$db_prefix}log_topics
  254. WHERE notificationSent != 0;
  255. ALTER TABLE {$db_prefix}log_topics
  256. DROP notificationSent;
  257. ---#
  258. ---# Converting "log_errors"...
  259. ALTER TABLE {$db_prefix}log_errors
  260. CHANGE COLUMN ID_ERROR ID_ERROR mediumint(8) unsigned NOT NULL auto_increment,
  261. ADD session char(32) NOT NULL default ' ';
  262. ---#
  263. ---# Converting "log_boards"...
  264. ---{
  265. $request = upgrade_query("
  266. SELECT lmr.ID_BOARD, lmr.ID_MEMBER, lmr.logTime
  267. FROM {$db_prefix}log_mark_read AS lmr
  268. LEFT JOIN {$db_prefix}log_boards AS lb ON (lb.ID_BOARD = lmr.ID_BOARD AND lb.ID_MEMBER = lmr.ID_MEMBER)
  269. WHERE lb.logTime < lmr.logTime");
  270. $replaceRows = '';
  271. while ($row = smf_mysql_fetch_assoc($request))
  272. $replaceRows .= "($row[ID_BOARD], $row[ID_MEMBER], $row[logTime]),";
  273. smf_mysql_free_result($request);
  274. if (!empty($replaceRows))
  275. {
  276. $replaceRows = substr($replaceRows, 0, -1);
  277. upgrade_query("
  278. REPLACE INTO {$db_prefix}log_boards
  279. (ID_BOARD, ID_MEMBER, logTime)
  280. VALUES $replaceRows");
  281. }
  282. ---}
  283. ---#
  284. ---# Converting "log_activity"...
  285. ALTER TABLE {$db_prefix}log_activity
  286. ADD date date NOT NULL default '0001-01-01';
  287. ALTER TABLE {$db_prefix}log_activity
  288. DROP PRIMARY KEY;
  289. UPDATE IGNORE {$db_prefix}log_activity
  290. SET date = year * 10000 + month * 100 + day;
  291. ALTER TABLE {$db_prefix}log_activity
  292. DROP day,
  293. DROP month,
  294. DROP year;
  295. ALTER TABLE {$db_prefix}log_activity
  296. ADD INDEX hits (hits);
  297. ALTER TABLE {$db_prefix}log_activity
  298. ADD PRIMARY KEY (date);
  299. ALTER TABLE {$db_prefix}log_activity
  300. CHANGE COLUMN hits hits mediumint(8) unsigned NOT NULL default '0',
  301. CHANGE COLUMN topics topics smallint(5) unsigned NOT NULL default '0',
  302. CHANGE COLUMN posts posts smallint(5) unsigned NOT NULL default '0',
  303. CHANGE COLUMN registers registers smallint(5) unsigned NOT NULL default '0',
  304. CHANGE COLUMN most_on most_on smallint(5) unsigned NOT NULL default '0';
  305. ---#
  306. /******************************************************************************/
  307. --- Converting Boards and Categories...
  308. /******************************************************************************/
  309. ---# Adding new columns to "boards"...
  310. ALTER TABLE {$db_prefix}boards
  311. CHANGE COLUMN count countPosts tinyint(4) NOT NULL default '0',
  312. ADD lastUpdated int(11) unsigned NOT NULL default '0',
  313. ADD ID_PARENT smallint(5) unsigned NOT NULL default '0',
  314. ADD ID_LAST_MSG int(10) unsigned NOT NULL default '0',
  315. ADD childLevel tinyint(4) unsigned NOT NULL default '0';
  316. ---#
  317. ---# Updating the structure of "boards"...
  318. ALTER TABLE {$db_prefix}boards
  319. CHANGE COLUMN boardOrder boardOrder smallint(5) NOT NULL default '0';
  320. ALTER TABLE {$db_prefix}boards
  321. DROP isAnnouncement;
  322. ALTER TABLE {$db_prefix}boards
  323. ADD ID_THEME tinyint(4) unsigned NOT NULL default '0';
  324. ALTER TABLE {$db_prefix}boards
  325. ADD use_local_permissions tinyint(4) unsigned NOT NULL default '0';
  326. ALTER TABLE {$db_prefix}boards
  327. ADD override_theme tinyint(4) unsigned NOT NULL default '0';
  328. ---#
  329. ---# Reindexing "boards" (part 1)...
  330. ALTER TABLE {$db_prefix}boards
  331. DROP INDEX ID_CAT,
  332. DROP ID_LAST_TOPIC;
  333. ALTER TABLE {$db_prefix}boards
  334. DROP INDEX memberGroups;
  335. ---#
  336. ---# Reindexing "boards" (part 2)...
  337. ALTER TABLE {$db_prefix}boards
  338. ADD INDEX lastUpdated (lastUpdated),
  339. ADD INDEX memberGroups (memberGroups(48)),
  340. ADD UNIQUE INDEX categories (ID_CAT, ID_BOARD);
  341. ---#
  342. ---# Updating the column sizes on "boards"...
  343. ALTER TABLE {$db_prefix}boards
  344. DROP PRIMARY KEY,
  345. CHANGE COLUMN ID_CAT ID_CAT tinyint(4) unsigned NOT NULL default '0',
  346. CHANGE COLUMN numTopics numTopics mediumint(8) unsigned NOT NULL default '0',
  347. CHANGE COLUMN numPosts numPosts mediumint(8) unsigned NOT NULL default '0',
  348. CHANGE COLUMN description description text NOT NULL default '',
  349. CHANGE COLUMN ID_BOARD ID_BOARD smallint(5) unsigned NOT NULL auto_increment PRIMARY KEY;
  350. ---#
  351. ---# Updating access permissions...
  352. ---{
  353. $member_groups = getMemberGroups();
  354. $result = upgrade_query("
  355. ALTER TABLE {$db_prefix}boards
  356. ADD memberGroups varchar(128) NOT NULL default '-1,0'");
  357. if ($result !== false)
  358. {
  359. $result = upgrade_query("
  360. SELECT TRIM(memberGroups) AS memberGroups, ID_CAT
  361. FROM {$db_prefix}categories");
  362. while ($row = smf_mysql_fetch_assoc($result))
  363. {
  364. if (trim($row['memberGroups']) == '')
  365. $groups = '-1,0,2';
  366. else
  367. {
  368. $memberGroups = array_unique(explode(',', $row['memberGroups']));
  369. $groups = array(2);
  370. foreach ($memberGroups as $k => $check)
  371. {
  372. $memberGroups[$k] = trim($memberGroups[$k]);
  373. if ($memberGroups[$k] == '' || !isset($member_groups[$memberGroups[$k]]) || $member_groups[$memberGroups[$k]] == 8)
  374. continue;
  375. $groups[] = $member_groups[$memberGroups[$k]];
  376. }
  377. $groups = implode(',', array_unique($groups));
  378. }
  379. upgrade_query("
  380. UPDATE {$db_prefix}boards
  381. SET memberGroups = '$groups', lastUpdated = " . time() . "
  382. WHERE ID_CAT = $row[ID_CAT]");
  383. }
  384. }
  385. ---}
  386. ALTER TABLE {$db_prefix}categories
  387. DROP memberGroups;
  388. ALTER TABLE {$db_prefix}boards
  389. CHANGE COLUMN memberGroups memberGroups varchar(128) NOT NULL default '-1,0';
  390. ---#
  391. ---# Converting "categories"...
  392. ALTER TABLE {$db_prefix}categories
  393. DROP PRIMARY KEY,
  394. ADD canCollapse tinyint(1) NOT NULL default '1',
  395. CHANGE COLUMN ID_CAT ID_CAT tinyint(4) unsigned NOT NULL auto_increment PRIMARY KEY;
  396. ---#
  397. ---# Converting announcement permissions...
  398. ---{
  399. $request = upgrade_query("
  400. SHOW COLUMNS
  401. FROM {$db_prefix}boards
  402. LIKE 'notifyAnnouncements'");
  403. if (smf_mysql_num_rows($request) > 0)
  404. {
  405. $conversions = array(
  406. 'moderate_forum' => array('manage_membergroups', 'manage_bans'),
  407. 'admin_forum' => array('manage_permissions'),
  408. 'edit_forum' => array('manage_boards', 'manage_smileys', 'manage_attachments'),
  409. );
  410. foreach ($conversions as $original_permission => $new_permissions)
  411. {
  412. $setString = '';
  413. $result = upgrade_query("
  414. SELECT ID_GROUP, addDeny
  415. FROM {$db_prefix}permissions
  416. WHERE permission = '$original_permission'");
  417. while ($row = smf_mysql_fetch_assoc($result))
  418. $setString .= "
  419. ('" . implode("', $row[ID_GROUP], $row[addDeny]),
  420. ('", $new_permissions) . "', $row[ID_GROUP], $row[addDeny]),";
  421. smf_mysql_free_result($result);
  422. if ($setString != '')
  423. upgrade_query("
  424. INSERT IGNORE INTO {$db_prefix}permissions
  425. (permission, ID_GROUP, addDeny)
  426. VALUES" . substr($setString, 0, -1));
  427. }
  428. }
  429. smf_mysql_free_result($request);
  430. ---}
  431. DELETE FROM {$db_prefix}permissions
  432. WHERE permission = 'edit_forum';
  433. ALTER TABLE {$db_prefix}boards
  434. DROP COLUMN notifyAnnouncements;
  435. ---#
  436. ---# Converting board statistics...
  437. ---{
  438. $result = upgrade_query("
  439. SELECT MAX(m.ID_MSG) AS ID_LAST_MSG, t.ID_BOARD
  440. FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t)
  441. WHERE m.ID_MSG = t.ID_LAST_MSG
  442. GROUP BY t.ID_BOARD");
  443. $last_msgs = array();
  444. while ($row = smf_mysql_fetch_assoc($result))
  445. $last_msgs[] = $row['ID_LAST_MSG'];
  446. smf_mysql_free_result($result);
  447. if (!empty($last_msgs))
  448. {
  449. $result = upgrade_query("
  450. SELECT m.ID_MSG, m.posterTime, t.ID_BOARD
  451. FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t)
  452. WHERE t.ID_TOPIC = m.ID_TOPIC
  453. AND m.ID_MSG IN (" . implode(',', $last_msgs) . ")
  454. LIMIT " . count($last_msgs));
  455. while ($row = smf_mysql_fetch_assoc($result))
  456. {
  457. upgrade_query("
  458. UPDATE {$db_prefix}boards
  459. SET ID_LAST_MSG = $row[ID_MSG], lastUpdated = " . (int) $row['posterTime'] . "
  460. WHERE ID_BOARD = $row[ID_BOARD]
  461. LIMIT 1");
  462. }
  463. smf_mysql_free_result($result);
  464. }
  465. ---}
  466. ---#
  467. ---# Converting "moderators"...
  468. ---{
  469. $request = upgrade_query("
  470. SHOW COLUMNS
  471. FROM {$db_prefix}boards
  472. LIKE 'moderators'");
  473. $do_moderators = smf_mysql_num_rows($request) > 0;
  474. smf_mysql_free_result($request);
  475. if ($do_moderators)
  476. {
  477. $result = upgrade_query("
  478. SELECT TRIM(moderators) AS moderators, ID_BOARD
  479. FROM {$db_prefix}boards
  480. WHERE TRIM(moderators) != ''");
  481. while ($row = smf_mysql_fetch_assoc($result))
  482. {
  483. $moderators = array_unique(explode(',', $row['moderators']));
  484. foreach ($moderators as $k => $dummy)
  485. {
  486. $moderators[$k] = addslashes(trim($moderators[$k]));
  487. if ($moderators[$k] == '')
  488. unset($moderators[$k]);
  489. }
  490. if (!empty($moderators))
  491. {
  492. upgrade_query("
  493. INSERT IGNORE INTO {$db_prefix}moderators
  494. (ID_BOARD, ID_MEMBER)
  495. SELECT $row[ID_BOARD], ID_MEMBER
  496. FROM {$db_prefix}members
  497. WHERE memberName IN ('" . implode("', '", $moderators) . "')
  498. LIMIT " . count($moderators));
  499. }
  500. }
  501. }
  502. ---}
  503. ALTER TABLE {$db_prefix}boards
  504. DROP moderators;
  505. ---#
  506. ---# Updating board order...
  507. ---{
  508. $request = upgrade_query("
  509. SELECT c.ID_CAT, c.catOrder, b.ID_BOARD, b.boardOrder
  510. FROM {$db_prefix}categories AS c
  511. LEFT JOIN {$db_prefix}boards AS b ON (b.ID_CAT = c.ID_CAT)
  512. ORDER BY c.catOrder, b.childLevel, b.boardOrder, b.ID_BOARD");
  513. $catOrder = -1;
  514. $boardOrder = -1;
  515. $curCat = -1;
  516. while ($row = smf_mysql_fetch_assoc($request))
  517. {
  518. if ($curCat != $row['ID_CAT'])
  519. {
  520. $curCat = $row['ID_CAT'];
  521. if (++$catOrder != $row['catOrder'])
  522. upgrade_query("
  523. UPDATE {$db_prefix}categories
  524. SET catOrder = $catOrder
  525. WHERE ID_CAT = $row[ID_CAT]
  526. LIMIT 1");
  527. }
  528. if (!empty($row['ID_BOARD']) && ++$boardOrder != $row['boardOrder'])
  529. upgrade_query("
  530. UPDATE {$db_prefix}boards
  531. SET boardOrder = $boardOrder
  532. WHERE ID_BOARD = $row[ID_BOARD]
  533. LIMIT 1");
  534. }
  535. smf_mysql_free_result($request);
  536. ---}
  537. ---#
  538. ---# Fixing possible issues with board access (part 1)...
  539. ---{
  540. if (empty($modSettings['smfVersion']) || (substr($modSettings['smfVersion'], 0, 9) == '1.0 Beta ' && $modSettings['smfVersion'][9] <= 5))
  541. {
  542. $all_groups = array();
  543. $result = upgrade_query("
  544. SELECT ID_GROUP
  545. FROM {$db_prefix}membergroups");
  546. while ($row = smf_mysql_fetch_assoc($result))
  547. $all_groups[] = $row['ID_GROUP'];
  548. smf_mysql_free_result($result);
  549. $result = upgrade_query("
  550. SELECT ID_BOARD, memberGroups
  551. FROM {$db_prefix}boards
  552. WHERE FIND_IN_SET(0, memberGroups)");
  553. while ($row = smf_mysql_fetch_assoc($result))
  554. {
  555. upgrade_query("
  556. UPDATE {$db_prefix}boards
  557. SET memberGroups = '" . implode(',', array_unique(array_merge(explode(',', $row['memberGroups']), $all_groups))) . "'
  558. WHERE ID_BOARD = $row[ID_BOARD]
  559. LIMIT 1");
  560. }
  561. smf_mysql_free_result($result);
  562. }
  563. ---}
  564. ---#
  565. ---# Fixing possible issues with board access. (part 2)..
  566. UPDATE {$db_prefix}boards
  567. SET memberGroups = SUBSTRING(memberGroups, 2)
  568. WHERE SUBSTRING(memberGroups, 1, 1) = ',';
  569. UPDATE {$db_prefix}boards
  570. SET memberGroups = SUBSTRING(memberGroups, 1, LENGTH(memberGroups) - 1)
  571. WHERE SUBSTRING(memberGroups, LENGTH(memberGroups)) = ',';
  572. UPDATE {$db_prefix}boards
  573. SET memberGroups = REPLACE(',,', ',', REPLACE(',,', ',', memberGroups))
  574. WHERE LOCATE(',,', memberGroups);
  575. ---#
  576. /******************************************************************************/
  577. --- Converting attachments, topics, and messages...
  578. /******************************************************************************/
  579. ---# Converting "attachments"...
  580. INSERT INTO {$db_prefix}attachments
  581. (ID_MSG, filename, size)
  582. SELECT ID_MSG, SUBSTRING(attachmentFilename, 1, 255), attachmentSize
  583. FROM {$db_prefix}messages
  584. WHERE attachmentFilename IS NOT NULL
  585. AND attachmentFilename != '';
  586. ALTER TABLE {$db_prefix}messages
  587. DROP attachmentSize,
  588. DROP attachmentFilename;
  589. ---#
  590. ---# Updating "attachments"...
  591. ALTER TABLE {$db_prefix}attachments
  592. DROP INDEX ID_MEMBER,
  593. ADD UNIQUE ID_MEMBER (ID_MEMBER, ID_ATTACH);
  594. ALTER TABLE {$db_prefix}attachments
  595. CHANGE COLUMN size size int(10) unsigned NOT NULL default '0';
  596. ---#
  597. ---# Updating columns on "messages" (part 1)...
  598. ALTER TABLE {$db_prefix}messages
  599. DROP PRIMARY KEY,
  600. CHANGE COLUMN ID_MSG ID_MSG int(10) unsigned NOT NULL auto_increment PRIMARY KEY;
  601. ---#
  602. ---# Updating columns on "messages" (part 2)...
  603. ALTER TABLE {$db_prefix}messages
  604. CHANGE COLUMN ID_TOPIC ID_TOPIC mediumint(8) unsigned NOT NULL default '0';
  605. ALTER TABLE {$db_prefix}messages
  606. CHANGE COLUMN smiliesEnabled smileysEnabled tinyint(4) NOT NULL default '1';
  607. ---#
  608. ---# Updating columns on "messages" (part 3)...
  609. ALTER TABLE {$db_prefix}messages
  610. CHANGE COLUMN posterTime posterTime int(10) unsigned NOT NULL default '0',
  611. CHANGE COLUMN modifiedTime modifiedTime int(10) unsigned NOT NULL default '0';
  612. ALTER TABLE {$db_prefix}messages
  613. ADD INDEX participation (ID_MEMBER, ID_TOPIC);
  614. ALTER TABLE {$db_prefix}messages
  615. ADD INDEX ipIndex (posterIP(15), ID_TOPIC);
  616. ---#
  617. ---# Updating columns on "messages" (part 4)...
  618. ALTER TABLE {$db_prefix}messages
  619. CHANGE COLUMN ID_MEMBER ID_MEMBER mediumint(8) unsigned NOT NULL default '0',
  620. CHANGE COLUMN icon icon varchar(16) NOT NULL default 'xx';
  621. ALTER TABLE {$db_prefix}messages
  622. ADD INDEX ID_MEMBER (ID_MEMBER);
  623. ALTER TABLE {$db_prefix}messages
  624. ADD UNIQUE INDEX topic (ID_TOPIC, ID_MSG);
  625. ---#
  626. ---# Updating columns on "messages" (part 5)...
  627. ALTER TABLE {$db_prefix}messages
  628. ADD COLUMN ID_BOARD smallint(5) unsigned NOT NULL default '0';
  629. ---#
  630. ---# Updating data in "messages"...
  631. ---{
  632. while (true)
  633. {
  634. nextSubstep($substep);
  635. $request = upgrade_query("
  636. SELECT DISTINCT t.ID_BOARD, t.ID_TOPIC
  637. FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t)
  638. WHERE t.ID_TOPIC = m.ID_TOPIC
  639. AND m.ID_BOARD = 0
  640. LIMIT 1400");
  641. $boards = array();
  642. while ($row = smf_mysql_fetch_assoc($request))
  643. $boards[$row['ID_BOARD']][] = $row['ID_TOPIC'];
  644. foreach ($boards as $board => $topics)
  645. upgrade_query("
  646. UPDATE {$db_prefix}messages
  647. SET ID_BOARD = $board
  648. WHERE ID_TOPIC IN (" . implode(', ', $topics) . ')');
  649. if (smf_mysql_num_rows($request) < 1400)
  650. break;
  651. smf_mysql_free_result($request);
  652. }
  653. ---}
  654. ---#
  655. ---# Cleaning up "messages"...
  656. ALTER TABLE {$db_prefix}messages
  657. ADD INDEX ID_BOARD (ID_BOARD);
  658. ALTER TABLE {$db_prefix}messages
  659. DROP INDEX posterTime_2;
  660. ALTER TABLE {$db_prefix}messages
  661. DROP INDEX posterTime_3;
  662. ALTER TABLE {$db_prefix}messages
  663. DROP INDEX ID_MEMBER_2;
  664. ALTER TABLE {$db_prefix}messages
  665. DROP INDEX ID_MEMBER_3;
  666. ---#
  667. ---# Updating indexes on "topics" (part 1)...
  668. ALTER TABLE {$db_prefix}topics
  669. DROP INDEX ID_FIRST_MSG;
  670. ALTER TABLE {$db_prefix}topics
  671. DROP INDEX ID_LAST_MSG;
  672. ALTER TABLE {$db_prefix}topics
  673. ADD INDEX isSticky (isSticky);
  674. ---#
  675. ---# Updating indexes on "topics" (part 2)...
  676. ALTER IGNORE TABLE {$db_prefix}topics
  677. ADD UNIQUE INDEX lastMessage (ID_LAST_MSG, ID_BOARD),
  678. ADD UNIQUE INDEX firstMessage (ID_FIRST_MSG, ID_BOARD),
  679. ADD UNIQUE INDEX poll (ID_POLL, ID_TOPIC);
  680. ---#
  681. ---# Updating columns on "topics" (part 1)...
  682. ALTER TABLE {$db_prefix}topics
  683. DROP PRIMARY KEY,
  684. CHANGE COLUMN ID_TOPIC ID_TOPIC mediumint(8) unsigned NOT NULL auto_increment PRIMARY KEY,
  685. CHANGE COLUMN ID_BOARD ID_BOARD smallint(5) unsigned NOT NULL default '0';
  686. ---#
  687. ---# Updating columns on "topics" (part 2)...
  688. ALTER TABLE {$db_prefix}topics
  689. CHANGE COLUMN ID_MEMBER_STARTED ID_MEMBER_STARTED mediumint(8) unsigned NOT NULL default '0',
  690. CHANGE COLUMN ID_MEMBER_UPDATED ID_MEMBER_UPDATED mediumint(8) unsigned NOT NULL default '0';
  691. ---#
  692. ---# Updating columns on "topics" (part 3)...
  693. ALTER TABLE {$db_prefix}topics
  694. CHANGE COLUMN ID_FIRST_MSG ID_FIRST_MSG int(10) unsigned NOT NULL default '0',
  695. CHANGE COLUMN ID_LAST_MSG ID_LAST_MSG int(10) unsigned NOT NULL default '0';
  696. ---#
  697. ---# Updating columns on "topics" (part 4)...
  698. ALTER TABLE {$db_prefix}topics
  699. CHANGE COLUMN ID_POLL ID_POLL mediumint(8) unsigned NOT NULL default '0';
  700. ---#
  701. /******************************************************************************/
  702. --- Converting members and personal messages...
  703. /******************************************************************************/
  704. ---# Updating data in "members" (part 1)...
  705. UPDATE IGNORE {$db_prefix}members
  706. SET im_ignore_list = '*'
  707. WHERE im_ignore_list RLIKE '([\n,]|^)[*]([\n,]|$)';
  708. ---#
  709. ---# Updating data in "members" (part 2)...
  710. ---{
  711. $request = upgrade_query("
  712. SHOW COLUMNS
  713. FROM {$db_prefix}members
  714. LIKE 'im_ignore_list'");
  715. $do_it = smf_mysql_num_rows($request) != 0;
  716. smf_mysql_free_result($request);
  717. while ($do_it)
  718. {
  719. nextSubstep($substep);
  720. $request = upgrade_query("
  721. SELECT ID_MEMBER, im_ignore_list
  722. FROM {$db_prefix}members
  723. WHERE im_ignore_list RLIKE '[a-z]'
  724. LIMIT 512");
  725. while ($row = smf_mysql_fetch_assoc($request))
  726. {
  727. $request2 = upgrade_query("
  728. SELECT ID_MEMBER
  729. FROM {$db_prefix}members
  730. WHERE FIND_IN_SET(memberName, '" . addslashes($row['im_ignore_list']) . "')");
  731. $im_ignore_list = '';
  732. while ($row2 = smf_mysql_fetch_assoc($request2))
  733. $im_ignore_list .= ',' . $row2['ID_MEMBER'];
  734. smf_mysql_free_result($request2);
  735. upgrade_query("
  736. UPDATE {$db_prefix}members
  737. SET im_ignore_list = '" . substr($im_ignore_list, 1) . "'
  738. WHERE ID_MEMBER = $row[ID_MEMBER]
  739. LIMIT 1");
  740. }
  741. if (smf_mysql_num_rows($request) < 512)
  742. break;
  743. smf_mysql_free_result($request);
  744. }
  745. ---}
  746. ---#
  747. ---# Updating data in "members" (part 3)...
  748. UPDATE {$db_prefix}members
  749. SET realName = memberName
  750. WHERE IFNULL(realName, '') = '';
  751. ---#
  752. ---# Updating data in "members" (part 4)...
  753. UPDATE {$db_prefix}members
  754. SET lngfile = REPLACE(lngfile, '.lng', '')
  755. WHERE lngfile LIKE '%.lng';
  756. ---#
  757. ---# Cleaning up "members"...
  758. ALTER TABLE {$db_prefix}members
  759. DROP INDEX memberID;
  760. ALTER TABLE {$db_prefix}members
  761. DROP INDEX memberID_2;
  762. ---#
  763. ---# Adding new columns to "members"...
  764. ALTER TABLE {$db_prefix}members
  765. DROP PRIMARY KEY,
  766. CHANGE COLUMN ID_MEMBER ID_MEMBER mediumint(8) unsigned NOT NULL auto_increment PRIMARY KEY,
  767. ADD instantMessages smallint(5) NOT NULL default 0,
  768. ADD unreadMessages smallint(5) NOT NULL default 0,
  769. ADD ID_THEME tinyint(4) unsigned NOT NULL default 0,
  770. ADD ID_GROUP smallint(5) unsigned NOT NULL default 0,
  771. ADD is_activated tinyint(3) unsigned NOT NULL default '1',
  772. ADD validation_code varchar(10) NOT NULL default '',
  773. ADD ID_MSG_LAST_VISIT int(10) unsigned NOT NULL default '0',
  774. ADD additionalGroups tinytext NOT NULL default '';
  775. ---#
  776. ---# Updating columns on "members"...
  777. ALTER TABLE {$db_prefix}members
  778. CHANGE COLUMN ID_THEME ID_THEME tinyint(4) unsigned NOT NULL default 0;
  779. ALTER TABLE {$db_prefix}members
  780. ADD showOnline tinyint(4) NOT NULL default '1';
  781. ALTER TABLE {$db_prefix}members
  782. ADD smileySet varchar(48) NOT NULL default '';
  783. ALTER TABLE {$db_prefix}members
  784. ADD totalTimeLoggedIn int(10) unsigned NOT NULL default '0';
  785. ALTER TABLE {$db_prefix}members
  786. ADD passwordSalt varchar(5) NOT NULL default '';
  787. ---#
  788. ---# Updating data in "members" (part 5)...
  789. UPDATE {$db_prefix}members
  790. SET gender = CASE gender
  791. WHEN '0' THEN 0
  792. WHEN 'Male' THEN 1
  793. WHEN 'Female' THEN 2
  794. ELSE 0 END, secretAnswer = IF(secretAnswer = '', '', MD5(secretAnswer))
  795. WHERE gender NOT IN ('0', '1', '2');
  796. ---#
  797. ---# Updating data in "members" (part 6)...
  798. ---{
  799. $member_groups = getMemberGroups();
  800. foreach ($member_groups as $name => $id)
  801. {
  802. upgrade_query("
  803. UPDATE IGNORE {$db_prefix}members
  804. SET ID_GROUP = $id
  805. WHERE memberGroup = '" . addslashes($name) . "'");
  806. nextSubstep($substep);
  807. }
  808. ---}
  809. UPDATE IGNORE {$db_prefix}members
  810. SET ID_GROUP = 1
  811. WHERE memberGroup = 'Administrator';
  812. UPDATE IGNORE {$db_prefix}members
  813. SET ID_GROUP = 2
  814. WHERE memberGroup = 'Global Moderator';
  815. ALTER TABLE {$db_prefix}members
  816. DROP memberGroup;
  817. ---#
  818. ---# Changing column sizes on "members" (part 1)...
  819. ALTER TABLE {$db_prefix}members
  820. CHANGE COLUMN timeOffset timeOffset float NOT NULL default '0',
  821. CHANGE COLUMN posts posts mediumint(8) unsigned NOT NULL default '0',
  822. CHANGE COLUMN timeFormat timeFormat varchar(80) NOT NULL default '',
  823. CHANGE COLUMN lastLogin lastLogin int(11) NOT NULL default '0',
  824. CHANGE COLUMN karmaBad karmaBad smallint(5) unsigned NOT NULL default '0',
  825. CHANGE COLUMN karmaGood karmaGood smallint(5) unsigned NOT NULL default '0',
  826. CHANGE COLUMN gender gender tinyint(4) unsigned NOT NULL default '0',
  827. CHANGE COLUMN hideEmail hideEmail tinyint(4) NOT NULL default '0';
  828. ---#
  829. ---# Changing column sizes on "members" (part 2)...
  830. ALTER TABLE {$db_prefix}members
  831. DROP INDEX realName;
  832. ALTER TABLE {$db_prefix}members
  833. CHANGE COLUMN AIM AIM varchar(16) NOT NULL default '',
  834. CHANGE COLUMN YIM YIM varchar(32) NOT NULL default '',
  835. CHANGE COLUMN ICQ ICQ tinytext NOT NULL default '',
  836. CHANGE COLUMN realName realName tinytext NOT NULL default '',
  837. CHANGE COLUMN emailAddress emailAddress tinytext NOT NULL default '',
  838. CHANGE COLUMN dateRegistered dateRegistered int(10) unsigned NOT NULL default '0',
  839. CHANGE COLUMN passwd passwd varchar(64) NOT NULL default '',
  840. CHANGE COLUMN personalText personalText tinytext NOT NULL default '',
  841. CHANGE COLUMN websiteTitle websiteTitle tinytext NOT NULL default '';
  842. ---#
  843. ---# Changing column sizes on "members" (part 3)...
  844. ALTER TABLE {$db_prefix}members
  845. DROP INDEX lngfile;
  846. ALTER TABLE {$db_prefix}members
  847. CHANGE COLUMN websiteUrl websiteUrl tinytext NOT NULL default '',
  848. CHANGE COLUMN location location tinytext NOT NULL default '',
  849. CHANGE COLUMN avatar avatar tinytext NOT NULL default '',
  850. CHANGE COLUMN im_ignore_list im_ignore_list tinytext NOT NULL default '',
  851. CHANGE COLUMN usertitle usertitle tinytext NOT NULL default '',
  852. CHANGE COLUMN lngfile lngfile tinytext NOT NULL default '',
  853. CHANGE COLUMN MSN MSN tinytext NOT NULL default '',
  854. CHANGE COLUMN memberIP memberIP tinytext NOT NULL default '',
  855. ADD INDEX lngfile (lngfile(24));
  856. ---#
  857. ---# Updating keys on "members"...
  858. ALTER TABLE {$db_prefix}members
  859. ADD INDEX ID_GROUP (ID_GROUP),
  860. ADD INDEX birthdate (birthdate),
  861. ADD INDEX lngfile (lngfile(30));
  862. ---#
  863. ---# Converting member statistics...
  864. REPLACE INTO {$db_prefix}settings
  865. (variable, value)
  866. SELECT 'latestMember', ID_MEMBER
  867. FROM {$db_prefix}members
  868. ORDER BY ID_MEMBER DESC
  869. LIMIT 1;
  870. REPLACE INTO {$db_prefix}settings
  871. (variable, value)
  872. SELECT 'latestRealName', IFNULL(realName, memberName)
  873. FROM {$db_prefix}members
  874. ORDER BY ID_MEMBER DESC
  875. LIMIT 1;
  876. REPLACE INTO {$db_prefix}settings
  877. (variable, value)
  878. SELECT 'maxMsgID', ID_MSG
  879. FROM {$db_prefix}messages
  880. ORDER BY ID_MSG DESC
  881. LIMIT 1;
  882. ---#
  883. ---# Adding new columns to "instant_messages"...
  884. ALTER IGNORE TABLE {$db_prefix}instant_messages
  885. ADD COLUMN deletedBySender tinyint(3) unsigned NOT NULL default '0' AFTER ID_MEMBER_FROM;
  886. ---#
  887. ---# Changing column sizes on "instant_messages" (part 1)...
  888. ALTER TABLE {$db_prefix}instant_messages
  889. CHANGE COLUMN ID_MEMBER_FROM ID_MEMBER_FROM mediumint(8) unsigned NOT NULL default 0,
  890. CHANGE COLUMN msgtime msgtime int(10) unsigned NOT NULL default '0',
  891. CHANGE COLUMN subject subject tinytext NOT NULL;
  892. ALTER TABLE {$db_prefix}instant_messages
  893. DROP INDEX fromName,
  894. DROP INDEX ID_MEMBER_FROM;
  895. ---#
  896. ---# Changing column sizes on "instant_messages" (part 2)...
  897. ALTER TABLE {$db_prefix}instant_messages
  898. DROP PRIMARY KEY,
  899. CHANGE COLUMN ID_IM ID_PM int(10) unsigned NOT NULL auto_increment PRIMARY KEY;
  900. ALTER TABLE {$db_prefix}instant_messages
  901. ADD INDEX msgtime (msgtime);
  902. ---#
  903. ---# Cleaning up "instant_messages"...
  904. ALTER TABLE {$db_prefix}instant_messages
  905. DROP INDEX ID_MEMBER_FROM_2;
  906. ALTER TABLE {$db_prefix}instant_messages
  907. DROP INDEX ID_MEMBER_FROM_3;
  908. ALTER TABLE {$db_prefix}instant_messages
  909. DROP INDEX ID_MEMBER_FROM_4;
  910. ALTER TABLE {$db_prefix}instant_messages
  911. DROP INDEX ID_MEMBER_FROM_5;
  912. ALTER TABLE {$db_prefix}instant_messages
  913. DROP INDEX ID_MEMBER_TO_2;
  914. ALTER TABLE {$db_prefix}instant_messages
  915. DROP INDEX ID_MEMBER_TO_3;
  916. ALTER TABLE {$db_prefix}instant_messages
  917. DROP INDEX ID_MEMBER_TO_4;
  918. ALTER TABLE {$db_prefix}instant_messages
  919. DROP INDEX ID_MEMBER_TO_5;
  920. ALTER TABLE {$db_prefix}instant_messages
  921. DROP INDEX deletedBy_2;
  922. ALTER TABLE {$db_prefix}instant_messages
  923. DROP INDEX deletedBy_3;
  924. ALTER TABLE {$db_prefix}instant_messages
  925. DROP INDEX deletedBy_4;
  926. ALTER TABLE {$db_prefix}instant_messages
  927. DROP INDEX deletedBy_5;
  928. ---#
  929. ---# Creating "im_recipients"...
  930. CREATE TABLE IF NOT EXISTS {$db_prefix}im_recipients (
  931. ID_PM int(10) unsigned NOT NULL default '0',
  932. ID_MEMBER mediumint(8) unsigned NOT NULL default '0',
  933. bcc tinyint(3) unsigned NOT NULL default '0',
  934. is_read tinyint(3) unsigned NOT NULL default '0',
  935. deleted tinyint(3) unsigned NOT NULL default '0',
  936. PRIMARY KEY (ID_PM, ID_MEMBER),
  937. KEY ID_MEMBER (ID_MEMBER, deleted)
  938. ) ENGINE=MyISAM;
  939. ---#
  940. ---# Updating "im_recipients"...
  941. ALTER TABLE {$db_prefix}im_recipients
  942. DROP PRIMARY KEY,
  943. CHANGE COLUMN ID_IM ID_PM int(10) unsigned NOT NULL default '0',
  944. ADD PRIMARY KEY (ID_PM, ID_MEMBER);
  945. ---#
  946. ---# Updating data in "instant_messages" (part 1)...
  947. ---{
  948. $request = upgrade_query("
  949. SHOW COLUMNS
  950. FROM {$db_prefix}instant_messages
  951. LIKE 'readBy'");
  952. $do_it = $request !== false;
  953. if ($do_it)
  954. {
  955. $adv_im = smf_mysql_num_rows($request) == 0;
  956. smf_mysql_free_result($request);
  957. upgrade_query("
  958. INSERT IGNORE INTO {$db_prefix}im_recipients
  959. (ID_PM, ID_MEMBER, bcc, is_read, deleted)
  960. SELECT ID_PM, ID_MEMBER_TO, 0, IF(" . (!$adv_im ? 'readBy' : 'alerted') . " != 0, 1, 0), IF(deletedBy = '1', 1, 0)
  961. FROM {$db_prefix}instant_messages");
  962. }
  963. ---}
  964. UPDATE IGNORE {$db_prefix}instant_messages
  965. SET deletedBySender = 1
  966. WHERE deletedBy = 0;
  967. ---#
  968. ---# Updating data in "instant_messages" (part 2)...
  969. ALTER TABLE {$db_prefix}instant_messages
  970. DROP INDEX ID_MEMBER_TO;
  971. ALTER TABLE {$db_prefix}instant_messages
  972. DROP INDEX deletedBy;
  973. ALTER TABLE {$db_prefix}instant_messages
  974. DROP INDEX readBy;
  975. ALTER TABLE {$db_prefix}instant_messages
  976. DROP COLUMN ID_MEMBER_TO,
  977. DROP COLUMN deletedBy,
  978. DROP COLUMN toName,
  979. DROP COLUMN readBy;
  980. ALTER TABLE {$db_prefix}instant_messages
  981. ADD INDEX ID_MEMBER (ID_MEMBER_FROM, deletedBySender);
  982. ---#
  983. ---# Recounting personal message totals...
  984. ---{
  985. $request = upgrade_query("
  986. SHOW CREATE TABLE {$db_prefix}instant_messages");
  987. $do_it = $request !== false;
  988. @smf_mysql_free_result($request);
  989. $request = upgrade_query("
  990. SELECT COUNT(*)
  991. FROM {$db_prefix}members");
  992. list ($totalMembers) = smf_mysql_fetch_row($request);
  993. smf_mysql_free_result($request);
  994. $_GET['m'] = (int) @$_GET['m'];
  995. while ($_GET['m'] < $totalMembers && $do_it)
  996. {
  997. nextSubstep($substep);
  998. $mrequest = upgrade_query("
  999. SELECT mem.ID_MEMBER, COUNT(pmr.ID_PM) AS instantMessages_real, mem.instantMessages
  1000. FROM {$db_prefix}members AS mem
  1001. LEFT JOIN {$db_prefix}im_recipients AS pmr ON (pmr.ID_MEMBER = mem.ID_MEMBER AND pmr.deleted = 0)
  1002. WHERE mem.ID_MEMBER > $_GET[m]
  1003. AND mem.ID_MEMBER <= $_GET[m] + 512
  1004. GROUP BY mem.ID_MEMBER
  1005. HAVING instantMessages_real != instantMessages
  1006. LIMIT 512");
  1007. while ($row = smf_mysql_fetch_assoc($mrequest))
  1008. {
  1009. upgrade_query("
  1010. UPDATE {$db_prefix}members
  1011. SET instantMessages = $row[instantMessages_real]
  1012. WHERE ID_MEMBER = $row[ID_MEMBER]
  1013. LIMIT 1");
  1014. }
  1015. $_GET['m'] += 512;
  1016. }
  1017. unset($_GET['m']);
  1018. ---}
  1019. ---{
  1020. $request = upgrade_query("
  1021. SHOW CREATE TABLE {$db_prefix}instant_messages");
  1022. $do_it = $request !== false;
  1023. @smf_mysql_free_result($request);
  1024. $request = upgrade_query("
  1025. SELECT COUNT(*)
  1026. FROM {$db_prefix}members");
  1027. list ($totalMembers) = smf_mysql_fetch_row($request);
  1028. smf_mysql_free_result($request);
  1029. $_GET['m'] = (int) @$_GET['m'];
  1030. while ($_GET['m'] < $totalMembers && $do_it)
  1031. {
  1032. nextSubstep($substep);
  1033. $mrequest = upgrade_query("
  1034. SELECT mem.ID_MEMBER, COUNT(pmr.ID_PM) AS unreadMessages_real, mem.unreadMessages
  1035. FROM {$db_prefix}members AS mem
  1036. LEFT JOIN {$db_prefix}im_recipients AS pmr ON (pmr.ID_MEMBER = mem.ID_MEMBER AND pmr.deleted = 0 AND pmr.is_read = 0)
  1037. WHERE mem.ID_MEMBER > $_GET[m]
  1038. AND mem.ID_MEMBER <= $_GET[m] + 512
  1039. GROUP BY mem.ID_MEMBER
  1040. HAVING unreadMessages_real != unreadMessages
  1041. LIMIT 512");
  1042. while ($row = smf_mysql_fetch_assoc($mrequest))
  1043. {
  1044. upgrade_query("
  1045. UPDATE {$db_prefix}members
  1046. SET unreadMessages = $row[unreadMessages_real]
  1047. WHERE ID_MEMBER = $row[ID_MEMBER]
  1048. LIMIT 1");
  1049. }
  1050. $_GET['m'] += 512;
  1051. }
  1052. unset($_GET['m']);
  1053. ---}
  1054. ---#
  1055. ---# Converting "membergroups"...
  1056. ---{
  1057. global $JrPostNum, $FullPostNum, $SrPostNum, $GodPostNum;
  1058. $result = upgrade_query("
  1059. SELECT minPosts
  1060. FROM {$db_prefix}membergroups
  1061. LIMIT 1");
  1062. if ($result === false)
  1063. {
  1064. upgrade_query("
  1065. RENAME TABLE {$db_prefix}membergroups TO {$db_prefix}old_membergroups");
  1066. upgrade_query("
  1067. CREATE TABLE {$db_prefix}membergroups (
  1068. ID_GROUP smallint(5) unsigned NOT NULL auto_increment,
  1069. groupName varchar(80) NOT NULL default '',
  1070. onlineColor varchar(20) NOT NULL default '',
  1071. minPosts mediumint(9) NOT NULL default '-1',
  1072. maxMessages smallint(5) unsigned NOT NULL default '0',
  1073. stars tinytext NOT NULL default '',
  1074. PRIMARY KEY (ID_GROUP),
  1075. KEY minPosts (minPosts)
  1076. ) ENGINE=MyISAM");
  1077. upgrade_query("
  1078. INSERT INTO {$db_prefix}membergroups
  1079. (ID_GROUP, groupName, onlineColor, minPosts, stars)
  1080. SELECT ID_GROUP, membergroup, '#FF0000', -1, '5#staradmin.gif'
  1081. FROM {$db_prefix}old_membergroups
  1082. WHERE ID_GROUP = 1");
  1083. upgrade_query("
  1084. INSERT INTO {$db_prefix}membergroups
  1085. (ID_GROUP, groupName, onlineColor, minPosts, stars)
  1086. SELECT 2, membergroup, '#0000FF', -1, '5#stargmod.gif'
  1087. FROM {$db_prefix}old_membergroups
  1088. WHERE ID_GROUP = 8");
  1089. upgrade_query("
  1090. INSERT INTO {$db_prefix}membergroups
  1091. (ID_GROUP, groupName, onlineColor, minPosts, stars)
  1092. SELECT 3, membergroup, '', -1, '5#starmod.gif'
  1093. FROM {$db_prefix}old_membergroups
  1094. WHERE ID_GROUP = 2");
  1095. upgrade_query("
  1096. INSERT INTO {$db_prefix}membergroups
  1097. (ID_GROUP, groupName, onlineColor, minPosts, stars)
  1098. SELECT
  1099. ID_GROUP + 1, membergroup, '', CASE ID_GROUP
  1100. WHEN 3 THEN 0
  1101. WHEN 4 THEN '$JrPostNum'
  1102. WHEN 5 THEN '$FullPostNum'
  1103. WHEN 6 THEN '$SrPostNum'
  1104. WHEN 7 THEN '$GodPostNum'
  1105. END, CONCAT(ID_GROUP - 2, '#star.gif')
  1106. FROM {$db_prefix}old_membergroups
  1107. WHERE ID_GROUP IN (3, 4, 5, 6, 7)");
  1108. upgrade_query("
  1109. INSERT INTO {$db_prefix}membergroups
  1110. (ID_GROUP, groupName, onlineColor, minPosts, stars)
  1111. SELECT ID_GROUP, membergroup, '', -1, ''
  1112. FROM {$db_prefix}old_membergroups
  1113. WHERE ID_GROUP > 8");
  1114. upgrade_query("
  1115. DROP TABLE IF EXISTS {$db_prefix}old_membergroups");
  1116. $permissions = array(
  1117. 'view_mlist',
  1118. 'search_posts',
  1119. 'profile_view_own',
  1120. 'profile_view_any',
  1121. 'pm_read',
  1122. 'pm_send',
  1123. 'calendar_view',
  1124. 'view_stats',
  1125. 'who_view',
  1126. 'profile_identity_own',
  1127. 'profile_extra_own',
  1128. 'profile_remote_avatar',
  1129. 'profile_remove_own',
  1130. );
  1131. foreach ($permissions as $perm)
  1132. upgrade_query("
  1133. INSERT INTO {$db_prefix}permissions
  1134. (ID_GROUP, permission)
  1135. SELECT IF(ID_GROUP = 1, 0, ID_GROUP), '$perm'
  1136. FROM {$db_prefix}membergroups
  1137. WHERE ID_GROUP != 3
  1138. AND minPosts = -1");
  1139. $board_permissions = array(
  1140. 'remove_own',
  1141. 'lock_own',
  1142. 'mark_any_notify',
  1143. 'mark_notify',
  1144. 'modify_own',
  1145. 'poll_add_own',
  1146. 'poll_edit_own',
  1147. 'poll_lock_own',
  1148. 'poll_post',
  1149. 'poll_view',
  1150. 'poll_vote',
  1151. 'post_attachment',
  1152. 'post_new',
  1153. 'post_reply_any',
  1154. 'post_reply_own',
  1155. 'delete_own',
  1156. 'report_any',
  1157. 'send_topic',
  1158. 'view_attachments',
  1159. );
  1160. foreach ($board_permissions as $perm)
  1161. upgrade_query("
  1162. INSERT INTO {$db_prefix}board_permissions
  1163. (ID_GROUP, permission)
  1164. SELECT IF(ID_GROUP = 1, 0, ID_GROUP), '$perm'
  1165. FROM {$db_prefix}membergroups
  1166. WHERE minPosts = -1");
  1167. }
  1168. ---}
  1169. ---#
  1170. ---# Converting "reserved_names"...
  1171. ---{
  1172. $request = upgrade_query("
  1173. SELECT setting, value
  1174. FROM {$db_prefix}reserved_names");
  1175. if ($request !== false)
  1176. {
  1177. $words = array();
  1178. $match_settings = array();
  1179. while ($row = smf_mysql_fetch_assoc($request))
  1180. {
  1181. if (substr($row['setting'], 0, 5) == 'match')
  1182. $match_settings[$row['setting']] = $row['value'];
  1183. else
  1184. $words[] = $row['value'];
  1185. }
  1186. smf_mysql_free_result($request);
  1187. upgrade_query("
  1188. INSERT IGNORE INTO {$db_prefix}settings
  1189. VALUES ('reserveWord', '" . (int) @$match_settings['matchword'] . "'),
  1190. ('reserveCase', '" . (int) @$match_settings['matchcase'] . "'),
  1191. ('reserveUser', '" . (int) @$match_settings['matchuser'] . "'),
  1192. ('reserveName', '" . (int) @$match_settings['matchname'] . "'),
  1193. ('reserveNames', '" . implode("\n", $words) . "')");
  1194. upgrade_query("
  1195. DROP TABLE {$db_prefix}reserved_names");
  1196. }
  1197. ---}
  1198. ---#
  1199. ---# Converting member's groups...
  1200. ALTER TABLE {$db_prefix}members
  1201. ADD COLUMN ID_POST_GROUP smallint(5) unsigned NOT NULL default '0',
  1202. ADD INDEX ID_POST_GROUP (ID_POST_GROUP);
  1203. ---{
  1204. $request = upgrade_query("
  1205. SELECT ID_GROUP, minPosts
  1206. FROM {$db_prefix}membergroups
  1207. WHERE minPosts != -1
  1208. ORDER BY minPosts DESC");
  1209. $post_groups = array();
  1210. while ($row = smf_mysql_fetch_assoc($request))
  1211. $post_groups[$row['minPosts']] = $row['ID_GROUP'];
  1212. smf_mysql_free_result($request);
  1213. $request = upgrade_query("
  1214. SELECT ID_MEMBER, posts
  1215. FROM {$db_prefix}members");
  1216. $mg_updates = array();
  1217. while ($row = smf_mysql_fetch_assoc($request))
  1218. {
  1219. $group = 4;
  1220. foreach ($post_groups as $min_posts => $group_id)
  1221. if ($row['posts'] > $min_posts)
  1222. {
  1223. $group = $group_id;
  1224. break;
  1225. }
  1226. $mg_updates[$group][] = $row['ID_MEMBER'];
  1227. }
  1228. smf_mysql_free_result($request);
  1229. foreach ($mg_updates as $group_to => $update_members)
  1230. upgrade_query("
  1231. UPDATE {$db_prefix}members
  1232. SET ID_POST_GROUP = $group_to
  1233. WHERE ID_MEMBER IN (" . implode(', ', $update_members) . ")
  1234. LIMIT " . count($update_members));
  1235. ---}
  1236. ---#
  1237. /******************************************************************************/
  1238. --- Converting the calendar, notifications, and miscellaneous...
  1239. /******************************************************************************/
  1240. ---# Converting censored words...
  1241. ---{
  1242. if (!isset($modSettings['censor_vulgar']) || !isset($modSettings['censor_proper']))
  1243. {
  1244. $request = upgrade_query("
  1245. SELECT vulgar, proper
  1246. FROM {$db_prefix}censor");
  1247. $censor_vulgar = array();
  1248. $censor_proper = array();
  1249. while ($row = smf_mysql_fetch_row($request))
  1250. {
  1251. $censor_vulgar[] = trim($row[0]);
  1252. $censor_proper[] = trim($row[1]);
  1253. }
  1254. smf_mysql_free_result($request);
  1255. $modSettings['censor_vulgar'] = addslashes(implode("\n", $censor_vulgar));
  1256. $modSettings['censor_proper'] = addslashes(implode("\n", $censor_proper));
  1257. upgrade_query("
  1258. INSERT IGNORE INTO {$db_prefix}settings
  1259. (variable, value)
  1260. VALUES
  1261. ('censor_vulgar', '$modSettings[censor_vulgar]'),
  1262. ('censor_proper', '$modSettings[censor_proper]')");
  1263. upgrade_query("
  1264. DROP TABLE IF EXISTS {$db_prefix}censor");
  1265. }
  1266. ---}
  1267. ---#
  1268. ---# Converting topic notifications...
  1269. ---{
  1270. $result = upgrade_query("
  1271. SELECT COUNT(*)
  1272. FROM {$db_prefix}topics
  1273. WHERE notifies != ''");
  1274. if ($result !== false)
  1275. {
  1276. list ($numNotifies) = smf_mysql_fetch_row($result);
  1277. smf_mysql_free_result($result);
  1278. $_GET['t'] = (int) @$_GET['t'];
  1279. while ($_GET['t'] < $numNotifies)
  1280. {
  1281. nextSubstep($substep);
  1282. upgrade_query("
  1283. INSERT IGNORE INTO {$db_prefix}log_notify
  1284. (ID_MEMBER, ID_TOPIC)
  1285. SELECT mem.ID_MEMBER, t.ID_TOPIC
  1286. FROM ({$db_prefix}topics AS t, {$db_prefix}members AS mem)
  1287. WHERE FIND_IN_SET(mem.ID_MEMBER, t.notifies)
  1288. AND t.notifies != ''
  1289. LIMIT $_GET[t], 512");
  1290. $_GET['t'] += 512;
  1291. }
  1292. unset($_GET['t']);
  1293. }
  1294. ---}
  1295. ALTER TABLE {$db_prefix}topics
  1296. DROP notifies;
  1297. ---#
  1298. ---# Converting "banned"...
  1299. ---{
  1300. $request = upgrade_query("
  1301. SELECT type, value
  1302. FROM {$db_prefix}banned
  1303. WHERE type = 'ip'");
  1304. if ($request !== false)
  1305. {
  1306. $insertEntries = array();
  1307. while ($row = smf_mysql_fetch_assoc($request))
  1308. {
  1309. if (preg_match('~^\d{1,3}\.(\d{1,3}|\*)\.(\d{1,3}|\*)\.(\d{1,3}|\*)$~', $row['value']) == 0)
  1310. continue;
  1311. $ip_parts = ip2range($row['value']);
  1312. $insertEntries[] = "('ip_ban', {$ip_parts[0]['low']}, {$ip_parts[0]['high']}, {$ip_parts[1]['low']}, {$ip_parts[1]['high']}, {$ip_parts[2]['low']}, {$ip_parts[2]['high']}, {$ip_parts[3]['low']}, {$ip_parts[3]['high']}, '', '', 0, " . time() . ", NULL, 'full_ban', '', 'Imported from YaBB SE')";
  1313. }
  1314. smf_mysql_free_result($request);
  1315. upgrade_query("
  1316. CREATE TABLE IF NOT EXISTS {$db_prefix}banned2 (
  1317. id_ban mediumint(8) unsigned NOT NULL auto_increment,
  1318. ban_type varchar(30) NOT NULL default '',
  1319. ip_low1 tinyint(3) unsigned NOT NULL default '0',
  1320. ip_high1 tinyint(3) unsigned NOT NULL default '0',
  1321. ip_low2 tinyint(3) unsigned NOT NULL default '0',
  1322. ip_high2 tinyint(3) unsigned NOT NULL default '0',
  1323. ip_low3 tinyint(3) unsigned NOT NULL default '0',
  1324. ip_high3 tinyint(3) unsigned NOT NULL default '0',
  1325. ip_low4 tinyint(3) unsigned NOT NULL default '0',
  1326. ip_high4 tinyint(3) unsigned NOT NULL default '0',
  1327. hostname tinytext NOT NULL default '',
  1328. email_address tinytext NOT NULL default '',
  1329. ID_MEMBER mediumint(8) unsigned NOT NULL default '0',
  1330. ban_time int(10) unsigned NOT NULL default '0',
  1331. expire_time int(10) unsigned,
  1332. restriction_type varchar(30) NOT NULL default '',
  1333. reason tinytext NOT NULL default '',
  1334. notes text NOT NULL default '',
  1335. PRIMARY KEY (id_ban)
  1336. ) ENGINE=MyISAM");
  1337. upgrade_query("
  1338. INSERT INTO {$db_prefix}banned2
  1339. (ban_type, ip_low1, ip_high1, ip_low2, ip_high2, ip_low3, ip_high3, ip_low4, ip_high4, hostname, email_address, ID_MEMBER, ban_time, expire_time, restriction_type, reason, notes)
  1340. SELECT 'email_ban', 0, 0, 0, 0, 0, 0, 0, 0, '', value, 0, " . time() . ", NULL, 'full_ban', '', 'Imported from YaBB SE'
  1341. FROM {$db_prefix}banned
  1342. WHERE type = 'email'");
  1343. upgrade_query("
  1344. INSERT INTO {$db_prefix}banned2
  1345. (ban_type, ip_low1, ip_high1, ip_low2, ip_high2, ip_low3, ip_high3, ip_low4, ip_high4, hostname, email_address, ID_MEMBER, ban_time, expire_time, restriction_type, reason, notes)
  1346. SELECT 'user_ban', 0, 0, 0, 0, 0, 0, 0, 0, '', '', mem.ID_MEMBER, " . time() . ", NULL, 'full_ban', '', 'Imported from YaBB SE'
  1347. FROM ({$db_prefix}banned AS ban, {$db_prefix}members AS mem)
  1348. WHERE ban.type = 'username'
  1349. AND mem.memberName = ban.value");
  1350. upgrade_query("
  1351. DROP TABLE {$db_prefix}banned");
  1352. upgrade_query("
  1353. RENAME TABLE {$db_prefix}banned2 TO {$db_prefix}banned");
  1354. if (!empty($insertEntries))
  1355. {
  1356. upgrade_query("
  1357. INSERT INTO {$db_prefix}banned
  1358. (ban_type, ip_low1, ip_high1, ip_low2, ip_high2, ip_low3, ip_high3, ip_low4, ip_high4, hostname, email_address, ID_MEMBER, ban_time, expire_time, restriction_type, reason, notes)
  1359. VALUES " . implode(',', $insertEntries));
  1360. }
  1361. }
  1362. ---}
  1363. ---#
  1364. ---# Updating "log_banned"...
  1365. ALTER TABLE {$db_prefix}log_banned
  1366. CHANGE COLUMN logTime logTime int(10) unsigned NOT NULL default '0';
  1367. ALTER TABLE {$db_prefix}log_banned
  1368. ADD COLUMN id_ban_log mediumint(8) unsigned NOT NULL auto_increment PRIMARY KEY FIRST,
  1369. ADD COLUMN ID_MEMBER mediumint(8) unsigned NOT NULL default '0' AFTER id_ban_log,
  1370. ADD INDEX logTime (logTime);
  1371. ---#
  1372. ---# Updating columns on "calendar"...
  1373. ALTER TABLE {$db_prefix}calendar
  1374. DROP PRIMARY KEY,
  1375. CHANGE COLUMN id ID_EVENT smallint(5) unsigned NOT NULL auto_increment PRIMARY KEY,
  1376. CHANGE COLUMN id_board ID_BOARD smallint(5) unsigned NOT NULL default '0',
  1377. CHANGE COLUMN id_topic ID_TOPIC mediumint(8) unsigned NOT NULL default '0',
  1378. CHANGE COLUMN id_member ID_MEMBER mediumint(8) unsigned NOT NULL default '0';
  1379. ALTER TABLE {$db_prefix}calendar
  1380. CHANGE COLUMN title title varchar(48) NOT NULL default '';
  1381. ALTER TABLE {$db_prefix}calendar
  1382. ADD eventDate date NOT NULL default '0000-00-00';
  1383. ---#
  1384. ---# Updating indexes on "calendar"...
  1385. ALTER TABLE {$db_prefix}calendar
  1386. DROP INDEX idx_year_month;
  1387. ALTER TABLE {$db_prefix}calendar
  1388. DROP INDEX year;
  1389. ---#
  1390. ---# Updating data in "calendar"...
  1391. UPDATE IGNORE {$db_prefix}calendar
  1392. SET eventDate = CONCAT(year, '-', month + 1, '-', day);
  1393. ALTER TABLE {$db_prefix}calendar
  1394. DROP year,
  1395. DROP month,
  1396. DROP day,
  1397. ADD INDEX eventDate (eventDate);
  1398. ---#
  1399. ---# Updating structure on "calendar_holidays"...
  1400. CREATE TABLE IF NOT EXISTS {$db_prefix}calendar_holidays (
  1401. ID_HOLIDAY smallint(5) unsigned NOT NULL auto_increment,
  1402. eventDate date NOT NULL default '0000-00-00',
  1403. title varchar(30) NOT NULL default '',
  1404. PRIMARY KEY (ID_HOLIDAY),
  1405. KEY eventDate (eventDate)
  1406. ) ENGINE=MyISAM;
  1407. ---#
  1408. ---# Updating data in "calendar_holidays"...
  1409. ---{
  1410. $result = upgrade_query("
  1411. SELECT COUNT(*)
  1412. FROM {$db_prefix}calendar_holidays");
  1413. list ($size) = smf_mysql_fetch_row($result);
  1414. smf_mysql_free_result($result);
  1415. if (empty($size))
  1416. {
  1417. upgrade_query("
  1418. INSERT INTO {$db_prefix}calendar_holidays
  1419. (eventDate, title)
  1420. SELECT IF(year IS NULL, CONCAT('0000-', month, '-', day), CONCAT(year, '-', month, '-', day)), title
  1421. FROM {$db_prefix}calendar_holiday");
  1422. upgrade_query("
  1423. INSERT INTO {$db_prefix}calendar_holidays
  1424. (eventDate, title)
  1425. VALUES ('0000-06-06', 'D-Day')");
  1426. }
  1427. ---}
  1428. UPDATE {$db_prefix}calendar_holidays
  1429. SET title = 'New Year\'s'
  1430. WHERE title = 'New Years';
  1431. ---#
  1432. /******************************************************************************/
  1433. --- Converting polls and choices...
  1434. /******************************************************************************/
  1435. ---# Converting data to "poll_choices"...
  1436. INSERT INTO {$db_prefix}poll_choices
  1437. (ID_POLL, ID_CHOICE, label, votes)
  1438. SELECT ID_POLL, 0, option1, votes1
  1439. FROM {$db_prefix}polls;
  1440. INSERT INTO {$db_prefix}poll_choices
  1441. (ID_POLL, ID_CHOICE, label, votes)
  1442. SELECT ID_POLL, 1, option2, votes2
  1443. FROM {$db_prefix}polls;
  1444. INSERT INTO {$db_prefix}poll_choices
  1445. (ID_POLL, ID_CHOICE, label, votes)
  1446. SELECT ID_POLL, 2, option3, votes3
  1447. FROM {$db_prefix}polls;
  1448. INSERT INTO {$db_prefix}poll_choices
  1449. (ID_POLL, ID_CHOICE, label, votes)
  1450. SELECT ID_POLL, 3, option4, votes4
  1451. FROM {$db_prefix}polls;
  1452. INSERT INTO {$db_prefix}poll_choices
  1453. (ID_POLL, ID_CHOICE, label, votes)
  1454. SELECT ID_POLL, 4, option5, votes5
  1455. FROM {$db_prefix}polls;
  1456. INSERT INTO {$db_prefix}poll_choices
  1457. (ID_POLL, ID_CHOICE, label, votes)
  1458. SELECT ID_POLL, 5, option6, votes6
  1459. FROM {$db_prefix}polls;
  1460. INSERT INTO {$db_prefix}poll_choices
  1461. (ID_POLL, ID_CHOICE, label, votes)
  1462. SELECT ID_POLL, 6, option7, votes7
  1463. FROM {$db_prefix}polls;
  1464. INSERT INTO {$db_prefix}poll_choices
  1465. (ID_POLL, ID_CHOICE, label, votes)
  1466. SELECT ID_POLL, 7, option8, votes8
  1467. FROM {$db_prefix}polls;
  1468. ---#
  1469. ---# Converting data to "log_polls"...
  1470. ---{
  1471. $query = upgrade_query("
  1472. SELECT ID_POLL, votedMemberIDs
  1473. FROM {$db_prefix}polls");
  1474. if ($query !== false)
  1475. {
  1476. $setStringLog = '';
  1477. while ($row = smf_mysql_fetch_assoc($query))
  1478. {
  1479. $members = explode(',', $row['votedMemberIDs']);
  1480. foreach ($members as $member)
  1481. if (is_numeric($member) && !empty($member))
  1482. $setStringLog .= "
  1483. ($row[ID_POLL], $member, 0),";
  1484. }
  1485. if (!empty($setStringLog))
  1486. {
  1487. upgrade_query("
  1488. INSERT IGNORE INTO {$db_prefix}log_polls
  1489. (ID_POLL, ID_MEMBER, ID_CHOICE)
  1490. VALUES " . substr($setStringLog, 0, -1));
  1491. }
  1492. }
  1493. ---}
  1494. ---#
  1495. ---# Updating "polls"...
  1496. ALTER TABLE {$db_prefix}polls
  1497. DROP option1, DROP option2, DROP option3, DROP option4, DROP option5, DROP option6, DROP option7, DROP option8,
  1498. DROP votes1, DROP votes2, DROP votes3, DROP votes4, DROP votes5, DROP votes6, DROP votes7, DROP votes8,
  1499. DROP votedMemberIDs,
  1500. DROP PRIMARY KEY,
  1501. CHANGE COLUMN ID_POLL ID_POLL mediumint(8) unsigned NOT NULL auto_increment PRIMARY KEY,
  1502. CHANGE COLUMN votingLocked votingLocked tinyint(1) NOT NULL default '0',
  1503. CHANGE COLUMN question question tinytext NOT NULL default '',
  1504. ADD maxVotes tinyint(4) unsigned NOT NULL default '1',
  1505. ADD expireTime int(10) unsigned NOT NULL default '0',
  1506. ADD hideResults tinyint(4) unsigned NOT NULL default '0';
  1507. ALTER TABLE {$db_prefix}polls
  1508. ADD ID_MEMBER mediumint(8) unsigned NOT NULL default '0',
  1509. ADD posterName tinytext NOT NULL default '';
  1510. ALTER TABLE {$db_prefix}polls
  1511. ADD changeVote tinyint(4) unsigned NOT NULL default '0';
  1512. ---#
  1513. ---# Updating data in "polls"...
  1514. ---{
  1515. $result = upgrade_query("
  1516. SELECT p.ID_POLL, t.ID_MEMBER_STARTED
  1517. FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}polls AS p)
  1518. WHERE m.ID_MSG = t.ID_FIRST_MSG
  1519. AND p.ID_POLL = t.ID_POLL
  1520. AND p.ID_MEMBER = 0
  1521. AND t.ID_MEMBER_STARTED != 0");
  1522. while ($row = smf_mysql_fetch_assoc($result))
  1523. {
  1524. upgrade_query("
  1525. UPDATE {$db_prefix}polls
  1526. SET ID_MEMBER = $row[ID_MEMBER_STARTED]
  1527. WHERE ID_POLL = $row[ID_POLL]
  1528. LIMIT 1");
  1529. }
  1530. smf_mysql_free_result($result);
  1531. ---}
  1532. ---#
  1533. /******************************************************************************/
  1534. --- Converting settings...
  1535. /******************************************************************************/
  1536. ---# Updating news...
  1537. ---{
  1538. if (!isset($modSettings['smfVersion']))
  1539. {
  1540. upgrade_query("
  1541. REPLACE INTO {$db_prefix}settings
  1542. (variable, value)
  1543. VALUES
  1544. ('news', SUBSTRING('" . htmlspecialchars(stripslashes($modSettings['news']), ENT_QUOTES) . "', 1, 65534))");
  1545. }
  1546. ---}
  1547. ---#
  1548. ---# Updating "themes"...
  1549. ---{
  1550. convertSettingsToTheme();
  1551. $insertRows = '';
  1552. $request = upgrade_query("
  1553. SELECT ID_THEME, IF(value = '2', 5, value) AS value
  1554. FROM {$db_prefix}themes
  1555. WHERE variable = 'display_recent_bar'");
  1556. while ($row = smf_mysql_fetch_assoc($request))
  1557. $insertRows .= "($row[ID_THEME], 'number_recent_posts', '$row[value]'),";
  1558. smf_mysql_free_result($request);
  1559. if (!empty($insertRows))
  1560. {
  1561. $insertRows = substr($insertRows, 0, -1);
  1562. upgrade_query("
  1563. INSERT IGNORE INTO {$db_prefix}themes
  1564. (ID_THEME, variable, value)
  1565. VALUES $insertRows");
  1566. }
  1567. ---}
  1568. ---#
  1569. ---# Updating "settings"...
  1570. ALTER TABLE {$db_prefix}settings
  1571. DROP INDEX variable;
  1572. UPDATE IGNORE {$db_prefix}settings
  1573. SET variable = 'guest_hideContacts'
  1574. WHERE variable = 'guest_hideEmail'
  1575. LIMIT 1;
  1576. ---#
  1577. ---# Adding new settings (part 1)...
  1578. INSERT IGNORE INTO {$db_prefix}settings
  1579. (variable, value)
  1580. VALUES
  1581. ('news', ''),
  1582. ('compactTopicPagesContiguous', '5'),
  1583. ('compactTopicPagesEnable', '1'),
  1584. ('enableStickyTopics', '1'),
  1585. ('todayMod', '1'),
  1586. ('karmaMode', '0'),
  1587. ('karmaTimeRestrictAdmins', '1'),
  1588. ('enablePreviousNext', '1'),
  1589. ('pollMode', '1'),
  1590. ('enableVBStyleLogin', '1'),
  1591. ('enableCompressedOutput', '1'),
  1592. ('karmaWaitTime', '1'),
  1593. ('karmaMinPosts', '0'),
  1594. ('karmaLabel', 'Karma:'),
  1595. ('karmaSmiteLabel', '[smite]'),
  1596. ('karmaApplaudLabel', '[applaud]'),
  1597. ('attachmentSizeLimit', '128'),
  1598. ('attachmentPostLimit', '192'),
  1599. ('attachmentNumPerPostLimit', '4'),
  1600. ('attachmentDirSizeLimit', '10240'),
  1601. ('attachmentUploadDir', '{$sboarddir}/attachments'),
  1602. ('attachmentExtensions', 'txt,doc,pdf,jpg,gif,mpg,png'),
  1603. ('attachmentCheckExtensions', '1'),
  1604. ('attachmentShowImages', '1'),
  1605. ('attachmentEnable', '1'),
  1606. ('attachmentEncryptFilenames', '1'),
  1607. ('censorIgnoreCase', '1'),
  1608. ('mostOnline', '1');
  1609. INSERT IGNORE INTO {$db_prefix}settings
  1610. (variable, value)
  1611. VALUES
  1612. ('mostOnlineToday', '1'),
  1613. ('mostDate', UNIX_TIMESTAMP()),
  1614. ('trackStats', '1'),
  1615. ('userLanguage', '1'),
  1616. ('titlesEnable', '1'),
  1617. ('topicSummaryPosts', '15'),
  1618. ('enableErrorLogging', '1'),
  1619. ('onlineEnable', '0'),
  1620. ('cal_holidaycolor', '000080'),
  1621. ('cal_bdaycolor', '920AC4'),
  1622. ('cal_eventcolor', '078907'),
  1623. ('cal_enabled', '0'),
  1624. ('cal_maxyear', '2010'),
  1625. ('cal_minyear', '2002'),
  1626. ('cal_daysaslink', '0'),
  1627. ('cal_defaultboard', ''),
  1628. ('cal_showeventsonindex', '0'),
  1629. ('cal_showbdaysonindex', '0'),
  1630. ('cal_showholidaysonindex', '0'),
  1631. ('cal_maxspan', '7'),
  1632. ('cal_highlight_events', '3'),
  1633. ('cal_highlight_holidays', '3'),
  1634. ('cal_highlight_birthdays', '3'),
  1635. ('cal_disable_prev_next', '0'),
  1636. ('cal_display_type', '0'),
  1637. ('cal_week_links', '2'),
  1638. ('cal_prev_next_links', '1'),
  1639. ('cal_short_days', '0'),
  1640. ('cal_short_months', '0'),
  1641. ('cal_week_numbers', '0'),
  1642. ('smtp_host', ''),
  1643. ('smtp_username', ''),
  1644. ('smtp_password', ''),
  1645. ('mail_type', '0'),
  1646. ('timeLoadPageEnable', '0'),
  1647. ('totalTopics', '1'),
  1648. ('totalMessages', '1'),
  1649. ('simpleSearch', '0'),
  1650. ('censor_vulgar', ''),
  1651. ('censor_proper', ''),
  1652. ('mostOnlineToday', '1'),
  1653. ('enablePostHTML', '0'),
  1654. ('theme_allow', '1'),
  1655. ('theme_default', '1'),
  1656. ('theme_guests', '1'),
  1657. ('enableEmbeddedFlash', '0'),
  1658. ('xmlnews_enable', '1'),
  1659. ('xmlnews_maxlen', '255'),
  1660. ('hotTopicPosts', '15'),
  1661. ('hotTopicVeryPosts', '25'),
  1662. ('allow_editDisplayName', '1'),
  1663. ('number_format', '1234.00'),
  1664. ('attachmentEncryptFilenames', '1'),
  1665. ('autoLinkUrls', '1');
  1666. INSERT IGNORE INTO {$db_prefix}settings
  1667. (variable, value)
  1668. VALUES
  1669. ('avatar_allow_server_stored', '1'),
  1670. ('avatar_check_size', '0'),
  1671. ('avatar_action_too_large', 'option_user_resize'),
  1672. ('avatar_resize_upload', '1'),
  1673. ('avatar_download_png', '1'),
  1674. ('failed_login_threshold', '3'),
  1675. ('edit_wait_time', '90'),
  1676. ('autoFixDatabase', '1'),
  1677. ('autoOptDatabase', '7'),
  1678. ('autoOptMaxOnline', '0'),
  1679. ('autoOptLastOpt', '0'),
  1680. ('enableParticipation', '1'),
  1681. ('recycle_enable', '0'),
  1682. ('recycle_board', '0'),
  1683. ('banLastUpdated', '0'),
  1684. ('enableAllMessages', '0'),
  1685. ('fixLongWords', '0'),
  1686. ('knownThemes', '1,2'),
  1687. ('who_enabled', '1'),
  1688. ('lastActive', '15'),
  1689. ('allow_hideOnline', '1'),
  1690. ('guest_hideContacts', '0');
  1691. ---#
  1692. ---# Adding new settings (part 2)...
  1693. ---{
  1694. upgrade_query("
  1695. INSERT IGNORE INTO {$db_prefix}settings
  1696. (variable, value)
  1697. VALUES
  1698. ('registration_method', '" . (!empty($modSettings['registration_disabled']) ? 3 : (!empty($modSettings['approve_registration']) ? 2 : (!empty($GLOBALS['emailpassword']) || !empty($modSettings['send_validation']) ? 1 : 0))) . "'),
  1699. ('send_validation_onChange', '" . @$GLOBALS['emailnewpass'] . "'),
  1700. ('send_welcomeEmail', '" . @$GLOBALS['emailwelcome'] . "'),
  1701. ('allow_hideEmail', '" . @$GLOBALS['allow_hide_email'] . "'),
  1702. ('allow_guestAccess', '" . @$GLOBALS['guestaccess'] . "'),
  1703. ('time_format', '" . (!empty($GLOBALS['timeformatstring']) ? $GLOBALS['timeformatstring'] : '%B %d, %Y, %I:%M:%S %p') . "'),
  1704. ('enableBBC', '" . (!isset($GLOBALS['enable_ubbc']) ? 1 : $GLOBALS['enable_ubbc']) . "'),
  1705. ('max_messageLength', '" . (empty($GLOBALS['MaxMessLen']) ? 10000 : $GLOBALS['MaxMessLen']) . "'),
  1706. ('max_signatureLength', '" . @$GLOBALS['MaxSigLen'] . "'),
  1707. ('spamWaitTime', '" . @$GLOBALS['timeout'] . "'),
  1708. ('avatar_directory', '" . (isset($GLOBALS['facesdir']) ? fixRelativePath($GLOBALS['facesdir']) : fixRelativePath('./avatars')) . "'),
  1709. ('avatar_url', '" . @$GLOBALS['facesurl'] . "'),
  1710. ('avatar_max_height_external', '" . @$GLOBALS['userpic_height'] . "'),
  1711. ('avatar_max_width_external', '" . @$GLOBALS['userpic_width'] . "'),
  1712. ('avatar_max_height_upload', '" . @$GLOBALS['userpic_height'] . "'),
  1713. ('avatar_max_width_upload', '" . @$GLOBALS['userpic_width'] . "'),
  1714. ('defaultMaxMessages', '" . (empty($GLOBALS['maxmessagedisplay']) ? 15 : $GLOBALS['maxmessagedisplay']) . "'),
  1715. ('defaultMaxTopics', '" . (empty($GLOBALS['maxdisplay']) ? 20 : $GLOBALS['maxdisplay']) . "'),
  1716. ('defaultMaxMembers', '" . (empty($GLOBALS['MembersPerPage']) ? 20 : $GLOBALS['MembersPerPage']) . "'),
  1717. ('time_offset', '" . @$GLOBALS['timeoffset'] . "'),
  1718. ('cookieTime', '" . (empty($GLOBALS['Cookie_Length']) ? 60 : $GLOBALS['Cookie_Length']) . "'),
  1719. ('requireAgreement', '" . @$GLOBALS['RegAgree'] . "')");
  1720. ---}
  1721. INSERT IGNORE INTO {$db_prefix}settings
  1722. (variable, value)
  1723. VALUES
  1724. ('smileys_dir', '{$sboarddir}/Smileys'),
  1725. ('smileys_url', '{$boardurl}/Smileys'),
  1726. ('smiley_sets_known', 'default,classic'),
  1727. ('smiley_sets_names', 'Default\nClassic'),
  1728. ('smiley_sets_default', 'default'),
  1729. ('censorIgnoreCase', '1'),
  1730. ('cal_days_for_index', '7'),
  1731. ('unapprovedMembers', '0'),
  1732. ('default_personalText', ''),
  1733. ('attachmentPostLimit', '192'),
  1734. ('attachmentNumPerPostLimit', '4'),
  1735. ('package_make_backups', '1'),
  1736. ('databaseSession_loose', '1'),
  1737. ('databaseSession_lifetime', '2880'),
  1738. ('smtp_port', '25'),
  1739. ('search_cache_size', '50'),
  1740. ('search_results_per_page', '30'),
  1741. ('search_weight_frequency', '30'),
  1742. ('search_weight_age', '25'),
  1743. ('search_weight_length', '20'),
  1744. ('search_weight_subject', '15'),
  1745. ('search_weight_first_message', '10');
  1746. DELETE FROM {$db_prefix}settings
  1747. WHERE variable = 'agreement'
  1748. LIMIT 1;
  1749. ---#
  1750. ---# Converting settings to options...
  1751. ---{
  1752. convertSettingsToOptions();
  1753. ---}
  1754. ---#
  1755. ---# Updating statistics...
  1756. REPLACE INTO {$db_prefix}settings
  1757. (variable, value)
  1758. SELECT 'latestMember', ID_MEMBER
  1759. FROM {$db_prefix}members
  1760. ORDER BY ID_MEMBER DESC
  1761. LIMIT 1;
  1762. REPLACE INTO {$db_prefix}settings
  1763. (variable, value)
  1764. SELECT 'latestRealName', IFNULL(realName, memberName)
  1765. FROM {$db_prefix}members
  1766. ORDER BY ID_MEMBER DESC
  1767. LIMIT 1;
  1768. REPLACE INTO {$db_prefix}settings
  1769. (variable, value)
  1770. SELECT 'maxMsgID', ID_MSG
  1771. FROM {$db_prefix}messages
  1772. ORDER BY ID_MSG DESC
  1773. LIMIT 1;
  1774. REPLACE INTO {$db_prefix}settings
  1775. (variable, value)
  1776. SELECT 'totalMembers', COUNT(*)
  1777. FROM {$db_prefix}members;
  1778. REPLACE INTO {$db_prefix}settings
  1779. (variable, value)
  1780. SELECT 'unapprovedMembers', COUNT(*)
  1781. FROM {$db_prefix}members
  1782. WHERE is_activated = 0
  1783. AND validation_code = '';
  1784. REPLACE INTO {$db_prefix}settings
  1785. (variable, value)
  1786. SELECT 'totalMessages', COUNT(*)
  1787. FROM {$db_prefix}messages;
  1788. REPLACE INTO {$db_prefix}settings
  1789. (variable, value)
  1790. SELECT 'totalTopics', COUNT(*)
  1791. FROM {$db_prefix}topics;
  1792. REPLACE INTO {$db_prefix}settings
  1793. (variable, value)
  1794. VALUES ('cal_today_updated', '00000000');
  1795. ---#