Index: trunk/admin/include/functions_upgrade.php
===================================================================
--- trunk/admin/include/functions_upgrade.php	(revision 1075)
+++ trunk/admin/include/functions_upgrade.php	(revision 1075)
@@ -0,0 +1,44 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch        : BSF (Best So Far)
+// | file          : $RCSfile$
+// | last update   : $Date: 2006-03-09 00:14:53 +0100 (jeu., 09 mars 2006) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1070 $
+// +-----------------------------------------------------------------------+
+// | 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.                                                                  |
+// +-----------------------------------------------------------------------+
+
+function check_upgrade()
+{
+  // Is PhpWebGallery already installed ?
+  if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
+  {
+    $message = 'PhpWebGallery is not in upgrade mode. In include/mysql.inc.php,
+insert line
+<pre style="background-color:lightgray">
+define(\'PHPWG_IN_UPGRADE\', true);
+</pre>
+if you want to upgrade';
+    die($message);
+  }
+}
+
+
+?>
Index: trunk/include/common.inc.php
===================================================================
--- trunk/include/common.inc.php	(revision 1074)
+++ trunk/include/common.inc.php	(revision 1075)
@@ -3,5 +3,5 @@
 // | PhpWebGallery - a PHP based picture gallery                           |
 // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
@@ -133,5 +133,38 @@
 or die ( "Could not connect to database" );
 
-if ($conf['check_upgrade_feed'])
+//
+// Setup gallery wide options, if this fails then we output a CRITICAL_ERROR
+// since basic gallery information is not available
+//
+$query = '
+SELECT param,value
+ FROM '.CONFIG_TABLE.'
+;';
+if (!($result = pwg_query($query)))
+{
+  die("Could not query config information");
+}
+
+while ( $row =mysql_fetch_array( $result ) )
+{
+  if ( isset( $row['value'] ) )
+  {
+    $conf[$row['param']] = $row['value'];
+  }
+  else
+  {
+    $conf[$row['param']] = '';
+  }
+  // If the field is true or false, the variable is transformed into a
+  // boolean value.
+  if ( $conf[$row['param']] == 'true' or $conf[$row['param']] == 'false' )
+  {
+    $conf[$row['param']] = get_boolean( $conf[$row['param']] );
+  }
+}
+
+include(PHPWG_ROOT_PATH.'include/user.inc.php');
+
+if (is_admin() and $conf['check_upgrade_feed'])
 {
   // retrieve already applied upgrades
@@ -158,37 +191,4 @@
 }
 
-//
-// Setup gallery wide options, if this fails then we output a CRITICAL_ERROR
-// since basic gallery information is not available
-//
-$query = '
-SELECT param,value
- FROM '.CONFIG_TABLE.'
-;';
-if (!($result = pwg_query($query)))
-{
-  die("Could not query config information");
-}
-
-while ( $row =mysql_fetch_array( $result ) )
-{
-  if ( isset( $row['value'] ) )
-  {
-    $conf[$row['param']] = $row['value'];
-  }
-  else
-  {
-    $conf[$row['param']] = '';
-  }
-  // If the field is true or false, the variable is transformed into a
-  // boolean value.
-  if ( $conf[$row['param']] == 'true' or $conf[$row['param']] == 'false' )
-  {
-    $conf[$row['param']] = get_boolean( $conf[$row['param']] );
-  }
-}
-
-include(PHPWG_ROOT_PATH.'include/user.inc.php');
-
 // language files
 include_once(get_language_filepath('common.lang.php'));
Index: trunk/include/functions_user.inc.php
===================================================================
--- trunk/include/functions_user.inc.php	(revision 1074)
+++ trunk/include/functions_user.inc.php	(revision 1075)
@@ -3,5 +3,5 @@
 // | PhpWebGallery - a PHP based picture gallery                           |
 // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
@@ -278,4 +278,6 @@
 function calculate_permissions($user_id, $user_status)
 {
+  global $user;
+
   $private_array = array();
   $authorized_array = array();
@@ -293,5 +295,5 @@
 
   // if user is not an admin, locked categories can be considered as private$
-  if (!is_admin())
+  if (!is_admin($user_status))
   {
     $query = '
@@ -542,34 +544,36 @@
  * @return bool
 */
-function is_autorize_status($access_type)
+function is_autorize_status($access_type, $user_status = '')
 {
   global $user;
 
+  if (($user_status == '') and isset($user['status']))
+  {
+    $user_status = $user['status'];
+  }
+
   $access_type_status = ACCESS_NONE;
-  if (isset($user['status']))
-  {
-    switch ($user['status'])
-    {
-      case 'guest':
-      case 'generic':
-      {
-        $access_type_status = ACCESS_GUEST;
-        break;
-      }
-      case 'normal':
-      {
-        $access_type_status = ACCESS_CLASSIC;
-        break;
-      }
-      case 'admin':
-      {
-        $access_type_status = ACCESS_ADMINISTRATOR;
-        break;
-      }
-      case 'webmaster':
-      {
-        $access_type_status = ACCESS_WEBMASTER;
-        break;
-      }
+  switch ($user_status)
+  {
+    case 'guest':
+    case 'generic':
+    {
+      $access_type_status = ACCESS_GUEST;
+      break;
+    }
+    case 'normal':
+    {
+      $access_type_status = ACCESS_CLASSIC;
+      break;
+    }
+    case 'admin':
+    {
+      $access_type_status = ACCESS_ADMINISTRATOR;
+      break;
+    }
+    case 'webmaster':
+    {
+      $access_type_status = ACCESS_WEBMASTER;
+      break;
     }
   }
@@ -584,9 +588,9 @@
  * @return none
 */
-function check_status($access_type)
+function check_status($access_type, $user_status = '')
 {
   global $lang;
 
-  if (!is_autorize_status($access_type))
+  if (!is_autorize_status($access_type, $user_status))
   {
     echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />';
@@ -600,7 +604,7 @@
  * @return bool
 */
-function is_admin()
-{
-  return is_autorize_status(ACCESS_ADMINISTRATOR);
+function is_admin($user_status = '')
+{
+  return is_autorize_status(ACCESS_ADMINISTRATOR, $user_status);
 }
 
Index: trunk/upgrade.php
===================================================================
--- trunk/upgrade.php	(revision 1074)
+++ trunk/upgrade.php	(revision 1075)
@@ -3,5 +3,5 @@
 // | PhpWebGallery - a PHP based picture gallery                           |
 // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
@@ -33,15 +33,9 @@
 
 include(PHPWG_ROOT_PATH.'include/mysql.inc.php');
-// Is PhpWebGallery already installed ?
-if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
-{
-  $message = 'PhpWebGallery is not in upgrade mode. In include/mysql.inc.php,
-insert line
-<pre style="background-color:lightgray">
-define(\'PHPWG_IN_UPGRADE\', true);
-</pre>
-if you want to upgrade';
-  die($message);
-}
+
+// +-----------------------------------------------------------------------+
+// | Check Access and exit when it is not ok                               |
+// +-----------------------------------------------------------------------+
+check_upgrade();
 
 // concerning upgrade, we use the default users table
Index: trunk/upgrade_feed.php
===================================================================
--- trunk/upgrade_feed.php	(revision 1074)
+++ trunk/upgrade_feed.php	(revision 1075)
@@ -3,5 +3,5 @@
 // | PhpWebGallery - a PHP based picture gallery                           |
 // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
 // +-----------------------------------------------------------------------+
 // | branch        : BSF (Best So Far)
@@ -30,6 +30,12 @@
 include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');
 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php');
 include(PHPWG_ROOT_PATH.'include/template.php');
 include(PHPWG_ROOT_PATH.'include/mysql.inc.php');
+
+// +-----------------------------------------------------------------------+
+// | Check Access and exit when it is not ok                               |
+// +-----------------------------------------------------------------------+
+check_upgrade();
 
 define('PREFIX_TABLE', $prefixeTable);
