1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Xmf\Database\Tables; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Upgrade from 2.5.10 to 2.5.11 |
7
|
|
|
* |
8
|
|
|
* @copyright (c) 2000-2021 XOOPS Project (https://xoops.org) |
9
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
10
|
|
|
* @package Upgrade |
11
|
|
|
* @since 2.5.11 |
12
|
|
|
* @author XOOPS Team |
13
|
|
|
*/ |
14
|
|
|
class Upgrade_2511 extends XoopsUpgrade |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* __construct |
18
|
|
|
*/ |
19
|
|
|
public function __construct() |
20
|
|
|
{ |
21
|
|
|
parent::__construct(basename(__DIR__)); |
22
|
|
|
$this->tasks = array( |
23
|
|
|
'bannerintsize', |
24
|
|
|
'qmail', |
25
|
|
|
); |
26
|
|
|
$this->usedFiles = array(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Determine if columns are declared mediumint, and if |
32
|
|
|
* so, queue ddl to alter to int. |
33
|
|
|
* |
34
|
|
|
* @param $migrate \Xmf\Database\Tables |
35
|
|
|
* @param $bannerTableName string |
36
|
|
|
* @param $bannerColumnNames string[] array of columns to check |
37
|
|
|
* |
38
|
|
|
* @return integer count of queue items added |
39
|
|
|
*/ |
40
|
|
|
protected function fromMediumToInt(Tables $migrate, $bannerTableName, $bannerColumnNames) |
41
|
|
|
{ |
42
|
|
|
$migrate->useTable($bannerTableName); |
43
|
|
|
$count = 0; |
44
|
|
|
foreach ($bannerColumnNames as $column) { |
45
|
|
|
$attributes = $migrate->getColumnAttributes($bannerTableName, $column); |
46
|
|
|
if (0 === strpos(trim($attributes), 'mediumint')) { |
|
|
|
|
47
|
|
|
$count++; |
48
|
|
|
$migrate->alterColumn($bannerTableName, $column, 'int(10) UNSIGNED NOT NULL DEFAULT \'0\''); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
return $count; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
private $bannerTableName = 'banner'; |
55
|
|
|
private $bannerColumnNames = array('impmade', 'clicks'); |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Increase count columns from mediumint to int |
59
|
|
|
* |
60
|
|
|
* @return bool true if patch IS applied, false if NOT applied |
61
|
|
|
*/ |
62
|
|
|
public function check_bannerintsize() |
63
|
|
|
{ |
64
|
|
|
$migrate = new Tables(); |
65
|
|
|
$count = $this->fromMediumToInt($migrate, $this->bannerTableName, $this->bannerColumnNames); |
66
|
|
|
|
67
|
|
|
return $count==0; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Increase count columns from mediumint to int (Think BIG!) |
72
|
|
|
* |
73
|
|
|
* @return bool true if applied, false if failed |
74
|
|
|
*/ |
75
|
|
|
public function apply_bannerintsize() |
76
|
|
|
{ |
77
|
|
|
$migrate = new \Xmf\Database\Tables(); |
78
|
|
|
|
79
|
|
|
$count = $this->fromMediumToInt($migrate, $this->bannerTableName, $this->bannerColumnNames); |
80
|
|
|
|
81
|
|
|
$result = $migrate->executeQueue(true); |
82
|
|
|
if (false === $result) { |
83
|
|
|
$this->logs[] = sprintf('Migration of %s table failed. Error: %s - %s' . |
84
|
|
|
$this->bannerTableName, |
85
|
|
|
$migrate->getLastErrNo(), |
86
|
|
|
$migrate->getLastError() |
87
|
|
|
); |
88
|
|
|
return false; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $count!==0; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Add qmail as valid mailmethod |
96
|
|
|
* |
97
|
|
|
* @return bool |
98
|
|
|
*/ |
99
|
|
|
public function check_qmail() |
100
|
|
|
{ |
101
|
|
|
/* @var XoopsMySQLDatabase $db */ |
102
|
|
|
$db = XoopsDatabaseFactory::getDatabaseConnection(); |
103
|
|
|
|
104
|
|
|
$table = $db->prefix('configoption'); |
105
|
|
|
|
106
|
|
|
$sql = sprintf( |
107
|
|
|
'SELECT count(*) FROM `%s` ' |
108
|
|
|
. "WHERE `conf_id` = 64 AND `confop_name` = 'qmail'", |
109
|
|
|
$db->escape($table) |
110
|
|
|
); |
111
|
|
|
|
112
|
|
|
/** @var mysqli_result $result */ |
113
|
|
|
$result = $db->query($sql); |
114
|
|
|
if ($result) { |
|
|
|
|
115
|
|
|
$row = $db->fetchRow($result); |
116
|
|
|
if ($row) { |
117
|
|
|
$count = $row[0]; |
118
|
|
|
return (0 === (int) $count) ? false : true; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
return false; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Add qmail as valid mailmethod |
126
|
|
|
* |
127
|
|
|
* phpMailer has qmail support, similar to but slightly different than sendmail |
128
|
|
|
* This will allow webmasters to utilize qmail if it is provisioned on server. |
129
|
|
|
* |
130
|
|
|
* @return bool |
131
|
|
|
*/ |
132
|
|
|
public function apply_qmail() |
133
|
|
|
{ |
134
|
|
|
$migrate = new Tables(); |
135
|
|
|
$migrate->useTable('configoption'); |
136
|
|
|
$migrate->insert( |
137
|
|
|
'configoption', |
138
|
|
|
array('confop_name' => 'qmail', 'confop_value' => 'qmail', 'conf_id' => 64) |
139
|
|
|
); |
140
|
|
|
return $migrate->executeQueue(true); |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
return new Upgrade_2511(); |
145
|
|
|
|