|
| 1 | +<?php |
| 2 | +/* |
| 3 | + * Copyright 2007-2016 Abstrium <contact (at) pydio.com> |
| 4 | + * This file is part of Pydio. |
| 5 | + * |
| 6 | + * Pydio is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU Affero General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * Pydio is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU Affero General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Affero General Public License |
| 17 | + * along with Pydio. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + * |
| 19 | + * The latest code can be found at <https://pydio.com/>. |
| 20 | + */ |
| 21 | + |
| 22 | +/** |
| 23 | + * @param string $version |
| 24 | + * @throws Exception |
| 25 | + */ |
| 26 | +function checkPhpVersion($version){ |
| 27 | + if(version_compare(PHP_VERSION, $version) < 0){ |
| 28 | + throw new Exception("For Pydio 7, PHP version must be greater or equal to $version, detected version is ".PHP_VERSION." - Upgrade aborted."); |
| 29 | + }else{ |
| 30 | + echo "<div class='upgrade_result success'>- Checking Php Version (".PHP_VERSION.") : OK</div>"; |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +/** |
| 35 | + * @param string $type |
| 36 | + * @param string $name |
| 37 | + * @throws Exception |
| 38 | + */ |
| 39 | +function checkPluginUsed($type, $name){ |
| 40 | + |
| 41 | + if($type === "conf"){ |
| 42 | + $p = ConfService::getConfStorageImpl(); |
| 43 | + if($p->getName() === $name){ |
| 44 | + throw new Exception("You are currently using $type.$name as configuration storage. This was deprecated in Pydio 6 and is now removed in Pydio7. Aborting upgrade"); |
| 45 | + }else{ |
| 46 | + echo "<div class='upgrade_result success'>- Checking plugin $type ($name) : OK</div>"; |
| 47 | + } |
| 48 | + }else if($type === "auth") { |
| 49 | + $p = ConfService::getAuthDriverImpl(); |
| 50 | + if ($p->getName() === $name) { |
| 51 | + throw new Exception("You are currently using $type.$name for authentication backend. This was deprecated in Pydio 6 and is now removed in Pydio7. Aborting upgrade"); |
| 52 | + } else { |
| 53 | + if ($p->getName() === "multi") { |
| 54 | + $drivers = $p->drivers; |
| 55 | + if (isSet($drivers[$name])) { |
| 56 | + throw new Exception("You are currently using $type.$name for authentication backend. This was deprecated in Pydio 6 and is now removed in Pydio7. Aborting upgrade"); |
| 57 | + } else { |
| 58 | + echo "<div class='upgrade_result success'>- Checking plugin $type (" . implode(", ", array_keys($drivers)) . ") : OK</div>"; |
| 59 | + } |
| 60 | + } |
| 61 | + echo "<div class='upgrade_result success'>- Checking plugin $type ($name) : OK</div>"; |
| 62 | + } |
| 63 | + }else if($type === "access"){ |
| 64 | + |
| 65 | + // Check if a workspace is currently using this plugin |
| 66 | + echo "<div class='upgrade_result success'>- Should check usage of plugin $type ($name) in active workspaces : TODO</div>"; |
| 67 | + |
| 68 | + |
| 69 | + }else{ |
| 70 | + $plugs = AJXP_PluginsService::getInstance()->getActivePluginsForType($type); |
| 71 | + if(isSet($plugs[$name])){ |
| 72 | + throw new Exception("You are currently using plugin $type.$name. This is removed in Pydio7. Please disable it before running upgrade. Aborting upgrade"); |
| 73 | + } |
| 74 | + echo "<div class='upgrade_result success'>- Checking plugin $type ($name) : OK</div>"; |
| 75 | + } |
| 76 | + |
| 77 | +} |
| 78 | + |
| 79 | +/** |
| 80 | + * @param string $themeName |
| 81 | + * @throws Exception |
| 82 | + */ |
| 83 | +function checkThemeUsed($themeName){ |
| 84 | + |
| 85 | + $p = AJXP_PluginsService::getInstance()->findPlugin("gui", "ajax"); |
| 86 | + $options = $p->getConfigs(); |
| 87 | + if(isSet($options["GUI_THEME"]) && $options["GUI_THEME"] === $themeName){ |
| 88 | + throw new Exception("You are currently using theme ".$options["GUI_THEME"]." which was removed from Pydio 7. If you want to be able to upgrade, you have to switch to Orbit theme. Aborting upgrade."); |
| 89 | + }else{ |
| 90 | + echo "<div class='upgrade_result success'>- Checking usage of remove theme ($themeName): OK</div>"; |
| 91 | + } |
| 92 | + |
| 93 | +} |
| 94 | + |
| 95 | +function blockAllXHRInPage(){ |
| 96 | + print ' |
| 97 | + <script type="text/javascript"> |
| 98 | + (function(open) { |
| 99 | + parent.XMLHttpRequest.prototype.open = function(method, url, async, user, pass) { |
| 100 | + console.error("XHR Call to "+url+" blocked by upgrade process!"); |
| 101 | + }; |
| 102 | + })(parent.XMLHttpRequest.prototype.open); |
| 103 | + </script> |
| 104 | + <div class="upgrade_result success">Blocking all XHR in page: OK</div> |
| 105 | + '; |
| 106 | +} |
| 107 | + |
| 108 | +blockAllXHRInPage(); |
| 109 | +if(defined('AJXP_PACKAGE_NAME') && AJXP_PACKAGE_NAME === 'pydio-enterprise'){ |
| 110 | + checkPhpVersion('5.6.0'); |
| 111 | +}else{ |
| 112 | + checkPhpVersion('5.5.9'); |
| 113 | +} |
| 114 | +if(AJXP_VERSION === '6.4.2'){ |
| 115 | + checkPluginUsed("conf", "serial"); |
| 116 | + checkPluginUsed("auth", "serial"); |
| 117 | + checkPluginUsed("auth", "cmsms"); |
| 118 | + checkPluginUsed("access", "remote_fs"); |
| 119 | + checkThemeUsed("vision"); |
| 120 | + checkThemeUsed("umbra"); |
| 121 | +} |
0 commit comments