|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Upgrader index file |
|
4
|
|
|
* |
|
5
|
|
|
* You may not change or alter any portion of this comment or credits |
|
6
|
|
|
* of supporting developers from this source code or any supporting source code |
|
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
8
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
|
13
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html) |
|
14
|
|
|
* @package upgrader |
|
15
|
|
|
* @since 2.3.0 |
|
16
|
|
|
* @author Skalpa Keo <[email protected]> |
|
17
|
|
|
* @author Taiwen Jiang <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
/* @var $xoopsUser XoopsUser */ |
|
20
|
|
|
|
|
21
|
|
|
//Before xoops 2.5.8 the table 'sess_ip' was of type varchar (15). This is a problem for IPv6 addresses because it is longer. The upgrade process would change the column to VARCHAR(45) but it requires login, which is failing. If the user has an IPv6 address, it is converted to short IP during the upgrade. At the end of the upgrade IPV6 works |
|
22
|
|
|
//save current IP |
|
23
|
|
|
$ip = $_SERVER['REMOTE_ADDR']; |
|
24
|
|
|
if (strlen($_SERVER['REMOTE_ADDR']) > 15) { |
|
25
|
|
|
//new IP for upgrade |
|
26
|
|
|
$_SERVER['REMOTE_ADDR'] = '::1'; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
include_once '../mainfile.php'; |
|
30
|
|
|
defined('XOOPS_ROOT_PATH') or die('Bad installation: please add this folder to the XOOPS install you want to upgrade'); |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
$reporting = -1; // 0; |
|
33
|
|
|
if (isset($_GET['debug'])) { |
|
34
|
|
|
$reporting = -1; |
|
35
|
|
|
} |
|
36
|
|
|
error_reporting($reporting); |
|
37
|
|
|
$xoopsLogger->activated = true; |
|
38
|
|
|
$xoopsLogger->enableRendering(); |
|
39
|
|
|
xoops_loadLanguage('logger'); |
|
40
|
|
|
|
|
41
|
|
|
require './class/abstract.php'; |
|
42
|
|
|
require './class/patchstatus.php'; |
|
43
|
|
|
require './class/control.php'; |
|
44
|
|
|
|
|
45
|
|
|
$GLOBALS['error'] = false; |
|
46
|
|
|
$upgradeControl = new UpgradeControl(); |
|
47
|
|
|
|
|
48
|
|
|
$upgradeControl->determineLanguage(); |
|
49
|
|
|
$upgradeControl->buildUpgradeQueue(); |
|
50
|
|
|
|
|
51
|
|
|
ob_start(); |
|
52
|
|
|
global $xoopsUser; |
|
|
|
|
|
|
53
|
|
|
if (!$xoopsUser || !$xoopsUser->isAdmin()) { |
|
54
|
|
|
include_once 'login.php'; |
|
55
|
|
|
} else { |
|
56
|
|
|
$op = Xmf\Request::getCmd('action', ''); |
|
57
|
|
|
if (!$upgradeControl->needUpgrade) { |
|
58
|
|
|
$op = ''; |
|
59
|
|
|
} |
|
60
|
|
|
if (empty($op)) { |
|
61
|
|
|
$upgradeControl->loadLanguage('welcome'); |
|
62
|
|
|
echo _XOOPS_UPGRADE_WELCOME; |
|
63
|
|
|
} else { |
|
64
|
|
|
if (!empty($upgradeControl->needWriteFiles)) { |
|
65
|
|
|
echo '<div class="panel panel-danger">' |
|
66
|
|
|
. '<div class="panel-heading">' . _SET_FILES_WRITABLE . '</div>' |
|
67
|
|
|
. '<div class="panel-body"><ul class="fa-ul">'; |
|
68
|
|
|
foreach ($upgradeControl->needWriteFiles as $file) { |
|
69
|
|
|
echo '<li><i class="fa-li fa fa-ban text-danger"></i>' . $file . '</li>'; |
|
70
|
|
|
$GLOBALS['error'] = true; |
|
71
|
|
|
} |
|
72
|
|
|
echo '</ul></div></div>'; |
|
73
|
|
|
} else { |
|
74
|
|
|
$next = $upgradeControl->getNextPatch(); |
|
75
|
|
|
printf('<h2>' . _PERFORMING_UPGRADE . '</h2>', $next); |
|
76
|
|
|
/** @var $upgrader XoopsUpgrade */ |
|
77
|
|
|
$upgradeClass = $upgradeControl->upgradeQueue[$next]->patchClass; |
|
78
|
|
|
$upgrader = new $upgradeClass(); |
|
79
|
|
|
$res = $upgrader->apply(); |
|
80
|
|
|
if ($message = $upgrader->message()) { |
|
81
|
|
|
echo '<div class="well">' . $message . '</div>'; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
if ($res) { |
|
85
|
|
|
$upgradeControl->upgradeQueue[$next]->applied = true; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
if (0 === $upgradeControl->countUpgradeQueue()) { |
|
90
|
|
|
echo $upgradeControl->oneButtonContinueForm( |
|
91
|
|
|
XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=system', |
|
92
|
|
|
array() |
|
93
|
|
|
); |
|
94
|
|
|
} else { |
|
95
|
|
|
echo $upgradeControl->oneButtonContinueForm(); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
$content = ob_get_contents(); |
|
99
|
|
|
ob_end_clean(); |
|
100
|
|
|
|
|
101
|
|
|
include_once 'upgrade_tpl.php'; |
|
102
|
|
|
|
PHP has two types of connecting operators (logical operators, and boolean operators):
and&&or||The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&, or||.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
dieintroduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrowat this point:These limitations lead to logical operators rarely being of use in current PHP code.