@@ -101,16 +101,6 @@ function output($message)
101101 Sql_Query (sprintf ('delete from %s ' ,$ GLOBALS ['tables ' ]['sendprocess ' ]));
102102
103103 ignore_user_abort (1 );
104- // rename tables if we are using the prefix
105- include dirname (__FILE__ ).'/structure.php ' ;
106- foreach ($ DBstruct as $ table => $ value ) {
107- set_time_limit (500 );
108- if (isset ($ table_prefix )) {
109- if (Sql_Table_exists ($ table ) && !Sql_Table_Exists ($ tables [$ table ])) {
110- Sql_Verbose_Query ("alter table $ table rename $ tables [$ table ]" , 1 );
111- }
112- }
113- }
114104 @ob_end_flush ();
115105 @ob_start ();
116106
@@ -230,144 +220,12 @@ function output($message)
230220 Sql_Query (sprintf ('update %s set data = "%s" where data = "%s" ' , $ GLOBALS ['tables ' ]['subscribepage_data ' ], sql_escape ($ newFooter ), addslashes ($ value )));
231221 }
232222 }
233- //# remember whether we've done this, to avoid doing it every time
234- //# even thought that's not such a big deal
235- $ isUTF8 = getConfig ('UTF8converted ' );
236-
237- if (empty ($ isUTF8 )) {
238- $ maxsize = 0 ;
239- $ req = Sql_Query ('select (data_length+index_length) tablesize
240- from information_schema.tables
241- where table_schema=" ' .$ GLOBALS ['database_name ' ].'" ' );
242-
243- while ($ row = Sql_Fetch_Assoc ($ req )) {
244- if ($ row ['tablesize ' ] > $ maxsize ) {
245- $ maxsize = $ row ['tablesize ' ];
246- }
247- }
248- $ maxsize = (int ) ($ maxsize * 1.2 ); //# add another 20%
249- #this is only valid when the DB is on the same host
250- if ($ GLOBALS ['database_host ' ] == 'localhost ' ) {
251- $ row = Sql_Fetch_Row_Query ('select @@datadir ' );
252- $ dataDir = $ row [0 ];
253- $ avail = disk_free_space ($ dataDir );
254- } else {
255- # let's assume the DB host has sufficient space
256- $ avail = $ maxsize + 1 ;
257- }
258-
259- //# convert to UTF8
260- $ dbname = $ GLOBALS ['database_name ' ];
261- if ($ maxsize < $ avail && !empty ($ dbname )) {
262- //# the conversion complains about a key length
263- Sql_Query (sprintf ('alter table ' .$ GLOBALS ['tables ' ]['user_blacklist_data ' ].' change column email email varchar(150) not null unique ' ));
264-
265- $ req = Sql_Query ('select * from information_schema.columns where table_schema = " ' .$ dbname .'" and CHARACTER_SET_NAME != "utf8" ' );
266-
267- $ dbcolumns = array ();
268- $ dbtables = array ();
269- while ($ row = Sql_Fetch_Assoc ($ req )) {
270- //# make sure to only change our own tables, in case we share with other applications
271- if (in_array ($ row ['TABLE_NAME ' ], array_values ($ GLOBALS ['tables ' ]))) {
272- $ dbcolumns [] = $ row ;
273- $ dbtables [$ row ['TABLE_NAME ' ]] = $ row ['TABLE_NAME ' ];
274- }
275- }
276-
277- Sql_Query ('use ' .$ dbname );
278-
279- output ($ GLOBALS ['I18N ' ]->get ('Upgrading the database to use UTF-8, please wait ' ).'<br/> ' );
280- foreach ($ dbtables as $ dbtable ) {
281- set_time_limit (3600 );
282- output ($ GLOBALS ['I18N ' ]->get ('Upgrading table ' ).' ' .$ dbtable .'<br/> ' );
283- Sql_Query (sprintf ('alter table %s default charset utf8 ' , $ dbtable ), 1 );
284- }
285-
286- foreach ($ dbcolumns as $ dbcolumn ) {
287- set_time_limit (600 );
288- output ($ GLOBALS ['I18N ' ]->get ('Upgrading column ' ).' ' .$ dbcolumn ['COLUMN_NAME ' ].'<br/> ' );
289- Sql_Query (sprintf ('alter table %s change column %s %s %s default character set utf8 ' ,
290- $ dbcolumn ['TABLE_NAME ' ], $ dbcolumn ['COLUMN_NAME ' ], $ dbcolumn ['COLUMN_NAME ' ],
291- $ dbcolumn ['COLUMN_TYPE ' ]), 1 );
292- }
293- output ($ GLOBALS ['I18N ' ]->get ('upgrade to UTF-8, done ' ).'<br/> ' );
294- saveConfig ('UTF8converted ' , date ('Y-m-d H:i ' ), 0 );
295- } else {
296- echo '<div class="error"> ' .s ('Database requires converting to UTF-8. ' ).'<br/> ' ;
297- echo s ('However, there is too little diskspace for this conversion ' ).'<br/> ' ;
298- echo s ('Please do a manual conversion. ' ).' ' .PageLinkButton ('converttoutf8 ' ,
299- s ('Run manual conversion to UTF8 ' ));
300- echo '</div> ' ;
301- }
302- }
303-
304- //# 2.11.7 and up
305- Sql_Query (sprintf ('alter table %s add column privileges text ' , $ tables ['admin ' ]), 1 );
306- Sql_Query ('alter table ' .$ tables ['list ' ].' add column category varchar(255) default "" ' , 1 );
307- Sql_Query ('alter table ' .$ tables ['user_attribute ' ].' change column value value text ' );
308- Sql_Query ('alter table ' .$ tables ['message ' ].' change column textmessage textmessage longtext ' );
309- Sql_Query ('alter table ' .$ tables ['message ' ].' change column message message longtext ' );
310- Sql_Query ('alter table ' .$ tables ['messagedata ' ].' change column data data longtext ' );
311- Sql_Query ('alter table ' .$ tables ['bounce ' ].' add index statusidx (status(20)) ' , 1 );
312223
313224 //# fetch the list of TLDs, if possible
314225 if (defined ('TLD_AUTH_LIST ' )) {
315226 refreshTlds (true );
316227 }
317228
318- //# changed terminology
319- Sql_Query (sprintf ('update %s set status = "invalid email address" where status = "invalid email" ' ,
320- $ tables ['usermessage ' ]));
321-
322- //# for some reason there are some config entries marked non-editable, that should be
323- include_once dirname (__FILE__ ).'/defaultconfig.php ' ;
324- foreach ($ default_config as $ configItem => $ configDetails ) {
325- if (empty ($ configDetails ['hidden ' ])) {
326- Sql_Query (sprintf ('update %s set editable = 1 where item = "%s" ' , $ tables ['config ' ], $ configItem ));
327- } else {
328- Sql_Query (sprintf ('update %s set editable = 0 where item = "%s" ' , $ tables ['config ' ], $ configItem ));
329- }
330- }
331-
332- //# replace old header and footer with the new one
333- //# but only if there are untouched from the default, which seems fairly common
334- $ oldPH = @file_get_contents (dirname (__FILE__ ).'/ui/old_public_header.inc ' );
335- $ oldPH2 = preg_replace ("/ \n/ " , "\r\n" , $ oldPH ); //# version with \r\n instead of \n
336-
337- $ oldPF = @file_get_contents (dirname (__FILE__ ).'/ui/old_public_footer.inc ' );
338- $ oldPF2 = preg_replace ("/ \n/ " , "\r\n" , $ oldPF ); //# version with \r\n instead of \n
339- Sql_Query (sprintf ('update %s set value = "%s" where item = "pageheader" and (value = "%s" or value = "%s") ' ,
340- $ tables ['config ' ], sql_escape ($ defaultheader ), addslashes ($ oldPH ), addslashes ($ oldPH2 )));
341- Sql_Query (sprintf ('update %s set value = "%s" where item = "pagefooter" and (value = "%s" or value = "%s") ' ,
342- $ tables ['config ' ], sql_escape ($ defaultfooter ), addslashes ($ oldPF ), addslashes ($ oldPF2 )));
343-
344- //# and the same for subscribe pages
345- Sql_Query (sprintf ('update %s set data = "%s" where name = "header" and (data = "%s" or data = "%s") ' ,
346- $ tables ['subscribepage_data ' ], sql_escape ($ defaultheader ), addslashes ($ oldPH ), addslashes ($ oldPH2 )));
347- Sql_Query (sprintf ('update %s set data = "%s" where name = "footer" and (data = "%s" or data = "%s") ' ,
348- $ tables ['subscribepage_data ' ], sql_escape ($ defaultfooter ), addslashes ($ oldPF ), addslashes ($ oldPF2 )));
349-
350- if (is_file (dirname (__FILE__ ).'/ui/ ' .$ GLOBALS ['ui ' ].'/old_public_header.inc ' )) {
351- $ oldPH = file_get_contents (dirname (__FILE__ ).'/ui/ ' .$ GLOBALS ['ui ' ].'/old_public_header.inc ' );
352- $ oldPH2 = preg_replace ("/ \n/ " , "\r\n" , $ oldPH ); //# version with \r\n instead of \n
353- $ oldPF = file_get_contents (dirname (__FILE__ ).'/ui/ ' .$ GLOBALS ['ui ' ].'/old_public_footer.inc ' );
354- $ oldPF2 = preg_replace ("/ \n/ " , "\r\n" , $ oldPF ); //# version with \r\n instead of \n
355- $ currentPH = getConfig ('pageheader ' );
356- $ currentPF = getConfig ('pagefooter ' );
357-
358- if (($ currentPH == $ oldPH2 || $ currentPH ."\r\n" == $ oldPH2 ) && !empty ($ defaultheader )) {
359- SaveConfig ('pageheader ' , $ defaultheader , 1 );
360- Sql_Query (sprintf ('update %s set data = "%s" where name = "header" and data = "%s" ' ,
361- $ tables ['subscribepage_data ' ], sql_escape ($ defaultheader ), addslashes ($ currentPH )));
362- //# only try to change footer when header has changed
363- if ($ currentPF == $ oldPF2 && !empty ($ defaultfooter )) {
364- SaveConfig ('pagefooter ' , $ defaultfooter , 1 );
365- Sql_Query (sprintf ('update %s set data = "%s" where name = "footer" and data = "%s" ' ,
366- $ tables ['subscribepage_data ' ], sql_escape ($ defaultfooter ), addslashes ($ currentPF )));
367- }
368- }
369- }
370-
371229 //# #17328 - remove list categories with quotes
372230 Sql_Query (sprintf ("update %s set category = replace(category, \"\\\\' \", \" \") " , $ tables ['list ' ]));
373231
@@ -402,7 +260,7 @@ function output($message)
402260
403261 // output(s('Giving a UUID to your subscribers and campaigns. If you have a lot of them, this may take a while.'));
404262 // output(s('If the page times out, you can reload. Or otherwise try to run the upgrade from commandline instead.').' '.resourceLink('https://resources.phplist.com/system/commandline', s('Documentation how to set up phpList commandline')));
405- } else {
263+ } elseif ( $ numS > 0 ) {
406264 output (s ('Giving a UUID to your subscribers and campaigns. If you have a lot of them, this may take a while. ' ));
407265 output (s ('If the page times out, you can reload. Or otherwise try to run the upgrade from commandline instead. ' ).' ' .resourceLink ('https://resources.phplist.com/system/commandline ' , s ('Documentation how to set up phpList commandline ' )));
408266 while ($ row = Sql_Fetch_Row ($ req )) {
0 commit comments