PageRenderTime 42ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/Portal_XL50_Premod-3.0.8/phpBB3/gallery/index.php

https://github.com/Lucky65/phpBB-Portal-XL-5.0-italian
PHP | 272 lines | 201 code | 27 blank | 44 comment | 34 complexity | 5ce7b6953c4ef499975a809321c31448 MD5 | raw file
  1. <?php
  2. /**
  3. *
  4. * @package phpBB Gallery
  5. * @version $Id$
  6. * @copyright (c) 2007 nickvergessen nickvergessen@gmx.de http://www.flying-bits.org
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. *
  9. */
  10. /**
  11. * @ignore
  12. */
  13. define('IN_PHPBB', true);
  14. $phpbb_root_path = $gallery_root_path = '';
  15. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  16. include($phpbb_root_path . $gallery_root_path . 'includes/root_path.' . $phpEx);
  17. include($phpbb_root_path . 'common.' . $phpEx);
  18. include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  19. include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
  20. // Start session management
  21. $user->session_begin();
  22. $auth->acl($user->data);
  23. $user->setup(array('mods/gallery', 'mods/info_acp_gallery'));
  24. $gallery_root_path = GALLERY_ROOT_PATH;
  25. include($phpbb_root_path . $gallery_root_path . 'includes/common.' . $phpEx);
  26. include($phpbb_root_path . $gallery_root_path . 'includes/permissions.' . $phpEx);
  27. include($phpbb_root_path . $gallery_root_path . 'includes/functions_display.' . $phpEx);
  28. /**
  29. * Display albums
  30. */
  31. $mode = request_var('mode', 'index', true);
  32. display_albums((($mode == 'personal') ? 'personal' : 0), $config['load_moderators']);
  33. if ($mode == 'personal')
  34. {
  35. $template->assign_block_vars('navlinks', array(
  36. 'FORUM_NAME' => $user->lang['PERSONAL_ALBUMS'],
  37. 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}{$gallery_root_path}index.$phpEx", 'mode=personal'))
  38. );
  39. $template->assign_var('S_PERSONAL_GALLERY', true);
  40. }
  41. /**
  42. * Add a personal albums category to the album listing if the user has permission to view personal albums
  43. */
  44. else if ($gallery_config['personal_album_index'] && gallery_acl_check('a_list', PERSONAL_GALLERY_PERMISSIONS))
  45. {
  46. $images = $images_real = $last_image = 0;
  47. $last_image = $lastimage_image_id = $lastimage_user_id = $lastimage_album_id = 0;
  48. $lastimage_time = $lastimage_name = $lastimage_username = $lastimage_user_colour = $last_image_page_url = $last_thumb_url = '';
  49. $sql = 'SELECT *
  50. FROM ' . GALLERY_ALBUMS_TABLE . '
  51. WHERE album_user_id <> 0';
  52. $result = $db->sql_query($sql);
  53. while ($row = $db->sql_fetchrow($result))
  54. {
  55. $images += $row['album_images'];
  56. $images_real += $row['album_images_real'];
  57. if ($last_image < $row['album_last_image_id'])
  58. {
  59. $last_image = $row['album_last_image_id'];
  60. $lastimage_name = $row['album_last_image_name'];
  61. $lastimage_time = $user->format_date($row['album_last_image_time']);
  62. $lastimage_image_id = $row['album_last_image_id'];
  63. $lastimage_user_id = $row['album_last_user_id'];
  64. $lastimage_username = $row['album_last_username'];
  65. $lastimage_user_colour = $row['album_last_user_colour'];
  66. // www.phpBB-SEO.com SEO TOOLKIT BEGIN
  67. $phpbb_seo->prepare_url('pic', $lastimage_name, $lastimage_image_id, $phpbb_seo->seo_url['album'][$row['album_id']]);
  68. // www.phpBB-SEO.com SEO TOOLKIT END
  69. $last_image_page_url = append_sid("{$phpbb_root_path}{$gallery_root_path}image_page.$phpEx", 'album_id=' . $row['album_id'] . '&amp;image_id=' . $row['album_last_image_id']);
  70. $last_thumb_url = append_sid("{$phpbb_root_path}{$gallery_root_path}thumbnail.$phpEx", 'album_id=' . $row['album_id'] . '&amp;image_id=' . $row['album_last_image_id']);
  71. $lastimage_album_id = $row['album_id'];
  72. }
  73. }
  74. $db->sql_freeresult($result);
  75. $template->assign_block_vars('albumrow', array(
  76. 'S_IS_CAT' => true,
  77. 'S_NO_CAT' => false,
  78. 'S_LIST_SUBALBUMS' => true,
  79. 'S_SUBALBUMS' => true,
  80. 'U_VIEWALBUM' => append_sid("{$phpbb_root_path}{$gallery_root_path}index.$phpEx", 'mode=personal'),
  81. 'ALBUM_NAME' => $user->lang['USERS_PERSONAL_ALBUMS'],
  82. ));
  83. $template->assign_block_vars('albumrow', array(
  84. 'S_IS_CAT' => false,
  85. 'S_NO_CAT' => false,
  86. 'S_LIST_SUBALBUMS' => true,
  87. 'S_SUBALBUMS' => true,
  88. 'U_VIEWALBUM' => append_sid("{$phpbb_root_path}{$gallery_root_path}index.$phpEx", 'mode=personal'),
  89. 'ALBUM_NAME' => $user->lang['USERS_PERSONAL_ALBUMS'],
  90. 'ALBUM_FOLDER_IMG' => $user->img('forum_read_subforum', 'no'),
  91. 'ALBUM_FOLDER_IMG_SRC' => $user->img('forum_read_subforum', 'no', false, '', 'src'),
  92. 'SUBALBUMS' => ((gallery_acl_check('i_upload', OWN_GALLERY_PERMISSIONS) || $user->gallery['personal_album_id']) ? '<a href="' . (($user->gallery['personal_album_id']) ? append_sid("{$phpbb_root_path}{$gallery_root_path}album.$phpEx", 'album_id=' . $user->gallery['personal_album_id']) : append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=gallery&amp;mode=manage_albums')) . '">' . $user->data['username'] . '</a>' : ''),
  93. 'ALBUM_DESC' => '',
  94. 'L_MODERATORS' => '',
  95. 'L_SUBALBUM_STR' => (gallery_acl_check('i_upload', OWN_GALLERY_PERMISSIONS) || $user->gallery['personal_album_id']) ? $user->lang['YOUR_PERSONAL_ALBUM'] . ': ' : '',
  96. 'MODERATORS' => '',
  97. 'IMAGES' => $images,
  98. 'UNAPPROVED_IMAGES' => (gallery_acl_check('m_status', PERSONAL_GALLERY_PERMISSIONS)) ? $images_real - $images : '',
  99. 'LAST_IMAGE_TIME' => $lastimage_time,
  100. 'LAST_USER_FULL' => get_username_string('full', $lastimage_user_id, $lastimage_username, $lastimage_user_colour),
  101. 'UC_FAKE_THUMBNAIL' => ($gallery_config['disp_fake_thumb']) ? generate_image_link('fake_thumbnail', $gallery_config['link_thumbnail'], $lastimage_image_id, $lastimage_name, $lastimage_album_id) : '',
  102. 'UC_IMAGE_NAME' => generate_image_link('image_name', $gallery_config['link_image_name'], $lastimage_image_id, $lastimage_name, $lastimage_album_id),
  103. 'UC_LASTIMAGE_ICON' => generate_image_link('lastimage_icon', $gallery_config['link_image_icon'], $lastimage_image_id, $lastimage_name, $lastimage_album_id),
  104. ));
  105. // Assign subforums loop for style authors
  106. $template->assign_block_vars('albumrow.subalbum', array(
  107. 'U_SUBALBUM' => ((gallery_acl_check('i_upload', OWN_GALLERY_PERMISSIONS)) ? ($user->gallery['personal_album_id'] > 0) ? append_sid("{$phpbb_root_path}{$gallery_root_path}album.$phpEx", 'album_id=' . $user->gallery['personal_album_id']) : append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=gallery&amp;mode=manage_albums') : ''),
  108. 'SUBALBUM_NAME' => $user->lang['YOUR_PERSONAL_ALBUM'],
  109. ));
  110. }
  111. /**
  112. * Recent images & comments and random images
  113. */
  114. include($phpbb_root_path . $gallery_root_path . 'includes/functions_recent.' . $phpEx);
  115. $ints = array(
  116. 'rows' => $gallery_config['rrc_gindex_rows'],
  117. 'columns' => $gallery_config['rrc_gindex_columns'],
  118. 'comments' => $gallery_config['rrc_gindex_crows'],
  119. 'contests' => $gallery_config['rrc_gindex_contests'],
  120. );
  121. /**
  122. * int array including all relevent numbers for rows, columns and stuff like that,
  123. * display int sum of the options which should be displayed, see gallery/includes/constants.php "// Display-options for RRC-Feature" for values
  124. * modes int sum of the modes which should be displayed, see gallery/includes/constants.php "// Mode-options for RRC-Feature" for values
  125. * collapse bool collapse comments
  126. * include_pgalleries bool include personal albums
  127. * mode_id string 'user' or 'album' to only display images of a certain user or album
  128. * id int user_id for user profile or album_id for view of recent and random images
  129. */
  130. if ($gallery_config['rrc_gindex_mode'])
  131. {
  132. recent_gallery_images($ints, $gallery_config['rrc_gindex_display'], $gallery_config['rrc_gindex_mode'], $gallery_config['rrc_gindex_comments'], $gallery_config['rrc_gindex_pgalleries']);
  133. }
  134. // Set some stats, get posts count from forums data if we... hum... retrieve all forums data
  135. $total_images = $config['num_images'];
  136. $total_comments = $gallery_config['num_comments'];
  137. $total_pgalleries = $gallery_config['personal_counter'];
  138. $l_total_image_s = ($total_images == 0) ? 'TOTAL_IMAGES_ZERO' : 'TOTAL_IMAGES_OTHER';
  139. $l_total_comment_s = ($total_comments == 0) ? 'TOTAL_COMMENTS_ZERO' : 'TOTAL_COMMENTS_OTHER';
  140. $l_total_pgallery_s = ($total_pgalleries == 0) ? 'TOTAL_PGALLERIES_ZERO' : 'TOTAL_PGALLERIES_OTHER';
  141. // Grab group details for legend display
  142. $legend = '';
  143. if ($gallery_config['disp_whoisonline'])
  144. {
  145. // Copied from phpbb::index.php
  146. if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
  147. {
  148. $sql = 'SELECT group_id, group_name, group_colour, group_type
  149. FROM ' . GROUPS_TABLE . '
  150. WHERE group_legend = 1
  151. ORDER BY group_name ASC';
  152. }
  153. else
  154. {
  155. $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
  156. FROM ' . GROUPS_TABLE . ' g
  157. LEFT JOIN ' . USER_GROUP_TABLE . ' ug
  158. ON (
  159. g.group_id = ug.group_id
  160. AND ug.user_id = ' . $user->data['user_id'] . '
  161. AND ug.user_pending = 0
  162. )
  163. WHERE g.group_legend = 1
  164. AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
  165. ORDER BY g.group_name ASC';
  166. }
  167. $result = $db->sql_query($sql);
  168. $legend = array();
  169. while ($row = $db->sql_fetchrow($result))
  170. {
  171. $colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
  172. $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
  173. if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
  174. {
  175. $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
  176. }
  177. else
  178. {
  179. // www.phpBB-SEO.com SEO TOOLKIT BEGIN
  180. $phpbb_seo->prepare_url('group', $row['group_name'], $row['group_id']);
  181. // www.phpBB-SEO.com SEO TOOLKIT END
  182. $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
  183. }
  184. }
  185. $db->sql_freeresult($result);
  186. $legend = implode(', ', $legend);
  187. }
  188. // Generate birthday list if required ...
  189. $birthday_list = '';
  190. if ($config['allow_birthdays'] && $gallery_config['disp_birthdays'])
  191. {
  192. // Copied from phpbb::index.php
  193. $now = getdate(time() + $user->timezone + $user->dst - date('Z'));
  194. $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
  195. FROM ' . USERS_TABLE . ' u
  196. LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
  197. WHERE (b.ban_id IS NULL
  198. OR b.ban_exclude = 1)
  199. AND u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
  200. AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
  201. $result = $db->sql_query($sql);
  202. while ($row = $db->sql_fetchrow($result))
  203. {
  204. $birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
  205. if ($age = (int) substr($row['user_birthday'], -4))
  206. {
  207. $birthday_list .= ' (' . ($now['year'] - $age) . ')';
  208. }
  209. }
  210. $db->sql_freeresult($result);
  211. }
  212. $first_char = request_var('first_char', '');
  213. $s_char_options = '<option value=""' . ((!$first_char) ? ' selected="selected"' : '') . '>' . $user->lang['ALL'] . '</option>';
  214. // Loop the ASCII: a-z
  215. for ($i = 97; $i < 123; $i++)
  216. {
  217. $s_char_options .= '<option value="' . chr($i) . '"' . (($first_char == chr($i)) ? ' selected="selected"' : '') . '>' . chr($i - 32) . '</option>';
  218. }
  219. $s_char_options .= '<option value="other"' . (($first_char == 'other') ? ' selected="selected"' : '') . '>#</option>';
  220. // Output page
  221. $template->assign_vars(array(
  222. 'TOTAL_IMAGES' => ($gallery_config['disp_statistic']) ? sprintf($user->lang[$l_total_image_s], $total_images) : '',
  223. 'TOTAL_COMMENTS' => ($gallery_config['allow_comments']) ? sprintf($user->lang[$l_total_comment_s], $total_comments) : '',
  224. 'TOTAL_PGALLERIES' => (gallery_acl_check('a_list', PERSONAL_GALLERY_PERMISSIONS)) ? sprintf($user->lang[$l_total_pgallery_s], $total_pgalleries) : '',
  225. // www.phpBB-SEO.com SEO TOOLKIT BEGIN
  226. 'NEWEST_PGALLERIES' => ($total_pgalleries) ? sprintf($user->lang['NEWEST_PGALLERY'], get_username_string('full', $gallery_config['newest_pgallery_user_id'], $gallery_config['newest_pgallery_username'], $gallery_config['newest_pgallery_user_colour'], '', "{$phpbb_root_path}{$gallery_root_path}album.$phpEx?album_id=". $gallery_config['newest_pgallery_album_id'])) : '',
  227. // www.phpBB-SEO.com SEO TOOLKIT END
  228. 'S_DISP_LOGIN' => $gallery_config['disp_login'],
  229. 'S_DISP_WHOISONLINE' => $gallery_config['disp_whoisonline'],
  230. 'LEGEND' => $legend,
  231. 'BIRTHDAY_LIST' => $birthday_list,
  232. 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&amp;redirect=' . urlencode("{$gallery_root_path}index.$phpEx" . (($mode == 'personal') ? '?mode=personal' : ''))),
  233. 'S_DISPLAY_BIRTHDAY_LIST' => ($gallery_config['disp_birthdays']) ? true : false,
  234. 'U_YOUR_PERSONAL_GALLERY' => (gallery_acl_check('i_upload', OWN_GALLERY_PERMISSIONS)) ? ($user->gallery['personal_album_id'] > 0) ? append_sid("{$phpbb_root_path}{$gallery_root_path}album.$phpEx", 'album_id=' . $user->gallery['personal_album_id']) : append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=gallery&amp;mode=manage_albums') : '',
  235. 'U_USERS_PERSONAL_GALLERIES' => (gallery_acl_check('a_list', PERSONAL_GALLERY_PERMISSIONS)) ? append_sid("{$phpbb_root_path}{$gallery_root_path}index.$phpEx", 'mode=personal') : '',
  236. 'S_USERS_PERSONAL_GALLERIES' => (!$gallery_config['personal_album_index'] && gallery_acl_check('a_list', PERSONAL_GALLERY_PERMISSIONS)) ? true : false,
  237. 'S_CHAR_OPTIONS' => $s_char_options,
  238. 'U_MARK_ALBUMS' => ($user->data['is_registered']) ? append_sid("{$phpbb_root_path}{$gallery_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;mark=albums') : '',
  239. ));
  240. page_header($user->lang['GALLERY'] . (($mode == 'personal') ? ' - ' . $user->lang['PERSONAL_ALBUMS'] : ''));
  241. $template->set_filenames(array(
  242. 'body' => 'gallery/index_body.html')
  243. );
  244. page_footer();
  245. ?>