Index: trunk/include/config_default.inc.php
===================================================================
--- trunk/include/config_default.inc.php	(revision 1040)
+++ trunk/include/config_default.inc.php	(revision 1041)
@@ -94,4 +94,8 @@
 $conf['rate'] = true;
 
+// rate_anonymous : visitors are able to rate pictures (requires 
+// $conf['rate'] set to true)
+$conf['rate_anonymous'] = true;
+
 // newcat_default_commentable : at creation, must a category be commentable
 // or not ?
Index: trunk/include/section_init.inc.php
===================================================================
--- trunk/include/section_init.inc.php	(revision 1040)
+++ trunk/include/section_init.inc.php	(revision 1041)
@@ -209,5 +209,5 @@
         array(
           'title' => $lang['favorites'],
-          'items' => array_from_query($query, 'id'),
+          'items' => array_from_query($query, 'image_id'),
           'thumbnails_include' => 'include/category_default.inc.php',
           )
Index: trunk/install/db/7-database.php
===================================================================
--- trunk/install/db/7-database.php	(revision 1041)
+++ trunk/install/db/7-database.php	(revision 1041)
@@ -0,0 +1,70 @@
+<?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 |
+// | Copyright (C) 2006 Ruben ARNAUD - team@phpwebgallery.net              |
+// +-----------------------------------------------------------------------+
+// | branch        : BSF (Best So Far)
+// | file          : $RCSfile$
+// | last update   : $Date: 2005-09-21 00:04:57 +0200 (mer, 21 sep 2005) $
+// | last modifier : $Author: plg $
+// | revision      : $Revision: 870 $
+// +-----------------------------------------------------------------------+
+// | 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!');
+}
+
+$upgrade_description = 'Anonymous rating';
+
+// +-----------------------------------------------------------------------+
+// |                            Upgrade content                            |
+// +-----------------------------------------------------------------------+
+
+$query = '
+ALTER TABLE '.PREFIX_TABLE.'rate DROP PRIMARY KEY;'
+;
+pwg_query($query);
+
+$query ='
+ALTER TABLE '.PREFIX_TABLE.'rate ADD COLUMN anonymous_id VARCHAR(45) NOT NULL DEFAULT \'\' AFTER element_id;'
+;
+pwg_query($query);
+
+$query ='
+ALTER TABLE '.PREFIX_TABLE.'rate ADD COLUMN date DATE NOT NULL AFTER rate;'
+;
+pwg_query($query);
+
+$query ='
+UPDATE '.PREFIX_TABLE.'rate SET date=NOW() WHERE date<"1990-01-01";'
+;
+pwg_query($query);
+
+$query = '
+ALTER TABLE '.PREFIX_TABLE.'rate ADD PRIMARY KEY (element_id, user_id, anonymous_id);'
+;
+pwg_query($query);
+
+echo
+"\n"
+.'Table '.PREFIX_TABLE.'rate upgraded'
+."\n"
+;
+?>
Index: trunk/install/phpwebgallery_structure.sql
===================================================================
--- trunk/install/phpwebgallery_structure.sql	(revision 1040)
+++ trunk/install/phpwebgallery_structure.sql	(revision 1041)
@@ -174,6 +174,8 @@
   `user_id` smallint(5) NOT NULL default '0',
   `element_id` mediumint(8) unsigned NOT NULL default '0',
+  `anonymous_id` varchar(45) NOT NULL default '',
   `rate` tinyint(2) unsigned NOT NULL default '0',
-  PRIMARY KEY  (`user_id`,`element_id`)
+  `date` date NOT NULL default '0000-00-00',
+  PRIMARY KEY  (`element_id`,`user_id`,`anonymous_id`)
 ) TYPE=MyISAM;
 
Index: trunk/picture.php
===================================================================
--- trunk/picture.php	(revision 1040)
+++ trunk/picture.php	(revision 1041)
@@ -70,5 +70,5 @@
         PHPWG_ROOT_PATH.'picture.php'.
         get_query_string_diff(
-          array('image_id', 'add_fav', 'slideshow', 'rate')
+          array('image_id', 'add_fav', 'slideshow')
           ).
         '&amp;image_id='.$page['items'][ $page['first_rank'] ],
@@ -90,5 +90,5 @@
         PHPWG_ROOT_PATH.'picture.php'.
         get_query_string_diff(
-          array('image_id', 'add_fav', 'slideshow', 'rate')
+          array('image_id', 'add_fav', 'slideshow')
           ).
         '&amp;image_id='.$page['items'][ $page['last_rank'] ],
@@ -144,168 +144,79 @@
 }
 
-//---------------------------------------------------------- related categories
-$query = '
-SELECT category_id,uppercats,commentable,global_rank
-  FROM '.IMAGE_CATEGORY_TABLE.'
-    INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
-  WHERE image_id = '.$_GET['image_id'].'
-    AND category_id NOT IN ('.$user['forbidden_categories'].')
-;';
-$result = pwg_query($query);
-$related_categories = array();
-while ($row = mysql_fetch_array($result))
-{
-  array_push($related_categories, $row);
-}
-usort($related_categories, 'global_rank_compare');
-//------------------------------------- prev, current & next picture management
-$picture = array();
-
-$ids = array($_GET['image_id']);
-if (isset($page['previous_item']))
-{
-  array_push($ids, $page['previous_item']);
-}
-if (isset($page['next_item']))
-{
-  array_push($ids, $page['next_item']);
-}
-
-$query = '
-SELECT *
-  FROM '.IMAGES_TABLE.'
-  WHERE id IN ('.implode(',', $ids).')
-;';
-
-$result = pwg_query($query);
-
-while ($row = mysql_fetch_array($result))
-{
-  if (isset($page['previous_item']) and $row['id'] == $page['previous_item'])
-  {
-    $i = 'prev';
-  }
-  else if (isset($page['next_item']) and $row['id'] == $page['next_item'])
-  {
-    $i = 'next';
-  }
-  else
-  {
-    $i = 'current';
-  }
-  
-  foreach (array_keys($row) as $key)
-  {
-    if (!is_numeric($key))
-    {
-      $picture[$i][$key] = $row[$key];
-    }
-  }
-
-  $picture[$i]['is_picture'] = false;
-  if (in_array(get_extension($row['file']), $conf['picture_ext']))
-  {
-    $picture[$i]['is_picture'] = true;
-  }
-  
-  $cat_directory = dirname($row['path']);
-  $file_wo_ext = get_filename_wo_extension($row['file']);
-
-  $icon = get_themeconf('mime_icon_dir');
-  $icon.= strtolower(get_extension($row['file'])).'.png';
-
-  if (isset($row['representative_ext']) and $row['representative_ext'] != '')
-  {
-    $picture[$i]['src'] =
-      $cat_directory.'/pwg_representative/'
-      .$file_wo_ext.'.'.$row['representative_ext'];
-  }
-  else
-  {
-    $picture[$i]['src'] = $icon;
-  }
-  // special case for picture files
-  if ($picture[$i]['is_picture'])
-  {
-    $picture[$i]['src'] = $row['path'];
-    // if we are working on the "current" element, we search if there is a
-    // high quality picture
-    if ($i == 'current')
-    {
-      if ($row['has_high']=='true')
-      {
-        $url_high=$cat_directory.'/pwg_high/'.$row['file'];
-        $picture[$i]['high'] = $url_high;
-      }
-    }
-  }
-
-  // if picture is not a file, we need the download link
-  if (!$picture[$i]['is_picture'])
-  {
-    $picture[$i]['download'] = $row['path'];
-  }
-
-  $picture[$i]['thumbnail'] = get_thumbnail_src($row['path'], @$row['tn_ext']);
-  
-  if ( !empty( $row['name'] ) )
-  {
-    $picture[$i]['name'] = $row['name'];
-  }
-  else
-  {
-    $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
-  }
-
-  $picture[$i]['url'] =
-    PHPWG_ROOT_PATH.'picture.php'
-    .get_query_string_diff(array('image_id', 'add_fav', 'slideshow', 'rate'))
-    .'&amp;image_id='.$row['id'];
-}
-
-$url_up = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat'];
-
-$url_up_start = floor( $page['current_rank'] / $user['nb_image_page'] );
-$url_up_start *= $user['nb_image_page'];
-if ($url_up_start>0)
-{
-  $url_up .= '&amp;start='.$url_up_start; 
-}
-
-if ( $page['cat'] == 'search' )
-{
-  $url_up.= "&amp;search=".$_GET['search'];
-}
-if ( $page['cat'] == 'list' )
-{
-  $url_up.= "&amp;list=".$_GET['list'];
-}
-
-$url_admin =
-  PHPWG_ROOT_PATH.'admin.php?page=picture_modify'
-  .'&amp;cat_id='.$page['cat']
-  .'&amp;image_id='.$_GET['image_id'];
-
-$url_slide =
-  $picture['current']['url'].'&amp;slideshow='.$conf['slideshow_period'];
 
 //----------------------------------------------------------- rate registration
 if (isset($_GET['rate'])
     and $conf['rate']
-    and !$user['is_the_guest']
+    and ( !$user['is_the_guest'] or $conf['rate_anonymous'] )
     and in_array($_GET['rate'], $rate_items))
 {
+  if ($user['is_the_guest'])
+  {
+    $ip_components = explode('.', $_SERVER["REMOTE_ADDR"]);
+    if ( count($ip_components)>3 )
+    {
+      array_pop($ip_components);
+    }
+    $anonymous_id = implode ('.', $ip_components);
+
+    if ( isset($_COOKIE['pwg_anonymous_rater']) )
+    {
+      if ($anonymous_id != $_COOKIE['pwg_anonymous_rater'] )
+      { // client has changed his IP adress or he's trying to fool us
+        $query = '
+SELECT element_id FROM '. RATE_TABLE . '
+  WHERE user_id=' . $user['id'] . '
+  AND anonymous_id=\'' . $anonymous_id . '\'';
+        $result = pwg_query($query);
+        $already_there = array();
+        while ( $row = mysql_fetch_array($result) )
+        {
+          array_push( $already_there, $row['element_id'] );
+        }
+        
+        if ( count($already_there)>0 )
+        {
+          $query = '
+DELETE FROM '. RATE_TABLE . '
+  WHERE user_id=' . $user['id'] . '
+  AND anonymous_id=\'' . $_COOKIE['pwg_anonymous_rater'] . '\'
+  AND element_id NOT IN (' . implode(',',$already_there) . ')';
+          pwg_query($query);
+        }
+        
+        $query = '
+UPDATE '. RATE_TABLE . '
+  SET anonymous_id=\'' . $anonymous_id . '\'
+  WHERE user_id=' . $user['id'] . '
+  AND anonymous_id=\'' . $_COOKIE['pwg_anonymous_rater'] . '\'';
+        pwg_query($query);
+
+        setcookie('pwg_anonymous_rater', $anonymous_id, 
+                   strtotime('+10 years'), cookie_path() );
+      }
+    }
+    else
+    {
+      setcookie('pwg_anonymous_rater', $anonymous_id, 
+                 strtotime('+10 years'), cookie_path() );
+    }
+  }
+
   $query = '
-DELETE
-  FROM '.RATE_TABLE.'
-  WHERE user_id = '.$user['id'].'
-    AND element_id = '.$_GET['image_id'].'
-;';
+DELETE FROM '.RATE_TABLE.'
+  WHERE element_id = '.$_GET['image_id'] . '
+  AND user_id = '.$user['id']
+;
+  if (isset($anonymous_id))
+  {
+    $query.= ' AND anonymous_id=\'' . $anonymous_id .'\'';
+  }
   pwg_query($query);
   $query = '
 INSERT INTO '.RATE_TABLE.'
-  (user_id,element_id,rate)
+  (user_id,anonymous_id,element_id,rate,date)
   VALUES
-  ('.$user['id'].','.$_GET['image_id'].','.$_GET['rate'].')
+  ('.$user['id'].','.(isset($anonymous_id)?'\''.$anonymous_id.'\'':"''").','.
+   $_GET['image_id'].','.$_GET['rate'].',NOW())
 ;';
   pwg_query($query);
@@ -324,5 +235,158 @@
 ;';
   pwg_query($query);
-}
+  $url =
+    PHPWG_ROOT_PATH
+    .'picture.php'
+    .get_query_string_diff(array('rate'));
+  redirect($url);
+}
+
+
+//---------------------------------------------------------- related categories
+$query = '
+SELECT category_id,uppercats,commentable,global_rank
+  FROM '.IMAGE_CATEGORY_TABLE.'
+    INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
+  WHERE image_id = '.$_GET['image_id'].'
+    AND category_id NOT IN ('.$user['forbidden_categories'].')
+;';
+$result = pwg_query($query);
+$related_categories = array();
+while ($row = mysql_fetch_array($result))
+{
+  array_push($related_categories, $row);
+}
+usort($related_categories, 'global_rank_compare');
+//------------------------------------- prev, current & next picture management
+$picture = array();
+
+$ids = array($_GET['image_id']);
+if (isset($page['previous_item']))
+{
+  array_push($ids, $page['previous_item']);
+}
+if (isset($page['next_item']))
+{
+  array_push($ids, $page['next_item']);
+}
+
+$query = '
+SELECT *
+  FROM '.IMAGES_TABLE.'
+  WHERE id IN ('.implode(',', $ids).')
+;';
+
+$result = pwg_query($query);
+
+while ($row = mysql_fetch_array($result))
+{
+  if (isset($page['previous_item']) and $row['id'] == $page['previous_item'])
+  {
+    $i = 'prev';
+  }
+  else if (isset($page['next_item']) and $row['id'] == $page['next_item'])
+  {
+    $i = 'next';
+  }
+  else
+  {
+    $i = 'current';
+  }
+  
+  foreach (array_keys($row) as $key)
+  {
+    if (!is_numeric($key))
+    {
+      $picture[$i][$key] = $row[$key];
+    }
+  }
+
+  $picture[$i]['is_picture'] = false;
+  if (in_array(get_extension($row['file']), $conf['picture_ext']))
+  {
+    $picture[$i]['is_picture'] = true;
+  }
+  
+  $cat_directory = dirname($row['path']);
+  $file_wo_ext = get_filename_wo_extension($row['file']);
+
+  $icon = get_themeconf('mime_icon_dir');
+  $icon.= strtolower(get_extension($row['file'])).'.png';
+
+  if (isset($row['representative_ext']) and $row['representative_ext'] != '')
+  {
+    $picture[$i]['src'] =
+      $cat_directory.'/pwg_representative/'
+      .$file_wo_ext.'.'.$row['representative_ext'];
+  }
+  else
+  {
+    $picture[$i]['src'] = $icon;
+  }
+  // special case for picture files
+  if ($picture[$i]['is_picture'])
+  {
+    $picture[$i]['src'] = $row['path'];
+    // if we are working on the "current" element, we search if there is a
+    // high quality picture
+    if ($i == 'current')
+    {
+      if ($row['has_high']=='true')
+      {
+        $url_high=$cat_directory.'/pwg_high/'.$row['file'];
+        $picture[$i]['high'] = $url_high;
+      }
+    }
+  }
+
+  // if picture is not a file, we need the download link
+  if (!$picture[$i]['is_picture'])
+  {
+    $picture[$i]['download'] = $row['path'];
+  }
+
+  $picture[$i]['thumbnail'] = get_thumbnail_src($row['path'], @$row['tn_ext']);
+  
+  if ( !empty( $row['name'] ) )
+  {
+    $picture[$i]['name'] = $row['name'];
+  }
+  else
+  {
+    $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
+  }
+
+  $picture[$i]['url'] =
+    PHPWG_ROOT_PATH.'picture.php'
+    .get_query_string_diff(array('image_id', 'add_fav', 'slideshow'))
+    .'&amp;image_id='.$row['id'];
+}
+
+$url_up = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat'];
+
+$url_up_start = floor( $page['current_rank'] / $user['nb_image_page'] );
+$url_up_start *= $user['nb_image_page'];
+if ($url_up_start>0)
+{
+  $url_up .= '&amp;start='.$url_up_start; 
+}
+
+if ( $page['cat'] == 'search' )
+{
+  $url_up.= "&amp;search=".$_GET['search'];
+}
+if ( $page['cat'] == 'list' )
+{
+  $url_up.= "&amp;list=".$_GET['list'];
+}
+
+$url_admin =
+  PHPWG_ROOT_PATH.'admin.php?page=picture_modify'
+  .'&amp;cat_id='.$page['cat']
+  .'&amp;image_id='.$_GET['image_id'];
+
+$url_slide =
+  $picture['current']['url'].'&amp;slideshow='.$conf['slideshow_period'];
+
 //--------------------------------------------------------- favorite management
 if ( isset( $_GET['add_fav'] ) )
@@ -344,5 +408,5 @@
   if ( !$_GET['add_fav'] and $page['cat'] == 'fav' )
   {
-    if (!$has_prev and !$has_next)
+    if (!isset($page['previous_item']) and !isset($page['next_item']))
     {
       // there is no favorite picture anymore we redirect the user to the
@@ -350,5 +414,5 @@
       redirect($url_up);
     }
-    else if (!$has_prev)
+    else if (!isset($page['previous_item']))
     {
       $url = str_replace( '&amp;', '&', $picture['next']['url'] );
@@ -459,5 +523,5 @@
 $title =  $picture['current']['name'];
 $refresh = 0;
-if ( isset( $_GET['slideshow'] ) and $has_next )
+if ( isset( $_GET['slideshow'] ) and isset($page['next_item']) )
 {
   $refresh= $_GET['slideshow'];
@@ -601,6 +665,6 @@
   $template->assign_block_vars('high', array(
     'U_HIGH' => $picture['current']['high'],
-	'UUID'=>$uuid
-	));
+    'UUID'=>$uuid
+  ));
   $template->assign_block_vars(
     'download',
@@ -618,5 +682,5 @@
       'URL' =>
         PHPWG_ROOT_PATH.'picture.php'
-        .get_query_string_diff(array())
+        .get_query_string_diff(array('add_fav'))
         .'&amp;representative=1'
       )
@@ -631,5 +695,5 @@
       'URL' =>
         PHPWG_ROOT_PATH.'picture.php'
-        .get_query_string_diff(array('caddie')).'&amp;caddie=1')
+        .get_query_string_diff(array('add_fav')).'&amp;caddie=1')
     );
 }
@@ -647,5 +711,5 @@
   {
     $url = PHPWG_ROOT_PATH.'picture.php';
-    $url.= get_query_string_diff(array('rate','add_fav'));
+    $url.= get_query_string_diff(array('add_fav'));
     $url.= '&amp;add_fav=1';
 
@@ -662,5 +726,5 @@
   {
     $url = PHPWG_ROOT_PATH.'picture.php';
-    $url.= get_query_string_diff(array('rate','add_fav'));
+    $url.= get_query_string_diff(array('add_fav'));
     $url.= '&amp;add_fav=0';
     
@@ -918,5 +982,5 @@
 {
   if ( !is_numeric( $_GET['slideshow'] ) ) $_GET['slideshow'] = $conf['slideshow_period'];
-	
+  
   $template->assign_block_vars('stop_slideshow', array(
   'U_SLIDESHOW'=>$picture['current']['url']
@@ -948,60 +1012,79 @@
       );
   }
+
+  if ($conf['rate_anonymous'] or !$user['is_the_guest'])
+  {
+    if ($row['count']>0)
+    {
+      $query = 'SELECT rate
+      FROM '.RATE_TABLE.'
+      WHERE element_id = '.$_GET['image_id'] . '
+      AND user_id = '.$user['id'] ;
   
-  if (!$user['is_the_guest'])
-  {
-    $query = 'SELECT rate
-    FROM '.RATE_TABLE.'
-    WHERE user_id = '.$user['id'].'
-    AND element_id = '.$_GET['image_id'].';';
-  $result = pwg_query($query);
-  if (mysql_num_rows($result) > 0)
-  {
-    $row = mysql_fetch_array($result);
-    $sentence = $lang['already_rated'];
-    $sentence.= ' ('.$row['rate'].'). ';
-    $sentence.= $lang['update_rate'];
-  }
-  else
-  {
-    $sentence = $lang['never_rated'].'. '.$lang['to_rate'];
-  }  
-  $template->assign_block_vars(
-    'rate',
-    array(
-      'CONTENT' => $value,
-      'SENTENCE' => $sentence
-      ));
-
-  $template->assign_block_vars('info_rate', array('CONTENT' => $value));
-  
-  $template->assign_vars(
-    array(
-      'INFO_RATE' => $value
-      )
-    );
-  
-  foreach ($rate_items as $num => $mark)
-  {
-    if ($num > 0)
-    {
-      $separator = '|';
-    }
-    else
-    {
-      $separator = '';
-    }
-
-    $url = PHPWG_ROOT_PATH.'picture.php';
-    $url.= get_query_string_diff(array('rate','add_fav'));
-    $url.= '&amp;rate='.$mark;
-    
+      if ($user['is_the_guest'])
+      {
+        $ip_components = explode('.', $_SERVER['REMOTE_ADDR']);
+        if ( count($ip_components)>3 )
+        {
+          array_pop($ip_components);
+        }
+        $anonymous_id = implode ('.', $ip_components);
+        $query .= ' AND anonymous_id = \''.$anonymous_id . '\'';
+      }
+      
+      $result = pwg_query($query);
+      if (mysql_num_rows($result) > 0)
+      {
+        $row = mysql_fetch_array($result);
+        $sentence = $lang['already_rated'];
+        $sentence.= ' ('.$row['rate'].'). ';
+        $sentence.= $lang['update_rate'];
+      }
+      else
+      {
+        $sentence = $lang['never_rated'].'. '.$lang['to_rate'];
+      }
+    }
+    else  
+    {
+      $sentence = $lang['never_rated'].'. '.$lang['to_rate'];
+    }
     $template->assign_block_vars(
-      'rate.rate_option',
+      'rate',
       array(
-        'OPTION' => $mark,
-        'URL' => $url,
-        'SEPARATOR' => $separator
+        'CONTENT' => $value,
+        'SENTENCE' => $sentence
         ));
+
+    $template->assign_block_vars('info_rate', array('CONTENT' => $value));
+
+    $template->assign_vars(
+      array(
+        'INFO_RATE' => $value
+        )
+      );
+
+    foreach ($rate_items as $num => $mark)
+    {
+      if ($num > 0)
+      {
+        $separator = '|';
+      }
+      else
+      {
+        $separator = '';
+      }
+
+      $url = PHPWG_ROOT_PATH.'picture.php';
+      $url.= get_query_string_diff(array('add_fav'));
+      $url.= '&amp;rate='.$mark;
+
+      $template->assign_block_vars(
+        'rate.rate_option',
+        array(
+          'OPTION' => $mark,
+          'URL' => $url,
+          'SEPARATOR' => $separator
+          ));
     }
   }
@@ -1032,5 +1115,5 @@
   // navigation bar creation
   $url = PHPWG_ROOT_PATH.'picture.php';
-  $url.= get_query_string_diff(array('rate','add_fav','start'));
+  $url.= get_query_string_diff(array('add_fav','start'));
 
   if (!isset( $_GET['start'] )
@@ -1052,30 +1135,33 @@
     'NAV_BAR'=>$page['navigation_bar']));
 
-  $query = 'SELECT id,author,date,image_id,content';
-  $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$_GET['image_id'];
-  $query.= " AND validated = 'true'";
-  $query.= ' ORDER BY date ASC';
-  $query.= ' LIMIT '.$page['start'].', '.$conf['nb_comment_page'].';';
-  $result = pwg_query( $query );
-                
-  while ( $row = mysql_fetch_array( $result ) )
-  {
-    $template->assign_block_vars(
-      'comments.comment',
-      array(
-        'COMMENT_AUTHOR'=>empty($row['author'])?$lang['guest']:$row['author'],
-        'COMMENT_DATE'=>format_date($row['date'], 'mysql_datetime', true),
-	'COMMENT'=>parse_comment_content($row['content'])
-	));
-	
-    if ( $user['status'] == 'admin' )
+  if ($row['nb_comments']>0)
+  {
+    $query = 'SELECT id,author,date,image_id,content';
+    $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$_GET['image_id'];
+    $query.= " AND validated = 'true'";
+    $query.= ' ORDER BY date ASC';
+    $query.= ' LIMIT '.$page['start'].', '.$conf['nb_comment_page'].';';
+    $result = pwg_query( $query );
+
+    while ( $row = mysql_fetch_array( $result ) )
     {
       $template->assign_block_vars(
-        'comments.comment.delete',
-        array('U_COMMENT_DELETE'=> $url.'&amp;del='.$row['id']
-          ));
-    }
-  }
-
+        'comments.comment',
+        array(
+          'COMMENT_AUTHOR'=>empty($row['author'])?$lang['guest']:$row['author'],
+          'COMMENT_DATE'=>format_date($row['date'], 'mysql_datetime', true),
+    'COMMENT'=>parse_comment_content($row['content'])
+    ));
+
+      if ( $user['status'] == 'admin' )
+      {
+        $template->assign_block_vars(
+          'comments.comment.delete',
+          array('U_COMMENT_DELETE'=> $url.'&amp;del='.$row['id']
+            ));
+      }
+    }
+  }
+  
   if (!$user['is_the_guest']
       or ($user['is_the_guest'] and $conf['comments_forall']))
Index: trunk/template/yoga/redirect.tpl
===================================================================
--- trunk/template/yoga/redirect.tpl	(revision 1040)
+++ trunk/template/yoga/redirect.tpl	(revision 1041)
@@ -1,1 +1,2 @@
-redirection
+redirection<br/>
+<a href="{U_REFRESH}">{U_REFRESH}</a>
