PageRenderTime 30ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/album_showpage.php

http://github.com/MightyGorgon/icy_phoenix
PHP | 1278 lines | 963 code | 165 blank | 150 comment | 297 complexity | 8993e32689d603235d2b3b048e18db8e MD5 | raw file
Possible License(s): AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. *
  4. * @package Icy Phoenix
  5. * @version $Id$
  6. * @copyright (c) 2008 Icy Phoenix
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. *
  9. */
  10. /**
  11. *
  12. * @Extra credits for this file
  13. * Smartor (smartor_xp@hotmail.com)
  14. *
  15. */
  16. define('IN_ICYPHOENIX', true);
  17. if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
  18. if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
  19. include(IP_ROOT_PATH . 'common.' . PHP_EXT);
  20. include(IP_ROOT_PATH . 'includes/functions_validate.' . PHP_EXT);
  21. include(IP_ROOT_PATH . 'includes/functions_post.' . PHP_EXT);
  22. // Start session management
  23. $user->session_begin();
  24. $auth->acl($user->data);
  25. $user->setup();
  26. // End session management
  27. // Get general album information
  28. include(ALBUM_MOD_PATH . 'album_common.' . PHP_EXT);
  29. include_once(IP_ROOT_PATH . 'includes/functions_users.' . PHP_EXT);
  30. include_once(IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
  31. $comment_text_message = request_var('message', '', true);
  32. $comment_text = request_var('comment', '', true);
  33. $comment_text = (!empty($comment_text_message) ? $comment_text_message : $comment_text);
  34. $mode = request_var('mode', '');
  35. if($mode == 'smilies')
  36. {
  37. generate_smilies('window');
  38. exit;
  39. }
  40. // ------------------------------------
  41. // Check the request
  42. // ------------------------------------
  43. $pic_id = request_var('pic_id', 0);
  44. if ($pic_id <= 0)
  45. {
  46. message_die(GENERAL_MESSAGE, $lang['NO_PICS_SPECIFIED']);
  47. }
  48. $comment_id = request_var('comment_id', 0);
  49. $comment_id = ($comment_id < 0) ? 0 : $comment_id;
  50. // Midthumb & Full Pic
  51. if(isset($_GET['full']) || isset($_POST['full']))
  52. {
  53. $picm = false;
  54. $full_size_param = '&amp;full=true';
  55. }
  56. else
  57. {
  58. if ($album_config['midthumb_use'] == 1)
  59. {
  60. $picm = true;
  61. $full_size_param = '';
  62. }
  63. else
  64. {
  65. $picm = false;
  66. $full_size_param = '&amp;full=true';
  67. }
  68. }
  69. $sort_method = request_var('sort_method', $album_config['sort_method']);
  70. $sort_method = check_var_value($sort_method, array('pic_time', 'pic_title', 'pic_view_count'));
  71. $sort_order = request_var('sort_order', $album_config['sort_order']);
  72. $sort_order = check_var_value(strtoupper($sort_order), array('ASC', 'DESC'));
  73. $sort_append = '&amp;sort_method=' . $sort_method . '&amp;sort_order=' . $sort_order;
  74. $is_slideshow = request_var('slideshow', 0);
  75. $is_slideshow = !empty($is_slideshow) ? true : false;
  76. // ------------------------------------
  77. // TEMPLATE ASSIGNEMENT
  78. // ------------------------------------
  79. if ($is_slideshow)
  80. {
  81. $gen_simple_header = true;
  82. $show_template = 'album_slideshow_body.tpl';
  83. $nuffimage_pic = ($picm == false) ? 'album_pic.' : 'album_picm.';
  84. $nuff_display = false;
  85. }
  86. else
  87. {
  88. //$show_template = 'album_showpage_body.tpl';
  89. if ((isset($_GET['nuffimage']) || isset($_POST['nuffimage'])) & ($album_config['enable_nuffimage'] == 1))
  90. {
  91. include(ALBUM_MOD_PATH . 'album_nuffimage_box.' . PHP_EXT);
  92. $template->assign_var_from_handle('NUFFIMAGE_BOX', 'nuffimage_box');
  93. $show_template = 'album_pic_nuffed_body.tpl';
  94. $nuffimage_vars = '&amp;nuffimage=true';
  95. $nuffimage_pic = 'album_pic_nuffed.';
  96. $nuff_display = true;
  97. $nuff_http_full_string = $nuff_http['full_string'];
  98. $template->assign_block_vars('disable_pic_nuffed', array(
  99. 'L_PIC_UNNUFFED_CLICK' => $lang['Nuff_UnClick'],
  100. 'U_PIC_UNNUFFED_CLICK' => append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . $full_size_param . $sort_append)),
  101. )
  102. );
  103. }
  104. else
  105. {
  106. $show_template = 'album_showpage_body.tpl';
  107. $nuffimage_vars = '';
  108. $nuffimage_pic = ($picm == false) ? 'album_pic.' : 'album_picm.';
  109. $nuff_display = false;
  110. $nuff_http_full_string = '';
  111. }
  112. }
  113. // ------------------------------------
  114. // PREVIOUS / NEXT / PICS NAV
  115. // ------------------------------------
  116. $sql = "SELECT pic_id, pic_cat_id, pic_user_id, pic_time
  117. FROM " . ALBUM_TABLE . "
  118. WHERE pic_id = " . $pic_id;
  119. $result = $db->sql_query($sql);
  120. $row = $db->sql_fetchrow($result);
  121. if(empty($row))
  122. {
  123. message_die(GENERAL_ERROR, $lang['Pic_not_exist']);
  124. }
  125. $pic_id_old = $pic_id;
  126. $pic_id_tmp = $row['pic_id'];
  127. $pic_cat_id_tmp = $row['pic_cat_id'];
  128. $pic_time_tmp = $row['pic_time'];
  129. $pic_user_id_tmp = $row['pic_user_id'];
  130. $db->sql_freeresult($result);
  131. $sql_order = 'ORDER BY a.' . $sort_method . ' ' . $sort_order;
  132. $sql = "SELECT *
  133. FROM " . ALBUM_TABLE . " AS a
  134. WHERE a.pic_cat_id = " . $pic_cat_id_tmp . "
  135. AND a.pic_approval = 1
  136. " . $sql_order;
  137. $result = $db->sql_query($sql);
  138. $total_pic_count = $db->sql_numrows($result);
  139. $total_pic_rows = $db->sql_fetchrowset($result);
  140. $db->sql_freeresult($result);
  141. if ($album_config['slideshow_script'])
  142. {
  143. $template->assign_block_vars('switch_slideshow_scripts', array());
  144. $pic_link = ($picm == false) ? 'album_pic.' : 'album_picm.';
  145. $pic_list = '';
  146. $tit_list = '';
  147. $des_list = '';
  148. for($i = 0; $i < $total_pic_count; $i++)
  149. {
  150. if ($pic_id == $total_pic_rows[$i]['pic_id'])
  151. {
  152. $pic_array_id = $i;
  153. }
  154. $pic_list .= 'Pic[' . $i . '] = \'' . append_sid(album_append_uid($pic_link . PHP_EXT . '?pic_id=' . $total_pic_rows[$i]['pic_id']), true) . '\'; ' . "\n";
  155. /*
  156. $tit_list .= 'Tit[' . $i . '] = \'' . str_replace("'", "\'", $total_pic_rows[$i]['pic_title']) . '\'; ' . "\n";
  157. $des_list .= 'Des[' . $i . '] = \'' . str_replace(array("\r\n", "\n", "\r"), array('\n', '\n', '\n'), str_replace("'", "\'", $total_pic_rows[$i]['pic_desc'])) . '\'; ' . "\n";
  158. */
  159. $tit_list .= 'Tit[' . $i . '] = \'' . addslashes($total_pic_rows[$i]['pic_title']) . '\'; ' . "\n";
  160. $des_list .= 'Des[' . $i . '] = \'' . str_replace(array("\r\n", "\n", "\r"), array('\n', '\n', '\n'), addslashes($total_pic_rows[$i]['pic_desc'])) . '\'; ' . "\n";
  161. /*
  162. $pic_list .= 'Pic[' . $i . '] = \'' . ALBUM_UPLOAD_PATH . $total_pic_rows[$i]['pic_filename'] . '\'; ' . "\n";
  163. */
  164. }
  165. $template->assign_vars(array(
  166. 'S_SLIDESHOW_SCRIPTS' => true,
  167. 'PIC_LIST' => $pic_list,
  168. 'TIT_LIST' => $tit_list,
  169. 'DES_LIST' => $des_list,
  170. )
  171. );
  172. }
  173. else
  174. {
  175. for($i = 0; $i < $total_pic_count; $i++)
  176. {
  177. if ($pic_id == $total_pic_rows[$i]['pic_id'])
  178. {
  179. $pic_array_id = $i;
  180. }
  181. }
  182. }
  183. $first_pic_id = $total_pic_rows[0]['pic_id'];
  184. $last_pic_id = $total_pic_rows[$total_pic_count - 1]['pic_id'];
  185. // ------------------------------------
  186. // PREVIOUS & NEXT
  187. // ------------------------------------
  188. // JHL these variables were being reset after some tests had been made - now moved up to the correct position
  189. $no_prev_pic = false;
  190. $no_next_pic = false;
  191. if ($pic_array_id == 0)
  192. {
  193. $no_prev_pic = true;
  194. if(isset($_GET['mode']) && ($_GET['mode'] == 'next'))
  195. {
  196. message_die(GENERAL_ERROR, $lang['Pic_not_exist']);
  197. }
  198. }
  199. if ($pic_array_id == ($total_pic_count - 1))
  200. {
  201. $no_next_pic = true;
  202. if(isset($_GET['mode']) && ($_GET['mode'] == 'prev'))
  203. {
  204. message_die(GENERAL_ERROR, $lang['Pic_not_exist']);
  205. }
  206. }
  207. $pic_id_old = $total_pic_rows[$pic_array_id]['pic_id'];
  208. if(isset($_GET['mode']) && ($_GET['mode'] == 'next'))
  209. {
  210. $new_pic_array_id = $pic_array_id - 1;
  211. if ($new_pic_array_id == 0)
  212. {
  213. $no_prev_pic = true;
  214. }
  215. }
  216. elseif(isset($_GET['mode']) && ($_GET['mode'] == 'prev'))
  217. {
  218. $new_pic_array_id = $pic_array_id + 1;
  219. if ($new_pic_array_id == ($total_pic_count - 1))
  220. {
  221. $no_next_pic = true;
  222. }
  223. }
  224. else
  225. {
  226. $new_pic_array_id = $pic_array_id;
  227. }
  228. $pic_id_tmp = $total_pic_rows[$new_pic_array_id]['pic_id'];
  229. $pic_cat_id_tmp = $total_pic_rows[$new_pic_array_id]['pic_cat_id'];
  230. $pic_time_tmp = $total_pic_rows[$new_pic_array_id]['pic_time'];
  231. $pic_user_id_tmp = $total_pic_rows[$new_pic_array_id]['pic_user_id'];
  232. $next_pic_count = ($total_pic_count - $new_pic_array_id - 1);
  233. $prev_pic_count = $new_pic_array_id;
  234. if(isset($_GET['mode']))
  235. {
  236. if (($_GET['mode'] == 'next') || ($_GET['mode'] == 'prev'))
  237. {
  238. $pic_id = $pic_id_tmp;
  239. }
  240. }
  241. if ($album_config['show_pics_nav'] == 1)
  242. {
  243. $template->assign_block_vars('pics_nav', array(
  244. 'L_PICS_NAV' => $lang['Pics_Nav'],
  245. 'L_PICS_NAV_NEXT' => $lang['Pics_Nav_Next'],
  246. 'L_PICS_NAV_PREV' => $lang['Pics_Nav_Prev'],
  247. )
  248. );
  249. }
  250. if (!$album_config['invert_nav_arrows'])
  251. {
  252. $max_pic_counter = min(($total_pic_count - 1), ($new_pic_array_id + 2));
  253. $min_pic_counter = max(0, ($new_pic_array_id - 2));
  254. for($i = $min_pic_counter; $i <= $max_pic_counter; $i++)
  255. {
  256. $thumbnail_file = append_sid(album_append_uid('album_thumbnail.' . PHP_EXT . '?pic_id=' . $total_pic_rows[$i]['pic_id']));
  257. if (($album_config['thumbnail_cache'] == true) && ($album_config['quick_thumbs'] == true))
  258. {
  259. $thumbnail_file = picture_quick_thumb($total_pic_rows[$i]['pic_filename'], $total_pic_rows[$i]['pic_thumbnail'], $thumbnail_file);
  260. }
  261. $pic_preview = '';
  262. $pic_preview_hs = '';
  263. if ($album_config['lb_preview'])
  264. {
  265. $slideshow_cat = '';
  266. $slideshow = !empty($slideshow_cat) ? ', { slideshowGroup: \'' . $slideshow_cat . '\' } ' : '';
  267. $pic_preview_hs = ' class="highslide" onclick="return hs.expand(this' . $slideshow . ');"';
  268. $pic_preview = 'onmouseover="showtrail(\'' . append_sid(album_append_uid('album_picm.' . PHP_EXT . '?pic_id=' . $total_pic_rows[$i]['pic_id'])) . '\',\'' . addslashes($total_pic_rows[$i]['pic_title']) . '\', ' . $album_config['midthumb_width'] . ', ' . $album_config['midthumb_height'] . ')" onmouseout="hidetrail()"';
  269. }
  270. if ($album_config['show_pics_nav'])
  271. {
  272. $template->assign_block_vars('pics_nav.pics', array(
  273. 'U_PIC_THUMB' => $thumbnail_file,
  274. 'U_PIC_LINK' => ($i == $new_pic_array_id) ? '#' : append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $total_pic_rows[$i]['pic_id'] . $full_size_param . $nuffimage_vars . $sort_append)),
  275. 'U_PIC_LINK_HS' => append_sid(album_append_uid('album_pic.' . PHP_EXT . '?pic_id=' . $total_pic_rows[$i]['pic_id'])),
  276. 'PIC_TITLE' => $total_pic_rows[$i]['pic_title'],
  277. 'PIC_PREVIEW_HS' => $pic_preview_hs,
  278. 'PIC_PREVIEW' => ($i == $new_pic_array_id) ? '' : $pic_preview,
  279. 'CLASS' => ($i == $new_pic_array_id) ? 'image-current' : 'image',
  280. 'STYLE' => ($i == $new_pic_array_id) ? 'border: solid 3px #ff5522;' : '',
  281. )
  282. );
  283. }
  284. }
  285. }
  286. else
  287. {
  288. $max_pic_counter = max(0, ($new_pic_array_id - 2));
  289. $min_pic_counter = min(($total_pic_count - 1), ($new_pic_array_id + 2));
  290. for($i = $min_pic_counter; $i >= $max_pic_counter; $i--)
  291. {
  292. $thumbnail_file = append_sid(album_append_uid('album_thumbnail.' . PHP_EXT . '?pic_id=' . $total_pic_rows[$i]['pic_id']));
  293. if (($album_config['thumbnail_cache'] == true) && ($album_config['quick_thumbs'] == true))
  294. {
  295. $thumbnail_file = picture_quick_thumb($total_pic_rows[$i]['pic_filename'], $total_pic_rows[$i]['pic_thumbnail'], $thumbnail_file);
  296. }
  297. $pic_preview = '';
  298. $pic_preview_hs = '';
  299. if ($album_config['lb_preview'])
  300. {
  301. $slideshow_cat = '';
  302. $slideshow = !empty($slideshow_cat) ? ', { slideshowGroup: \'' . $slideshow_cat . '\' } ' : '';
  303. $pic_preview_hs = ' class="highslide" onclick="return hs.expand(this' . $slideshow . ');"';
  304. $pic_preview = 'onmouseover="showtrail(\'' . append_sid(album_append_uid('album_picm.' . PHP_EXT . '?pic_id=' . $total_pic_rows[$i]['pic_id'])) . '\',\'' . addslashes($total_pic_rows[$i]['pic_title']) . '\', ' . $album_config['midthumb_width'] . ', ' . $album_config['midthumb_height'] . ')" onmouseout="hidetrail()"';
  305. }
  306. if ($album_config['show_pics_nav'] == 1)
  307. {
  308. $template->assign_block_vars('pics_nav.pics', array(
  309. 'U_PIC_THUMB' => $thumbnail_file,
  310. 'U_PIC_LINK' => ($i == $new_pic_array_id) ? '#' : append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $total_pic_rows[$i]['pic_id'] . $full_size_param . $nuffimage_vars . $sort_append)),
  311. 'U_PIC_LINK_HS' => append_sid(album_append_uid('album_pic.' . PHP_EXT . '?pic_id=' . $total_pic_rows[$i]['pic_id'])),
  312. 'PIC_TITLE' => $total_pic_rows[$i]['pic_title'],
  313. 'PIC_PREVIEW_HS' => $pic_preview_hs,
  314. 'PIC_PREVIEW' => ($i == $new_pic_array_id) ? '' : $pic_preview,
  315. 'CLASS' => ($i == $new_pic_array_id) ? 'image-current' : 'image',
  316. 'STYLE' => ($i == $new_pic_array_id) ? 'border: solid 3px #FF5522;' : '',
  317. )
  318. );
  319. }
  320. }
  321. }
  322. // ------------------------------------
  323. // SPECIAL FX
  324. // ------------------------------------
  325. if ($album_config['enable_nuffimage'] == 1)
  326. {
  327. $template->assign_block_vars('pic_nuffed_enabled', array(
  328. 'L_PIC_NUFFED_CLICK' => $lang['Nuff_Click'],
  329. 'U_PIC_NUFFED_CLICK' => append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . $full_size_param . '&amp;nuffimage=true&amp;' . $sort_append)),
  330. )
  331. );
  332. }
  333. else
  334. {
  335. $template->assign_block_vars('switch_slideshow_no_scripts', array());
  336. }
  337. // ------------------------------------
  338. // Get $pic_id from $comment_id
  339. // ------------------------------------
  340. if(!empty($comment_id) && $album_config['comment'] == 1)
  341. {
  342. $sql = "SELECT comment_id, comment_pic_id
  343. FROM ". ALBUM_COMMENT_TABLE ."
  344. WHERE comment_id = '$comment_id'";
  345. $result = $db->sql_query($sql);
  346. $row = $db->sql_fetchrow($result);
  347. if(empty($row))
  348. {
  349. message_die(GENERAL_ERROR, 'This comment does not exist');
  350. }
  351. $pic_id = $row['comment_pic_id'];
  352. }
  353. // ------------------------------------
  354. // Get this pic info and current category info
  355. // ------------------------------------
  356. $sql = "SELECT p.*, ac.*, u.user_id, u.username, u.user_active, u.user_color, u.user_rank, u.user_level, u.user_avatar, u.user_avatar_type, u.user_allowavatar, r.rate_pic_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments_count
  357. FROM " . ALBUM_CAT_TABLE . " AS ac, " . ALBUM_TABLE . " AS p
  358. LEFT JOIN " . USERS_TABLE . " AS u ON p.pic_user_id = u.user_id
  359. LEFT JOIN " . ALBUM_COMMENT_TABLE . " AS c ON p.pic_id = c.comment_pic_id
  360. LEFT JOIN " . ALBUM_RATE_TABLE . " AS r ON p.pic_id = r.rate_pic_id
  361. WHERE pic_id = '$pic_id'
  362. AND ac.cat_id = p.pic_cat_id
  363. GROUP BY p.pic_id
  364. LIMIT 1";
  365. $result = $db->sql_query($sql);
  366. $thispic = $db->sql_fetchrow($result);
  367. $cat_id = ($thispic['pic_cat_id'] != 0) ? $thispic['pic_cat_id'] : $thispic['cat_id'];
  368. $album_user_id = $thispic['cat_user_id'];
  369. $total_comments = $thispic['comments_count'];
  370. $comments_per_page = $config['posts_per_page'];
  371. if(empty($thispic))
  372. {
  373. message_die(GENERAL_ERROR, $lang['Pic_not_exist'] . $lang['Nav_Separator'] . $pic_id);
  374. }
  375. // ------------------------------------
  376. // Check the permissions
  377. // ------------------------------------
  378. $check_permissions = ALBUM_AUTH_VIEW|ALBUM_AUTH_RATE|ALBUM_AUTH_COMMENT|ALBUM_AUTH_EDIT|ALBUM_AUTH_DELETE;
  379. $auth_data = album_permissions($album_user_id, $cat_id, $check_permissions, $thispic);
  380. if ($auth_data['view'] == 0)
  381. {
  382. if (!$user->data['session_logged_in'])
  383. {
  384. redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=album_showpage.' . PHP_EXT . '&amp;pic_id=' . $pic_id));
  385. exit;
  386. }
  387. else
  388. {
  389. message_die(GENERAL_ERROR, $lang['Not_Authorized']);
  390. }
  391. }
  392. // ------------------------------------
  393. //RATING: Additional Check: if this user already rated
  394. // ------------------------------------
  395. $own_pic_rate = false;
  396. if($user->data['session_logged_in'])
  397. {
  398. $sql = "SELECT *
  399. FROM ". ALBUM_RATE_TABLE ."
  400. WHERE rate_pic_id = '$pic_id'
  401. AND rate_user_id = '". $user->data['user_id'] ."'
  402. LIMIT 1";
  403. $result = $db->sql_query($sql);
  404. if ($db->sql_numrows($result) > 0)
  405. {
  406. $already_rated = true;
  407. }
  408. else
  409. {
  410. $already_rated = false;
  411. }
  412. if ($thispic['pic_user_id'] == $user->data['user_id'])
  413. {
  414. $own_pic_rate = true;
  415. }
  416. }
  417. else
  418. {
  419. $already_rated = false;
  420. }
  421. // Watch pic for comments - BEGIN
  422. if($user->data['session_logged_in'])
  423. {
  424. //$can_watch_comment = true;
  425. $sql = "SELECT notify_status
  426. FROM " . ALBUM_COMMENT_WATCH_TABLE . "
  427. WHERE pic_id = $pic_id
  428. AND user_id = " . $user->data['user_id'] . "
  429. LIMIT 1";
  430. $result = $db->sql_query($sql);
  431. if ($row = $db->sql_fetchrow($result))
  432. {
  433. $is_watching_comments = true;
  434. if (isset($_GET['unwatch']))
  435. {
  436. if ($_GET['unwatch'] == 'comment')
  437. {
  438. $sql = "DELETE FROM " . ALBUM_COMMENT_WATCH_TABLE . "
  439. WHERE pic_id = $pic_id
  440. AND user_id = " . $user->data['user_id'];
  441. $result = $db->sql_query($sql);
  442. $is_watching_comment = false;
  443. }
  444. $redirect_url = append_sid('album.' . PHP_EXT);
  445. meta_refresh(3, $redirect_url);
  446. $message = $lang['No_longer_watching_comment'] . '<br /><br />' . sprintf($lang['Click_return_pic'], '<a href="' . append_sid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id) . '">', '</a>');
  447. message_die(GENERAL_MESSAGE, $message);
  448. }
  449. else
  450. {
  451. $is_watching_comment = true;
  452. if ($row['notify_status'])
  453. {
  454. $sql = "UPDATE " . ALBUM_COMMENT_WATCH_TABLE . "
  455. SET notify_status = 0
  456. WHERE pic_id = $pic_id
  457. AND user_id = " . $user->data['user_id'];
  458. $result = $db->sql_query($sql);
  459. }
  460. }
  461. }
  462. // Set pic for watch request
  463. if (isset($_GET['watch']))
  464. {
  465. if ($_GET['watch'] == 'comment')
  466. {
  467. $sql = "INSERT INTO " . ALBUM_COMMENT_WATCH_TABLE . " (pic_id, user_id, notify_status)
  468. VALUES ($pic_id, " . $user->data['user_id'] . ", 0)";
  469. $result = $db->sql_query($sql);
  470. }
  471. $redirect_url = append_sid('album.' . PHP_EXT);
  472. meta_refresh(3, $redirect_url);
  473. $message = $lang['Watching_comment'] . '<br /><br />' . sprintf($lang['Click_return_pic'], '<a href="' . append_sid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id) . '">', '</a>');
  474. message_die(GENERAL_MESSAGE, $message);
  475. }
  476. }
  477. // Watch pic for comments - END
  478. /*
  479. +----------------------------------------------------------
  480. | Main work here...
  481. +----------------------------------------------------------
  482. */
  483. album_read_tree($album_user_id);
  484. $album_nav_cat_desc = album_make_nav_tree($cat_id, 'album_cat.' . PHP_EXT, 'nav' , $album_user_id);
  485. if ($album_nav_cat_desc != '')
  486. {
  487. $nav_server_url = create_server_url();
  488. $album_nav_cat_desc = ALBUM_NAV_ARROW . $album_nav_cat_desc;
  489. $breadcrumbs['address'] = ALBUM_NAV_ARROW . '<a href="' . $nav_server_url . append_sid('album.' . PHP_EXT) . '">' . $lang['Album'] . '</a>' . $album_nav_cat_desc;
  490. }
  491. if(empty($comment_text) && !isset($_POST['rating']))
  492. {
  493. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  494. Comments Screen
  495. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  496. // ------------------------------------
  497. // Get the comments thread
  498. // Beware: when this script was called with comment_id (without start)
  499. // ------------------------------------
  500. if ($album_config['comment'])
  501. {
  502. if(empty($comment_id))
  503. {
  504. $start = request_var('start', 0);
  505. $start = ($start < 0) ? 0 : $start;
  506. }
  507. else
  508. {
  509. // We must do a query to co-ordinate this comment
  510. $sql = "SELECT COUNT(comment_id) AS count
  511. FROM ". ALBUM_COMMENT_TABLE ."
  512. WHERE comment_pic_id = $pic_id
  513. AND comment_id < $comment_id";
  514. $result = $db->sql_query($sql);
  515. $row = $db->sql_fetchrow($result);
  516. if(!empty($row))
  517. {
  518. $start = floor($row['count'] / $comments_per_page) * $comments_per_page;
  519. }
  520. else
  521. {
  522. $start = 0;
  523. }
  524. }
  525. if ($total_comments > 0)
  526. {
  527. $template->assign_block_vars('coment_switcharo_top', array());
  528. $limit_sql = ($start == 0) ? $comments_per_page : $start . ',' . $comments_per_page;
  529. $comment_sort_order = (!empty($_GET['comment_sort_order'])) ? $_GET['comment_sort_order'] : 'ASC';
  530. $comment_sort_order = (strtoupper($comment_sort_order) == 'DESC') ? 'DESC' : 'ASC';
  531. $sql = "SELECT c.*, u.*
  532. FROM " . ALBUM_COMMENT_TABLE . " AS c
  533. LEFT JOIN " . USERS_TABLE . " AS u ON c.comment_user_id = u.user_id
  534. WHERE c.comment_pic_id = '$pic_id'
  535. ORDER BY c.comment_id $comment_sort_order
  536. LIMIT $limit_sql";
  537. $result = $db->sql_query($sql);
  538. $commentrow = array();
  539. while($row = $db->sql_fetchrow($result))
  540. {
  541. $commentrow[] = $row;
  542. }
  543. $db->sql_freeresult($result);
  544. // Ranks
  545. @include_once(IP_ROOT_PATH . 'includes/functions_users.' . PHP_EXT);
  546. $ranks_array = $cache->obtain_ranks(false);
  547. for ($i = 0; $i < sizeof($commentrow); $i++)
  548. {
  549. $poster = ($commentrow[$i]['comment_username'] == '') ? $lang['Guest'] : colorize_username($commentrow[$i]['user_id'], $commentrow[$i]['username'], $commentrow[$i]['user_color']);
  550. if ($commentrow[$i]['comment_edit_count'] > 0)
  551. {
  552. $sql = "SELECT c.comment_id, c.comment_edit_user_id, u.user_id, u.username, u.user_color
  553. FROM " . ALBUM_COMMENT_TABLE . " AS c
  554. LEFT JOIN " . USERS_TABLE . " AS u ON c.comment_edit_user_id = u.user_id
  555. WHERE c.comment_id = '".$commentrow[$i]['comment_id']."'
  556. LIMIT 1";
  557. $result = $db->sql_query($sql);
  558. $lastedit_row = $db->sql_fetchrow($result);
  559. $edit_info = ($commentrow[$i]['comment_edit_count'] == 1) ? $lang['Edited_time_total'] : $lang['Edited_times_total'];
  560. $edit_info = '<br /><br />&raquo;&nbsp;' . sprintf($edit_info, colorize_username($lastedit_row['user_id'], $lastedit_row['username'], $lastedit_row['user_color']), create_date_ip($config['default_dateformat'], $commentrow[$i]['comment_edit_time'], $config['board_timezone']), $commentrow[$i]['comment_edit_count']) .'<br />';
  561. }
  562. else
  563. {
  564. $edit_info = '';
  565. }
  566. $commentrow[$i]['comment_text'] = censor_text($commentrow[$i]['comment_text']);
  567. // Smilies
  568. $html_on = ($user->data['user_allowhtml'] && $config['allow_html']) ? 1 : 0 ;
  569. $bbcode_on = ($user->data['user_allowbbcode'] && $config['allow_bbcode']) ? 1 : 0 ;
  570. $smilies_on = ($user->data['user_allowsmile'] && $config['allow_smilies']) ? 1 : 0 ;
  571. $bbcode->allow_html = $html_on;
  572. $bbcode->allow_bbcode = $bbcode_on;
  573. $bbcode->allow_smilies = $smilies_on;
  574. $commentrow[$i]['comment_text'] = strtr($commentrow[$i]['comment_text'], array_flip(get_html_translation_table(HTML_ENTITIES)));
  575. $commentrow[$i]['comment_text'] = $bbcode->parse($commentrow[$i]['comment_text']);
  576. $commentrow[$i]['comment_text'] = $bbcode->acronym_pass($commentrow[$i]['comment_text']);
  577. $commentrow[$i]['comment_text'] = $bbcode->autolink_text($commentrow[$i]['comment_text'], '999999');
  578. $user_sig = ($config['allow_sig']) ? trim($commentrow[$i]['user_sig']) : '';
  579. if($user_sig != '')
  580. {
  581. $bbcode->is_sig = true;
  582. $user_sig = $bbcode->parse($user_sig);
  583. $bbcode->is_sig = false;
  584. }
  585. $user_info = array();
  586. $user_info = generate_user_info($commentrow[$i]);
  587. foreach ($user_info as $k => $v)
  588. {
  589. $$k = $v;
  590. }
  591. $poster_avatar = $user_info['avatar'];
  592. // Mighty Gorgon - Multiple Ranks - BEGIN
  593. $user_ranks = generate_ranks($commentrow[$i], $ranks_array);
  594. if (($user_ranks['rank_01_html'] == '') && ($user_ranks['rank_01_img_html'] == '') && ($user_ranks['rank_02_html'] == '') && ($user_ranks['rank_02_img_html'] == '') && ($user_ranks['rank_03_html'] == '') && ($user_ranks['rank_03_img_html'] == '') && ($user_ranks['rank_04_html'] == '') && ($user_ranks['rank_04_img_html'] == '') && ($user_ranks['rank_05_html'] == '') && ($user_ranks['rank_05_img_html'] == ''))
  595. {
  596. $user_ranks['rank_01_html'] = '&nbsp;';
  597. }
  598. // Mighty Gorgon - Multiple Ranks - END
  599. $poster_rank = $user_ranks['rank_01_html'];
  600. $rank_image = $user_ranks['rank_01_img_html'];
  601. // Handle anon users posting with usernames
  602. if (($commentrow[$i]['user_id'] == ANONYMOUS) && ($commentrow[$i]['post_username'] != ''))
  603. {
  604. $poster = colorize_username($commentrow[$i]['user_id'], $commentrow[$i]['username'], $commentrow[$i]['user_color']);
  605. $poster_rank = $lang['Guest'];
  606. }
  607. if ($user->data['user_level'] == ADMIN)
  608. {
  609. $ip_url = 'http://www.nic.com/cgi-bin/whois.cgi?query=' . htmlspecialchars(urlencode($commentrow[$i]['comment_user_ip']));
  610. $ip_img = '<a href="' . $ip_url . '" target="_blank"><img src="' . $images['icon_ip2'] . '" alt="' . $lang['View_IP'] . ' (' . htmlspecialchars($commentrow[$i]['comment_user_ip']) . ')" title="' . $lang['View_IP'] . ' (' . htmlspecialchars($commentrow[$i]['comment_user_ip']) . ')" /></a>';
  611. $ip = '<a href="' . $ip_url . '">' . $lang['View_IP'] . '</a>';
  612. }
  613. else
  614. {
  615. $ip_img = '';
  616. $ip = '';
  617. }
  618. $edit_url = append_sid(album_append_uid('album_comment_edit.' . PHP_EXT . '?comment_id=' . $commentrow[$i]['comment_id']));
  619. $delete_url = append_sid(album_append_uid('album_comment_delete.' . PHP_EXT . '?comment_id=' . $commentrow[$i]['comment_id']));
  620. $template->assign_block_vars('commentrow', array(
  621. 'ID' => $commentrow[$i]['comment_id'],
  622. 'POSTER_NAME' => $poster,
  623. 'COMMENT_TIME' => create_date_ip($config['default_dateformat'], $commentrow[$i]['comment_time'], $config['board_timezone']),
  624. 'IP' => ($user->data['user_level'] == ADMIN) ? '<a href="' . $ip_url . '" target="_blank">' . htmlspecialchars($commentrow[$i]['comment_user_ip']) .'</a><br />' : '',
  625. 'IP_IMG' => $ip_img,
  626. 'POSTER_ONLINE_STATUS_IMG' => $online_status_img,
  627. //users mesangers, website, email
  628. 'PROFILE_IMG' => ($commentrow[$i]['user_id'] != ANONYMOUS) ? '<a href="' . $profile_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" /></a>' : '',
  629. 'PM_IMG' => ($commentrow[$i]['user_id'] != ANONYMOUS) ? '<a href="' . $pm_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" /></a>' : '',
  630. 'EMAIL_IMG' => (($commentrow[$i]['user_id'] != ANONYMOUS) && ($email_url != '')) ? '<a href="' . $email_url . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" /></a>' : '',
  631. 'WWW_IMG' => ($commentrow[$i]['user_id'] != ANONYMOUS) ? ($commentrow[$i]['user_website']) ? '<a href="' . $commentrow[$i]['user_website'] . '" target="_blank"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" /></a>' : '' : '',
  632. 'AIM_IMG' => ($commentrow[$i]['user_id'] != ANONYMOUS) ? $aim_img : '',
  633. 'SKYPE_IMG' => ($commentrow[$i]['user_id'] != ANONYMOUS) ? $skype_img : '',
  634. 'ICQ_IMG' => ($commentrow[$i]['user_id'] != ANONYMOUS) ? $icq_img : '',
  635. 'MSNM_IMG' => ($commentrow[$i]['user_id'] != ANONYMOUS) ? $msn_img : '',
  636. 'YIM_IMG' => ($commentrow[$i]['user_id'] != ANONYMOUS) ? $yahoo_img : '',
  637. 'U_PROFILE' => $profile_url,
  638. 'U_PM' => $pm_url,
  639. 'U_IP' => $ip_url,
  640. 'U_EMAIL' => $email_url,
  641. 'U_WWW' => $www_url,
  642. 'U_AIM' => $aim_url,
  643. 'U_ICQ' => $icq_url,
  644. 'U_MSN' => $msn_url,
  645. 'U_SKYPE' => $skype_url,
  646. 'U_YIM' => $yahoo_url,
  647. 'L_POSTER_ONLINE_STATUS' => $online_status_lang,
  648. 'POSTER_ONLINE_STATUS_CLASS' => $online_status_class,
  649. 'U_POSTER_ONLINE_STATUS' => $online_status_url,
  650. 'POSTER_AVATAR' => $poster_avatar,
  651. 'POSTER_RANK' => $poster_rank,
  652. 'POSTER_RANK_IMAGE' => $rank_image,
  653. 'POSTER_JOINED' => ($commentrow[$i]['user_id'] != ANONYMOUS) ? $lang['Joined'] . ': ' . create_date($lang['JOINED_DATE_FORMAT'], $commentrow[$i]['user_regdate'], $config['board_timezone']) : '',
  654. 'POSTER_POSTS' => ($commentrow[$i]['user_id'] != ANONYMOUS) ? $lang['Posts'] . ': ' . $commentrow[$i]['user_posts'] : '',
  655. 'POSTER_FROM' => ($commentrow[$i]['user_from'] && $commentrow[$i]['user_id'] != ANONYMOUS) ? $lang['Location'] . ': ' . $commentrow[$i]['user_from'] : '',
  656. 'POSTER_SIGNATURE' => $user_sig,
  657. 'TEXT' => $commentrow[$i]['comment_text'],
  658. 'EDIT_INFO' => $edit_info,
  659. 'U_EDIT' => (($auth_data['edit'] && ($commentrow[$i]['comment_user_id'] == $user->data['user_id'])) || ($auth_data['moderator'] && ($thispic['cat_edit_level'] != ALBUM_ADMIN)) || ($user->data['user_level'] == ADMIN)) ? $edit_url : '',
  660. 'EDIT' => (($auth_data['edit'] && ($commentrow[$i]['comment_user_id'] == $user->data['user_id'])) || ($auth_data['moderator'] && ($thispic['cat_edit_level'] != ALBUM_ADMIN)) || ($user->data['user_level'] == ADMIN)) ? '<a href="' . $edit_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_delete_post'] . '" title="' . $lang['Edit_delete_post'] . '" /></a>' : '',
  661. 'U_DELETE' => (($auth_data['delete'] && ($commentrow[$i]['comment_user_id'] == $user->data['user_id'])) || ($auth_data['moderator'] && ($thispic['cat_delete_level'] != ALBUM_ADMIN)) || ($user->data['user_level'] == ADMIN)) ? $delete_url : '',
  662. 'DELETE' => (($auth_data['delete'] && ($commentrow[$i]['comment_user_id'] == $user->data['user_id'])) || ($auth_data['moderator'] && ($thispic['cat_delete_level'] != ALBUM_ADMIN)) || ($user->data['user_level'] == ADMIN)) ? '<a href="' . $delete_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" /></a>' : ''
  663. )
  664. );
  665. }
  666. }
  667. }
  668. // Mighty Gorgon - Slideshow - BEGIN
  669. if ($is_slideshow)
  670. {
  671. $template->assign_var('S_SLIDESHOW', true);
  672. $css_temp = array('fap_slideshow.css');
  673. $template->css_include = array_merge($template->css_include, $css_temp);
  674. unset($css_temp);
  675. $slideshow_delay = request_var('slideshow', 0);
  676. $slideshow_select = '';
  677. $slideshow_onoff = $lang['Slideshow_Off'];
  678. $slideshow_link = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id));
  679. $slideshow_link_full = '<a href="' . $slideshow_link . '">' . $lang['Slideshow_Off'] . '</a>';
  680. $pic_link = append_sid(album_append_uid($nuffimage_pic . PHP_EXT . '?pic_id=' . $pic_id));
  681. $pic_base_link = 'album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . $full_size_param . $sort_append;
  682. if ($album_config['invert_nav_arrows'] == 0)
  683. {
  684. $next_pic = ($no_prev_pic == false) ? '<a href="' . append_sid(album_append_uid($pic_base_link . '&amp;mode=next' . $nuffimage_vars)) . '#TopPic" style="background-image: none; display: inline;"><img src="' . $images['icon_left_arrow3'] . '" title="' . $lang['Next_Pic'] . '" alt="' . $lang['Next_Pic'] . '" style="border:0px;vertical-align:middle;" /></a>' : '';
  685. $prev_pic = ($no_next_pic == false) ? '<a href="' . append_sid(album_append_uid($pic_base_link . '&amp;mode=prev' . $nuffimage_vars)) . '#TopPic" style="background-image: none; display: inline;"><img src="' . $images['icon_right_arrow3'] . '" title="' . $lang['Prev_Pic'] . '" alt="' . $lang['Prev_Pic'] . '" style="border:0px;vertical-align:middle;" /></a>' : '';
  686. $next_pic_url = ($no_prev_pic == false) ? append_sid(album_append_uid($pic_base_link . '&amp;mode=next&amp;slideshow=' . $slideshow_delay)) . '#TopPic' : append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $first_pic_id . $full_size_param . $sort_append)) . '#TopPic';
  687. $prev_pic_url = ($no_next_pic == false) ? append_sid(album_append_uid($pic_base_link . '&amp;mode=prev&amp;slideshow=' . $slideshow_delay)) . '#TopPic' : append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $last_pic_id . $full_size_param . $sort_append)) . '#TopPic';
  688. }
  689. else
  690. {
  691. $next_pic = ($no_next_pic== false) ? '<a href="' . append_sid(album_append_uid($pic_base_link . '&amp;mode=prev' . $nuffimage_vars)) . '#TopPic" style="background-image: none; display: inline;"><img src="' . $images['icon_left_arrow3'] . '" title="' . $lang['Prev_Pic'] . '" alt="' . $lang['Prev_Pic'] . '" style="border:0px;vertical-align:middle;" /></a>' : '';
  692. $prev_pic = ($no_prev_pic == false) ? '<a href="' . append_sid(album_append_uid($pic_base_link . '&amp;mode=next' . $nuffimage_vars)) . '#TopPic" style="background-image: none; display: inline;"><img src="' . $images['icon_right_arrow3'] . '" title="' . $lang['Next_Pic'] . '" alt="' . $lang['Next_Pic'] . '" style="border:0px;vertical-align:middle;" /></a>' : '';
  693. $next_pic_url = ($no_next_pic == false) ? append_sid(album_append_uid($pic_base_link . '&amp;mode=prev&amp;slideshow=' . $slideshow_delay)) . '#TopPic' : append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $first_pic_id . $full_size_param . $sort_append)) . '#TopPic';
  694. $prev_pic_url = ($no_prev_pic == false) ? append_sid(album_append_uid($pic_base_link . '&amp;mode=next&amp;slideshow=' . $slideshow_delay)) . '#TopPic' : append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $last_pic_id . $full_size_param . $sort_append)) . '#TopPic';
  695. }
  696. }
  697. else
  698. {
  699. if ($album_config['show_slideshow'])
  700. {
  701. $template->assign_block_vars('switch_slideshow_enabled', array());
  702. }
  703. //$slideshow_delay = 5;
  704. $slideshow_select = $lang['Slideshow_Delay'] . ':&nbsp;';
  705. $slideshow_select .= '<select name="slideshow">';
  706. $slideshow_select .= '<option value="1">1 Sec</option>';
  707. $slideshow_select .= '<option value="3">3 Sec</option>';
  708. $slideshow_select .= '<option value="5" selected="selected">5 Sec</option>';
  709. $slideshow_select .= '<option value="7">7 Sec</option>';
  710. $slideshow_select .= '<option value="10">10 Sec</option>';
  711. $slideshow_select .= '</select>&nbsp;';
  712. $slideshow_onoff = $lang['Slideshow_On'];
  713. //$slideshow_link = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . '&amp;full=true&amp;slideshow=' . $slideshow_delay));
  714. $slideshow_link = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . '&amp;full=true'));
  715. $slideshow_link_full = '<a href="' . $slideshow_link . '">' . $lang['Slideshow_On'] . '</a>';
  716. $pic_link = append_sid(album_append_uid($nuffimage_pic . PHP_EXT . '?pic_id=' . $pic_id . $sort_append . $full_size_param . $nuff_http_full_string));
  717. $pic_base_link = 'album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . $full_size_param . $sort_append;
  718. if ($album_config['invert_nav_arrows'] == 0)
  719. {
  720. $next_pic = ($no_prev_pic == false) ? '<a href="' . append_sid(album_append_uid($pic_base_link . '&amp;mode=next' . $nuffimage_vars)) . '#TopPic" style="background-image: none; display: inline;"><img src="' . $images['icon_left_arrow3'] . '" title="' . $lang['Next_Pic'] . '" style="border:0px;vertical-align:middle;" alt="' . $lang['Next_Pic'] . '" /></a>' : '';
  721. $prev_pic = ($no_next_pic == false) ? '<a href="' . append_sid(album_append_uid($pic_base_link . '&amp;mode=prev' . $nuffimage_vars)) . '#TopPic" style="background-image: none; display: inline;"><img src="' . $images['icon_right_arrow3'] . '" title="' . $lang['Prev_Pic'] . '" style="border:0px;vertical-align:middle;" alt="' . $lang['Prev_Pic'] . '" /></a>' : '';
  722. }
  723. else
  724. {
  725. $next_pic = ($no_next_pic== false) ? '<a href="' . append_sid(album_append_uid($pic_base_link . '&amp;mode=prev' . $nuffimage_vars)) . '#TopPic" style="background-image: none; display: inline;"><img src="' . $images['icon_left_arrow3'] . '" title="' . $lang['Prev_Pic'] . '" style="border:0px;vertical-align:middle;" alt="' . $lang['Prev_Pic'] . '" /></a>' : '';
  726. $prev_pic = ($no_prev_pic == false) ? '<a href="' . append_sid(album_append_uid($pic_base_link . '&amp;mode=next' . $nuffimage_vars)) . '#TopPic" style="background-image: none; display: inline;"><img src="' . $images['icon_right_arrow3'] . '" title="' . $lang['Next_Pic'] . '" style="border:0px;vertical-align:middle;" alt="' . $lang['Next_Pic'] . '" /></a>' : '';
  727. }
  728. }
  729. //$temp_js = '<script type="text/javascript">window.attachEvent(\'onload\', runSlideShow();)</script>';
  730. if ($album_config['slideshow_script'])
  731. {
  732. $template->assign_var('S_SLIDESHOW_SCRIPT', true);
  733. //$slideshow_refresh = '</body><body onload="runSlideShow()">';
  734. //$slideshow_refresh = '<script type="text/javascript">onload_functions.push(\'runSlideShow()\');</script>';
  735. //$slideshow_refresh = $temp_js;
  736. }
  737. else
  738. {
  739. $slideshow_refresh = '<meta http-equiv="refresh" content="' . $slideshow_delay . ';url=' . $next_pic_url . '">';
  740. }
  741. $template->assign_vars(array(
  742. // Mighty Gorgon - Slideshow - BEGIN
  743. 'L_SLIDESHOW' => $lang['Slideshow'],
  744. 'L_SLIDESHOW_DELAY' => $lang['Slideshow_Delay'],
  745. 'L_SLIDESHOW_ONOFF' => $slideshow_onoff,
  746. 'S_SLIDESHOW_REFRESH' => $slideshow_refresh,
  747. 'SLIDESHOW_SELECT' => $slideshow_select,
  748. 'SLIDESHOW_DELAY' => $slideshow_delay,
  749. 'U_SLIDESHOW' => $slideshow_link,
  750. 'U_SLIDESHOW_FULL' => $slideshow_link_full,
  751. 'U_SLIDESHOW_REFRESH' => $slideshow_refresh,
  752. 'U_SLIDESHOW_REFRESH_META' => '<meta http-equiv="refresh" content="' . $slideshow_delay . ';url=' . $next_pic_url . '">',
  753. // Mighty Gorgon - Slideshow - END
  754. )
  755. );
  756. // Mighty Gorgon - Slideshow - END
  757. // Start output of page
  758. $meta_content['page_title'] = $lang['Album'] . ' - ' . $thispic['pic_title'];
  759. $meta_content['description'] = $lang['Album'] . ' - ' . strip_tags($thispic['cat_title']) . ' - ' . $thispic['pic_title'] . ' - ' . $thispic['pic_desc'];
  760. $meta_content['keywords'] = $lang['Album'] . ', ' . strip_tags($thispic['cat_title']) . ', ' . $thispic['pic_title'] . ', ' . $thispic['pic_desc'] . ', ';
  761. $poster = ($thispic['username'] == '') ? $lang['Guest'] : colorize_username($thispic['user_id'], $thispic['username'], $thispic['user_color'], $thispic['user_active']);
  762. //---------------------------------
  763. // Comment Posting Form
  764. //---------------------------------
  765. if (($auth_data['comment'] == 1) && $album_config['comment'])
  766. {
  767. $template->assign_block_vars('switch_comment_post', array());
  768. if(!$user->data['session_logged_in'])
  769. {
  770. $template->assign_block_vars('switch_comment_post.logout', array());
  771. }
  772. }
  773. // Rating System
  774. if ($album_config['rate'])
  775. {
  776. $image_rating = ImageRating($thispic['rating']);
  777. $template->assign_block_vars('rate_switch', array());
  778. if ($auth_data['rate'] == 1 && ($already_rated == false) && (($own_pic_rate == false) || ($user->data['user_level'] == ADMIN)))
  779. {
  780. $template->assign_block_vars('rate_switch.rate_row', array());
  781. for ($i = 0; $i < $album_config['rate_scale']; $i++)
  782. {
  783. $template->assign_block_vars('rate_switch.rate_row.rate_scale_row', array(
  784. 'POINT' => ($i + 1)
  785. )
  786. );
  787. }
  788. }
  789. }
  790. // Mighty Gorgon - Pic Size - BEGIN
  791. /*
  792. * JHL: this code was added and now removed by me because it is a brainfart for two reasons
  793. * - the thumbnail may not yet exist (!)
  794. * - the displayed page format would change as the real thumnail sizes may differ
  795. */
  796. /*
  797. $pic_info = pic_info($thispic['pic_filename'], $thispic['pic_thumbnail'], $thispic['pic_title']);
  798. $pic_thumbnail_path = $pic_info['thumbnail_m_fullpath'];
  799. $pic_thumbnail_size = @getimagesize($pic_thumbnail_path);
  800. $pic_thumbnail_width = $pic_thumbnail_size[0];
  801. $pic_thumbnail_height = $pic_thumbnail_size[1];
  802. */
  803. $pic_fullpath = ALBUM_UPLOAD_PATH . $thispic['pic_filename'];
  804. $pic_size = @getimagesize($pic_fullpath);
  805. $pic_width = $pic_size[0];
  806. $pic_height = $pic_size[1];
  807. $pic_filesize = @filesize($pic_fullpath);
  808. // Mighty Gorgon - Pic Size - END
  809. if (($album_config['show_exif'] == 1) && (function_exists('exif_read_data')))
  810. {
  811. //echo(function_exists(exif_read_data));
  812. $xif = @exif_read_data($pic_fullpath, 0, true);
  813. if (!empty($xif[IFD0]) || !empty($xif[EXIF]))
  814. {
  815. $template->assign_block_vars('switch_exif_enabled', array());
  816. include_once(ALBUM_MOD_PATH . 'album_exif_info.' . PHP_EXT);
  817. }
  818. }
  819. $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
  820. $server_name = trim($config['server_name']);
  821. $server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' : '/';
  822. $script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($config['script_path']));
  823. $script_name = ($script_name == '') ? '' : $script_name . '/';
  824. $server_path = $server_protocol . $server_name . $server_port . $script_name;
  825. $thumbnail_file = append_sid(album_append_uid('album_thumbnail.' . PHP_EXT . '?pic_id=' . $pic_id));
  826. if (($album_config['thumbnail_cache'] == true) && ($album_config['quick_thumbs'] == true))
  827. {
  828. $thumbnail_file = picture_quick_thumb($thispic[$i]['pic_filename'], $thispic[$i]['pic_thumbnail'], $thumbnail_file);
  829. }
  830. $edit_link_content = $lang['Edit_pic'];
  831. $delete_link_content = $lang['Delete_pic'];
  832. $lock_link_content = ($thispic['pic_lock'] == 0) ? $lang['Lock'] : $lang['Unlock'];
  833. $move_link_content = $lang['Move'];
  834. $copy_link_content = $lang['Copy'];
  835. $style_used = explode('/', $template->files['body']);
  836. $allowed_styles = array(
  837. //'ca_aphrodite',
  838. 'floreal',
  839. 'icy_phoenix',
  840. 'mg_themes',
  841. //'morpheus',
  842. 'pearl',
  843. //'squared',
  844. );
  845. if(in_array($style_used[2], $allowed_styles) && (!empty($template->xs_version)))
  846. {
  847. $edit_link_content = '<img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_pic'] . '" title="' . $lang['Edit_pic'] . '" />';
  848. $delete_link_content = '<img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['Delete_pic'] . '" title="' . $lang['Delete_pic'] . '" />';
  849. $lock_link_content = ($thispic['pic_lock'] == 0) ? '<img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['Lock'] . '" title="' . $lang['Lock'] . '" />' : '<img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['Unlock'] . '" title="' . $lang['Unlock'] . '" />';
  850. $move_link_content = '<img src="' . $images['topic_mod_move'] . '" alt="' . $lang['Move'] . '" title="' . $lang['Move'] . '" />';
  851. $copy_link_content = '<img src="' . $images['topic_mod_copy'] . '" alt="' . $lang['Copy'] . '" title="' . $lang['Copy'] . '" />';
  852. }
  853. $pic_desc = $thispic['pic_desc'];
  854. $parse_desc_bbcode = true;
  855. if ($parse_desc_bbcode)
  856. {
  857. $bbcode->allow_html = ($config['allow_html'] ? true : false);
  858. $bbcode->allow_bbcode = ($config['allow_bbcode'] ? true : false);
  859. $bbcode->allow_smilies = ($config['allow_smilies'] ? true : false);
  860. $pic_desc = $bbcode->parse($pic_desc);
  861. }
  862. else
  863. {
  864. $pic_desc = nl2br(htmlspecialchars($pic_desc));
  865. }
  866. $pic_sp_link = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $thispic['pic_id']));
  867. $pic_dl_link = append_sid(album_append_uid('album_pic.' . PHP_EXT . '?pic_id=' . $thispic['pic_id']));
  868. $pic_full_set = (($picm == false) || ($nuff_display == true)) ? true : false;
  869. $user_info = array();
  870. $user_info = generate_user_info($thispic);
  871. foreach ($user_info as $k => $v)
  872. {
  873. $$k = $v;
  874. }
  875. $poster_avatar = $user_info['avatar'];
  876. $template->assign_vars(array(
  877. 'CAT_TITLE' => $thispic['cat_title'],
  878. 'U_VIEW_CAT' => append_sid(album_append_uid('album_cat.' . PHP_EXT . '?cat_id=' . $cat_id)),
  879. 'ALBUM_NAVIGATION_ARROW' => ALBUM_NAV_ARROW,
  880. 'NAV_CAT_DESC' => $album_nav_cat_desc,
  881. 'EDIT' => (($auth_data['moderator']) || ($user->data['user_id'] == $thispic['pic_user_id'])) ? '<a href="' . append_sid(album_append_uid('album_edit.' . PHP_EXT . '?pic_id=' . $thispic['pic_id'])) . '">' . $edit_link_content . '</a>' : '',
  882. 'DELETE' => (($auth_data['moderator']) || ($user->data['user_id'] == $thispic['pic_user_id'])) ? '<a href="' . append_sid(album_append_uid('album_delete.' . PHP_EXT . '?pic_id=' . $thispic['pic_id'])) . '">' . $delete_link_content . '</a>' : '',
  883. 'LOCK' => ($auth_data['moderator']) ? '<a href="' . append_sid(album_append_uid('album_modcp.' . PHP_EXT . '?mode=' . (($thispic['pic_lock'] == 0) ? 'lock' : 'unlock') . '&amp;pic_id=' . $thispic['pic_id'])) . '">' . $lock_link_content . '</a>' : '',
  884. 'MOVE' => ($auth_data['moderator']) ? '<a href="' . append_sid(album_append_uid('album_modcp.' . PHP_EXT . '?mode=move&amp;pic_id=' . $thispic['pic_id'])) . '">' . $move_link_content . '</a>' : '',
  885. 'COPY' => ($auth_data['moderator']) ? '<a href="'. append_sid(album_append_uid('album_modcp.' . PHP_EXT . '?mode=copy&amp;pic_id=' . $thispic['pic_id'])) . '">' . $copy_link_content . '</a>' : '',
  886. 'U_PIC_FULL_URL' => $server_path . $pic_fullpath,
  887. //'U_PIC' => append_sid(album_append_uid($nuffimage_pic . PHP_EXT . '?pic_id=' . $pic_id . $sort_append . $full_size_param . $nuff_http_full_string)),
  888. 'U_PIC' => $pic_link,
  889. 'U_PIC_SP' => $pic_sp_link,
  890. 'U_PIC_DL' => $pic_dl_link,
  891. //'U_PIC_L1' => ($picm == false) ? '' : '<a href="album_showpage.' . PHP_EXT . '?full=true&amp;pic_id=' . $pic_id . $nuffimage_vars . '">',
  892. 'U_PIC_L1' => ($pic_full_set) ? '' : '<a href="' . append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?full=true&amp;pic_id=' . $pic_id . $sort_append . $nuffimage_vars)) . '">',
  893. 'U_PIC_L2' => ($pic_full_set) ? '' : '</a>',
  894. 'U_PIC_CLICK' => ($pic_full_set) ? '' : $lang['Click_enlarge'],
  895. 'U_PIC_THUMB' => append_sid(album_append_uid('album_thumbnail.' . PHP_EXT . '?pic_id=' . $pic_id . $sort_append)),
  896. 'U_SMILEY_CREATOR' => append_sid('smiley_creator.' . PHP_EXT . '?mode=text2shield'),
  897. 'PIC_COUNT' => sprintf($lang['Pics_Counter'], ($new_pic_array_id + 1), $total_pic_count),
  898. 'NEXT_PIC' => $next_pic,
  899. 'PREV_PIC' => $prev_pic,
  900. // Mighty Gorgon - Pic Size - BEGIN
  901. 'L_PIC_DETAILS' => $lang['Pic_Details'],
  902. 'L_PIC_SIZE' => $lang['Pic_Size'],
  903. 'L_PIC_TYPE' => $lang['Pic_Type'],
  904. // Mighty Gorgon: JHL wants to remove this code by replacing the size with the ones added in album_config, but it's better to keep this code, to make sure proportions are always respected
  905. // JHL: No, see the reasoning above
  906. /*
  907. 'PIC_HEIGHT' => ($pic_full_set) ? $pic_height : $pic_thumbnail_height,
  908. 'PIC_WIDTH' => ($pic_full_set) ? $pic_width : $pic_thumbnail_width,
  909. */
  910. 'PIC_HEIGHT' => ($pic_full_set) ? $pic_height : $album_config['midthumb_height'],
  911. 'PIC_WIDTH' => ($pic_full_set) ? $pic_width : $album_config['midthumb_width'],
  912. 'PIC_SIZE' => $pic_width . ' x ' . $pic_height . ' (' . intval($pic_filesize/1024) . 'KB)',
  913. 'PIC_TYPE' => strtoupper(substr($thispic['pic_filename'], strlen($thispic['pic_filename']) - 3, 3)),
  914. // Mighty Gorgon - Pic Size - END
  915. 'PIC_ID' => $pic_id,
  916. 'PIC_BBCODE' => '[albumimg]' . $pic_id . '[/albumimg]',
  917. 'PIC_TITLE' => $thispic['pic_title'],
  918. 'PIC_DESC' => $pic_desc,
  919. 'S_THUMBNAIL_SIZE' => $album_config['thumbnail_size'],
  920. 'POSTER' => $poster,
  921. 'POSTER_AVATAR' => $poster_avatar,
  922. 'PIC_TIME' => create_date_ip($config['default_dateformat'], $thispic['pic_time'], $config['board_timezone']),
  923. 'PIC_VIEW' => $thispic['pic_view_count'],
  924. 'PIC_COMMENTS' => $total_comments,
  925. 'TARGET_BLANK' => ($album_config['fullpic_popup']) ? 'target="_blank"' : '',
  926. 'L_PIC_ID' => $lang['Pic_ID'],
  927. 'L_PIC_BBCODE' => $lang['Pic_BBCode'],
  928. 'L_PIC_TITLE' => $lang['Pic_Image'],
  929. 'L_PIC_DESC' => $lang['Pic_Desc'],
  930. 'L_POSTER' => $lang['Pic_Poster'],
  931. 'L_POSTED' => $lang['Posted'],
  932. 'L_VIEW' => $lang['Views'],
  933. 'L_COMMENTS' => $lang['Comments'],
  934. 'L_RATING' => $lang['Rating'],
  935. 'L_EDIT' => $lang['Edit'],
  936. 'L_DELETE' => $lang['Delete'],
  937. 'L_USER_WWW' => $lang['Website'],
  938. 'L_USER_EMAIL' => $lang['Send_Email'],
  939. 'L_USER_PROFILE' => $lang['Profile'],
  940. 'L_ONLINE_STATUS' => $lang['Online_status'],
  941. 'L_PM' => $lang['Private_Message'],
  942. 'L_POST_YOUR_COMMENT' => $lang['Post_your_comment'],
  943. 'L_MESSAGE' => $lang['Message'],
  944. 'L_USERNAME' => $lang['Username'],
  945. 'L_COMMENT_NO_TEXT' => $lang['Comment_no_text'],
  946. 'L_COMMENT_TOO_LONG' => $lang['Comment_too_long'],
  947. 'L_MAX_LENGTH' => $lang['Max_length'],
  948. 'S_MAX_LENGTH' => $album_config['desc_length'],
  949. 'L_ORDER' => $lang['Order'],
  950. 'L_SORT' => $lang['Sort'],
  951. 'L_ASC' => $lang['Sort_Ascending'],
  952. 'L_DESC' => $lang['Sort_Descending'],
  953. 'L_BACK_TO_TOP' => $lang['Back_to_top'],
  954. 'L_COMMENT_WATCH' =>$lang['Pic_comment_notification'],
  955. 'SORT_ASC' => ($sort_order == 'ASC') ? 'selected="selected"' : '',
  956. 'SORT_DESC' => ($sort_order == 'DESC') ? 'selected="selected"' : '',
  957. 'L_SUBMIT' => $lang['Submit'],
  958. 'S_ALBUM_ACTION' => append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id)),
  959. 'U_COMMENT_WATCH_LINK' =>($is_watching_comments) ? '<a href="' . append_sid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . '&amp;unwatch=comment') . '">' . $lang['Unwatch_pic'] . '</a>' : ($user->data['session_logged_in'] ? '<a href="' . append_sid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . '&amp;watch=comment') . '">' . $lang['Watch_pic'] . '</a>' : ''),
  960. // Rating
  961. //'S_RATE_MSG' => (!$user->data['session_logged_in'] && $auth_data['rate'] == 0) ? $lang['Login_To_Vote'] : (($already_rated) ? $lang['Already_rated'] : $lang['Please_Rate_It']),
  962. 'S_RATE_MSG' => (!$user->data['session_logged_in'] && $auth_data['rate'] == 0) ? $lang['Login_To_Vote'] : ((($own_pic_rate == true) && ($user->data['user_level'] != ADMIN)) ? $lang['Own_Pic_Rate'] : ((($already_rated == true) && ($user->data['user_level'] != ADMIN)) ? $lang['Already_rated'] : $lang['Please_Rate_It'])),
  963. 'PIC_RATING' => $image_rating . ((($own_pic_rate == true) && ($user->data['user_level'] != ADMIN)) ? '&nbsp;(' . $lang['Own_Pic_Rate'] . ')' : ((($already_rated == true) && ($user->data['user_level'] != ADMIN)) ? ('&nbsp;(' . $lang['Already_rated'] . ')') : '')),
  964. 'L_CURRENT_RATING' => $lang['Current_Rating'],
  965. 'L_PLEASE_RATE_IT' => $lang['Please_Rate_It']
  966. )
  967. );
  968. // Social Bookmarks
  969. if ($config['show_social_bookmarks'] == true)
  970. {
  971. $template->assign_block_vars('social_bookmarks', array());
  972. }
  973. $topic_title_enc = urlencode(ip_utf8_decode($thispic['pic_title']));
  974. $topic_title_enc_utf8 = urlencode($thispic['pic_title']);
  975. $topic_link = 'album_showpage.' . PHP_EXT . '?pic_id=' . $thispic['pic_id'] . $full_size_param . $nuffimage_vars . $sort_append;
  976. $topic_url_enc = urlencode(ip_utf8_decode(create_server_url() . $topic_link));
  977. $topic_url_enc_utf8 = urlencode(create_server_url() . $topic_link);
  978. $template->assign_vars(array(
  979. // Social Bookmarks - BEGIN
  980. 'TOPIC_TITLE_ENC' => $topic_title_enc,
  981. 'TOPIC_TITLE_ENC_UTF8' => $topic_title_enc_utf8,
  982. 'TOPIC_URL_ENC' => $topic_url_enc,
  983. 'TOPIC_URL_ENC_UTF8' => $topic_url_enc_utf8,
  984. 'U_TELL' => append_sid('tellafriend.' . PHP_EXT . '?topic_title=' . $topic_title_enc . '&amp;topic_url=' . urlencode(ip_utf8_decode(str_replace('&amp;', '&', $topic_link)))),
  985. 'L_SHARE_TOPIC' => $lang['ShareThisTopic'],
  986. // Social Bookmarks - END
  987. )
  988. );
  989. // BBCBMG - BEGIN
  990. include(IP_ROOT_PATH . 'includes/bbcb_mg.' . PHP_EXT);
  991. $template->assign_var_from_handle('BBCB_MG', 'bbcb_mg');
  992. // BBCBMG - END
  993. // BBCBMG SMILEYS - BEGIN
  994. generate_smilies('inline');
  995. include(IP_ROOT_PATH . 'includes/bbcb_smileys_mg.' . PHP_EXT);
  996. $template->assign_var_from_handle('BBCB_SMILEYS_MG', 'bbcb_smileys_mg');
  997. // BBCBMG SMILEYS - END
  998. if (($album_config['comment'] == 1) && ($total_comments > 0))
  999. {
  1000. $template->assign_vars(array(
  1001. 'PAGINATION' => generate_pagination(append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . '&amp;sort_order=' . $sort_order)), $total_comments, $comments_per_page, $start),
  1002. 'PAGE_NUMBER' => sprintf($lang['Page_of'], (floor($start / $comm

Large files files are truncated, but you can click here to view the full file