Skip to content

Commit

Permalink
PHP 8 upgrade (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
flashadvocate authored Dec 27, 2022
1 parent 6479c23 commit cea2297
Show file tree
Hide file tree
Showing 22 changed files with 330 additions and 95 deletions.
6 changes: 6 additions & 0 deletions .docker/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM httpd:2.4.33-alpine
RUN apk update; \
apk upgrade;
COPY minimanager.apache.conf /usr/local/apache2/conf/minimanager.apache.conf
RUN echo "Include /usr/local/apache2/conf/minimanager.apache.conf" \
>> /usr/local/apache2/conf/httpd.conf
21 changes: 21 additions & 0 deletions .docker/apache/minimanager.apache.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ServerName localhost

LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so
LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so

<VirtualHost *:80>
# Proxy .php requests to port 9000 of the php-fpm container
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/var/www/html/$1
DocumentRoot /var/www/html/
<Directory /var/www/html/>
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

# Send apache logs to stdout and stderr
CustomLog /proc/self/fd/1 common
ErrorLog /proc/self/fd/2
</VirtualHost>
40 changes: 40 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3.2"
services:
php:
build: './php/'
networks:
- backend
volumes:
- ../:/var/www/html/
apache:
build: './apache/'
depends_on:
- php
- mysql
networks:
- frontend
- backend
ports:
- "8080:80"
volumes:
- ../:/var/www/html/
mysql:
image: mysql:5.6.40
command: --init-file /mysql/init.sql
ports:
- "3306:3306"
volumes:
- ./mysql/data:/var/lib/mysql
- ./mysql/init.sql:/mysql/init.sql
networks:
- backend
environment:
- MYSQL_ROOT_PASSWORD=rootpassword

healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
retries: 10
networks:
frontend:
backend:
1 change: 1 addition & 0 deletions .docker/mysql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data/
109 changes: 109 additions & 0 deletions .docker/mysql/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
CREATE DATABASE IF NOT EXISTS mmftc;
USE mmftc;
--
-- Table structure for table `mm_forum_posts`
--

DROP TABLE IF EXISTS `mm_forum_posts`;

CREATE TABLE `mm_forum_posts`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`authorid` bigint(20) unsigned NOT NULL DEFAULT '0',
`authorname` varchar(16) NOT NULL DEFAULT '',
`forum` bigint(20) unsigned NOT NULL DEFAULT '0',
`topic` bigint(20) unsigned NOT NULL DEFAULT '0',
`lastpost` bigint(20) unsigned NOT NULL DEFAULT '0',
`name` varchar(50) NOT NULL DEFAULT '',
`text` longtext,
`time` varchar(255) NOT NULL,
`annouced` tinyint(3) unsigned NOT NULL DEFAULT '0',
`sticked` tinyint(3) unsigned NOT NULL DEFAULT '0',
`closed` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

--
-- Dumping data for table `mm_forum_posts`
--

LOCK
TABLES `mm_forum_posts` WRITE;
/*!40000 ALTER TABLE `mm_forum_posts` DISABLE KEYS */;
INSERT INTO `mm_forum_posts`(`id`, `authorid`, `authorname`, `forum`, `topic`, `lastpost`, `name`, `text`, `time`,
`annouced`, `sticked`)
values (1, 0, 'miniManagerTeam', 1, 1, 1, 'Hello Admin!',
'[b]Hi[/b] !!:D<br /><br />If you are reading this, that means that you have [i]correctly[/i] installed this forum, XD<br /><br /><br /><br />So what\' s next?<br /><br />Edit [color=red]forum.conf.php[/color]<br /><br /><br /><br />And enjoy!<br /><br /><br /><br />Report bugs at [url=https://github.com/TrinityCore/minimanager/issues]MiniManager tracker[/url]<br /><br /><br /><br />Bye!<br /><br />miniManagerTeam','00/00/00 00:00:00',1,0);
/*!40000 ALTER TABLE `mm_forum_posts` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `mm_motd`
--

DROP TABLE IF EXISTS `mm_motd`;

CREATE TABLE `mm_motd` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Identifier',
`realmid` int(11) NOT NULL,
`type` longtext NOT NULL,
`content` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='MOTD System';

--
-- Dumping data for table `mm_motd`
--

LOCK TABLES `mm_motd` WRITE;
/*!40000 ALTER TABLE `mm_motd` DISABLE KEYS */;
INSERT INTO `mm_motd` VALUES (1, 1, '02/05/10 14:29:07 Posted by: MiniManager Team', 'Hello Admin\r\n\r\nhelp supporting Minimanager\r\n\r\nhttps://github.com/TrinityCore/minimanager/issues\r\n\r\nif you found a bug or improved it,
please contribute\r\n\r\nor it will eventually stop development from lack of interrest from community ');
/*!40000 ALTER TABLE `mm_motd` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `mm_point_system_invites`
--

DROP TABLE IF EXISTS `mm_point_system_invites`;
CREATE TABLE `mm_point_system_invites` (
`entry` int(11) NOT NULL auto_increment,
`PlayersAccount` char(50) default NULL,
`InvitedBy` char(50) default NULL,
`InviterAccount` char(50) default NULL,
`Treated` int(1) NOT NULL default '0',
`Rewarded` int(1) NOT NULL default '0',
UNIQUE KEY `entry` (`entry`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `mm_account`
--

DROP TABLE IF EXISTS `mm_account`;
CREATE TABLE `mm_account` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(32) NOT NULL DEFAULT '',
`salt` binary(32),
`verifier` binary(32),
`email` text,
`joindate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_ip` varchar(30) NOT NULL DEFAULT '127.0.0.1',
`locked` tinyint(3) unsigned NOT NULL DEFAULT '0',
`expansion` tinyint(3) unsigned NOT NULL DEFAULT '0',
`authkey` varchar(40) DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Accounts pending verification';

DROP TABLE IF EXISTS `mm_password_resets`;
CREATE TABLE `mm_password_resets` (
`token` binary(32) not null,
`accountId` int(11) unsigned not null,
`oldsalt` binary(32),
`salt` binary(32),
`verifier` binary(32),
`time` bigint unsigned,
primary key (`token`)
);
7 changes: 7 additions & 0 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM php:8.0-fpm-alpine
RUN apk update \
apk upgrade;
RUN apk add --upgrade php8-gmp gmp-dev;

RUN docker-php-ext-install mysqli gmp;

1 change: 1 addition & 0 deletions .docker/php/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=php_gmp.so
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
config.php
vendor/
.idea/
9 changes: 9 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ function dobackup()
$row[$j] = preg_replace("/\n/","\\n",$row[$j]);
if (isset($row[$j]))
{
if ($sql->field_type($acc_query,$j) == "int")
if ($sql->field_type($j,$acc_query) == "int")
$result .= "$row[$j]";
else
$result .= "'$row[$j]'" ;
Expand Down Expand Up @@ -550,7 +550,7 @@ function dobackup()

if (isset($row[$j]))
{
if ($sql->field_type($char_query,$j) == "int")
if ($sql->field_type($j,$char_query) == "int")
$result .= "$row[$j]";
else
$result .= "'$row[$j]'" ;
Expand Down
12 changes: 12 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "trinitycore/minimanager",
"description": "Web portal for TrinityCore emulator",
"type": "project",
"license": "gpl-2.0",
"minimum-stability": "stable",
"require": {
"php": "^7.4|^8.0|^8.1",
"ext-gmp": "*",
"ext-mysqli": "*"
}
}
22 changes: 22 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function do_submit_data ()
{
$output .= '
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\'---></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;---></td>
<td>
<a href="char.php?id='.$char['guid'].'&amp;realm='.$realm['id'].'">'.$char['name'].' -
<img src="img/c_icons/'.$char['race'].'-'.$char['gender'].'.gif" onmousemove="toolTip(\''.char_get_race_name($char['race']).'\', \'item_tooltip\')" onmouseout="toolTip()" alt="" />
Expand All @@ -156,7 +156,7 @@ function do_submit_data ()
{
$output .= '
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\'---></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;---></td>
<td>
<a href="char.php?id='.$char['guid'].'">'.$char['name'].' -
<img src="img/c_icons/'.$char['race'].'-'.$char['gender'].'.gif" onmousemove="toolTip(\''.char_get_race_name($char['race']).'\', \'item_tooltip\')" onmouseout="toolTip()" alt="" />
Expand Down
4 changes: 2 additions & 2 deletions footer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
//hide undefined variables in some cases (some errorpages for ex.)
if (!isset($debug))
error_reporting('E_NONE'); // fuck this, we need a real fix
error_reporting(0); // fuck this, we need a real fix

// level 1 debug prints total queries,
// so we would have to close these, or we can't have debug output
Expand Down Expand Up @@ -40,7 +40,7 @@
</div>
<div id="body_buttom">';
// show login and register button at bottom of every page if guest mode is activated
if($allow_anony && empty($_SESSION['logged_in']))
if($allow_anony && empty($_SESSION['logged_in']) && !strpos($_SERVER["REQUEST_URI"], "login"))
{
$lang_login = lang_login();
$output .= '
Expand Down
7 changes: 3 additions & 4 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@

//---------------------Headers' header-----------------------------------------
// sets encoding defined in config for language support
header('Content-Type: text/html; charset='.$site_encoding);
header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');
header('Content-Type: text/html; charset='.$site_encoding ?? 'utf-8');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
$output .= '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Expand All @@ -96,9 +94,10 @@
<title>'.$title.'</title>
<meta http-equiv="Content-Type" content="text/html; charset='.$site_encoding.'" />
<meta http-equiv="Content-Type" content="text/javascript; charset='.$site_encoding.'" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="themes/'.$theme.'/'.$theme.'_1024.css" title="1024" />
<link rel="stylesheet" type="text/css" href="themes/'.$theme.'/'.$theme.'_1280.css" title="1280" />
<link rel="SHORTCUT ICON" href="img/favicon.ico" />
<link rel="icon" href="img/favicon.ico" />
<script type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="libs/js/general.js"></script>
<script type="text/javascript" src="libs/js/layout.js"></script>
Expand Down
18 changes: 11 additions & 7 deletions libs/db_lib/mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function connect($db_host, $db_username, $db_password, $db_name = NULL, $use_nam

if ($this->link_id){
if (!empty($use_names)) $this->query("SET NAMES '$use_names'");
} else die($lang_global['err_sql_conn_db']);
} else die($lang_global['err_sql_conn_db'] . " DB: {$db_name}");
}

function db($db_name) {
Expand Down Expand Up @@ -93,11 +93,11 @@ function free_result($query_id = false){
return ($query_id) ? @mysqli_free_result($query_id) : false;
}

function field_type($query_id = 0,$field_offset){
function field_type($field_offset, $query_id = 0){
return false; //TODO
}

function field_name($query_id = 0,$field_offset){
function field_name($field_offset,$query_id = 0){
return false; //TODO
}

Expand All @@ -118,11 +118,11 @@ function close(){
global $tot_queries;
$tot_queries += $this->num_queries;
if ($this->link_id){
if ($this->query_result) @mysqli_free_result($this->query_result);
return @mysqli_close($this->link_id);
if ($this->query_result instanceof mysqli_result) mysqli_free_result($this->query_result);
return mysqli_close($this->link_id);
} else return false;
}

function start_transaction(){
return;
}
Expand All @@ -131,4 +131,8 @@ function end_transaction(){
return;
}
}
?>
?>




2 changes: 1 addition & 1 deletion libs/db_lib/sql_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function sql_table_dump ($dbhost, $dbuser, $dbpass, $database, $table, $construc
$row[$j] = addslashes($row[$j]);
$row[$j] = preg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) {
if ($sql_0->field_type($query,$j) == "int") fwrite($fp, "$row[$j]")or die (error($lang_backup['file_write_err']));
if ($sql_0->field_type($j,$query) == "int") fwrite($fp, "$row[$j]")or die (error($lang_backup['file_write_err']));
else fwrite($fp, "'$row[$j]'")or die (error($lang_backup['file_write_err']));
}else fwrite($fp, "''")or die (error($lang_backup['file_write_err']));
if ($j<($num_fields-1)) fwrite($fp, ",")or die (error($lang_backup['file_write_err']));
Expand Down
2 changes: 1 addition & 1 deletion logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

if (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') === false)
{
header('Location: https://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\').'/login.php');
header('Location: //'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\').'/login.php');
exit();
}
else
Expand Down
Loading

0 comments on commit cea2297

Please sign in to comment.