2003-10-04 18:08:53 +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 |
|
|
|
|
// | Copyright (C) 2003-2004 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. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2003-10-04 18:08:53 +02:00
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | initialization |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-03-20 01:52:37 +01:00
|
|
|
if (!defined('IN_ADMIN'))
|
|
|
|
{
|
|
|
|
define('PHPWG_ROOT_PATH','./');
|
2004-10-23 19:56:46 +02:00
|
|
|
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
2004-03-20 01:52:37 +01:00
|
|
|
}
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
if (isset($_GET['last_days']))
|
2004-03-20 01:52:37 +01:00
|
|
|
{
|
2004-10-23 19:56:46 +02:00
|
|
|
define('MAX_DAYS', $_GET['last_days']);
|
2004-03-20 01:52:37 +01:00
|
|
|
}
|
2004-10-23 19:56:46 +02:00
|
|
|
else
|
2004-03-20 01:52:37 +01:00
|
|
|
{
|
2004-10-23 19:56:46 +02:00
|
|
|
define('MAX_DAYS', 0);
|
2004-03-20 01:52:37 +01:00
|
|
|
}
|
2004-10-23 19:56:46 +02:00
|
|
|
$array_cat_names = array();
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | comments management |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// comments deletion
|
|
|
|
if (isset($_POST['delete']) and count($_POST['comment_id']) > 0)
|
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
DELETE FROM '.COMMENTS_TABLE.'
|
|
|
|
WHERE id IN ('.implode(',', $_POST['comment_id']).')
|
|
|
|
;';
|
2004-10-30 17:42:29 +02:00
|
|
|
pwg_query($query);
|
2004-10-23 19:56:46 +02:00
|
|
|
}
|
|
|
|
// comments validation
|
|
|
|
if (isset($_POST['validate']) and count($_POST['comment_id']) > 0)
|
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
UPDATE '.COMMENTS_TABLE.'
|
|
|
|
SET validated = \'true\'
|
|
|
|
WHERE id IN ('.implode(',', $_POST['comment_id']).')
|
|
|
|
;';
|
2004-10-30 17:42:29 +02:00
|
|
|
pwg_query($query);
|
2004-10-23 19:56:46 +02:00
|
|
|
}
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | page header and options |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-03-20 01:52:37 +01:00
|
|
|
if (!defined('IN_ADMIN'))
|
|
|
|
{
|
|
|
|
$title= $lang['title_comments'];
|
|
|
|
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
|
|
|
}
|
2004-02-08 02:28:18 +01:00
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
$template->set_filenames(array('comments'=>'comments.tpl'));
|
|
|
|
$template->assign_vars(
|
|
|
|
array(
|
|
|
|
'L_COMMENT_TITLE' => $title,
|
|
|
|
'L_COMMENT_STATS' => $lang['stats_last_days'],
|
|
|
|
'L_COMMENT_RETURN' => $lang['return_main_page'],
|
|
|
|
'L_DELETE' =>$lang['delete'],
|
|
|
|
'L_VALIDATE'=>$lang['submit'],
|
|
|
|
|
|
|
|
'U_HOME' => add_session_id(PHPWG_ROOT_PATH.'category.php')
|
|
|
|
)
|
|
|
|
);
|
2004-02-08 02:28:18 +01:00
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
foreach ($conf['last_days'] as $option)
|
|
|
|
{
|
2004-05-20 23:22:44 +02:00
|
|
|
$url = $_SERVER['PHP_SELF'].'?last_days='.($option - 1);
|
2004-10-23 19:56:46 +02:00
|
|
|
if (defined('IN_ADMIN'))
|
|
|
|
{
|
|
|
|
$url.= '&page=comments';
|
|
|
|
}
|
2004-05-20 23:22:44 +02:00
|
|
|
$template->assign_block_vars(
|
|
|
|
'last_day_option',
|
|
|
|
array(
|
|
|
|
'OPTION'=>$option,
|
2004-10-23 19:56:46 +02:00
|
|
|
'T_STYLE'=>(($option == MAX_DAYS + 1)?'text-decoration:underline;':''),
|
|
|
|
'U_OPTION'=>add_session_id($url)
|
2004-05-20 23:22:44 +02:00
|
|
|
)
|
|
|
|
);
|
2004-02-08 02:28:18 +01:00
|
|
|
}
|
2004-10-23 19:56:46 +02:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | last comments display |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-02-08 02:28:18 +01:00
|
|
|
// 1. retrieving picture ids which have comments recently added
|
2004-10-23 19:56:46 +02:00
|
|
|
$maxdate = date('Y-m-d', strtotime('-'.MAX_DAYS.' day'));
|
|
|
|
|
|
|
|
$query = '
|
|
|
|
SELECT DISTINCT(ic.image_id) AS image_id,(ic.category_id) AS category_id
|
|
|
|
FROM '.COMMENTS_TABLE.' AS c, '.IMAGE_CATEGORY_TABLE.' AS ic
|
|
|
|
WHERE c.image_id = ic.image_id
|
|
|
|
AND date >= \''.$maxdate.'\'';
|
|
|
|
if ($user['status'] != 'admin')
|
2003-10-04 18:08:53 +02:00
|
|
|
{
|
2004-10-23 19:56:46 +02:00
|
|
|
$query.= "
|
|
|
|
AND validated = 'true'";
|
2004-03-20 01:52:37 +01:00
|
|
|
// we must not show pictures of a forbidden category
|
2004-10-23 19:56:46 +02:00
|
|
|
if ($user['forbidden_categories'] != '')
|
2004-03-20 01:52:37 +01:00
|
|
|
{
|
2004-10-23 19:56:46 +02:00
|
|
|
$query.= '
|
|
|
|
AND category_id NOT IN ('.$user['forbidden_categories'].')';
|
2004-03-20 01:52:37 +01:00
|
|
|
}
|
2004-02-08 02:28:18 +01:00
|
|
|
}
|
2004-10-23 19:56:46 +02:00
|
|
|
$query.= '
|
|
|
|
ORDER BY ic.image_id DESC
|
|
|
|
;';
|
2004-10-30 17:42:29 +02:00
|
|
|
$result = pwg_query($query);
|
2004-10-23 19:56:46 +02:00
|
|
|
if ($user['status'] == 'admin')
|
2004-03-20 01:52:37 +01:00
|
|
|
{
|
|
|
|
$template->assign_block_vars('validation', array());
|
|
|
|
}
|
2004-10-23 19:56:46 +02:00
|
|
|
while ($row = mysql_fetch_array($result))
|
|
|
|
{
|
|
|
|
$category_id = $row['category_id'];
|
|
|
|
|
|
|
|
// for each picture, getting informations for displaying thumbnail and
|
|
|
|
// link to the full size picture
|
|
|
|
$query = '
|
2004-11-17 00:38:34 +01:00
|
|
|
SELECT name,file,storage_category_id as cat_id,tn_ext,path
|
2004-10-23 19:56:46 +02:00
|
|
|
FROM '.IMAGES_TABLE.'
|
|
|
|
WHERE id = '.$row['image_id'].'
|
|
|
|
;';
|
2004-10-30 17:42:29 +02:00
|
|
|
$subresult = pwg_query($query);
|
2004-10-23 19:56:46 +02:00
|
|
|
$subrow = mysql_fetch_array($subresult);
|
2003-10-04 18:08:53 +02:00
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
if (!isset($array_cat_names[$subrow['cat_id']]))
|
|
|
|
{
|
|
|
|
$cat_result = get_cat_info($subrow['cat_id']);
|
|
|
|
$array_cat_names[$subrow['cat_id']] =
|
|
|
|
get_cat_display_name($cat_result['name'], ' > ', '');
|
|
|
|
}
|
|
|
|
|
|
|
|
// name of the picture
|
|
|
|
$name = $array_cat_names[$category_id].' > ';
|
|
|
|
if (!empty($subrow['name']))
|
|
|
|
{
|
|
|
|
$name.= $subrow['name'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$name.= str_replace('_',' ',get_filename_wo_extension($subrow['file']));
|
|
|
|
}
|
|
|
|
$name.= ' [ '.$subrow['file'].' ]';
|
|
|
|
// source of the thumbnail picture
|
2004-11-17 00:38:34 +01:00
|
|
|
$thumbnail_src = get_thumbnail_src($subrow['path'], @$subrow['tn_ext']);
|
2004-10-23 19:56:46 +02:00
|
|
|
// link to the full size picture
|
|
|
|
$url = PHPWG_ROOT_PATH.'picture.php?cat='.$category_id;
|
|
|
|
$url.= '&image_id='.$row['image_id'];
|
|
|
|
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'picture',
|
|
|
|
array(
|
|
|
|
'TITLE_IMG'=>$name,
|
|
|
|
'I_THUMB'=>$thumbnail_src,
|
|
|
|
'U_THUMB'=>add_session_id($url)
|
|
|
|
));
|
|
|
|
|
|
|
|
// for each picture, retrieving all comments
|
|
|
|
$query = '
|
|
|
|
SELECT *
|
|
|
|
FROM '.COMMENTS_TABLE.'
|
|
|
|
WHERE image_id = '.$row['image_id'].'
|
|
|
|
AND date >= \''.$maxdate.'\'';
|
|
|
|
if ($user['status'] != 'admin')
|
|
|
|
{
|
|
|
|
$query.= '
|
|
|
|
AND validated = \'true\'';
|
|
|
|
}
|
|
|
|
$query.= '
|
|
|
|
ORDER BY date DESC
|
|
|
|
;';
|
2004-10-30 17:42:29 +02:00
|
|
|
$handleresult = pwg_query($query);
|
2004-10-23 19:56:46 +02:00
|
|
|
while ($subrow = mysql_fetch_array($handleresult))
|
|
|
|
{
|
|
|
|
$author = $subrow['author'];
|
|
|
|
if (empty($subrow['author']))
|
2003-10-04 18:08:53 +02:00
|
|
|
{
|
2004-10-23 19:56:46 +02:00
|
|
|
$author = $lang['guest'];
|
2003-10-04 18:08:53 +02:00
|
|
|
}
|
|
|
|
|
2004-08-05 19:27:09 +02:00
|
|
|
$template->assign_block_vars(
|
2004-10-23 19:56:46 +02:00
|
|
|
'picture.comment',
|
2004-08-05 19:27:09 +02:00
|
|
|
array(
|
2004-10-23 19:56:46 +02:00
|
|
|
'COMMENT_AUTHOR'=>$author,
|
|
|
|
'COMMENT_DATE'=>format_date($subrow['date'],'mysql_datetime',true),
|
|
|
|
'COMMENT'=>parse_comment_content($subrow['content']),
|
2004-08-05 19:27:09 +02:00
|
|
|
));
|
|
|
|
|
2004-10-23 19:56:46 +02:00
|
|
|
if ($user['status'] == 'admin')
|
2003-10-04 18:08:53 +02:00
|
|
|
{
|
2004-05-20 23:22:44 +02:00
|
|
|
$template->assign_block_vars(
|
2004-10-23 19:56:46 +02:00
|
|
|
'picture.comment.validation',
|
|
|
|
array(
|
|
|
|
'ID'=> $subrow['id'],
|
|
|
|
'CHECKED'=>($subrow['validated']=='false')?'checked="checked"': ''
|
2004-05-20 23:22:44 +02:00
|
|
|
));
|
2003-10-04 18:08:53 +02:00
|
|
|
}
|
|
|
|
}
|
2004-10-23 19:56:46 +02:00
|
|
|
}
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | html code display |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-03-20 01:52:37 +01:00
|
|
|
if (defined('IN_ADMIN'))
|
|
|
|
{
|
|
|
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('title',array());
|
|
|
|
$template->pparse('comments');
|
|
|
|
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
|
|
|
}
|
2004-02-12 00:20:38 +01:00
|
|
|
?>
|