1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
// |
5
|
|
|
// ------------------------------------------------------------------------ // |
6
|
|
|
// XOOPS - PHP Content Management System // |
7
|
|
|
// Copyright (c) 2000-2020 XOOPS.org // |
8
|
|
|
// <https://xoops.org> // |
9
|
|
|
// ------------------------------------------------------------------------ // |
10
|
|
|
// This program is free software; you can redistribute it and/or modify // |
11
|
|
|
// it under the terms of the GNU General Public License as published by // |
12
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
13
|
|
|
// (at your option) any later version. // |
14
|
|
|
// // |
15
|
|
|
// You may not change or alter any portion of this comment or credits // |
16
|
|
|
// of supporting developers from this source code or any supporting // |
17
|
|
|
// source code which is considered copyrighted (c) material of the // |
18
|
|
|
// original comment or credit authors. // |
19
|
|
|
// // |
20
|
|
|
// This program is distributed in the hope that it will be useful, // |
21
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
22
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
23
|
|
|
// GNU General Public License for more details. // |
24
|
|
|
// // |
25
|
|
|
// You should have received a copy of the GNU General Public License // |
26
|
|
|
// along with this program; if not, write to the Free Software // |
27
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
28
|
|
|
// ------------------------------------------------------------------------ // |
29
|
|
|
// Author: Kazumi Ono (AKA onokazu) // |
30
|
|
|
// URL: http://www.myweb.ne.jp/, https://xoops.org/, http://jp.xoops.org/ // |
31
|
|
|
// Project: XOOPS Project // |
32
|
|
|
// ------------------------------------------------------------------------- // |
33
|
|
|
use Xmf\Request; |
34
|
|
|
use Xmf\Module\Admin; |
35
|
|
|
use XoopsModules\Tdmdownloads\{ |
36
|
|
|
Common\Configurator, |
37
|
|
|
Common\Migrate, |
38
|
|
|
Helper |
39
|
|
|
}; |
40
|
|
|
|
41
|
|
|
/** @var Admin $adminObject */ |
42
|
|
|
/** @var Configurator $configurator */ |
43
|
|
|
/** @var Migrate $migrator */ |
44
|
|
|
require __DIR__ . '/admin_header.php'; |
45
|
|
|
xoops_cp_header(); |
46
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
47
|
|
|
echo <<<EOF |
48
|
|
|
<form method="post" class="form-inline"> |
49
|
|
|
<div class="form-group"> |
50
|
|
|
<input name="show" class="btn btn-default" type="submit" value="Show SQL"> |
51
|
|
|
</div> |
52
|
|
|
<div class="form-group"> |
53
|
|
|
<input name="migrate" class="btn btn-default" type="submit" value="Do Migration"> |
54
|
|
|
</div> |
55
|
|
|
<div class="form-group"> |
56
|
|
|
<input name="schema" class="btn btn-default" type="submit" value="Write Schema"> |
57
|
|
|
</div> |
58
|
|
|
</form> |
59
|
|
|
EOF; |
60
|
|
|
//XoopsLoad::load('migrate', 'newbb'); |
61
|
|
|
$configurator = new Configurator(); |
62
|
|
|
$migrator = new Migrate($configurator); |
|
|
|
|
63
|
|
|
$op = Request::getCmd('op', 'show'); |
64
|
|
|
$opShow = Request::getCmd('show', null, 'POST'); |
65
|
|
|
$opMigrate = Request::getCmd('migrate', null, 'POST'); |
66
|
|
|
$opSchema = Request::getCmd('schema', null, 'POST'); |
67
|
|
|
$op = !empty($opShow) ? 'show' : $op; |
68
|
|
|
$op = !empty($opMigrate) ? 'migrate' : $op; |
69
|
|
|
$op = !empty($opSchema) ? 'schema' : $op; |
70
|
|
|
$message = ''; |
71
|
|
|
switch ($op) { |
72
|
|
|
case 'show': |
73
|
|
|
default: |
74
|
|
|
$queue = $migrator->getSynchronizeDDL(); |
75
|
|
|
if (!empty($queue)) { |
76
|
|
|
echo "<pre>\n"; |
77
|
|
|
foreach ($queue as $line) { |
78
|
|
|
echo $line . ";\n"; |
79
|
|
|
} |
80
|
|
|
echo "</pre>\n"; |
81
|
|
|
} |
82
|
|
|
break; |
83
|
|
|
case 'migrate': |
84
|
|
|
$migrator->synchronizeSchema(); |
85
|
|
|
$message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_OK'); |
86
|
|
|
break; |
87
|
|
|
case 'schema': |
88
|
|
|
xoops_confirm(['op' => 'confirmwrite'], 'migrate.php', constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_WARNING'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM')); |
89
|
|
|
break; |
90
|
|
|
case 'confirmwrite': |
91
|
|
|
if ($GLOBALS['xoopsSecurity']->check()) { |
92
|
|
|
$migrator->saveCurrentSchema(); |
93
|
|
|
$message = constant('CO_' . $moduleDirNameUpper . '_' . 'MIGRATE_SCHEMA_OK'); |
94
|
|
|
} |
95
|
|
|
break; |
96
|
|
|
} |
97
|
|
|
echo "<div>$message</div>"; |
98
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
99
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.