upgrade_1-0.sql 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027
  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. ('enableThemes', '1');
  1610. INSERT IGNORE INTO {$db_prefix}settings
  1611. (variable, value)
  1612. VALUES
  1613. ('mostOnlineToday', '1'),
  1614. ('mostDate', UNIX_TIMESTAMP()),
  1615. ('trackStats', '1'),
  1616. ('userLanguage', '1'),
  1617. ('titlesEnable', '1'),
  1618. ('topicSummaryPosts', '15'),
  1619. ('enableErrorLogging', '1'),
  1620. ('onlineEnable', '0'),
  1621. ('cal_holidaycolor', '000080'),
  1622. ('cal_bdaycolor', '920AC4'),
  1623. ('cal_eventcolor', '078907'),
  1624. ('cal_enabled', '0'),
  1625. ('cal_maxyear', '2010'),
  1626. ('cal_minyear', '2002'),
  1627. ('cal_daysaslink', '0'),
  1628. ('cal_defaultboard', ''),
  1629. ('cal_showeventsonindex', '0'),
  1630. ('cal_showbdaysonindex', '0'),
  1631. ('cal_showholidaysonindex', '0'),
  1632. ('cal_maxspan', '7'),
  1633. ('cal_highlight_events', '3'),
  1634. ('cal_highlight_holidays', '3'),
  1635. ('cal_highlight_birthdays', '3'),
  1636. ('cal_disable_prev_next', '0'),
  1637. ('cal_display_type', '0'),
  1638. ('cal_week_links', '2'),
  1639. ('cal_prev_next_links', '1'),
  1640. ('cal_short_days', '0'),
  1641. ('cal_short_months', '0'),
  1642. ('cal_week_numbers', '0'),
  1643. ('smtp_host', ''),
  1644. ('smtp_username', ''),
  1645. ('smtp_password', ''),
  1646. ('mail_type', '0'),
  1647. ('timeLoadPageEnable', '0'),
  1648. ('totalTopics', '1'),
  1649. ('totalMessages', '1'),
  1650. ('simpleSearch', '0'),
  1651. ('censor_vulgar', ''),
  1652. ('censor_proper', ''),
  1653. ('mostOnlineToday', '1'),
  1654. ('enablePostHTML', '0'),
  1655. ('theme_allow', '1'),
  1656. ('theme_default', '1'),
  1657. ('theme_guests', '1'),
  1658. ('enableEmbeddedFlash', '0'),
  1659. ('xmlnews_enable', '1'),
  1660. ('xmlnews_maxlen', '255'),
  1661. ('hotTopicPosts', '15'),
  1662. ('hotTopicVeryPosts', '25'),
  1663. ('allow_editDisplayName', '1'),
  1664. ('number_format', '1234.00'),
  1665. ('attachmentEncryptFilenames', '1'),
  1666. ('autoLinkUrls', '1');
  1667. INSERT IGNORE INTO {$db_prefix}settings
  1668. (variable, value)
  1669. VALUES
  1670. ('avatar_allow_server_stored', '1'),
  1671. ('avatar_check_size', '0'),
  1672. ('avatar_action_too_large', 'option_user_resize'),
  1673. ('avatar_resize_upload', '1'),
  1674. ('avatar_download_png', '1'),
  1675. ('failed_login_threshold', '3'),
  1676. ('edit_wait_time', '90'),
  1677. ('autoFixDatabase', '1'),
  1678. ('autoOptDatabase', '7'),
  1679. ('autoOptMaxOnline', '0'),
  1680. ('autoOptLastOpt', '0'),
  1681. ('enableParticipation', '1'),
  1682. ('recycle_enable', '0'),
  1683. ('recycle_board', '0'),
  1684. ('banLastUpdated', '0'),
  1685. ('enableAllMessages', '0'),
  1686. ('fixLongWords', '0'),
  1687. ('knownThemes', '1,2'),
  1688. ('who_enabled', '1'),
  1689. ('lastActive', '15'),
  1690. ('allow_hideOnline', '1'),
  1691. ('guest_hideContacts', '0');
  1692. ---#
  1693. ---# Adding new settings (part 2)...
  1694. ---{
  1695. upgrade_query("
  1696. INSERT IGNORE INTO {$db_prefix}settings
  1697. (variable, value)
  1698. VALUES
  1699. ('registration_method', '" . (!empty($modSettings['registration_disabled']) ? 3 : (!empty($modSettings['approve_registration']) ? 2 : (!empty($GLOBALS['emailpassword']) || !empty($modSettings['send_validation']) ? 1 : 0))) . "'),
  1700. ('send_validation_onChange', '" . @$GLOBALS['emailnewpass'] . "'),
  1701. ('send_welcomeEmail', '" . @$GLOBALS['emailwelcome'] . "'),
  1702. ('allow_hideEmail', '" . @$GLOBALS['allow_hide_email'] . "'),
  1703. ('allow_guestAccess', '" . @$GLOBALS['guestaccess'] . "'),
  1704. ('time_format', '" . (!empty($GLOBALS['timeformatstring']) ? $GLOBALS['timeformatstring'] : '%B %d, %Y, %I:%M:%S %p') . "'),
  1705. ('enableBBC', '" . (!isset($GLOBALS['enable_ubbc']) ? 1 : $GLOBALS['enable_ubbc']) . "'),
  1706. ('max_messageLength', '" . (empty($GLOBALS['MaxMessLen']) ? 10000 : $GLOBALS['MaxMessLen']) . "'),
  1707. ('max_signatureLength', '" . @$GLOBALS['MaxSigLen'] . "'),
  1708. ('spamWaitTime', '" . @$GLOBALS['timeout'] . "'),
  1709. ('avatar_directory', '" . (isset($GLOBALS['facesdir']) ? fixRelativePath($GLOBALS['facesdir']) : fixRelativePath('./avatars')) . "'),
  1710. ('avatar_url', '" . @$GLOBALS['facesurl'] . "'),
  1711. ('avatar_max_height_external', '" . @$GLOBALS['userpic_height'] . "'),
  1712. ('avatar_max_width_external', '" . @$GLOBALS['userpic_width'] . "'),
  1713. ('avatar_max_height_upload', '" . @$GLOBALS['userpic_height'] . "'),
  1714. ('avatar_max_width_upload', '" . @$GLOBALS['userpic_width'] . "'),
  1715. ('defaultMaxMessages', '" . (empty($GLOBALS['maxmessagedisplay']) ? 15 : $GLOBALS['maxmessagedisplay']) . "'),
  1716. ('defaultMaxTopics', '" . (empty($GLOBALS['maxdisplay']) ? 20 : $GLOBALS['maxdisplay']) . "'),
  1717. ('defaultMaxMembers', '" . (empty($GLOBALS['MembersPerPage']) ? 20 : $GLOBALS['MembersPerPage']) . "'),
  1718. ('time_offset', '" . @$GLOBALS['timeoffset'] . "'),
  1719. ('cookieTime', '" . (empty($GLOBALS['Cookie_Length']) ? 60 : $GLOBALS['Cookie_Length']) . "'),
  1720. ('requireAgreement', '" . @$GLOBALS['RegAgree'] . "')");
  1721. ---}
  1722. INSERT IGNORE INTO {$db_prefix}settings
  1723. (variable, value)
  1724. VALUES
  1725. ('smileys_dir', '{$sboarddir}/Smileys'),
  1726. ('smileys_url', '{$boardurl}/Smileys'),
  1727. ('smiley_sets_known', 'default,classic'),
  1728. ('smiley_sets_names', 'Default\nClassic'),
  1729. ('smiley_sets_default', 'default'),
  1730. ('censorIgnoreCase', '1'),
  1731. ('cal_days_for_index', '7'),
  1732. ('unapprovedMembers', '0'),
  1733. ('default_personalText', ''),
  1734. ('attachmentPostLimit', '192'),
  1735. ('attachmentNumPerPostLimit', '4'),
  1736. ('package_make_backups', '1'),
  1737. ('databaseSession_loose', '1'),
  1738. ('databaseSession_lifetime', '2880'),
  1739. ('smtp_port', '25'),
  1740. ('search_cache_size', '50'),
  1741. ('search_results_per_page', '30'),
  1742. ('search_weight_frequency', '30'),
  1743. ('search_weight_age', '25'),
  1744. ('search_weight_length', '20'),
  1745. ('search_weight_subject', '15'),
  1746. ('search_weight_first_message', '10');
  1747. DELETE FROM {$db_prefix}settings
  1748. WHERE variable = 'agreement'
  1749. LIMIT 1;
  1750. ---#
  1751. ---# Converting settings to options...
  1752. ---{
  1753. convertSettingsToOptions();
  1754. ---}
  1755. ---#
  1756. ---# Updating statistics...
  1757. REPLACE INTO {$db_prefix}settings
  1758. (variable, value)
  1759. SELECT 'latestMember', ID_MEMBER
  1760. FROM {$db_prefix}members
  1761. ORDER BY ID_MEMBER DESC
  1762. LIMIT 1;
  1763. REPLACE INTO {$db_prefix}settings
  1764. (variable, value)
  1765. SELECT 'latestRealName', IFNULL(realName, memberName)
  1766. FROM {$db_prefix}members
  1767. ORDER BY ID_MEMBER DESC
  1768. LIMIT 1;
  1769. REPLACE INTO {$db_prefix}settings
  1770. (variable, value)
  1771. SELECT 'maxMsgID', ID_MSG
  1772. FROM {$db_prefix}messages
  1773. ORDER BY ID_MSG DESC
  1774. LIMIT 1;
  1775. REPLACE INTO {$db_prefix}settings
  1776. (variable, value)
  1777. SELECT 'totalMembers', COUNT(*)
  1778. FROM {$db_prefix}members;
  1779. REPLACE INTO {$db_prefix}settings
  1780. (variable, value)
  1781. SELECT 'unapprovedMembers', COUNT(*)
  1782. FROM {$db_prefix}members
  1783. WHERE is_activated = 0
  1784. AND validation_code = '';
  1785. REPLACE INTO {$db_prefix}settings
  1786. (variable, value)
  1787. SELECT 'totalMessages', COUNT(*)
  1788. FROM {$db_prefix}messages;
  1789. REPLACE INTO {$db_prefix}settings
  1790. (variable, value)
  1791. SELECT 'totalTopics', COUNT(*)
  1792. FROM {$db_prefix}topics;
  1793. REPLACE INTO {$db_prefix}settings
  1794. (variable, value)
  1795. VALUES ('cal_today_updated', '00000000');
  1796. ---#