This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
/
class.UpdateController.php
178 lines (151 loc) · 6.64 KB
/
class.UpdateController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/
defined('AJXP_EXEC') or die( 'Access not allowed');
/**
* @package AjaXplorer_Plugins
* @subpackage Action
*/
class UpdateController extends AJXP_Plugin
{
public function init($options)
{
parent::init($options);
$u = AuthService::getLoggedUser();
if($u == null) return;
if ($u->getGroupPath() != "/") {
$this->enabled = false;
}
}
/**
* Parse
* @param DOMNode $contribNode
*/
protected function parseSpecificContributions(&$contribNode)
{
parent::parseSpecificContributions($contribNode);
if($this->pluginConf["ENABLE_324_IMPORT"] == true) return;
if($contribNode->nodeName != "actions") return ;
$actionXpath=new DOMXPath($contribNode->ownerDocument);
$compressNodeList = $actionXpath->query('action[@name="import_from_324"]', $contribNode);
if(!$compressNodeList->length) return ;
$compressNode = $compressNodeList->item(0);
$contribNode->removeChild($compressNode);
$compressNodeList = $actionXpath->query('action[@name="migrate_metaserial"]', $contribNode);
if(!$compressNodeList->length) return ;
$compressNode = $compressNodeList->item(0);
$contribNode->removeChild($compressNode);
}
public function switchAction($action, $httpVars, $fileVars)
{
$loggedUser = AuthService::getLoggedUser();
if(AuthService::usersEnabled() && !$loggedUser->isAdmin()) return ;
require_once(AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/action.updater/class.AjaXplorerUpgrader.php");
if (!empty($this->pluginConf["PROXY_HOST"]) || !empty($this->pluginConf["UPDATE_SITE_USER"])) {
AjaXplorerUpgrader::configureProxy(
$this->pluginConf["PROXY_HOST"],
$this->pluginConf["PROXY_USER"],
$this->pluginConf["PROXY_PASS"],
$this->pluginConf["UPDATE_SITE_USER"],
$this->pluginConf["UPDATE_SITE_PASS"]
);
}
switch ($action) {
case "migrate_metaserial":
$dryRun = !isSet($httpVars["real_run"]);
AjaXplorerUpgrader::migrateMetaSerialPlugin($httpVars["repository_id"], $dryRun);
break;
case "get_upgrade_path":
header("Content-type: application/json");
print AjaXplorerUpgrader::getUpgradePath($this->pluginConf["UPDATE_SITE"], "json", $this->pluginConf["UPDATE_CHANNEL"]);
break;
case "display_upgrade_note":
$url = $httpVars["url"];
$context = AjaXplorerUpgrader::getContext();
if($context != null){
$content = file_get_contents($url, null, $context);
}else{
$content = file_get_contents($url);
}
echo $content;
break;
case "test_upgrade_scripts":
if(!AJXP_SERVER_DEBUG
|| AuthService::getLoggedUser() == null
|| !AuthService::getLoggedUser()->isAdmin()){
break;
}
$upgrader = new AjaXplorerUpgrader("", "", "");
$upgrader->testUpgradeScripts();
break;
case "perform_upgrade" :
AJXP_Utils::safeIniSet("output_buffering", "Off");
if (AJXP_PACKAGING != "zip") {
$lang = ConfService::getLanguage();
$file = $this->getBaseDir()."/howto/linux_en.html";
if($lang != "en" && is_file($this->getBaseDir()."/howto/linux_$lang.html")){
$file = $this->getBaseDir()."/howto/linux_$lang.html";
}
$content = file_get_contents($file);
print $content;
break;
}
$res = AjaXplorerUpgrader::getUpgradePath($this->pluginConf["UPDATE_SITE"], "php", $this->pluginConf["UPDATE_CHANNEL"]);
if (!count($res["packages"])) {
print("No update is necessary!");
break;
}
include(dirname(__FILE__)."/output_head.html");
foreach ($res["packages"] as $index => $zipPackage) {
print("<div class='main_step'>Applying upgrade ".basename($zipPackage)."</div>");
$u = new AjaXplorerUpgrader(
$zipPackage,
$res["hashes"][$index],
$res["hash_method"],
explode(",",$this->pluginConf["PRESERVE_FILES"])
);
$errors = false;
while ($u->hasNextStep()) {
set_time_limit(180);
print("<div class='upgrade_step'><div class='upgrade_title'>".$u->currentStepTitle."</div>");
$u->execute();
if ($u->error != null) {
print("<div class='upgrade_result error'>- Error : ".$u->error."</div>");
$errors = true;
break;
} else {
print("<div class='upgrade_result success'>- ".$u->result."</div>");
}
print("</div>");
// FLUSH OUTPUT, SCROLL DOWN
print str_repeat(' ',300);
print('<script type="text/javascript">doScroll();</script>');
flush();
sleep(0.5);
}
if($errors) break;
}
print('<script type="text/javascript">replaceTop();</script>');
print str_repeat(' ',300);
flush();
break;
}
}
}