Browse Source

migrate to php 7

mw_29
Adrian Malacoda 1 year ago
parent
commit
8b2e8e318e
4 changed files with 40 additions and 40 deletions
  1. 6
    6
      Dockerfile
  2. 26
    26
      application/forums/smf_api.php
  3. 4
    4
      configuration/php-fpm.conf
  4. 4
    4
      configuration/supervisord.conf

+ 6
- 6
Dockerfile View File

@@ -1,6 +1,6 @@
1 1
 FROM debian:stable
2 2
 
3
-RUN apt-get -y update && apt-get -y install nginx php5-fpm php5-mysql php-apc supervisor python-pip mysql-client imagemagick curl wget
3
+RUN apt-get -y update && apt-get -y install nginx php-fpm php-mysql php-apcu php-mbstring php-xml supervisor python-pip mysql-client imagemagick curl wget
4 4
 RUN pip install supervisor-stdout
5 5
 
6 6
 ENV MW_VERSION REL1_29
@@ -23,14 +23,14 @@ RUN cd /usr/src && curl -sS https://getcomposer.org/installer | php -- --install
23 23
 # Clone mediawiki and SMF source into temp directory, install and then copy over to application dir
24 24
 RUN cd /tmp && wget $MW_SOURCE && tar -xvf mediawiki-*.tar.gz && \
25 25
     cp -Rv mediawiki-*/* $WIKI_SOURCE && rm -rf mediawiki-* && \
26
-    mkdir smf && cp smf && wget $SMF_SOURCE && tar -xvf $SMF_SOURCE && \
27
-    rm -rf Settings.php attachments *.tar.gz && cp -Rv * $FORUMS_SOURCE  
26
+    mkdir smf && cd smf && wget $SMF_SOURCE && tar -xvf smf_*.tar.gz && \
27
+    rm -rf Settings.php attachments smf_*.tar.gz && cp -Rv * $FORUMS_SOURCE
28 28
 
29 29
 RUN ln -sf /configuration/supervisord.conf /etc/supervisor/supervisord.conf && \
30 30
     ln -sf /configuration/nginx.conf /etc/nginx/nginx.conf && \
31
-    ln -sf /configuration/php-fpm.conf /etc/php5/fpm/php-fpm.conf && \
32
-    ln -sf /configuration/php-fpm-pool.conf /etc/php5/fpm/pool.d/www.conf && \
33
-    ln -sf /configuration/php.ini /etc/php5/fpm/php.ini
31
+    ln -sf /configuration/php-fpm.conf /etc/php/7.0/fpm/php-fpm.conf && \
32
+    ln -sf /configuration/php-fpm-pool.conf /etc/php/7.0/fpm/pool.d/www.conf && \
33
+    ln -sf /configuration/php.ini /etc/php/7.0/fpm/php.ini
34 34
 
35 35
 RUN chown -R www-data:www-data /application
36 36
 

+ 26
- 26
application/forums/smf_api.php View File

@@ -140,7 +140,7 @@
140 140
 $maintenance = 0;
141 141
 
142 142
 // This is just because SMF in general hates magic quotes at runtime.
143
-@set_magic_quotes_runtime(0);
143
+//@set_magic_quotes_runtime(0);
144 144
 
145 145
 // Hopefully the forum is in the same place as this script.
146 146
 require_once(dirname(__FILE__) . '/Settings.php');
@@ -152,18 +152,18 @@ if ($maintenance != 2)
152 152
 {
153 153
 	// Ignore connection errors, because this is just an API file.
154 154
 	if (empty($db_persist))
155
-		$smf_connection = @mysql_connect($db_server, $db_user, $db_passwd);
155
+		$smf_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
156 156
 	else
157
-		$smf_connection = @mysql_pconnect($db_server, $db_user, $db_passwd);
157
+		$smf_connection = @mysqli_pconnect($db_server, $db_user, $db_passwd);
158 158
 	//$db_prefix = '`' . $db_name . '`.' . $db_prefix;
159
-	mysql_select_db($db_name);
159
+	mysqli_select_db($db_name);
160 160
 	$request = smf_query("
161 161
 		SELECT `variable`, `value`
162 162
 		FROM {$db_prefix}settings",__FILE__,__LINE__);
163 163
 	$smf_settings = array();
164
-	while ($row = @mysql_fetch_row($request))
164
+	while ($row = @mysqli_fetch_row($request))
165 165
 		$smf_settings[$row[0]] = $row[1];
166
-	mysql_free_result($request);
166
+	mysqli_free_result($request);
167 167
 }
168 168
 
169 169
 // Load stuff from the Settings.php file into $smf_settings.
@@ -196,8 +196,8 @@ function smf_setLoginCookie($cookie_length, $id, $password = '', $encrypted = tr
196 196
 			FROM $smf_settings[db_prefix]members
197 197
 			WHERE member_name = '$username'
198 198
 			LIMIT 1", __FILE__, __LINE__);
199
-		list ($id) = mysql_fetch_row($result);
200
-		mysql_free_result($result);
199
+		list ($id) = mysqli_fetch_row($result);
200
+		mysqli_free_result($result);
201 201
 
202 202
 		// It wasn't found, after all?
203 203
 		if (empty($id))
@@ -222,8 +222,8 @@ function smf_setLoginCookie($cookie_length, $id, $password = '', $encrypted = tr
222 222
 			FROM $smf_settings[db_prefix]members
223 223
 			WHERE id_member = '" . (int) $id . "'
224 224
 			LIMIT 1", __FILE__, __LINE__);
225
-		list ($username, $salt) = mysql_fetch_row($result);
226
-		mysql_free_result($result);
225
+		list ($username, $salt) = mysqli_fetch_row($result);
226
+		mysqli_free_result($result);
227 227
 
228 228
 		if (empty($username))
229 229
 			return false;
@@ -319,10 +319,10 @@ function smf_authenticateUser()
319 319
 			LIMIT 1", __FILE__, __LINE__);
320 320
 
321 321
 		// Did we find 'im?  If not, junk it.
322
-		if (mysql_num_rows($request) != 0)
322
+		if (mysqli_num_rows($request) != 0)
323 323
 		{
324 324
 			// The base settings array.
325
-			$smf_user_info += mysql_fetch_assoc($request);
325
+			$smf_user_info += mysqli_fetch_assoc($request);
326 326
 
327 327
 			if (strlen($password) == 40)
328 328
 				$check = sha1($smf_user_info['passwd'] . $smf_user_info['password_salt']) == $password;
@@ -334,7 +334,7 @@ function smf_authenticateUser()
334 334
 		}
335 335
 		else
336 336
 			$ID_MEMBER = 0;
337
-		mysql_free_result($request);
337
+		mysqli_free_result($request);
338 338
 	}
339 339
 
340 340
 	if (empty($ID_MEMBER))
@@ -502,8 +502,8 @@ function smf_isOnline($user)
502 502
 			LEFT JOIN $smf_settings[db_prefix]members AS mem ON (mem.id_member = lo.id_member)" : '') . "
503 503
 		WHERE lo.id_member = " . (int) $user . (!is_integer($user) ? " OR mem.member_name = '$user'" : '') . "
504 504
 		LIMIT 1", __FILE__, __LINE__);
505
-	$return = mysql_num_rows($result) != 0;
506
-	mysql_free_result($result);
505
+	$return = mysqli_num_rows($result) != 0;
506
+	mysqli_free_result($result);
507 507
 
508 508
 	return $return;
509 509
 }
@@ -563,10 +563,10 @@ function smf_query($string, $file, $line)
563 563
 
564 564
 	$smf_settings['db_count'] = @$smf_settings['db_count'] + 1;
565 565
 
566
-	$ret = mysql_query($string, $smf_connection);
566
+	$ret = mysqli_query($string, $smf_connection);
567 567
 
568 568
 	if ($ret === false)
569
-		smf_logError(mysql_error($smf_connection), $file, $line);
569
+		smf_logError(mysqli_error($smf_connection), $file, $line);
570 570
 
571 571
 	return $ret;
572 572
 }
@@ -591,14 +591,14 @@ function smf_allowedTo($permission)
591 591
 			WHERE id_group IN (" . implode(', ', $smf_user_info['groups']) . ")", __FILE__, __LINE__);
592 592
 		$removals = array();
593 593
 		$smf_user_info['permissions'] = array();
594
-		while ($row = mysql_fetch_assoc($result))
594
+		while ($row = mysqli_fetch_assoc($result))
595 595
 		{
596 596
 			if (empty($row['add_deny']))
597 597
 				$removals[] = $row['permission'];
598 598
 			else
599 599
 				$smf_user_info['permissions'][] = $row['permission'];
600 600
 		}
601
-		mysql_free_result($result);
601
+		mysqli_free_result($result);
602 602
 
603 603
 		// And now we get rid of the removals ;).
604 604
 		if (!empty($smf_settings['permission_enable_deny']))
@@ -664,7 +664,7 @@ function smf_loadThemeData($ID_THEME = 0)
664 664
 			AND id_theme" . ($theme == 1 ? ' = 1' : " IN ($theme, 1)"), __FILE__, __LINE__);
665 665
 	// Pick between $smf_settings['theme'] and $smf_user_info['theme'] depending on whose data it is.
666 666
 	$themeData = array(0 => array(), $member => array());
667
-	while ($row = mysql_fetch_assoc($result))
667
+	while ($row = mysqli_fetch_assoc($result))
668 668
 	{
669 669
 		// If this is the themedir of the default theme, store it.
670 670
 		if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member']))
@@ -674,7 +674,7 @@ function smf_loadThemeData($ID_THEME = 0)
674 674
 		if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1')
675 675
 			$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
676 676
 	}
677
-	mysql_free_result($result);
677
+	mysqli_free_result($result);
678 678
 
679 679
 	$smf_settings['theme'] = $themeData[0];
680 680
 	$smf_user_info['theme'] = $themeData[$member];
@@ -702,7 +702,7 @@ function smf_loadSession()
702 702
 	@ini_set('session.use_cookies', true);
703 703
 	@ini_set('session.use_only_cookies', false);
704 704
 	@ini_set('arg_separator.output', '&');
705
-	
705
+
706 706
 	// If it's already been started... probably best to skip this.
707 707
 	if ((@ini_get('session.auto_start') == 1 && !empty($smf_settings['databaseSession_enable'])) || session_id() == '')
708 708
 	{
@@ -759,8 +759,8 @@ function smf_sessionRead($session_id)
759 759
 		FROM $smf_settings[db_prefix]sessions
760 760
 		WHERE session_id = '" . addslashes($session_id) . "'
761 761
 		LIMIT 1", __FILE__, __LINE__);
762
-	list ($sess_data) = mysql_fetch_row($result);
763
-	mysql_free_result($result);
762
+	list ($sess_data) = mysqli_fetch_row($result);
763
+	mysqli_free_result($result);
764 764
 
765 765
 	return $sess_data;
766 766
 }
@@ -780,7 +780,7 @@ function smf_sessionWrite($session_id, $data)
780 780
 		LIMIT 1", __FILE__, __LINE__);
781 781
 
782 782
 	// If that didn't work, try inserting a new one.
783
-	if (mysql_affected_rows($smf_connection) == 0)
783
+	if (mysqli_affected_rows($smf_connection) == 0)
784 784
 		$result = smf_query("
785 785
 			INSERT IGNORE INTO $smf_settings[db_prefix]sessions
786 786
 				(session_id, data, last_update)
@@ -912,4 +912,4 @@ if (!function_exists('sha1'))
912 912
 	}
913 913
 }
914 914
 
915
-?>
915
+?>

+ 4
- 4
configuration/php-fpm.conf View File

@@ -27,7 +27,7 @@ pid = run/php5-fpm.pid
27 27
 ; Error log file
28 28
 ; Note: the default prefix is /var
29 29
 ; Default Value: log/php-fpm.log
30
-error_log = /var/log/php5-fpm.log
30
+error_log = /var/log/php-fpm.log
31 31
 
32 32
 ; Log level
33 33
 ; Possible Values: alert, error, warning, notice, debug
@@ -40,7 +40,7 @@ error_log = /var/log/php5-fpm.log
40 40
 ; Default Value: 0
41 41
 emergency_restart_threshold = 10
42 42
 
43
-; Interval of time used by emergency_restart_interval to determine when 
43
+; Interval of time used by emergency_restart_interval to determine when
44 44
 ; a graceful restart will be initiated.  This can be useful to work around
45 45
 ; accidental corruptions in an accelerator's shared memory.
46 46
 ; Available Units: s(econds), m(inutes), h(ours), or d(ays)
@@ -59,7 +59,7 @@ process_control_timeout = 5
59 59
 daemonize = no
60 60
 
61 61
 ;;;;;;;;;;;;;;;;;;;;
62
-; Pool Definitions ; 
62
+; Pool Definitions ;
63 63
 ;;;;;;;;;;;;;;;;;;;;
64 64
 
65 65
 ; Multiple pools of child processes may be started with different listening
@@ -69,4 +69,4 @@ daemonize = no
69 69
 
70 70
 ; To configure the pools it is recommended to have one .conf file per
71 71
 ; pool in the following directory:
72
-include=/etc/php5/fpm/pool.d/*.conf
72
+include=/etc/php/7.0/fpm/pool.d/*.conf

+ 4
- 4
configuration/supervisord.conf View File

@@ -15,13 +15,13 @@ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
15 15
 [supervisorctl]
16 16
 serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
17 17
 
18
-[program:php5-fpm]
19
-command=/usr/sbin/php5-fpm -c /etc/php5/fpm
18
+[program:php-fpm]
19
+command=/usr/sbin/php-fpm7.0 -c /etc/php/7.0/fpm
20 20
 stdout_events_enabled=true
21 21
 stderr_events_enabled=true
22 22
 
23
-[program:php5-fpm-log]
24
-command=tail -f /var/log/php5-fpm.log
23
+[program:php-fpm-log]
24
+command=tail -f /var/log/php-fpm.log
25 25
 stdout_events_enabled=true
26 26
 stderr_events_enabled=true
27 27
 autorestart=unexpected

Loading…
Cancel
Save