/** * Sets up some basic stuff for the gallery. */ public static function init() { global $db, $user; phpbb_gallery_url::_include('functions_phpbb', 'phpbb', 'includes/gallery/'); phpbb_gallery_plugins::init(phpbb_gallery_url::path()); // Little precaution. $user->data['user_id'] = (int) $user->data['user_id']; self::$user = new phpbb_gallery_user($db, $user->data['user_id']); $user_id = $user->data['user_perm_from'] == 0 ? $user->data['user_id'] : $user->data['user_perm_from']; self::$auth = new phpbb_gallery_auth($user_id); if (phpbb_gallery_config::get('mvc_time') < time()) { // Check the version, do we need to update? phpbb_gallery_config::set('mvc_time', time() + 86400); phpbb_gallery_config::set('mvc_version', phpbb_gallery_modversioncheck::check(true)); } self::$loaded = true; }
/** * */ public static function add_user_to_user_cache(&$user_cache, $row) { global $auth, $config, $user; $user_id = $row['user_id']; if ($user_id == ANONYMOUS) { $user_cache[$user_id] = array('joined' => '', 'posts' => '', 'from' => '', 'sig' => '', 'sig_bbcode_uid' => '', 'sig_bbcode_bitfield' => '', 'online' => false, 'avatar' => $user->optionget('viewavatars') ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '', 'rank_title' => '', 'rank_image' => '', 'rank_image_src' => '', 'sig' => '', 'profile' => '', 'pm' => '', 'email' => '', 'www' => '', 'icq_status_img' => '', 'icq' => '', 'aim' => '', 'msn' => '', 'yim' => '', 'jabber' => '', 'search' => '', 'age' => '', 'gallery_album' => '', 'gallery_images' => '', 'gallery_search' => '', 'username' => $row['username'], 'user_colour' => $row['user_colour'], 'warnings' => 0, 'allow_pm' => 0); get_user_rank($row['user_rank'], false, $user_cache[$user_id]['rank_title'], $user_cache[$user_id]['rank_image'], $user_cache[$user_id]['rank_image_src']); } else { $user_sig = ''; if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs')) { $user_sig = $row['user_sig']; } $id_cache[] = $user_id; $user_cache[$user_id] = array('joined' => $user->format_date($row['user_regdate']), 'posts' => $row['user_posts'], 'warnings' => isset($row['user_warnings']) ? $row['user_warnings'] : 0, 'from' => !empty($row['user_from']) ? $row['user_from'] : '', 'sig' => $user_sig, 'sig_bbcode_uid' => !empty($row['user_sig_bbcode_uid']) ? $row['user_sig_bbcode_uid'] : '', 'sig_bbcode_bitfield' => !empty($row['user_sig_bbcode_bitfield']) ? $row['user_sig_bbcode_bitfield'] : '', 'viewonline' => $row['user_allow_viewonline'], 'allow_pm' => $row['user_allow_pm'], 'avatar' => $user->optionget('viewavatars') ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '', 'age' => '', 'rank_title' => '', 'rank_image' => '', 'rank_image_src' => '', 'user_id' => $row['user_id'], 'username' => $row['username'], 'user_colour' => $row['user_colour'], 'online' => false, 'profile' => phpbb_gallery_url::append_sid('phpbb', 'memberlist', "mode=viewprofile&u={$user_id}"), 'www' => $row['user_website'], 'aim' => $row['user_aim'] && $auth->acl_get('u_sendim') ? phpbb_gallery_url::append_sid('phpbb', 'memberlist', "mode=contact&action=aim&u={$user_id}") : '', 'msn' => $row['user_msnm'] && $auth->acl_get('u_sendim') ? phpbb_gallery_url::append_sid('phpbb', 'memberlist', "mode=contact&action=msnm&u={$user_id}") : '', 'yim' => $row['user_yim'] ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&.src=pg' : '', 'jabber' => $row['user_jabber'] && $auth->acl_get('u_sendim') ? phpbb_gallery_url::append_sid('phpbb', 'memberlist', "mode=contact&action=jabber&u={$user_id}") : '', 'search' => $auth->acl_get('u_search') ? phpbb_gallery_url::append_sid('phpbb', 'search', "author_id={$user_id}&sr=posts") : '', 'gallery_album' => $row['personal_album_id'] && phpbb_gallery_config::get('viewtopic_icon') ? phpbb_gallery_url::append_sid('album', "album_id=" . $row['personal_album_id']) : '', 'gallery_images' => phpbb_gallery_config::get('viewtopic_images') ? $row['user_images'] : 0, 'gallery_search' => phpbb_gallery_config::get('viewtopic_images') && phpbb_gallery_config::get('viewtopic_link') && $row['user_images'] ? phpbb_gallery_url::append_sid('search', "user_id={$user_id}") : ''); get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$user_id]['rank_title'], $user_cache[$user_id]['rank_image'], $user_cache[$user_id]['rank_image_src']); if (!empty($row['user_allow_viewemail']) || $auth->acl_get('a_email')) { $user_cache[$user_id]['email'] = $config['board_email_form'] && $config['email_enable'] ? phpbb_gallery_url::append_sid('phpbb', 'memberlist', "mode=email&u={$user_id}") : ($config['board_hide_emails'] && !$auth->acl_get('a_email') ? '' : 'mailto:' . $row['user_email']); } else { $user_cache[$user_id]['email'] = ''; } if (!empty($row['user_icq'])) { $user_cache[$user_id]['icq'] = 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq']; $user_cache[$user_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" alt="" />'; } else { $user_cache[$user_id]['icq_status_img'] = ''; $user_cache[$user_id]['icq'] = ''; } if ($config['allow_birthdays'] && !empty($row['user_birthday'])) { list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday'])); if ($bday_year) { $now = getdate(time() + $user->timezone + $user->dst - date('Z')); $diff = $now['mon'] - $bday_month; if ($diff == 0) { $diff = $now['mday'] - $bday_day < 0 ? 1 : 0; } else { $diff = $diff < 0 ? 1 : 0; } $user_cache[$user_id]['age'] = (int) ($now['year'] - $bday_year - $diff); } } } }
public static function report($mode, $album_id, $album_data) { global $config, $db, $template, $user; $start = request_var('start', 0); $sort_key = request_var('sk', 'image_time'); $sort_dir = request_var('sd', 'DESC') == 'DESC' ? 'DESC' : 'ASC'; $images_per_page = $config['topics_per_page']; $count_images = 0; if (!in_array($sort_key, self::$allowed_sort_params)) { $sort_key = 'image_time'; } $m_status = ' AND i.image_status <> ' . phpbb_gallery_image::STATUS_UNAPPROVED; if (phpbb_gallery::$auth->acl_check('m_status', $album_id, $album_data['album_user_id'])) { $m_status = ''; } if ($mode == 'report_open') { $report_status = REPORT_OPEN; } else { $report_status = REPORT_LOCKED; } $sql_array = array('SELECT' => 'COUNT(i.image_id) images', 'FROM' => array(GALLERY_REPORTS_TABLE => 'r'), 'LEFT_JOIN' => array(array('FROM' => array(GALLERY_IMAGES_TABLE => 'i'), 'ON' => 'r.report_image_id = i.image_id')), 'WHERE' => "r.report_album_id = {$album_id} AND r.report_status = {$report_status} {$m_status}"); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $count_images = (int) $db->sql_fetchfield('images'); $db->sql_freeresult($result); $sql_array = array('SELECT' => 'r.*, u.username reporter_name, u.user_colour reporter_colour, m.username mod_username, m.user_colour mod_user_colour, i.*', 'FROM' => array(GALLERY_REPORTS_TABLE => 'r'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'r.reporter_id = u.user_id'), array('FROM' => array(USERS_TABLE => 'm'), 'ON' => 'r.report_manager = m.user_id'), array('FROM' => array(GALLERY_IMAGES_TABLE => 'i'), 'ON' => 'r.report_image_id = i.image_id')), 'WHERE' => "r.report_album_id = {$album_id} AND r.report_status = {$report_status} {$m_status}", 'ORDER_BY' => $sort_key . ' ' . $sort_dir); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $images_per_page, $start); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('image_row', array('THUMBNAIL' => generate_image_link('fake_thumbnail', phpbb_gallery_config::get('link_thumbnail'), $row['image_id'], $row['image_name'], $album_id), 'REPORTER' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'UPLOADER' => get_username_string('full', $row['image_user_id'], $row['image_username'], $row['image_user_colour']), 'REPORT_ID' => $row['report_id'], 'REPORT_MOD' => $row['report_manager'] ? get_username_string('full', $row['report_manager'], $row['mod_username'], $row['mod_user_colour']) : '', 'REPORT_TIME' => $user->format_date($row['report_time']), 'IMAGE_TIME' => $user->format_date($row['image_time']), 'IMAGE_NAME' => $row['image_name'], 'U_IMAGE' => phpbb_gallery_url::append_sid('image', "album_id={$album_id}&image_id=" . $row['image_id']), 'U_IMAGE_PAGE' => phpbb_gallery_url::append_sid('mcp', 'mode=report_details&album_id=' . $album_id . '&option_id=' . $row['report_id']))); } $db->sql_freeresult($result); if ($report_status == REPORT_LOCKED) { $desc_string = $user->lang('WAITING_REPORTED_DONE', $count_images); } else { $desc_string = $user->lang('WAITING_REPORTED_IMAGE', $count_images); } $template->assign_vars(array('S_SORT_DESC' => $sort_dir == 'DESC' ? true : false, 'S_SORT_KEY' => $sort_key, 'TITLE' => $user->lang['REPORTED_IMAGES'], 'DESCRIPTION' => $desc_string, 'PAGINATION' => generate_pagination(phpbb_gallery_url::append_sid('mcp', "mode={$mode}&album_id={$album_id}&sd={$sort_dir}&sk={$sort_key}"), $count_images, $images_per_page, $start), 'PAGE_NUMBER' => on_page($count_images, $images_per_page, $start), 'TOTAL_IMAGES' => $count_images == 1 ? $user->lang['VIEW_ALBUM_IMAGE'] : sprintf($user->lang['VIEW_ALBUM_IMAGES'], $count_images), 'S_REPORT_LIST' => true, 'S_REPORTER' => true, 'S_MARK' => true)); $template->assign_vars(array('REPORTED_IMG' => $user->img('icon_topic_reported', 'IMAGE_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'phpbb_gallery_image::STATUS_UNAPPROVED'), 'S_MCP_ACTION' => phpbb_gallery_url::append_sid('mcp', "mode={$mode}&album_id={$album_id}"), 'DISP_FAKE_THUMB' => phpbb_gallery_config::get('mini_thumbnail_disp'), 'FAKE_THUMB_SIZE' => phpbb_gallery_config::get('mini_thumbnail_size'))); }
/** * Generate link to image * * @param string $content what's in the link: image_name, thumbnail, fake_thumbnail, medium or lastimage_icon * @param string $mode where does the link leed to: highslide, lytebox, lytebox_slide_show, image_page, image, none * @param int $image_id * @param string $image_name * @param int $album_id * @param bool $is_gif we need to know whether we display a gif, so we can use a better medium-image * @param bool $count shall the image-link be counted as view? (Set to false from image_page.php to deny double increment) * @param string $additional_parameters additional parameters for the url, (starting with &) */ public static function generate_link($content, $mode, $image_id, $image_name, $album_id, $is_gif = false, $count = true, $additional_parameters = '') { global $phpEx, $user; $image_page_url = phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&image_id={$image_id}{$additional_parameters}"); $image_url = phpbb_gallery_url::append_sid('image', "album_id={$album_id}&image_id={$image_id}{$additional_parameters}" . (!$count ? '&view=no_count' : '')); $thumb_url = phpbb_gallery_url::append_sid('image', "mode=thumbnail&album_id={$album_id}&image_id={$image_id}{$additional_parameters}"); $medium_url = phpbb_gallery_url::append_sid('image', "mode=medium&album_id={$album_id}&image_id={$image_id}{$additional_parameters}"); switch ($content) { case 'image_name': $shorten_image_name = utf8_strlen(htmlspecialchars_decode($image_name)) > phpbb_gallery_config::get('shortnames') + 3 ? utf8_substr(htmlspecialchars_decode($image_name), 0, phpbb_gallery_config::get('shortnames')) . '...' : $image_name; $content = '<span style="font-weight: bold;">' . $shorten_image_name . '</span>'; break; case 'image_name_unbold': $shorten_image_name = utf8_strlen(htmlspecialchars_decode($image_name)) > phpbb_gallery_config::get('shortnames') + 3 ? utf8_substr(htmlspecialchars_decode($image_name), 0, phpbb_gallery_config::get('shortnames')) . '...' : $image_name; $content = $shorten_image_name; break; case 'thumbnail': $content = '<img src="{U_THUMBNAIL}" alt="{IMAGE_NAME}" title="{IMAGE_NAME}" />'; $content = str_replace(array('{U_THUMBNAIL}', '{IMAGE_NAME}'), array($thumb_url, $image_name), $content); break; case 'fake_thumbnail': $content = '<img src="{U_THUMBNAIL}" alt="{IMAGE_NAME}" title="{IMAGE_NAME}" style="max-width: {FAKE_THUMB_SIZE}px; max-height: {FAKE_THUMB_SIZE}px;" />'; $content = str_replace(array('{U_THUMBNAIL}', '{IMAGE_NAME}', '{FAKE_THUMB_SIZE}'), array($thumb_url, $image_name, phpbb_gallery_config::get('mini_thumbnail_size')), $content); break; case 'medium': $content = '<img src="{U_MEDIUM}" alt="{IMAGE_NAME}" title="{IMAGE_NAME}" />'; $content = str_replace(array('{U_MEDIUM}', '{IMAGE_NAME}'), array($medium_url, $image_name), $content); //cheat for animated/transparent gifs if ($is_gif) { $content = '<img src="{U_MEDIUM}" alt="{IMAGE_NAME}" title="{IMAGE_NAME}" style="max-width: {MEDIUM_WIDTH_SIZE}px; max-height: {MEDIUM_HEIGHT_SIZE}px;" />'; $content = str_replace(array('{U_MEDIUM}', '{IMAGE_NAME}', '{MEDIUM_HEIGHT_SIZE}', '{MEDIUM_WIDTH_SIZE}'), array($image_url, $image_name, phpbb_gallery_config::get('medium_height'), phpbb_gallery_config::get('medium_width')), $content); } break; case 'lastimage_icon': $content = $user->img('icon_topic_latest', 'VIEW_LATEST_IMAGE'); break; } switch ($mode) { case 'image_page': $url = $image_page_url; $tpl = '<a href="{IMAGE_URL}" title="{IMAGE_NAME}">{CONTENT}</a>'; break; case 'image_page_next': $url = $image_page_url; $tpl = '<a href="{IMAGE_URL}" title="{IMAGE_NAME}" class="right-box right">{CONTENT}</a>'; break; case 'image_page_prev': $url = $image_page_url; $tpl = '<a href="{IMAGE_URL}" title="{IMAGE_NAME}" class="left-box left">{CONTENT}</a>'; break; case 'image': $url = $image_url; $tpl = '<a href="{IMAGE_URL}" title="{IMAGE_NAME}">{CONTENT}</a>'; break; case 'none': $url = $image_page_url; $tpl = '{CONTENT}'; break; default: $url = $image_url; $tpl = phpbb_gallery_plugins::generate_image_link($mode); break; } return str_replace(array('{IMAGE_URL}', '{IMAGE_NAME}', '{CONTENT}'), array($url, $image_name, $content), $tpl); }
if (phpbb_gallery_misc::display_captcha('comment')) { // Get the captcha instance phpbb_gallery_url::_include('captcha/captcha_factory', 'phpbb'); $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_POST); $template->assign_vars(array('S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template())); } // Different link, when we rate and dont comment if (!$s_hide_comment_input) { $template->assign_var('S_COMMENT_ACTION', phpbb_gallery_url::append_sid('posting', "album_id={$album_id}&image_id={$image_id}&mode=comment&submode=add")); } } /** * Listing comment */ if (phpbb_gallery_config::get('allow_comments') && phpbb_gallery::$auth->acl_check('c_read', $album_id, $album_data['album_user_id']) && time() > $album_data['contest_start'] + $album_data['contest_end']) { $user->add_lang('viewtopic'); $start = request_var('start', 0); $sort_order = request_var('sort_order', 'ASC') == 'ASC' ? 'ASC' : 'DESC'; $template->assign_vars(array('S_ALLOWED_READ_COMMENTS' => true, 'IMAGE_COMMENTS' => $image_data['image_comments'], 'SORT_ASC' => $sort_order == 'ASC' ? true : false)); if ($image_data['image_comments'] > 0) { if (!class_exists('bbcode')) { phpbb_gallery_url::_include('bbcode', 'phpbb'); } $bbcode = new bbcode(); $comments = $users = $user_cache = array(); $users[] = $image_data['image_user_id']; $sql = 'SELECT * FROM ' . GALLERY_COMMENTS_TABLE . ' WHERE comment_image_id = ' . $image_id . ' ORDER BY comment_id ' . $sort_order;
function cleanup() { global $auth, $cache, $db, $template, $user; $delete = isset($_POST['delete']) ? true : false; $submit = isset($_POST['submit']) ? true : false; $missing_sources = request_var('source', array(0)); $missing_entries = request_var('entry', array(''), true); $missing_authors = request_var('author', array(0), true); $missing_comments = request_var('comment', array(0), true); $missing_personals = request_var('personal', array(0), true); $personals_bad = request_var('personal_bad', array(0), true); $s_hidden_fields = build_hidden_fields(array('source' => $missing_sources, 'entry' => $missing_entries, 'author' => $missing_authors, 'comment' => $missing_comments, 'personal' => $missing_personals, 'personal_bad' => $personals_bad)); if ($submit) { if ($missing_authors) { $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . ' SET image_user_id = ' . ANONYMOUS . ",\n\t\t\t\t\t\timage_user_colour = ''\n\t\t\t\t\tWHERE " . $db->sql_in_set('image_id', $missing_authors); $db->sql_query($sql); } if ($missing_comments) { $sql = 'UPDATE ' . GALLERY_COMMENTS_TABLE . ' SET comment_user_id = ' . ANONYMOUS . ",\n\t\t\t\t\t\tcomment_user_colour = ''\n\t\t\t\t\tWHERE " . $db->sql_in_set('comment_id', $missing_comments); $db->sql_query($sql); } trigger_error($user->lang['CLEAN_CHANGED'] . adm_back_link($this->u_action)); } if (confirm_box(true)) { $message = array(); if ($missing_sources) { $sql = 'DELETE FROM ' . GALLERY_COMMENTS_TABLE . ' WHERE ' . $db->sql_in_set('comment_image_id', $missing_sources); $db->sql_query($sql); $sql = 'DELETE FROM ' . GALLERY_REPORTS_TABLE . ' WHERE ' . $db->sql_in_set('report_image_id', $missing_sources); $db->sql_query($sql); $sql = 'DELETE FROM ' . GALLERY_FAVORITES_TABLE . ' WHERE ' . $db->sql_in_set('image_id', $missing_sources); $db->sql_query($sql); $sql = 'DELETE FROM ' . GALLERY_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('image_id', $missing_sources); $db->sql_query($sql); phpbb_gallery_image_base::delete_images($missing_sources); $message[] = $user->lang['CLEAN_SOURCES_DONE']; } if ($missing_entries) { foreach ($missing_entries as $missing_image) { @unlink(phpbb_gallery_url::path('upload') . utf8_decode($missing_image)); } $message[] = $user->lang['CLEAN_ENTRIES_DONE']; } if ($missing_authors) { $deleted_images = $filenames = array(); $sql = 'SELECT image_id, image_filename FROM ' . GALLERY_IMAGES_TABLE . ' WHERE ' . $db->sql_in_set('image_id', $missing_authors); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $filenames[(int) $row['image_id']] = $row['image_filename']; $deleted_images[] = $row['image_id']; } $db->sql_freeresult($result); // we have all image_ids in $deleted_images which are deleted // aswell as the album_ids in $deleted_albums // so now drop the comments, ratings, images and albums if ($deleted_images) { $sql = 'DELETE FROM ' . GALLERY_COMMENTS_TABLE . ' WHERE ' . $db->sql_in_set('comment_image_id', $deleted_images); $db->sql_query($sql); $sql = 'DELETE FROM ' . GALLERY_FAVORITES_TABLE . ' WHERE ' . $db->sql_in_set('image_id', $deleted_images); $db->sql_query($sql); $sql = 'DELETE FROM ' . GALLERY_REPORTS_TABLE . ' WHERE ' . $db->sql_in_set('report_image_id', $deleted_images); $db->sql_query($sql); $sql = 'DELETE FROM ' . GALLERY_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('image_id', $deleted_images); $db->sql_query($sql); phpbb_gallery_image_base::delete_images($deleted_images, $filenames); } $message[] = $user->lang['CLEAN_AUTHORS_DONE']; } if ($missing_comments) { $sql = 'DELETE FROM ' . GALLERY_COMMENTS_TABLE . ' WHERE ' . $db->sql_in_set('comment_id', $missing_comments); $db->sql_query($sql); $message[] = $user->lang['CLEAN_COMMENTS_DONE']; } if ($missing_personals || $personals_bad) { $delete_albums = array_merge($missing_personals, $personals_bad); $deleted_images = $deleted_albums = array(0); $user_image_count = array(); $sql = 'SELECT COUNT(album_user_id) personal_counter FROM ' . GALLERY_ALBUMS_TABLE . ' WHERE parent_id = 0 AND ' . $db->sql_in_set('album_user_id', $delete_albums); $result = $db->sql_query($sql); $remove_personal_counter = $db->sql_fetchfield('personal_counter'); $db->sql_freeresult($result); $sql = 'SELECT album_id FROM ' . GALLERY_ALBUMS_TABLE . ' WHERE ' . $db->sql_in_set('album_user_id', $delete_albums); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $deleted_albums[] = $row['album_id']; } $db->sql_freeresult($result); $sql = 'SELECT image_id, image_filename, image_user_id FROM ' . GALLERY_IMAGES_TABLE . ' WHERE ' . $db->sql_in_set('image_album_id', $deleted_albums); $result = $db->sql_query($sql); $filenames = array(); while ($row = $db->sql_fetchrow($result)) { $deleted_images[] = $row['image_id']; $filenames[(int) $row['image_id']] = $row['image_filename']; if (isset($user_image_count[$row['image_user_id']])) { $user_image_count[$row['image_user_id']]++; } else { $user_image_count[(int) $row['image_user_id']] = 1; } } $db->sql_freeresult($result); if ($deleted_images) { $sql = 'DELETE FROM ' . GALLERY_COMMENTS_TABLE . ' WHERE ' . $db->sql_in_set('comment_image_id', $deleted_images); $db->sql_query($sql); $sql = 'DELETE FROM ' . GALLERY_FAVORITES_TABLE . ' WHERE ' . $db->sql_in_set('image_id', $deleted_images); $db->sql_query($sql); $sql = 'DELETE FROM ' . GALLERY_REPORTS_TABLE . ' WHERE ' . $db->sql_in_set('report_image_id', $deleted_images); $db->sql_query($sql); $sql = 'DELETE FROM ' . GALLERY_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('image_id', $deleted_images); $db->sql_query($sql); phpbb_gallery_image_base::delete_images($deleted_images, $filenames); } $sql = 'DELETE FROM ' . GALLERY_ALBUMS_TABLE . ' WHERE ' . $db->sql_in_set('album_id', $deleted_albums); $db->sql_query($sql); phpbb_gallery_config::get('num_pegas', $remove_personal_counter); if (in_array(phpbb_gallery_config::get('newest_pega_album_id'), $deleted_albums)) { // Update the config for the statistic on the index if (phpbb_gallery_config::get('num_pegas') > 0) { $sql_array = array('SELECT' => 'a.album_id, u.user_id, u.username, u.user_colour', 'FROM' => array(GALLERY_ALBUMS_TABLE => 'a'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = a.album_user_id')), 'WHERE' => 'a.album_user_id <> ' . phpbb_gallery_album::PUBLIC_ALBUM . ' AND a.parent_id = 0', 'ORDER_BY' => 'a.album_id DESC'); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, 1); $newest_pgallery = $db->sql_fetchrow($result); $db->sql_freeresult($result); phpbb_gallery_config::set('newest_pega_user_id', $newest_pgallery['user_id']); phpbb_gallery_config::set('newest_pega_username', $newest_pgallery['username']); phpbb_gallery_config::set('newest_pega_user_colour', $newest_pgallery['user_colour']); phpbb_gallery_config::set('newest_pega_album_id', $newest_pgallery['album_id']); } else { phpbb_gallery_config::set('newest_pega_user_id', 0); phpbb_gallery_config::set('newest_pega_username', ''); phpbb_gallery_config::set('newest_pega_user_colour', ''); phpbb_gallery_config::set('newest_pega_album_id', 0); } } $user_ids = array(); foreach ($user_image_count as $user_id => $images) { $user_ids[] = (int) $user_id; phpbb_gallery_hookup::add_image($user_id, 0 - $images); $uploader = new phpbb_gallery_user($db, $user_id, false); $uploader->update_images(0 - $images); } phpbb_gallery_user_helpers::update_users($user_ids, array('personal_album_id' => 0)); if ($missing_personals) { $message[] = $user->lang['CLEAN_PERSONALS_DONE']; } if ($personals_bad) { $message[] = $user->lang['CLEAN_PERSONALS_BAD_DONE']; } } // Make sure the overall image & comment count is correct... $sql = 'SELECT COUNT(image_id) AS num_images, SUM(image_comments) AS num_comments FROM ' . GALLERY_IMAGES_TABLE . ' WHERE image_status <> ' . phpbb_gallery_image::STATUS_UNAPPROVED; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); phpbb_gallery_config::set('num_images', $row['num_images']); phpbb_gallery_config::set('num_comments', $row['num_comments']); $cache->destroy('sql', GALLERY_ALBUMS_TABLE); $cache->destroy('sql', GALLERY_COMMENTS_TABLE); $cache->destroy('sql', GALLERY_FAVORITES_TABLE); $cache->destroy('sql', GALLERY_IMAGES_TABLE); $cache->destroy('sql', GALLERY_RATES_TABLE); $cache->destroy('sql', GALLERY_REPORTS_TABLE); $cache->destroy('sql', GALLERY_WATCH_TABLE); $cache->destroy('_albums'); phpbb_gallery_auth::set_user_permissions('all', ''); trigger_error(implode('<br />', $message) . adm_back_link($this->u_action)); } else { if ($delete || isset($_POST['cancel'])) { if (isset($_POST['cancel'])) { trigger_error($user->lang['CLEAN_GALLERY_ABORT'] . adm_back_link($this->u_action), E_USER_WARNING); } else { $user->lang['CLEAN_GALLERY_CONFIRM'] = $user->lang['CONFIRM_CLEAN']; if ($missing_sources) { $user->lang['CLEAN_GALLERY_CONFIRM'] = $user->lang['CONFIRM_CLEAN_SOURCES'] . '<br />' . $user->lang['CLEAN_GALLERY_CONFIRM']; } if ($missing_entries) { $user->lang['CLEAN_GALLERY_CONFIRM'] = $user->lang['CONFIRM_CLEAN_ENTRIES'] . '<br />' . $user->lang['CLEAN_GALLERY_CONFIRM']; } if ($missing_authors) { $user->lang['CLEAN_GALLERY_CONFIRM'] = $user->lang['CONFIRM_CLEAN_AUTHORS'] . '<br />' . $user->lang['CLEAN_GALLERY_CONFIRM']; } if ($missing_comments) { $user->lang['CLEAN_GALLERY_CONFIRM'] = $user->lang['CONFIRM_CLEAN_COMMENTS'] . '<br />' . $user->lang['CLEAN_GALLERY_CONFIRM']; } if ($personals_bad || $missing_personals) { $sql = 'SELECT album_name, album_user_id FROM ' . GALLERY_ALBUMS_TABLE . ' WHERE ' . $db->sql_in_set('album_user_id', array_merge($missing_personals, $personals_bad)); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (in_array($row['album_user_id'], $personals_bad)) { $personals_bad_names[] = $row['album_name']; } else { $missing_personals_names[] = $row['album_name']; } } $db->sql_freeresult($result); } if ($missing_personals) { $user->lang['CLEAN_GALLERY_CONFIRM'] = sprintf($user->lang['CONFIRM_CLEAN_PERSONALS'], implode(', ', $missing_personals_names)) . '<br />' . $user->lang['CLEAN_GALLERY_CONFIRM']; } if ($personals_bad) { $user->lang['CLEAN_GALLERY_CONFIRM'] = sprintf($user->lang['CONFIRM_CLEAN_PERSONALS_BAD'], implode(', ', $personals_bad_names)) . '<br />' . $user->lang['CLEAN_GALLERY_CONFIRM']; } confirm_box(false, 'CLEAN_GALLERY', $s_hidden_fields); } } } $requested_source = array(); $sql_array = array('SELECT' => 'i.image_id, i.image_name, i.image_filemissing, i.image_filename, i.image_username, u.user_id', 'FROM' => array(GALLERY_IMAGES_TABLE => 'i'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = i.image_user_id'))); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if ($row['image_filemissing']) { $template->assign_block_vars('sourcerow', array('IMAGE_ID' => $row['image_id'], 'IMAGE_NAME' => $row['image_name'])); } if (!$row['user_id']) { $template->assign_block_vars('authorrow', array('IMAGE_ID' => $row['image_id'], 'AUTHOR_NAME' => $row['image_username'])); } $requested_source[] = $row['image_filename']; } $db->sql_freeresult($result); $check_mode = request_var('check_mode', ''); if ($check_mode == 'source') { $source_missing = array(); // Reset the status: a image might have been viewed without file but the file is back $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . ' SET image_filemissing = 0'; $db->sql_query($sql); $sql = 'SELECT image_id, image_filename, image_filemissing FROM ' . GALLERY_IMAGES_TABLE; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!file_exists(phpbb_gallery_url::path('upload') . $row['image_filename'])) { $source_missing[] = $row['image_id']; } } $db->sql_freeresult($result); if ($source_missing) { $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . "\n\t\t\t\t\tSET image_filemissing = 1\n\t\t\t\t\tWHERE " . $db->sql_in_set('image_id', $source_missing); $db->sql_query($sql); } } if ($check_mode == 'entry') { $directory = phpbb_gallery_url::path('upload'); $handle = opendir($directory); while ($file = readdir($handle)) { if (!is_dir($directory . $file) && (substr(strtolower($file), '-4') == '.png' || substr(strtolower($file), '-4') == '.gif' || substr(strtolower($file), '-4') == '.jpg') && !in_array($file, $requested_source)) { if (strpos($file, 'image_not_exist') !== false || strpos($file, 'not_authorised') !== false || strpos($file, 'no_hotlinking') !== false) { continue; } $template->assign_block_vars('entryrow', array('FILE_NAME' => utf8_encode($file))); } } closedir($handle); } $sql_array = array('SELECT' => 'c.comment_id, c.comment_image_id, c.comment_username, u.user_id', 'FROM' => array(GALLERY_COMMENTS_TABLE => 'c'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = c.comment_user_id'))); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (!$row['user_id']) { $template->assign_block_vars('commentrow', array('COMMENT_ID' => $row['comment_id'], 'IMAGE_ID' => $row['comment_image_id'], 'AUTHOR_NAME' => $row['comment_username'])); } } $db->sql_freeresult($result); $sql_array = array('SELECT' => 'a.album_id, a.album_user_id, a.album_name, u.user_id, a.album_images_real', 'FROM' => array(GALLERY_ALBUMS_TABLE => 'a'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = a.album_user_id')), 'WHERE' => 'a.album_user_id <> ' . phpbb_gallery_album::PUBLIC_ALBUM . ' AND a.parent_id = 0'); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $personalrow = $personal_bad_row = array(); while ($row = $db->sql_fetchrow($result)) { $album = array('user_id' => $row['album_user_id'], 'album_id' => $row['album_id'], 'album_name' => $row['album_name'], 'images' => $row['album_images_real']); if (!$row['user_id']) { $personalrow[$row['album_user_id']] = $album; } $personal_bad_row[$row['album_user_id']] = $album; } $db->sql_freeresult($result); $sql = 'SELECT ga.album_user_id, ga.album_images_real FROM ' . GALLERY_ALBUMS_TABLE . ' ga WHERE ga.album_user_id <> ' . phpbb_gallery_album::PUBLIC_ALBUM . ' AND ga.parent_id <> 0'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (isset($personalrow[$row['album_user_id']])) { $personalrow[$row['album_user_id']]['images'] = $personalrow[$row['album_user_id']]['images'] + $row['album_images_real']; } $personal_bad_row[$row['album_user_id']]['images'] = $personal_bad_row[$row['album_user_id']]['images'] + $row['album_images_real']; } $db->sql_freeresult($result); foreach ($personalrow as $key => $row) { $template->assign_block_vars('personalrow', array('USER_ID' => $row['user_id'], 'ALBUM_ID' => $row['album_id'], 'AUTHOR_NAME' => $row['album_name'])); } foreach ($personal_bad_row as $key => $row) { $template->assign_block_vars('personal_bad_row', array('USER_ID' => $row['user_id'], 'ALBUM_ID' => $row['album_id'], 'AUTHOR_NAME' => $row['album_name'], 'IMAGES' => $row['images'])); } $template->assign_vars(array('S_GALLERY_MANAGE_RESTS' => true, 'ACP_GALLERY_TITLE' => $user->lang['ACP_GALLERY_CLEANUP'], 'ACP_GALLERY_TITLE_EXPLAIN' => $user->lang['ACP_GALLERY_CLEANUP_EXPLAIN'], 'CHECK_SOURCE' => $this->u_action . '&check_mode=source', 'CHECK_ENTRY' => $this->u_action . '&check_mode=entry', 'S_FOUNDER' => $user->data['user_type'] == USER_FOUNDER ? true : false)); }
/** * Submit rating for an image. * * @param int $user_id * @param int $points * @param string $user_ip Can be empty, function falls back to $user->ip */ public function submit_rating($user_id = false, $points = false, $user_ip = false) { switch (self::MODE_SELECT) { //@todo: self::MODE_THUMB: //@todo: self::MODE_STARS: case self::MODE_SELECT: default: global $user; $user_id = $user_id ? $user_id : $user->data['user_id']; $points = $points ? $points : request_var('rating', 0); $points = max(1, min($points, phpbb_gallery_config::get('max_rating'))); break; } if ($user_id == ANONYMOUS || $this->get_user_rating($user_id)) { return false; } $this->insert_rating($user_id, $points, $user_ip); $this->recalc_image_rating($this->image_id); $this->user_rating[$user_id] = $points; }
function main($id, $mode) { global $db, $user, $auth, $cache, $template; phpbb_gallery::init(); $user->add_lang(array('mods/gallery_acp', 'mods/gallery')); $submit = isset($_POST['submit']) ? true : false; $form_key = 'acp_time'; add_form_key($form_key); switch ($mode) { case 'main': // Disable some Options if they can not be used if (!function_exists('exif_read_data')) { $this->display_vars['vars']['exif_data']['type'] = 'custom'; $this->display_vars['vars']['exif_data']['explain'] = true; $this->display_vars['vars']['exif_data']['method'] = 'disabled_boolean'; } if (!function_exists('imagerotate')) { $this->display_vars['vars']['allow_rotate_images']['type'] = 'custom'; $this->display_vars['vars']['allow_rotate_images']['explain'] = true; $this->display_vars['vars']['allow_rotate_images']['method'] = 'disabled_boolean'; } break; default: trigger_error('NO_MODE', E_USER_ERROR); break; } phpbb_gallery_config::load(true); $this->new_config = phpbb_gallery_config::get_array(); $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config; $error = array(); // We validate the complete config if whished validate_config_vars($this->display_vars['vars'], $cfg_array, $error); if ($submit && !check_form_key($form_key)) { $error[] = $user->lang['FORM_INVALID']; } // Do not write values if there is an error if (sizeof($error)) { $submit = false; } // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($this->display_vars['vars'] as $config_name => $null) { if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) { continue; } $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; if ($submit) { // Check for RRC-display-options if (isset($null['method']) && ($null['method'] == 'rrc_display' || $null['method'] == 'rrc_modes')) { // Changing the value, casted by int to not mess up anything $config_value = (int) array_sum(request_var($config_name, array(0))); } // Recalculate the Watermark-position if (isset($null['method']) && $null['method'] == 'watermark_position') { // Changing the value, casted by int to not mess up anything $config_value = request_var('watermark_position_x', 0) + request_var('watermark_position_y', 0); } if ($config_name == 'link_thumbnail') { $update_bbcode = request_var('update_bbcode', ''); // Update the BBCode if ($update_bbcode) { if (!class_exists('acp_bbcodes')) { phpbb_gallery_url::_include('acp/acp_bbcodes', 'phpbb'); } $acp_bbcodes = new acp_bbcodes(); $bbcode_match = '[album]{NUMBER}[/album]'; $bbcode_tpl = $this->bbcode_tpl($config_value); $sql_ary = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl); $sql_ary = array_merge($sql_ary, array('bbcode_match' => $bbcode_match, 'bbcode_tpl' => $bbcode_tpl, 'display_on_posting' => true, 'bbcode_helpline' => 'GALLERY_HELPLINE_ALBUM')); $sql = 'UPDATE ' . BBCODES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE bbcode_tag = '" . $sql_ary['bbcode_tag'] . "'"; $db->sql_query($sql); $cache->destroy('sql', BBCODES_TABLE); } } phpbb_gallery_config::set($config_name, $config_value); } } if ($submit) { $cache->destroy('sql', CONFIG_TABLE); trigger_error($user->lang['GALLERY_CONFIG_UPDATED'] . adm_back_link($this->u_action)); } $this->tpl_name = 'acp_board'; $this->page_title = $this->display_vars['title']; $template->assign_vars(array('L_TITLE' => $user->lang[$this->display_vars['title']], 'L_TITLE_EXPLAIN' => $user->lang[$this->display_vars['title'] . '_EXPLAIN'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action)); // Output relevant page foreach ($this->display_vars['vars'] as $config_key => $vars) { if (!is_array($vars) && strpos($config_key, 'legend') === false) { continue; } if (strpos($config_key, 'legend') !== false) { $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars)); continue; } $this->new_config[$config_key] = phpbb_gallery_config::get($config_key); $type = explode(':', $vars['type']); $l_explain = ''; if ($vars['explain']) { $l_explain = isset($user->lang[$vars['lang'] . '_EXP']) ? $user->lang[$vars['lang'] . '_EXP'] : ''; } $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars); if (empty($content)) { continue; } $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content)); unset($this->display_vars['vars'][$config_key]); } }
$template->assign_block_vars('imageblock.imagerow.noimage', array()); continue; } // Assign the image to the template-block phpbb_gallery_image::assign_block('imageblock.imagerow.image', $rowset[$j], $rowset[$j]['album_status'], phpbb_gallery_config::get('search_display'), $rowset[$j]['album_user_id']); } } } } else { $sql_array = array('SELECT' => 'c.*, i.*', 'FROM' => array(GALLERY_COMMENTS_TABLE => 'c'), 'LEFT_JOIN' => array(array('FROM' => array(GALLERY_IMAGES_TABLE => 'i'), 'ON' => 'c.comment_image_id = i.image_id')), 'WHERE' => $sql_where, 'ORDER_BY' => $sql_order); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); while ($commentrow = $db->sql_fetchrow($result)) { $image_id = $commentrow['image_id']; $album_id = $commentrow['image_album_id']; $template->assign_block_vars('commentrow', array('U_COMMENT' => phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&image_id={$image_id}") . '#' . $commentrow['comment_id'], 'COMMENT_ID' => $commentrow['comment_id'], 'TIME' => $user->format_date($commentrow['comment_time']), 'TEXT' => generate_text_for_display($commentrow['comment'], $commentrow['comment_uid'], $commentrow['comment_bitfield'], 7), 'U_DELETE' => phpbb_gallery::$auth->acl_check('m_comments', $album_id) || phpbb_gallery::$auth->acl_check('c_delete', $album_id) && $commentrow['comment_user_id'] == $user->data['user_id'] && $user->data['is_registered'] ? phpbb_gallery_url::append_sid('posting', "album_id={$album_id}&image_id={$image_id}&mode=comment&submode=delete&comment_id=" . $commentrow['comment_id']) : '', 'U_EDIT' => phpbb_gallery::$auth->acl_check('m_comments', $album_id) || phpbb_gallery::$auth->acl_check('c_edit', $album_id) && $commentrow['comment_user_id'] == $user->data['user_id'] && $user->data['is_registered'] ? phpbb_gallery_url::append_sid('posting', "album_id={$album_id}&image_id={$image_id}&mode=comment&submode=edit&comment_id=" . $commentrow['comment_id']) : '', 'U_INFO' => $auth->acl_get('a_') ? phpbb_gallery_url::append_sid('mcp', 'mode=whois&ip=' . $commentrow['comment_user_ip']) : '', 'UC_THUMBNAIL' => phpbb_gallery_image::generate_link('thumbnail', phpbb_gallery_config::get('link_thumbnail'), $commentrow['image_id'], $commentrow['image_name'], $commentrow['image_album_id']), 'UC_IMAGE_NAME' => phpbb_gallery_image::generate_link('image_name', phpbb_gallery_config::get('link_image_name'), $commentrow['image_id'], $commentrow['image_name'], $commentrow['image_album_id']), 'IMAGE_AUTHOR' => get_username_string('full', $commentrow['image_user_id'], $commentrow['image_username'], $commentrow['image_user_colour']), 'IMAGE_TIME' => $user->format_date($commentrow['image_time']), 'POST_AUTHOR_FULL' => get_username_string('full', $commentrow['comment_user_id'], $commentrow['comment_username'], $commentrow['comment_user_colour']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $commentrow['comment_user_id'], $commentrow['comment_username'], $commentrow['comment_user_colour']), 'POST_AUTHOR' => get_username_string('username', $commentrow['comment_user_id'], $commentrow['comment_username'], $commentrow['comment_user_colour']), 'U_POST_AUTHOR' => get_username_string('profile', $commentrow['comment_user_id'], $commentrow['comment_username'], $commentrow['comment_user_colour']))); } $db->sql_freeresult($result); $template->assign_vars(array('DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_COMMENT'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_COMMENT'), 'INFO_IMG' => $user->img('icon_post_info', 'IP'), 'MINI_POST_IMG' => $user->img('icon_post_target_unread', 'COMMENT'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'))); } } unset($rowset); page_header($l_search_title ? $l_search_title : $user->lang['SEARCH']); $template->set_filenames(array('body' => 'gallery/search_results.html')); make_jumpbox(phpbb_gallery_url::append_sid('phpbb', 'viewforum')); page_footer(); } $s_albums = phpbb_gallery_album::get_albumbox(false, false, false, 'i_view'); if (!$s_albums) { trigger_error('NO_SEARCH'); }
function manage_favorites() { global $db, $template, $user; $action = request_var('action', ''); $image_id_ary = request_var('image_id_ary', array(0)); if ($image_id_ary && $action == 'remove_favorite') { $sql = 'DELETE FROM ' . GALLERY_FAVORITES_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' AND ' . $db->sql_in_set('image_id', $image_id_ary); $db->sql_query($sql); $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . ' SET image_favorited = image_favorited - 1 WHERE ' . $db->sql_in_set('image_id', $image_id_ary); $db->sql_query($sql); meta_refresh(3, $this->u_action); trigger_error($user->lang['UNFAVORITED_IMAGES'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>')); } $start = request_var('start', 0); $images_per_page = phpbb_gallery_config::get('album_rows') * phpbb_gallery_config::get('album_columns'); $total_images = 0; $sql = 'SELECT COUNT(image_id) as images FROM ' . GALLERY_FAVORITES_TABLE . ' WHERE user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $total_images = (int) $db->sql_fetchfield('images'); $db->sql_freeresult($result); $sql_array = array('SELECT' => 'f.*, i.*, a.album_name', 'FROM' => array(GALLERY_FAVORITES_TABLE => 'f'), 'LEFT_JOIN' => array(array('FROM' => array(GALLERY_IMAGES_TABLE => 'i'), 'ON' => 'f.image_id = i.image_id'), array('FROM' => array(GALLERY_ALBUMS_TABLE => 'a'), 'ON' => 'a.album_id = i.image_album_id')), 'WHERE' => 'f.user_id = ' . $user->data['user_id']); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $images_per_page, $start); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('image_row', array('UC_IMAGE_NAME' => phpbb_gallery_image::generate_link('image_name', phpbb_gallery_config::get('link_image_name'), $row['image_id'], $row['image_name'], $row['image_album_id']), 'UC_FAKE_THUMBNAIL' => phpbb_gallery_image::generate_link('fake_thumbnail', phpbb_gallery_config::get('link_thumbnail'), $row['image_id'], $row['image_name'], $row['image_album_id']), 'UPLOADER' => $row['image_contest'] && !phpbb_gallery::$auth->acl_check('m_status', $row['image_album_id']) ? $user->lang['CONTEST_USERNAME'] : get_username_string('full', $row['image_user_id'], $row['image_username'], $row['image_user_colour']), 'IMAGE_TIME' => $user->format_date($row['image_time']), 'ALBUM_NAME' => $row['album_name'], 'IMAGE_ID' => $row['image_id'], 'U_VIEW_ALBUM' => phpbb_gallery_url::append_sid('album', 'album_id=' . $row['image_album_id']), 'U_IMAGE' => phpbb_gallery_url::append_sid('image_page', 'album_id=' . $row['image_album_id'] . '&image_id=' . $row['image_id']))); } $db->sql_freeresult($result); $template->assign_vars(array('S_MANAGE_FAVORITES' => true, 'S_UCP_ACTION' => $this->u_action, 'L_TITLE' => $user->lang['UCP_GALLERY_FAVORITES'], 'L_TITLE_EXPLAIN' => $user->lang['YOUR_FAVORITE_IMAGES'], 'PAGINATION' => generate_pagination(phpbb_gallery_url::append_sid('phpbb', 'ucp', 'i=gallery&mode=manage_favorites'), $total_images, $images_per_page, $start), 'PAGE_NUMBER' => on_page($total_images, $images_per_page, $start), 'TOTAL_IMAGES' => $total_images == 1 ? $user->lang['VIEW_ALBUM_IMAGE'] : sprintf($user->lang['VIEW_ALBUM_IMAGES'], $total_images), 'DISP_FAKE_THUMB' => true, 'FAKE_THUMB_SIZE' => phpbb_gallery_config::get('mini_thumbnail_size'))); }
/** * Set users default group * * borrowed from phpBB3 * @author: phpBB Group * @function: group_set_user_default */ public static function group_set_user_default($user_id_ary, $sql_ary) { global $db; if (empty($user_id_ary)) { return; } if (isset($sql_ary['user_colour'])) { // Update any cached colour information for these users $sql = 'UPDATE ' . GALLERY_ALBUMS_TABLE . " SET album_last_user_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\t\tWHERE " . $db->sql_in_set('album_last_user_id', $user_id_ary); $db->sql_query($sql); $sql = 'UPDATE ' . GALLERY_COMMENTS_TABLE . " SET comment_user_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\t\tWHERE " . $db->sql_in_set('comment_user_id', $user_id_ary); $db->sql_query($sql); $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . " SET image_user_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\t\tWHERE " . $db->sql_in_set('image_user_id', $user_id_ary); $db->sql_query($sql); if (in_array(phpbb_gallery_config::get('newest_pega_user_id'), $user_id_ary)) { phpbb_gallery_config::set('newest_pega_user_colour', $sql_ary['user_colour']); } } }
/** * User authorisation levels output * * @param string $mode Can only be 'album' so far. * @param int $album_id The current album the user is in. * @param int $album_status The albums status bit. * @param int $album_user_id The user-id of the album owner. Saves us a call to the cache if it is set. * * borrowed from phpBB3 * @author: phpBB Group * @function: gen_forum_auth_level */ public function gen_auth_level($mode, $album_id, $album_status, $album_user_id = -1) { global $template, $user; $locked = $album_status == ITEM_LOCKED && !gallery_acl_check('m_', $album_id, $album_user_id) ? true : false; $rules = array($this->acl_check('i_view', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_VIEW_CAN'] : $user->lang['ALBUM_VIEW_CANNOT'], $this->acl_check('i_upload', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_UPLOAD_CAN'] : $user->lang['ALBUM_UPLOAD_CANNOT'], $this->acl_check('i_edit', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_EDIT_CAN'] : $user->lang['ALBUM_EDIT_CANNOT'], $this->acl_check('i_delete', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_DELETE_CAN'] : $user->lang['ALBUM_DELETE_CANNOT']); if (phpbb_gallery_config::get('allow_comments') && $this->acl_check('c_read', $album_id, $album_user_id)) { $rules[] = $this->acl_check('c_post', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_COMMENT_CAN'] : $user->lang['ALBUM_COMMENT_CANNOT']; } if (phpbb_gallery_config::get('allow_rates')) { $rules[] = $this->acl_check('i_rate', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_RATE_CAN'] : $user->lang['ALBUM_RATE_CANNOT']; } foreach ($rules as $rule) { $template->assign_block_vars('rules', array('RULE' => $rule)); } return; }
if ($user->data['user_id'] != $comment_data['comment_user_id']) { add_log('gallery', $image_data['image_album_id'], $image_data['image_id'], 'LOG_GALLERY_COMMENT_DELETED', $image_data['image_name']); } $submit = true; $message = $user->lang['DELETED_COMMENT'] . '<br />'; } else { if (isset($_POST['cancel'])) { $message = $user->lang['DELETED_COMMENT_NOT'] . '<br />'; $submit = true; } else { confirm_box(false, 'DELETE_COMMENT2', $s_hidden_fields); } } break; } $template->assign_vars(array('ERROR' => $error, 'MESSAGE' => $comment, 'USERNAME' => $comment_username, 'REQ_USERNAME' => $comment_username_req, 'L_COMMENT_LENGTH' => sprintf($user->lang['COMMENT_LENGTH'], phpbb_gallery_config::get('comment_length')), 'IMAGE_RSZ_WIDTH' => phpbb_gallery_config::get('medium_width'), 'IMAGE_RSZ_HEIGHT' => phpbb_gallery_config::get('medium_height'), 'U_IMAGE' => $image_id ? phpbb_gallery_url::append_sid('image', "album_id={$album_id}&image_id={$image_id}") : '', 'U_VIEW_IMAGE' => $image_id ? phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&image_id={$image_id}") : '', 'IMAGE_NAME' => $image_id ? $image_data['image_name'] : '', 'S_ALBUM_ACTION' => $s_album_action, 'S_COMMENT' => true)); } break; } if ($submit) { if ($image_id) { $image_backlink = phpbb_gallery_url::append_sid('image_page', ($album_id ? "album_id={$album_id}&" : '') . "image_id={$image_id}"); $message .= '<br />' . sprintf($user->lang['CLICK_RETURN_IMAGE'], '<a href="' . $image_backlink . '">', '</a>'); } if ($album_id) { $album_backlink = phpbb_gallery_url::append_sid('album', "album_id={$album_id}"); $message .= '<br />' . sprintf($user->lang['CLICK_RETURN_ALBUM'], '<a href="' . $album_backlink . '">', '</a>'); } meta_refresh($slower_redirect ? 10 : 3, $image_id ? $image_backlink : $album_backlink); trigger_error($message); }
$image_tools->set_image_data(phpbb_gallery_url::path('upload') . $image_data['image_filename']); $image_tools->read_image(true); $image_size['file'] = $image_tools->image_size['file']; $image_size['width'] = $image_tools->image_size['width']; $image_size['height'] = $image_tools->image_size['height']; $image_tools->set_image_data($image_source); if ($image_size['width'] > $resize_width || $image_size['height'] > $resize_height) { $put_details = phpbb_gallery_config::get('thumbnail_infoline') && $mode == 'thumbnail' ? true : false; $image_tools->create_thumbnail($resize_width, $resize_height, $put_details, phpbb_gallery_constants::THUMBNAIL_INFO_HEIGHT, $image_size); } if (phpbb_gallery_config::get($mode . '_cache')) { $image_tools->write_image($image_source, $mode == 'thumbnail' ? phpbb_gallery_config::get('thumbnail_quality') : phpbb_gallery_config::get('jpg_quality'), false); if ($mode == 'thumbnail') { $image_data['filesize_cache'] = @filesize($image_source); $sql_ary = array('filesize_cache' => $image_data['filesize_cache']); } else { $image_data['filesize_medium'] = @filesize($image_source); $sql_ary = array('filesize_medium' => $image_data['filesize_medium']); } $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE ' . $db->sql_in_set('image_id', $image_id); $db->sql_query($sql); } } } // Watermark if (phpbb_gallery_config::get('watermark_enabled') && $album_data['album_watermark'] && !phpbb_gallery::$auth->acl_check('i_watermark', $album_id, $album_data['album_user_id']) && $possible_watermark) { $filesize_var = ''; $image_tools->watermark_image(phpbb_gallery_url::path('phpbb') . phpbb_gallery_config::get('watermark_source'), phpbb_gallery_config::get('watermark_position'), phpbb_gallery_config::get('watermark_height'), phpbb_gallery_config::get('watermark_width')); } $image_tools->send_image_to_browser();
$legend = implode(', ', $legend); } // Generate birthday list if required ... $birthday_list = ''; if ($config['allow_birthdays'] && phpbb_gallery_config::get('disp_birthdays')) { // Copied from phpbb::index.php $now = getdate(time() + $user->timezone + $user->dst - date('Z')); $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday FROM ' . USERS_TABLE . ' u LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\tWHERE (b.ban_id IS NULL\n\t\t\tOR b.ban_exclude = 1)\n\t\t\tAND u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'\n\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $birthday_list .= ($birthday_list != '' ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); if ($age = (int) substr($row['user_birthday'], -4)) { $birthday_list .= ' (' . ($now['year'] - $age) . ')'; } } $db->sql_freeresult($result); } $first_char = request_var('first_char', ''); $s_char_options = '<option value=""' . (!$first_char ? ' selected="selected"' : '') . '>' . $user->lang['ALL'] . '</option>'; // Loop the ASCII: a-z for ($i = 97; $i < 123; $i++) { $s_char_options .= '<option value="' . chr($i) . '"' . ($first_char == chr($i) ? ' selected="selected"' : '') . '>' . chr($i - 32) . '</option>'; } $s_char_options .= '<option value="other"' . ($first_char == 'other' ? ' selected="selected"' : '') . '>#</option>'; // Output page $template->assign_vars(array('TOTAL_IMAGES' => phpbb_gallery_config::get('disp_statistic') ? $user->lang('TOTAL_IMAGES_SPRINTF', $total_images) : '', 'TOTAL_COMMENTS' => phpbb_gallery_config::get('allow_comments') ? sprintf($user->lang[$l_total_comment_s], $total_comments) : '', 'TOTAL_PGALLERIES' => phpbb_gallery::$auth->acl_check('a_list', phpbb_gallery_auth::PERSONAL_ALBUM) ? sprintf($user->lang[$l_total_pgallery_s], $total_pgalleries) : '', 'NEWEST_PGALLERIES' => $total_pgalleries ? sprintf($user->lang['NEWEST_PGALLERY'], get_username_string('full', phpbb_gallery_config::get('newest_pega_user_id'), phpbb_gallery_config::get('newest_pega_username'), phpbb_gallery_config::get('newest_pega_user_colour'), '', phpbb_gallery_url::append_sid('album', 'album_id=' . phpbb_gallery_config::get('newest_pega_album_id')))) : '', 'S_DISP_LOGIN' => phpbb_gallery_config::get('disp_login'), 'S_DISP_WHOISONLINE' => phpbb_gallery_config::get('disp_whoisonline'), 'LEGEND' => $legend, 'BIRTHDAY_LIST' => $birthday_list, 'S_LOGIN_ACTION' => phpbb_gallery_url::append_sid('phpbb', 'ucp', 'mode=login&redirect=' . urlencode(phpbb_gallery_url::path('relative') . "index.{$phpEx}" . ($mode == 'personal' ? '?mode=personal' : ''))), 'S_DISPLAY_BIRTHDAY_LIST' => phpbb_gallery_config::get('disp_birthdays') ? true : false, 'U_YOUR_PERSONAL_GALLERY' => phpbb_gallery::$auth->acl_check('i_upload', phpbb_gallery_auth::OWN_ALBUM) ? phpbb_gallery::$user->get_data('personal_album_id') ? phpbb_gallery_url::append_sid('album', 'album_id=' . phpbb_gallery::$user->get_data('personal_album_id')) : phpbb_gallery_url::append_sid('phpbb', 'ucp', 'i=gallery&mode=manage_albums') : '', 'U_USERS_PERSONAL_GALLERIES' => phpbb_gallery::$auth->acl_check('a_list', phpbb_gallery_auth::PERSONAL_ALBUM) ? phpbb_gallery_url::append_sid('index', 'mode=personal') : '', 'S_USERS_PERSONAL_GALLERIES' => !phpbb_gallery_config::get('pegas_index_album') && phpbb_gallery::$auth->acl_check('a_list', phpbb_gallery_auth::PERSONAL_ALBUM) ? true : false, 'S_CHAR_OPTIONS' => $s_char_options, 'U_MARK_ALBUMS' => $user->data['is_registered'] ? phpbb_gallery_url::append_sid('index', 'hash=' . generate_link_hash('global') . '&mark=albums') : '', 'U_G_SEARCH_COMMENTED' => phpbb_gallery_config::get('allow_comments') ? phpbb_gallery_url::append_sid('search', 'search_id=commented') : '', 'U_G_SEARCH_CONTESTS' => phpbb_gallery_config::get('allow_rates') && phpbb_gallery_config::get('contests_ended') ? phpbb_gallery_url::append_sid('search', 'search_id=contests') : '', 'U_G_SEARCH_RANDOM' => phpbb_gallery_url::append_sid('search', 'search_id=random'), 'U_G_SEARCH_RECENT' => phpbb_gallery_url::append_sid('search', 'search_id=recent'), 'U_G_SEARCH_SELF' => phpbb_gallery_url::append_sid('search', 'search_id=egosearch'), 'U_G_SEARCH_TOPRATED' => phpbb_gallery_config::get('allow_rates') ? phpbb_gallery_url::append_sid('search', 'search_id=toprated') : '')); page_header($user->lang['GALLERY'] . ($mode == 'personal' ? ' - ' . $user->lang['PERSONAL_ALBUMS'] : '')); $template->set_filenames(array('body' => 'gallery/index_body.html')); page_footer();
/** * Provide an opportunity to customise some advanced settings during the install * in case it is necessary for them to be set to access later */ function obtain_advanced_settings($mode, $sub) { global $user, $template, $phpbb_root_path, $phpEx, $db; $create = request_var('create', ''); if ($create) { // Add modules $choosen_acp_module = request_var('acp_module', 0); $choosen_ucp_module = request_var('ucp_module', 0); $choosen_log_module = request_var('log_module', 0); switch (phpbb_gallery_config::get('version')) { case '0.1.2': case '0.1.3': case '0.2.0': case '0.2.1': case '0.2.2': case '0.2.3': case '0.3.0': case '0.3.1': case '0.3.2-RC1': case '0.3.2-RC2': case '0.4.0-RC1': case '0.4.0-RC2': case '0.4.0-RC3': case '0.4.0': break; case '0.4.1': // Logs $gallery_log = array('module_basename' => 'logs', 'module_enabled' => 1, 'module_display' => 1, 'parent_id' => $choosen_log_module, 'module_class' => 'acp', 'module_langname' => 'ACP_GALLERY_LOGS', 'module_mode' => 'gallery', 'module_auth' => 'acl_a_viewlogs'); add_module($gallery_log); case '0.5.0': case '0.5.1': case '0.5.2': case '0.5.3': case '0.5.4': case '1.0.0-dev': case '1.0.0-RC1': case '1.0.0-RC2': case '1.0.0': case '1.0.1-dev': case '1.0.1': case '1.0.2-dev': case '1.0.2-RC1': // Add album-BBCode add_bbcode('album'); case '1.0.2': case '1.0.3-RC1': case '1.0.3-RC2': case '1.0.3': case '1.0.4': case '1.0.5-RC1': trigger_error('VERSION_NOT_SUPPORTED', E_USER_ERROR); case '1.0.5': break; } $s_hidden_fields = ''; $url = append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=final"); } else { $data = array('acp_module' => phpbb_gallery_constants::MODULE_DEFAULT_ACP, 'log_module' => phpbb_gallery_constants::MODULE_DEFAULT_LOG, 'ucp_module' => phpbb_gallery_constants::MODULE_DEFAULT_UCP); $modules = $this->gallery_config_options; switch (phpbb_gallery_config::get('version')) { case '1.0.5-RC1': case '1.0.5': case '1.0.4': case '1.0.3': case '1.0.3-RC2': case '1.0.3-RC1': case '1.0.2': case '1.0.2-RC1': case '1.0.2-dev': case '1.0.1': $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => '', 'LEGEND_EXPLAIN' => $user->lang['BBCODES_NEEDS_REPARSE'])); case '1.0.1-dev': case '1.0.0': case '1.0.0-RC2': case '1.0.0-RC1': case '1.0.0-dev': case '0.5.4': case '0.5.3': case '0.5.2': case '0.5.1': case '0.5.0': // needs to be moved before the first unset. unset($modules['legend1']); unset($modules['log_module']); case '0.4.1': unset($modules['acp_module']); unset($modules['ucp_module']); // We need to build all modules before this version break; } foreach ($modules as $config_key => $vars) { if (!is_array($vars) && strpos($config_key, 'legend') === false) { continue; } if (strpos($config_key, 'legend') !== false) { $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => $user->lang[$vars])); continue; } $options = isset($vars['options']) ? $vars['options'] : ''; $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => $user->lang[$vars['lang']], 'S_EXPLAIN' => $vars['explain'], 'S_LEGEND' => false, 'TITLE_EXPLAIN' => $vars['explain'] ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '', 'CONTENT' => $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options))); } $s_hidden_fields = '<input type="hidden" name="create" value="true" />'; $url = append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=advanced"); } $submit = $user->lang['NEXT_STEP']; $template->assign_vars(array('TITLE' => $user->lang['STAGE_ADVANCED'], 'BODY' => $user->lang['STAGE_ADVANCED_EXPLAIN'], 'L_SUBMIT' => $submit, 'S_HIDDEN' => $s_hidden_fields, 'U_ACTION' => $url)); }
/** * Display albums * * borrowed from phpBB3 * @author: phpBB Group * @function: display_forums */ public static function display_albums($root_data = '', $display_moderators = true, $return_moderators = false) { global $auth, $db, $template, $user; $album_rows = $subalbums = $album_ids = $album_ids_moderator = $album_moderators = $active_album_ary = array(); $parent_id = $visible_albums = 0; $sql_from = ''; $mode = request_var('mode', ''); // Mark albums read? $mark_read = request_var('mark', ''); if ($mark_read == 'all') { $mark_read = ''; } if (!$root_data) { if ($mark_read == 'albums') { $mark_read = 'all'; } $root_data = array('album_id' => self::PUBLIC_ALBUM); $sql_where = 'a.album_user_id = ' . self::PUBLIC_ALBUM; } else { if ($root_data == 'personal') { if ($mark_read == 'albums') { $mark_read = 'all'; } $root_data = array('album_id' => 0); //@todo: I think this is incorrect!? $sql_where = 'a.album_user_id > ' . self::PUBLIC_ALBUM; $num_pegas = phpbb_gallery_config::get('num_pegas'); $first_char = request_var('first_char', ''); if ($first_char == 'other') { // Loop the ASCII: a-z for ($i = 97; $i < 123; $i++) { $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->any_char); } } else { if ($first_char) { $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->any_char); } } if ($first_char) { // We do not view all personal albums, so we need to recount, for the pagination. $sql_array = array('SELECT' => 'count(a.album_id) as pgalleries', 'FROM' => array(GALLERY_ALBUMS_TABLE => 'a'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = a.album_user_id')), 'WHERE' => 'a.parent_id = 0 AND ' . $sql_where); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $num_pegas = $db->sql_fetchfield('pgalleries'); $db->sql_freeresult($result); } $mode_personal = true; $start = request_var('start', 0); $limit = phpbb_gallery_config::get('pegas_per_page'); $template->assign_vars(array('PAGINATION' => generate_pagination(phpbb_gallery_url::append_sid('index', 'mode=' . $mode . ($first_char ? '&first_char=' . $first_char : '')), $num_pegas, $limit, $start), 'TOTAL_PGALLERIES_SHORT' => sprintf($user->lang['TOTAL_PGALLERIES_SHORT'], $num_pegas), 'PAGE_NUMBER' => on_page($num_pegas, $limit, $start))); } else { $sql_where = 'a.left_id > ' . $root_data['left_id'] . ' AND a.left_id < ' . $root_data['right_id'] . ' AND a.album_user_id = ' . $root_data['album_user_id']; } } $sql_array = array('SELECT' => 'a.*, at.mark_time', 'FROM' => array(GALLERY_ALBUMS_TABLE => 'a'), 'LEFT_JOIN' => array(array('FROM' => array(GALLERY_ATRACK_TABLE => 'at'), 'ON' => 'at.user_id = ' . $user->data['user_id'] . ' AND a.album_id = at.album_id')), 'ORDER_BY' => 'a.album_user_id, a.left_id'); if (isset($mode_personal)) { $sql_array['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = a.album_user_id'); $sql_array['ORDER_BY'] = 'u.username_clean, a.left_id'; } $sql_array['LEFT_JOIN'][] = array('FROM' => array(GALLERY_CONTESTS_TABLE => 'c'), 'ON' => 'c.contest_album_id = a.album_id'); $sql_array['SELECT'] = $sql_array['SELECT'] . ', c.contest_marked'; $sql = $db->sql_build_query('SELECT', array('SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'WHERE' => $sql_where, 'ORDER_BY' => $sql_array['ORDER_BY'])); $result = $db->sql_query($sql); $album_tracking_info = array(); $branch_root_id = $root_data['album_id']; while ($row = $db->sql_fetchrow($result)) { $album_id = $row['album_id']; // Mark albums read? if ($mark_read == 'albums' || $mark_read == 'all') { if (phpbb_gallery::$auth->acl_check('a_list', $album_id, $row['album_user_id'])) { $album_ids[] = $album_id; continue; } } // Category with no members if (!$row['album_type'] && $row['left_id'] + 1 == $row['right_id']) { continue; } // Skip branch if (isset($right_id)) { if ($row['left_id'] < $right_id) { continue; } unset($right_id); } if (!phpbb_gallery::$auth->acl_check('a_list', $album_id, $row['album_user_id'])) { // if the user does not have permissions to list this album, skip everything until next branch $right_id = $row['right_id']; continue; } $album_tracking_info[$album_id] = !empty($row['mark_time']) ? $row['mark_time'] : phpbb_gallery::$user->data('user_lastmark'); $row['album_images'] = $row['album_images']; $row['album_images_real'] = $row['album_images_real']; if ($row['parent_id'] == $root_data['album_id'] || $row['parent_id'] == $branch_root_id) { if ($row['album_type']) { $album_ids_moderator[] = (int) $album_id; } // Direct child of current branch $parent_id = $album_id; $album_rows[$album_id] = $row; if (!$row['album_type'] && $row['parent_id'] == $root_data['album_id']) { $branch_root_id = $album_id; } $album_rows[$parent_id]['album_id_last_image'] = $row['album_id']; $album_rows[$parent_id]['album_type_last_image'] = $row['album_type']; $album_rows[$parent_id]['album_contest_marked'] = $row['contest_marked']; $album_rows[$parent_id]['orig_album_last_image_time'] = $row['album_last_image_time']; } else { if ($row['album_type']) { $subalbums[$parent_id][$album_id]['display'] = $row['display_on_index'] ? true : false; $subalbums[$parent_id][$album_id]['name'] = $row['album_name']; $subalbums[$parent_id][$album_id]['orig_album_last_image_time'] = $row['album_last_image_time']; $subalbums[$parent_id][$album_id]['children'] = array(); if (isset($subalbums[$parent_id][$row['parent_id']]) && !$row['display_on_index']) { $subalbums[$parent_id][$row['parent_id']]['children'][] = $album_id; } $album_rows[$parent_id]['album_images'] += $row['album_images']; $album_rows[$parent_id]['album_images_real'] += $row['album_images_real']; if ($row['album_last_image_time'] > $album_rows[$parent_id]['album_last_image_time']) { $album_rows[$parent_id]['album_last_image_id'] = $row['album_last_image_id']; $album_rows[$parent_id]['album_last_image_name'] = $row['album_last_image_name']; $album_rows[$parent_id]['album_last_image_time'] = $row['album_last_image_time']; $album_rows[$parent_id]['album_last_user_id'] = $row['album_last_user_id']; $album_rows[$parent_id]['album_last_username'] = $row['album_last_username']; $album_rows[$parent_id]['album_last_user_colour'] = $row['album_last_user_colour']; $album_rows[$parent_id]['album_type_last_image'] = $row['album_type']; $album_rows[$parent_id]['album_contest_marked'] = $row['contest_marked']; $album_rows[$parent_id]['album_id_last_image'] = $album_id; } } } } $db->sql_freeresult($result); // Handle marking albums if ($mark_read == 'albums' || $mark_read == 'all') { $redirect = build_url('mark', 'hash'); $token = request_var('hash', ''); if (check_link_hash($token, 'global')) { if ($mark_read == 'all') { phpbb_gallery_misc::markread('all'); $message = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>'); } else { phpbb_gallery_misc::markread('albums', $album_ids); $message = sprintf($user->lang['RETURN_ALBUM'], '<a href="' . $redirect . '">', '</a>'); } meta_refresh(3, $redirect); trigger_error($user->lang['ALBUMS_MARKED'] . '<br /><br />' . $message); } else { $message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'); meta_refresh(3, $redirect); trigger_error($message); } } // Grab moderators ... if necessary if ($display_moderators) { if ($return_moderators) { $album_ids_moderator[] = $root_data['album_id']; } self::get_moderators($album_moderators, $album_ids_moderator); } // Used to tell whatever we have to create a dummy category or not. $last_catless = true; foreach ($album_rows as $row) { // Empty category if ($row['parent_id'] == $root_data['album_id'] && $row['album_type'] == self::TYPE_CAT) { $template->assign_block_vars('albumrow', array('S_IS_CAT' => true, 'ALBUM_ID' => $row['album_id'], 'ALBUM_NAME' => $row['album_name'], 'ALBUM_DESC' => generate_text_for_display($row['album_desc'], $row['album_desc_uid'], $row['album_desc_bitfield'], $row['album_desc_options']), 'ALBUM_FOLDER_IMG' => '', 'ALBUM_FOLDER_IMG_SRC' => '', 'ALBUM_IMAGE' => $row['album_image'] ? phpbb_gallery_url::path('phpbb') . $row['album_image'] : '', 'U_VIEWALBUM' => phpbb_gallery_url::append_sid('album', 'album_id=' . $row['album_id']))); continue; } $visible_albums++; if ($mode == 'personal' && ($visible_albums <= $start || $visible_albums > $start + $limit)) { continue; } $album_id = $row['album_id']; $album_unread = isset($album_tracking_info[$album_id]) && $row['orig_album_last_image_time'] > $album_tracking_info[$album_id] && $user->data['user_id'] != ANONYMOUS ? true : false; $folder_image = $folder_alt = $l_subalbums = ''; $subalbums_list = array(); // Generate list of subalbums if we need to if (isset($subalbums[$album_id])) { foreach ($subalbums[$album_id] as $subalbum_id => $subalbum_row) { $subalbum_unread = isset($album_tracking_info[$subalbum_id]) && $subalbum_row['orig_album_last_image_time'] > $album_tracking_info[$subalbum_id] && $user->data['user_id'] != ANONYMOUS ? true : false; if (!$subalbum_unread && !empty($subalbum_row['children']) && $user->data['user_id'] != ANONYMOUS) { foreach ($subalbum_row['children'] as $child_id) { if (isset($album_tracking_info[$child_id]) && $subalbums[$album_id][$child_id]['orig_album_last_image_time'] > $album_tracking_info[$child_id]) { // Once we found an unread child album, we can drop out of this loop $subalbum_unread = true; break; } } } if ($subalbum_row['display'] && $subalbum_row['name']) { $subalbums_list[] = array('link' => phpbb_gallery_url::append_sid('album', 'album_id=' . $subalbum_id), 'name' => $subalbum_row['name'], 'unread' => $subalbum_unread); } else { unset($subalbums[$album_id][$subalbum_id]); } if ($subalbum_unread) { $album_unread = true; } } $l_subalbums = sizeof($subalbums[$album_id]) == 1 ? $user->lang['SUBALBUM'] . ': ' : $user->lang['SUBALBUMS'] . ': '; $folder_image = $album_unread ? 'forum_unread_subforum' : 'forum_read_subforum'; } else { $folder_alt = $album_unread ? 'NEW_IMAGES' : 'NO_NEW_IMAGES'; $folder_image = $album_unread ? 'forum_unread' : 'forum_read'; } if ($row['album_status'] == self::STATUS_LOCKED) { $folder_image = $album_unread ? 'forum_unread_locked' : 'forum_read_locked'; $folder_alt = 'ALBUM_LOCKED'; } // Create last post link information, if appropriate if ($row['album_last_image_id']) { $lastimage_name = $row['album_last_image_name']; $lastimage_time = $user->format_date($row['album_last_image_time']); $lastimage_image_id = $row['album_last_image_id']; $lastimage_album_id = $row['album_id_last_image']; $lastimage_album_type = $row['album_type_last_image']; $lastimage_contest_marked = $row['album_contest_marked']; $lastimage_uc_fake_thumbnail = phpbb_gallery_image::generate_link('fake_thumbnail', phpbb_gallery_config::get('link_thumbnail'), $lastimage_image_id, $lastimage_name, $lastimage_album_id); $lastimage_uc_thumbnail = phpbb_gallery_image::generate_link('thumbnail', phpbb_gallery_config::get('link_thumbnail'), $lastimage_image_id, $lastimage_name, $lastimage_album_id); $lastimage_uc_name = phpbb_gallery_image::generate_link('image_name', phpbb_gallery_config::get('link_image_name'), $lastimage_image_id, $lastimage_name, $lastimage_album_id); $lastimage_uc_icon = phpbb_gallery_image::generate_link('lastimage_icon', phpbb_gallery_config::get('link_image_icon'), $lastimage_image_id, $lastimage_name, $lastimage_album_id); } else { $lastimage_time = $lastimage_image_id = $lastimage_album_id = $lastimage_album_type = 0; $lastimage_name = $lastimage_uc_fake_thumbnail = $lastimage_uc_thumbnail = $lastimage_uc_name = $lastimage_uc_icon = ''; } // Output moderator listing ... if applicable $l_moderator = $moderators_list = ''; if ($display_moderators && !empty($album_moderators[$album_id])) { $l_moderator = sizeof($album_moderators[$album_id]) == 1 ? $user->lang['MODERATOR'] : $user->lang['MODERATORS']; $moderators_list = implode(', ', $album_moderators[$album_id]); } $s_subalbums_list = array(); foreach ($subalbums_list as $subalbum) { $s_subalbums_list[] = '<a href="' . $subalbum['link'] . '" class="subforum ' . ($subalbum['unread'] ? 'unread' : 'read') . '" title="' . ($subalbum['unread'] ? $user->lang['NEW_IMAGES'] : $user->lang['NO_NEW_IMAGES']) . '">' . $subalbum['name'] . '</a>'; } $s_subalbums_list = (string) implode(', ', $s_subalbums_list); $catless = $row['parent_id'] == $root_data['album_id'] ? true : false; $template->assign_block_vars('albumrow', array('S_IS_CAT' => false, 'S_NO_CAT' => $catless && !$last_catless, 'S_LOCKED_ALBUM' => $row['album_status'] == self::STATUS_LOCKED ? true : false, 'S_LIST_SUBALBUMS' => $row['display_subalbum_list'] ? true : false, 'S_SUBALBUMS' => sizeof($subalbums_list) ? true : false, 'ALBUM_ID' => $row['album_id'], 'ALBUM_NAME' => $row['album_name'], 'ALBUM_DESC' => generate_text_for_display($row['album_desc'], $row['album_desc_uid'], $row['album_desc_bitfield'], $row['album_desc_options']), 'IMAGES' => $row['album_images'], 'UNAPPROVED_IMAGES' => phpbb_gallery::$auth->acl_check('m_status', $album_id, $row['album_user_id']) ? $row['album_images_real'] - $row['album_images'] : 0, 'ALBUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'ALBUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'), 'ALBUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '', 'ALBUM_IMAGE' => $row['album_image'] ? phpbb_gallery_url::path('phpbb') . $row['album_image'] : '', 'LAST_IMAGE_TIME' => $lastimage_time, 'LAST_USER_FULL' => $lastimage_album_type == self::TYPE_CONTEST && ($lastimage_contest_marked && !phpbb_gallery::$auth->acl_check('m_status', $album_id, $row['album_user_id'])) ? $user->lang['CONTEST_USERNAME'] : get_username_string('full', $row['album_last_user_id'], $row['album_last_username'], $row['album_last_user_colour']), 'UC_THUMBNAIL' => phpbb_gallery_config::get('mini_thumbnail_disp') ? $lastimage_uc_thumbnail : '', 'UC_FAKE_THUMBNAIL' => phpbb_gallery_config::get('mini_thumbnail_disp') ? $lastimage_uc_fake_thumbnail : '', 'UC_IMAGE_NAME' => $lastimage_uc_name, 'UC_LASTIMAGE_ICON' => $lastimage_uc_icon, 'ALBUM_COLOUR' => get_username_string('colour', $row['album_last_user_id'], $row['album_last_username'], $row['album_last_user_colour']), 'MODERATORS' => $moderators_list, 'SUBALBUMS' => $s_subalbums_list, 'L_SUBALBUM_STR' => $l_subalbums, 'L_ALBUM_FOLDER_ALT' => $folder_alt, 'L_MODERATOR_STR' => $l_moderator, 'U_VIEWALBUM' => phpbb_gallery_url::append_sid('album', 'album_id=' . $row['album_id']))); // Assign subforums loop for style authors foreach ($subalbums_list as $subalbum) { $template->assign_block_vars('albumrow.subalbum', array('U_SUBALBUM' => $subalbum['link'], 'SUBALBUM_NAME' => $subalbum['name'], 'S_UNREAD' => $subalbum['unread'])); } $last_catless = $catless; } $template->assign_vars(array('U_MARK_ALBUMS' => $user->data['is_registered'] ? phpbb_gallery_url::append_sid('album', 'hash=' . generate_link_hash('global') . '&album_id=' . $root_data['album_id'] . '&mark=albums') : '', 'S_HAS_SUBALBUM' => $visible_albums ? true : false, 'L_SUBFORUM' => $visible_albums == 1 ? $user->lang['SUBALBUM'] : $user->lang['SUBALBUMS'], 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'FAKE_THUMB_SIZE' => phpbb_gallery_config::get('mini_thumbnail_size'))); if ($return_moderators) { return array($active_album_ary, $album_moderators); } return array($active_album_ary, array()); }
/** * Query the comments and put them into the template. */ private function display_comments() { if (empty($this->auth_comments)) { return; } global $auth, $db, $template, $user; $user->add_lang('viewtopic'); $sql_array = array('SELECT' => 'c.*, i.*', 'FROM' => array(GALLERY_COMMENTS_TABLE => 'c'), 'LEFT_JOIN' => array(array('FROM' => array(GALLERY_IMAGES_TABLE => 'i'), 'ON' => 'c.comment_image_id = i.image_id')), 'WHERE' => $this->sql_where_auth . ' AND ' . $db->sql_in_set('i.image_album_id', $this->auth_comments, false, true), 'ORDER_BY' => 'c.comment_id DESC'); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $this->num_comments); while ($row = $db->sql_fetchrow($result)) { $image_id = (int) $row['image_id']; $album_id = (int) $row['image_album_id']; $template->assign_block_vars($this->template_block_comments, array('U_COMMENT' => phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&image_id={$image_id}") . '#comment_' . $row['comment_id'], 'COMMENT_ID' => $row['comment_id'], 'TIME' => $user->format_date($row['comment_time']), 'TEXT' => generate_text_for_display($row['comment'], $row['comment_uid'], $row['comment_bitfield'], 7), 'U_DELETE' => phpbb_gallery::$auth->acl_check('m_comments', $album_id) || phpbb_gallery::$auth->acl_check('c_delete', $album_id) && $row['comment_user_id'] == $user->data['user_id'] && $user->data['is_registered'] ? phpbb_gallery_url::append_sid('comment', "album_id={$album_id}&image_id={$image_id}&mode=delete&comment_id=" . $row['comment_id']) : '', 'U_QUOTE' => phpbb_gallery::$auth->acl_check('c_post', $album_id) ? phpbb_gallery_url::append_sid('comment', "album_id={$album_id}&image_id={$image_id}&mode=add&comment_id=" . $row['comment_id']) : '', 'U_EDIT' => phpbb_gallery::$auth->acl_check('m_comments', $album_id) || phpbb_gallery::$auth->acl_check('c_edit', $album_id) && $row['comment_user_id'] == $user->data['user_id'] && $user->data['is_registered'] ? phpbb_gallery_url::append_sid('comment', "album_id={$album_id}&image_id={$image_id}&mode=edit&comment_id=" . $row['comment_id']) : '', 'U_INFO' => $auth->acl_get('a_') ? phpbb_gallery_url::append_sid('mcp', 'mode=whois&ip=' . $row['comment_user_ip']) : '', 'UC_THUMBNAIL' => phpbb_gallery_image::generate_link('thumbnail', phpbb_gallery_config::get('link_thumbnail'), $row['image_id'], $row['image_name'], $row['image_album_id']), 'UC_IMAGE_NAME' => phpbb_gallery_image::generate_link('image_name', phpbb_gallery_config::get('link_image_name'), $row['image_id'], $row['image_name'], $row['image_album_id']), 'IMAGE_AUTHOR' => get_username_string('full', $row['image_user_id'], $row['image_username'], $row['image_user_colour']), 'IMAGE_TIME' => $user->format_date($row['image_time']), 'POST_AUTHOR_FULL' => get_username_string('full', $row['comment_user_id'], $row['comment_username'], $row['comment_user_colour']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['comment_user_id'], $row['comment_username'], $row['comment_user_colour']), 'POST_AUTHOR' => get_username_string('username', $row['comment_user_id'], $row['comment_username'], $row['comment_user_colour']), 'U_POST_AUTHOR' => get_username_string('profile', $row['comment_user_id'], $row['comment_username'], $row['comment_user_colour']))); } $db->sql_freeresult($result); $template->assign_vars(array('S_COMMENTS' => true, 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_COMMENT'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_COMMENT'), 'QUOTE_IMG' => $user->img('icon_post_quote', 'QUOTE_COMMENT'), 'INFO_IMG' => $user->img('icon_post_info', 'IP'), 'MINI_POST_IMG' => $user->img('icon_post_target', 'COMMENT'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), 'COLLAPSE_COMMENTS' => $this->toggle_comments)); }
} // Is it a personal album, and does the user have permissions to create more? if ($album_data['album_user_id'] == $user->data['user_id']) { if (phpbb_gallery::$auth->acl_check('i_upload', phpbb_gallery_auth::OWN_ALBUM) && !phpbb_gallery::$auth->acl_check('album_unlimited', phpbb_gallery_auth::OWN_ALBUM)) { $sql = 'SELECT COUNT(album_id) albums FROM ' . GALLERY_ALBUMS_TABLE . ' WHERE album_user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $albums = (int) $db->sql_fetchfield('albums'); $db->sql_freeresult($result); if ($albums < phpbb_gallery::$auth->acl_check('album_count', phpbb_gallery_auth::OWN_ALBUM)) { $allowed_create = true; } } elseif (phpbb_gallery::$auth->acl_check('album_unlimited', phpbb_gallery_auth::OWN_ALBUM)) { $allowed_create = true; } } } // End of "We have album_type so that there may be images ..." // Page is ready loaded, mark album as "read" phpbb_gallery_misc::markread('album', $album_id); $template->assign_vars(array('S_IN_ALBUM' => true, 'S_IS_POSTABLE' => $album_data['album_type'] != phpbb_gallery_album::TYPE_CAT ? true : false, 'S_IS_LOCKED' => $album_data['album_status'] == phpbb_gallery_album::STATUS_LOCKED ? true : false, 'UPLOAD_IMG' => $album_data['album_status'] == phpbb_gallery_album::STATUS_LOCKED ? $user->img('button_topic_locked', 'ALBUM_LOCKED') : $user->img('button_upload_image', 'UPLOAD_IMAGE'), 'S_MODE' => $album_data['album_type'], 'L_MODERATORS' => $l_moderator, 'MODERATORS' => $moderators_list, 'U_UPLOAD_IMAGE' => (!$album_data['album_user_id'] || $album_data['album_user_id'] == $user->data['user_id']) && ($user->data['user_id'] == ANONYMOUS || phpbb_gallery::$auth->acl_check('i_upload', $album_id, $album_data['album_user_id'])) ? phpbb_gallery_url::append_sid('posting', "mode=image&submode=upload&album_id={$album_id}") : '', 'U_CREATE_ALBUM' => $album_data['album_user_id'] == $user->data['user_id'] && $allowed_create ? phpbb_gallery_url::append_sid('phpbb', 'ucp', "i=gallery&mode=manage_albums&action=create&parent_id={$album_id}&redirect=album") : '', 'U_EDIT_ALBUM' => $album_data['album_user_id'] == $user->data['user_id'] ? phpbb_gallery_url::append_sid('phpbb', 'ucp', "i=gallery&mode=manage_albums&action=edit&album_id={$album_id}&redirect=album") : '', 'U_SLIDE_SHOW' => sizeof(phpbb_gallery_plugins::$plugins) && phpbb_gallery_plugins::$slideshow ? phpbb_gallery_url::append_sid('album', "album_id={$album_id}&mode=slide_show" . ($sort_key != phpbb_gallery_config::get('default_sort_key') ? "&sk={$sort_key}" : '') . ($sort_dir != phpbb_gallery_config::get('default_sort_dir') ? "&sd={$sort_dir}" : '')) : '', 'S_DISPLAY_SEARCHBOX' => $auth->acl_get('u_search') && $config['load_search'] ? true : false, 'S_SEARCHBOX_ACTION' => phpbb_gallery_url::append_sid('search', 'aid[]=' . $album_id), 'S_THUMBNAIL_SIZE' => phpbb_gallery_config::get('thumbnail_height') + 20 + (phpbb_gallery_config::get('thumbnail_infoline') ? phpbb_gallery_constants::THUMBNAIL_INFO_HEIGHT : 0), 'S_COLS' => phpbb_gallery_config::get('album_columns'), 'S_COL_WIDTH' => 100 / phpbb_gallery_config::get('album_columns') . '%', 'S_JUMPBOX_ACTION' => phpbb_gallery_url::append_sid('album'), 'S_ALBUM_ACTION' => phpbb_gallery_url::append_sid('album', "album_id={$album_id}"), 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'ALBUM_JUMPBOX' => phpbb_gallery_album::get_albumbox(false, '', $album_id), 'U_RETURN_LINK' => phpbb_gallery_url::append_sid('index'), 'S_RETURN_LINK' => $user->lang['GALLERY'], 'PAGINATION' => generate_pagination(phpbb_gallery_url::append_sid('album', "album_id={$album_id}&sk={$sort_key}&sd={$sort_dir}&st={$sort_days}"), $image_counter, $images_per_page, $start), 'TOTAL_IMAGES' => $image_counter == 1 ? $user->lang['IMAGE_#'] : sprintf($user->lang['IMAGES_#'], $image_counter), 'PAGE_NUMBER' => on_page($image_counter, $images_per_page, $start), 'L_WATCH_TOPIC' => $album_data['watch_id'] ? $user->lang['UNWATCH_ALBUM'] : $user->lang['WATCH_ALBUM'], 'U_WATCH_TOPIC' => $album_data['album_type'] != phpbb_gallery_album::TYPE_CAT && $user->data['user_id'] != ANONYMOUS ? phpbb_gallery_url::append_sid('posting', "mode=album&submode=" . ($album_data['watch_id'] ? 'unwatch' : 'watch') . "&album_id={$album_id}") : '', 'S_WATCHING_TOPIC' => $album_data['watch_id'] ? true : false)); if (version_compare($config['version'], '3.0.5', '>')) { page_header($user->lang['VIEW_ALBUM'] . ' - ' . $album_data['album_name'], true, $album_id, 'album'); } else { // Backwards compatible cheat_phpbb_31975(); page_header($user->lang['VIEW_ALBUM'] . ' - ' . $album_data['album_name']); } $template->set_filenames(array('body' => 'gallery/album_body.html')); page_footer();
public static function display_captcha($mode) { static $gallery_display_captcha; if (isset($gallery_display_captcha[$mode])) { return $gallery_display_captcha[$mode]; } global $config, $user; $gallery_display_captcha[$mode] = $user->data['user_id'] == ANONYMOUS && phpbb_gallery_config::get('captcha_' . $mode) && version_compare($config['version'], '3.0.5', '>'); return $gallery_display_captcha[$mode]; }