Index: /extensions/autoupdate/trunk/autoupdate.php
===================================================================
--- /extensions/autoupdate/trunk/autoupdate.php	(revision 6195)
+++ /extensions/autoupdate/trunk/autoupdate.php	(revision 6196)
@@ -1,3 +1,5 @@
 <?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
 include(AUTOUPDATE_PATH.'include/functions.inc.php');
@@ -27,5 +29,8 @@
   if (preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches))
   {
-    if (@fetchRemote(PHPWG_URL.'/download/all_versions.php', $result)
+    $url = PHPWG_URL.'/download/all_versions.php';
+    $url .= '?rand='.md5(uniqid(rand(), true)); // Avoid server cache
+
+    if (@fetchRemote($url, $result)
       and $all_versions = @explode("\n", $result)
       and is_array($all_versions))
@@ -88,5 +93,5 @@
 // |                                Step 2                                 |
 // +-----------------------------------------------------------------------+
-if ($step == 2)
+if ($step == 2 and is_webmaster())
 {
   if (isset($_POST['submit']) and isset($_POST['upgrade_to']))
@@ -99,7 +104,7 @@
 // |                                Step 3                                 |
 // +-----------------------------------------------------------------------+
-if ($step == 3)
+if ($step == 3 and is_webmaster())
 {
-  if (isset($_POST['saveTemplate']))
+  if (isset($_POST['saveTemplate']) and version_compare(PHPWG_VERSION, '2.1', '<'))
   {
     autoupdate_save_template_dir();
@@ -121,9 +126,15 @@
 // +-----------------------------------------------------------------------+
 
+if (!is_webmaster())
+{
+  array_push($page['errors'], l10n('Webmaster status is required.'));
+}
+
 $template->assign(array(
-  'STEP'        => $step,
-  'AU_URL'      => get_admin_plugin_menu_link(AUTOUPDATE_PATH . '/autoupdate.php'),
-  'UPGRADE_TO'  => $upgrade_to,
-  'RELEASE_URL' => PHPWG_URL.'/releases/'.$upgrade_to,
+  'STEP'          => $step,
+  'AU_URL'        => get_admin_plugin_menu_link(AUTOUPDATE_PATH . '/autoupdate.php'),
+  'PHPWG_VERSION' => PHPWG_VERSION,
+  'UPGRADE_TO'    => $upgrade_to,
+  'RELEASE_URL'   => PHPWG_URL.'/releases/'.$upgrade_to,
   )
 );
Index: /extensions/autoupdate/trunk/include/functions.inc.php
===================================================================
--- /extensions/autoupdate/trunk/include/functions.inc.php	(revision 6195)
+++ /extensions/autoupdate/trunk/include/functions.inc.php	(revision 6196)
@@ -1,5 +1,7 @@
 <?php
 
-function autoupdate_deltree($path)
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+function autoupdate_deltree($path, $move_to_trash=false)
 {
   if (is_dir($path))
@@ -13,5 +15,5 @@
         if (is_dir($pathfile))
         {
-          autoupdate_deltree($pathfile);
+          autoupdate_deltree($pathfile, $move_to_trash);
         }
         else
@@ -22,5 +24,21 @@
     }
     closedir($fh);
-    return @rmdir($path);
+    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;
+    }
   }
 }
@@ -65,5 +83,5 @@
       elseif (is_dir($path))
       {
-        autoupdate_deltree($path);
+        autoupdate_deltree($path, true);
       }
     }
@@ -399,4 +417,12 @@
 }
 
+if (!function_exists('is_webmaster'))
+{
+  function is_webmaster($user_status = '')
+  {
+    return is_autorize_status(ACCESS_WEBMASTER, $user_status);
+  }
+}
+
 define('AU_DEFAULT_INDEX', file_get_contents(AUTOUPDATE_PATH.'index.php'));
 ?>
Index: /extensions/autoupdate/trunk/include/functions_remote.inc.php
===================================================================
--- /extensions/autoupdate/trunk/include/functions_remote.inc.php	(revision 6195)
+++ /extensions/autoupdate/trunk/include/functions_remote.inc.php	(revision 6196)
@@ -1,3 +1,5 @@
 <?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
 function autoupdate_check_version($version=PHPWG_VERSION)
Index: /extensions/autoupdate/trunk/language/cs_CZ/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/cs_CZ/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/cs_CZ/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 /*TODO*/$lang['Some themes and plugins may be not available yet.'] = 'Some themes and plugins may be not available yet.';
 /*TODO*/$lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).';
-/*TODO*/$lang['First Step'] = 'First Step';
-/*TODO*/$lang['Second Step'] = 'Second Step';
-/*TODO*/$lang['Third Step'] = 'Third Step';
+/*TODO*/$lang['autoupdate_step_1'] = 'First Step';
+/*TODO*/$lang['autoupdate_step_2'] = 'Second Step';
+/*TODO*/$lang['autoupdate_step_3'] = 'Third Step';
 /*TODO*/$lang['Save Template Directory'] = 'Save template directory';
 /*TODO*/$lang['Dump Database'] = 'Dump Database';
Index: /extensions/autoupdate/trunk/language/de_DE/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/de_DE/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/de_DE/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 $lang['Some themes and plugins may be not available yet.'] = 'Einige Themen und Plugins sind dadurch nicht mehr verwendbar.';
 $lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'Sie können direkt auf Version %s aktualisieren und Version %s überspringen (empfohlen).';
-$lang['First Step'] = 'Erster Schritt';
-$lang['Second Step'] = 'Zweiter Schritt';
-$lang['Third Step'] = 'Dritter Schritt';
+$lang['autoupdate_step_1'] = 'Erster Schritt';
+$lang['autoupdate_step_2'] = 'Zweiter Schritt';
+$lang['autoupdate_step_3'] = 'Dritter Schritt';
 $lang['Save Template Directory'] = 'Sichere den Templateordner';
 $lang['Dump Database'] = 'Exportiere die Datenbank';
Index: /extensions/autoupdate/trunk/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/en_UK/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/en_UK/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 $lang['Some themes and plugins may be not available yet.'] = 'Some themes and plugins may be not available yet.';
 $lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).';
-$lang['First Step'] = 'First Step';
-$lang['Second Step'] = 'Second Step';
-$lang['Third Step'] = 'Third Step';
+$lang['autoupdate_step_1'] = 'First Step';
+$lang['autoupdate_step_2'] = 'Second Step';
+$lang['autoupdate_step_3'] = 'Third Step';
 $lang['Save Template Directory'] = 'Save template directory';
 $lang['Dump Database'] = 'Dump Database';
Index: /extensions/autoupdate/trunk/language/es_ES/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/es_ES/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/es_ES/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 $lang['Some themes and plugins may be not available yet.'] = 'Algunos temas y plugins pueden no estar disponibles todavía.';
 $lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'Puede actualizar a Piwigo% s directamente, sin actualizar a Piwigo %s (recomendado).';
-$lang['First Step'] = 'Primer paso';
-$lang['Second Step'] = 'Segundo Paso';
-$lang['Third Step'] = 'Tercer paso';
+$lang['autoupdate_step_1'] = 'Primer paso';
+$lang['autoupdate_step_2'] = 'Segundo Paso';
+$lang['autoupdate_step_3'] = 'Tercer paso';
 $lang['Save Template Directory'] = 'Guardar directorio de plantillas';
 $lang['Dump Database'] = 'Volcar la base de datos';
Index: /extensions/autoupdate/trunk/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/fr_FR/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/fr_FR/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 $lang['Some themes and plugins may be not available yet.'] = 'Certains thèmes ou plugins ne sont peut-être pas encore disponibles.';
 $lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'Vous pouvez mettre à jour vers Piwigo %s directement, sans passer par Piwigo %s (recommandé).';
-$lang['First Step'] = 'Première étape';
-$lang['Second Step'] = 'Deuxième étape';
-$lang['Third Step'] = 'Troisième étape';
+$lang['autoupdate_step_1'] = 'Première étape';
+$lang['autoupdate_step_2'] = 'Deuxième étape';
+$lang['autoupdate_step_3'] = 'Troisième étape';
 $lang['Save Template Directory'] = 'Sauvegarder le dossier template';
 $lang['Dump Database'] = 'Sauvegarder la base de données';
Index: /extensions/autoupdate/trunk/language/hr_HR/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/hr_HR/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/hr_HR/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 /*TODO*/$lang['Some themes and plugins may be not available yet.'] = 'Some themes and plugins may be not available yet.';
 /*TODO*/$lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).';
-/*TODO*/$lang['First Step'] = 'First Step';
-/*TODO*/$lang['Second Step'] = 'Second Step';
-/*TODO*/$lang['Third Step'] = 'Third Step';
+/*TODO*/$lang['autoupdate_step_1'] = 'First Step';
+/*TODO*/$lang['autoupdate_step_2'] = 'Second Step';
+/*TODO*/$lang['autoupdate_step_3'] = 'Third Step';
 /*TODO*/$lang['Save Template Directory'] = 'Save template directory';
 /*TODO*/$lang['Dump Database'] = 'Dump Database';
Index: /extensions/autoupdate/trunk/language/hu_HU/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/hu_HU/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/hu_HU/plugin.lang.php	(revision 6196)
@@ -29,7 +29,7 @@
 $lang['Some themes and plugins may be not available yet.'] = 'Lehet, hogy néhány téma és bővítmény még nem áll rendelkezésre.';
 $lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'Lehetősége van közvetlenül frissíteni a Piwigo %s verziójára, kihagyva a Piwigo %s verzióját (ajánlott).';
-$lang['First Step'] = 'Első lépés';
-$lang['Second Step'] = 'Második lépés';
-$lang['Third Step'] = 'Harmadik lépés';
+$lang['autoupdate_step_1'] = 'Első lépés';
+$lang['autoupdate_step_2'] = 'Második lépés';
+$lang['autoupdate_step_3'] = 'Harmadik lépés';
 $lang['Save Template Directory'] = 'Template könyvtár mentése';
 $lang['Dump Database'] = 'Adatbázis mentése';
Index: /extensions/autoupdate/trunk/language/it_IT/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/it_IT/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/it_IT/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 $lang['Some themes and plugins may be not available yet.'] = 'Alcuni temi e plugin possono non essere ancora disponibili.';
 $lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'E\' possibile aggiornare a Piwigo %s direttamente, senza passare a Piwigo %s (consigliato).';
-$lang['First Step'] = 'Primo passo';
-$lang['Second Step'] = 'Secondo passo';
-$lang['Third Step'] = 'Terzo passo';
+$lang['autoupdate_step_1'] = 'Primo passo';
+$lang['autoupdate_step_2'] = 'Secondo passo';
+$lang['autoupdate_step_3'] = 'Terzo passo';
 $lang['Save Template Directory'] = 'Salvare la template directory';
 $lang['Dump Database'] = 'Salvare Database';
Index: /extensions/autoupdate/trunk/language/ja_JP/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/ja_JP/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/ja_JP/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 /*TODO*/$lang['Some themes and plugins may be not available yet.'] = 'Some themes and plugins may be not available yet.';
 /*TODO*/$lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).';
-/*TODO*/$lang['First Step'] = 'First Step';
-/*TODO*/$lang['Second Step'] = 'Second Step';
-/*TODO*/$lang['Third Step'] = 'Third Step';
+/*TODO*/$lang['autoupdate_step_1'] = 'First Step';
+/*TODO*/$lang['autoupdate_step_2'] = 'Second Step';
+/*TODO*/$lang['autoupdate_step_3'] = 'Third Step';
 /*TODO*/$lang['Save Template Directory'] = 'Save template directory';
 /*TODO*/$lang['Dump Database'] = 'Dump Database';
Index: /extensions/autoupdate/trunk/language/nl_NL/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/nl_NL/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/nl_NL/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 $lang['Some themes and plugins may be not available yet.'] = 'Sommige thema\'s en plugins zijn mogelijk nog niet beschikbaar.';
 $lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'U kunt direct upgraden naar Piwigo versie %s, zonder eerst te upgraden naar Piwigo versie %s (aanbevolen).';
-$lang['First Step'] = 'Eerste stap';
-$lang['Second Step'] = 'Tweede stap';
-$lang['Third Step'] = 'Derde stap';
+$lang['autoupdate_step_1'] = 'Eerste stap';
+$lang['autoupdate_step_2'] = 'Tweede stap';
+$lang['autoupdate_step_3'] = 'Derde stap';
 $lang['Save Template Directory'] = 'Bewaar de template directory';
 $lang['Dump Database'] = 'Dump de database';
Index: /extensions/autoupdate/trunk/language/pl_PL/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/pl_PL/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/pl_PL/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 /*TODO*/$lang['Some themes and plugins may be not available yet.'] = 'Some themes and plugins may be not available yet.';
 /*TODO*/$lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).';
-/*TODO*/$lang['First Step'] = 'First Step';
-/*TODO*/$lang['Second Step'] = 'Second Step';
-/*TODO*/$lang['Third Step'] = 'Third Step';
+/*TODO*/$lang['autoupdate_step_1'] = 'First Step';
+/*TODO*/$lang['autoupdate_step_2'] = 'Second Step';
+/*TODO*/$lang['autoupdate_step_3'] = 'Third Step';
 /*TODO*/$lang['Save Template Directory'] = 'Save template directory';
 /*TODO*/$lang['Dump Database'] = 'Dump Database';
Index: /extensions/autoupdate/trunk/language/ru_RU/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/ru_RU/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/ru_RU/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 /*TODO*/$lang['Some themes and plugins may be not available yet.'] = 'Some themes and plugins may be not available yet.';
 /*TODO*/$lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).';
-/*TODO*/$lang['First Step'] = 'First Step';
-/*TODO*/$lang['Second Step'] = 'Second Step';
-/*TODO*/$lang['Third Step'] = 'Third Step';
+/*TODO*/$lang['autoupdate_step_1'] = 'First Step';
+/*TODO*/$lang['autoupdate_step_2'] = 'Second Step';
+/*TODO*/$lang['autoupdate_step_3'] = 'Third Step';
 /*TODO*/$lang['Save Template Directory'] = 'Save template directory';
 /*TODO*/$lang['Dump Database'] = 'Dump Database';
Index: /extensions/autoupdate/trunk/language/vi_VN/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/vi_VN/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/vi_VN/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 $lang['Some themes and plugins may be not available yet.'] = 'M?t s? themes và plugins có th? chua dùng du?c.';
 $lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'B?n có th? nâng c?p tr?c ti?p lên phiên b?n Piwigo %s, mà không c?n ph?i nâng c?p t? phiên b?n %s (khuy?n cáo).';
-$lang['First Step'] = 'Bu?c th? nh?t';
-$lang['Second Step'] = 'Bu?c th? 2';
-$lang['Third Step'] = 'Bu?c th? 3';
+$lang['autoupdate_step_1'] = 'Bu?c th? nh?t';
+$lang['autoupdate_step_2'] = 'Bu?c th? 2';
+$lang['autoupdate_step_3'] = 'Bu?c th? 3';
 $lang['Save Template Directory'] = 'Luu l?i template c?a thu m?c';
 $lang['Dump Database'] = 'T?o b?n sao co s? d? li?u';
Index: /extensions/autoupdate/trunk/language/zh_CN/plugin.lang.php
===================================================================
--- /extensions/autoupdate/trunk/language/zh_CN/plugin.lang.php	(revision 6195)
+++ /extensions/autoupdate/trunk/language/zh_CN/plugin.lang.php	(revision 6196)
@@ -28,7 +28,7 @@
 $lang['Some themes and plugins may be not available yet.'] = '一些主题和插件也许还未能用.';
 $lang['You can upgrade to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = '您可以直接升级到 Piwigo %s , 而并不需要先升级到 Piwigo %s (recommended).';
-$lang['First Step'] = '第一步';
-$lang['Second Step'] = '第二步';
-$lang['Third Step'] = '第三步';
+$lang['autoupdate_step_1'] = '第一步';
+$lang['autoupdate_step_2'] = '第二步';
+$lang['autoupdate_step_3'] = '第三步';
 $lang['Save Template Directory'] = '保存模板目录';
 $lang['Dump Database'] = '转存数据库';
Index: /extensions/autoupdate/trunk/maintain.inc.php
===================================================================
--- /extensions/autoupdate/trunk/maintain.inc.php	(revision 6195)
+++ /extensions/autoupdate/trunk/maintain.inc.php	(revision 6196)
@@ -15,5 +15,5 @@
 }
 
-function plugin_deactivate()
+function plugin_uninstall()
 {
   global $prefixeTable;
Index: /extensions/autoupdate/trunk/plugins_update.php
===================================================================
--- /extensions/autoupdate/trunk/plugins_update.php	(revision 6195)
+++ /extensions/autoupdate/trunk/plugins_update.php	(revision 6196)
@@ -1,3 +1,5 @@
 <?php
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
 function autoupdate_plugins_update_filter($content, &$smarty)
Index: /extensions/autoupdate/trunk/template/autoupdate.tpl
===================================================================
--- /extensions/autoupdate/trunk/template/autoupdate.tpl	(revision 6195)
+++ /extensions/autoupdate/trunk/template/autoupdate.tpl	(revision 6196)
@@ -56,17 +56,26 @@
 </p>
 <form action="" method="post">
+
+{if version_compare($PHPWG_VERSION, '2.1', '<')}
+{counter assign=i}
 <fieldset>
-  <legend>{'First Step'|@translate}</legend>
+  <legend>{'autoupdate_step_'|cat:$i|@translate}</legend>
   <p><input type="submit" name="saveTemplate" value="{'Save Template Directory'|@translate}"></p>
 </fieldset>
+{/if}
+
+{counter assign=i}
 <fieldset>
-  <legend>{'Second Step'|@translate}</legend>
+  <legend>{'autoupdate_step_'|cat:$i|@translate}</legend>
   <p><input type="checkbox" name="includeHistory"> &nbsp; {'Include history data (Warning: server memory limit may be exceeded)'|@translate}</p>
   <p><input type="submit" name="dumpDatabase" value="{'Dump Database'|@translate}"></p>
 </fieldset>
+
+{counter assign=i}
 <fieldset>
-  <legend>{'Third Step'|@translate|@sprintf:$UPGRADE_TO}</legend>
+  <legend>{'autoupdate_step_'|cat:$i|@translate}</legend>
   <p><input type="submit" name="submit" value="{'Upgrade to Piwigo %s'|@translate|@sprintf:$UPGRADE_TO}" onClick="return confirm('{'autoupdate_alert'|@translate}');"></p>
 </fieldset>
+
 <p><input type="hidden" name="upgrade_to" value="{$UPGRADE_TO}"></p>
 </form>
