Index: /branches/2.1/include/functions.inc.php
===================================================================
--- /branches/2.1/include/functions.inc.php	(revision 6668)
+++ /branches/2.1/include/functions.inc.php	(revision 6669)
@@ -33,16 +33,4 @@
 
 //----------------------------------------------------------- generic functions
-function get_extra_fields($order_by_fields)
-{
-  $fields = str_ireplace(array(' order by ', ' desc', ' asc'),
-			 array('', '', ''),
-			 $order_by_fields
-			 );
-  if (!empty($fields))
-  {
-    $fields = ','.$fields;
-  }
-  return $fields;
-}
 
 // The function get_moment returns a float value coresponding to the number
@@ -584,5 +572,5 @@
   global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug;
 
-  if (!isset($lang_info))
+  if (!isset($lang_info) || !isset($template) )
   {
     $user = build_user( $conf['guest_id'], true);
@@ -591,8 +579,4 @@
     load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
     $template = new Template(PHPWG_ROOT_PATH.'themes', get_default_theme());
-  }
-  else
-  {
-    $template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme']);
   }
 
Index: /branches/2.1/include/functions_calendar.inc.php
===================================================================
--- /branches/2.1/include/functions_calendar.inc.php	(revision 6668)
+++ /branches/2.1/include/functions_calendar.inc.php	(revision 6669)
@@ -259,5 +259,5 @@
   if ($must_show_list)
   {
-    $query = 'SELECT DISTINCT id '.get_extra_fields($conf['order_by']);
+    $query = 'SELECT DISTINCT id ';
     $query .= ','.$calendar->date_field;
     $query .= $calendar->inner_sql.'
Index: /branches/2.1/include/functions_notification.inc.php
===================================================================
--- /branches/2.1/include/functions_notification.inc.php	(revision 6668)
+++ /branches/2.1/include/functions_notification.inc.php	(revision 6669)
@@ -80,5 +80,5 @@
       if (!empty($end))
       {
-	$query .= '      
+	$query .= '
     AND c.validation_date <= \''.$end.'\'';
       }
@@ -95,5 +95,5 @@
       }
       if (!empty($end))
-      {      
+      {
 	$query .= ' AND date <= \''.$end.'\'';
       }
@@ -620,8 +620,19 @@
 
   $title = l10n_dec('%d new image', '%d new images', $date_detail['nb_elements']);
-  $title .= ' ('.$lang['month'][(int)$exploded_date['tm_mon']].' '.$exploded_date['tm_mday'].')';
+  $title .= ' ('.$lang['month'][1+$exploded_date['tm_mon']].' '.$exploded_date['tm_mday'].')';
 
   return $title;
 }
 
+if(!function_exists("strptime"))
+{
+		function strptime($date, $fmt)
+		{
+			if ($fmt != '%Y-%m-%d %H:%M:%S')
+				die('Invalid strptime format '.$fmt);
+			list($y,$m,$d,$H,$M,$S) = preg_split('/[-: ]/', $date);
+			$res = localtime( mktime($H,$M,$S,$m,$d,$y), true );
+			return $res;
+		}
+ }
 ?>
Index: /branches/2.1/include/section_init.inc.php
===================================================================
--- /branches/2.1/include/section_init.inc.php	(revision 6668)
+++ /branches/2.1/include/section_init.inc.php	(revision 6669)
@@ -290,5 +290,5 @@
     // Main query
     $query = '
-SELECT DISTINCT(image_id)'.get_extra_fields($conf['order_by']).'
+SELECT DISTINCT(image_id)
   FROM '.IMAGE_CATEGORY_TABLE.'
     INNER JOIN '.IMAGES_TABLE.' ON id = image_id
@@ -324,5 +324,5 @@
     {
       $query = '
-SELECT DISTINCT image_id'.get_extra_fields($conf['order_by']).'
+SELECT DISTINCT image_id
   FROM '.IMAGE_CATEGORY_TABLE.' INNER JOIN '.IMAGES_TABLE.' ON image_id=id
   WHERE image_id IN ('.implode(',', $items).')
@@ -441,5 +441,5 @@
 
     $query = '
-SELECT DISTINCT(id)'.get_extra_fields($conf['order_by']).'
+SELECT DISTINCT(id)
   FROM '.IMAGES_TABLE.'
     INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
@@ -529,5 +529,5 @@
   {
     $query ='
-SELECT DISTINCT(id)'.get_extra_fields($conf['order_by']).'
+SELECT DISTINCT(id)
   FROM '.IMAGES_TABLE.'
     INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
Index: /branches/2.1/themes/default/template/comments.tpl
===================================================================
--- /branches/2.1/themes/default/template/comments.tpl	(revision 6668)
+++ /branches/2.1/themes/default/template/comments.tpl	(revision 6669)
@@ -3,5 +3,5 @@
   <div class="titrePage">
     <ul class="categoryActions">
-      <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
+      <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
     </ul>
     <h2>{'User comments'|@translate}</h2>
Index: /branches/2.1/themes/default/template/notification.tpl
===================================================================
--- /branches/2.1/themes/default/template/notification.tpl	(revision 6668)
+++ /branches/2.1/themes/default/template/notification.tpl	(revision 6669)
@@ -7,5 +7,5 @@
   <div class="titrePage">
     <ul class="categoryActions">
-      <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
+      <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
     </ul>
     <h2>{'Notification'|@translate}</h2>
Index: /branches/2.1/themes/default/template/password.tpl
===================================================================
--- /branches/2.1/themes/default/template/password.tpl	(revision 6668)
+++ /branches/2.1/themes/default/template/password.tpl	(revision 6669)
@@ -3,5 +3,5 @@
   <div class="titrePage">
     <ul class="categoryActions">
-      <li><a href="{$U_HOME}" title="{'Go through the gallery as a visitor'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
+      <li><a href="{$U_HOME}" title="{'Go through the gallery as a visitor'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
     </ul>
     <h2>{'Password forgotten'|@translate}</h2>
Index: /branches/2.1/themes/default/template/tags.tpl
===================================================================
--- /branches/2.1/themes/default/template/tags.tpl	(revision 6668)
+++ /branches/2.1/themes/default/template/tags.tpl	(revision 6669)
@@ -4,12 +4,12 @@
 		<ul class="categoryActions">
 		{if $display_mode == 'letters'}
-			<li><a href="{$U_CLOUD}" title="{'show tag cloud'|@translate}" rel="nofollow"><img src="{$themeconf.icon_dir}/tag_cloud.png" class="button" alt="{'cloud'|@translate}"></a></li>
+			<li><a href="{$U_CLOUD}" title="{'show tag cloud'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/tag_cloud.png" class="button" alt="{'cloud'|@translate}"></a></li>
 		{/if}
 
 		{if $display_mode == 'cloud'}
-			<li><a href="{$U_LETTERS}" title="{'group by letters'|@translate}" rel="nofollow"><img src="{$themeconf.icon_dir}/tag_letters.png" class="button" alt="{'letters'|@translate}"></a></li>
+			<li><a href="{$U_LETTERS}" title="{'group by letters'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/tag_letters.png" class="button" alt="{'letters'|@translate}"></a></li>
 		{/if}
 
-			<li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
+			<li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
 		</ul>
 		<h2>{'Tags'|@translate}</h2>
Index: /branches/2.1/themes/default/template/upload.tpl
===================================================================
--- /branches/2.1/themes/default/template/upload.tpl	(revision 6668)
+++ /branches/2.1/themes/default/template/upload.tpl	(revision 6669)
@@ -9,5 +9,5 @@
   <div class="titrePage">
     <ul class="categoryActions">
-      <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
+      <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
     </ul>
     <h2>{'Upload a picture'|@translate}</h2>
