1
|
|
|
<?php
|
2
|
|
|
/*
|
3
|
|
|
You may not change or alter any portion of this comment or credits
|
4
|
|
|
of supporting developers from this source code or any supporting source code
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors.
|
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful,
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
10
|
|
|
*/
|
11
|
|
|
|
12
|
|
|
/**
|
13
|
|
|
* Wggithub module for xoops
|
14
|
|
|
*
|
15
|
|
|
* @param mixed $module
|
16
|
|
|
* @param null|mixed $prev_version
|
17
|
|
|
* @package Wggithub
|
18
|
|
|
* @since 1.0
|
19
|
|
|
* @min_xoops 2.5.9
|
20
|
|
|
* @author Wedega - Email:<[email protected]> - Website:<https://wedega.com>
|
21
|
|
|
* @version $Id: 1.0 update.php 1 Mon 2018-03-19 10:04:53Z XOOPS Project (www.xoops.org) $
|
22
|
|
|
* @copyright module for xoops
|
23
|
|
|
* @license GPL 2.0 or later
|
24
|
|
|
*/
|
25
|
|
|
|
26
|
|
|
/**
|
27
|
|
|
* @param $module
|
28
|
|
|
* @param null $prev_version
|
|
|
|
|
29
|
|
|
*
|
30
|
|
|
* @return bool|null
|
31
|
|
|
*/
|
32
|
|
|
function xoops_module_update_wggithub($module, $prev_version = null)
|
|
|
|
|
33
|
|
|
{
|
34
|
|
|
//wggithub_check_db($module);
|
35
|
|
|
|
36
|
|
|
//check upload directory
|
37
|
|
|
include_once __DIR__ . '/install.php';
|
38
|
|
|
xoops_module_install_wggithub($module);
|
39
|
|
|
|
40
|
|
|
$errors = $module->getErrors();
|
41
|
|
|
if (!empty($errors)) {
|
42
|
|
|
print_r($errors);
|
43
|
|
|
}
|
44
|
|
|
|
45
|
|
|
return true;
|
46
|
|
|
|
47
|
|
|
}
|
48
|
|
|
|
49
|
|
|
/**
|
50
|
|
|
* @param $module
|
51
|
|
|
*
|
52
|
|
|
* @return bool
|
53
|
|
|
*/
|
54
|
|
|
function wggithub_check_db($module)
|
55
|
|
|
{
|
56
|
|
|
$ret = true;
|
57
|
|
|
//insert here code for database check
|
58
|
|
|
|
59
|
|
|
// update table (add new field)
|
60
|
|
|
$table = $GLOBALS['xoopsDB']->prefix('wggithub_repositories');
|
61
|
|
|
$field = 'repo_release';
|
62
|
|
|
$check = $GLOBALS['xoopsDB']->queryF('SHOW COLUMNS FROM `' . $table . "` LIKE '" . $field . "'");
|
63
|
|
|
$numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
|
64
|
|
|
if (!$numRows) {
|
65
|
|
|
$sql = "ALTER TABLE `$table` ADD `$field` INT(1) NOT NULL DEFAULT '0' AFTER `repo_htmlurl`;";
|
66
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
|
|
|
|
|
67
|
|
|
xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
|
|
|
|
|
68
|
|
|
$module->setErrors("Error when adding '$field' to table '$table'.");
|
69
|
|
|
$ret = false;
|
70
|
|
|
}
|
71
|
|
|
}
|
72
|
|
|
|
73
|
|
|
// update table (add new field)
|
74
|
|
|
$table = $GLOBALS['xoopsDB']->prefix('wggithub_repositories');
|
75
|
|
|
$field = 'repo_prerelease';
|
76
|
|
|
$check = $GLOBALS['xoopsDB']->queryF('SHOW COLUMNS FROM `' . $table . "` LIKE '" . $field . "'");
|
77
|
|
|
$numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
|
78
|
|
|
if (!$numRows) {
|
79
|
|
|
$sql = "ALTER TABLE `$table` ADD `$field` INT(1) NOT NULL DEFAULT '0' AFTER `repo_htmlurl`;";
|
80
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
|
81
|
|
|
xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
|
82
|
|
|
$module->setErrors("Error when adding '$field' to table '$table'.");
|
83
|
|
|
$ret = false;
|
84
|
|
|
}
|
85
|
|
|
}
|
86
|
|
|
// update table (add new field)
|
87
|
|
|
$table = $GLOBALS['xoopsDB']->prefix('wggithub_repositories');
|
88
|
|
|
$field = 'repo_readme';
|
89
|
|
|
$check = $GLOBALS['xoopsDB']->queryF('SHOW COLUMNS FROM `' . $table . "` LIKE '" . $field . "'");
|
90
|
|
|
$numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
|
91
|
|
|
if (!$numRows) {
|
92
|
|
|
$sql = "ALTER TABLE `$table` ADD `$field` INT(1) NOT NULL DEFAULT '0' AFTER `repo_htmlurl`;";
|
93
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
|
94
|
|
|
xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
|
95
|
|
|
$module->setErrors("Error when adding '$field' to table '$table'.");
|
96
|
|
|
$ret = false;
|
97
|
|
|
}
|
98
|
|
|
}
|
99
|
|
|
|
100
|
|
|
// update table (add new field)
|
101
|
|
|
$table = $GLOBALS['xoopsDB']->prefix('wggithub_directories');
|
102
|
|
|
$field = 'dir_filterrelease';
|
103
|
|
|
$check = $GLOBALS['xoopsDB']->queryF('SHOW COLUMNS FROM `' . $table . "` LIKE '" . $field . "'");
|
104
|
|
|
$numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
|
105
|
|
|
if (!$numRows) {
|
106
|
|
|
$sql = "ALTER TABLE `$table` ADD `$field` INT(1) NOT NULL DEFAULT '0' AFTER `dir_online`;";
|
107
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
|
108
|
|
|
xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
|
109
|
|
|
$module->setErrors("Error when adding '$field' to table '$table'.");
|
110
|
|
|
$ret = false;
|
111
|
|
|
}
|
112
|
|
|
}
|
113
|
|
|
|
114
|
|
|
// create new table
|
115
|
|
|
$table = $GLOBALS['xoopsDB']->prefix('wggithub_logs');
|
116
|
|
|
$check = $GLOBALS['xoopsDB']->queryF("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='$table'");
|
117
|
|
|
$numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
|
118
|
|
|
if (!$numRows) {
|
119
|
|
|
// create new table
|
120
|
|
|
$sql = "CREATE TABLE `$table` (
|
121
|
|
|
`log_id` INT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
|
122
|
|
|
`log_type` INT(1) NOT NULL DEFAULT '0',
|
123
|
|
|
`log_details` VARCHAR(255) NOT NULL DEFAULT '',
|
124
|
|
|
`log_result` TEXT NOT NULL ,
|
125
|
|
|
`log_datecreated` INT(11) NOT NULL DEFAULT '0',
|
126
|
|
|
`log_submitter` INT(10) NOT NULL DEFAULT '0',
|
127
|
|
|
PRIMARY KEY (`log_id`)
|
128
|
|
|
) ENGINE=InnoDB;";
|
129
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
|
130
|
|
|
xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
|
131
|
|
|
$module->setErrors("Error when creating table '$table'.");
|
132
|
|
|
$ret = false;
|
133
|
|
|
}
|
134
|
|
|
}
|
135
|
|
|
|
136
|
|
|
// update table (add new field)
|
137
|
|
|
$table = $GLOBALS['xoopsDB']->prefix('wggithub_directories');
|
138
|
|
|
$field = 'dir_content';
|
139
|
|
|
$check = $GLOBALS['xoopsDB']->queryF('SHOW COLUMNS FROM `' . $table . "` LIKE '" . $field . "'");
|
140
|
|
|
$numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
|
141
|
|
|
if (!$numRows) {
|
142
|
|
|
$sql = "ALTER TABLE `$table` ADD `$field` INT(10) NOT NULL DEFAULT '0' AFTER `dir_type`;";
|
143
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
|
144
|
|
|
xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
|
145
|
|
|
$module->setErrors("Error when adding '$field' to table '$table'.");
|
146
|
|
|
$ret = false;
|
147
|
|
|
}
|
148
|
|
|
}
|
149
|
|
|
|
150
|
|
|
// update table (add new field)
|
151
|
|
|
$table = $GLOBALS['xoopsDB']->prefix('wggithub_directories');
|
152
|
|
|
$field = 'dir_descr';
|
153
|
|
|
$check = $GLOBALS['xoopsDB']->queryF('SHOW COLUMNS FROM `' . $table . "` LIKE '" . $field . "'");
|
154
|
|
|
$numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
|
155
|
|
|
if (!$numRows) {
|
156
|
|
|
$sql = "ALTER TABLE `$table` ADD `$field` TEXT NOT NULL AFTER `dir_type`;";
|
157
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
|
158
|
|
|
xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
|
159
|
|
|
$module->setErrors("Error when adding '$field' to table '$table'.");
|
160
|
|
|
$ret = false;
|
161
|
|
|
}
|
162
|
|
|
}
|
163
|
|
|
|
164
|
|
|
// update table (add new field)
|
165
|
|
|
$table = $GLOBALS['xoopsDB']->prefix('wggithub_readmes');
|
166
|
|
|
$field = 'rm_baseurl';
|
167
|
|
|
$check = $GLOBALS['xoopsDB']->queryF('SHOW COLUMNS FROM `' . $table . "` LIKE '" . $field . "'");
|
168
|
|
|
$numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
|
169
|
|
|
if (!$numRows) {
|
170
|
|
|
$sql = "ALTER TABLE `$table` ADD `$field` VARCHAR(255) NOT NULL DEFAULT '' AFTER `rm_downloadurl`;";
|
171
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
|
172
|
|
|
xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
|
173
|
|
|
$module->setErrors("Error when adding '$field' to table '$table'.");
|
174
|
|
|
$ret = false;
|
175
|
|
|
}
|
176
|
|
|
}
|
177
|
|
|
|
178
|
|
|
// update table (add new field)
|
179
|
|
|
$table = $GLOBALS['xoopsDB']->prefix('wggithub_directories');
|
180
|
|
|
$field = 'dir_weight';
|
181
|
|
|
$check = $GLOBALS['xoopsDB']->queryF('SHOW COLUMNS FROM `' . $table . "` LIKE '" . $field . "'");
|
182
|
|
|
$numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
|
183
|
|
|
if (!$numRows) {
|
184
|
|
|
$sql = "ALTER TABLE `$table` ADD `$field` INT(10) NOT NULL DEFAULT '0' AFTER `dir_filterrelease`;";
|
185
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
|
186
|
|
|
xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
|
187
|
|
|
$module->setErrors("Error when adding '$field' to table '$table'.");
|
188
|
|
|
$ret = false;
|
189
|
|
|
}
|
190
|
|
|
}
|
191
|
|
|
|
192
|
|
|
// update table (add new field)
|
193
|
|
|
$table = $GLOBALS['xoopsDB']->prefix('wggithub_repositories');
|
194
|
|
|
$field = 'repo_approved';
|
195
|
|
|
$check = $GLOBALS['xoopsDB']->queryF('SHOW COLUMNS FROM `' . $table . "` LIKE '" . $field . "'");
|
196
|
|
|
$numRows = $GLOBALS['xoopsDB']->getRowsNum($check);
|
197
|
|
|
if (!$numRows) {
|
198
|
|
|
$sql = "ALTER TABLE `$table` ADD `$field` INT(1) NOT NULL DEFAULT '0' AFTER `repo_release`;";
|
199
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
|
200
|
|
|
xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
|
201
|
|
|
$module->setErrors("Error when adding '$field' to table '$table'.");
|
202
|
|
|
$ret = false;
|
203
|
|
|
}
|
204
|
|
|
}
|
205
|
|
|
|
206
|
|
|
return $ret;
|
207
|
|
|
}
|
208
|
|
|
|