123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030 |
- /* ATTENTION: You don't need to run or use this file! The upgrade.php script does everything for you! */
- /******************************************************************************/
- --- Changing column names.
- /******************************************************************************/
- ---# Renaming table columns.
- ---{
- // The array holding all the changes.
- $nameChanges = array(
- 'admin_info_files' => array(
- 'ID_FILE' => 'ID_FILE id_file tinyint(4) unsigned NOT NULL auto_increment',
- ),
- 'approval_queue' => array(
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_ATTACH' => 'ID_ATTACH id_attach int(10) unsigned NOT NULL default \'0\'',
- 'ID_EVENT' => 'ID_EVENT id_event smallint(5) unsigned NOT NULL default \'0\'',
- 'attachmentType' => 'attachmentType attachment_type tinyint(3) unsigned NOT NULL default \'0\'',
- ),
- 'attachments' => array(
- 'ID_ATTACH' => 'ID_ATTACH id_attach int(10) unsigned NOT NULL auto_increment',
- 'ID_THUMB' => 'ID_THUMB id_thumb int(10) unsigned NOT NULL default \'0\'',
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'attachmentType' => 'attachmentType attachment_type tinyint(3) unsigned NOT NULL default \'0\'',
- ),
- 'ban_groups' => array(
- 'ID_BAN_GROUP' => 'ID_BAN_GROUP id_ban_group mediumint(8) unsigned NOT NULL auto_increment',
- ),
- 'ban_items' => array(
- 'ID_BAN' => 'ID_BAN id_ban mediumint(8) unsigned NOT NULL auto_increment',
- 'ID_BAN_GROUP' => 'ID_BAN_GROUP id_ban_group smallint(5) unsigned NOT NULL default \'0\'',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- ),
- 'board_permissions' => array(
- 'ID_GROUP' => 'ID_GROUP id_group smallint(5) NOT NULL default \'0\'',
- 'ID_PROFILE' => 'ID_PROFILE id_profile smallint(5) NOT NULL default \'0\'',
- 'addDeny' => 'addDeny add_deny tinyint(4) NOT NULL default \'1\'',
- ),
- 'boards' => array(
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL auto_increment',
- 'ID_CAT' => 'ID_CAT id_cat tinyint(4) unsigned NOT NULL default \'0\'',
- 'childLevel' => 'childLevel child_level tinyint(4) unsigned NOT NULL default \'0\'',
- 'ID_PARENT' => 'ID_PARENT id_parent smallint(5) unsigned NOT NULL default \'0\'',
- 'boardOrder' => 'boardOrder board_order smallint(5) NOT NULL default \'0\'',
- 'ID_LAST_MSG' => 'ID_LAST_MSG id_last_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_MSG_UPDATED' => 'ID_MSG_UPDATED id_msg_updated int(10) unsigned NOT NULL default \'0\'',
- 'memberGroups' => 'memberGroups member_groups varchar(255) NOT NULL default \'-1,0\'',
- 'ID_PROFILE' => 'ID_PROFILE id_profile smallint(5) unsigned NOT NULL default \'1\'',
- 'numTopics' => 'numTopics num_topics mediumint(8) unsigned NOT NULL default \'0\'',
- 'numPosts' => 'numPosts num_posts mediumint(8) unsigned NOT NULL default \'0\'',
- 'countPosts' => 'countPosts count_posts tinyint(4) NOT NULL default \'0\'',
- 'ID_THEME' => 'ID_THEME id_theme tinyint(4) unsigned NOT NULL default \'0\'',
- 'unapprovedPosts' => 'unapprovedPosts unapproved_posts smallint(5) NOT NULL default \'0\'',
- 'unapprovedTopics' => 'unapprovedTopics unapproved_topics smallint(5) NOT NULL default \'0\'',
- ),
- 'calendar' => array(
- 'ID_EVENT' => 'ID_EVENT id_event smallint(5) unsigned NOT NULL auto_increment',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL default \'0\'',
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL default \'0\'',
- 'startDate' => 'startDate start_date date NOT NULL default \'0001-01-01\'',
- 'endDate' => 'endDate end_date date NOT NULL default \'0001-01-01\'',
- ),
- 'calendar_holidays' => array(
- 'ID_HOLIDAY' => 'ID_HOLIDAY id_holiday smallint(5) unsigned NOT NULL auto_increment',
- 'eventDate' => 'eventDate event_date date NOT NULL default \'0001-01-01\'',
- ),
- 'categories' => array(
- 'ID_CAT' => 'ID_CAT id_cat tinyint(4) unsigned NOT NULL auto_increment',
- 'catOrder' => 'catOrder cat_order tinyint(4) NOT NULL default \'0\'',
- 'canCollapse' => 'canCollapse can_collapse tinyint(1) NOT NULL default \'1\'',
- ),
- 'collapsed_categories' => array(
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_CAT' => 'ID_CAT id_cat tinyint(4) unsigned NOT NULL',
- ),
- 'custom_fields' => array(
- 'ID_FIELD' => 'ID_FIELD id_field smallint(5) NOT NULL auto_increment',
- 'colName' => 'colName col_name varchar(12) NOT NULL default \'\'',
- 'fieldName' => 'fieldName field_name varchar(40) NOT NULL default \'\'',
- 'fieldDesc' => 'fieldDesc field_desc varchar(255) NOT NULL default \'\'',
- 'fieldType' => 'fieldType field_type varchar(8) NOT NULL default \'text\'',
- 'fieldLength' => 'fieldLength field_length smallint(5) NOT NULL default \'255\'',
- 'fieldOptions' => 'fieldOptions field_options text NOT NULL',
- 'showReg' => 'showReg show_reg tinyint(3) NOT NULL default \'0\'',
- 'showDisplay' => 'showDisplay show_display tinyint(3) NOT NULL default \'0\'',
- 'showProfile' => 'showProfile show_profile varchar(20) NOT NULL default \'forumprofile\'',
- 'defaultValue' => 'defaultValue default_value varchar(8) NOT NULL default \'0\'',
- ),
- 'group_moderators' => array(
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_GROUP' => 'ID_GROUP id_group smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'log_actions' => array(
- 'ID_ACTION' => 'ID_ACTION id_action int(10) unsigned NOT NULL auto_increment',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'logTime' => 'logTime log_time int(10) unsigned NOT NULL default \'0\'',
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'log_activity' => array(
- 'mostOn' => 'mostOn most_on smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'log_banned' => array(
- 'ID_BAN_LOG' => 'ID_BAN_LOG id_ban_log mediumint(8) unsigned NOT NULL auto_increment',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'logTime' => 'logTime log_time int(10) unsigned NOT NULL default \'0\'',
- ),
- 'log_boards' => array(
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'log_digest' => array(
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL default \'0\'',
- ),
- 'log_errors' => array(
- 'ID_ERROR' => 'ID_ERROR id_error mediumint(8) unsigned NOT NULL auto_increment',
- 'logTime' => 'logTime log_time int(10) unsigned NOT NULL default \'0\'',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'errorType' => 'errorType error_type char(15) NOT NULL default \'general\'',
- ),
- 'log_floodcontrol' => array(
- 'logTime' => 'logTime log_time int(10) unsigned NOT NULL default \'0\'',
- ),
- 'log_group_requests' => array(
- 'ID_REQUEST' => 'ID_REQUEST id_request mediumint(8) unsigned NOT NULL auto_increment',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_GROUP' => 'ID_GROUP id_group smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'log_karma' => array(
- 'ID_TARGET' => 'ID_TARGET id_target mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_EXECUTOR' => 'ID_EXECUTOR id_executor mediumint(8) unsigned NOT NULL default \'0\'',
- 'logTime' => 'logTime log_time int(10) unsigned NOT NULL default \'0\'',
- ),
- 'log_mark_read' => array(
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'log_notify' => array(
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'log_packages' => array(
- 'ID_INSTALL' => 'ID_INSTALL id_install int(10) NOT NULL auto_increment',
- 'ID_MEMBER_INSTALLED' => 'ID_MEMBER_INSTALLED id_member_installed mediumint(8) NOT NULL default \'0\'',
- 'ID_MEMBER_REMOVED' => 'ID_MEMBER_REMOVED id_member_removed mediumint(8) NOT NULL default \'0\'',
- ),
- 'log_polls' => array(
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_CHOICE' => 'ID_CHOICE id_choice tinyint(3) unsigned NOT NULL default \'0\'',
- 'ID_POLL' => 'ID_POLL id_poll mediumint(8) unsigned NOT NULL default \'0\'',
- ),
- 'log_reported' => array(
- 'ID_REPORT' => 'ID_REPORT id_report mediumint(8) unsigned NOT NULL auto_increment',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'log_reported_comments' => array(
- 'ID_COMMENT' => 'ID_COMMENT id_comment mediumint(8) unsigned NOT NULL auto_increment',
- 'ID_REPORT' => 'ID_REPORT id_report mediumint(8) NOT NULL default \'0\'',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- ),
- 'log_scheduled_tasks' => array(
- 'ID_LOG' => 'ID_LOG id_log mediumint(8) NOT NULL auto_increment',
- 'ID_TASK' => 'ID_TASK id_task smallint(5) NOT NULL default \'0\'',
- 'timeRun' => 'timeRun time_run int(10) NOT NULL default \'0\'',
- 'timeTaken' => 'timeTaken time_taken float NOT NULL default \'0\'',
- ),
- 'log_search_messages' => array(
- 'ID_SEARCH' => 'ID_SEARCH id_search tinyint(3) unsigned NOT NULL default \'0\'',
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL default \'0\'',
- ),
- 'log_search_results' => array(
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_SEARCH' => 'ID_SEARCH id_search tinyint(3) unsigned NOT NULL default \'0\'',
- ),
- 'log_search_subjects' => array(
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL default \'0\'',
- ),
- 'log_search_topics' => array(
- 'ID_SEARCH' => 'ID_SEARCH id_search tinyint(3) unsigned NOT NULL default \'0\'',
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL default \'0\'',
- ),
- 'log_subscribed' => array(
- 'ID_SUBLOG' => 'ID_SUBLOG id_sublog int(10) unsigned NOT NULL auto_increment',
- 'ID_SUBSCRIBE' => 'ID_SUBSCRIBE id_subscribe mediumint(8) unsigned NOT NULL default \'0\'',
- 'OLD_ID_GROUP' => 'OLD_ID_GROUP old_id_group smallint(5) NOT NULL default \'0\'',
- 'startTime' => 'startTime start_time int(10) NOT NULL default \'0\'',
- 'endTime' => 'endTime end_time int(10) NOT NULL default \'0\'',
- ),
- 'log_topics' => array(
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL default \'0\'',
- ),
- 'mail_queue' => array(
- 'ID_MAIL' => 'ID_MAIL id_mail int(10) unsigned NOT NULL auto_increment',
- ),
- 'members' => array(
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL auto_increment',
- 'memberName' => 'memberName member_name varchar(80) NOT NULL default \'\'',
- 'dateRegistered' => 'dateRegistered date_registered int(10) unsigned NOT NULL default \'0\'',
- 'ID_GROUP' => 'ID_GROUP id_group smallint(5) unsigned NOT NULL default \'0\'',
- 'lastLogin' => 'lastLogin last_login int(10) unsigned NOT NULL default \'0\'',
- 'realName' => 'realName real_name varchar(255) NOT NULL default \'\'',
- 'instantMessages' => 'instantMessages instant_messages smallint(5) NOT NULL default \'0\'',
- 'unreadMessages' => 'unreadMessages unread_messages smallint(5) NOT NULL default \'0\'',
- 'messageLabels' => 'messageLabels message_labels text NOT NULL',
- 'emailAddress' => 'emailAddress email_address varchar(255) NOT NULL default \'\'',
- 'personalText' => 'personalText personal_text varchar(255) NOT NULL default \'\'',
- 'websiteTitle' => 'websiteTitle website_title varchar(255) NOT NULL default \'\'',
- 'websiteUrl' => 'websiteUrl website_url varchar(255) NOT NULL default \'\'',
- 'ICQ' => 'ICQ icq varchar(255) NOT NULL default \'\'',
- 'AIM' => 'AIM aim varchar(255) NOT NULL default \'\'',
- 'YIM' => 'YIM yim varchar(32) NOT NULL default \'\'',
- 'MSN' => 'MSN msn varchar(255) NOT NULL default \'\'',
- 'hideEmail' => 'hideEmail hide_email tinyint(4) NOT NULL default \'0\'',
- 'showOnline' => 'showOnline show_online tinyint(4) NOT NULL default \'1\'',
- 'timeFormat' => 'timeFormat time_format varchar(80) NOT NULL default \'\'',
- 'timeOffset' => 'timeOffset time_offset float NOT NULL default \'0\'',
- 'karmaBad' => 'karmaBad karma_bad smallint(5) unsigned NOT NULL default \'0\'',
- 'karmaGood' => 'karmaGood karma_good smallint(5) unsigned NOT NULL default \'0\'',
- 'notifyAnnouncements' => 'notifyAnnouncements notify_announcements tinyint(4) NOT NULL default \'1\'',
- 'notifyRegularity' => 'notifyRegularity notify_regularity tinyint(4) NOT NULL default \'1\'',
- 'notifySendBody' => 'notifySendBody notify_send_body tinyint(4) NOT NULL default \'0\'',
- 'notifyTypes' => 'notifyTypes notify_types tinyint(4) NOT NULL default \'2\'',
- 'memberIP' => 'memberIP member_ip varchar(255) NOT NULL default \'\'',
- 'secretQuestion' => 'secretQuestion secret_question varchar(255) NOT NULL default \'\'',
- 'secretAnswer' => 'secretAnswer secret_answer varchar(64) NOT NULL default \'\'',
- 'ID_THEME' => 'ID_THEME id_theme tinyint(4) unsigned NOT NULL default \'0\'',
- 'ID_MSG_LAST_VISIT' => 'ID_MSG_LAST_VISIT id_msg_last_visit int(10) unsigned NOT NULL default \'0\'',
- 'additionalGroups' => 'additionalGroups additional_groups varchar(255) NOT NULL default \'\'',
- 'smileySet' => 'smileySet smiley_set varchar(48) NOT NULL default \'\'',
- 'ID_POST_GROUP' => 'ID_POST_GROUP id_post_group smallint(5) unsigned NOT NULL default \'0\'',
- 'totalTimeLoggedIn' => 'totalTimeLoggedIn total_time_logged_in int(10) unsigned NOT NULL default \'0\'',
- 'passwordSalt' => 'passwordSalt password_salt varchar(255) NOT NULL default \'\'',
- 'ignoreBoards' => 'ignoreBoards ignore_boards text NOT NULL',
- 'memberIP2' => 'memberIP2 member_ip2 varchar(255) NOT NULL default \'\'',
- ),
- 'messages' => array(
- 'ID_MSG' => 'ID_MSG id_msg int(10) unsigned NOT NULL auto_increment',
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL default \'0\'',
- 'posterTime' => 'posterTime poster_time int(10) unsigned NOT NULL default \'0\'',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_MSG_MODIFIED' => 'ID_MSG_MODIFIED id_msg_modified int(10) unsigned NOT NULL default \'0\'',
- 'posterName' => 'posterName poster_name varchar(255) NOT NULL default \'\'',
- 'posterEmail' => 'posterEmail poster_email varchar(255) NOT NULL default \'\'',
- 'posterIP' => 'posterIP poster_ip varchar(255) NOT NULL default \'\'',
- 'smileysEnabled' => 'smileysEnabled smileys_enabled tinyint(4) NOT NULL default \'1\'',
- 'modifiedTime' => 'modifiedTime modified_time int(10) unsigned NOT NULL default \'0\'',
- 'modifiedName' => 'modifiedName modified_name varchar(255) NOT NULL default \'\'',
- ),
- 'membergroups' => array(
- 'ID_GROUP' => 'ID_GROUP id_group smallint(5) unsigned NOT NULL auto_increment',
- 'ID_PARENT' => 'ID_PARENT id_parent smallint(5) NOT NULL default \'-2\'',
- 'groupName' => 'groupName group_name varchar(80) NOT NULL default \'\'',
- 'onlineColor' => 'onlineColor online_color varchar(20) NOT NULL default \'\'',
- 'minPosts' => 'minPosts min_posts mediumint(9) NOT NULL default \'-1\'',
- 'maxMessages' => 'maxMessages max_messages smallint(5) unsigned NOT NULL default \'0\'',
- 'groupType' => 'groupType group_type tinyint(3) NOT NULL default \'0\'',
- ),
- 'message_icons' => array(
- 'ID_ICON' => 'ID_ICON id_icon smallint(5) unsigned NOT NULL auto_increment',
- 'iconOrder' => 'iconOrder icon_order smallint(5) unsigned NOT NULL default \'0\'',
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'moderators' => array(
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'package_servers' => array(
- 'ID_SERVER' => 'ID_SERVER id_server smallint(5) unsigned NOT NULL auto_increment',
- ),
- 'personal_messages' => array(
- 'ID_PM' => 'ID_PM id_pm int(10) unsigned NOT NULL auto_increment',
- 'ID_MEMBER_FROM' => 'ID_MEMBER_FROM id_member_from mediumint(8) unsigned NOT NULL default \'0\'',
- 'deletedBySender' => 'deletedBySender deleted_by_sender tinyint(3) unsigned NOT NULL default \'0\'',
- 'fromName' => 'fromName from_name varchar(255) NOT NULL default \'\'',
- ),
- 'permission_profiles' => array(
- 'ID_PROFILE' => 'ID_PROFILE id_profile smallint(5) NOT NULL auto_increment',
- ),
- 'permissions' => array(
- 'ID_GROUP' => 'ID_GROUP id_group smallint(5) NOT NULL default \'0\'',
- 'addDeny' => 'addDeny add_deny tinyint(4) NOT NULL default \'1\'',
- ),
- 'pm_recipients' => array(
- 'ID_PM' => 'ID_PM id_pm int(10) unsigned NOT NULL default \'0\'',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- ),
- 'polls' => array(
- 'ID_POLL' => 'ID_POLL id_poll mediumint(8) unsigned NOT NULL auto_increment',
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) unsigned NOT NULL default \'0\'',
- 'votingLocked' => 'votingLocked voting_locked tinyint(1) NOT NULL default \'0\'',
- 'maxVotes' => 'maxVotes max_votes tinyint(3) unsigned NOT NULL default \'1\'',
- 'expireTime' => 'expireTime expire_time int(10) unsigned NOT NULL default \'0\'',
- 'hideResults' => 'hideResults hide_results tinyint(3) unsigned NOT NULL default \'0\'',
- 'changeVote' => 'changeVote change_vote tinyint(3) unsigned NOT NULL default \'0\'',
- 'posterName' => 'posterName poster_name varchar(255) NOT NULL default \'\'',
- ),
- 'poll_choices' => array(
- 'ID_CHOICE' => 'ID_CHOICE id_choice tinyint(3) unsigned NOT NULL default \'0\'',
- 'ID_POLL' => 'ID_POLL id_poll mediumint(8) unsigned NOT NULL default \'0\'',
- ),
- 'scheduled_tasks' => array(
- 'ID_TASK' => 'ID_TASK id_task smallint(5) NOT NULL auto_increment',
- 'nextTime' => 'nextTime next_time int(10) NOT NULL default \'0\'',
- 'timeRegularity' => 'timeRegularity time_regularity smallint(5) NOT NULL default \'0\'',
- 'timeOffset' => 'timeOffset time_offset int(10) NOT NULL default \'0\'',
- 'timeUnit' => 'timeUnit time_unit varchar(1) NOT NULL default \'h\'',
- ),
- 'smileys' => array(
- 'ID_SMILEY' => 'ID_SMILEY id_smiley smallint(5) unsigned NOT NULL auto_increment',
- 'smileyRow' => 'smileyRow smiley_row tinyint(4) unsigned NOT NULL default \'0\'',
- 'smileyOrder' => 'smileyOrder smiley_order smallint(5) unsigned NOT NULL default \'0\'',
- ),
- 'subscriptions' => array(
- 'ID_SUBSCRIBE' => 'ID_SUBSCRIBE id_subscribe mediumint(8) unsigned NOT NULL auto_increment',
- 'ID_GROUP' => 'ID_GROUP id_group smallint(5) NOT NULL default \'0\'',
- 'addGroups' => 'addGroups add_groups varchar(40) NOT NULL default \'\'',
- 'allowPartial' => 'allowPartial allow_partial tinyint(3) NOT NULL default \'0\'',
- ),
- 'themes' => array(
- 'ID_MEMBER' => 'ID_MEMBER id_member mediumint(8) NOT NULL default \'0\'',
- 'ID_THEME' => 'ID_THEME id_theme tinyint(4) unsigned NOT NULL default \'1\'',
- ),
- 'topics' => array(
- 'ID_TOPIC' => 'ID_TOPIC id_topic mediumint(8) unsigned NOT NULL auto_increment',
- 'isSticky' => 'isSticky is_sticky tinyint(4) NOT NULL default \'0\'',
- 'ID_BOARD' => 'ID_BOARD id_board smallint(5) unsigned NOT NULL default \'0\'',
- 'ID_FIRST_MSG' => 'ID_FIRST_MSG id_first_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_LAST_MSG' => 'ID_LAST_MSG id_last_msg int(10) unsigned NOT NULL default \'0\'',
- 'ID_MEMBER_STARTED' => 'ID_MEMBER_STARTED id_member_started mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_MEMBER_UPDATED' => 'ID_MEMBER_UPDATED id_member_updated mediumint(8) unsigned NOT NULL default \'0\'',
- 'ID_POLL' => 'ID_POLL id_poll mediumint(8) unsigned NOT NULL default \'0\'',
- 'numReplies' => 'numReplies num_replies int(10) unsigned NOT NULL default \'0\'',
- 'numViews' => 'numViews num_views int(10) unsigned NOT NULL default \'0\'',
- 'unapprovedPosts' => 'unapprovedPosts unapproved_posts smallint(5) NOT NULL default \'0\'',
- ),
- );
- $_GET['ren_col'] = isset($_GET['ren_col']) ? (int) $_GET['ren_col'] : 0;
- $step_progress['name'] = 'Renaming columns';
- $step_progress['current'] = $_GET['ren_col'];
- $step_progress['total'] = count($nameChanges);
- $count = 0;
- // Now do every table...
- foreach ($nameChanges as $table_name => $table)
- {
- // Already done this?
- $count++;
- if ($_GET['ren_col'] > $count)
- continue;
- $_GET['ren_col'] = $count;
- // Check the table exists!
- $request = upgrade_query("
- SHOW TABLES
- LIKE '{$db_prefix}$table_name'");
- if (smf_mysql_num_rows($request) == 0)
- {
- smf_mysql_free_result($request);
- continue;
- }
- smf_mysql_free_result($request);
- // Check each column!
- $actualChanges = array();
- foreach ($table as $colname => $coldef)
- {
- $change = array(
- 'table' => $table_name,
- 'name' => $colname,
- 'type' => 'column',
- 'method' => 'change_remove',
- 'text' => 'CHANGE ' . $coldef,
- );
- // Check if this change may need a special edit.
- checkChange($change);
- if (protected_alter($change, $substep, true) == false)
- $actualChanges[] = ' CHANGE COLUMN ' . $coldef;
- }
- // Do the query - if it needs doing.
- if (!empty($actualChanges))
- {
- $change = array(
- 'table' => $table_name,
- 'name' => 'na',
- 'type' => 'table',
- 'method' => 'full_change',
- 'text' => implode(', ', $actualChanges),
- );
- // Here we go - hold on!
- protected_alter($change, $substep);
- }
- // Update where we are!
- $step_progress['current'] = $_GET['ren_col'];
- }
- // All done!
- unset($_GET['ren_col']);
- ---}
- ---#
- ---# Converting "log_online".
- DROP TABLE IF EXISTS {$db_prefix}log_online;
- CREATE TABLE {$db_prefix}log_online (
- session varchar(32) NOT NULL default '',
- log_time int(10) NOT NULL default '0',
- id_member mediumint(8) unsigned NOT NULL default '0',
- id_spider smallint(5) unsigned NOT NULL default '0',
- ip int(10) unsigned NOT NULL default '0',
- url text NOT NULL,
- PRIMARY KEY (session),
- KEY log_time (log_time),
- KEY id_member (id_member)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- /******************************************************************************/
- --- Adding new board specific features.
- /******************************************************************************/
- ---# Implementing board redirects.
- ALTER TABLE {$db_prefix}boards
- ADD COLUMN redirect varchar(255) NOT NULL default '';
- ---#
- /******************************************************************************/
- --- Adding search engine tracking.
- /******************************************************************************/
- ---# Creating spider table.
- CREATE TABLE IF NOT EXISTS {$db_prefix}spiders (
- id_spider smallint(5) unsigned NOT NULL auto_increment,
- spider_name varchar(255) NOT NULL default '',
- user_agent varchar(255) NOT NULL default '',
- ip_info varchar(255) NOT NULL default '',
- PRIMARY KEY id_spider(id_spider)
- ) ENGINE=MyISAM{$db_collation};
- INSERT IGNORE INTO {$db_prefix}spiders
- (id_spider, spider_name, user_agent, ip_info)
- VALUES
- (1, 'Google', 'googlebot', ''),
- (2, 'Yahoo!', 'slurp', ''),
- (3, 'MSN', 'msnbot', ''),
- (4, 'Google (Mobile)', 'Googlebot-Mobile', ''),
- (5, 'Google (Image)', 'Googlebot-Image', ''),
- (6, 'Google (AdSense)', 'Mediapartners-Google', ''),
- (7, 'Google (Adwords)', 'AdsBot-Google', ''),
- (8, 'Yahoo! (Mobile)', 'YahooSeeker/M1A1-R2D2', ''),
- (9, 'Yahoo! (Image)', 'Yahoo-MMCrawler', ''),
- (10, 'MSN (Mobile)', 'MSNBOT_Mobile', ''),
- (11, 'MSN (Media)', 'msnbot-media', ''),
- (12, 'Cuil', 'twiceler', ''),
- (13, 'Ask', 'Teoma', ''),
- (14, 'Baidu', 'Baiduspider', ''),
- (15, 'Gigablast', 'Gigabot', ''),
- (16, 'InternetArchive', 'ia_archiver-web.archive.org', ''),
- (17, 'Alexa', 'ia_archiver', ''),
- (18, 'Omgili', 'omgilibot', ''),
- (19, 'EntireWeb', 'Speedy Spider', ''),
- (20, 'Yandex', 'yandex', '');
- ---#
- ---# Removing a spider.
- ---{
- upgrade_query("
- DELETE FROM {$db_prefix}spiders
- WHERE user_agent = 'yahoo'
- AND spider_name = 'Yahoo! (Publisher)'
- ");
- ---}
- ---#
- ---# Creating spider hit tracking table.
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_spider_hits (
- id_hit int(10) unsigned NOT NULL auto_increment,
- id_spider smallint(5) unsigned NOT NULL default '0',
- log_time int(10) unsigned NOT NULL default '0',
- url varchar(255) NOT NULL default '',
- processed tinyint(3) unsigned NOT NULL default '0',
- PRIMARY KEY (id_hit),
- KEY id_spider(id_spider),
- KEY log_time(log_time),
- KEY processed (processed)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Making some changes to spider hit table...
- ALTER TABLE {$db_prefix}log_spider_hits
- ADD COLUMN id_hit int(10) unsigned NOT NULL auto_increment,
- ADD PRIMARY KEY (id_hit);
- ---#
- ---# Creating spider statistic table.
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_spider_stats (
- id_spider smallint(5) unsigned NOT NULL default '0',
- page_hits smallint(5) unsigned NOT NULL default '0',
- last_seen int(10) unsigned NOT NULL default '0',
- stat_date date NOT NULL default '0001-01-01',
- PRIMARY KEY (stat_date, id_spider)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- /******************************************************************************/
- --- Adding new forum settings.
- /******************************************************************************/
- ---# Resetting settings_updated.
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('settings_updated', '0'),
- ('last_mod_report_action', '0'),
- ('search_floodcontrol_time', '5'),
- ('next_task_time', UNIX_TIMESTAMP());
- ---#
- ---# Changing stats settings.
- ---{
- $request = upgrade_query("
- SELECT value
- FROM {$db_prefix}themes
- WHERE variable = 'show_sp1_info'");
- if (smf_mysql_num_rows($request) != 0)
- {
- upgrade_query("
- DELETE FROM {$db_prefix}themes
- WHERE variable = 'show_stats_index'");
- upgrade_query("
- UPDATE {$db_prefix}themes
- SET variable = 'show_stats_index'
- WHERE variable = 'show_sp1_info'");
- }
- upgrade_query("
- DELETE FROM {$db_prefix}themes
- WHERE variable = 'show_sp1_info'");
- ---}
- ---#
- ---# Enable cache if upgrading from 1.1 and lower.
- ---{
- if (isset($modSettings['smfVersion']) && $modSettings['smfVersion'] <= '2.0 Beta 1')
- {
- $request = upgrade_query("
- SELECT value
- FROM {$db_prefix}settings
- WHERE variable = 'cache_enable'");
- list ($cache_enable) = $smcFunc['db_fetch_row']($request);
- // No cache before 1.1.
- if ($smcFunc['db_num_rows']($request) == 0)
- upgrade_query("
- INSERT INTO {$db_prefix}settings
- (variable, value)
- VALUES ('cache_enable', '1')");
- elseif (empty($cache_enable))
- upgrade_query("
- UPDATE {$db_prefix}settings
- SET value = '1'
- WHERE variable = 'cache_enable'");
- }
- ---}
- ---#
- ---# Changing visual verification setting.
- ---{
- $request = upgrade_query("
- SELECT value
- FROM {$db_prefix}settings
- WHERE variable = 'disable_visual_verification'");
- if (smf_mysql_num_rows($request) != 0)
- {
- list ($oldValue) = smf_mysql_fetch_row($request);
- if ($oldValue != 0)
- {
- // We have changed the medium setting from SMF 1.1.2.
- if ($oldValue == 4)
- $oldValue = 5;
- upgrade_query("
- UPDATE {$db_prefix}settings
- SET variable = 'visual_verification_type', value = $oldValue
- WHERE variable = 'disable_visual_verification'");
- }
- }
- upgrade_query("
- DELETE FROM {$db_prefix}settings
- WHERE variable = 'disable_visual_verification'");
- ---}
- ---#
- ---# Changing visual verification setting, again.
- ---{
- $request = upgrade_query("
- SELECT value
- FROM {$db_prefix}settings
- WHERE variable = 'reg_verification'");
- if (smf_mysql_num_rows($request) == 0)
- {
- // Upgrade visual verification again!
- if (!empty($modSettings['visual_verification_type']))
- {
- upgrade_query("
- UPDATE {$db_prefix}settings
- SET value = value - 1
- WHERE variable = 'visual_verification_type'");
- $modSettings['visual_verification_type']--;
- }
- // Never set?
- elseif (!isset($modSettings['visual_verification_type']))
- {
- upgrade_query("
- INSERT INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('visual_verification_type', '3')");
- $modSettings['visual_verification_type'] = 3;
- }
- upgrade_query("
- INSERT INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('reg_verification', '" . (!empty($modSettings['visual_verification_type']) ? 1 : 0) . "')");
- }
- ---}
- ---#
- ---# Changing default personal text setting.
- UPDATE {$db_prefix}settings
- SET variable = 'default_personal_text'
- WHERE variable = 'default_personalText';
- DELETE FROM {$db_prefix}settings
- WHERE variable = 'default_personalText';
- ---#
- ---# Removing allow hide email setting.
- DELETE FROM {$db_prefix}settings
- WHERE variable = 'allow_hideEmail'
- OR variable = 'allow_hide_email';
- ---#
- ---# Ensuring stats index setting present...
- INSERT IGNORE INTO {$db_prefix}themes
- (id_theme, variable, value)
- VALUES
- (1, 'show_stats_index', '0');
- ---#
- ---# Ensuring forum width setting present...
- INSERT IGNORE INTO {$db_prefix}themes
- (id_theme, variable, value)
- VALUES
- (1, 'forum_width', '90%');
- ---#
- ---# Replacing old calendar settings...
- ---{
- // Only try it if one of the "new" settings doesn't yet exist.
- if (!isset($modSettings['cal_showholidays']) || !isset($modSettings['cal_showbdays']) || !isset($modSettings['cal_showevents']))
- {
- // Default to just the calendar setting.
- $modSettings['cal_showholidays'] = empty($modSettings['cal_showholidaysoncalendar']) ? 0 : 1;
- $modSettings['cal_showbdays'] = empty($modSettings['cal_showbdaysoncalendar']) ? 0 : 1;
- $modSettings['cal_showevents'] = empty($modSettings['cal_showeventsoncalendar']) ? 0 : 1;
- // Then take into account board index.
- if (!empty($modSettings['cal_showholidaysonindex']))
- $modSettings['cal_showholidays'] = $modSettings['cal_showholidays'] === 1 ? 2 : 3;
- if (!empty($modSettings['cal_showbdaysonindex']))
- $modSettings['cal_showbdays'] = $modSettings['cal_showbdays'] === 1 ? 2 : 3;
- if (!empty($modSettings['cal_showeventsonindex']))
- $modSettings['cal_showevents'] = $modSettings['cal_showevents'] === 1 ? 2 : 3;
- // Actually save the settings.
- upgrade_query("
- INSERT IGNORE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('cal_showholidays', $modSettings[cal_showholidays]),
- ('cal_showbdays', $modSettings[cal_showbdays]),
- ('cal_showevents', $modSettings[cal_showevents])");
- }
- ---}
- ---#
- ---# Deleting old calendar settings...
- DELETE FROM {$db_prefix}settings
- WHERE VARIABLE IN ('cal_showholidaysonindex', 'cal_showbdaysonindex', 'cal_showeventsonindex',
- 'cal_showholidaysoncalendar', 'cal_showbdaysoncalendar', 'cal_showeventsoncalendar',
- 'cal_holidaycolor', 'cal_bdaycolor', 'cal_eventcolor');
- ---#
- ---# Adjusting calendar maximum year...
- ---{
- if (!isset($modSettings['cal_maxyear']) || $modSettings['cal_maxyear'] == '2010')
- {
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('cal_maxyear', '2020')");
- }
- ---}
- ---#
- ---# Adding advanced signature settings...
- ---{
- if (empty($modSettings['signature_settings']))
- {
- if (isset($modSettings['max_signatureLength']))
- $modSettings['signature_settings'] = '1,' . $modSettings['max_signatureLength'] . ',0,0,0,0,0,0:';
- else
- $modSettings['signature_settings'] = '1,300,0,0,0,0,0,0:';
- upgrade_query("
- INSERT IGNORE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('signature_settings', '$modSettings[signature_settings]')");
- upgrade_query("
- DELETE FROM {$db_prefix}settings
- WHERE variable = 'max_signatureLength'");
- }
- ---}
- ---#
- ---# Updating spam protection settings.
- ---{
- if (empty($modSettings['pm_spam_settings']))
- {
- if (isset($modSettings['max_pm_recipients']))
- $modSettings['pm_spam_settings'] = $modSettings['max_pm_recipients'] . ',5,20';
- else
- $modSettings['pm_spam_settings'] = '10,5,20';
- }
- elseif (substr_count($modSettings['pm_spam_settings'], ',') == 1)
- {
- $modSettings['pm_spam_settings'] .= ',20';
- }
- upgrade_query("
- INSERT IGNORE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('pm_spam_settings', '$modSettings[pm_spam_settings]')");
- upgrade_query("
- DELETE FROM {$db_prefix}settings
- WHERE variable = 'max_pm_recipients'");
- ---}
- ---#
- ---# Adjusting timezone settings...
- ---{
- if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
- {
- $server_offset = mktime(0, 0, 0, 1, 1, 1970);
- $timezone_id = 'Etc/GMT' . ($server_offset > 0 ? '+' : '') . ($server_offset / 3600);
- if (date_default_timezone_set($timezone_id))
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('default_timezone', '$timezone_id')");
- }
- ---}
- ---#
- ---# Checking theme layers are correct for default themes.
- ---{
- $request = upgrade_query("
- SELECT id_theme, value, variable
- FROM {$db_prefix}themes
- WHERE variable = 'theme_layers'
- OR variable = 'theme_dir'");
- $themeLayerChanges = array();
- while ($row = smf_mysql_fetch_assoc($request))
- {
- $themeLayerChanges[$row['id_theme']][$row['variable']] = $row['value'];
- }
- smf_mysql_free_result($request);
- foreach ($themeLayerChanges as $id_theme => $data)
- {
- // Has to be a SMF provided theme and have custom layers defined.
- if (!isset($data['theme_layers']) || !isset($data['theme_dir']) || !in_array(substr($data['theme_dir'], -7), array('default', 'babylon', 'classic')))
- continue;
- $layers = explode(',', $data['theme_layers']);
- foreach ($layers as $k => $v)
- if ($v == 'main')
- {
- $layers[$k] = 'html,body';
- upgrade_query("
- UPDATE {$db_prefix}themes
- SET value = '" . implode(',', $layers) . "'
- WHERE id_theme = $id_theme
- AND variable = 'theme_layers'");
- break;
- }
- }
- ---}
- ---#
- ---# Adding index to log_notify table...
- ALTER TABLE {$db_prefix}log_notify
- ADD INDEX id_topic (id_topic, id_member);
- ---#
- /******************************************************************************/
- --- Adding custom profile fields.
- /******************************************************************************/
- ---# Creating "custom_fields" table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}custom_fields (
- id_field smallint(5) NOT NULL auto_increment,
- col_name varchar(12) NOT NULL default '',
- field_name varchar(40) NOT NULL default '',
- field_desc varchar(255) NOT NULL default '',
- field_type varchar(8) NOT NULL default 'text',
- field_length smallint(5) NOT NULL default '255',
- field_options text NOT NULL,
- mask varchar(255) NOT NULL default '',
- show_reg tinyint(3) NOT NULL default '0',
- show_display tinyint(3) NOT NULL default '0',
- show_profile varchar(20) NOT NULL default 'forumprofile',
- private tinyint(3) NOT NULL default '0',
- active tinyint(3) NOT NULL default '1',
- bbc tinyint(3) NOT NULL default '0',
- default_value varchar(255) NOT NULL default '',
- PRIMARY KEY (id_field),
- UNIQUE col_name (col_name)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding search ability to custom fields.
- ALTER TABLE {$db_prefix}custom_fields
- ADD COLUMN can_search tinyint(3) NOT NULL default '0' AFTER bbc;
- ---#
- ---# Fixing default value field length.
- ALTER TABLE {$db_prefix}custom_fields
- CHANGE COLUMN default_value default_value varchar(255) NOT NULL default '';
- ---#
- ---# Enhancing privacy settings for custom fields.
- ---{
- if (isset($modSettings['smfVersion']) && $modSettings['smfVersion'] <= '2.0 Beta 1')
- {
- upgrade_query("
- UPDATE {$db_prefix}custom_fields
- SET private = 2
- WHERE private = 1");
- }
- if (isset($modSettings['smfVersion']) && $modSettings['smfVersion'] < '2.0 Beta 4')
- {
- upgrade_query("
- UPDATE {$db_prefix}custom_fields
- SET private = 3
- WHERE private = 2");
- }
- ---}
- ---#
- ---# Checking display fields setup correctly..
- ---{
- if (isset($modSettings['smfVersion']) && $modSettings['smfVersion'] <= '2.0 Beta 1' && isset($modSettings['displayFields']) && @unserialize($modSettings['displayFields']) == false)
- {
- $request = upgrade_query("
- SELECT col_name, field_name, bbc
- FROM {$db_prefix}custom_fields
- WHERE show_display = 1
- AND active = 1
- AND private != 2");
- $fields = array();
- while ($row = smf_mysql_fetch_assoc($request))
- {
- $fields[] = array(
- 'c' => strtr($row['col_name'], array('|' => '', ';' => '')),
- 'f' => strtr($row['field_name'], array('|' => '', ';' => '')),
- 'b' => ($row['bbc'] ? '1' : '0')
- );
- }
- smf_mysql_free_result($request);
- upgrade_query("
- UPDATE {$db_prefix}settings
- SET value = '" . smf_mysql_real_escape_string(serialize($fields)) . "'
- WHERE variable = 'displayFields'");
- }
- ---}
- ---#
- ---# Adding new custom fields columns.
- ALTER TABLE {$db_prefix}custom_fields
- ADD enclose text NOT NULL;
- ALTER TABLE {$db_prefix}custom_fields
- ADD placement tinyint(3) NOT NULL default '0';
- ---#
- /******************************************************************************/
- --- Adding email digest functionality.
- /******************************************************************************/
- ---# Creating "log_digest" table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_digest (
- id_topic mediumint(8) unsigned NOT NULL default '0',
- id_msg int(10) unsigned NOT NULL default '0',
- note_type varchar(10) NOT NULL default 'post',
- daily tinyint(3) unsigned NOT NULL default '0',
- exclude mediumint(8) unsigned NOT NULL default '0'
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding digest option to "members" table...
- ALTER TABLE {$db_prefix}members
- CHANGE COLUMN notifyOnce notify_regularity tinyint(4) unsigned NOT NULL default '1';
- ---#
- /******************************************************************************/
- --- Making changes to the package manager.
- /******************************************************************************/
- ---# Creating "log_packages" table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_packages (
- id_install int(10) NOT NULL auto_increment,
- filename varchar(255) NOT NULL default '',
- package_id varchar(255) NOT NULL default '',
- name varchar(255) NOT NULL default '',
- version varchar(255) NOT NULL default '',
- id_member_installed mediumint(8) NOT NULL default '0',
- member_installed varchar(255) NOT NULL default '',
- time_installed int(10) NOT NULL default '0',
- id_member_removed mediumint(8) NOT NULL default '0',
- member_removed varchar(255) NOT NULL default '',
- time_removed int(10) NOT NULL default '0',
- install_state tinyint(3) NOT NULL default '1',
- failed_steps text NOT NULL,
- themes_installed varchar(255) NOT NULL default '',
- db_changes text NOT NULL,
- PRIMARY KEY (id_install),
- KEY filename (filename(15))
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding extra "log_packages" columns...
- ALTER TABLE {$db_prefix}log_packages
- ADD db_changes text NOT NULL AFTER themes_installed;
- ---#
- ---# Changing URL to SMF package server...
- UPDATE {$db_prefix}package_servers
- SET url = 'http://custom.simplemachines.org/packages/mods'
- WHERE url = 'http://mods.simplemachines.org';
- ---#
- /******************************************************************************/
- --- Creating mail queue functionality.
- /******************************************************************************/
- ---# Creating "mail_queue" table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}mail_queue (
- id_mail int(10) unsigned NOT NULL auto_increment,
- time_sent int(10) NOT NULL default '0',
- recipient varchar(255) NOT NULL default '',
- body text NOT NULL,
- subject varchar(255) NOT NULL default '',
- headers text NOT NULL,
- send_html tinyint(3) NOT NULL default '0',
- priority tinyint(3) NOT NULL default '1',
- PRIMARY KEY (id_mail),
- KEY time_sent (time_sent),
- KEY mail_priority (priority, id_mail)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding new mail queue settings...
- ---{
- if (!isset($modSettings['mail_next_send']))
- {
- upgrade_query("
- INSERT INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('mail_next_send', '0'),
- ('mail_recent', '0000000000|0')");
- }
- ---}
- ---#
- ---# Change mail queue indexes...
- ALTER TABLE {$db_prefix}mail_queue
- DROP INDEX priority;
- ALTER TABLE {$db_prefix}mail_queue
- ADD INDEX mail_priority (priority, id_mail);
- ---#
- ---# Adding type to mail queue...
- ALTER TABLE {$db_prefix}mail_queue
- ADD private tinyint(1) NOT NULL default '0';
- ---#
- /******************************************************************************/
- --- Creating moderation center tables.
- /******************************************************************************/
- ---# Creating "log_reported" table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_reported (
- id_report mediumint(8) unsigned NOT NULL auto_increment,
- id_msg int(10) unsigned NOT NULL default '0',
- id_topic mediumint(8) unsigned NOT NULL default '0',
- id_board smallint(5) unsigned NOT NULL default '0',
- id_member mediumint(8) unsigned NOT NULL default '0',
- membername varchar(255) NOT NULL default '',
- subject varchar(255) NOT NULL default '',
- body text NOT NULL,
- time_started int(10) NOT NULL default '0',
- time_updated int(10) NOT NULL default '0',
- num_reports mediumint(6) NOT NULL default '0',
- closed tinyint(3) NOT NULL default '0',
- ignore_all tinyint(3) NOT NULL default '0',
- PRIMARY KEY (id_report),
- KEY id_member (id_member),
- KEY id_topic (id_topic),
- KEY closed (closed),
- KEY time_started (time_started),
- KEY id_msg (id_msg)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Creating "log_reported_comments" table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_reported_comments (
- id_comment mediumint(8) unsigned NOT NULL auto_increment,
- id_report mediumint(8) NOT NULL default '0',
- id_member mediumint(8) NOT NULL,
- membername varchar(255) NOT NULL default '',
- comment varchar(255) NOT NULL default '',
- time_sent int(10) NOT NULL,
- PRIMARY KEY (id_comment),
- KEY id_report (id_report),
- KEY id_member (id_member),
- KEY time_sent (time_sent)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding moderator center permissions...
- ---{
- // Don't do this twice!
- if (@$modSettings['smfVersion'] < '2.0')
- {
- // Try find people who probably should see the moderation center.
- $request = upgrade_query("
- SELECT id_group, add_deny, permission
- FROM {$db_prefix}permissions
- WHERE permission = 'calendar_edit_any'");
- $inserts = array();
- while ($row = smf_mysql_fetch_assoc($request))
- {
- $inserts[] = "($row[id_group], 'access_mod_center', $row[add_deny])";
- }
- smf_mysql_free_result($request);
- if (!empty($inserts))
- upgrade_query("
- INSERT IGNORE INTO {$db_prefix}permissions
- (id_group, permission, add_deny)
- VALUES
- " . implode(',', $inserts));
- }
- ---}
- ---#
- ---# Adding moderation center preferences...
- ALTER TABLE {$db_prefix}members
- ADD mod_prefs varchar(20) NOT NULL default '';
- ---#
- /******************************************************************************/
- --- Adding user warnings.
- /******************************************************************************/
- ---# Creating member notices table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_member_notices (
- id_notice mediumint(8) unsigned NOT NULL auto_increment,
- subject varchar(255) NOT NULL default '',
- body text NOT NULL,
- PRIMARY KEY (id_notice)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Creating comments table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_comments (
- id_comment mediumint(8) unsigned NOT NULL auto_increment,
- id_member mediumint(8) unsigned NOT NULL default '0',
- member_name varchar(80) NOT NULL default '',
- comment_type varchar(8) NOT NULL default 'warning',
- id_recipient mediumint(8) unsigned NOT NULL default '0',
- recipient_name varchar(255) NOT NULL default '',
- log_time int(10) NOT NULL default '0',
- id_notice mediumint(8) unsigned NOT NULL default '0',
- counter tinyint(3) NOT NULL default '0',
- body text NOT NULL,
- PRIMARY KEY (id_comment),
- KEY id_recipient (id_recipient),
- KEY log_time (log_time),
- KEY comment_type (comment_type(8))
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding user warning column...
- ALTER TABLE {$db_prefix}members
- ADD warning tinyint(4) NOT NULL default '0';
- ALTER TABLE {$db_prefix}members
- ADD INDEX warning (warning);
- ---#
- ---# Ensuring warning settings are present...
- ---{
- // Only do this if not already done.
- if (empty($modSettings['warning_settings']))
- {
- upgrade_query("
- INSERT IGNORE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('warning_settings', '1,20,0'),
- ('warning_watch', '10'),
- ('warning_moderate', '35'),
- ('warning_mute', '60')");
- }
- ---}
- ---#
- /******************************************************************************/
- --- Enhancing membergroups.
- /******************************************************************************/
- ---# Creating "log_group_requests" table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_group_requests (
- id_request mediumint(8) unsigned NOT NULL auto_increment,
- id_member mediumint(8) unsigned NOT NULL default '0',
- id_group smallint(5) unsigned NOT NULL default '0',
- time_applied int(10) unsigned NOT NULL default '0',
- reason text NOT NULL,
- PRIMARY KEY (id_request),
- UNIQUE id_member (id_member, id_group)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding new membergroup table columns...
- ALTER TABLE {$db_prefix}membergroups
- ADD description text NOT NULL AFTER group_name;
- ALTER TABLE {$db_prefix}membergroups
- ADD group_type tinyint(3) NOT NULL default '0';
- ALTER TABLE {$db_prefix}membergroups
- ADD hidden tinyint(3) NOT NULL default '0';
- ---#
- ---# Creating "group_moderators" table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}group_moderators (
- id_group smallint(5) unsigned NOT NULL default '0',
- id_member mediumint(8) unsigned NOT NULL default '0',
- PRIMARY KEY (id_group, id_member)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- /******************************************************************************/
- --- Updating attachment data...
- /******************************************************************************/
- ---# Altering attachment table.
- ALTER TABLE {$db_prefix}attachments
- ADD COLUMN fileext varchar(8) NOT NULL default '',
- ADD COLUMN mime_type varchar(20) NOT NULL default '';
- ALTER TABLE {$db_prefix}attachments
- ADD COLUMN id_folder tinyint(3) NOT NULL default '1';
- ---#
- ---# Adding file hash.
- ALTER TABLE {$db_prefix}attachments
- ADD COLUMN file_hash varchar(40) NOT NULL default '';
- ---#
- ---# Populate the attachment extension.
- UPDATE {$db_prefix}attachments
- SET fileext = LOWER(SUBSTRING(filename, 1 - (INSTR(REVERSE(filename), '.'))))
- WHERE fileext = ''
- AND INSTR(filename, '.')
- AND attachment_type != 3;
- ---#
- ---# Updating thumbnail attachments JPG.
- UPDATE {$db_prefix}attachments
- SET fileext = 'jpg'
- WHERE attachment_type = 3
- AND fileext = ''
- AND RIGHT(filename, 9) = 'JPG_thumb';
- ---#
- ---# Updating thumbnail attachments PNG.
- UPDATE {$db_prefix}attachments
- SET fileext = 'png'
- WHERE attachment_type = 3
- AND fileext = ''
- AND RIGHT(filename, 9) = 'PNG_thumb';
- ---#
- ---# Calculating attachment mime types.
- ---{
- // Don't ever bother doing this twice.
- if (@$modSettings['smfVersion'] < '2.0' || @$modSettings['smfVersion'] === '2.0 a')
- {
- $request = upgrade_query("
- SELECT MAX(id_attach)
- FROM {$db_prefix}attachments");
- list ($step_progress['total']) = $smcFunc['db_fetch_row']($request);
- $smcFunc['db_free_result']($request);
- $_GET['a'] = isset($_GET['a']) ? (int) $_GET['a'] : 0;
- $step_progress['name'] = 'Calculating MIME Types';
- $step_progress['current'] = $_GET['a'];
- if (!function_exists('getAttachmentFilename'))
- {
- function getAttachmentFilename($filename, $attachment_id)
- {
- global $modSettings;
- $clean_name = strtr($filename, 'ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy');
- $clean_name = strtr($clean_name, array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u'));
- $clean_name = preg_replace(array('/\s/', '/[^\w_\.\-]/'), array('_', ''), $clean_name);
- $enc_name = $attachment_id . '_' . strtr($clean_name, '.', '_') . md5($clean_name);
- $clean_name = preg_replace('~\.[\.]+~', '.', $clean_name);
- if ($attachment_id == false)
- return $clean_name;
- if (file_exists($modSettings['attachmentUploadDir'] . '/' . $enc_name))
- $filename = $modSettings['attachmentUploadDir'] . '/' . $enc_name;
- else
- $filename = $modSettings['attachmentUploadDir'] . '/' . $clean_name;
- return $filename;
- }
- }
- $ext_updates = array();
- // What headers are valid results for getimagesize?
- $validTypes = array(
- 1 => 'gif',
- 2 => 'jpeg',
- 3 => 'png',
- 5 => 'psd',
- 6 => 'bmp',
- 7 => 'tiff',
- 8 => 'tiff',
- 9 => 'jpeg',
- 14 => 'iff',
- );
- $is_done = false;
- while (!$is_done)
- {
- nextSubStep($substep);
- $request = upgrade_query("
- SELECT id_attach, filename, fileext
- FROM {$db_prefix}attachments
- WHERE fileext != ''
- AND mime_type = ''
- LIMIT $_GET[a], 100");
- // Finished?
- if ($smcFunc['db_num_rows']($request) == 0)
- $is_done = true;
- while ($row = $smcFunc['db_fetch_assoc']($request))
- {
- $filename = getAttachmentFilename($row['filename'], $row['id_attach']);
- if (!file_exists($filename))
- continue;
- // Is it an image?
- $size = @getimagesize($filename);
- // Nothing valid?
- if (empty($size) || empty($size[0]))
- continue;
- // Got the mime?
- elseif (!empty($size['mime']))
- $mime = $size['mime'];
- // Otherwise is it valid?
- elseif (!isset($validTypes[$size[2]]))
- continue;
- else
- $mime = 'image/' . $validTypes[$size[2]];
- // Let's try keep updates to a minimum.
- if (!isset($ext_updates[$row['fileext'] . $size['mime']]))
- $ext_updates[$row['fileext'] . $size['mime']] = array(
- 'fileext' => $row['fileext'],
- 'mime' => $mime,
- 'files' => array(),
- );
- $ext_updates[$row['fileext'] . $size['mime']]['files'][] = $row['id_attach'];
- }
- $smcFunc['db_free_result']($request);
- // Do the updates?
- foreach ($ext_updates as $key => $update)
- {
- upgrade_query("
- UPDATE {$db_prefix}attachments
- SET mime_type = '$update[mime]'
- WHERE id_attach IN (" . implode(',', $update['files']) . ")");
- // Remove it.
- unset($ext_updates[$key]);
- }
- $_GET['a'] += 100;
- $step_progress['current'] = $_GET['a'];
- }
- unset($_GET['a']);
- }
- ---}
- ---#
- /******************************************************************************/
- --- Adding Post Moderation.
- /******************************************************************************/
- ---# Creating "approval_queue" table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}approval_queue (
- id_msg int(10) unsigned NOT NULL default '0',
- id_attach int(10) unsigned NOT NULL default '0',
- id_event smallint(5) unsigned NOT NULL default '0'
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding approved column to attachments table...
- ALTER TABLE {$db_prefix}attachments
- ADD approved tinyint(3) NOT NULL default '1';
- ---#
- ---# Adding approved column to messages table...
- ALTER TABLE {$db_prefix}messages
- ADD approved tinyint(3) NOT NULL default '1';
- ALTER TABLE {$db_prefix}messages
- ADD INDEX approved (approved);
- ---#
- ---# Adding unapproved count column to topics table...
- ALTER TABLE {$db_prefix}topics
- ADD unapproved_posts smallint(5) NOT NULL default '0';
- ---#
- ---# Adding approved column to topics table...
- ALTER TABLE {$db_prefix}topics
- ADD approved tinyint(3) NOT NULL default '1',
- ADD INDEX approved (approved);
- ---#
- ---# Adding approved columns to boards table...
- ALTER TABLE {$db_prefix}boards
- ADD unapproved_posts smallint(5) NOT NULL default '0',
- ADD unapproved_topics smallint(5) NOT NULL default '0';
- ---#
- ---# Adding post moderation permissions...
- ---{
- // We *cannot* do this twice!
- if (@$modSettings['smfVersion'] < '2.0')
- {
- // Anyone who can currently edit posts we assume can approve them...
- $request = upgrade_query("
- SELECT id_group, id_board, add_deny, permission
- FROM {$db_prefix}board_permissions
- WHERE permission = 'modify_any'");
- $inserts = array();
- while ($row = smf_mysql_fetch_assoc($request))
- {
- $inserts[] = "($row[id_group], $row[id_board], 'approve_posts', $row[add_deny])";
- }
- smf_mysql_free_result($request);
- if (!empty($inserts))
- upgrade_query("
- INSERT IGNORE INTO {$db_prefix}board_permissions
- (id_group, id_board, permission, add_deny)
- VALUES
- " . implode(',', $inserts));
- }
- ---}
- ---#
- /******************************************************************************/
- --- Upgrading the error log.
- /******************************************************************************/
- ---# Adding columns to log_errors table...
- ALTER TABLE {$db_prefix}log_errors
- ADD error_type char(15) NOT NULL default 'general';
- ALTER TABLE {$db_prefix}log_errors
- ADD file varchar(255) NOT NULL default '',
- ADD line mediumint(8) unsigned NOT NULL default '0';
- ---#
- ---# Updating error log table...
- ---{
- $request = upgrade_query("
- SELECT COUNT(*)
- FROM {$db_prefix}log_errors");
- list($totalActions) = smf_mysql_fetch_row($request);
- smf_mysql_free_result($request);
- $_GET['m'] = !empty($_GET['m']) ? (int) $_GET['m'] : '0';
- $step_progress['total'] = $totalActions;
- $step_progress['current'] = $_GET['m'];
- while ($_GET['m'] < $totalActions)
- {
- nextSubStep($substep);
- $request = upgrade_query("
- SELECT id_error, message, file, line
- FROM {$db_prefix}log_errors
- LIMIT $_GET[m], 500");
- while($row = smf_mysql_fetch_assoc($request))
- {
- preg_match('~<br />(%1\$s: )?([\w\. \\\\/\-_:]+)<br />(%2\$s: )?([\d]+)~', $row['message'], $matches);
- if (!empty($matches[2]) && !empty($matches[4]) && empty($row['file']) && empty($row['line']))
- {
- $row['file'] = addslashes(str_replace('\\', '/', $matches[2]));
- $row['line'] = (int) $matches[4];
- $row['message'] = addslashes(preg_replace('~<br />(%1\$s: )?([\w\. \\\\/\-_:]+)<br />(%2\$s: )?([\d]+)~', '', $row['message']));
- }
- else
- continue;
- upgrade_query("
- UPDATE {$db_prefix}log_errors
- SET file = SUBSTRING('$row[file]', 1, 255),
- line = $row[line],
- message = SUBSTRING('$row[message]', 1, 65535)
- WHERE id_error = $row[id_error]
- LIMIT 1");
- }
- $_GET['m'] += 500;
- $step_progress['current'] = $_GET['m'];
- }
- unset($_GET['m']);
- ---}
- ---#
- /******************************************************************************/
- --- Adding Scheduled Tasks Data.
- /******************************************************************************/
- ---# Creating Scheduled Task Table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}scheduled_tasks (
- id_task smallint(5) NOT NULL auto_increment,
- next_time int(10) NOT NULL default '0',
- time_offset int(10) NOT NULL default '0',
- time_regularity smallint(5) NOT NULL default '0',
- time_unit varchar(1) NOT NULL default 'h',
- disabled tinyint(3) NOT NULL default '0',
- task varchar(24) NOT NULL default '',
- PRIMARY KEY (id_task),
- KEY next_time (next_time),
- KEY disabled (disabled),
- UNIQUE task (task)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Populating Scheduled Task Table...
- INSERT IGNORE INTO {$db_prefix}scheduled_tasks
- (next_time, time_offset, time_regularity, time_unit, disabled, task)
- VALUES
- (0, 0, 2, 'h', 0, 'approval_notification'),
- (0, 0, 7, 'd', 0, 'auto_optimize'),
- (0, 60, 1, 'd', 0, 'daily_maintenance'),
- (0, 0, 1, 'd', 0, 'daily_digest'),
- (0, 0, 1, 'w', 0, 'weekly_digest'),
- (0, 0, 1, 'd', 1, 'birthdayemails'),
- (0, 120, 1, 'd', 0, 'paid_subscriptions');
- ---#
- ---# Adding the simple machines scheduled task.
- ---{
- // Randomise the time.
- $randomTime = 82800 + rand(0, 86399);
- upgrade_query("
- INSERT IGNORE INTO {$db_prefix}scheduled_tasks
- (next_time, time_offset, time_regularity, time_unit, disabled, task)
- VALUES
- (0, {$randomTime}, 1, 'd', 0, 'fetchSMfiles')");
- ---}
- ---#
- ---# Deleting old scheduled task items...
- DELETE FROM {$db_prefix}scheduled_tasks
- WHERE task = 'clean_cache';
- ---#
- ---# Moving auto optimise settings to scheduled task...
- ---{
- if (!isset($modSettings['next_task_time']) && isset($modSettings['autoOptLastOpt']))
- {
- // Try move over the regularity...
- if (isset($modSettings['autoOptDatabase']))
- {
- $disabled = empty($modSettings['autoOptDatabase']) ? 1 : 0;
- $regularity = $disabled ? 7 : $modSettings['autoOptDatabase'];
- $next_time = $modSettings['autoOptLastOpt'] + 3600 * 24 * $modSettings['autoOptDatabase'];
- // Update the task accordingly.
- upgrade_query("
- UPDATE {$db_prefix}scheduled_tasks
- SET disabled = $disabled, time_regularity = $regularity, next_time = $next_time
- WHERE task = 'auto_optimize'");
- }
- // Delete the old settings!
- upgrade_query("
- DELETE FROM {$db_prefix}settings
- WHERE VARIABLE IN ('autoOptLastOpt', 'autoOptDatabase')");
- }
- ---}
- ---#
- ---# Creating Scheduled Task Log Table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_scheduled_tasks (
- id_log mediumint(8) NOT NULL auto_increment,
- id_task smallint(5) NOT NULL default '0',
- time_run int(10) NOT NULL default '0',
- time_taken float NOT NULL default '0',
- PRIMARY KEY (id_log)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding new scheduled task setting...
- ---{
- if (!isset($modSettings['next_task_time']))
- {
- upgrade_query("
- INSERT INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('next_task_time', '0')");
- }
- ---}
- ---#
- ---# Setting the birthday email template if not set...
- ---{
- if (!isset($modSettings['birthday_email']))
- {
- upgrade_query("
- INSERT INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('birthday_email', 'happy_birthday')");
- }
- ---}
- ---#
- /******************************************************************************/
- --- Adding permission profiles for boards.
- /******************************************************************************/
- ---# Creating "permission_profiles" table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}permission_profiles (
- id_profile smallint(5) NOT NULL auto_increment,
- profile_name varchar(255) NOT NULL default '',
- PRIMARY KEY (id_profile)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding profile columns to boards table...
- ALTER TABLE {$db_prefix}boards
- ADD id_profile smallint(5) unsigned NOT NULL default '1' AFTER member_groups;
- ---#
- ---# Adding profile columns to board permission table...
- ALTER TABLE {$db_prefix}board_permissions
- ADD id_profile smallint(5) unsigned NOT NULL default '1' AFTER id_group;
- ALTER TABLE {$db_prefix}board_permissions
- DROP PRIMARY KEY;
- ALTER TABLE {$db_prefix}board_permissions
- ADD PRIMARY KEY (id_group, id_profile, permission);
- ---#
- ---# Cleaning up some 2.0 Beta 1 permission profile bits...
- ---{
- $request = upgrade_query("
- SELECT id_profile
- FROM {$db_prefix}permission_profiles
- WHERE profile_name = ''");
- $profiles = array();
- while ($row = smf_mysql_fetch_assoc($request))
- $profiles[] = $row['id_profile'];
- smf_mysql_free_result($request);
- if (!empty($profiles))
- {
- $request = upgrade_query("
- SELECT id_profile, name
- FROM {$db_prefix}boards
- WHERE id_profile IN (" . implode(',', $profiles) . ")");
- $done_ids = array();
- while ($row = smf_mysql_fetch_assoc($request))
- {
- if (isset($done_ids[$row['id_profile']]))
- continue;
- $done_ids[$row['id_profile']] = true;
- $row['name'] = smf_mysql_real_escape_string($row['name']);
- upgrade_query("
- UPDATE {$db_prefix}permission_profiles
- SET profile_name = '$row[name]'
- WHERE id_profile = $row[id_profile]");
- }
- smf_mysql_free_result($request);
- }
- ---}
- ---#
- ---# Migrating old board profiles to profile system
- ---{
- // Doing this twice would be awful!
- $request = upgrade_query("
- SELECT COUNT(*)
- FROM {$db_prefix}permission_profiles");
- list ($profileCount) = smf_mysql_fetch_row($request);
- smf_mysql_free_result($request);
- if ($profileCount == 0)
- {
- // Everything starts off invalid.
- upgrade_query("
- UPDATE {$db_prefix}board_permissions
- SET id_profile = 0");
- // Insert a boat load of default profile permissions.
- upgrade_query("
- INSERT INTO {$db_prefix}permission_profiles
- (id_profile, profile_name)
- VALUES
- (1, 'default'),
- (2, 'no_polls'),
- (3, 'reply_only'),
- (4, 'read_only')");
- // Update the default permissions, this is easy!
- upgrade_query("
- UPDATE {$db_prefix}board_permissions
- SET id_profile = 1
- WHERE id_board = 0");
- // Load all the other permissions
- $request = upgrade_query("
- SELECT id_board, id_group, permission, add_deny
- FROM {$db_prefix}board_permissions
- WHERE id_profile = 0");
- $all_perms = array();
- while ($row = smf_mysql_fetch_assoc($request))
- $all_perms[$row['id_board']][$row['id_group']][$row['permission']] = $row['add_deny'];
- smf_mysql_free_result($request);
- // Now we have the profile profiles for this installation. We now need to go through each board and work out what the permission profile should be!
- $request = upgrade_query("
- SELECT id_board, name, permission_mode
- FROM {$db_prefix}boards");
- $board_updates = array();
- while ($row = smf_mysql_fetch_assoc($request))
- {
- $row['name'] = addslashes($row['name']);
- // Is it a truely local permission board? If so this is a new profile!
- if ($row['permission_mode'] == 1)
- {
- // I know we could cache this, but I think we need to be practical - this is slow but guaranteed to work.
- upgrade_query("
- INSERT INTO {$db_prefix}permission_profiles
- (profile_name)
- VALUES
- ('$row[name]')");
- $board_updates[smf_mysql_insert_id()][] = $row['id_board'];
- }
- // Otherwise, dear god, this is an old school "simple" permission...
- elseif ($row['permission_mode'] > 1 && $row['permission_mode'] < 5)
- {
- $board_updates[$row['permission_mode']][] = $row['id_board'];
- }
- // Otherwise this is easy. It becomes default.
- else
- $board_updates[1][] = $row['id_board'];
- }
- smf_mysql_free_result($request);
- // Update the board tables.
- foreach ($board_updates as $profile => $boards)
- {
- if (empty($boards))
- continue;
- $boards = implode(',', $boards);
- upgrade_query("
- UPDATE {$db_prefix}boards
- SET id_profile = $profile
- WHERE id_board IN ($boards)");
- // If it's a custom profile then update this too.
- if ($profile > 4)
- upgrade_query("
- UPDATE {$db_prefix}board_permissions
- SET id_profile = $profile
- WHERE id_board IN ($boards)
- AND id_profile = 0");
- }
- // Just in case we have any random permissions that didn't have boards.
- upgrade_query("
- DELETE FROM {$db_prefix}board_permissions
- WHERE id_profile = 0");
- }
- ---}
- ---#
- ---# Removing old board permissions column...
- ALTER TABLE {$db_prefix}board_permissions
- DROP COLUMN id_board;
- ---#
- ---# Check the predefined profiles all have the right permissions.
- ---{
- // What are all the permissions people can have.
- $mod_permissions = array(
- 'moderate_board', 'post_new', 'post_reply_own', 'post_reply_any', 'poll_post', 'poll_add_any',
- 'poll_remove_any', 'poll_view', 'poll_vote', 'poll_lock_any', 'poll_edit_any', 'report_any',
- 'lock_own', 'send_topic', 'mark_any_notify', 'mark_notify', 'delete_own', 'modify_own', 'make_sticky',
- 'lock_any', 'remove_any', 'move_any', 'merge_any', 'split_any', 'delete_any', 'modify_any', 'approve_posts',
- 'post_attachment', 'view_attachments', 'post_unapproved_replies_any', 'post_unapproved_replies_own',
- 'post_unapproved_attachments', 'post_unapproved_topics',
- );
- $no_poll_reg = array(
- 'post_new', 'post_reply_own', 'post_reply_any', 'poll_view', 'poll_vote', 'report_any',
- 'lock_own', 'send_topic', 'mark_any_notify', 'mark_notify', 'delete_own', 'modify_own',
- 'post_attachment', 'view_attachments', 'remove_own', 'post_unapproved_replies_any', 'post_unapproved_replies_own',
- 'post_unapproved_attachments', 'post_unapproved_topics',
- );
- $reply_only_reg = array(
- 'post_reply_own', 'post_reply_any', 'poll_view', 'poll_vote', 'report_any',
- 'lock_own', 'send_topic', 'mark_any_notify', 'mark_notify', 'delete_own', 'modify_own',
- 'post_attachment', 'view_attachments', 'remove_own', 'post_unapproved_replies_any', 'post_unapproved_replies_own',
- 'post_unapproved_attachments',
- );
- $read_only_reg = array(
- 'poll_view', 'poll_vote', 'report_any', 'send_topic', 'mark_any_notify', 'mark_notify', 'view_attachments',
- );
- // Clear all the current predefined profiles.
- upgrade_query("
- DELETE FROM {$db_prefix}board_permissions
- WHERE id_profile IN (2,3,4)");
- // Get all the membergroups - cheating to use the fact id_group = 1 exists to get a group of 0.
- $request = upgrade_query("
- SELECT IF(id_group = 1, 0, id_group) AS id_group
- FROM {$db_prefix}membergroups
- WHERE id_group != 0
- AND min_posts = -1");
- $inserts = array();
- while ($row = smf_mysql_fetch_assoc($request))
- {
- if ($row['id_group'] == 2 || $row['id_group'] == 3)
- {
- foreach ($mod_permissions as $permission)
- {
- $inserts[] = "($row[id_group], 2, '$permission')";
- $inserts[] = "($row[id_group], 3, '$permission')";
- $inserts[] = "($row[id_group], 4, '$permission')";
- }
- }
- else
- {
- foreach ($no_poll_reg as $permission)
- $inserts[] = "($row[id_group], 2, '$permission')";
- foreach ($reply_only_reg as $permission)
- $inserts[] = "($row[id_group], 3, '$permission')";
- foreach ($read_only_reg as $permission)
- $inserts[] = "($row[id_group], 4, '$permission')";
- }
- }
- smf_mysql_free_result($request);
- upgrade_query("
- INSERT INTO {$db_prefix}board_permissions
- (id_group, id_profile, permission)
- VALUES (-1, 2, 'poll_view'),
- (-1, 3, 'poll_view'),
- (-1, 4, 'poll_view'),
- " . implode(', ', $inserts));
- ---}
- ---#
- ---# Adding inherited permissions...
- ALTER TABLE {$db_prefix}membergroups
- ADD id_parent smallint(5) NOT NULL default '-2';
- ---#
- ---# Make sure admins and moderators don't inherit...
- UPDATE {$db_prefix}membergroups
- SET id_parent = -2
- WHERE id_group = 1
- OR id_group = 3;
- ---#
- ---# Deleting old permission settings...
- DELETE FROM {$db_prefix}settings
- WHERE VARIABLE IN ('permission_enable_by_board', 'autoOptDatabase');
- ---#
- ---# Removing old permission_mode column...
- ALTER TABLE {$db_prefix}boards
- DROP COLUMN permission_mode;
- ---#
- /******************************************************************************/
- --- Adding Some Additional Functionality.
- /******************************************************************************/
- ---# Adding column to hold the boards being ignored ...
- ALTER TABLE {$db_prefix}members
- ADD ignore_boards text NOT NULL;
- ---#
- ---# Purge flood control ...
- DELETE FROM {$db_prefix}log_floodcontrol;
- ---#
- ---# Adding advanced flood control ...
- ALTER TABLE {$db_prefix}log_floodcontrol
- ADD log_type varchar(8) NOT NULL default 'post';
- ---#
- ---# Sorting out flood control keys ...
- ALTER TABLE {$db_prefix}log_floodcontrol
- DROP PRIMARY KEY,
- ADD PRIMARY KEY (ip(16), log_type(8));
- ---#
- ---# Adding guest voting ...
- ALTER TABLE {$db_prefix}polls
- ADD guest_vote tinyint(3) NOT NULL default '0';
- DELETE FROM {$db_prefix}log_polls
- WHERE id_member < 0;
- ALTER TABLE {$db_prefix}log_polls
- DROP PRIMARY KEY;
- ALTER TABLE {$db_prefix}log_polls
- ADD INDEX id_poll (id_poll, id_member, id_choice);
- ---#
- ---# Implementing admin feature toggles.
- ---{
- if (!isset($modSettings['admin_features']))
- {
- // Work out what they used to have enabled.
- if (!empty($modSettings['karmaMode']))
- $enabled_features[] = 'k';
- $enabled_features = implode(',', $enabled_features);
- upgrade_query("
- INSERT INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('admin_features', '$enabled_features')");
- }
- ---}
- ---#
- ---# Adding advanced password brute force protection to "members" table...
- ALTER TABLE {$db_prefix}members
- ADD passwd_flood varchar(12) NOT NULL default '';
- ---#
- /******************************************************************************/
- --- Adding some columns to moderation log
- /******************************************************************************/
- ---# Add the columns and the keys to log_actions ...
- ALTER TABLE {$db_prefix}log_actions
- ADD id_board smallint(5) unsigned NOT NULL default '0',
- ADD id_topic mediumint(8) unsigned NOT NULL default '0',
- ADD id_msg int(10) unsigned NOT NULL default '0',
- ADD KEY id_board (id_board),
- ADD KEY id_msg (id_msg);
- ---#
- ---# Add the user log...
- ALTER TABLE {$db_prefix}log_actions
- ADD id_log tinyint(3) unsigned NOT NULL default '1',
- ADD KEY id_log (id_log);
- ---#
- ---# Update the information already in log_actions
- ---{
- $request = upgrade_query("
- SELECT COUNT(*)
- FROM {$db_prefix}log_actions");
- list($totalActions) = smf_mysql_fetch_row($request);
- smf_mysql_free_result($request);
- $_GET['m'] = !empty($_GET['m']) ? (int) $_GET['m'] : '0';
- $step_progress['total'] = $totalActions;
- $step_progress['current'] = $_GET['m'];
- while ($_GET['m'] < $totalActions)
- {
- nextSubStep($substep);
- $mrequest = upgrade_query("
- SELECT id_action, extra, id_board, id_topic, id_msg
- FROM {$db_prefix}log_actions
- LIMIT $_GET[m], 500");
- while ($row = smf_mysql_fetch_assoc($mrequest))
- {
- if (!empty($row['id_board']) || !empty($row['id_topic']) || !empty($row['id_msg']))
- continue;
- $row['extra'] = @unserialize($row['extra']);
- // Corrupt?
- $row['extra'] = is_array($row['extra']) ? $row['extra'] : array();
- if (!empty($row['extra']['board']))
- {
- $board_id = (int) $row['extra']['board'];
- unset($row['extra']['board']);
- }
- else
- $board_id = '0';
- if (!empty($row['extra']['board_to']) && empty($board_id))
- {
- $board_id = (int) $row['extra']['board_to'];
- unset($row['extra']['board_to']);
- }
- if (!empty($row['extra']['topic']))
- {
- $topic_id = (int) $row['extra']['topic'];
- unset($row['extra']['topic']);
- if (empty($board_id))
- {
- $trequest = upgrade_query("
- SELECT id_board
- FROM {$db_prefix}topics
- WHERE id_topic=$topic_id
- LIMIT 1");
- if (smf_mysql_num_rows($trequest))
- list($board_id) = smf_mysql_fetch_row($trequest);
- smf_mysql_free_result($trequest);
- }
- }
- else
- $topic_id = '0';
- if(!empty($row['extra']['message']))
- {
- $msg_id = (int) $row['extra']['message'];
- unset($row['extra']['message']);
- if (empty($topic_id) || empty($board_id))
- {
- $trequest = upgrade_query("
- SELECT id_board, id_topic
- FROM {$db_prefix}messages
- WHERE id_msg=$msg_id
- LIMIT 1");
- if (smf_mysql_num_rows($trequest))
- list($board_id, $topic_id) = smf_mysql_fetch_row($trequest);
- smf_mysql_free_result($trequest);
- }
- }
- else
- $msg_id = '0';
- $row['extra'] = addslashes(serialize($row['extra']));
- upgrade_query("UPDATE {$db_prefix}log_actions SET id_board=$board_id, id_topic=$topic_id, id_msg=$msg_id, extra='$row[extra]' WHERE id_action=$row[id_action]");
- }
- $_GET['m'] += 500;
- $step_progress['current'] = $_GET['m'];
- }
- unset($_GET['m']);
- ---}
- ---#
- /******************************************************************************/
- --- Create a repository for the javascript files from Simple Machines...
- /******************************************************************************/
- ---# Creating repository table ...
- CREATE TABLE IF NOT EXISTS {$db_prefix}admin_info_files (
- id_file tinyint(4) unsigned NOT NULL auto_increment,
- filename varchar(255) NOT NULL default '',
- path varchar(255) NOT NULL default '',
- parameters varchar(255) NOT NULL default '',
- data text NOT NULL,
- filetype varchar(255) NOT NULL default '',
- PRIMARY KEY (id_file),
- KEY filename (filename(30))
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Add in the files to get from Simple Machines...
- INSERT IGNORE INTO {$db_prefix}admin_info_files
- (id_file, filename, path, parameters)
- VALUES
- (1, 'current-version.js', '/smf/', 'version=%3$s'),
- (2, 'detailed-version.js', '/smf/', 'language=%1$s&version=%3$s'),
- (3, 'latest-news.js', '/smf/', 'language=%1$s&format=%2$s'),
- (4, 'latest-packages.js', '/smf/', 'language=%1$s&version=%3$s'),
- (5, 'latest-smileys.js', '/smf/', 'language=%1$s&version=%3$s'),
- (6, 'latest-themes.js', '/smf/', 'language=%1$s&version=%3$s');
- ---#
- ---# Ensure that the table has the filetype column
- ALTER TABLE {$db_prefix}admin_info_files
- ADD filetype varchar(255) NOT NULL default '';
- ---#
- ---# Set the filetype for the files
- UPDATE {$db_prefix}admin_info_files
- SET filetype='text/javascript'
- WHERE id_file IN (1,2,3,4,5,6,7);
- ---#
- ---# Ensure that the files from Simple Machines get updated
- UPDATE {$db_prefix}scheduled_tasks
- SET next_time = UNIX_TIMESTAMP()
- WHERE id_task = 7
- LIMIT 1;
- ---#
- /******************************************************************************/
- --- Adding new personal messaging functionality.
- /******************************************************************************/
- ---# Adding personal message rules table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}pm_rules (
- id_rule int(10) unsigned NOT NULL auto_increment,
- id_member int(10) unsigned NOT NULL default '0',
- rule_name varchar(60) NOT NULL,
- criteria text NOT NULL,
- actions text NOT NULL,
- delete_pm tinyint(3) unsigned NOT NULL default '0',
- is_or tinyint(3) unsigned NOT NULL default '0',
- PRIMARY KEY (id_rule),
- KEY id_member (id_member),
- KEY delete_pm (delete_pm)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding new message status columns...
- ALTER TABLE {$db_prefix}members
- ADD COLUMN new_pm tinyint(3) NOT NULL default '0';
- ALTER TABLE {$db_prefix}members
- ADD COLUMN pm_prefs mediumint(8) NOT NULL default '0';
- ALTER TABLE {$db_prefix}pm_recipients
- ADD COLUMN is_new tinyint(3) NOT NULL default '0';
- ---#
- ---# Set the new status to be correct....
- ---{
- // Don't do this twice!
- if (@$modSettings['smfVersion'] < '2.0')
- {
- // Set all unread messages as new.
- upgrade_query("
- UPDATE {$db_prefix}pm_recipients
- SET is_new = 1
- WHERE is_read = 0");
- // Also set members to have a new pm if they have any unread.
- upgrade_query("
- UPDATE {$db_prefix}members
- SET new_pm = 1
- WHERE unread_messages > 0");
- }
- ---}
- ---#
- ---# Adding personal message tracking column...
- ALTER TABLE {$db_prefix}personal_messages
- ADD id_pm_head int(10) unsigned default '0' NOT NULL AFTER id_pm,
- ADD INDEX id_pm_head (id_pm_head);
- ---#
- ---# Adding personal message tracking column...
- UPDATE {$db_prefix}personal_messages
- SET id_pm_head = id_pm
- WHERE id_pm_head = 0;
- ---#
- /******************************************************************************/
- --- Adding Open ID support.
- /******************************************************************************/
- ---# Adding Open ID Assocation table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}openid_assoc (
- server_url text NOT NULL,
- handle varchar(255) NOT NULL default '',
- secret text NOT NULL,
- issued int(10) NOT NULL default '0',
- expires int(10) NOT NULL default '0',
- assoc_type varchar(64) NOT NULL,
- PRIMARY KEY (server_url(125), handle(125)),
- KEY expires (expires)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Adding column to hold Open ID URL...
- ALTER TABLE {$db_prefix}members
- ADD openid_uri text NOT NULL;
- ---#
- /******************************************************************************/
- --- Adding paid subscriptions.
- /******************************************************************************/
- ---# Creating subscriptions table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}subscriptions(
- id_subscribe mediumint(8) unsigned NOT NULL auto_increment,
- name varchar(60) NOT NULL default '',
- description varchar(255) NOT NULL default '',
- cost text NOT NULL,
- length varchar(6) NOT NULL default '',
- id_group smallint(5) NOT NULL default '0',
- add_groups varchar(40) NOT NULL default '',
- active tinyint(3) NOT NULL default '1',
- repeatable tinyint(3) NOT NULL default '0',
- allow_partial tinyint(3) NOT NULL default '0',
- reminder tinyint(3) NOT NULL default '0',
- email_complete text NOT NULL,
- PRIMARY KEY (id_subscribe),
- KEY active (active)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Creating log_subscribed table...
- CREATE TABLE IF NOT EXISTS {$db_prefix}log_subscribed(
- id_sublog int(10) unsigned NOT NULL auto_increment,
- id_subscribe mediumint(8) unsigned NOT NULL default '0',
- id_member int(10) NOT NULL default '0',
- old_id_group smallint(5) NOT NULL default '0',
- start_time int(10) NOT NULL default '0',
- end_time int(10) NOT NULL default '0',
- status tinyint(3) NOT NULL default '0',
- payments_pending tinyint(3) NOT NULL default '0',
- pending_details text NOT NULL,
- reminder_sent tinyint(3) NOT NULL default '0',
- vendor_ref varchar(255) NOT NULL default '',
- PRIMARY KEY (id_sublog),
- UNIQUE KEY id_subscribe (id_subscribe, id_member),
- KEY end_time (end_time),
- KEY reminder_sent (reminder_sent),
- KEY payments_pending (payments_pending),
- KEY id_member (id_member)
- ) ENGINE=MyISAM{$db_collation};
- ---#
- ---# Clean up any pre-2.0 mod settings.
- UPDATE {$db_prefix}settings
- SET variable = 'paid_currency_code'
- WHERE variable = 'currency_code';
- UPDATE {$db_prefix}settings
- SET variable = 'paid_currency_symbol'
- WHERE variable = 'currency_symbol';
- DELETE FROM {$db_prefix}settings
- WHERE variable = 'currency_code'
- OR variable = 'currency_symbol';
- ---#
- ---# Clean up any pre-2.0 mod settings (part 2).
- ---{
- $request = upgrade_query("
- SHOW COLUMNS
- FROM {$db_prefix}subscriptions");
- $new_cols = array('repeatable', 'reminder', 'email_complete', 'allow_partial');
- $new_cols = array_flip($new_cols);
- while ($request && $row = smf_mysql_fetch_row($request))
- {
- $row[0] = strtolower($row[0]);
- if (isset($new_cols[$row[0]]))
- unset($new_cols[$row[0]]);
- }
- if ($request)
- smf_mysql_free_result($request);
- if (isset($new_cols['repeatable']))
- upgrade_query("
- ALTER TABLE {$db_prefix}subscriptions
- ADD COLUMN Repeatable tinyint(3) NOT NULL default '0'");
- if (isset($new_cols['reminder']))
- upgrade_query("
- ALTER TABLE {$db_prefix}subscriptions
- ADD COLUMN reminder tinyint(3) NOT NULL default '0'");
- if (isset($new_cols['email_complete']))
- upgrade_query("
- ALTER TABLE {$db_prefix}subscriptions
- ADD COLUMN email_complete text NOT NULL");
- if (isset($new_cols['allowpartial']))
- upgrade_query("
- ALTER TABLE {$db_prefix}subscriptions
- ADD COLUMN allow_partial tinyint(3) NOT NULL default '0'");
- $request = upgrade_query("
- SHOW COLUMNS
- FROM {$db_prefix}log_subscribed");
- $new_cols = array('reminder_sent', 'vendor_ref', 'payments_pending', 'pending_details');
- $new_cols = array_flip($new_cols);
- while ($request && $row = smf_mysql_fetch_row($request))
- {
- if (isset($new_cols[$row[0]]))
- unset($new_cols[$row[0]]);
- }
- if ($request)
- smf_mysql_free_result($request);
- if (isset($new_cols['reminder_sent']))
- upgrade_query("
- ALTER TABLE {$db_prefix}log_subscribed
- ADD COLUMN reminder_sent tinyint(3) NOT NULL default '0'");
- if (isset($new_cols['vendor_ref']))
- upgrade_query("
- ALTER TABLE {$db_prefix}log_subscribed
- ADD COLUMN vendor_ref varchar(255) NOT NULL default ''");
- if (isset($new_cols['payments_pending']))
- upgrade_query("
- ALTER TABLE {$db_prefix}log_subscribed
- ADD COLUMN payments_pending tinyint(3) NOT NULL default '0'");
- if (isset($new_cols['pending_details']))
- {
- upgrade_query("
- UPDATE {$db_prefix}log_subscribed
- SET status = 0
- WHERE status = 1");
- upgrade_query("
- UPDATE {$db_prefix}log_subscribed
- SET status = 1
- WHERE status = 2");
- upgrade_query("
- ALTER TABLE {$db_prefix}log_subscribed
- ADD COLUMN pending_details text NOT NULL");
- }
- ---}
- ---#
- ---# Confirming paid subscription keys are in place ...
- ALTER TABLE {$db_prefix}log_subscribed
- ADD KEY reminder_sent (reminder_sent),
- ADD KEY end_time (end_time),
- ADD KEY payments_pending (payments_pending),
- ADD KEY status (status);
- ---#
- /******************************************************************************/
- --- Adding weekly maintenance task.
- /******************************************************************************/
- ---# Adding scheduled task...
- INSERT IGNORE INTO {$db_prefix}scheduled_tasks (next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (0, 0, 1, 'w', 0, 'weekly_maintenance');
- ---#
- /******************************************************************************/
- --- Adding log pruning.
- /******************************************************************************/
- ---# Adding pruning option...
- INSERT IGNORE INTO {$db_prefix}settings (variable, value) VALUES ('pruningOptions', '30,180,180,180,30,0');
- ---#
- /******************************************************************************/
- --- Adding restore topic from recycle.
- /******************************************************************************/
- ---# Adding restore from recycle feature...
- ALTER TABLE {$db_prefix}topics
- ADD COLUMN id_previous_board smallint(5) NOT NULL default '0',
- ADD COLUMN id_previous_topic mediumint(8) NOT NULL default '0';
- ---#
- /******************************************************************************/
- --- Providing more room for apf options.
- /******************************************************************************/
- ---# Changing field_options column to a larger field type...
- ALTER TABLE {$db_prefix}custom_fields
- CHANGE field_options field_options text NOT NULL;
- ---#
- /******************************************************************************/
- --- Providing more room for ignoring boards.
- /******************************************************************************/
- ---# Changing ignore_boards column to a larger field type...
- ALTER TABLE {$db_prefix}members
- CHANGE ignore_boards ignore_boards text NOT NULL;
- ---#
- /******************************************************************************/
- --- Allow for longer calendar event/holiday titles.
- /******************************************************************************/
- ---# Changing event title column to a larger field type...
- ALTER TABLE {$db_prefix}calendar
- CHANGE title title varchar(255) NOT NULL default '';
- ---#
- ---# Changing holidays title column to a larger field type...
- ALTER TABLE {$db_prefix}calendar_holidays
- CHANGE title title varchar(255) NOT NULL default '';
- ---#
- /******************************************************************************/
- --- Adding extra columns to polls.
- /******************************************************************************/
- ---# Adding reset poll timestamp and guest voters counter...
- ALTER TABLE {$db_prefix}polls
- ADD COLUMN reset_poll int(10) unsigned NOT NULL default '0' AFTER guest_vote,
- ADD COLUMN num_guest_voters int(10) unsigned NOT NULL default '0' AFTER guest_vote;
- ---#
- ---# Fixing guest voter tallys on existing polls...
- ---{
- $request = upgrade_query("
- SELECT p.id_poll, count(lp.id_member) as guest_voters
- FROM {$db_prefix}polls AS p
- LEFT JOIN {$db_prefix}log_polls AS lp ON (lp.id_poll = p.id_poll AND lp.id_member = 0)
- WHERE lp.id_member = 0
- AND p.num_guest_voters = 0
- GROUP BY p.id_poll");
- while ($request && $row = $smcFunc['db_fetch_assoc']($request))
- upgrade_query("
- UPDATE {$db_prefix}polls
- SET num_guest_voters = ". $row['guest_voters']. "
- WHERE id_poll = " . $row['id_poll'] . "
- AND num_guest_voters = 0");
- ---}
- ---#
- /******************************************************************************/
- --- Changing all tinytext columns to varchar(255).
- /******************************************************************************/
- ---# Changing all tinytext columns to varchar(255)...
- ---{
- // The array holding all the changes.
- $nameChanges = array(
- 'admin_info_files' => array(
- 'filename' => 'filename filename varchar(255) NOT NULL default \'\'',
- 'path' => 'path path varchar(255) NOT NULL default \'\'',
- 'parameters' => 'parameters parameters varchar(255) NOT NULL default \'\'',
- 'filetype' => 'filetype filetype varchar(255) NOT NULL default \'\'',
- ),
- 'attachments' => array(
- 'filename' => 'filename filename varchar(255) NOT NULL default \'\'',
- ),
- 'ban_groups' => array(
- 'reason' => 'reason reason varchar(255) NOT NULL default \'\'',
- ),
- 'ban_items' => array(
- 'hostname' => 'hostname hostname varchar(255) NOT NULL default \'\'',
- 'email_address' => 'email_address email_address varchar(255) NOT NULL default \'\'',
- ),
- 'boards' => array(
- 'name' => 'name name varchar(255) NOT NULL default \'\'',
- ),
- 'categories' => array(
- 'name' => 'name name varchar(255) NOT NULL default \'\'',
- ),
- 'custom_fields' => array(
- 'field_desc' => 'field_desc field_desc varchar(255) NOT NULL default \'\'',
- 'mask' => 'mask mask varchar(255) NOT NULL default \'\'',
- 'default_value' => 'default_value default_value varchar(255) NOT NULL default \'\'',
- ),
- 'log_banned' => array(
- 'email' => 'email email varchar(255) NOT NULL default \'\'',
- ),
- 'log_comments' => array(
- 'recipient_name' => 'recipient_name recipient_name varchar(255) NOT NULL default \'\'',
- ),
- 'log_errors' => array(
- 'file' => 'file file varchar(255) NOT NULL default \'\'',
- ),
- 'log_member_notices' => array(
- 'subject' => 'subject subject varchar(255) NOT NULL default \'\'',
- ),
- 'log_packages' => array(
- 'filename' => 'filename filename varchar(255) NOT NULL default \'\'',
- 'package_id' => 'package_id package_id varchar(255) NOT NULL default \'\'',
- 'name' => 'name name varchar(255) NOT NULL default \'\'',
- 'version' => 'version version varchar(255) NOT NULL default \'\'',
- 'member_installed' => 'member_installed member_installed varchar(255) NOT NULL default \'\'',
- 'member_removed' => 'member_removed member_removed varchar(255) NOT NULL default \'\'',
- 'themes_installed' => 'themes_installed themes_installed varchar(255) NOT NULL default \'\'',
- ),
- 'log_reported' => array(
- 'membername' => 'membername membername varchar(255) NOT NULL default \'\'',
- 'subject' => 'subject subject varchar(255) NOT NULL default \'\'',
- ),
- 'log_reported_comments' => array(
- 'membername' => 'membername membername varchar(255) NOT NULL default \'\'',
- 'comment' => 'comment comment varchar(255) NOT NULL default \'\'',
- ),
- 'log_spider_hits' => array(
- 'url' => 'url url varchar(255) NOT NULL default \'\'',
- ),
- 'log_subscribed' => array(
- 'vendor_ref' => 'vendor_ref vendor_ref varchar(255) NOT NULL default \'\'',
- ),
- 'mail_queue' => array(
- 'recipient' => 'recipient recipient varchar(255) NOT NULL default \'\'',
- 'subject' => 'subject subject varchar(255) NOT NULL default \'\'',
- ),
- 'membergroups' => array(
- 'stars' => 'stars stars varchar(255) NOT NULL default \'\'',
- ),
- 'members' => array(
- 'lngfile' => 'lngfile lngfile varchar(255) NOT NULL default \'\'',
- 'real_name' => 'real_name real_name varchar(255) NOT NULL default \'\'',
- 'pm_ignore_list' => 'pm_ignore_list pm_ignore_list varchar(255) NOT NULL default \'\'',
- 'email_address' => 'email_address email_address varchar(255) NOT NULL default \'\'',
- 'personal_text' => 'personal_text personal_text varchar(255) NOT NULL default \'\'',
- 'website_title' => 'website_title website_title varchar(255) NOT NULL default \'\'',
- 'website_url' => 'website_url website_url varchar(255) NOT NULL default \'\'',
- 'location' => 'location location varchar(255) NOT NULL default \'\'',
- 'icq' => 'icq icq varchar(255) NOT NULL default \'\'',
- 'aim' => 'aim aim varchar(255) NOT NULL default \'\'',
- 'msn' => 'msn msn varchar(255) NOT NULL default \'\'',
- 'avatar' => 'avatar avatar varchar(255) NOT NULL default \'\'',
- 'usertitle' => 'usertitle usertitle varchar(255) NOT NULL default \'\'',
- 'member_ip' => 'member_ip member_ip varchar(255) NOT NULL default \'\'',
- 'member_ip2' => 'member_ip2 member_ip2 varchar(255) NOT NULL default \'\'',
- 'secret_question' => 'secret_question secret_question varchar(255) NOT NULL default \'\'',
- 'additional_groups' => 'additional_groups additional_groups varchar(255) NOT NULL default \'\'',
- ),
- 'messages' => array(
- 'subject' => 'subject subject varchar(255) NOT NULL default \'\'',
- 'poster_name' => 'poster_name poster_name varchar(255) NOT NULL default \'\'',
- 'poster_email' => 'poster_email poster_email varchar(255) NOT NULL default \'\'',
- 'poster_ip' => 'poster_ip poster_ip varchar(255) NOT NULL default \'\'',
- 'modified_name' => 'modified_name modified_name varchar(255) NOT NULL default \'\'',
- ),
- 'openid_assoc' => array(
- 'handle' => 'handle handle varchar(255) NOT NULL default \'\'',
- ),
- 'package_servers' => array(
- 'name' => 'name name varchar(255) NOT NULL default \'\'',
- 'url' => 'url url varchar(255) NOT NULL default \'\'',
- ),
- 'permission_profiles' => array(
- 'profile_name' => 'profile_name profile_name varchar(255) NOT NULL default \'\'',
- ),
- 'personal_messages' => array(
- 'from_name' => 'from_name from_name varchar(255) NOT NULL default \'\'',
- 'subject' => 'subject subject varchar(255) NOT NULL default \'\'',
- ),
- 'polls' => array(
- 'question' => 'question question varchar(255) NOT NULL default \'\'',
- 'poster_name' => 'poster_name poster_name varchar(255) NOT NULL default \'\'',
- ),
- 'poll_choices' => array(
- 'label' => 'label label varchar(255) NOT NULL default \'\'',
- ),
- 'settings' => array(
- 'variable' => 'variable variable varchar(255) NOT NULL default \'\'',
- ),
- 'spiders' => array(
- 'spider_name' => 'spider_name spider_name varchar(255) NOT NULL default \'\'',
- 'user_agent' => 'user_agent user_agent varchar(255) NOT NULL default \'\'',
- 'ip_info' => 'ip_info ip_info varchar(255) NOT NULL default \'\'',
- ),
- 'subscriptions' => array(
- 'description' => 'description description varchar(255) NOT NULL default \'\'',
- ),
- 'themes' => array(
- 'variable' => 'variable variable varchar(255) NOT NULL default \'\'',
- ),
- );
- $_GET['ren_col'] = isset($_GET['ren_col']) ? (int) $_GET['ren_col'] : 0;
- $step_progress['name'] = 'Changing tinytext columns to varchar(255)';
- $step_progress['current'] = $_GET['ren_col'];
- $step_progress['total'] = count($nameChanges);
- $count = 0;
- // Now do every table...
- foreach ($nameChanges as $table_name => $table)
- {
- // Already done this?
- $count++;
- if ($_GET['ren_col'] > $count)
- continue;
- $_GET['ren_col'] = $count;
- // Check the table exists!
- $request = upgrade_query("
- SHOW TABLES
- LIKE '{$db_prefix}$table_name'");
- if (smf_mysql_num_rows($request) == 0)
- {
- smf_mysql_free_result($request);
- continue;
- }
- smf_mysql_free_result($request);
- // Converting is intensive, so make damn sure that we need to do it.
- $request = upgrade_query("
- SHOW FIELDS
- FROM `{$db_prefix}$table_name`");
- $tinytextColumns = array();
- while($row = smf_mysql_fetch_assoc($request))
- {
- // Tinytext detected so store column name.
- if ($row['Type'] == 'tinytext')
- $tinytextColumns[$row['Field']] = $row['Field'];
- }
- smf_mysql_free_result($request);
- // Check each column!
- $actualChanges = array();
- foreach ($table as $colname => $coldef)
- {
- // Column was not detected as tinytext so skip it
- // Either it was already converted or was changed eg text (so do not break it)
- if (!isset($tinytextColumns[$colname]))
- continue;
- $change = array(
- 'table' => $table_name,
- 'name' => $colname,
- 'type' => 'column',
- 'method' => 'change_remove',
- 'text' => 'CHANGE ' . $coldef,
- );
- if (protected_alter($change, $substep, true) == false)
- $actualChanges[] = ' CHANGE COLUMN ' . $coldef;
- }
- // Do the query - if it needs doing.
- if (!empty($actualChanges))
- {
- $change = array(
- 'table' => $table_name,
- 'name' => 'na',
- 'type' => 'table',
- 'method' => 'full_change',
- 'text' => implode(', ', $actualChanges),
- );
- // Here we go - hold on!
- protected_alter($change, $substep);
- }
- // Update where we are!
- $step_progress['current'] = $_GET['ren_col'];
- }
- // All done!
- unset($_GET['ren_col']);
- ---}
- ---#
- /******************************************************************************/
- --- Adding new personal message setting.
- /******************************************************************************/
- ---# Adding column that stores the PM receiving setting...
- ALTER TABLE {$db_prefix}members
- ADD COLUMN pm_receive_from tinyint(4) unsigned NOT NULL default '1';
- ---#
- ---# Enable the buddy and ignore lists if we have not done so thus far...
- ---{
- // Don't do this if we've done this already.
- if (empty($modSettings['dont_repeat_buddylists']))
- {
- // Make sure the pm_receive_from column has the right default value - early adoptors might have a '0' set here.
- upgrade_query("
- ALTER TABLE {$db_prefix}members
- CHANGE pm_receive_from pm_receive_from tinyint(3) unsigned NOT NULL default '1'");
- // Update previous ignore lists if they're set to ignore all.
- upgrade_query("
- UPDATE {$db_prefix}members
- SET pm_receive_from = 3, pm_ignore_list = ''
- WHERE pm_ignore_list = '*'");
- // Ignore posts made by ignored users by default.
- upgrade_query("
- REPLACE INTO {$db_prefix}themes
- (id_member, id_theme, variable, value)
- VALUES
- (-1, 1, 'posts_apply_ignore_list', '1')");
- // Enable buddy and ignore lists, and make sure not to skip this step next time we run this.
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('enable_buddylist', '1'),
- ('dont_repeat_buddylists', '1')");
- }
- // And yet, and yet... We might have a small hiccup here...
- if (!empty($modSettings['dont_repeat_buddylists']) && !isset($modSettings['enable_buddylist']))
- {
- // Correct RC3 adopters setting here...
- if (isset($modSettings['enable_buddylists']))
- {
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('enable_buddylist', '" . $modSettings['enable_buddylists'] . "')");
- }
- else
- {
- // This should never happen :)
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('enable_buddylist', '1')");
- }
- }
- ---}
- ---#
- /******************************************************************************/
- --- Adding settings for attachments and avatars.
- /******************************************************************************/
- ---# Add new security settings for attachments and avatars...
- ---{
- // Don't do this if we've done this already.
- if (!isset($modSettings['attachment_image_reencode']))
- {
- // Enable image re-encoding by default.
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('attachment_image_reencode', '1')");
- }
- if (!isset($modSettings['attachment_image_paranoid']))
- {
- // Disable draconic checks by default.
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('attachment_image_paranoid', '0')");
- }
- if (!isset($modSettings['avatar_reencode']))
- {
- // Enable image re-encoding by default.
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('avatar_reencode', '1')");
- }
- if (!isset($modSettings['avatar_paranoid']))
- {
- // Disable draconic checks by default.
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('avatar_paranoid', '0')");
- }
- ---}
- ---#
- ---# Add other attachment settings...
- ---{
- if (!isset($modSettings['attachment_thumb_png']))
- {
- // Make image attachment thumbnail as PNG by default.
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('attachment_thumb_png', '1')");
- }
- ---}
- ---#
- /******************************************************************************/
- --- Cleaning up after old themes...
- /******************************************************************************/
- ---# Checking for "babylon" and removing it if necessary...
- ---{
- // Do they have "babylon" installed?
- if (file_exists($GLOBALS['boarddir'] . '/Themes/babylon'))
- {
- $babylon_dir = $GLOBALS['boarddir'] . '/Themes/babylon';
- $theme_request = upgrade_query("
- SELECT ID_THEME
- FROM {$db_prefix}themes
- WHERE variable = 'theme_dir'
- AND value ='$babylon_dir'");
- // Don't do anything if this theme is already uninstalled
- if (smf_mysql_num_rows($theme_request) == 1)
- {
- $id_theme = mysql_result($theme_request, 0);
- mysql_free_result($theme_request);
- $known_themes = explode(', ', $modSettings['knownThemes']);
- // Remove this value...
- $known_themes = array_diff($known_themes, array($id_theme));
- // Change back to a string...
- $known_themes = implode(', ', $known_themes);
- // Update the database
- upgrade_query("
- REPLACE INTO {$db_prefix}settings (variable, value)
- VALUES ('knownThemes', '$known_themes')");
- // Delete any info about this theme
- upgrade_query("
- DELETE FROM {$db_prefix}themes
- WHERE id_theme = $id_theme");
- // Set any members or boards using this theme to the default
- upgrade_query("
- UPDATE {$db_prefix}members
- SET id_theme = 0
- WHERE id_theme = $id_theme");
- upgrade_query("
- UPDATE {$db_prefix}boards
- SET id_theme = 0
- WHERE id_theme = $id_theme");
- if ($modSettings['theme_guests'] == $id_theme)
- {
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES('theme_guests', 0)");
- }
- }
- }
- ---}
- ---#
- /******************************************************************************/
- --- Installing new smileys sets...
- /******************************************************************************/
- ---# Installing new smiley sets...
- ---{
- // Don't do this twice!
- if (empty($modSettings['installed_new_smiley_sets_20']))
- {
- // First, the entries.
- upgrade_query("
- UPDATE {$db_prefix}settings
- SET value = CONCAT(value, ',aaron,akyhne')
- WHERE variable = 'smiley_sets_known'");
- // Second, the names.
- upgrade_query("
- UPDATE {$db_prefix}settings
- SET value = CONCAT(value, '\nAaron\nAkyhne')
- WHERE variable = 'smiley_sets_names'");
- // This ain't running twice either.
- upgrade_query("
- REPLACE INTO {$db_prefix}settings
- (variable, value)
- VALUES
- ('installed_new_smiley_sets_20', '1')");
- }
- ---}
- ---#
- /******************************************************************************/
- --- Adding new indexes to the topics table.
- /******************************************************************************/
- ---# Adding index member_started...
- ALTER TABLE {$db_prefix}topics
- ADD INDEX member_started (id_member_started, id_board);
- ---#
- ---# Adding index last_message_sticky...
- ALTER TABLE {$db_prefix}topics
- ADD INDEX last_message_sticky (id_board, is_sticky, id_last_msg);
- ---#
- ---# Adding index board_news...
- ALTER TABLE {$db_prefix}topics
- ADD INDEX board_news (id_board, id_first_msg);
- ---#
- /******************************************************************************/
- --- Adding new indexes to members table.
- /******************************************************************************/
- ---# Adding index on total_time_logged_in...
- ALTER TABLE {$db_prefix}members
- ADD INDEX total_time_logged_in (total_time_logged_in);
- ---#
- ---# Adding index on id_theme...
- ALTER TABLE {$db_prefix}members
- ADD INDEX id_theme (id_theme);
- ---#
- ---# Dropping index on real_name(30) ...
- ---{
- // Detect existing index with limited length
- $request = upgrade_query("
- SHOW INDEXES
- FROM {$db_prefix}members"
- );
- // Drop the existing index before we recreate it.
- while ($row = smf_mysql_fetch_assoc($request))
- {
- if ($row['Key_name'] === 'real_name' && $row['Sub_part'] == 30)
- {
- upgrade_query("
- ALTER TABLE {$db_prefix}members
- DROP INDEX real_name"
- );
- break;
- }
- }
- smf_mysql_free_result($request);
- ---}
- ---#
- ---# Adding index on real_name...
- ALTER TABLE {$db_prefix}members
- ADD INDEX real_name (real_name);
- ---#
- ---# Dropping index member_name(30)...
- ---{
- // Detect existing index with limited length
- $request = upgrade_query("
- SHOW INDEXES
- FROM {$db_prefix}members"
- );
- // Drop the existing index before we recreate it.
- while ($row = smf_mysql_fetch_assoc($request))
- {
- if ($row['Key_name'] === 'member_name' && $row['Sub_part'] == 30)
- {
- upgrade_query("
- ALTER TABLE {$db_prefix}members
- DROP INDEX member_name"
- );
- break;
- }
- }
- smf_mysql_free_result($request);
- ---}
- ---#
- ---# Adding index on member_name...
- ALTER TABLE {$db_prefix}members
- ADD INDEX member_name (member_name);
- ---#
- /******************************************************************************/
- --- Adding new indexes to messages table.
- /******************************************************************************/
- ---# Adding index id_member_msg...
- ALTER TABLE {$db_prefix}messages
- ADD INDEX id_member_msg (id_member, approved, id_msg);
- ---#
- ---# Adding index current_topic...
- ALTER TABLE {$db_prefix}messages
- ADD INDEX current_topic (id_topic, id_msg, id_member, approved);
- ---#
- ---# Adding index related_ip...
- ALTER TABLE {$db_prefix}messages
- ADD INDEX related_ip (id_member, poster_ip, id_msg);
- ---#
- /******************************************************************************/
- --- Adding new indexes to attachments table.
- /******************************************************************************/
- ---# Adding index on attachment_type...
- ALTER TABLE {$db_prefix}attachments
- ADD INDEX attachment_type (attachment_type);
- ---#
- /******************************************************************************/
- --- Dropping unnecessary indexes...
- /******************************************************************************/
- ---# Removing index on hits...
- ALTER TABLE {$db_prefix}log_activity
- DROP INDEX hits;
- ---#
- /******************************************************************************/
- --- Adding extra columns to reported post comments
- /******************************************************************************/
- ---# Adding email address and member ip columns...
- ALTER TABLE {$db_prefix}log_reported_comments
- ADD COLUMN member_ip varchar(255) NOT NULL default '' AFTER membername,
- ADD COLUMN email_address varchar(255) NOT NULL default '' AFTER membername;
- ---#
- /******************************************************************************/
- --- Adjusting group types.
- /******************************************************************************/
- ---# Fixing the group types.
- ---{
- // Get the admin group type.
- $request = upgrade_query("
- SELECT group_type
- FROM {$db_prefix}membergroups
- WHERE id_group = 1
- LIMIT 1");
- list ($admin_group_type) = smf_mysql_fetch_row($request);
- smf_mysql_free_result($request);
- // Not protected means we haven't updated yet!
- if ($admin_group_type != 1)
- {
- // Increase by one.
- upgrade_query("
- UPDATE {$db_prefix}membergroups
- SET group_type = group_type + 1
- WHERE group_type > 0");
- }
- ---}
- ---#
- ---# Changing the group type for Administrator group.
- UPDATE {$db_prefix}membergroups
- SET group_type = 1
- WHERE id_group = 1;
- ---#
- /******************************************************************************/
- --- Final clean up...
- /******************************************************************************/
- ---# Sorting the boards...
- ALTER TABLE {$db_prefix}categories
- ORDER BY cat_order;
- ALTER TABLE {$db_prefix}boards
- ORDER BY board_order;
- ---#
|