1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2006-02-01 02:46:26 +0000 (Wed, 01 Feb 2006) $ |
---|
10 | // | last modifier : $Author: rvelices $ |
---|
11 | // | revision : $Revision: 1020 $ |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | This program is free software; you can redistribute it and/or modify | |
---|
14 | // | it under the terms of the GNU General Public License as published by | |
---|
15 | // | the Free Software Foundation | |
---|
16 | // | | |
---|
17 | // | This program is distributed in the hope that it will be useful, but | |
---|
18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
20 | // | General Public License for more details. | |
---|
21 | // | | |
---|
22 | // | You should have received a copy of the GNU General Public License | |
---|
23 | // | along with this program; if not, write to the Free Software | |
---|
24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
25 | // | USA. | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | |
---|
28 | $rate_items = array(0,1,2,3,4,5); |
---|
29 | //--------------------------------------------------------------------- include |
---|
30 | define('PHPWG_ROOT_PATH','./'); |
---|
31 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
32 | //-------------------------------------------------- access authorization check |
---|
33 | check_cat_id( $_GET['cat'] ); |
---|
34 | |
---|
35 | if (!isset($page['cat'])) |
---|
36 | { |
---|
37 | die($lang['access_forbiden']); |
---|
38 | } |
---|
39 | |
---|
40 | check_login_authorization(); |
---|
41 | if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) |
---|
42 | { |
---|
43 | check_restrictions( $page['cat'] ); |
---|
44 | } |
---|
45 | //---------------------------------------- incrementation of the number of hits |
---|
46 | if ( count(array_intersect( |
---|
47 | array_keys($_GET), |
---|
48 | array('add_fav', 'caddie', 'rate', 'representative', 'del') ) |
---|
49 | )==0 ) |
---|
50 | { |
---|
51 | $query = ' |
---|
52 | UPDATE '.IMAGES_TABLE.' |
---|
53 | SET hit = hit+1 |
---|
54 | WHERE id = '.$_GET['image_id'].' |
---|
55 | ;'; |
---|
56 | @pwg_query( $query ); |
---|
57 | } |
---|
58 | //-------------------------------------------------------------- initialization |
---|
59 | initialize_category( 'picture' ); |
---|
60 | // retrieving the number of the picture in its category (in order) |
---|
61 | $query = ' |
---|
62 | SELECT DISTINCT(id) |
---|
63 | FROM '.IMAGES_TABLE.' |
---|
64 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id |
---|
65 | '.$page['where'].' |
---|
66 | '.$conf['order_by'].' |
---|
67 | ;'; |
---|
68 | $result = pwg_query( $query ); |
---|
69 | $page['num'] = 0; |
---|
70 | $belongs = false; |
---|
71 | while ($row = mysql_fetch_array($result)) |
---|
72 | { |
---|
73 | if ($row['id'] == $_GET['image_id']) |
---|
74 | { |
---|
75 | $belongs = true; |
---|
76 | break; |
---|
77 | } |
---|
78 | if ($page['num']==0) |
---|
79 | { |
---|
80 | $url_first_last = PHPWG_ROOT_PATH.'picture.php'; |
---|
81 | $url_first_last.= get_query_string_diff(array('image_id','add_fav', |
---|
82 | 'slideshow','rate')); |
---|
83 | $url_first_last.= '&image_id='; |
---|
84 | $template->assign_block_vars( |
---|
85 | 'first', |
---|
86 | array( |
---|
87 | 'U_IMG' => $url_first_last . $row['id'], |
---|
88 | )); |
---|
89 | } |
---|
90 | $page['num']++; |
---|
91 | } |
---|
92 | if ($page['cat_nb_images']>0 and $page['num'] < $page['cat_nb_images'] - 1) |
---|
93 | { |
---|
94 | mysql_data_seek($result, $page['cat_nb_images'] - 1); |
---|
95 | $row = mysql_fetch_array($result); |
---|
96 | $url_first_last = PHPWG_ROOT_PATH.'picture.php'; |
---|
97 | $url_first_last.= get_query_string_diff(array('image_id','add_fav', |
---|
98 | 'slideshow','rate')); |
---|
99 | $url_first_last.= '&image_id='; |
---|
100 | $template->assign_block_vars( |
---|
101 | 'last', |
---|
102 | array( |
---|
103 | 'U_IMG' => $url_first_last . $row['id'], |
---|
104 | )); |
---|
105 | } |
---|
106 | |
---|
107 | // if this image_id doesn't correspond to this category, an error message is |
---|
108 | // displayed, and execution is stopped |
---|
109 | if (!$belongs) |
---|
110 | { |
---|
111 | echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />'; |
---|
112 | echo '<a href="'.PHPWG_ROOT_PATH.'category.php'.'">'; |
---|
113 | echo $lang['thumbnails'].'</a></div>'; |
---|
114 | exit(); |
---|
115 | } |
---|
116 | //-------------------------------------------------------------- representative |
---|
117 | if ('admin' == $user['status'] and isset($_GET['representative'])) |
---|
118 | { |
---|
119 | $query = ' |
---|
120 | UPDATE '.CATEGORIES_TABLE.' |
---|
121 | SET representative_picture_id = '.$_GET['image_id'].' |
---|
122 | WHERE id = '.$page['cat'].' |
---|
123 | ;'; |
---|
124 | pwg_query($query); |
---|
125 | |
---|
126 | $url = |
---|
127 | PHPWG_ROOT_PATH |
---|
128 | .'picture.php' |
---|
129 | .get_query_string_diff(array('representative')); |
---|
130 | redirect($url); |
---|
131 | } |
---|
132 | |
---|
133 | //-------------------------------------------------------------- caddie filling |
---|
134 | |
---|
135 | if (isset($_GET['caddie'])) |
---|
136 | { |
---|
137 | fill_caddie(array($_GET['image_id'])); |
---|
138 | |
---|
139 | $url = |
---|
140 | PHPWG_ROOT_PATH |
---|
141 | .'picture.php' |
---|
142 | .get_query_string_diff(array('caddie')); |
---|
143 | redirect($url); |
---|
144 | } |
---|
145 | |
---|
146 | //---------------------------------------------------------- related categories |
---|
147 | $query = ' |
---|
148 | SELECT category_id,uppercats,commentable,global_rank |
---|
149 | FROM '.IMAGE_CATEGORY_TABLE.' |
---|
150 | INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id |
---|
151 | WHERE image_id = '.$_GET['image_id'].' |
---|
152 | AND category_id NOT IN ('.$user['forbidden_categories'].') |
---|
153 | ;'; |
---|
154 | $result = pwg_query($query); |
---|
155 | $related_categories = array(); |
---|
156 | while ($row = mysql_fetch_array($result)) |
---|
157 | { |
---|
158 | array_push($related_categories, $row); |
---|
159 | } |
---|
160 | usort($related_categories, 'global_rank_compare'); |
---|
161 | //------------------------------------- prev, current & next picture management |
---|
162 | $picture = array(); |
---|
163 | |
---|
164 | if ($page['num'] == 0) |
---|
165 | { |
---|
166 | $has_prev = false; |
---|
167 | } |
---|
168 | else |
---|
169 | { |
---|
170 | $has_prev = true; |
---|
171 | } |
---|
172 | |
---|
173 | if ($page['num'] == $page['cat_nb_images'] - 1) |
---|
174 | { |
---|
175 | $has_next = false; |
---|
176 | } |
---|
177 | else |
---|
178 | { |
---|
179 | $has_next = true; |
---|
180 | } |
---|
181 | |
---|
182 | $query = ' |
---|
183 | SELECT DISTINCT(i.id), i.* |
---|
184 | FROM '.IMAGES_TABLE.' AS i |
---|
185 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id |
---|
186 | '.$page['where'].' |
---|
187 | '.$conf['order_by'].' |
---|
188 | '; |
---|
189 | |
---|
190 | if ( !$has_prev ) |
---|
191 | { |
---|
192 | $query.= ' LIMIT 0,2'; |
---|
193 | } |
---|
194 | else |
---|
195 | { |
---|
196 | $query.= ' LIMIT '.($page['num'] - 1).',3'; |
---|
197 | } |
---|
198 | $query.= ';'; |
---|
199 | |
---|
200 | $result = pwg_query( $query ); |
---|
201 | $indexes = array('prev', 'current', 'next'); |
---|
202 | |
---|
203 | foreach (array('prev', 'current', 'next') as $i) |
---|
204 | { |
---|
205 | if ($i == 'prev' and !$has_prev) |
---|
206 | { |
---|
207 | continue; |
---|
208 | } |
---|
209 | if ($i == 'next' and !$has_next) |
---|
210 | { |
---|
211 | break; |
---|
212 | } |
---|
213 | |
---|
214 | $row = mysql_fetch_array($result); |
---|
215 | foreach (array_keys($row) as $key) |
---|
216 | { |
---|
217 | if (!is_numeric($key)) |
---|
218 | { |
---|
219 | $picture[$i][$key] = $row[$key]; |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | $picture[$i]['is_picture'] = false; |
---|
224 | if (in_array(get_extension($row['file']), $conf['picture_ext'])) |
---|
225 | { |
---|
226 | $picture[$i]['is_picture'] = true; |
---|
227 | } |
---|
228 | |
---|
229 | $cat_directory = dirname($row['path']); |
---|
230 | $file_wo_ext = get_filename_wo_extension($row['file']); |
---|
231 | |
---|
232 | $icon = get_themeconf('mime_icon_dir'); |
---|
233 | $icon.= strtolower(get_extension($row['file'])).'.png'; |
---|
234 | |
---|
235 | if (isset($row['representative_ext']) and $row['representative_ext'] != '') |
---|
236 | { |
---|
237 | $picture[$i]['src'] = $cat_directory.'/pwg_representative/'; |
---|
238 | $picture[$i]['src'].= $file_wo_ext.'.'.$row['representative_ext']; |
---|
239 | } |
---|
240 | else |
---|
241 | { |
---|
242 | $picture[$i]['src'] = $icon; |
---|
243 | } |
---|
244 | // special case for picture files |
---|
245 | if ($picture[$i]['is_picture']) |
---|
246 | { |
---|
247 | $picture[$i]['src'] = $row['path']; |
---|
248 | // if we are working on the "current" element, we search if there is a |
---|
249 | // high quality picture |
---|
250 | if ($i == 'current') |
---|
251 | { |
---|
252 | $url_high=$cat_directory.'/pwg_high/'.$row['file']; |
---|
253 | if (url_is_remote($cat_directory)) |
---|
254 | { |
---|
255 | if ($row['has_high']) |
---|
256 | { |
---|
257 | $picture[$i]['high'] = $url_high; |
---|
258 | } |
---|
259 | } |
---|
260 | else |
---|
261 | { |
---|
262 | if (@fopen($url_high, 'r')) |
---|
263 | { |
---|
264 | $picture[$i]['high'] = $url_high; |
---|
265 | } |
---|
266 | } |
---|
267 | } |
---|
268 | } |
---|
269 | |
---|
270 | // if picture is not a file, we need the download link |
---|
271 | if (!$picture[$i]['is_picture']) |
---|
272 | { |
---|
273 | $picture[$i]['download'] = $row['path']; |
---|
274 | } |
---|
275 | |
---|
276 | $picture[$i]['thumbnail'] = get_thumbnail_src($row['path'], @$row['tn_ext']); |
---|
277 | |
---|
278 | if ( !empty( $row['name'] ) ) |
---|
279 | { |
---|
280 | $picture[$i]['name'] = $row['name']; |
---|
281 | } |
---|
282 | else |
---|
283 | { |
---|
284 | $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext); |
---|
285 | } |
---|
286 | |
---|
287 | $picture[$i]['url'] = PHPWG_ROOT_PATH.'picture.php'; |
---|
288 | $picture[$i]['url'].= get_query_string_diff(array('image_id','add_fav', |
---|
289 | 'slideshow','rate')); |
---|
290 | $picture[$i]['url'].= '&image_id='.$row['id']; |
---|
291 | } |
---|
292 | |
---|
293 | $url_up = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat']; |
---|
294 | $url_up_start = floor( $page['num'] / $user['nb_image_page'] ); |
---|
295 | $url_up_start *= $user['nb_image_page']; |
---|
296 | if ($url_up_start>0) |
---|
297 | { |
---|
298 | $url_up .= '&start='.$url_up_start; |
---|
299 | } |
---|
300 | |
---|
301 | if ( $page['cat'] == 'search' ) |
---|
302 | { |
---|
303 | $url_up.= "&search=".$_GET['search']; |
---|
304 | } |
---|
305 | if ( $page['cat'] == 'list' ) |
---|
306 | { |
---|
307 | $url_up.= "&list=".$_GET['list']; |
---|
308 | } |
---|
309 | |
---|
310 | $url_admin = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; |
---|
311 | $url_admin.= '&cat_id='.$page['cat']; |
---|
312 | $url_admin.= '&image_id='.$_GET['image_id']; |
---|
313 | |
---|
314 | $url_slide = $picture['current']['url']; |
---|
315 | $url_slide.= '&slideshow='.$conf['slideshow_period']; |
---|
316 | |
---|
317 | //----------------------------------------------------------- rate registration |
---|
318 | if (isset($_GET['rate']) |
---|
319 | and $conf['rate'] |
---|
320 | and !$user['is_the_guest'] |
---|
321 | and in_array($_GET['rate'], $rate_items)) |
---|
322 | { |
---|
323 | $query = ' |
---|
324 | DELETE |
---|
325 | FROM '.RATE_TABLE.' |
---|
326 | WHERE user_id = '.$user['id'].' |
---|
327 | AND element_id = '.$_GET['image_id'].' |
---|
328 | ;'; |
---|
329 | pwg_query($query); |
---|
330 | $query = ' |
---|
331 | INSERT INTO '.RATE_TABLE.' |
---|
332 | (user_id,element_id,rate) |
---|
333 | VALUES |
---|
334 | ('.$user['id'].','.$_GET['image_id'].','.$_GET['rate'].') |
---|
335 | ;'; |
---|
336 | pwg_query($query); |
---|
337 | |
---|
338 | // update of images.average_rate field |
---|
339 | $query = ' |
---|
340 | SELECT ROUND(AVG(rate),2) AS average_rate |
---|
341 | FROM '.RATE_TABLE.' |
---|
342 | WHERE element_id = '.$_GET['image_id'].' |
---|
343 | ;'; |
---|
344 | $row = mysql_fetch_array(pwg_query($query)); |
---|
345 | $query = ' |
---|
346 | UPDATE '.IMAGES_TABLE.' |
---|
347 | SET average_rate = '.$row['average_rate'].' |
---|
348 | WHERE id = '.$_GET['image_id'].' |
---|
349 | ;'; |
---|
350 | pwg_query($query); |
---|
351 | } |
---|
352 | //--------------------------------------------------------- favorite management |
---|
353 | if ( isset( $_GET['add_fav'] ) ) |
---|
354 | { |
---|
355 | $query = 'DELETE FROM '.FAVORITES_TABLE; |
---|
356 | $query.= ' WHERE user_id = '.$user['id']; |
---|
357 | $query.= ' AND image_id = '.$picture['current']['id']; |
---|
358 | $query.= ';'; |
---|
359 | $result = pwg_query( $query ); |
---|
360 | |
---|
361 | if ( $_GET['add_fav'] == 1 ) |
---|
362 | { |
---|
363 | $query = 'INSERT INTO '.FAVORITES_TABLE; |
---|
364 | $query.= ' (image_id,user_id) VALUES'; |
---|
365 | $query.= ' ('.$picture['current']['id'].','.$user['id'].')'; |
---|
366 | $query.= ';'; |
---|
367 | $result = pwg_query( $query ); |
---|
368 | } |
---|
369 | if ( !$_GET['add_fav'] and $page['cat'] == 'fav' ) |
---|
370 | { |
---|
371 | if (!$has_prev and !$has_next) |
---|
372 | { |
---|
373 | // there is no favorite picture anymore we redirect the user to the |
---|
374 | // category page |
---|
375 | redirect($url_up); |
---|
376 | } |
---|
377 | else if (!$has_prev) |
---|
378 | { |
---|
379 | $url = str_replace( '&', '&', $picture['next']['url'] ); |
---|
380 | redirect( $url ); |
---|
381 | } |
---|
382 | else |
---|
383 | { |
---|
384 | $url = str_replace('&', '&', $picture['prev']['url'] ); |
---|
385 | redirect( $url ); |
---|
386 | } |
---|
387 | redirect( $url ); |
---|
388 | } |
---|
389 | } |
---|
390 | |
---|
391 | //------------------------------------------------------ comment registeration |
---|
392 | if ( isset( $_POST['content'] ) && !empty($_POST['content']) ) |
---|
393 | { |
---|
394 | $register_comment = true; |
---|
395 | $author = !empty($_POST['author'])?$_POST['author']:$lang['guest']; |
---|
396 | // if a guest try to use the name of an already existing user, he must be |
---|
397 | // rejected |
---|
398 | if ( $author != $user['username'] ) |
---|
399 | { |
---|
400 | $query = 'SELECT COUNT(*) AS user_exists'; |
---|
401 | $query.= ' FROM '.USERS_TABLE; |
---|
402 | $query.= ' WHERE '.$conf['user_fields']['username']." = '".$author."'"; |
---|
403 | $query.= ';'; |
---|
404 | $row = mysql_fetch_array( pwg_query( $query ) ); |
---|
405 | if ( $row['user_exists'] == 1 ) |
---|
406 | { |
---|
407 | $template->assign_block_vars( |
---|
408 | 'information', |
---|
409 | array('INFORMATION'=>$lang['comment_user_exists'])); |
---|
410 | $register_comment = false; |
---|
411 | } |
---|
412 | } |
---|
413 | |
---|
414 | if ( $register_comment ) |
---|
415 | { |
---|
416 | // anti-flood system |
---|
417 | $reference_date = time() - $conf['anti-flood_time']; |
---|
418 | $query = 'SELECT id FROM '.COMMENTS_TABLE; |
---|
419 | $query.= ' WHERE date > FROM_UNIXTIME('.$reference_date.')'; |
---|
420 | $query.= " AND author = '".$author."'"; |
---|
421 | $query.= ';'; |
---|
422 | if ( mysql_num_rows( pwg_query( $query ) ) == 0 |
---|
423 | or $conf['anti-flood_time'] == 0 ) |
---|
424 | { |
---|
425 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
426 | |
---|
427 | $data = array(); |
---|
428 | $data{'author'} = $author; |
---|
429 | $data{'date'} = $dbnow; |
---|
430 | $data{'image_id'} = $_GET['image_id']; |
---|
431 | $data{'content'} = htmlspecialchars( $_POST['content'], ENT_QUOTES); |
---|
432 | |
---|
433 | if (!$conf['comments_validation'] or $user['status'] == 'admin') |
---|
434 | { |
---|
435 | $data{'validated'} = 'true'; |
---|
436 | $data{'validation_date'} = $dbnow; |
---|
437 | } |
---|
438 | else |
---|
439 | { |
---|
440 | $data{'validated'} = 'false'; |
---|
441 | } |
---|
442 | |
---|
443 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
444 | $fields = array('author', 'date', 'image_id', 'content', 'validated', |
---|
445 | 'validation_date'); |
---|
446 | mass_inserts(COMMENTS_TABLE, $fields, array($data)); |
---|
447 | |
---|
448 | // information message |
---|
449 | $message = $lang['comment_added']; |
---|
450 | |
---|
451 | if (!$conf['comments_validation'] or $user['status'] == 'admin') |
---|
452 | |
---|
453 | if ( $conf['comments_validation'] and $user['status'] != 'admin' ) |
---|
454 | { |
---|
455 | $message.= '<br />'.$lang['comment_to_validate']; |
---|
456 | } |
---|
457 | $template->assign_block_vars('information', |
---|
458 | array('INFORMATION'=>$message)); |
---|
459 | } |
---|
460 | else |
---|
461 | { |
---|
462 | // information message |
---|
463 | $template->assign_block_vars( |
---|
464 | 'information', |
---|
465 | array('INFORMATION'=>$lang['comment_anti-flood'])); |
---|
466 | } |
---|
467 | } |
---|
468 | } |
---|
469 | // comment deletion |
---|
470 | if ( isset( $_GET['del'] ) |
---|
471 | and is_numeric( $_GET['del'] ) |
---|
472 | and $user['status'] == 'admin' ) |
---|
473 | { |
---|
474 | $query = 'DELETE FROM '.COMMENTS_TABLE; |
---|
475 | $query.= ' WHERE id = '.$_GET['del']; |
---|
476 | $query.= ';'; |
---|
477 | pwg_query( $query ); |
---|
478 | } |
---|
479 | |
---|
480 | // |
---|
481 | // Start output of page |
---|
482 | // |
---|
483 | |
---|
484 | $title = $picture['current']['name']; |
---|
485 | $refresh = 0; |
---|
486 | if ( isset( $_GET['slideshow'] ) and $has_next ) |
---|
487 | { |
---|
488 | $refresh= $_GET['slideshow']; |
---|
489 | $url_link = $picture['next']['url'].'&slideshow='.$refresh; |
---|
490 | } |
---|
491 | |
---|
492 | $title_img = $picture['current']['name']; |
---|
493 | $title_nb = ''; |
---|
494 | if (is_numeric( $page['cat'] )) |
---|
495 | { |
---|
496 | $title_img = replace_space(get_cat_display_name($page['cat_name'])); |
---|
497 | $n = $page['num'] + 1; |
---|
498 | $title_nb = $n.'/'.$page['cat_nb_images']; |
---|
499 | } |
---|
500 | else if ( $page['cat'] == 'search' ) |
---|
501 | { |
---|
502 | $title_img = replace_search( $title_img, $_GET['search'] ); |
---|
503 | } |
---|
504 | |
---|
505 | // calculation of width and height |
---|
506 | if (empty($picture['current']['width'])) |
---|
507 | { |
---|
508 | $taille_image = @getimagesize($picture['current']['src']); |
---|
509 | $original_width = $taille_image[0]; |
---|
510 | $original_height = $taille_image[1]; |
---|
511 | } |
---|
512 | else |
---|
513 | { |
---|
514 | $original_width = $picture['current']['width']; |
---|
515 | $original_height = $picture['current']['height']; |
---|
516 | } |
---|
517 | |
---|
518 | $picture_size = get_picture_size($original_width, $original_height, |
---|
519 | @$user['maxwidth'], @$user['maxheight']); |
---|
520 | |
---|
521 | // metadata |
---|
522 | if ($conf['show_exif'] or $conf['show_iptc']) |
---|
523 | { |
---|
524 | $metadata_showable = true; |
---|
525 | } |
---|
526 | else |
---|
527 | { |
---|
528 | $metadata_showable = false; |
---|
529 | } |
---|
530 | |
---|
531 | $url_metadata = PHPWG_ROOT_PATH.'picture.php'; |
---|
532 | $url_metadata .= get_query_string_diff(array('add_fav', 'slideshow', 'show_metadata')); |
---|
533 | if ($metadata_showable and !isset($_GET['show_metadata'])) |
---|
534 | { |
---|
535 | $url_metadata.= '&show_metadata=1'; |
---|
536 | } |
---|
537 | |
---|
538 | $page['body_id'] = 'thePicturePage'; |
---|
539 | //-------------------------------------------------------- navigation management |
---|
540 | if ($has_prev) |
---|
541 | { |
---|
542 | $template->assign_block_vars( |
---|
543 | 'previous', |
---|
544 | array( |
---|
545 | 'TITLE_IMG' => $picture['prev']['name'], |
---|
546 | 'IMG' => $picture['prev']['thumbnail'], |
---|
547 | 'U_IMG' => $picture['prev']['url'], |
---|
548 | 'U_IMG_SRC' => $picture['prev']['src'] |
---|
549 | )); |
---|
550 | } |
---|
551 | |
---|
552 | if ($has_next) |
---|
553 | { |
---|
554 | $template->assign_block_vars( |
---|
555 | 'next', |
---|
556 | array( |
---|
557 | 'TITLE_IMG' => $picture['next']['name'], |
---|
558 | 'IMG' => $picture['next']['thumbnail'], |
---|
559 | 'U_IMG' => $picture['next']['url'], |
---|
560 | 'U_IMG_SRC' => $picture['next']['src'] // allow navigator to preload |
---|
561 | )); |
---|
562 | } |
---|
563 | |
---|
564 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
565 | $template->set_filenames(array('picture'=>'picture.tpl')); |
---|
566 | |
---|
567 | $template->assign_vars(array( |
---|
568 | 'CATEGORY' => $title_img, |
---|
569 | 'PHOTO' => $title_nb, |
---|
570 | 'TITLE' => $picture['current']['name'], |
---|
571 | 'SRC_IMG' => $picture['current']['src'], |
---|
572 | 'ALT_IMG' => $picture['current']['file'], |
---|
573 | 'WIDTH_IMG' => $picture_size[0], |
---|
574 | 'HEIGHT_IMG' => $picture_size[1], |
---|
575 | |
---|
576 | 'LEVEL_SEPARATOR' => $conf['level_separator'], |
---|
577 | |
---|
578 | 'L_HOME' => $lang['home'], |
---|
579 | 'L_SLIDESHOW' => $lang['slideshow'], |
---|
580 | 'L_STOP_SLIDESHOW' => $lang['slideshow_stop'], |
---|
581 | 'L_PREV_IMG' =>$lang['previous_page'].' : ', |
---|
582 | 'L_NEXT_IMG' =>$lang['next_page'].' : ', |
---|
583 | 'L_ADMIN' =>$lang['link_info_image'], |
---|
584 | 'L_COMMENT_TITLE' =>$lang['comments_title'], |
---|
585 | 'L_ADD_COMMENT' =>$lang['comments_add'], |
---|
586 | 'L_DELETE_COMMENT' =>$lang['comments_del'], |
---|
587 | 'L_DELETE' =>$lang['delete'], |
---|
588 | 'L_SUBMIT' =>$lang['submit'], |
---|
589 | 'L_AUTHOR' => $lang['upload_author'], |
---|
590 | 'L_COMMENT' =>$lang['comment'], |
---|
591 | 'L_DOWNLOAD' => $lang['download'], |
---|
592 | 'L_DOWNLOAD_HINT' => $lang['download_hint'], |
---|
593 | 'L_PICTURE_METADATA' => $lang['picture_show_metadata'], |
---|
594 | 'L_PICTURE_HIGH' => $lang['picture_high'], |
---|
595 | 'L_UP_HINT' => $lang['home_hint'], |
---|
596 | 'L_UP_ALT' => $lang['home'], |
---|
597 | |
---|
598 | 'U_HOME' => (PHPWG_ROOT_PATH.'category.php'), |
---|
599 | 'U_UP' => $url_up, |
---|
600 | 'U_METADATA' => $url_metadata, |
---|
601 | 'U_ADMIN' => $url_admin, |
---|
602 | 'U_SLIDESHOW'=> $url_slide, |
---|
603 | 'U_ADD_COMMENT' => str_replace( '&', '&', $_SERVER['REQUEST_URI'] ) |
---|
604 | ) |
---|
605 | ); |
---|
606 | |
---|
607 | if ($conf['show_picture_name_on_title']) |
---|
608 | { |
---|
609 | $template->assign_block_vars('title', array()); |
---|
610 | } |
---|
611 | |
---|
612 | //------------------------------------------------------- upper menu management |
---|
613 | // download link if file is not a picture |
---|
614 | if (!$picture['current']['is_picture']) |
---|
615 | { |
---|
616 | $template->assign_block_vars( |
---|
617 | 'download', |
---|
618 | array('U_DOWNLOAD' => $picture['current']['download'])); |
---|
619 | } |
---|
620 | // display a high quality link if present |
---|
621 | if (isset($picture['current']['high'])) |
---|
622 | { |
---|
623 | $uuid = uniqid(rand()); |
---|
624 | $template->assign_block_vars('high', array( |
---|
625 | 'U_HIGH' => $picture['current']['high'], |
---|
626 | 'UUID'=>$uuid |
---|
627 | )); |
---|
628 | $template->assign_block_vars( |
---|
629 | 'download', |
---|
630 | array('U_DOWNLOAD' => PHPWG_ROOT_PATH.'action.php?dwn=' |
---|
631 | .$picture['current']['high'] |
---|
632 | ) |
---|
633 | ); |
---|
634 | } |
---|
635 | // button to set the current picture as representative |
---|
636 | if ('admin' == $user['status'] and is_numeric($page['cat'])) |
---|
637 | { |
---|
638 | $template->assign_block_vars( |
---|
639 | 'representative', |
---|
640 | array( |
---|
641 | 'URL' => |
---|
642 | PHPWG_ROOT_PATH.'picture.php' |
---|
643 | .get_query_string_diff(array()) |
---|
644 | .'&representative=1' |
---|
645 | ) |
---|
646 | ); |
---|
647 | } |
---|
648 | |
---|
649 | if ('admin' == $user['status']) |
---|
650 | { |
---|
651 | $template->assign_block_vars( |
---|
652 | 'caddie', |
---|
653 | array( |
---|
654 | 'URL' => |
---|
655 | PHPWG_ROOT_PATH.'picture.php' |
---|
656 | .get_query_string_diff(array('caddie')).'&caddie=1') |
---|
657 | ); |
---|
658 | } |
---|
659 | |
---|
660 | //------------------------------------------------------- favorite manipulation |
---|
661 | if ( !$user['is_the_guest'] ) |
---|
662 | { |
---|
663 | // verify if the picture is already in the favorite of the user |
---|
664 | $query = 'SELECT COUNT(*) AS nb_fav'; |
---|
665 | $query.= ' FROM '.FAVORITES_TABLE.' WHERE image_id = '.$_GET['image_id']; |
---|
666 | $query.= ' AND user_id = '.$user['id'].';'; |
---|
667 | $result = pwg_query( $query ); |
---|
668 | $row = mysql_fetch_array( $result ); |
---|
669 | if (!$row['nb_fav']) |
---|
670 | { |
---|
671 | $url = PHPWG_ROOT_PATH.'picture.php'; |
---|
672 | $url.= get_query_string_diff(array('rate','add_fav')); |
---|
673 | $url.= '&add_fav=1'; |
---|
674 | |
---|
675 | $template->assign_block_vars( |
---|
676 | 'favorite', |
---|
677 | array( |
---|
678 | 'FAVORITE_IMG' => get_themeconf('icon_dir').'/favorite.png', |
---|
679 | 'FAVORITE_HINT' =>$lang['add_favorites_hint'], |
---|
680 | 'FAVORITE_ALT' =>$lang['add_favorites_alt'], |
---|
681 | 'U_FAVORITE' => $url |
---|
682 | )); |
---|
683 | } |
---|
684 | else |
---|
685 | { |
---|
686 | $url = PHPWG_ROOT_PATH.'picture.php'; |
---|
687 | $url.= get_query_string_diff(array('rate','add_fav')); |
---|
688 | $url.= '&add_fav=0'; |
---|
689 | |
---|
690 | $template->assign_block_vars( |
---|
691 | 'favorite', |
---|
692 | array( |
---|
693 | 'FAVORITE_IMG' => get_themeconf('icon_dir').'/del_favorite.png', |
---|
694 | 'FAVORITE_HINT' =>$lang['del_favorites_hint'], |
---|
695 | 'FAVORITE_ALT' =>$lang['del_favorites_alt'], |
---|
696 | 'U_FAVORITE'=> $url |
---|
697 | )); |
---|
698 | } |
---|
699 | } |
---|
700 | //------------------------------------ admin link for information modifications |
---|
701 | if ( $user['status'] == 'admin' ) |
---|
702 | { |
---|
703 | $template->assign_block_vars('admin', array()); |
---|
704 | } |
---|
705 | |
---|
706 | //--------------------------------------------------------- picture information |
---|
707 | // legend |
---|
708 | if (isset($picture['current']['comment']) |
---|
709 | and !empty($picture['current']['comment'])) |
---|
710 | { |
---|
711 | $template->assign_block_vars( |
---|
712 | 'legend', |
---|
713 | array( |
---|
714 | 'COMMENT_IMG' => nl2br($picture['current']['comment']) |
---|
715 | )); |
---|
716 | } |
---|
717 | |
---|
718 | $infos = array(); |
---|
719 | |
---|
720 | // author |
---|
721 | if (!empty($picture['current']['author'])) |
---|
722 | { |
---|
723 | $infos['INFO_AUTHOR'] = |
---|
724 | // FIXME because of search engine partial rewrite, giving the author |
---|
725 | // name threw GET is not supported anymore. This feature should come |
---|
726 | // back later, with a better design |
---|
727 | // '<a href="'. |
---|
728 | // PHPWG_ROOT_PATH.'category.php?cat=search'. |
---|
729 | // '&search=author:'.$picture['current']['author'] |
---|
730 | // .'">'.$picture['current']['author'].'</a>'; |
---|
731 | $picture['current']['author']; |
---|
732 | } |
---|
733 | else |
---|
734 | { |
---|
735 | $infos['INFO_AUTHOR'] = l10n('N/A'); |
---|
736 | } |
---|
737 | |
---|
738 | // creation date |
---|
739 | if (!empty($picture['current']['date_creation'])) |
---|
740 | { |
---|
741 | $infos['INFO_CREATION_DATE'] = |
---|
742 | // FIXME because of search engine partial rewrite, giving the author |
---|
743 | // name threw GET is not supported anymore. This feature should come |
---|
744 | // back later, with a better design (calendar view). |
---|
745 | // '<a href="'. |
---|
746 | // PHPWG_ROOT_PATH.'category.php?cat=search'. |
---|
747 | // '&search=date_creation:'.$picture['current']['date_creation'] |
---|
748 | // .'">'.format_date($picture['current']['date_creation']).'</a>'; |
---|
749 | format_date($picture['current']['date_creation']); |
---|
750 | } |
---|
751 | else |
---|
752 | { |
---|
753 | $infos['INFO_CREATION_DATE'] = l10n('N/A'); |
---|
754 | } |
---|
755 | |
---|
756 | // date of availability |
---|
757 | $infos['INFO_AVAILABILITY_DATE'] = |
---|
758 | // FIXME because of search engine partial rewrite, giving the author |
---|
759 | // name threw GET is not supported anymore. This feature should come |
---|
760 | // back later, with a better design (calendar view). |
---|
761 | // |
---|
762 | // '<a href="'. |
---|
763 | // PHPWG_ROOT_PATH.'category.php?cat=search'. |
---|
764 | // '&search=date_available:'. |
---|
765 | // substr($picture['current']['date_available'], 0, 10) |
---|
766 | // .'">'. |
---|
767 | // format_date($picture['current']['date_available'], 'mysql_datetime'). |
---|
768 | // '</a>'; |
---|
769 | format_date($picture['current']['date_available'], 'mysql_datetime'); |
---|
770 | |
---|
771 | // size in pixels |
---|
772 | if ($picture['current']['is_picture']) |
---|
773 | { |
---|
774 | if ($original_width != $picture_size[0] |
---|
775 | or $original_height != $picture_size[1]) |
---|
776 | { |
---|
777 | $infos['INFO_DIMENSIONS'] = |
---|
778 | '<a href="'.$picture['current']['src'].'" title="'. |
---|
779 | l10n('Original dimensions').'">'. |
---|
780 | $original_width.'*'.$original_height.'</a>'; |
---|
781 | } |
---|
782 | else |
---|
783 | { |
---|
784 | $infos['INFO_DIMENSIONS'] = $original_width.'*'.$original_height; |
---|
785 | } |
---|
786 | } |
---|
787 | else |
---|
788 | { |
---|
789 | $infos['INFO_DIMENSIONS'] = l10n('N/A'); |
---|
790 | } |
---|
791 | |
---|
792 | // filesize |
---|
793 | if (!empty($picture['current']['filesize'])) |
---|
794 | { |
---|
795 | $infos['INFO_FILESIZE'] = |
---|
796 | sprintf(l10n('%d Kb'), $picture['current']['filesize']); |
---|
797 | } |
---|
798 | else |
---|
799 | { |
---|
800 | $infos['INFO_FILESIZE'] = l10n('N/A'); |
---|
801 | } |
---|
802 | |
---|
803 | // number of visits |
---|
804 | $infos['INFO_VISITS'] = $picture['current']['hit']; |
---|
805 | |
---|
806 | // file |
---|
807 | $infos['INFO_FILE'] = $picture['current']['file']; |
---|
808 | |
---|
809 | // keywords |
---|
810 | if (!empty($picture['current']['keywords'])) |
---|
811 | { |
---|
812 | $infos['INFO_KEYWORDS'] = |
---|
813 | // FIXME because of search engine partial rewrite, giving the author |
---|
814 | // name threw GET is not supported anymore. This feature should come |
---|
815 | // back later, with a better design (tag classification). |
---|
816 | // preg_replace( |
---|
817 | // '/([^,]+)/', |
---|
818 | // '<a href="'. |
---|
819 | // PHPWG_ROOT_PATH.'category.php?cat=search&search=keywords:$1' |
---|
820 | // .'">$1</a>', |
---|
821 | // $picture['current']['keywords'] |
---|
822 | // ); |
---|
823 | $picture['current']['keywords']; |
---|
824 | } |
---|
825 | else |
---|
826 | { |
---|
827 | $infos['INFO_KEYWORDS'] = l10n('N/A'); |
---|
828 | } |
---|
829 | |
---|
830 | $template->assign_vars($infos); |
---|
831 | |
---|
832 | // related categories |
---|
833 | foreach ($related_categories as $category) |
---|
834 | { |
---|
835 | $template->assign_block_vars( |
---|
836 | 'category', |
---|
837 | array( |
---|
838 | 'LINE' => count($related_categories) > 3 |
---|
839 | ? get_cat_display_name_cache($category['uppercats']) |
---|
840 | : get_cat_display_name_from_id($category['category_id']) |
---|
841 | ) |
---|
842 | ); |
---|
843 | } |
---|
844 | |
---|
845 | //------------------------------------------------------------------- metadata |
---|
846 | if ($metadata_showable and isset($_GET['show_metadata'])) |
---|
847 | { |
---|
848 | include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php'); |
---|
849 | $template->assign_block_vars('metadata', array()); |
---|
850 | if ($conf['show_exif']) |
---|
851 | { |
---|
852 | if (!function_exists('read_exif_data')) |
---|
853 | { |
---|
854 | die('Exif extension not available, admin should disable exif display'); |
---|
855 | } |
---|
856 | |
---|
857 | if ($exif = @read_exif_data($picture['current']['src'])) |
---|
858 | { |
---|
859 | $template->assign_block_vars( |
---|
860 | 'metadata.headline', |
---|
861 | array('TITLE' => 'EXIF Metadata') |
---|
862 | ); |
---|
863 | |
---|
864 | foreach ($conf['show_exif_fields'] as $field) |
---|
865 | { |
---|
866 | if (strpos($field, ';') === false) |
---|
867 | { |
---|
868 | if (isset($exif[$field])) |
---|
869 | { |
---|
870 | $key = $field; |
---|
871 | if (isset($lang['exif_field_'.$field])) |
---|
872 | { |
---|
873 | $key = $lang['exif_field_'.$field]; |
---|
874 | } |
---|
875 | |
---|
876 | $template->assign_block_vars( |
---|
877 | 'metadata.line', |
---|
878 | array( |
---|
879 | 'KEY' => $key, |
---|
880 | 'VALUE' => $exif[$field] |
---|
881 | ) |
---|
882 | ); |
---|
883 | } |
---|
884 | } |
---|
885 | else |
---|
886 | { |
---|
887 | $tokens = explode(';', $field); |
---|
888 | if (isset($exif[$tokens[0]][$tokens[1]])) |
---|
889 | { |
---|
890 | $key = $tokens[1]; |
---|
891 | if (isset($lang['exif_field_'.$tokens[1]])) |
---|
892 | { |
---|
893 | $key = $lang['exif_field_'.$tokens[1]]; |
---|
894 | } |
---|
895 | |
---|
896 | $template->assign_block_vars( |
---|
897 | 'metadata.line', |
---|
898 | array( |
---|
899 | 'KEY' => $key, |
---|
900 | 'VALUE' => $exif[$tokens[0]][$tokens[1]] |
---|
901 | ) |
---|
902 | ); |
---|
903 | } |
---|
904 | } |
---|
905 | } |
---|
906 | } |
---|
907 | } |
---|
908 | if ($conf['show_iptc']) |
---|
909 | { |
---|
910 | $iptc = get_iptc_data($picture['current']['src'], |
---|
911 | $conf['show_iptc_mapping']); |
---|
912 | |
---|
913 | if (count($iptc) > 0) |
---|
914 | { |
---|
915 | $template->assign_block_vars( |
---|
916 | 'metadata.headline', |
---|
917 | array('TITLE' => 'IPTC Metadata') |
---|
918 | ); |
---|
919 | } |
---|
920 | |
---|
921 | foreach ($iptc as $field => $value) |
---|
922 | { |
---|
923 | $key = $field; |
---|
924 | if (isset($lang[$field])) |
---|
925 | { |
---|
926 | $key = $lang[$field]; |
---|
927 | } |
---|
928 | |
---|
929 | $template->assign_block_vars( |
---|
930 | 'metadata.line', |
---|
931 | array( |
---|
932 | 'KEY' => $key, |
---|
933 | 'VALUE' => $value |
---|
934 | ) |
---|
935 | ); |
---|
936 | } |
---|
937 | } |
---|
938 | } |
---|
939 | //slideshow end |
---|
940 | if ( isset( $_GET['slideshow'] ) ) |
---|
941 | { |
---|
942 | if ( !is_numeric( $_GET['slideshow'] ) ) $_GET['slideshow'] = $conf['slideshow_period']; |
---|
943 | |
---|
944 | $template->assign_block_vars('stop_slideshow', array( |
---|
945 | 'U_SLIDESHOW'=>$picture['current']['url'] |
---|
946 | )); |
---|
947 | } |
---|
948 | |
---|
949 | //------------------------------------------------------------------- rating |
---|
950 | if ($conf['rate']) |
---|
951 | { |
---|
952 | $query = ' |
---|
953 | SELECT COUNT(rate) AS count |
---|
954 | , ROUND(AVG(rate),2) AS average |
---|
955 | , ROUND(STD(rate),2) AS STD |
---|
956 | FROM '.RATE_TABLE.' |
---|
957 | WHERE element_id = '.$picture['current']['id'].' |
---|
958 | ;'; |
---|
959 | $row = mysql_fetch_array(pwg_query($query)); |
---|
960 | if ($row['count'] == 0) |
---|
961 | { |
---|
962 | $value = $lang['no_rate']; |
---|
963 | } |
---|
964 | else |
---|
965 | { |
---|
966 | $value = sprintf( |
---|
967 | l10n('%.2f (rated %d times, standard deviation = %.2f)'), |
---|
968 | $row['average'], |
---|
969 | $row['count'], |
---|
970 | $row['STD'] |
---|
971 | ); |
---|
972 | } |
---|
973 | |
---|
974 | if (!$user['is_the_guest']) |
---|
975 | { |
---|
976 | $query = 'SELECT rate |
---|
977 | FROM '.RATE_TABLE.' |
---|
978 | WHERE user_id = '.$user['id'].' |
---|
979 | AND element_id = '.$_GET['image_id'].';'; |
---|
980 | $result = pwg_query($query); |
---|
981 | if (mysql_num_rows($result) > 0) |
---|
982 | { |
---|
983 | $row = mysql_fetch_array($result); |
---|
984 | $sentence = $lang['already_rated']; |
---|
985 | $sentence.= ' ('.$row['rate'].'). '; |
---|
986 | $sentence.= $lang['update_rate']; |
---|
987 | } |
---|
988 | else |
---|
989 | { |
---|
990 | $sentence = $lang['never_rated'].'. '.$lang['to_rate']; |
---|
991 | } |
---|
992 | $template->assign_block_vars( |
---|
993 | 'rate', |
---|
994 | array( |
---|
995 | 'CONTENT' => $value, |
---|
996 | 'SENTENCE' => $sentence |
---|
997 | )); |
---|
998 | |
---|
999 | $template->assign_block_vars('info_rate', array('CONTENT' => $value)); |
---|
1000 | |
---|
1001 | $template->assign_vars( |
---|
1002 | array( |
---|
1003 | 'INFO_RATE' => $value |
---|
1004 | ) |
---|
1005 | ); |
---|
1006 | |
---|
1007 | foreach ($rate_items as $num => $mark) |
---|
1008 | { |
---|
1009 | if ($num > 0) |
---|
1010 | { |
---|
1011 | $separator = '|'; |
---|
1012 | } |
---|
1013 | else |
---|
1014 | { |
---|
1015 | $separator = ''; |
---|
1016 | } |
---|
1017 | |
---|
1018 | $url = PHPWG_ROOT_PATH.'picture.php'; |
---|
1019 | $url.= get_query_string_diff(array('rate','add_fav')); |
---|
1020 | $url.= '&rate='.$mark; |
---|
1021 | |
---|
1022 | $template->assign_block_vars( |
---|
1023 | 'rate.rate_option', |
---|
1024 | array( |
---|
1025 | 'OPTION' => $mark, |
---|
1026 | 'URL' => $url, |
---|
1027 | 'SEPARATOR' => $separator |
---|
1028 | )); |
---|
1029 | } |
---|
1030 | } |
---|
1031 | } |
---|
1032 | |
---|
1033 | //---------------------------------------------------- users's comments display |
---|
1034 | |
---|
1035 | // the picture is commentable if it belongs at least to one category which |
---|
1036 | // is commentable |
---|
1037 | $page['show_comments'] = false; |
---|
1038 | foreach ($related_categories as $category) |
---|
1039 | { |
---|
1040 | if ($category['commentable'] == 'true') |
---|
1041 | { |
---|
1042 | $page['show_comments'] = true; |
---|
1043 | } |
---|
1044 | } |
---|
1045 | |
---|
1046 | if ($page['show_comments']) |
---|
1047 | { |
---|
1048 | // number of comment for this picture |
---|
1049 | $query = 'SELECT COUNT(*) AS nb_comments'; |
---|
1050 | $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$_GET['image_id']; |
---|
1051 | $query.= " AND validated = 'true'"; |
---|
1052 | $query.= ';'; |
---|
1053 | $row = mysql_fetch_array( pwg_query( $query ) ); |
---|
1054 | |
---|
1055 | // navigation bar creation |
---|
1056 | $url = PHPWG_ROOT_PATH.'picture.php'; |
---|
1057 | $url.= get_query_string_diff(array('rate','add_fav')); |
---|
1058 | |
---|
1059 | if (!isset( $_GET['start'] ) |
---|
1060 | or !is_numeric( $_GET['start'] ) |
---|
1061 | or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) |
---|
1062 | { |
---|
1063 | $page['start'] = 0; |
---|
1064 | } |
---|
1065 | else |
---|
1066 | { |
---|
1067 | $page['start'] = $_GET['start']; |
---|
1068 | } |
---|
1069 | $page['navigation_bar'] = create_navigation_bar( $url, $row['nb_comments'], |
---|
1070 | $page['start'], |
---|
1071 | $conf['nb_comment_page'], |
---|
1072 | '' ); |
---|
1073 | $template->assign_block_vars('comments', array( |
---|
1074 | 'NB_COMMENT'=>$row['nb_comments'], |
---|
1075 | 'NAV_BAR'=>$page['navigation_bar'])); |
---|
1076 | |
---|
1077 | $query = 'SELECT id,author,date,image_id,content'; |
---|
1078 | $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$_GET['image_id']; |
---|
1079 | $query.= " AND validated = 'true'"; |
---|
1080 | $query.= ' ORDER BY date ASC'; |
---|
1081 | $query.= ' LIMIT '.$page['start'].', '.$conf['nb_comment_page'].';'; |
---|
1082 | $result = pwg_query( $query ); |
---|
1083 | |
---|
1084 | while ( $row = mysql_fetch_array( $result ) ) |
---|
1085 | { |
---|
1086 | $template->assign_block_vars( |
---|
1087 | 'comments.comment', |
---|
1088 | array( |
---|
1089 | 'COMMENT_AUTHOR'=>empty($row['author'])?$lang['guest']:$row['author'], |
---|
1090 | 'COMMENT_DATE'=>format_date($row['date'], 'mysql_datetime', true), |
---|
1091 | 'COMMENT'=>parse_comment_content($row['content']) |
---|
1092 | )); |
---|
1093 | |
---|
1094 | if ( $user['status'] == 'admin' ) |
---|
1095 | { |
---|
1096 | $template->assign_block_vars( |
---|
1097 | 'comments.comment.delete', |
---|
1098 | array('U_COMMENT_DELETE'=> $url.'&del='.$row['id'] |
---|
1099 | )); |
---|
1100 | } |
---|
1101 | } |
---|
1102 | |
---|
1103 | if (!$user['is_the_guest'] |
---|
1104 | or ($user['is_the_guest'] and $conf['comments_forall'])) |
---|
1105 | { |
---|
1106 | $template->assign_block_vars('comments.add_comment', array()); |
---|
1107 | // display author field if the user is not logged in |
---|
1108 | if (!$user['is_the_guest']) |
---|
1109 | { |
---|
1110 | $template->assign_block_vars( |
---|
1111 | 'comments.add_comment.author_known', |
---|
1112 | array('KNOWN_AUTHOR'=>$user['username']) |
---|
1113 | ); |
---|
1114 | } |
---|
1115 | else |
---|
1116 | { |
---|
1117 | $template->assign_block_vars( |
---|
1118 | 'comments.add_comment.author_field', array() |
---|
1119 | ); |
---|
1120 | } |
---|
1121 | } |
---|
1122 | } |
---|
1123 | //------------------------------------------------------------ log informations |
---|
1124 | pwg_log( 'picture', $title_img, $picture['current']['file'] ); |
---|
1125 | |
---|
1126 | $template->parse('picture'); |
---|
1127 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
1128 | ?> |
---|