/** * Constructor * * @param string $file Full link to the image-file * @param mixed $image_id False or integer */ public function __construct($file, $image_id = false) { if (self::$function_exists === null) { self::$function_exists = function_exists('exif_read_data') ? true : false; } if ($image_id) { $this->image_id = (int) $image_id; } $this->file = $file; }
$db->sql_freeresult($result); $s_allowed_delete = $s_allowed_edit = $s_allowed_status = false; if ((phpbb_gallery::$auth->acl_check('m_', $album_id, $album_data['album_user_id']) || $image_data['image_user_id'] == $user->data['user_id']) && $user->data['user_id'] != ANONYMOUS) { $s_user_allowed = $image_data['image_user_id'] == $user->data['user_id'] && $album_data['album_status'] != phpbb_gallery_album::STATUS_LOCKED; $s_allowed_delete = phpbb_gallery::$auth->acl_check('i_delete', $album_id, $album_data['album_user_id']) && $s_user_allowed || phpbb_gallery::$auth->acl_check('m_delete', $album_id, $album_data['album_user_id']); $s_allowed_edit = phpbb_gallery::$auth->acl_check('i_edit', $album_id, $album_data['album_user_id']) && $s_user_allowed || phpbb_gallery::$auth->acl_check('m_edit', $album_id, $album_data['album_user_id']); $s_quick_mod = $s_allowed_delete || $s_allowed_edit || phpbb_gallery::$auth->acl_check('m_status', $album_id, $album_data['album_user_id']) || phpbb_gallery::$auth->acl_check('m_move', $album_id, $album_data['album_user_id']); $user->add_lang('mods/gallery_mcp'); $template->assign_vars(array('S_MOD_ACTION' => phpbb_gallery_url::append_sid('mcp', "album_id={$album_id}&image_id={$image_id}&quickmod=1", true, $user->session_id), 'S_QUICK_MOD' => $s_quick_mod, 'S_QM_MOVE' => phpbb_gallery::$auth->acl_check('m_move', $album_id, $album_data['album_user_id']), 'S_QM_EDIT' => $s_allowed_edit, 'S_QM_DELETE' => $s_allowed_delete, 'S_QM_REPORT' => phpbb_gallery::$auth->acl_check('m_report', $album_id, $album_data['album_user_id']), 'S_QM_STATUS' => phpbb_gallery::$auth->acl_check('m_status', $album_id, $album_data['album_user_id']), 'S_IMAGE_REPORTED' => $image_data['image_reported'], 'U_IMAGE_REPORTED' => $image_data['image_reported'] ? phpbb_gallery_url::append_sid('mcp', "mode=report_details&album_id={$album_id}&option_id=" . $image_data['image_reported']) : '', 'S_STATUS_APPROVED' => $image_data['image_status'] == phpbb_gallery_image::STATUS_APPROVED, 'S_STATUS_UNAPPROVED' => $image_data['image_status'] == phpbb_gallery_image::STATUS_UNAPPROVED, 'S_STATUS_LOCKED' => $image_data['image_status'] == phpbb_gallery_image::STATUS_LOCKED)); } $template->assign_vars(array('U_VIEW_ALBUM' => phpbb_gallery_url::append_sid("album.{$phpEx}", "album_id={$album_id}"), 'UC_PREVIOUS_IMAGE' => !empty($previous_data) && phpbb_gallery_config::get('disp_nextprev_thumbnail') ? generate_image_link('thumbnail', 'image_page', $previous_data['image_id'], $previous_data['image_name'], $album_id) : '', 'UC_PREVIOUS' => !empty($previous_data) ? phpbb_gallery_image::generate_link('image_name_unbold', 'image_page_prev', $previous_data['image_id'], $previous_data['image_name'], $album_id) : '', 'UC_IMAGE' => phpbb_gallery_image::generate_link('medium', phpbb_gallery_config::get('link_imagepage'), $image_id, $image_data['image_name'], $album_id, substr($image_data['image_filename'], 0 - 3) == 'gif' ? true : false, false), 'UC_NEXT_IMAGE' => !empty($next_data) && phpbb_gallery_config::get('disp_nextprev_thumbnail') ? generate_image_link('thumbnail', 'image_page', $next_data['image_id'], $next_data['image_name'], $album_id) : '', 'UC_NEXT' => !empty($next_data) ? phpbb_gallery_image::generate_link('image_name_unbold', 'image_page_next', $next_data['image_id'], $next_data['image_name'], $album_id) : '', 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_IMAGE'), 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_IMAGE'), 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_IMAGE'), 'STATUS_IMG' => $user->img('icon_post_info', 'STATUS_IMAGE'), 'U_DELETE' => $s_allowed_delete ? phpbb_gallery_url::append_sid('posting', "mode=image&submode=delete&album_id={$album_id}&image_id={$image_id}") : '', 'U_EDIT' => $s_allowed_edit ? phpbb_gallery_url::append_sid('posting', "mode=image&submode=edit&album_id={$album_id}&image_id={$image_id}") : '', 'U_REPORT' => phpbb_gallery::$auth->acl_check('i_report', $album_id, $album_data['album_user_id']) && $image_data['image_user_id'] != $user->data['user_id'] ? phpbb_gallery_url::append_sid('posting', "mode=image&submode=report&album_id={$album_id}&image_id={$image_id}") : '', 'U_STATUS' => $s_allowed_status ? phpbb_gallery_url::append_sid('mcp', "mode=queue_details&album_id={$album_id}&option_id={$image_id}") : '', 'CONTEST_RANK' => $image_data['image_contest_rank'] ? $user->lang['CONTEST_RESULT_' . $image_data['image_contest_rank']] : '', 'IMAGE_NAME' => $image_data['image_name'], 'IMAGE_DESC' => generate_text_for_display($image_data['image_desc'], $image_data['image_desc_uid'], $image_data['image_desc_bitfield'], 7), 'IMAGE_BBCODE' => '[album]' . $image_id . '[/album]', 'IMAGE_IMGURL_BBCODE' => phpbb_gallery_config::get('disp_image_url') ? '[url=' . phpbb_gallery_url::path('full') . "image.{$phpEx}?album_id={$album_id}&image_id={$image_id}" . '][img]' . generate_board_url(false) . '/' . phpbb_gallery_url::path('relative') . "image.{$phpEx}?album_id={$album_id}&image_id={$image_id}&mode=thumbnail" . '[/img][/url]' : '', 'IMAGE_URL' => phpbb_gallery_config::get('disp_image_url') ? phpbb_gallery_url::path('full') . "image.{$phpEx}?album_id={$album_id}&image_id={$image_id}" : '', 'IMAGE_TIME' => $user->format_date($image_data['image_time']), 'IMAGE_VIEW' => $image_data['image_view_count'], 'POSTER_IP' => $auth->acl_get('a_') ? $image_data['image_user_ip'] : '', 'U_POSTER_WHOIS' => $auth->acl_get('a_') ? phpbb_gallery_url::append_sid('mcp', 'mode=whois&ip=' . $image_data['image_user_ip']) : '', 'L_BOOKMARK_TOPIC' => $image_data['favorite_id'] ? $user->lang['UNFAVORITE_IMAGE'] : $user->lang['FAVORITE_IMAGE'], 'U_BOOKMARK_TOPIC' => $user->data['user_id'] != ANONYMOUS ? phpbb_gallery_url::append_sid('posting', "mode=image&submode=" . ($image_data['favorite_id'] ? 'un' : '') . "favorite&album_id={$album_id}&image_id={$image_id}") : '', 'L_WATCH_TOPIC' => $image_data['watch_id'] ? $user->lang['UNWATCH_IMAGE'] : $user->lang['WATCH_IMAGE'], 'U_WATCH_TOPIC' => $user->data['user_id'] != ANONYMOUS ? phpbb_gallery_url::append_sid('posting', "mode=image&submode=" . ($image_data['watch_id'] ? 'un' : '') . "watch&album_id={$album_id}&image_id={$image_id}") : '', 'S_WATCHING_TOPIC' => $image_data['watch_id'] ? true : false, 'S_ALBUM_ACTION' => phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&image_id={$image_id}"), 'U_RETURN_LINK' => phpbb_gallery_url::append_sid('album', "album_id={$album_id}"), 'S_RETURN_LINK' => $album_data['album_name'], 'S_JUMPBOX_ACTION' => phpbb_gallery_url::append_sid('album'), 'ALBUM_JUMPBOX' => phpbb_gallery_album::get_albumbox(false, '', $album_id))); /** * Exif-Data */ if (phpbb_gallery_config::get('disp_exifdata') && $image_data['image_has_exif'] != phpbb_gallery_exif::UNAVAILABLE && substr($image_data['image_filename'], -4) == '.jpg' && function_exists('exif_read_data') && (phpbb_gallery::$auth->acl_check('m_status', $album_id, $album_data['album_user_id']) || $image_data['image_contest'] != phpbb_gallery_image::IN_CONTEST)) { $exif = new phpbb_gallery_exif(phpbb_gallery_url::path('upload') . $image_data['image_filename'], $image_id); $exif->interpret($image_data['image_has_exif'], $image_data['image_exif_data']); if (!empty($exif->data["EXIF"])) { $exif->send_to_template(phpbb_gallery::$user->get_data('user_viewexif')); } unset($exif); } /** * Rating */ if (phpbb_gallery_config::get('allow_rates')) { $rating = new phpbb_gallery_image_rating($image_id, $image_data, $album_data); $user_rating = $rating->get_user_rating($user->data['user_id']); // Check: User didn't rate yet, has permissions, it's not the users own image and the user is logged in if (!$user_rating && $rating->is_allowed()) { $rating->display_box();
} $image_data = array('filename' => $image_file->realname, 'image_album_id' => $album_data['album_id'], 'image_album_name' => $album_data['album_name'], 'image_name' => str_replace('{NUM}', $loop, request_var('image_name', '', true)), 'image_desc' => str_replace('{NUM}', $loop, request_var('message', '', true)), 'image_time' => time() + $loop, 'image_contest' => $album_data['album_contest'] ? phpbb_gallery_image::IN_CONTEST : phpbb_gallery_image::NO_CONTEST, 'thumbnail' => '', 'username' => request_var('username', $user->data['username'])); $image_data['image_name'] = request_var('filename', '') == 'filename' || $image_data['image_name'] == '' ? str_replace("_", " ", utf8_substr($image_file->uploadname, 0, strrpos($image_file->uploadname, '.'))) : $image_data['image_name']; if (!$image_data['image_name']) { trigger_error('MISSING_IMAGE_NAME'); } if (!$user->data['is_registered'] && $image_data['username']) { if (validate_username($image_data['username'])) { trigger_error('INVALID_USERNAME'); } } $image_tools = new phpbb_gallery_image_file(); $image_tools->set_image_options(phpbb_gallery_config::get('max_filesize'), phpbb_gallery_config::get('max_height'), phpbb_gallery_config::get('max_width')); $image_tools->set_image_data($image_file->destination_file, $image_data['image_name'], $image_file->filesize); // Read exif data from file $exif = new phpbb_gallery_exif($image_file->destination_file); $exif->read(); $image_data['image_exif_data'] = $exif->serialized; $image_data['image_has_exif'] = $exif->status; unset($exif); /// Rotate the image if (phpbb_gallery_config::get('allow_rotate')) { $image_tools->rotate_image($rotate[$i], phpbb_gallery_config::get('allow_resize')); if ($image_tools->rotated) { $image_file->height = $image_tools->image_size['height']; $image_file->width = $image_tools->image_size['width']; } } // Resize overside images if ($image_file->width > phpbb_gallery_config::get('max_width') || $image_file->height > phpbb_gallery_config::get('max_height')) { if (phpbb_gallery_config::get('allow_resize')) {