2003-05-09 14:42:42 +02:00
|
|
|
<?php
|
2004-02-07 20:36:44 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 22:12:59 +01:00
|
|
|
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
2006-03-14 00:27:34 +01:00
|
|
|
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
2004-02-07 20:36:44 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 22:12:59 +01:00
|
|
|
// | branch : BSF (Best So Far)
|
2004-02-07 20:36:44 +01:00
|
|
|
// | file : $RCSfile$
|
|
|
|
// | last update : $Date$
|
|
|
|
// | last modifier : $Author$
|
|
|
|
// | revision : $Revision$
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | 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. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-05-20 23:22:44 +02:00
|
|
|
|
2004-08-31 00:00:46 +02:00
|
|
|
$rate_items = array(0,1,2,3,4,5);
|
|
|
|
//--------------------------------------------------------------------- include
|
2004-02-19 01:31:09 +01:00
|
|
|
define('PHPWG_ROOT_PATH','./');
|
2004-11-21 13:42:55 +01:00
|
|
|
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
2006-02-23 06:12:32 +01:00
|
|
|
|
2006-03-09 23:46:28 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | Check Access and exit when user status is not ok |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
check_status(ACCESS_GUEST);
|
|
|
|
|
2006-02-23 06:12:32 +01:00
|
|
|
include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
|
2003-05-09 14:42:42 +02:00
|
|
|
//-------------------------------------------------- access authorization check
|
2006-02-12 22:52:16 +01:00
|
|
|
if (isset($page['cat']) and is_numeric($page['cat']))
|
|
|
|
{
|
|
|
|
check_restrictions($page['cat']);
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------------- initialization
|
|
|
|
// if this image_id doesn't correspond to this category, an error message is
|
|
|
|
// displayed, and execution is stopped
|
|
|
|
if (!in_array($_GET['image_id'], $page['items']))
|
|
|
|
{
|
|
|
|
echo '
|
|
|
|
<div style="text-align:center;">'.$lang['access_forbiden'].'<br />
|
|
|
|
<a href="'.PHPWG_ROOT_PATH.'category.php'.'">'.$lang['thumbnails'].'</a>
|
|
|
|
</div>';
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
$page['rank_of'] = array_flip($page['items']);
|
|
|
|
|
|
|
|
// caching first_rank, last_rank, current_rank in the displayed
|
|
|
|
// section. This should also help in readability.
|
|
|
|
$page['first_rank'] = 0;
|
|
|
|
$page['last_rank'] = count($page['items']) - 1;
|
|
|
|
$page['current_rank'] = $page['rank_of'][ $_GET['image_id'] ];
|
|
|
|
|
|
|
|
// caching current item : readability purpose
|
|
|
|
$page['current_item'] = $_GET['image_id'];
|
2005-11-16 22:18:56 +01:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
if ($page['current_rank'] != $page['first_rank'])
|
2005-11-16 22:18:56 +01:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
// "go to first picture of this section" link is displayed only if the
|
|
|
|
// displayed item is not the first.
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'first',
|
|
|
|
array(
|
|
|
|
'U_IMG' =>
|
|
|
|
PHPWG_ROOT_PATH.'picture.php'.
|
|
|
|
get_query_string_diff(
|
2006-02-14 02:14:31 +01:00
|
|
|
array('image_id', 'add_fav', 'slideshow')
|
2006-02-12 22:52:16 +01:00
|
|
|
).
|
|
|
|
'&image_id='.$page['items'][ $page['first_rank'] ],
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// caching previous item : readability purpose
|
|
|
|
$page['previous_item'] = $page['items'][ $page['current_rank'] - 1 ];
|
2005-11-16 22:18:56 +01:00
|
|
|
}
|
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
if ($page['current_rank'] != $page['last_rank'])
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
// "go to last picture of this section" link is displayed only if the
|
|
|
|
// displayed item is not the last.
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'last',
|
|
|
|
array(
|
|
|
|
'U_IMG' =>
|
|
|
|
PHPWG_ROOT_PATH.'picture.php'.
|
|
|
|
get_query_string_diff(
|
2006-02-14 02:14:31 +01:00
|
|
|
array('image_id', 'add_fav', 'slideshow')
|
2006-02-12 22:52:16 +01:00
|
|
|
).
|
|
|
|
'&image_id='.$page['items'][ $page['last_rank'] ],
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// caching next item : readability purpose
|
|
|
|
$page['next_item'] = $page['items'][ $page['current_rank'] + 1 ];
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
//---------------------------------------- incrementation of the number of hits
|
2006-01-27 02:11:43 +01:00
|
|
|
if ( count(array_intersect(
|
|
|
|
array_keys($_GET),
|
|
|
|
array('add_fav', 'caddie', 'rate', 'representative', 'del') )
|
|
|
|
)==0 )
|
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
UPDATE '.IMAGES_TABLE.'
|
|
|
|
SET hit = hit+1
|
|
|
|
WHERE id = '.$_GET['image_id'].'
|
|
|
|
;';
|
|
|
|
@pwg_query( $query );
|
|
|
|
}
|
|
|
|
|
2005-08-14 13:55:35 +02:00
|
|
|
//-------------------------------------------------------------- representative
|
2006-03-09 00:14:53 +01:00
|
|
|
if (is_admin() and isset($_GET['representative']))
|
2005-08-14 13:55:35 +02:00
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
UPDATE '.CATEGORIES_TABLE.'
|
|
|
|
SET representative_picture_id = '.$_GET['image_id'].'
|
|
|
|
WHERE id = '.$page['cat'].'
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
|
|
|
|
$url =
|
|
|
|
PHPWG_ROOT_PATH
|
|
|
|
.'picture.php'
|
|
|
|
.get_query_string_diff(array('representative'));
|
|
|
|
redirect($url);
|
|
|
|
}
|
2005-09-03 18:36:05 +02:00
|
|
|
|
|
|
|
//-------------------------------------------------------------- caddie filling
|
|
|
|
|
|
|
|
if (isset($_GET['caddie']))
|
|
|
|
{
|
|
|
|
fill_caddie(array($_GET['image_id']));
|
|
|
|
|
|
|
|
$url =
|
|
|
|
PHPWG_ROOT_PATH
|
|
|
|
.'picture.php'
|
|
|
|
.get_query_string_diff(array('caddie'));
|
|
|
|
redirect($url);
|
|
|
|
}
|
|
|
|
|
2006-02-14 02:14:31 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------- rate registration
|
|
|
|
if (isset($_GET['rate'])
|
|
|
|
and $conf['rate']
|
|
|
|
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'] );
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2006-02-14 02:14:31 +01:00
|
|
|
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);
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2006-02-14 02:14:31 +01:00
|
|
|
$query = '
|
|
|
|
UPDATE '. RATE_TABLE . '
|
|
|
|
SET anonymous_id=\'' . $anonymous_id . '\'
|
|
|
|
WHERE user_id=' . $user['id'] . '
|
|
|
|
AND anonymous_id=\'' . $_COOKIE['pwg_anonymous_rater'] . '\'';
|
|
|
|
pwg_query($query);
|
|
|
|
|
2006-02-28 05:28:06 +01:00
|
|
|
setcookie('pwg_anonymous_rater', $anonymous_id,
|
2006-02-14 02:14:31 +01:00
|
|
|
strtotime('+10 years'), cookie_path() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-28 05:28:06 +01:00
|
|
|
setcookie('pwg_anonymous_rater', $anonymous_id,
|
2006-02-14 02:14:31 +01:00
|
|
|
strtotime('+10 years'), cookie_path() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$query = '
|
|
|
|
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,anonymous_id,element_id,rate,date)
|
|
|
|
VALUES
|
|
|
|
('.$user['id'].','.(isset($anonymous_id)?'\''.$anonymous_id.'\'':"''").','.
|
|
|
|
$_GET['image_id'].','.$_GET['rate'].',NOW())
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
|
|
|
|
// update of images.average_rate field
|
|
|
|
$query = '
|
|
|
|
SELECT ROUND(AVG(rate),2) AS average_rate
|
|
|
|
FROM '.RATE_TABLE.'
|
|
|
|
WHERE element_id = '.$_GET['image_id'].'
|
|
|
|
;';
|
|
|
|
$row = mysql_fetch_array(pwg_query($query));
|
|
|
|
$query = '
|
|
|
|
UPDATE '.IMAGES_TABLE.'
|
|
|
|
SET average_rate = '.$row['average_rate'].'
|
|
|
|
WHERE id = '.$_GET['image_id'].'
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
$url =
|
|
|
|
PHPWG_ROOT_PATH
|
|
|
|
.'picture.php'
|
|
|
|
.get_query_string_diff(array('rate'));
|
|
|
|
redirect($url);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-12 11:27:43 +01:00
|
|
|
//---------------------------------------------------------- related categories
|
|
|
|
$query = '
|
|
|
|
SELECT category_id,uppercats,commentable,global_rank
|
|
|
|
FROM '.IMAGE_CATEGORY_TABLE.'
|
|
|
|
INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
|
2005-08-21 13:32:12 +02:00
|
|
|
WHERE image_id = '.$_GET['image_id'].'
|
|
|
|
AND category_id NOT IN ('.$user['forbidden_categories'].')
|
2005-03-12 11:27:43 +01:00
|
|
|
;';
|
|
|
|
$result = pwg_query($query);
|
|
|
|
$related_categories = array();
|
|
|
|
while ($row = mysql_fetch_array($result))
|
|
|
|
{
|
|
|
|
array_push($related_categories, $row);
|
|
|
|
}
|
|
|
|
usort($related_categories, 'global_rank_compare');
|
2004-03-30 00:40:21 +02:00
|
|
|
//------------------------------------- prev, current & next picture management
|
|
|
|
$picture = array();
|
2004-02-21 12:02:06 +01:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
$ids = array($_GET['image_id']);
|
|
|
|
if (isset($page['previous_item']))
|
2004-08-05 19:31:36 +02:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
array_push($ids, $page['previous_item']);
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
if (isset($page['next_item']))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
array_push($ids, $page['next_item']);
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2004-07-26 22:42:48 +02:00
|
|
|
$query = '
|
2006-02-12 22:52:16 +01:00
|
|
|
SELECT *
|
|
|
|
FROM '.IMAGES_TABLE.'
|
|
|
|
WHERE id IN ('.implode(',', $ids).')
|
|
|
|
;';
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
$result = pwg_query($query);
|
2004-03-30 00:40:21 +02:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
while ($row = mysql_fetch_array($result))
|
2004-02-21 12:02:06 +01:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
if (isset($page['previous_item']) and $row['id'] == $page['previous_item'])
|
2004-08-05 19:31:36 +02:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
$i = 'prev';
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
else if (isset($page['next_item']) and $row['id'] == $page['next_item'])
|
2004-08-05 19:31:36 +02:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
$i = 'next';
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$i = 'current';
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-08-05 19:31:36 +02:00
|
|
|
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;
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-11-17 00:38:34 +01:00
|
|
|
$cat_directory = dirname($row['path']);
|
2004-08-05 19:31:36 +02:00
|
|
|
$file_wo_ext = get_filename_wo_extension($row['file']);
|
2004-03-30 00:40:21 +02:00
|
|
|
|
2005-12-03 18:33:38 +01:00
|
|
|
$icon = get_themeconf('mime_icon_dir');
|
2004-08-05 19:31:36 +02:00
|
|
|
$icon.= strtolower(get_extension($row['file'])).'.png';
|
2004-03-30 00:40:21 +02:00
|
|
|
|
2005-02-09 22:45:24 +01:00
|
|
|
if (isset($row['representative_ext']) and $row['representative_ext'] != '')
|
2004-08-05 19:31:36 +02:00
|
|
|
{
|
2006-02-12 22:52:16 +01:00
|
|
|
$picture[$i]['src'] =
|
|
|
|
$cat_directory.'/pwg_representative/'
|
|
|
|
.$file_wo_ext.'.'.$row['representative_ext'];
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$picture[$i]['src'] = $icon;
|
|
|
|
}
|
|
|
|
// special case for picture files
|
|
|
|
if ($picture[$i]['is_picture'])
|
|
|
|
{
|
2004-11-17 00:38:34 +01:00
|
|
|
$picture[$i]['src'] = $row['path'];
|
2004-09-24 10:37:29 +02:00
|
|
|
// if we are working on the "current" element, we search if there is a
|
|
|
|
// high quality picture
|
|
|
|
if ($i == 'current')
|
|
|
|
{
|
2006-03-14 00:27:34 +01:00
|
|
|
if (($row['has_high'] == 'true') and ($user['enabled_high'] == 'true'))
|
2004-09-24 10:37:29 +02:00
|
|
|
{
|
2006-02-08 02:17:07 +01:00
|
|
|
$url_high=$cat_directory.'/pwg_high/'.$row['file'];
|
|
|
|
$picture[$i]['high'] = $url_high;
|
2004-09-24 10:37:29 +02:00
|
|
|
}
|
|
|
|
}
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// if picture is not a file, we need the download link
|
|
|
|
if (!$picture[$i]['is_picture'])
|
|
|
|
{
|
2004-11-17 00:38:34 +01:00
|
|
|
$picture[$i]['download'] = $row['path'];
|
2004-08-05 19:31:36 +02:00
|
|
|
}
|
|
|
|
|
2004-11-17 00:38:34 +01:00
|
|
|
$picture[$i]['thumbnail'] = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-03-30 00:40:21 +02:00
|
|
|
if ( !empty( $row['name'] ) )
|
2004-02-02 01:55:18 +01:00
|
|
|
{
|
2004-08-05 19:31:36 +02:00
|
|
|
$picture[$i]['name'] = $row['name'];
|
2004-02-02 01:55:18 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-08-05 19:31:36 +02:00
|
|
|
$picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
|
2004-02-02 01:55:18 +01:00
|
|
|
}
|
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
$picture[$i]['url'] =
|
|
|
|
PHPWG_ROOT_PATH.'picture.php'
|
2006-02-14 02:14:31 +01:00
|
|
|
.get_query_string_diff(array('image_id', 'add_fav', 'slideshow'))
|
2006-02-12 22:52:16 +01:00
|
|
|
.'&image_id='.$row['id'];
|
2004-02-02 01:55:18 +01:00
|
|
|
}
|
2003-07-01 11:27:20 +02:00
|
|
|
|
2006-02-23 03:30:19 +01:00
|
|
|
$url_up = PHPWG_ROOT_PATH.'category.php?';
|
|
|
|
if ( isset($page['cat']) )
|
|
|
|
{
|
|
|
|
$url_up .= 'cat='.$page['cat'];
|
|
|
|
}
|
|
|
|
elseif ( isset($_GET['calendar']) )
|
|
|
|
{
|
|
|
|
$url_up .= 'calendar='.$_GET['calendar'];
|
|
|
|
}
|
2006-02-12 22:52:16 +01:00
|
|
|
|
|
|
|
$url_up_start = floor( $page['current_rank'] / $user['nb_image_page'] );
|
2006-01-27 02:11:43 +01:00
|
|
|
$url_up_start *= $user['nb_image_page'];
|
|
|
|
if ($url_up_start>0)
|
|
|
|
{
|
2006-02-28 05:28:06 +01:00
|
|
|
$url_up .= '&start='.$url_up_start;
|
2006-01-27 02:11:43 +01:00
|
|
|
}
|
|
|
|
|
2006-02-24 02:16:30 +01:00
|
|
|
if ( isset($page['cat']) )
|
2004-11-16 00:13:24 +01:00
|
|
|
{
|
2006-02-24 02:16:30 +01:00
|
|
|
if ( $page['cat'] == 'search' )
|
|
|
|
{
|
|
|
|
$url_up.= '&search='.$_GET['search'];
|
|
|
|
}
|
|
|
|
if ( $page['cat'] == 'list' )
|
|
|
|
{
|
|
|
|
$url_up.= '&list='.$_GET['list'];
|
|
|
|
}
|
2004-11-16 00:13:24 +01:00
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
$url_admin =
|
|
|
|
PHPWG_ROOT_PATH.'admin.php?page=picture_modify'
|
2006-02-24 02:16:30 +01:00
|
|
|
.'&cat_id='. ( isset($page['cat']) ? $page['cat'] : '' )
|
2006-02-12 22:52:16 +01:00
|
|
|
.'&image_id='.$_GET['image_id'];
|
2004-09-23 18:42:11 +02:00
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
$url_slide =
|
|
|
|
$picture['current']['url'].'&slideshow='.$conf['slideshow_period'];
|
2005-09-03 18:36:05 +02:00
|
|
|
|
2004-02-21 12:02:06 +01:00
|
|
|
//--------------------------------------------------------- favorite management
|
|
|
|
if ( isset( $_GET['add_fav'] ) )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-03-30 00:40:21 +02:00
|
|
|
$query = 'DELETE FROM '.FAVORITES_TABLE;
|
|
|
|
$query.= ' WHERE user_id = '.$user['id'];
|
|
|
|
$query.= ' AND image_id = '.$picture['current']['id'];
|
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
$result = pwg_query( $query );
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-02-21 12:02:06 +01:00
|
|
|
if ( $_GET['add_fav'] == 1 )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-03-30 00:40:21 +02:00
|
|
|
$query = 'INSERT INTO '.FAVORITES_TABLE;
|
|
|
|
$query.= ' (image_id,user_id) VALUES';
|
|
|
|
$query.= ' ('.$picture['current']['id'].','.$user['id'].')';
|
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
$result = pwg_query( $query );
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2006-02-24 02:16:30 +01:00
|
|
|
if ( !$_GET['add_fav'] and isset($page['cat']) and 'fav'==$page['cat'] )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2006-02-14 02:14:31 +01:00
|
|
|
if (!isset($page['previous_item']) and !isset($page['next_item']))
|
2004-02-21 12:02:06 +01:00
|
|
|
{
|
2004-03-30 00:40:21 +02:00
|
|
|
// there is no favorite picture anymore we redirect the user to the
|
|
|
|
// category page
|
2006-01-15 14:45:42 +01:00
|
|
|
redirect($url_up);
|
2004-02-21 12:02:06 +01:00
|
|
|
}
|
2006-02-14 02:14:31 +01:00
|
|
|
else if (!isset($page['previous_item']))
|
2004-03-30 00:40:21 +02:00
|
|
|
{
|
|
|
|
$url = str_replace( '&', '&', $picture['next']['url'] );
|
2006-01-15 14:45:42 +01:00
|
|
|
redirect( $url );
|
2004-03-30 00:40:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$url = str_replace('&', '&', $picture['prev']['url'] );
|
2006-01-15 14:45:42 +01:00
|
|
|
redirect( $url );
|
2004-03-30 00:40:21 +02:00
|
|
|
}
|
2004-03-31 22:43:09 +02:00
|
|
|
redirect( $url );
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
}
|
2003-08-30 17:54:37 +02:00
|
|
|
|
2004-03-30 00:40:21 +02:00
|
|
|
//------------------------------------------------------ comment registeration
|
|
|
|
if ( isset( $_POST['content'] ) && !empty($_POST['content']) )
|
|
|
|
{
|
|
|
|
$register_comment = true;
|
|
|
|
$author = !empty($_POST['author'])?$_POST['author']:$lang['guest'];
|
|
|
|
// if a guest try to use the name of an already existing user, he must be
|
|
|
|
// rejected
|
|
|
|
if ( $author != $user['username'] )
|
2004-03-20 01:52:37 +01:00
|
|
|
{
|
2004-03-30 00:40:21 +02:00
|
|
|
$query = 'SELECT COUNT(*) AS user_exists';
|
|
|
|
$query.= ' FROM '.USERS_TABLE;
|
2005-10-19 00:29:21 +02:00
|
|
|
$query.= ' WHERE '.$conf['user_fields']['username']." = '".$author."'";
|
2004-03-30 00:40:21 +02:00
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
$row = mysql_fetch_array( pwg_query( $query ) );
|
2004-03-30 00:40:21 +02:00
|
|
|
if ( $row['user_exists'] == 1 )
|
2004-03-20 01:52:37 +01:00
|
|
|
{
|
2004-03-30 00:40:21 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'information',
|
|
|
|
array('INFORMATION'=>$lang['comment_user_exists']));
|
|
|
|
$register_comment = false;
|
2004-03-20 01:52:37 +01:00
|
|
|
}
|
2004-03-30 00:40:21 +02:00
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-03-30 00:40:21 +02:00
|
|
|
if ( $register_comment )
|
|
|
|
{
|
|
|
|
// anti-flood system
|
|
|
|
$reference_date = time() - $conf['anti-flood_time'];
|
|
|
|
$query = 'SELECT id FROM '.COMMENTS_TABLE;
|
2004-05-20 23:22:44 +02:00
|
|
|
$query.= ' WHERE date > FROM_UNIXTIME('.$reference_date.')';
|
2004-03-30 00:40:21 +02:00
|
|
|
$query.= " AND author = '".$author."'";
|
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
if ( mysql_num_rows( pwg_query( $query ) ) == 0
|
2004-03-30 00:40:21 +02:00
|
|
|
or $conf['anti-flood_time'] == 0 )
|
2004-03-20 01:52:37 +01:00
|
|
|
{
|
2005-07-16 16:29:35 +02:00
|
|
|
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$data{'author'} = $author;
|
|
|
|
$data{'date'} = $dbnow;
|
|
|
|
$data{'image_id'} = $_GET['image_id'];
|
|
|
|
$data{'content'} = htmlspecialchars( $_POST['content'], ENT_QUOTES);
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2006-03-09 00:14:53 +01:00
|
|
|
if (!$conf['comments_validation'] or is_admin())
|
2005-07-16 16:29:35 +02:00
|
|
|
{
|
|
|
|
$data{'validated'} = 'true';
|
|
|
|
$data{'validation_date'} = $dbnow;
|
2004-03-20 01:52:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-07-16 16:29:35 +02:00
|
|
|
$data{'validated'} = 'false';
|
2004-03-30 00:40:21 +02:00
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2005-07-16 16:29:35 +02:00
|
|
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
|
|
|
$fields = array('author', 'date', 'image_id', 'content', 'validated',
|
|
|
|
'validation_date');
|
|
|
|
mass_inserts(COMMENTS_TABLE, $fields, array($data));
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-03-30 00:40:21 +02:00
|
|
|
// information message
|
|
|
|
$message = $lang['comment_added'];
|
2005-07-16 16:29:35 +02:00
|
|
|
|
2006-03-09 00:14:53 +01:00
|
|
|
if (!$conf['comments_validation'] or is_admin())
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2006-03-09 00:14:53 +01:00
|
|
|
if ( $conf['comments_validation'] and !is_admin() )
|
2004-03-30 00:40:21 +02:00
|
|
|
{
|
|
|
|
$message.= '<br />'.$lang['comment_to_validate'];
|
|
|
|
}
|
|
|
|
$template->assign_block_vars('information',
|
|
|
|
array('INFORMATION'=>$message));
|
2004-03-20 01:52:37 +01:00
|
|
|
}
|
2004-03-30 00:40:21 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// information message
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'information',
|
|
|
|
array('INFORMATION'=>$lang['comment_anti-flood']));
|
|
|
|
}
|
2004-03-20 01:52:37 +01:00
|
|
|
}
|
2004-03-30 00:40:21 +02:00
|
|
|
}
|
|
|
|
// comment deletion
|
|
|
|
if ( isset( $_GET['del'] )
|
|
|
|
and is_numeric( $_GET['del'] )
|
2006-03-09 00:14:53 +01:00
|
|
|
and is_admin() )
|
2004-03-30 00:40:21 +02:00
|
|
|
{
|
|
|
|
$query = 'DELETE FROM '.COMMENTS_TABLE;
|
|
|
|
$query.= ' WHERE id = '.$_GET['del'];
|
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
pwg_query( $query );
|
2004-03-30 00:40:21 +02:00
|
|
|
}
|
2004-03-20 01:52:37 +01:00
|
|
|
|
2004-02-21 12:02:06 +01:00
|
|
|
//
|
|
|
|
// Start output of page
|
|
|
|
//
|
2003-08-30 17:54:37 +02:00
|
|
|
|
2004-02-21 12:02:06 +01:00
|
|
|
$title = $picture['current']['name'];
|
|
|
|
$refresh = 0;
|
2006-02-14 02:14:31 +01:00
|
|
|
if ( isset( $_GET['slideshow'] ) and isset($page['next_item']) )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-03-30 00:40:21 +02:00
|
|
|
$refresh= $_GET['slideshow'];
|
2004-03-31 22:43:09 +02:00
|
|
|
$url_link = $picture['next']['url'].'&slideshow='.$refresh;
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-02-21 12:02:06 +01:00
|
|
|
|
|
|
|
$title_img = $picture['current']['name'];
|
2006-02-28 05:28:06 +01:00
|
|
|
if ( isset( $page['cat'] ) )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2006-02-28 05:28:06 +01:00
|
|
|
if (is_numeric( $page['cat'] ))
|
2006-02-24 02:16:30 +01:00
|
|
|
{
|
|
|
|
$title_img = replace_space(get_cat_display_name($page['cat_name']));
|
|
|
|
}
|
|
|
|
else if ( $page['cat'] == 'search' )
|
|
|
|
{
|
|
|
|
$title_img = replace_search( $title_img, $_GET['search'] );
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2006-02-17 03:41:57 +01:00
|
|
|
$title_nb = ($page['current_rank'] + 1).'/'.$page['cat_nb_images'];
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2003-07-26 14:38:20 +02:00
|
|
|
// calculation of width and height
|
2004-08-16 23:42:54 +02:00
|
|
|
if (empty($picture['current']['width']))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-08-16 23:42:54 +02:00
|
|
|
$taille_image = @getimagesize($picture['current']['src']);
|
2003-05-09 14:42:42 +02:00
|
|
|
$original_width = $taille_image[0];
|
|
|
|
$original_height = $taille_image[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-02-21 12:02:06 +01:00
|
|
|
$original_width = $picture['current']['width'];
|
|
|
|
$original_height = $picture['current']['height'];
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
|
2004-12-20 13:30:36 +01:00
|
|
|
$picture_size = get_picture_size($original_width, $original_height,
|
|
|
|
@$user['maxwidth'], @$user['maxheight']);
|
2004-09-23 18:42:11 +02:00
|
|
|
|
|
|
|
// metadata
|
|
|
|
if ($conf['show_exif'] or $conf['show_iptc'])
|
|
|
|
{
|
|
|
|
$metadata_showable = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$metadata_showable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$url_metadata = PHPWG_ROOT_PATH.'picture.php';
|
|
|
|
$url_metadata .= get_query_string_diff(array('add_fav', 'slideshow', 'show_metadata'));
|
|
|
|
if ($metadata_showable and !isset($_GET['show_metadata']))
|
|
|
|
{
|
|
|
|
$url_metadata.= '&show_metadata=1';
|
|
|
|
}
|
2005-04-26 16:24:08 +02:00
|
|
|
|
- new : HTML BODY identifier to let CSS stylesheets manage specific
behaviour.
- deletion : admin/search useless
- improvement : in admin/user_list, special behaviour for true/false fields
(expand, show_comments)
- new : gallery_title and gallery_description are displayed at the top of
each page.
- improvement : simplification in HTML for categories menu.
- improvement : standardization of presentation in all public pages
(identification, registration, search, profile, notification, comments,
etc.)
(not in ChangeLog, below this line)
- add forgotten notification.php (should have been added in a previous
commit)
- [template cclear] deletion of useless class .bouton
- [template cclear] for test purpose, new presentation of register page
(using FORM.filter)
- [template cclear] adaptation of admin/group_list from template default
- [template cclear] deletion of obsolete admin/infos_images
- [template cclear] deletion of obsolete admin/search_username
- [template cclear] new icon register.png
git-svn-id: http://piwigo.org/svn/trunk@850 68402e56-0260-453c-a942-63ccdbb3a9ee
2005-08-26 00:43:47 +02:00
|
|
|
$page['body_id'] = 'thePicturePage';
|
2006-02-12 22:52:16 +01:00
|
|
|
//------------------------------------------------------- navigation management
|
|
|
|
if (isset($page['previous_item']))
|
2006-02-01 03:46:26 +01:00
|
|
|
{
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'previous',
|
|
|
|
array(
|
|
|
|
'TITLE_IMG' => $picture['prev']['name'],
|
|
|
|
'IMG' => $picture['prev']['thumbnail'],
|
|
|
|
'U_IMG' => $picture['prev']['url'],
|
|
|
|
'U_IMG_SRC' => $picture['prev']['src']
|
2006-02-12 22:52:16 +01:00
|
|
|
)
|
|
|
|
);
|
2006-02-01 03:46:26 +01:00
|
|
|
}
|
|
|
|
|
2006-02-12 22:52:16 +01:00
|
|
|
if (isset($page['next_item']))
|
2006-02-01 03:46:26 +01:00
|
|
|
{
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'next',
|
|
|
|
array(
|
|
|
|
'TITLE_IMG' => $picture['next']['name'],
|
|
|
|
'IMG' => $picture['next']['thumbnail'],
|
|
|
|
'U_IMG' => $picture['next']['url'],
|
|
|
|
'U_IMG_SRC' => $picture['next']['src'] // allow navigator to preload
|
2006-02-12 22:52:16 +01:00
|
|
|
)
|
|
|
|
);
|
2006-02-01 03:46:26 +01:00
|
|
|
}
|
|
|
|
|
2004-02-22 03:43:13 +01:00
|
|
|
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
2004-02-21 12:02:06 +01:00
|
|
|
$template->set_filenames(array('picture'=>'picture.tpl'));
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2004-02-26 19:33:45 +01:00
|
|
|
'CATEGORY' => $title_img,
|
|
|
|
'PHOTO' => $title_nb,
|
|
|
|
'TITLE' => $picture['current']['name'],
|
2004-02-21 12:02:06 +01:00
|
|
|
'SRC_IMG' => $picture['current']['src'],
|
|
|
|
'ALT_IMG' => $picture['current']['file'],
|
|
|
|
'WIDTH_IMG' => $picture_size[0],
|
|
|
|
'HEIGHT_IMG' => $picture_size[1],
|
|
|
|
|
2004-12-12 22:06:39 +01:00
|
|
|
'LEVEL_SEPARATOR' => $conf['level_separator'],
|
|
|
|
|
2004-11-18 15:57:00 +01:00
|
|
|
'L_HOME' => $lang['home'],
|
2004-02-21 12:02:06 +01:00
|
|
|
'L_SLIDESHOW' => $lang['slideshow'],
|
|
|
|
'L_STOP_SLIDESHOW' => $lang['slideshow_stop'],
|
2005-01-06 17:33:04 +01:00
|
|
|
'L_PREV_IMG' =>$lang['previous_page'].' : ',
|
|
|
|
'L_NEXT_IMG' =>$lang['next_page'].' : ',
|
2004-02-21 12:02:06 +01:00
|
|
|
'L_ADMIN' =>$lang['link_info_image'],
|
|
|
|
'L_COMMENT_TITLE' =>$lang['comments_title'],
|
|
|
|
'L_ADD_COMMENT' =>$lang['comments_add'],
|
|
|
|
'L_DELETE_COMMENT' =>$lang['comments_del'],
|
|
|
|
'L_DELETE' =>$lang['delete'],
|
|
|
|
'L_SUBMIT' =>$lang['submit'],
|
2005-10-16 00:20:48 +02:00
|
|
|
'L_AUTHOR' => $lang['upload_author'],
|
2004-03-20 01:52:37 +01:00
|
|
|
'L_COMMENT' =>$lang['comment'],
|
2004-08-05 19:31:36 +02:00
|
|
|
'L_DOWNLOAD' => $lang['download'],
|
|
|
|
'L_DOWNLOAD_HINT' => $lang['download_hint'],
|
2004-09-23 18:42:11 +02:00
|
|
|
'L_PICTURE_METADATA' => $lang['picture_show_metadata'],
|
2004-09-24 10:37:29 +02:00
|
|
|
'L_PICTURE_HIGH' => $lang['picture_high'],
|
2004-11-18 15:57:00 +01:00
|
|
|
'L_UP_HINT' => $lang['home_hint'],
|
|
|
|
'L_UP_ALT' => $lang['home'],
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2006-01-15 14:45:42 +01:00
|
|
|
'U_HOME' => (PHPWG_ROOT_PATH.'category.php'),
|
|
|
|
'U_UP' => $url_up,
|
|
|
|
'U_METADATA' => $url_metadata,
|
|
|
|
'U_ADMIN' => $url_admin,
|
|
|
|
'U_SLIDESHOW'=> $url_slide,
|
|
|
|
'U_ADD_COMMENT' => str_replace( '&', '&', $_SERVER['REQUEST_URI'] )
|
2004-02-21 12:02:06 +01:00
|
|
|
)
|
|
|
|
);
|
2005-07-17 16:58:42 +02:00
|
|
|
|
|
|
|
if ($conf['show_picture_name_on_title'])
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('title', array());
|
|
|
|
}
|
|
|
|
|
2004-09-24 10:37:29 +02:00
|
|
|
//------------------------------------------------------- upper menu management
|
2004-09-23 18:42:11 +02:00
|
|
|
// download link if file is not a picture
|
|
|
|
if (!$picture['current']['is_picture'])
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-09-24 10:37:29 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'download',
|
|
|
|
array('U_DOWNLOAD' => $picture['current']['download']));
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
2004-09-24 10:37:29 +02:00
|
|
|
// display a high quality link if present
|
|
|
|
if (isset($picture['current']['high']))
|
|
|
|
{
|
2004-10-02 00:50:50 +02:00
|
|
|
$uuid = uniqid(rand());
|
|
|
|
$template->assign_block_vars('high', array(
|
|
|
|
'U_HIGH' => $picture['current']['high'],
|
2006-02-14 02:14:31 +01:00
|
|
|
'UUID'=>$uuid
|
|
|
|
));
|
2005-12-19 19:58:38 +01:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'download',
|
|
|
|
array('U_DOWNLOAD' => PHPWG_ROOT_PATH.'action.php?dwn='
|
|
|
|
.$picture['current']['high']
|
|
|
|
)
|
|
|
|
);
|
2004-09-23 18:42:11 +02:00
|
|
|
}
|
2005-08-14 13:55:35 +02:00
|
|
|
// button to set the current picture as representative
|
2006-03-09 00:14:53 +01:00
|
|
|
if (is_admin() and
|
2006-02-24 02:16:30 +01:00
|
|
|
isset($page['cat']) and is_numeric($page['cat']))
|
2005-08-14 13:55:35 +02:00
|
|
|
{
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'representative',
|
|
|
|
array(
|
|
|
|
'URL' =>
|
|
|
|
PHPWG_ROOT_PATH.'picture.php'
|
2006-02-14 02:14:31 +01:00
|
|
|
.get_query_string_diff(array('add_fav'))
|
2005-08-14 13:55:35 +02:00
|
|
|
.'&representative=1'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2005-09-03 18:36:05 +02:00
|
|
|
|
2006-03-09 00:14:53 +01:00
|
|
|
if (is_admin())
|
2005-09-03 18:36:05 +02:00
|
|
|
{
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'caddie',
|
|
|
|
array(
|
|
|
|
'URL' =>
|
|
|
|
PHPWG_ROOT_PATH.'picture.php'
|
2006-02-14 02:14:31 +01:00
|
|
|
.get_query_string_diff(array('add_fav')).'&caddie=1')
|
2005-09-03 18:36:05 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2004-09-23 18:42:11 +02:00
|
|
|
//------------------------------------------------------- favorite manipulation
|
|
|
|
if ( !$user['is_the_guest'] )
|
|
|
|
{
|
|
|
|
// verify if the picture is already in the favorite of the user
|
|
|
|
$query = 'SELECT COUNT(*) AS nb_fav';
|
|
|
|
$query.= ' FROM '.FAVORITES_TABLE.' WHERE image_id = '.$_GET['image_id'];
|
|
|
|
$query.= ' AND user_id = '.$user['id'].';';
|
2004-10-30 17:42:29 +02:00
|
|
|
$result = pwg_query( $query );
|
2004-09-23 18:42:11 +02:00
|
|
|
$row = mysql_fetch_array( $result );
|
|
|
|
if (!$row['nb_fav'])
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-09-23 18:42:11 +02:00
|
|
|
$url = PHPWG_ROOT_PATH.'picture.php';
|
2006-02-14 02:14:31 +01:00
|
|
|
$url.= get_query_string_diff(array('add_fav'));
|
2004-09-23 18:42:11 +02:00
|
|
|
$url.= '&add_fav=1';
|
|
|
|
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'favorite',
|
|
|
|
array(
|
2005-12-03 18:33:38 +01:00
|
|
|
'FAVORITE_IMG' => get_themeconf('icon_dir').'/favorite.png',
|
2004-09-23 18:42:11 +02:00
|
|
|
'FAVORITE_HINT' =>$lang['add_favorites_hint'],
|
|
|
|
'FAVORITE_ALT' =>$lang['add_favorites_alt'],
|
|
|
|
'U_FAVORITE' => $url
|
|
|
|
));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$url = PHPWG_ROOT_PATH.'picture.php';
|
2006-02-14 02:14:31 +01:00
|
|
|
$url.= get_query_string_diff(array('add_fav'));
|
2004-09-23 18:42:11 +02:00
|
|
|
$url.= '&add_fav=0';
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-09-23 18:42:11 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'favorite',
|
|
|
|
array(
|
2005-12-03 18:33:38 +01:00
|
|
|
'FAVORITE_IMG' => get_themeconf('icon_dir').'/del_favorite.png',
|
2004-09-23 18:42:11 +02:00
|
|
|
'FAVORITE_HINT' =>$lang['del_favorites_hint'],
|
|
|
|
'FAVORITE_ALT' =>$lang['del_favorites_alt'],
|
|
|
|
'U_FAVORITE'=> $url
|
|
|
|
));
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
}
|
2004-09-23 18:42:11 +02:00
|
|
|
//------------------------------------ admin link for information modifications
|
2006-03-09 00:14:53 +01:00
|
|
|
if ( is_admin() )
|
2004-09-23 18:42:11 +02:00
|
|
|
{
|
|
|
|
$template->assign_block_vars('admin', array());
|
|
|
|
}
|
2004-02-21 12:02:06 +01:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
//--------------------------------------------------------- picture information
|
2004-03-20 01:52:37 +01:00
|
|
|
// legend
|
2004-08-05 19:31:36 +02:00
|
|
|
if (isset($picture['current']['comment'])
|
|
|
|
and !empty($picture['current']['comment']))
|
2004-03-20 01:52:37 +01:00
|
|
|
{
|
2004-08-05 19:31:36 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'legend',
|
|
|
|
array(
|
2005-03-12 11:27:43 +01:00
|
|
|
'COMMENT_IMG' => nl2br($picture['current']['comment'])
|
2004-08-05 19:31:36 +02:00
|
|
|
));
|
|
|
|
}
|
2004-09-23 18:42:11 +02:00
|
|
|
|
2005-08-21 13:32:12 +02:00
|
|
|
$infos = array();
|
|
|
|
|
|
|
|
// author
|
|
|
|
if (!empty($picture['current']['author']))
|
2003-07-28 23:30:19 +02:00
|
|
|
{
|
2005-08-21 13:32:12 +02:00
|
|
|
$infos['INFO_AUTHOR'] =
|
2006-01-20 15:34:37 +01:00
|
|
|
// FIXME because of search engine partial rewrite, giving the author
|
|
|
|
// name threw GET is not supported anymore. This feature should come
|
|
|
|
// back later, with a better design
|
|
|
|
// '<a href="'.
|
|
|
|
// PHPWG_ROOT_PATH.'category.php?cat=search'.
|
|
|
|
// '&search=author:'.$picture['current']['author']
|
|
|
|
// .'">'.$picture['current']['author'].'</a>';
|
|
|
|
$picture['current']['author'];
|
2005-08-21 13:32:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$infos['INFO_AUTHOR'] = l10n('N/A');
|
2003-07-28 23:30:19 +02:00
|
|
|
}
|
2005-04-26 16:24:08 +02:00
|
|
|
|
2005-08-21 13:32:12 +02:00
|
|
|
// creation date
|
|
|
|
if (!empty($picture['current']['date_creation']))
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 22:28:40 +01:00
|
|
|
{
|
2006-02-23 03:30:19 +01:00
|
|
|
$val = format_date($picture['current']['date_creation']);
|
2006-02-24 06:58:48 +01:00
|
|
|
$infos['INFO_CREATION_DATE'] = '<a href="'.
|
|
|
|
PHPWG_ROOT_PATH.'category.php?calendar=created-c-'.
|
2006-02-23 03:30:19 +01:00
|
|
|
$picture['current']['date_creation'].'">'.$val.'</a>';
|
2005-08-21 13:32:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$infos['INFO_CREATION_DATE'] = l10n('N/A');
|
|
|
|
}
|
|
|
|
|
|
|
|
// date of availability
|
2006-02-23 03:30:19 +01:00
|
|
|
$val = format_date($picture['current']['date_available'], 'mysql_datetime');
|
2006-02-28 05:28:06 +01:00
|
|
|
$infos['INFO_POSTED_DATE'] = '<a href="'.
|
2006-02-24 06:58:48 +01:00
|
|
|
PHPWG_ROOT_PATH.'category.php?calendar=posted-c-'.
|
|
|
|
substr($picture['current']['date_available'],0,10).'">'.$val.'</a>';
|
2005-08-21 13:32:12 +02:00
|
|
|
|
|
|
|
// size in pixels
|
|
|
|
if ($picture['current']['is_picture'])
|
|
|
|
{
|
|
|
|
if ($original_width != $picture_size[0]
|
|
|
|
or $original_height != $picture_size[1])
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 22:28:40 +01:00
|
|
|
{
|
2005-08-21 13:32:12 +02:00
|
|
|
$infos['INFO_DIMENSIONS'] =
|
|
|
|
'<a href="'.$picture['current']['src'].'" title="'.
|
|
|
|
l10n('Original dimensions').'">'.
|
|
|
|
$original_width.'*'.$original_height.'</a>';
|
- on picture.php, related categories under the element are displayed in
global_rank order
- when adding a new virtual category, initializes its global_rank
- bug fixed : in admin/cat_list, false next rank
- in admin/cat_modify, complete directory is calculated only if category is
not virtual
- admin/picture_modify rewritten : graphically nearer to admin/cat_modify,
virtual associations are back
- update_category partially rewritten : take an array of categories in
parameter, becomes optionnaly recursive, use the set_random_representant
function, set a random representant for categories with elements and no
representant
- bug fixed : on a search results screen, elements belonging to more than 1
category were shown more than once
- bug fixed : in admin/cat_modify, changing a value in a textefield and
hitting enter was setting a new random representant
git-svn-id: http://piwigo.org/svn/trunk@635 68402e56-0260-453c-a942-63ccdbb3a9ee
2004-12-05 22:28:40 +01:00
|
|
|
}
|
|
|
|
else
|
2004-10-21 23:17:07 +02:00
|
|
|
{
|
2005-08-21 13:32:12 +02:00
|
|
|
$infos['INFO_DIMENSIONS'] = $original_width.'*'.$original_height;
|
2004-11-13 14:43:53 +01:00
|
|
|
}
|
2004-10-21 23:17:07 +02:00
|
|
|
}
|
2005-08-21 13:32:12 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$infos['INFO_DIMENSIONS'] = l10n('N/A');
|
|
|
|
}
|
|
|
|
|
|
|
|
// filesize
|
|
|
|
if (!empty($picture['current']['filesize']))
|
|
|
|
{
|
|
|
|
$infos['INFO_FILESIZE'] =
|
|
|
|
sprintf(l10n('%d Kb'), $picture['current']['filesize']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$infos['INFO_FILESIZE'] = l10n('N/A');
|
|
|
|
}
|
|
|
|
|
|
|
|
// number of visits
|
|
|
|
$infos['INFO_VISITS'] = $picture['current']['hit'];
|
|
|
|
|
|
|
|
// file
|
|
|
|
$infos['INFO_FILE'] = $picture['current']['file'];
|
|
|
|
|
|
|
|
// keywords
|
|
|
|
if (!empty($picture['current']['keywords']))
|
|
|
|
{
|
|
|
|
$infos['INFO_KEYWORDS'] =
|
2006-01-20 15:34:37 +01:00
|
|
|
// FIXME because of search engine partial rewrite, giving the author
|
|
|
|
// name threw GET is not supported anymore. This feature should come
|
|
|
|
// back later, with a better design (tag classification).
|
|
|
|
// preg_replace(
|
|
|
|
// '/([^,]+)/',
|
|
|
|
// '<a href="'.
|
|
|
|
// PHPWG_ROOT_PATH.'category.php?cat=search&search=keywords:$1'
|
|
|
|
// .'">$1</a>',
|
|
|
|
// $picture['current']['keywords']
|
|
|
|
// );
|
|
|
|
$picture['current']['keywords'];
|
2005-08-21 13:32:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$infos['INFO_KEYWORDS'] = l10n('N/A');
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_vars($infos);
|
|
|
|
|
|
|
|
// related categories
|
|
|
|
foreach ($related_categories as $category)
|
|
|
|
{
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'category',
|
|
|
|
array(
|
|
|
|
'LINE' => count($related_categories) > 3
|
|
|
|
? get_cat_display_name_cache($category['uppercats'])
|
|
|
|
: get_cat_display_name_from_id($category['category_id'])
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2005-04-26 16:24:08 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------- metadata
|
2004-08-25 23:09:09 +02:00
|
|
|
if ($metadata_showable and isset($_GET['show_metadata']))
|
|
|
|
{
|
|
|
|
include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php');
|
|
|
|
$template->assign_block_vars('metadata', array());
|
|
|
|
if ($conf['show_exif'])
|
|
|
|
{
|
2005-02-13 13:49:52 +01:00
|
|
|
if (!function_exists('read_exif_data'))
|
|
|
|
{
|
|
|
|
die('Exif extension not available, admin should disable exif display');
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-08-25 23:09:09 +02:00
|
|
|
if ($exif = @read_exif_data($picture['current']['src']))
|
|
|
|
{
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'metadata.headline',
|
|
|
|
array('TITLE' => 'EXIF Metadata')
|
|
|
|
);
|
2004-09-23 18:42:11 +02:00
|
|
|
|
2004-08-25 23:09:09 +02:00
|
|
|
foreach ($conf['show_exif_fields'] as $field)
|
|
|
|
{
|
|
|
|
if (strpos($field, ';') === false)
|
|
|
|
{
|
|
|
|
if (isset($exif[$field]))
|
|
|
|
{
|
|
|
|
$key = $field;
|
|
|
|
if (isset($lang['exif_field_'.$field]))
|
|
|
|
{
|
|
|
|
$key = $lang['exif_field_'.$field];
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-08-25 23:09:09 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'metadata.line',
|
|
|
|
array(
|
|
|
|
'KEY' => $key,
|
|
|
|
'VALUE' => $exif[$field]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$tokens = explode(';', $field);
|
|
|
|
if (isset($exif[$tokens[0]][$tokens[1]]))
|
|
|
|
{
|
|
|
|
$key = $tokens[1];
|
|
|
|
if (isset($lang['exif_field_'.$tokens[1]]))
|
|
|
|
{
|
|
|
|
$key = $lang['exif_field_'.$tokens[1]];
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-08-25 23:09:09 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'metadata.line',
|
|
|
|
array(
|
|
|
|
'KEY' => $key,
|
|
|
|
'VALUE' => $exif[$tokens[0]][$tokens[1]]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($conf['show_iptc'])
|
|
|
|
{
|
|
|
|
$iptc = get_iptc_data($picture['current']['src'],
|
|
|
|
$conf['show_iptc_mapping']);
|
|
|
|
|
|
|
|
if (count($iptc) > 0)
|
|
|
|
{
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'metadata.headline',
|
|
|
|
array('TITLE' => 'IPTC Metadata')
|
|
|
|
);
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-08-25 23:09:09 +02:00
|
|
|
foreach ($iptc as $field => $value)
|
|
|
|
{
|
|
|
|
$key = $field;
|
|
|
|
if (isset($lang[$field]))
|
|
|
|
{
|
|
|
|
$key = $lang[$field];
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-08-25 23:09:09 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'metadata.line',
|
|
|
|
array(
|
|
|
|
'KEY' => $key,
|
|
|
|
'VALUE' => $value
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-09-23 18:42:11 +02:00
|
|
|
//slideshow end
|
|
|
|
if ( isset( $_GET['slideshow'] ) )
|
|
|
|
{
|
|
|
|
if ( !is_numeric( $_GET['slideshow'] ) ) $_GET['slideshow'] = $conf['slideshow_period'];
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-09-23 18:42:11 +02:00
|
|
|
$template->assign_block_vars('stop_slideshow', array(
|
2006-01-15 14:45:42 +01:00
|
|
|
'U_SLIDESHOW'=>$picture['current']['url']
|
2004-09-23 18:42:11 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2005-04-26 16:24:08 +02:00
|
|
|
//------------------------------------------------------------------- rating
|
|
|
|
if ($conf['rate'])
|
2004-08-31 00:00:46 +02:00
|
|
|
{
|
2005-08-21 13:32:12 +02:00
|
|
|
$query = '
|
|
|
|
SELECT COUNT(rate) AS count
|
2005-04-26 16:24:08 +02:00
|
|
|
, ROUND(AVG(rate),2) AS average
|
|
|
|
, ROUND(STD(rate),2) AS STD
|
2004-08-31 00:00:46 +02:00
|
|
|
FROM '.RATE_TABLE.'
|
2005-04-26 16:24:08 +02:00
|
|
|
WHERE element_id = '.$picture['current']['id'].'
|
2004-08-31 00:00:46 +02:00
|
|
|
;';
|
2005-04-26 16:24:08 +02:00
|
|
|
$row = mysql_fetch_array(pwg_query($query));
|
|
|
|
if ($row['count'] == 0)
|
|
|
|
{
|
|
|
|
$value = $lang['no_rate'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-08-21 13:32:12 +02:00
|
|
|
$value = sprintf(
|
|
|
|
l10n('%.2f (rated %d times, standard deviation = %.2f)'),
|
|
|
|
$row['average'],
|
|
|
|
$row['count'],
|
|
|
|
$row['STD']
|
|
|
|
);
|
2005-04-26 16:24:08 +02:00
|
|
|
}
|
2005-08-21 13:32:12 +02:00
|
|
|
|
2006-02-14 02:14:31 +01:00
|
|
|
if ($conf['rate_anonymous'] or !$user['is_the_guest'])
|
2004-08-31 00:00:46 +02:00
|
|
|
{
|
2006-02-14 02:14:31 +01:00
|
|
|
if ($row['count']>0)
|
2004-08-31 00:00:46 +02:00
|
|
|
{
|
2006-02-14 02:14:31 +01:00
|
|
|
$query = 'SELECT rate
|
|
|
|
FROM '.RATE_TABLE.'
|
|
|
|
WHERE element_id = '.$_GET['image_id'] . '
|
|
|
|
AND user_id = '.$user['id'] ;
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2006-02-14 02:14:31 +01:00
|
|
|
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 . '\'';
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2006-02-14 02:14:31 +01:00
|
|
|
$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
|
|
|
|
{
|
2006-02-15 03:29:26 +01:00
|
|
|
$sentence = $lang['never_rated'].'. '.$lang['Rate'];
|
2006-02-14 02:14:31 +01:00
|
|
|
}
|
2004-08-31 00:00:46 +02:00
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
else
|
2004-08-31 00:00:46 +02:00
|
|
|
{
|
2006-02-15 03:29:26 +01:00
|
|
|
$sentence = $lang['never_rated'].'. '.$lang['Rate'];
|
2004-08-31 00:00:46 +02:00
|
|
|
}
|
|
|
|
$template->assign_block_vars(
|
2006-02-14 02:14:31 +01:00
|
|
|
'rate',
|
2004-08-31 00:00:46 +02:00
|
|
|
array(
|
2006-02-14 02:14:31 +01:00
|
|
|
'CONTENT' => $value,
|
|
|
|
'SENTENCE' => $sentence
|
2004-08-31 00:00:46 +02:00
|
|
|
));
|
2006-02-14 02:14:31 +01:00
|
|
|
|
|
|
|
$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.= '&rate='.$mark;
|
|
|
|
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'rate.rate_option',
|
|
|
|
array(
|
|
|
|
'OPTION' => $mark,
|
|
|
|
'URL' => $url,
|
|
|
|
'SEPARATOR' => $separator
|
|
|
|
));
|
2005-04-26 16:24:08 +02:00
|
|
|
}
|
2004-08-31 00:00:46 +02:00
|
|
|
}
|
|
|
|
}
|
2005-04-26 16:24:08 +02:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
//---------------------------------------------------- users's comments display
|
2005-08-21 13:32:12 +02:00
|
|
|
|
|
|
|
// the picture is commentable if it belongs at least to one category which
|
|
|
|
// is commentable
|
|
|
|
$page['show_comments'] = false;
|
|
|
|
foreach ($related_categories as $category)
|
|
|
|
{
|
|
|
|
if ($category['commentable'] == 'true')
|
|
|
|
{
|
|
|
|
$page['show_comments'] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-13 14:43:53 +01:00
|
|
|
if ($page['show_comments'])
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
|
|
|
// number of comment for this picture
|
2003-07-01 11:27:20 +02:00
|
|
|
$query = 'SELECT COUNT(*) AS nb_comments';
|
2004-02-21 12:02:06 +01:00
|
|
|
$query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$_GET['image_id'];
|
2003-07-21 21:47:14 +02:00
|
|
|
$query.= " AND validated = 'true'";
|
|
|
|
$query.= ';';
|
2004-10-30 17:42:29 +02:00
|
|
|
$row = mysql_fetch_array( pwg_query( $query ) );
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2003-05-09 14:42:42 +02:00
|
|
|
// navigation bar creation
|
2004-08-31 00:00:46 +02:00
|
|
|
$url = PHPWG_ROOT_PATH.'picture.php';
|
2006-02-14 02:14:31 +01:00
|
|
|
$url.= get_query_string_diff(array('add_fav','start'));
|
2004-08-31 00:00:46 +02:00
|
|
|
|
|
|
|
if (!isset( $_GET['start'] )
|
2003-07-01 11:27:20 +02:00
|
|
|
or !is_numeric( $_GET['start'] )
|
|
|
|
or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
|
|
|
$page['start'] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$page['start'] = $_GET['start'];
|
|
|
|
}
|
2004-02-21 12:02:06 +01:00
|
|
|
$page['navigation_bar'] = create_navigation_bar( $url, $row['nb_comments'],
|
2003-05-09 14:42:42 +02:00
|
|
|
$page['start'],
|
|
|
|
$conf['nb_comment_page'],
|
|
|
|
'' );
|
2004-02-21 12:02:06 +01:00
|
|
|
$template->assign_block_vars('comments', array(
|
|
|
|
'NB_COMMENT'=>$row['nb_comments'],
|
|
|
|
'NAV_BAR'=>$page['navigation_bar']));
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2006-02-14 02:14:31 +01:00
|
|
|
if ($row['nb_comments']>0)
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2006-02-14 02:14:31 +01:00
|
|
|
$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 ) )
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-10-23 19:56:46 +02:00
|
|
|
$template->assign_block_vars(
|
2006-02-14 02:14:31 +01:00
|
|
|
'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'])
|
|
|
|
));
|
|
|
|
|
2006-03-09 00:14:53 +01:00
|
|
|
if ( is_admin() )
|
2006-02-14 02:14:31 +01:00
|
|
|
{
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'comments.comment.delete',
|
|
|
|
array('U_COMMENT_DELETE'=> $url.'&del='.$row['id']
|
|
|
|
));
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
}
|
2006-02-28 05:28:06 +01:00
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
if (!$user['is_the_guest']
|
|
|
|
or ($user['is_the_guest'] and $conf['comments_forall']))
|
2003-05-09 14:42:42 +02:00
|
|
|
{
|
2004-02-21 12:02:06 +01:00
|
|
|
$template->assign_block_vars('comments.add_comment', array());
|
2003-07-26 14:55:14 +02:00
|
|
|
// display author field if the user is not logged in
|
2004-10-23 19:56:46 +02:00
|
|
|
if (!$user['is_the_guest'])
|
2003-07-26 14:55:14 +02:00
|
|
|
{
|
2004-10-23 19:56:46 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'comments.add_comment.author_known',
|
|
|
|
array('KNOWN_AUTHOR'=>$user['username'])
|
|
|
|
);
|
|
|
|
}
|
2003-07-26 14:55:14 +02:00
|
|
|
else
|
|
|
|
{
|
2004-10-23 19:56:46 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'comments.add_comment.author_field', array()
|
|
|
|
);
|
2003-07-26 14:55:14 +02:00
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------ log informations
|
2004-02-21 12:02:06 +01:00
|
|
|
pwg_log( 'picture', $title_img, $picture['current']['file'] );
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2005-01-13 11:18:49 +01:00
|
|
|
$template->parse('picture');
|
2004-02-22 03:43:13 +01:00
|
|
|
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
2004-02-12 00:20:38 +01:00
|
|
|
?>
|