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