aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/updates.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/include/updates.class.php')
-rw-r--r--admin/include/updates.class.php103
1 files changed, 41 insertions, 62 deletions
diff --git a/admin/include/updates.class.php b/admin/include/updates.class.php
index 0ec0e0c40..2ab70d2be 100644
--- a/admin/include/updates.class.php
+++ b/admin/include/updates.class.php
@@ -1,4 +1,25 @@
<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program 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 |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
@@ -33,7 +54,7 @@ class updates
}
}
- function check_piwigo_upgrade()
+ static function check_piwigo_upgrade()
{
$_SESSION['need_update'] = null;
@@ -161,7 +182,7 @@ class updates
{
if (in_array($ext_id, $conf['updates_ignored'][$type]))
{
- array_push($ignore_list, $ext_id);
+ $ignore_list[] = $ext_id;
}
else
{
@@ -242,54 +263,13 @@ class updates
return $this->$type->$version_compare($a, $b);
}
- function deltree($path, $move_to_trash=false)
- {
- if (is_dir($path))
- {
- $fh = opendir($path);
- while ($file = readdir($fh))
- {
- if ($file != '.' and $file != '..')
- {
- $pathfile = $path . '/' . $file;
- if (is_dir($pathfile))
- {
- self::deltree($pathfile, $move_to_trash);
- }
- else
- {
- @unlink($pathfile);
- }
- }
- }
- closedir($fh);
- if (@rmdir($path))
- {
- return true;
- }
- elseif ($move_to_trash)
- {
- $trash = PHPWG_ROOT_PATH.'_trash';
- if (!is_dir($trash))
- {
- @mkgetdir($trash);
- }
- return @rename($path, $trash . '/'.md5(uniqid(rand(), true)));
- }
- else
- {
- return false;
- }
- }
- }
-
- function process_obsolete_list($file)
+ static function process_obsolete_list($file)
{
if (file_exists(PHPWG_ROOT_PATH.$file)
and $old_files = file(PHPWG_ROOT_PATH.$file, FILE_IGNORE_NEW_LINES)
and !empty($old_files))
{
- array_push($old_files, $file);
+ $old_files[] = $file;
foreach($old_files as $old_file)
{
$path = PHPWG_ROOT_PATH.$old_file;
@@ -299,13 +279,13 @@ class updates
}
elseif (is_dir($path))
{
- self::deltree($path, true);
+ deltree($path, PHPWG_ROOT_PATH.'_trash');
}
}
}
}
- function dump_database($include_history=false)
+ static function dump_database($include_history=false)
{
global $page, $conf, $cfgBase;
@@ -350,16 +330,16 @@ class updates
}
@readfile($backupFile);
- self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
+ deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
exit();
}
else
{
- array_push($page['errors'], l10n('Unable to dump database.'));
+ $page['errors'][] = l10n('Unable to dump database.');
}
}
- function upgrade_to($upgrade_to, &$step, $check_current_version=true)
+ static function upgrade_to($upgrade_to, &$step, $check_current_version=true)
{
global $page, $conf, $template;
@@ -449,13 +429,14 @@ class updates
if (empty($error))
{
self::process_obsolete_list($obsolete_list);
- self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
+ deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
invalidate_user_cache(true);
$template->delete_compiled_templates();
unset($_SESSION['need_update']);
if ($step == 2)
{
- array_push($page['infos'], l10n('Update Complete'), $upgrade_to);
+ $page['infos'][] = l10n('Update Complete');
+ $page['infos'][] = $upgrade_to;
$step = -1;
}
else
@@ -466,24 +447,22 @@ class updates
else
{
file_put_contents(PHPWG_ROOT_PATH.$conf['data_location'].'update/log_error.txt', $error);
- array_push(
- $page['errors'],
- sprintf(
- l10n('An error has occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.'),
- get_root_url().$conf['data_location'].'update/log_error.txt'
- )
- );
+
+ $page['errors'][] = l10n(
+ 'An error has occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.',
+ get_root_url().$conf['data_location'].'update/log_error.txt'
+ );
}
}
else
{
- self::deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
- array_push($page['errors'], l10n('An error has occured during upgrade.'));
+ deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
+ $page['errors'][] = l10n('An error has occured during upgrade.');
}
}
else
{
- array_push($page['errors'], l10n('Piwigo cannot retrieve upgrade file from server'));
+ $page['errors'][] = l10n('Piwigo cannot retrieve upgrade file from server');
}
}
}