Exemplo n.º 1
0
 /**
  * Static Constructor.
  */
 public static function init($force_root_path = false)
 {
     global $phpbb_admin_path, $phpbb_root_path, $phpEx;
     if ($force_root_path) {
         self::$phpbb_root_path = $force_root_path;
     } else {
         self::$phpbb_root_path = $phpbb_root_path;
     }
     $phpbb_admin_path = self::$phpbb_root_path . self::$phpbb_admin_path;
     self::$phpbb_admin_path = $phpbb_admin_path;
     self::$phpEx = '.' . $phpEx;
     self::$loaded = true;
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
 /**
  *
  */
 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&amp;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&amp;action=aim&amp;u={$user_id}") : '', 'msn' => $row['user_msnm'] && $auth->acl_get('u_sendim') ? phpbb_gallery_url::append_sid('phpbb', 'memberlist', "mode=contact&amp;action=msnm&amp;u={$user_id}") : '', 'yim' => $row['user_yim'] ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&amp;.src=pg' : '', 'jabber' => $row['user_jabber'] && $auth->acl_get('u_sendim') ? phpbb_gallery_url::append_sid('phpbb', 'memberlist', "mode=contact&amp;action=jabber&amp;u={$user_id}") : '', 'search' => $auth->acl_get('u_search') ? phpbb_gallery_url::append_sid('phpbb', 'search', "author_id={$user_id}&amp;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&amp;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'] . '&amp;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);
             }
         }
     }
 }
Exemplo n.º 4
0
 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}&amp;image_id=" . $row['image_id']), 'U_IMAGE_PAGE' => phpbb_gallery_url::append_sid('mcp', 'mode=report_details&amp;album_id=' . $album_id . '&amp;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}&amp;album_id={$album_id}&amp;sd={$sort_dir}&amp;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}&amp;album_id={$album_id}"), 'DISP_FAKE_THUMB' => phpbb_gallery_config::get('mini_thumbnail_disp'), 'FAKE_THUMB_SIZE' => phpbb_gallery_config::get('mini_thumbnail_size')));
 }
Exemplo n.º 5
0
    public function main($album_id)
    {
        $this->user->add_lang_ext('phpbbgallery/core', array('gallery'));
        $album_data = $this->album->get_info($album_id);
        $this->display->generate_navigation($album_data);
        add_form_key('gallery');
        $album_backlink = $this->helper->route('phpbbgallery_album', array('album_id' => $album_id));
        $album_loginlink = 'ucp.php?mode=login';
        $error = '';
        //Let's get authorization
        $this->auth->load_user_premissions($this->user->data['user_id']);
        if (!$this->auth->acl_check('i_upload', $album_id, $album_data['album_user_id']) || $album_data['album_status'] == $this->album->status_locked()) {
            $this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
        }
        $page_title = 'Upload to "' . $album_data['album_name'] . '"';
        // Before all
        if (!$this->check_fs()) {
            trigger_error('NO_WRITE_ACCESS');
        }
        $submit = $this->request->variable('submit', false);
        $mode = $this->request->variable('mode', 'upload');
        if ($mode == 'upload') {
            // Upload Quota Check
            // 1. Check album-configuration Quota
            if ($this->gallery_config->get('album_images') >= 0 && $album_data['album_images'] >= $this->gallery_config->get('album_images')) {
                //@todo: Add return link
                trigger_error('ALBUM_REACHED_QUOTA');
            }
            // 2. Check user-limit, if he is not allowed to go unlimited
            if (!$this->auth->acl_check('i_unlimited', $album_id, $album_data['album_user_id'])) {
                $sql = 'SELECT COUNT(image_id) count
					FROM ' . $this->images_table . '
					WHERE image_user_id = ' . $this->user->data['user_id'] . '
						AND image_status <> ' . $this->image->get_status_orphan() . '
						AND image_album_id = ' . $album_id;
                $result = $this->db->sql_query($sql);
                $own_images = (int) $this->db->sql_fetchfield('count');
                $this->db->sql_freeresult($result);
                if ($own_images >= $this->auth->acl_check('i_count', $album_id, $album_data['album_user_id'])) {
                    //@todo: Add return link
                    trigger_error($this->user->lang('USER_REACHED_QUOTA', $this->auth->acl_check('i_count', $album_id, $album_data['album_user_id'])));
                }
            }
            if ($this->misc->display_captcha('upload')) {
                phpbb_gallery_url::_include('captcha/captcha_factory', 'phpbb');
                $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']);
                $captcha->init(CONFIRM_POST);
                $s_captcha_hidden_fields = '';
            }
            $upload_files_limit = $this->auth->acl_check('i_unlimited', $album_id, $album_data['album_user_id']) ? $this->gallery_config->get('num_uploads') : min($this->auth->acl_check('i_count', $album_id, $album_data['album_user_id']) - $own_images, $this->gallery_config->get('num_uploads'));
            $process = new \phpbbgallery\core\upload($album_id, $upload_files_limit);
            if ($submit) {
                if (!check_form_key('gallery')) {
                    trigger_error('FORM_INVALID');
                }
                //$process = new \phpbbgallery\core\upload($album_id, $upload_files_limit);
                $process->set_rotating($this->request->variable('rotate', array(0)));
                $process->set_allow_comments($this->request->variable('allow_comments', false));
                /*if ($this->misc->display_captcha('upload'))
                		{
                			$captcha_error = $captcha->validate();
                			if ($captcha_error !== false)
                			{
                				$process->new_error($captcha_error);
                			}
                		}
                		*/
                if (!$this->user->data['is_registered']) {
                    $username = $this->request->variable('username', $user->data['username']);
                    if ($result = validate_username($username)) {
                        $this->user->add_lang('ucp');
                        $error_array[] = $this->user->lang[$result . '_USERNAME'];
                    } else {
                        $process->set_username($username);
                    }
                }
                if (empty($process->errors)) {
                    for ($file_count = 0; $file_count < $upload_files_limit; $file_count++) {
                        /**
                         * Upload an image from the FILES-array,
                         * call some functions (rotate, resize, ...)
                         * and store the image to the database
                         */
                        $file = $this->request->file('image_file_' . $file_count, '');
                        if (isset($file['size'])) {
                            if ($file['size'] > 0) {
                                $process->upload_file($file_count);
                            }
                        }
                    }
                }
                if (!$process->uploaded_files) {
                    $process->new_error($this->user->lang['UPLOAD_NO_FILE']);
                } else {
                    $mode = 'upload_edit';
                    // Remove submit, so we get the first screen of step 2.
                    $submit = false;
                }
                $error = implode('<br />', $process->errors);
                /*if (phpbb_gallery_misc::display_captcha('upload'))
                		{
                			$captcha->reset();
                		}*/
            }
            if (!$submit || isset($process) && !$process->uploaded_files) {
                for ($i = 0; $i < $upload_files_limit; $i++) {
                    $this->template->assign_block_vars('upload_image', array());
                }
            }
            if ($mode == 'upload') {
                $this->template->assign_vars(array('ERROR' => $error, 'S_MAX_FILESIZE' => get_formatted_filesize($this->gallery_config->get('max_filesize')), 'S_MAX_WIDTH' => $this->gallery_config->get('max_width'), 'S_MAX_HEIGHT' => $this->gallery_config->get('max_height'), 'S_ALLOWED_FILETYPES' => implode(', ', $process->get_allowed_types(true)), 'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_album_upload', array('album_id' => $album_id)), 'S_UPLOAD' => true, 'S_ALLOW_ROTATE' => $this->gallery_config->get('allow_rotate') && function_exists('imagerotate'), 'S_UPLOAD_LIMIT' => $upload_files_limit, 'S_COMMENTS_ENABLED' => $this->gallery_config->get('allow_comments') && $this->gallery_config->get('comment_user_control'), 'S_ALLOW_COMMENTS' => true, 'L_ALLOW_COMMENTS' => $this->user->lang('ALLOW_COMMENTS_ARY', $upload_files_limit)));
                /*if (phpbb_gallery_misc::display_captcha('upload'))
                		{
                			if (!$submit || !$captcha->is_solved())
                			{
                				$template->assign_vars(array(
                					'S_CONFIRM_CODE'			=> true,
                					'CAPTCHA_TEMPLATE'			=> $captcha->get_template(),
                				));
                			}
                			$template->assign_vars(array(
                				'S_CAPTCHA_HIDDEN_FIELDS'	=> $s_captcha_hidden_fields,
                			));
                		}*/
            }
        }
        if ($mode == 'upload_edit') {
            if ($submit) {
                // Upload Quota Check
                // 1. Check album-configuration Quota
                if ($this->gallery_config->get('album_images') >= 0 && $album_data['album_images'] >= $this->gallery_config->get('album_images')) {
                    //@todo: Add return link
                    trigger_error('ALBUM_REACHED_QUOTA');
                }
                // 2. Check user-limit, if he is not allowed to go unlimited
                if (!$this->auth->acl_check('i_unlimited', $album_id, $album_data['album_user_id'])) {
                    $sql = 'SELECT COUNT(image_id) count
						FROM ' . $this->images_table . '
						WHERE image_user_id = ' . $this->user->data['user_id'] . '
							AND image_status <> ' . $this->image->get_status_orphan() . '
							AND image_album_id = ' . $album_id;
                    $result = $this->db->sql_query($sql);
                    $own_images = (int) $this->db->sql_fetchfield('count');
                    $this->db->sql_freeresult($result);
                    if ($own_images >= $this->auth->acl_check('i_count', $album_id, $album_data['album_user_id'])) {
                        //@todo: Add return link
                        trigger_error($this->user->lang('USER_REACHED_QUOTA', $this->auth->acl_check('i_count', $album_id, $album_data['album_user_id'])));
                    }
                }
                $description_array = $this->request->variable('message', array(''), true);
                foreach ($description_array as $var) {
                    if (strlen($var) > $this->gallery_config->get('description_length')) {
                        trigger_error($this->user->lang('DESC_TOO_LONG'));
                    }
                }
                $upload_files_limit = $this->auth->acl_check('i_unlimited', $album_id, $album_data['album_user_id']) ? $this->gallery_config->get('num_uploads') : min($this->auth->acl_check('i_count', $album_id, $album_data['album_user_id']) - $own_images, $this->gallery_config->get('num_uploads'));
                $upload_ids = $this->request->variable('upload_ids', array(''));
                $process = new \phpbbgallery\core\upload($album_id, $upload_files_limit);
                $process->set_rotating($this->request->variable('rotate', array(0)));
                $process->get_images($upload_ids);
                $image_names = $this->request->variable('image_name', array(''), true);
                $process->set_names($image_names);
                $process->set_descriptions($description_array);
                $process->set_image_num($this->request->variable('image_num', 0));
                $process->use_same_name($this->request->variable('same_name', false));
                $success = true;
                $phpbb_gallery_notification = new \phpbbgallery\core\notification();
                foreach ($process->images as $image_id) {
                    $success = $success && $process->update_image($image_id, !$this->auth->acl_check('i_approve', $album_id, $album_data['album_user_id']), $album_data['album_contest']);
                    if ($this->gallery_user->get_data('watch_own')) {
                        $phpbb_gallery_notification->add($image_id);
                    }
                }
                $message = '';
                $error = implode('<br />', $process->errors);
                if ($this->auth->acl_check('i_approve', $album_id, $album_data['album_user_id'])) {
                    $message .= !$error ? $this->user->lang['ALBUM_UPLOAD_SUCCESSFUL'] : $this->user->lang('ALBUM_UPLOAD_SUCCESSFUL_ERROR', $error);
                    $meta_refresh_time = $success ? 3 : 20;
                    //$this->notification_helper->notify_album($album_id, $this->user->data['user_id']);
                    $data = array('targets' => array($this->user->data['user_id']), 'album_id' => $album_id, 'last_image' => end($process->images));
                    $this->notification_helper->new_image($data);
                } else {
                    $target = array('album_id' => $album_id, 'last_image' => end($process->images), 'uploader' => $this->user->data['user_id']);
                    $this->notification_helper->notify('approval', $target);
                    $message .= !$error ? $this->user->lang['ALBUM_UPLOAD_NEED_APPROVAL'] : $this->user->lang('ALBUM_UPLOAD_NEED_APPROVAL_ERROR', $error);
                    $meta_refresh_time = 20;
                }
                $message .= '<br /><br />' . sprintf($this->user->lang['CLICK_RETURN_ALBUM'], '<a href="' . $album_backlink . '">', '</a>');
                // ToDo - notifications!!!
                //$phpbb_gallery_notification->send_notification('album', $album_id, $image_names[0]);
                $this->image->handle_counter($process->images, true);
                $this->album->update_info($album_id);
                $this->url->meta_refresh($meta_refresh_time, $album_backlink);
                trigger_error($message);
            }
            $num_images = 0;
            foreach ($process->images as $image_id) {
                $data = $process->image_data[$image_id];
                $this->template->assign_block_vars('image', array('U_IMAGE' => $this->image->generate_link('thumbnail', 'plugin', $image_id, $data['image_name'], $album_id), 'IMAGE_NAME' => $data['image_name'], 'IMAGE_DESC' => $data['image_desc']));
                $num_images++;
            }
            $s_hidden_fields = build_hidden_fields(array('upload_ids' => $process->generate_hidden_fields()));
            $s_can_rotate = $this->gallery_config->get('allow_rotate') && function_exists('imagerotate');
            $this->template->assign_vars(array('ERROR' => $error, 'S_UPLOAD_EDIT' => true, 'S_ALLOW_ROTATE' => $s_can_rotate, 'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_album_upload', array('album_id' => $album_id)), 'S_USERNAME' => !$this->user->data['is_registered'] ? $username : '', 'NUM_IMAGES' => $num_images, 'COLOUR_ROWSPAN' => $s_can_rotate ? $num_images * 3 : $num_images * 2, 'L_DESCRIPTION_LENGTH' => $this->user->lang('DESCRIPTION_LENGTH', $this->gallery_config->get('description_length')), 'S_HIDDEN_FIELDS' => $s_hidden_fields));
        }
        return $this->helper->render('gallery/posting_body.html', $page_title);
    }
Exemplo n.º 6
0
                }
                $user_cache[$user_id]['sig'] = bbcode_nl2br($user_cache[$user_id]['sig']);
                $user_cache[$user_id]['sig'] = smiley_text($user_cache[$user_id]['sig']);
                $user_cache[$user_id]['sig_parsed'] = true;
            }
            $template->assign_block_vars('commentrow', array('U_COMMENT' => phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&amp;image_id={$image_id}&amp;start={$start}&amp;sort_order={$sort_order}") . '#' . $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), 'EDIT_INFO' => $edit_info, 'U_DELETE' => phpbb_gallery::$auth->acl_check('m_comments', $album_id, $album_data['album_user_id']) || phpbb_gallery::$auth->acl_check('c_delete', $album_id, $album_data['album_user_id']) && $row['comment_user_id'] == $user->data['user_id'] && $user->data['is_registered'] ? phpbb_gallery_url::append_sid('posting', "album_id={$album_id}&amp;image_id={$image_id}&amp;mode=comment&amp;submode=delete&amp;comment_id=" . $row['comment_id']) : '', 'U_EDIT' => phpbb_gallery::$auth->acl_check('m_comments', $album_id, $album_data['album_user_id']) || phpbb_gallery::$auth->acl_check('c_edit', $album_id, $album_data['album_user_id']) && $row['comment_user_id'] == $user->data['user_id'] && $user->data['is_registered'] ? phpbb_gallery_url::append_sid('posting', "album_id={$album_id}&amp;image_id={$image_id}&amp;mode=comment&amp;submode=edit&amp;comment_id=" . $row['comment_id']) : '', 'U_INFO' => $auth->acl_get('a_') ? phpbb_gallery_url::append_sid('mcp', 'mode=whois&amp;ip=' . $row['comment_user_ip']) : '', 'POST_AUTHOR_FULL' => get_username_string('full', $user_id, $row['comment_username'], $user_cache[$user_id]['user_colour']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $user_id, $row['comment_username'], $user_cache[$user_id]['user_colour']), 'POST_AUTHOR' => get_username_string('username', $user_id, $row['comment_username'], $user_cache[$user_id]['user_colour']), 'U_POST_AUTHOR' => get_username_string('profile', $user_id, $row['comment_username'], $user_cache[$user_id]['user_colour']), 'SIGNATURE' => $user_cache[$user_id]['sig'], 'RANK_TITLE' => $user_cache[$user_id]['rank_title'], 'RANK_IMG' => $user_cache[$user_id]['rank_image'], 'RANK_IMG_SRC' => $user_cache[$user_id]['rank_image_src'], 'POSTER_JOINED' => $user_cache[$user_id]['joined'], 'POSTER_POSTS' => $user_cache[$user_id]['posts'], 'POSTER_FROM' => $user_cache[$user_id]['from'], 'POSTER_AVATAR' => $user_cache[$user_id]['avatar'], 'POSTER_WARNINGS' => $user_cache[$user_id]['warnings'], 'POSTER_AGE' => $user_cache[$user_id]['age'], 'ICQ_STATUS_IMG' => $user_cache[$user_id]['icq_status_img'], 'ONLINE_IMG' => $user_id == ANONYMOUS || !$config['load_onlinetrack'] ? '' : ($user_cache[$user_id]['online'] ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 'S_ONLINE' => $user_id == ANONYMOUS || !$config['load_onlinetrack'] ? false : ($user_cache[$user_id]['online'] ? true : false), 'U_PROFILE' => $user_cache[$user_id]['profile'], 'U_SEARCH' => $user_cache[$user_id]['search'], 'U_PM' => $user_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$user_id]['allow_pm'] || $auth->acl_gets('a_', 'm_')) ? phpbb_gallery_url::append_sid('phpbb', 'ucp', 'i=pm&amp;mode=compose&amp;u=' . $user_id) : '', 'U_EMAIL' => $user_cache[$user_id]['email'], 'U_WWW' => $user_cache[$user_id]['www'], 'U_ICQ' => $user_cache[$user_id]['icq'], 'U_AIM' => $user_cache[$user_id]['aim'], 'U_MSN' => $user_cache[$user_id]['msn'], 'U_YIM' => $user_cache[$user_id]['yim'], 'U_JABBER' => $user_cache[$user_id]['jabber'], 'U_GALLERY' => $user_cache[$user_id]['gallery_album'], 'GALLERY_IMAGES' => $user_cache[$user_id]['gallery_images'], 'U_GALLERY_SEARCH' => $user_cache[$user_id]['gallery_search']));
        }
        $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'), 'PAGE_NUMBER' => sprintf($user->lang['PAGE_OF'], floor($start / $config['posts_per_page']) + 1, ceil($image_data['image_comments'] / $config['posts_per_page'])), 'PAGINATION' => generate_pagination(phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&amp;image_id={$image_id}&amp;sort_order={$sort_order}"), $image_data['image_comments'], $config['posts_per_page'], $start)));
    }
}
// Get the data of the image-uploader, if we don't have it from the comments anyway.
if (!isset($user_cache[$image_data['image_user_id']])) {
    $sql = $db->sql_build_query('SELECT', array('SELECT' => 'u.*, gu.personal_album_id, gu.user_images', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(phpbb_gallery_user_base::sql_table() => 'gu'), 'ON' => 'gu.user_id = u.user_id')), 'WHERE' => 'u.user_id = ' . $image_data['image_user_id']));
    $result = $db->sql_query($sql);
    $user_cache = array();
    while ($row = $db->sql_fetchrow($result)) {
        phpbb_gallery_user_base::add_user_to_user_cache($user_cache, $row);
    }
    $db->sql_freeresult($result);
}
if (phpbb_gallery::$auth->acl_check('m_status', $album_id, $album_data['album_user_id']) || $image_data['image_contest'] != phpbb_gallery_image::IN_CONTEST) {
    $user_cache[$user_id]['username'] = $image_data['image_username'] ? $image_data['image_username'] : $user->lang['GUEST'];
    $template->assign_vars(array('POSTER_FULL' => get_username_string('full', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'POSTER_COLOUR' => get_username_string('colour', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'POSTER_USERNAME' => get_username_string('username', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'U_POSTER' => get_username_string('profile', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'POSTER_SIGNATURE' => $user_cache[$user_id]['sig'], 'POSTER_RANK_TITLE' => $user_cache[$user_id]['rank_title'], 'POSTER_RANK_IMG' => $user_cache[$user_id]['rank_image'], 'POSTER_RANK_IMG_SRC' => $user_cache[$user_id]['rank_image_src'], 'POSTER_JOINED' => $user_cache[$user_id]['joined'], 'POSTER_POSTS' => $user_cache[$user_id]['posts'], 'POSTER_FROM' => $user_cache[$user_id]['from'], 'POSTER_AVATAR' => $user_cache[$user_id]['avatar'], 'POSTER_WARNINGS' => $user_cache[$user_id]['warnings'], 'POSTER_AGE' => $user_cache[$user_id]['age'], 'POSTER_ICQ_STATUS_IMG' => $user_cache[$user_id]['icq_status_img'], 'POSTER_ONLINE_IMG' => $user_id == ANONYMOUS || !$config['load_onlinetrack'] ? '' : ($user_cache[$user_id]['online'] ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 'S_POSTER_ONLINE' => $user_id == ANONYMOUS || !$config['load_onlinetrack'] ? false : ($user_cache[$user_id]['online'] ? true : false), 'U_POSTER_PROFILE' => $user_cache[$user_id]['profile'], 'U_POSTER_SEARCH' => $user_cache[$user_id]['search'], 'U_POSTER_PM' => $user_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$user_id]['allow_pm'] || $auth->acl_gets('a_', 'm_')) ? phpbb_gallery_url::append_sid('phpbb', 'ucp', 'i=pm&amp;mode=compose&amp;u=' . $user_id) : '', 'U_POSTER_EMAIL' => $user_cache[$user_id]['email'], 'U_POSTER_WWW' => $user_cache[$user_id]['www'], 'U_POSTER_ICQ' => $user_cache[$user_id]['icq'], 'U_POSTER_AIM' => $user_cache[$user_id]['aim'], 'U_POSTER_MSN' => $user_cache[$user_id]['msn'], 'U_POSTER_YIM' => $user_cache[$user_id]['yim'], 'U_POSTER_JABBER' => $user_cache[$user_id]['jabber'], 'U_POSTER_GALLERY' => $user_cache[$user_id]['gallery_album'], 'POSTER_GALLERY_IMAGES' => $user_cache[$user_id]['gallery_images'], 'U_POSTER_GALLERY_SEARCH' => $user_cache[$user_id]['gallery_search']));
} else {
    $template->assign_vars(array('POSTER_FULL' => sprintf($user->lang['CONTEST_USERNAME_LONG'], $user->format_date($album_data['contest_start'] + $album_data['contest_end'], false, true))));
}
$template->assign_vars(array('PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), 'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'), 'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'), 'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'), 'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'), 'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'), 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER'), 'GALLERY_IMG' => $user->img('icon_contact_gallery', 'PERSONAL_ALBUM')));
page_header($user->lang['VIEW_IMAGE'] . ' - ' . $image_data['image_name'], false);
$template->set_filenames(array('body' => 'gallery/viewimage_body.html'));
page_footer();
Exemplo n.º 7
0
 /**
  * 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 &amp;)
  */
 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}&amp;image_id={$image_id}{$additional_parameters}");
     $image_url = phpbb_gallery_url::append_sid('image', "album_id={$album_id}&amp;image_id={$image_id}{$additional_parameters}" . (!$count ? '&amp;view=no_count' : ''));
     $thumb_url = phpbb_gallery_url::append_sid('image', "mode=thumbnail&amp;album_id={$album_id}&amp;image_id={$image_id}{$additional_parameters}");
     $medium_url = phpbb_gallery_url::append_sid('image', "mode=medium&amp;album_id={$album_id}&amp;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);
 }
Exemplo n.º 8
0
                $template->assign_block_vars('commentrow', array('U_COMMENT' => phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&amp;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}&amp;image_id={$image_id}&amp;mode=comment&amp;submode=delete&amp;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}&amp;image_id={$image_id}&amp;mode=comment&amp;submode=edit&amp;comment_id=" . $commentrow['comment_id']) : '', 'U_INFO' => $auth->acl_get('a_') ? phpbb_gallery_url::append_sid('mcp', 'mode=whois&amp;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');
}
// Prevent undefined variable on build_hidden_fields()
$s_hidden_fields = array('e' => 0);
if ($_SID) {
    $s_hidden_fields['sid'] = $_SID;
}
if (!empty($_EXTRA_URL)) {
    foreach ($_EXTRA_URL as $url_param) {
        $url_param = explode('=', $url_param, 2);
        $s_hidden_fields[$url_param[0]] = $url_param[1];
    }
}
$template->assign_vars(array('S_SEARCH_ACTION' => phpbb_gallery_url::append_sid('search', false, true, 0), 'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields), 'S_ALBUM_OPTIONS' => $s_albums, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_IN_SEARCH' => true));
page_header($user->lang['GALLERY'] . ' &bull; ' . $user->lang['SEARCH'], false);
$template->set_filenames(array('body' => 'gallery/search_body.html'));
page_footer();
 /**
  * BBCode-Template
  */
 function bbcode_tpl($value)
 {
     $gallery_url = phpbb_gallery_url::path('full');
     if ($value == 'highslide' && in_array('highslide', phpbb_gallery_plugins::$plugins)) {
         $bbcode_tpl = '<a class="highslide" onclick="return hs.expand(this)" href="' . $gallery_url . 'image.php?image_id={NUMBER}"><img src="' . $gallery_url . 'image.php?mode=thumbnail&amp;image_id={NUMBER}" alt="{NUMBER}" /></a>';
     } else {
         if ($value == 'lytebox' && in_array('lytebox', phpbb_gallery_plugins::$plugins)) {
             $bbcode_tpl = '<a class="image-resize" rel="lytebox" href="' . $gallery_url . 'image.php?image_id={NUMBER}"><img src="' . $gallery_url . 'image.php?mode=thumbnail&amp;image_id={NUMBER}" alt="{NUMBER}" /></a>';
         } else {
             if ($value == 'image_page') {
                 $bbcode_tpl = '<a href="' . $gallery_url . 'image_page.php?image_id={NUMBER}"><img src="' . $gallery_url . 'image.php?mode=thumbnail&amp;image_id={NUMBER}" alt="{NUMBER}" /></a>';
             } else {
                 $bbcode_tpl = '<a href="' . $gallery_url . 'image.php?image_id={NUMBER}"><img src="' . $gallery_url . 'image.php?mode=thumbnail&amp;image_id={NUMBER}" alt="{NUMBER}" /></a>';
             }
         }
     }
     return $bbcode_tpl;
 }
Exemplo n.º 10
0
    $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&amp;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&amp;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') . '&amp;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();
Exemplo n.º 11
0
                        $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}&amp;image_id={$image_id}") : '', 'U_VIEW_IMAGE' => $image_id ? phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&amp;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}&amp;" : '') . "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);
}
page_header($page_title, false);
$template->set_filenames(array('body' => 'gallery/posting_body.html'));
page_footer();
Exemplo n.º 12
0
    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'] . '&amp;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&amp;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')));
    }
    function main($id, $mode)
    {
        global $cache, $db, $user, $auth, $template;
        phpbb_gallery::init();
        $manage_albums = new phpbb_gallery_album_manage(request_var('user_id', 0), request_var('parent_id', 0), $this->u_action);
        $user->add_lang(array('mods/gallery_acp', 'mods/gallery'));
        $this->tpl_name = 'gallery_albums';
        $this->page_title = 'ACP_GALLERY_MANAGE_ALBUMS';
        $form_key = 'acp_gallery_albums';
        add_form_key($form_key);
        $action = request_var('action', '');
        $update = isset($_POST['update']) ? true : false;
        $album_id = request_var('a', 0);
        $this->parent_id = request_var('parent_id', 0);
        $album_data = $errors = array();
        if ($update && !check_form_key($form_key)) {
            $update = false;
            $errors[] = $user->lang['FORM_INVALID'];
        }
        // Major routines
        if ($update) {
            switch ($action) {
                case 'delete':
                    $action_subalbums = request_var('action_subalbums', '');
                    $subalbums_to_id = request_var('subalbums_to_id', 0);
                    $action_images = request_var('action_images', '');
                    $images_to_id = request_var('images_to_id', 0);
                    $errors = $manage_albums->delete_album($album_id, $action_images, $action_subalbums, $images_to_id, $subalbums_to_id);
                    if (sizeof($errors)) {
                        break;
                    }
                    $cache->destroy('sql', GALLERY_ALBUMS_TABLE);
                    trigger_error($user->lang['ALBUM_DELETED'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
                    break;
                case 'edit':
                    $album_data = array('album_id' => $album_id);
                    // No break; here
                // No break; here
                case 'add':
                    $album_data += array('parent_id' => request_var('album_parent_id', $this->parent_id), 'album_type' => request_var('album_type', phpbb_gallery_album::TYPE_UPLOAD), 'type_action' => request_var('type_action', ''), 'album_status' => request_var('album_status', phpbb_gallery_album::STATUS_OPEN), 'album_parents' => '', 'album_name' => utf8_normalize_nfc(request_var('album_name', '', true)), 'album_desc' => utf8_normalize_nfc(request_var('album_desc', '', true)), 'album_desc_uid' => '', 'album_desc_options' => 7, 'album_desc_bitfield' => '', 'album_image' => request_var('album_image', ''), 'album_watermark' => request_var('album_watermark', false), 'album_sort_key' => request_var('album_sort_key', ''), 'album_sort_dir' => request_var('album_sort_dir', ''), 'display_subalbum_list' => request_var('display_subalbum_list', false), 'display_on_index' => request_var('display_on_index', false), 'display_in_rrc' => request_var('display_in_rrc', false));
                    // Categories are not able to be locked...
                    if ($album_data['album_type'] == phpbb_gallery_album::TYPE_CAT) {
                        $album_data['album_status'] = phpbb_gallery_album::STATUS_OPEN;
                    }
                    // Contests need contest_data, freaky... :-O
                    $contest_data = array('contest_start' => request_var('contest_start', ''), 'contest_rating' => request_var('contest_rating', ''), 'contest_end' => request_var('contest_end', ''));
                    // Get data for album description if specified
                    if ($album_data['album_desc']) {
                        generate_text_for_storage($album_data['album_desc'], $album_data['album_desc_uid'], $album_data['album_desc_bitfield'], $album_data['album_desc_options'], request_var('desc_parse_bbcode', false), request_var('desc_parse_urls', false), request_var('desc_parse_smilies', false));
                    }
                    $errors = $manage_albums->update_album_data($album_data, $contest_data);
                    if (!sizeof($errors)) {
                        $album_perm_from = request_var('album_perm_from', 0);
                        // Copy permissions? You do not need permissions for that in the gallery
                        if ($album_perm_from && $album_perm_from != $album_data['album_id']) {
                            // If we edit a album delete current permissions first
                            if ($action == 'edit') {
                                $sql = 'DELETE FROM ' . GALLERY_PERMISSIONS_TABLE . '
									WHERE perm_album_id = ' . $album_data['album_id'];
                                $db->sql_query($sql);
                                $sql = 'DELETE FROM ' . GALLERY_MODSCACHE_TABLE . '
									WHERE album_id = ' . $album_data['album_id'];
                                $db->sql_query($sql);
                            }
                            $sql = 'SELECT *
								FROM ' . GALLERY_PERMISSIONS_TABLE . '
								WHERE perm_album_id = ' . $album_perm_from;
                            $result = $db->sql_query($sql);
                            while ($row = $db->sql_fetchrow($result)) {
                                $perm_data[] = array('perm_role_id' => $row['perm_role_id'], 'perm_album_id' => $album_data['album_id'], 'perm_user_id' => $row['perm_user_id'], 'perm_group_id' => $row['perm_group_id'], 'perm_system' => $row['perm_system']);
                            }
                            $db->sql_freeresult($result);
                            $modscache_ary = array();
                            $sql = 'SELECT * FROM ' . GALLERY_MODSCACHE_TABLE . '
								WHERE album_id = ' . $album_perm_from;
                            $result = $db->sql_query($sql);
                            while ($row = $db->sql_fetchrow($result)) {
                                $modscache_ary[] = array('album_id' => $album_data['album_id'], 'user_id' => $row['user_id'], 'username' => $row['username'], 'group_id' => $row['group_id'], 'group_name' => $row['group_name'], 'display_on_index' => $row['display_on_index']);
                            }
                            $db->sql_freeresult($result);
                            $db->sql_multi_insert(GALLERY_PERMISSIONS_TABLE, $perm_data);
                            $db->sql_multi_insert(GALLERY_MODSCACHE_TABLE, $modscache_ary);
                        }
                        $cache->destroy('sql', GALLERY_ALBUMS_TABLE);
                        $cache->destroy('sql', GALLERY_MODSCACHE_TABLE);
                        $cache->destroy('sql', GALLERY_PERMISSIONS_TABLE);
                        $cache->destroy('_albums');
                        phpbb_gallery_auth::set_user_permissions('all', '');
                        $acl_url = '&amp;mode=manage&amp;action=v_mask&amp;album_id[]=' . $album_data['album_id'];
                        $message = $action == 'add' ? $user->lang['ALBUM_CREATED'] : $user->lang['ALBUM_UPDATED'];
                        $message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . phpbb_gallery_url::append_sid('admin', 'index', 'i=gallery_permissions' . $acl_url) . '">', '</a>');
                        // Redirect directly to permission settings screen
                        if ($action == 'add' && !$album_perm_from) {
                            meta_refresh(5, phpbb_gallery_url::append_sid('admin', 'index', 'i=gallery_permissions' . $acl_url));
                        }
                        trigger_error($message . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
                    }
                    break;
            }
        }
        switch ($action) {
            case 'move_up':
            case 'move_down':
                if (!$album_id) {
                    trigger_error($user->lang['NO_ALBUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
                }
                $sql = 'SELECT *
					FROM ' . GALLERY_ALBUMS_TABLE . "\n\t\t\t\t\tWHERE album_id = {$album_id}";
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if (!$row) {
                    trigger_error($user->lang['NO_ALBUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
                }
                $move_album_name = $manage_albums->move_album_by($row, $action, 1);
                if ($move_album_name !== false) {
                    add_log('admin', 'LOG_ALBUM_' . strtoupper($action), $row['album_name'], $move_album_name);
                    $cache->destroy('sql', GALLERY_ALBUMS_TABLE);
                }
                break;
            case 'sync':
            case 'sync_album':
                if (!$album_id) {
                    trigger_error($user->lang['NO_ALBUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
                }
                $sql = 'SELECT album_name, album_type
					FROM ' . GALLERY_ALBUMS_TABLE . "\n\t\t\t\t\tWHERE album_id = {$album_id}";
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if (!$row) {
                    trigger_error($user->lang['NO_ALBUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
                }
                phpbb_gallery_album::update_info($album_id);
                add_log('admin', 'LOG_ALBUM_SYNC', $row['album_name']);
                $template->assign_var('L_ALBUM_RESYNCED', sprintf($user->lang['ALBUM_RESYNCED'], $row['album_name']));
                break;
            case 'add':
            case 'edit':
                // Show form to create/modify a album
                if ($action == 'edit') {
                    $this->page_title = 'EDIT_ALBUM';
                    $row = phpbb_gallery_album::get_info($album_id);
                    $old_album_type = $row['album_type'];
                    if (!$update) {
                        $album_data = $row;
                    } else {
                        $album_data['left_id'] = $row['left_id'];
                        $album_data['right_id'] = $row['right_id'];
                    }
                    if ($row['album_type'] == phpbb_gallery_album::TYPE_CONTEST) {
                        $contest_data = $this->get_contest_info('album', $album_id);
                    } else {
                        // Default values, 3 days later rate and 7 for the end of the contest
                        $contest_data = array('contest_start' => time(), 'contest_rating' => 3 * 86400, 'contest_end' => 7 * 86400);
                    }
                    // Make sure no direct child albums are able to be selected as parents.
                    $exclude_albums = array();
                    foreach (phpbb_gallery_album::get_branch(phpbb_gallery_album::PUBLIC_ALBUM, $album_id, 'children') as $row) {
                        $exclude_albums[] = $row['album_id'];
                    }
                    $parents_list = phpbb_gallery_album::get_albumbox(true, '', $album_data['parent_id'], false, $exclude_albums);
                    /*
                    $album_data['album_password_confirm'] = $album_data['album_password'];
                    */
                } else {
                    $this->page_title = 'CREATE_ALBUM';
                    $album_id = $this->parent_id;
                    $parents_list = phpbb_gallery_album::get_albumbox(true, '', $this->parent_id);
                    // Fill album data with default values
                    if (!$update) {
                        $album_data = array('parent_id' => $this->parent_id, 'album_type' => phpbb_gallery_album::TYPE_UPLOAD, 'album_status' => phpbb_gallery_album::STATUS_OPEN, 'album_name' => utf8_normalize_nfc(request_var('album_name', '', true)), 'album_desc' => '', 'album_image' => '', 'album_watermark' => true, 'album_sort_key' => '', 'album_sort_dir' => '', 'display_subalbum_list' => true, 'display_on_index' => true, 'display_in_rrc' => true);
                        // Default values, 3 days later rate and 7 for the end of the contest
                        $contest_data = array('contest_start' => time(), 'contest_rating' => 3 * 86400, 'contest_end' => 7 * 86400);
                    }
                }
                $album_desc_data = array('text' => $album_data['album_desc'], 'allow_bbcode' => true, 'allow_smilies' => true, 'allow_urls' => true);
                // Parse desciption if specified
                if ($album_data['album_desc']) {
                    if (!isset($album_data['album_desc_uid'])) {
                        // Before we are able to display the preview and plane text, we need to parse our request_var()'d value...
                        $album_data['album_desc_uid'] = '';
                        $album_data['album_desc_bitfield'] = '';
                        $album_data['album_desc_options'] = 0;
                        generate_text_for_storage($album_data['album_desc'], $album_data['album_desc_uid'], $album_data['album_desc_bitfield'], $album_data['album_desc_options'], request_var('desc_allow_bbcode', false), request_var('desc_allow_urls', false), request_var('desc_allow_smilies', false));
                    }
                    // decode...
                    $album_desc_data = generate_text_for_edit($album_data['album_desc'], $album_data['album_desc_uid'], $album_data['album_desc_options']);
                }
                $album_type_options = '';
                $album_type_ary = array(phpbb_gallery_album::TYPE_CAT => 'CAT', phpbb_gallery_album::TYPE_UPLOAD => 'UPLOAD', phpbb_gallery_album::TYPE_CONTEST => 'CONTEST');
                foreach ($album_type_ary as $value => $lang) {
                    $album_type_options .= '<option value="' . $value . '"' . ($value == $album_data['album_type'] ? ' selected="selected"' : '') . '>' . $user->lang['ALBUM_TYPE_' . $lang] . '</option>';
                }
                $album_sort_key_options = '';
                $album_sort_key_options .= '<option' . (!in_array($album_data['album_sort_key'], array('t', 'n', 'vc', 'u', 'ra', 'r', 'c', 'lc')) ? ' selected="selected"' : '') . " value=''>" . $user->lang['SORT_DEFAULT'] . '</option>';
                $album_sort_key_options .= '<option' . ($album_data['album_sort_key'] == 't' ? ' selected="selected"' : '') . " value='t'>" . $user->lang['TIME'] . '</option>';
                $album_sort_key_options .= '<option' . ($album_data['album_sort_key'] == 'n' ? ' selected="selected"' : '') . " value='n'>" . $user->lang['IMAGE_NAME'] . '</option>';
                $album_sort_key_options .= '<option' . ($album_data['album_sort_key'] == 'vc' ? ' selected="selected"' : '') . " value='vc'>" . $user->lang['VIEWS'] . '</option>';
                $album_sort_key_options .= '<option' . ($album_data['album_sort_key'] == 'u' ? ' selected="selected"' : '') . " value='u'>" . $user->lang['USERNAME'] . '</option>';
                $album_sort_key_options .= '<option' . ($album_data['album_sort_key'] == 'ra' ? ' selected="selected"' : '') . " value='ra'>" . $user->lang['RATING'] . '</option>';
                $album_sort_key_options .= '<option' . ($album_data['album_sort_key'] == 'r' ? ' selected="selected"' : '') . " value='r'>" . $user->lang['RATES_COUNT'] . '</option>';
                $album_sort_key_options .= '<option' . ($album_data['album_sort_key'] == 'c' ? ' selected="selected"' : '') . " value='c'>" . $user->lang['COMMENTS'] . '</option>';
                $album_sort_key_options .= '<option' . ($album_data['album_sort_key'] == 'lc' ? ' selected="selected"' : '') . " value='lc'>" . $user->lang['NEW_COMMENT'] . '</option>';
                $album_sort_dir_options = '';
                $album_sort_dir_options .= '<option' . ($album_data['album_sort_dir'] != 'd' && $album_data['album_sort_dir'] != 'a' ? ' selected="selected"' : '') . " value=''>" . $user->lang['SORT_DEFAULT'] . '</option>';
                $album_sort_dir_options .= '<option' . ($album_data['album_sort_dir'] == 'd' ? ' selected="selected"' : '') . " value='d'>" . $user->lang['SORT_DESCENDING'] . '</option>';
                $album_sort_dir_options .= '<option' . ($album_data['album_sort_dir'] == 'a' ? ' selected="selected"' : '') . " value='a'>" . $user->lang['SORT_ASCENDING'] . '</option>';
                $statuslist = '<option value="' . phpbb_gallery_album::STATUS_OPEN . '"' . ($album_data['album_status'] == phpbb_gallery_album::STATUS_OPEN ? ' selected="selected"' : '') . '>' . $user->lang['UNLOCKED'] . '</option><option value="' . phpbb_gallery_album::STATUS_LOCKED . '"' . ($album_data['album_status'] == phpbb_gallery_album::STATUS_LOCKED ? ' selected="selected"' : '') . '>' . $user->lang['LOCKED'] . '</option>';
                $sql = 'SELECT album_id
					FROM ' . GALLERY_ALBUMS_TABLE . '
					WHERE album_type = ' . phpbb_gallery_album::TYPE_UPLOAD . '
						AND album_user_id = ' . phpbb_gallery_album::PUBLIC_ALBUM . "\n\t\t\t\t\t\tAND album_id <> {$album_id}";
                $result = $db->sql_query_limit($sql, 1);
                $uploadable_album_exists = false;
                if ($db->sql_fetchrow($result)) {
                    $uploadable_album_exists = true;
                }
                $db->sql_freeresult($result);
                // Subalbum move options
                if ($action == 'edit' && in_array($album_data['album_type'], array(phpbb_gallery_album::TYPE_UPLOAD, phpbb_gallery_album::TYPE_CONTEST))) {
                    $subalbums_id = array();
                    $subalbums = phpbb_gallery_album::get_branch(phpbb_gallery_album::PUBLIC_ALBUM, $album_id, 'children');
                    foreach ($subalbums as $row) {
                        $subalbums_id[] = $row['album_id'];
                    }
                    $albums_list = phpbb_gallery_album::get_albumbox(true, '', $album_data['parent_id'], false, $subalbums_id);
                    if ($uploadable_album_exists) {
                        $template->assign_vars(array('S_MOVE_ALBUM_OPTIONS' => phpbb_gallery_album::get_albumbox(true, '', $album_data['parent_id'], false, $subalbums_id, phpbb_gallery_album::PUBLIC_ALBUM, phpbb_gallery_album::TYPE_UPLOAD)));
                    }
                    $template->assign_vars(array('S_HAS_SUBALBUMS' => $album_data['right_id'] - $album_data['left_id'] > 1 ? true : false, 'S_ALBUMS_LIST' => $albums_list));
                } elseif ($uploadable_album_exists) {
                    $template->assign_vars(array('S_MOVE_ALBUM_OPTIONS' => phpbb_gallery_album::get_albumbox(true, '', $album_data['parent_id'], false, $album_id, 0, phpbb_gallery_album::TYPE_UPLOAD)));
                }
                /*
                if (strlen($album_data['album_password']) == 32)
                {
                	$errors[] = $user->lang['ALBUM_PASSWORD_OLD'];
                }
                */
                $template->assign_vars(array('S_EDIT_ALBUM' => true, 'S_ERROR' => sizeof($errors) ? true : false, 'S_PARENT_ID' => $this->parent_id, 'S_ALBUM_PARENT_ID' => $album_data['parent_id'], 'S_ADD_ACTION' => $action == 'add' ? true : false, 'U_BACK' => $this->u_action . '&amp;parent_id=' . $this->parent_id, 'U_EDIT_ACTION' => $this->u_action . "&amp;parent_id={$this->parent_id}&amp;action={$action}&amp;a={$album_id}", 'L_COPY_PERMISSIONS_EXPLAIN' => $user->lang['COPY_PERMISSIONS_' . strtoupper($action) . '_EXPLAIN'], 'L_TITLE' => $user->lang[$this->page_title], 'ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : '', 'ALBUM_NAME' => $album_data['album_name'], 'ALBUM_IMAGE' => $album_data['album_image'], 'ALBUM_IMAGE_SRC' => $album_data['album_image'] ? phpbb_gallery_url::path('phpbb') . $album_data['album_image'] : '', 'ALBUM_DESC' => $album_desc_data['text'], 'S_DESC_BBCODE_CHECKED' => $album_desc_data['allow_bbcode'] ? true : false, 'S_DESC_SMILIES_CHECKED' => $album_desc_data['allow_smilies'] ? true : false, 'S_DESC_URLS_CHECKED' => $album_desc_data['allow_urls'] ? true : false, 'S_ALBUM_TYPE_OPTIONS' => $album_type_options, 'S_STATUS_OPTIONS' => $statuslist, 'S_PARENT_OPTIONS' => $parents_list, 'S_ALBUM_OPTIONS' => phpbb_gallery_album::get_albumbox(true, '', $action == 'add' ? $album_data['parent_id'] : false, false, $action == 'edit' ? $album_data['album_id'] : false), 'S_ALBUM_ORIG_UPLOAD' => isset($old_album_type) && $old_album_type == phpbb_gallery_album::TYPE_UPLOAD ? true : false, 'S_ALBUM_ORIG_CAT' => isset($old_album_type) && $old_album_type == phpbb_gallery_album::TYPE_CAT ? true : false, 'S_ALBUM_ORIG_CONTEST' => isset($old_album_type) && $old_album_type == phpbb_gallery_album::TYPE_CONTEST ? true : false, 'S_ALBUM_UPLOAD' => $album_data['album_type'] == phpbb_gallery_album::TYPE_UPLOAD ? true : false, 'S_ALBUM_CAT' => $album_data['album_type'] == phpbb_gallery_album::TYPE_CAT ? true : false, 'S_ALBUM_CONTEST' => $album_data['album_type'] == phpbb_gallery_album::TYPE_CONTEST ? true : false, 'ALBUM_UPLOAD' => phpbb_gallery_album::TYPE_UPLOAD, 'ALBUM_CAT' => phpbb_gallery_album::TYPE_CAT, 'ALBUM_CONTEST' => phpbb_gallery_album::TYPE_CONTEST, 'S_CAN_COPY_PERMISSIONS' => true, 'S_ALBUM_WATERMARK' => $album_data['album_watermark'] ? true : false, 'ALBUM_SORT_KEY_OPTIONS' => $album_sort_key_options, 'ALBUM_SORT_DIR_OPTIONS' => $album_sort_dir_options, 'S_DISPLAY_SUBALBUM_LIST' => $album_data['display_subalbum_list'] ? true : false, 'S_DISPLAY_ON_INDEX' => $album_data['display_on_index'] ? true : false, 'S_DISPLAY_IN_RRC' => $album_data['display_in_rrc'] ? true : false, 'S_CONTEST_START' => $user->format_date($contest_data['contest_start'], 'Y-m-d H:i'), 'CONTEST_RATING' => $user->format_date($contest_data['contest_start'] + $contest_data['contest_rating'], 'Y-m-d H:i'), 'CONTEST_END' => $user->format_date($contest_data['contest_start'] + $contest_data['contest_end'], 'Y-m-d H:i')));
                return;
                break;
            case 'delete':
                if (!$album_id) {
                    trigger_error($user->lang['NO_ALBUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
                }
                $album_data = phpbb_gallery_album::get_info($album_id);
                $subalbums_id = array();
                $subalbums = phpbb_gallery_album::get_branch(phpbb_gallery_album::PUBLIC_ALBUM, $album_id, 'children');
                foreach ($subalbums as $row) {
                    $subalbums_id[] = $row['album_id'];
                }
                $albums_list = phpbb_gallery_album::get_albumbox(true, '', $album_data['parent_id'], false, $subalbums_id);
                $sql = 'SELECT album_id
					FROM ' . GALLERY_ALBUMS_TABLE . '
					WHERE album_type = ' . phpbb_gallery_album::TYPE_UPLOAD . "\n\t\t\t\t\t\tAND album_id <> {$album_id}\n\t\t\t\t\t\tAND album_user_id = " . phpbb_gallery_album::PUBLIC_ALBUM;
                $result = $db->sql_query_limit($sql, 1);
                if ($db->sql_fetchrow($result)) {
                    $template->assign_vars(array('S_MOVE_ALBUM_OPTIONS' => phpbb_gallery_album::get_albumbox(true, '', $album_data['parent_id'], false, $subalbums_id, phpbb_gallery_album::PUBLIC_ALBUM, phpbb_gallery_album::TYPE_UPLOAD)));
                }
                $db->sql_freeresult($result);
                $parent_id = $this->parent_id == $album_id ? 0 : $this->parent_id;
                $template->assign_vars(array('S_DELETE_ALBUM' => true, 'U_ACTION' => $this->u_action . "&amp;parent_id={$parent_id}&amp;action=delete&amp;a=" . $album_id, 'U_BACK' => $this->u_action . '&amp;parent_id=' . $this->parent_id, 'ALBUM_NAME' => $album_data['album_name'], 'S_ALBUM_POST' => in_array($album_data['album_type'], array(phpbb_gallery_album::TYPE_UPLOAD, phpbb_gallery_album::TYPE_CONTEST)) ? true : false, 'S_HAS_SUBALBUMS' => $album_data['right_id'] - $album_data['left_id'] > 1 ? true : false, 'S_ALBUMS_LIST' => $albums_list, 'S_ERROR' => sizeof($errors) ? true : false, 'ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : ''));
                return;
                break;
        }
        // Default management page
        if (!$this->parent_id) {
            $navigation = $user->lang['GALLERY_INDEX'];
        } else {
            $navigation = '<a href="' . $this->u_action . '">' . $user->lang['GALLERY_INDEX'] . '</a>';
            $albums_nav = phpbb_gallery_album::get_branch(phpbb_gallery_album::PUBLIC_ALBUM, $this->parent_id, 'parents', 'descending');
            foreach ($albums_nav as $row) {
                if ($row['album_id'] == $this->parent_id) {
                    $navigation .= ' -&gt; ' . $row['album_name'];
                } else {
                    $navigation .= ' -&gt; <a href="' . $this->u_action . '&amp;parent_id=' . $row['album_id'] . '">' . $row['album_name'] . '</a>';
                }
            }
        }
        // Jumpbox
        $album_box = phpbb_gallery_album::get_albumbox(true, '', $this->parent_id, false, false);
        if ($action == 'sync' || $action == 'sync_album') {
            $template->assign_var('S_RESYNCED', true);
        }
        $sql = 'SELECT *
			FROM ' . GALLERY_ALBUMS_TABLE . "\n\t\t\tWHERE parent_id = {$this->parent_id}\n\t\t\t\tAND album_user_id = " . phpbb_gallery_album::PUBLIC_ALBUM . '
			ORDER BY left_id';
        $result = $db->sql_query($sql);
        if ($row = $db->sql_fetchrow($result)) {
            do {
                $album_type = $row['album_type'];
                if ($row['album_status'] == phpbb_gallery_album::STATUS_LOCKED) {
                    $folder_image = '<img src="images/icon_folder_lock.gif" alt="' . $user->lang['LOCKED'] . '" />';
                } else {
                    $folder_image = $row['left_id'] + 1 != $row['right_id'] ? '<img src="images/icon_subfolder.gif" alt="' . $user->lang['SUBALBUM'] . '" />' : '<img src="images/icon_folder.gif" alt="' . $user->lang['FOLDER'] . '" />';
                }
                $url = $this->u_action . "&amp;parent_id={$this->parent_id}&amp;a={$row['album_id']}";
                $template->assign_block_vars('albums', array('FOLDER_IMAGE' => $folder_image, 'ALBUM_IMAGE' => $row['album_image'] ? '<img src="' . phpbb_gallery_url::path('phpbb') . $row['album_image'] . '" alt="" />' : '', 'ALBUM_IMAGE_SRC' => $row['album_image'] ? phpbb_gallery_url::path('phpbb') . $row['album_image'] : '', 'ALBUM_NAME' => $row['album_name'], 'ALBUM_DESCRIPTION' => generate_text_for_display($row['album_desc'], $row['album_desc_uid'], $row['album_desc_bitfield'], $row['album_desc_options']), 'ALBUM_IMAGES' => $row['album_images'], 'S_ALBUM_POST' => $album_type != phpbb_gallery_album::TYPE_CAT ? true : false, 'U_ALBUM' => $this->u_action . '&amp;parent_id=' . $row['album_id'], 'U_MOVE_UP' => $url . '&amp;action=move_up', 'U_MOVE_DOWN' => $url . '&amp;action=move_down', 'U_EDIT' => $url . '&amp;action=edit', 'U_DELETE' => $url . '&amp;action=delete', 'U_SYNC' => $url . '&amp;action=sync'));
            } while ($row = $db->sql_fetchrow($result));
        } else {
            if ($this->parent_id) {
                $row = get_album_info($this->parent_id);
                $url = $this->u_action . '&amp;parent_id=' . $this->parent_id . '&amp;a=' . $row['album_id'];
                $template->assign_vars(array('S_NO_ALBUMS' => true, 'U_EDIT' => $url . '&amp;action=edit', 'U_DELETE' => $url . '&amp;action=delete', 'U_SYNC' => $url . '&amp;action=sync'));
            }
        }
        $db->sql_freeresult($result);
        $template->assign_vars(array('ERROR_MSG' => sizeof($errors) ? implode('<br />', $errors) : '', 'NAVIGATION' => $navigation, 'ALBUM_BOX' => $album_box, 'U_SEL_ACTION' => $this->u_action, 'U_ACTION' => $this->u_action . '&amp;parent_id=' . $this->parent_id, 'U_PROGRESS_BAR' => $this->u_action . '&amp;action=progress_bar', 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&amp;action=progress_bar')));
    }
Exemplo n.º 14
0
 public static function viewonline($on_page, $album_id, $session_page)
 {
     static $album_data;
     global $template, $user, $location, $location_url;
     // Initial load of some needed stuff, like permissions, album data, ...
     phpbb_gallery::init();
     if (empty($album_data)) {
         global $cache;
         $user->add_lang(array('mods/info_acp_gallery', 'mods/gallery'));
         $album_data = $cache->obtain_album_list();
     }
     // Handle user location
     $location = $user->lang['GALLERY'];
     $location_url = phpbb_gallery_url::append_sid('index');
     if ($album_id && phpbb_gallery::$auth->acl_check('i_view', $album_id)) {
         switch ($on_page[1]) {
             case phpbb_gallery_url::path('relative') . 'album':
                 $location = sprintf($user->lang['VIEWING_ALBUM'], $album_data[$album_id]['album_name']);
                 $location_url = phpbb_gallery_url::append_sid('album', 'album_id=' . $album_id);
                 break;
             case phpbb_gallery_url::path('relative') . 'image_page':
             case phpbb_gallery_url::path('relative') . 'image':
                 $location = sprintf($user->lang['VIEWING_IMAGE'], $album_data[$album_id]['album_name']);
                 $location_url = phpbb_gallery_url::append_sid('album', 'album_id=' . $album_id);
                 break;
             case phpbb_gallery_url::path('relative') . 'posting':
                 preg_match('#mode=([a-z]+)#', $session_page, $on_page);
                 $on_page = sizeof($on_page) ? $on_page[1] : '';
                 switch ($on_page) {
                     case 'comment':
                         $location = sprintf($user->lang['COMMENT_IMAGE'], $album_data[$album_id]['album_name']);
                         break;
                     default:
                         $location = sprintf($user->lang['VIEWING_ALBUM'], $album_data[$album_id]['album_name']);
                         break;
                 }
                 $location_url = phpbb_gallery_url::append_sid('album', 'album_id=' . $album_id);
                 break;
         }
     } else {
         preg_match('#mode=([a-z]+)#', $session_page, $on_page);
         $on_page = sizeof($on_page) ? $on_page[1] : '';
         if ($on_page == 'personal' && phpbb_gallery::$auth->acl_check('i_view', PERSONAL_GALLERY_PERMISSIONS)) {
             $location = $user->lang['PERSONAL_ALBUMS'];
             $location_url = phpbb_gallery_url::append_sid('index', 'mode=personal');
         }
     }
 }
Exemplo n.º 15
0
                $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . '
					SET image_reported = ' . phpbb_gallery_constants::REPORT_UNREPORT . '
					WHERE ' . $db->sql_in_set('image_reported', $image_id_ary);
                $db->sql_query($sql);
                $success = true;
            } else {
                confirm_box(false, 'REPORT' . $multiple . '_A_DELETE2', $s_hidden_fields);
            }
            break;
    }
    if (isset($success)) {
        phpbb_gallery_album::update_info($album_id);
        if ($moving_target) {
            phpbb_gallery_album::update_info($moving_target);
        }
        redirect($redirect == 'redirect' ? phpbb_gallery_url::append_sid('album', "album_id={$album_id}") : phpbb_gallery_url::append_sid('mcp', "mode={$mode}&amp;album_id={$album_id}"));
    }
}
// end if ($action && $image_id_ary)
switch ($mode) {
    case 'album':
        phpbb_gallery_mcp::album($mode, $album_id, $album_data);
        break;
    case 'report_open':
    case 'report_closed':
        phpbb_gallery_mcp::report($mode, $album_id, $album_data);
        break;
    case 'queue_unapproved':
    case 'queue_approved':
    case 'queue_locked':
        phpbb_gallery_mcp::queue($mode, $album_id, $album_data);
    function permissions_p_mask()
    {
        global $cache, $db, $permissions, $template, $user;
        $user->add_lang('acp/permissions');
        if (!check_form_key('acp_gallery')) {
            trigger_error('FORM_INVALID');
        }
        $submit = isset($_POST['submit']) ? true : false;
        $delete = isset($_POST['delete']) ? true : false;
        $album_id = request_var('album_id', array(0));
        $group_id = request_var('group_id', array(0));
        $user_id = request_var('user_id', array(0));
        $username = request_var('username', array(''), true);
        $usernames = request_var('usernames', '', true);
        $p_system = request_var('p_system', 0);
        // Map usernames to ids and vice versa
        if ($usernames) {
            $username = explode("\n", $usernames);
        }
        unset($usernames);
        if (sizeof($username) && !sizeof($user_id)) {
            if (!function_exists('user_get_id_name')) {
                phpbb_gallery_url::_include('functions_user', 'phpbb');
            }
            user_get_id_name($user_id, $username);
            if (!sizeof($user_id)) {
                trigger_error($user->lang['SELECTED_USER_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
            }
        }
        unset($username);
        if (!sizeof($group_id) && !sizeof($user_id)) {
            trigger_error('NO_VICTIM_SELECTED', E_USER_WARNING);
        } elseif (sizeof($group_id)) {
            $victim_mode = 'group';
            $victim_id = $group_id;
        } else {
            $victim_mode = 'user';
            $victim_id = $user_id;
        }
        // Create the loops for the javascript
        for ($i = 0; $i < sizeof($permissions->cats[$p_system]); $i++) {
            $template->assign_block_vars('c_rows', array());
        }
        if ($victim_mode == 'group') {
            // Get the group information
            $sql = 'SELECT group_name, group_id, group_type, group_colour
				FROM ' . GROUPS_TABLE . '
				WHERE ' . $db->sql_in_set('group_id', $victim_id);
            $result = $db->sql_query($sql);
            $victim_list = array();
            while ($row = $db->sql_fetchrow($result)) {
                $row['group_name'] = $row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
                $victim_row = array('victim_id' => $row['group_id'], 'victim_name' => $row['group_name'], 'victim_colour' => $row['group_colour']);
                $victim_list[$row['group_id']] = $victim_row;
            }
            $db->sql_freeresult($result);
        } else {
            // Get the user information
            $sql = 'SELECT username, user_id, user_colour
				FROM ' . USERS_TABLE . '
				WHERE ' . $db->sql_in_set('user_id', $victim_id);
            $result = $db->sql_query($sql);
            $victim_list = array();
            while ($row = $db->sql_fetchrow($result)) {
                $victim_row = array('victim_id' => $row['user_id'], 'victim_name' => $row['username'], 'victim_colour' => $row['user_colour']);
                $victim_list[$row['user_id']] = $victim_row;
            }
            $db->sql_freeresult($result);
        }
        // Fetch the full-permissions-tree
        $sql = 'SELECT perm_role_id, perm_group_id, perm_user_id, perm_album_id
			FROM ' . GALLERY_PERMISSIONS_TABLE . '
			WHERE ' . (!$p_system ? $db->sql_in_set('perm_album_id', $album_id) : $db->sql_in_set('perm_system', $p_system)) . '
				AND ' . $db->sql_in_set('perm_' . $victim_mode . '_id', $victim_id);
        $result = $db->sql_query($sql);
        $p_masks = $fetch_roles = array();
        while ($row = $db->sql_fetchrow($result)) {
            $fetch_roles[] = $row['perm_role_id'];
            $p_masks[!$p_system ? $row['perm_album_id'] : $p_system][$row['perm_' . $victim_mode . '_id']] = $row['perm_role_id'];
        }
        $db->sql_freeresult($result);
        // Fetch the roles
        $roles = array();
        if (!empty($fetch_roles)) {
            $sql = 'SELECT *
				FROM ' . GALLERY_ROLES_TABLE . '
				WHERE ' . $db->sql_in_set('role_id', $fetch_roles);
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $roles[$row['role_id']] = $row;
            }
            $db->sql_freeresult($result);
        }
        // Album permissions
        if (!$p_system) {
            $album_list = $cache->obtain_album_list();
            foreach ($album_id as $album) {
                $album_row = $album_list[$album];
                $template->assign_block_vars('c_mask', array('C_MASK_ID' => $album_row['album_id'], 'C_MASK_NAME' => $album_row['album_name'], 'INHERIT_C_MASKS' => $this->inherit_albums($album_list, $album_id, $album_row['album_id'])));
                foreach ($victim_id as $victim) {
                    $victim_row = $victim_list[$victim];
                    $template->assign_block_vars('c_mask.v_mask', array('VICTIM_ID' => $victim_row['victim_id'], 'VICTIM_NAME' => '<span' . ($victim_row['victim_colour'] ? ' style="color: #' . $victim_row['victim_colour'] . '"' : '') . '>' . $victim_row['victim_name'] . '</span>', 'INHERIT_VICTIMS' => $this->inherit_victims($album_list, $album_id, $victim_list, $album_row['album_id'], $victim_row['victim_id'])));
                    $role_id = isset($p_masks[$album_row['album_id']][$victim_row['victim_id']]) ? $p_masks[$album_row['album_id']][$victim_row['victim_id']] : 0;
                    foreach ($permissions->cats[$p_system] as $category => $permission_values) {
                        $acl_s_never = $acl_s_no = $acl_s_yes = 0;
                        foreach ($permission_values as $permission) {
                            if (substr($permission, -6, 6) != '_count') {
                                if (isset($roles[$role_id][$permission]) && $roles[$role_id][$permission] == phpbb_gallery_auth::ACL_YES) {
                                    $acl_s_yes++;
                                } else {
                                    if (isset($roles[$role_id][$permission]) && $roles[$role_id][$permission] == phpbb_gallery_auth::ACL_NEVER) {
                                        $acl_s_never++;
                                    } else {
                                        if (isset($roles[$role_id][$permission]) && $roles[$role_id][$permission] == phpbb_gallery_auth::ACL_NO) {
                                            $acl_s_no++;
                                        }
                                    }
                                }
                            }
                        }
                        $template->assign_block_vars('c_mask.v_mask.category', array('CAT_NAME' => $user->lang['PERMISSION_' . strtoupper($category)], 'PERM_GROUP_ID' => $category, 'S_YES' => $acl_s_yes && !$acl_s_never && !$acl_s_no ? true : false, 'S_NEVER' => $acl_s_never && !$acl_s_yes && !$acl_s_no ? true : false, 'S_NO' => $acl_s_no && !$acl_s_never && !$acl_s_yes ? true : false));
                        foreach ($permission_values as $permission) {
                            $template->assign_block_vars('c_mask.v_mask.category.mask', array('PERMISSION' => $user->lang['PERMISSION_' . strtoupper($permission)], 'PERMISSION_EXPLAIN' => isset($user->lang['PERMISSION_' . strtoupper($permission) . '_EXPLAIN']) ? $user->lang['PERMISSION_' . strtoupper($permission) . '_EXPLAIN'] : '', 'S_FIELD_NAME' => 'setting[' . $album_row['album_id'] . '][' . $victim_row['victim_id'] . '][' . $permission . ']', 'S_NO' => isset($roles[$role_id][$permission]) && $roles[$role_id][$permission] == phpbb_gallery_auth::ACL_NO ? true : false, 'S_YES' => isset($roles[$role_id][$permission]) && $roles[$role_id][$permission] == phpbb_gallery_auth::ACL_YES ? true : false, 'S_NEVER' => isset($roles[$role_id][$permission]) && $roles[$role_id][$permission] == phpbb_gallery_auth::ACL_NEVER ? true : false, 'S_VALUE' => isset($roles[$role_id][$permission]) ? $roles[$role_id][$permission] : 0, 'S_COUNT_FIELD' => substr($permission, -6, 6) == '_count' ? true : false));
                        }
                    }
                }
            }
        } else {
            $template->assign_block_vars('c_mask', array('C_MASK_ID' => $p_system, 'C_MASK_NAME' => $p_system == phpbb_gallery_auth::OWN_ALBUM ? $user->lang['OWN_PERSONAL_ALBUMS'] : $user->lang['PERSONAL_ALBUMS']));
            foreach ($victim_id as $victim) {
                $victim_row = $victim_list[$victim];
                $template->assign_block_vars('c_mask.v_mask', array('VICTIM_ID' => $victim_row['victim_id'], 'VICTIM_NAME' => '<span' . ($victim_row['victim_colour'] ? ' style="color: #' . $victim_row['victim_colour'] . '"' : '') . '>' . $victim_row['victim_name'] . '</span>', 'INHERIT_VICTIMS' => $this->p_system_inherit_victims($p_system, $victim_list, $victim_row['victim_id'])));
                $role_id = isset($p_masks[$p_system][$victim_row['victim_id']]) ? $p_masks[$p_system][$victim_row['victim_id']] : 0;
                foreach ($permissions->cats[$p_system] as $category => $permission_values) {
                    $template->assign_block_vars('c_mask.v_mask.category', array('CAT_NAME' => $user->lang['PERMISSION_' . strtoupper($category)], 'PERM_GROUP_ID' => $category));
                    foreach ($permission_values as $permission) {
                        $template->assign_block_vars('c_mask.v_mask.category.mask', array('PERMISSION' => $user->lang['PERMISSION_' . strtoupper($permission)], 'PERMISSION_EXPLAIN' => isset($user->lang['PERMISSION_' . strtoupper($permission) . '_EXPLAIN']) ? $user->lang['PERMISSION_' . strtoupper($permission) . '_EXPLAIN'] : '', 'S_FIELD_NAME' => 'setting[' . $p_system . '][' . $victim_row['victim_id'] . '][' . $permission . ']', 'S_NO' => isset($roles[$role_id][$permission]) && $roles[$role_id][$permission] == phpbb_gallery_auth::ACL_NO ? true : false, 'S_YES' => isset($roles[$role_id][$permission]) && $roles[$role_id][$permission] == phpbb_gallery_auth::ACL_YES ? true : false, 'S_NEVER' => isset($roles[$role_id][$permission]) && $roles[$role_id][$permission] == phpbb_gallery_auth::ACL_NEVER ? true : false, 'S_VALUE' => isset($roles[$role_id][$permission]) ? $roles[$role_id][$permission] : 0, 'S_COUNT_FIELD' => substr($permission, -6, 6) == '_count' ? true : false));
                    }
                }
            }
        }
        // Setting permissions screen
        $s_hidden_fields = build_hidden_fields(array('user_id' => $user_id, 'group_id' => $group_id, 'album_id' => $album_id, 'p_system' => $p_system));
        $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields, 'U_ACTION' => $this->u_action . '&amp;action=set', 'S_PERMISSION_P_MASK' => true));
    }
Exemplo n.º 17
0
 /**
  * Checks that the server we are installing on meets the requirements for running phpBB
  */
 function check_server_requirements($mode, $sub)
 {
     global $user, $template, $phpbb_root_path, $phpEx;
     $this->page_title = $user->lang['STAGE_REQUIREMENTS'];
     $template->assign_vars(array('TITLE' => $user->lang['REQUIREMENTS_TITLE'], 'BODY' => $user->lang['REQUIREMENTS_EXPLAIN']));
     $passed = array('php' => false, 'files' => false, 'dirs' => false);
     // Test for basic PHP settings
     $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_EXP']));
     // Check for GD-Library
     if (@extension_loaded('gd') || can_load_dll('gd')) {
         $passed['php'] = true;
         $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
     } else {
         $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong>';
     }
     $template->assign_block_vars('checks', array('TITLE' => $user->lang['REQ_GD_LIBRARY'], 'RESULT' => $result, 'S_EXPLAIN' => false, 'S_LEGEND' => false));
     // Test for optional PHP settings
     $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS_OPTIONAL'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_OPTIONAL_EXP']));
     // Image rotate
     if (function_exists('imagerotate')) {
         $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
     } else {
         $gd_info = gd_info();
         $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . sprintf($user->lang['OPTIONAL_IMAGEROTATE_EXP'], $gd_info['GD Version']);
     }
     $template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_IMAGEROTATE'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_IMAGEROTATE_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false));
     // Exif data
     if (function_exists('exif_read_data')) {
         $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
     } else {
         $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . $user->lang['OPTIONAL_EXIFDATA_EXP'];
     }
     $template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_EXIFDATA'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_EXIFDATA_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false));
     // Check permissions on files/directories we need access to
     $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_REQUIRED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_REQUIRED_EXPLAIN']));
     $directories = array('import', 'upload', 'medium', 'cache');
     umask(0);
     $passed['dirs'] = true;
     foreach ($directories as $dir) {
         $write = false;
         // Now really check
         if (phpbb_gallery_url::_file_exists('', $dir, '') && is_dir(phpbb_gallery_url::_return_file('', $dir, ''))) {
             if (!phpbb_gallery_url::_is_writable('', $dir, '')) {
                 @chmod(phpbb_gallery_url::_return_file('', $dir, ''), 0777);
             }
         }
         // Now check if it is writable by storing a simple file
         $fp = @fopen(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock', 'wb');
         if ($fp !== false) {
             $write = true;
         }
         @fclose($fp);
         @unlink(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock');
         $passed['dirs'] = $write && $passed['dirs'] ? true : false;
         $write = $write ? '<strong style="color:green">' . $user->lang['WRITABLE'] . '</strong>' : '<strong style="color:red">' . $user->lang['UNWRITABLE'] . '</strong>';
         $template->assign_block_vars('checks', array('TITLE' => $dir, 'RESULT' => $write, 'S_EXPLAIN' => false, 'S_LEGEND' => false));
     }
     // Check whether all old files are deleted
     include $phpbb_root_path . 'install/outdated_files.' . $phpEx;
     umask(0);
     $passed['files'] = true;
     $delete = isset($_POST['delete']) ? true : false;
     foreach ($oudated_files as $file) {
         // Replace gallery root path with the constant.
         if (strpos($file, 'gallery/') == 0) {
             $file = substr_replace($file, phpbb_gallery_url::path('relative'), 0, 8);
         }
         $file = preg_replace('/\\.php$/i', ".{$phpEx}", $file);
         if ($delete) {
             if (@file_exists($phpbb_root_path . $file)) {
                 // Try to set CHMOD and then delete it
                 @chmod($phpbb_root_path . $file, 0777);
                 @unlink($phpbb_root_path . $file);
                 // Delete failed, tell the user to delete it manually
                 if (@file_exists($phpbb_root_path . $file)) {
                     if ($passed['files']) {
                         $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_OUTDATED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_OUTDATED_EXPLAIN']));
                     }
                     $template->assign_block_vars('checks', array('TITLE' => $file, 'RESULT' => '<strong style="color:red">' . $user->lang['FILE_DELETE_FAIL'] . '</strong>', 'S_EXPLAIN' => false, 'S_LEGEND' => false));
                     $passed['files'] = false;
                 }
             }
         } elseif (@file_exists($phpbb_root_path . $file)) {
             if ($passed['files']) {
                 $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_OUTDATED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_OUTDATED_EXPLAIN']));
             }
             $template->assign_block_vars('checks', array('TITLE' => $file, 'RESULT' => '<strong style="color:red">' . $user->lang['FILE_STILL_EXISTS'] . '</strong>', 'S_EXPLAIN' => false, 'S_LEGEND' => false));
             $passed['files'] = false;
         }
     }
     if (!$passed['files']) {
         $template->assign_block_vars('checks', array('TITLE' => '<strong>' . $user->lang['FILES_DELETE_OUTDATED'] . '</strong>', 'TITLE_EXPLAIN' => $user->lang['FILES_DELETE_OUTDATED_EXPLAIN'], 'RESULT' => '<input class="button1" type="submit" id="delete" onclick="this.className = \'button1 disabled\';" name="delete" value="' . $user->lang['FILES_DELETE_OUTDATED'] . '" />', 'S_EXPLAIN' => true, 'S_LEGEND' => false));
     }
     $url = !in_array(false, $passed) ? append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&amp;sub=update_db") : append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&amp;sub=requirements");
     $submit = !in_array(false, $passed) ? $user->lang['INSTALL_START'] : $user->lang['INSTALL_TEST'];
     $template->assign_vars(array('L_SUBMIT' => $submit, 'S_HIDDEN' => '', 'U_ACTION' => $url));
 }
Exemplo n.º 18
0
 /**
  * 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 ? '&amp;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') . '&amp;album_id=' . $root_data['album_id'] . '&amp;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());
 }
Exemplo n.º 19
0
 /**
  * Delete file from disc.
  *
  * @param	mixed		$files		String with filename or an array of filenames
  *									Array-Format: $image_id => $filename
  * @param	array		$locations	Array of valid url::path()s where the image should be deleted from
  */
 public function delete($files, $locations = array('cache', 'medium', 'upload'))
 {
     if (!is_array($files)) {
         $files = array(1 => $files);
     }
     foreach ($files as $image_id => $file) {
         foreach ($locations as $location) {
             @unlink(phpbb_gallery_url::path($location) . $file);
         }
     }
 }
Exemplo n.º 20
0
        $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();
* @package phpBB Gallery
* @version $Id$
* @copyright (c) 2007 nickvergessen nickvergessen@gmx.de http://www.flying-bits.org
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB')) {
    exit;
}
if (!defined('IN_INSTALL')) {
    exit;
}
$gallery_root_path = phpbb_gallery_url::path('relative');
function get_dbms_infos()
{
    global $db;
    switch ($db->sql_layer) {
        case 'mysql':
            $return['db_schema'] = 'mysql_40';
            $return['delimiter'] = ';';
            break;
        case 'mysql4':
            if (version_compare($db->sql_server_info(true), '4.1.3', '>=')) {
                $return['db_schema'] = 'mysql_41';
            } else {
                $return['db_schema'] = 'mysql_40';
            }
            $return['delimiter'] = ';';
Exemplo n.º 22
0
 /**
  * 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}&amp;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}&amp;image_id={$image_id}&amp;mode=delete&amp;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}&amp;image_id={$image_id}&amp;mode=add&amp;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}&amp;image_id={$image_id}&amp;mode=edit&amp;comment_id=" . $row['comment_id']) : '', 'U_INFO' => $auth->acl_get('a_') ? phpbb_gallery_url::append_sid('mcp', 'mode=whois&amp;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));
 }
 /**
  * Checks that the server we are installing on meets the requirements for running phpBB
  */
 function check_server_requirements($mode, $sub)
 {
     global $user, $template, $phpbb_root_path, $phpEx, $db;
     $this->page_title = $user->lang['STAGE_REQUIREMENTS'];
     $template->assign_vars(array('TITLE' => $user->lang['REQUIREMENTS_TITLE'], 'BODY' => $user->lang['REQUIREMENTS_EXPLAIN']));
     $passed = array('php' => false, 'files' => false);
     // Test for basic PHP settings
     $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_EXP']));
     // Check for GD-Library
     if (@extension_loaded('gd') || can_load_dll('gd')) {
         $passed['php'] = true;
         $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
     } else {
         $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong>';
     }
     $template->assign_block_vars('checks', array('TITLE' => $user->lang['REQ_GD_LIBRARY'], 'RESULT' => $result, 'S_EXPLAIN' => false, 'S_LEGEND' => false));
     // Test for optional PHP settings
     $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS_OPTIONAL'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_OPTIONAL_EXP']));
     // Image rotate
     if (function_exists('imagerotate')) {
         $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
     } else {
         $gd_info = gd_info();
         $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . sprintf($user->lang['OPTIONAL_IMAGEROTATE_EXP'], $gd_info['GD Version']);
     }
     $template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_IMAGEROTATE'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_IMAGEROTATE_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false));
     // Exif data
     if (function_exists('exif_read_data')) {
         $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>';
     } else {
         $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . $user->lang['OPTIONAL_EXIFDATA_EXP'];
     }
     $template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_EXIFDATA'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_EXIFDATA_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false));
     // Check permissions on files/directories we need access to
     $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_REQUIRED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_REQUIRED_EXPLAIN']));
     $directories = array('import', 'upload', 'medium', 'cache');
     umask(0);
     $passed['dirs'] = true;
     foreach ($directories as $dir) {
         $write = false;
         // Now really check
         if (phpbb_gallery_url::_file_exists('', $dir, '') && is_dir(phpbb_gallery_url::_return_file('', $dir, ''))) {
             if (!phpbb_gallery_url::_is_writable('', $dir, '')) {
                 @chmod(phpbb_gallery_url::_return_file('', $dir, ''), 0777);
             }
         }
         // Now check if it is writable by storing a simple file
         $fp = @fopen(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock', 'wb');
         if ($fp !== false) {
             $write = true;
         }
         @fclose($fp);
         @unlink(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock');
         $passed['dirs'] = $write && $passed['dirs'] ? true : false;
         $write = $write ? '<strong style="color:green">' . $user->lang['WRITABLE'] . '</strong>' : '<strong style="color:red">' . $user->lang['UNWRITABLE'] . '</strong>';
         $template->assign_block_vars('checks', array('TITLE' => $dir, 'RESULT' => $write, 'S_EXPLAIN' => false, 'S_LEGEND' => false));
     }
     $url = !in_array(false, $passed) ? append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&amp;sub=copy_table") : append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&amp;sub=requirements");
     $submit = !in_array(false, $passed) ? $user->lang['INSTALL_START'] : $user->lang['INSTALL_TEST'];
     $template->assign_vars(array('L_SUBMIT' => $submit, 'S_HIDDEN' => '', 'U_ACTION' => $url));
 }
Exemplo n.º 24
0
    }
    // 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&amp;submode=upload&amp;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&amp;mode=manage_albums&amp;action=create&amp;parent_id={$album_id}&amp;redirect=album") : '', 'U_EDIT_ALBUM' => $album_data['album_user_id'] == $user->data['user_id'] ? phpbb_gallery_url::append_sid('phpbb', 'ucp', "i=gallery&amp;mode=manage_albums&amp;action=edit&amp;album_id={$album_id}&amp;redirect=album") : '', 'U_SLIDE_SHOW' => sizeof(phpbb_gallery_plugins::$plugins) && phpbb_gallery_plugins::$slideshow ? phpbb_gallery_url::append_sid('album', "album_id={$album_id}&amp;mode=slide_show" . ($sort_key != phpbb_gallery_config::get('default_sort_key') ? "&amp;sk={$sort_key}" : '') . ($sort_dir != phpbb_gallery_config::get('default_sort_dir') ? "&amp;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}&amp;sk={$sort_key}&amp;sd={$sort_dir}&amp;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&amp;submode=" . ($album_data['watch_id'] ? 'unwatch' : 'watch') . "&amp;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();
Exemplo n.º 25
0
    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 . '&amp;check_mode=source', 'CHECK_ENTRY' => $this->u_action . '&amp;check_mode=entry', 'S_FOUNDER' => $user->data['user_type'] == USER_FOUNDER ? true : false));
    }
Exemplo n.º 26
0
    /**
     * Gallery Notification
     *
     * borrowed from phpBB3
     * @author: phpBB Group
     * @function: user_notification
     */
    public static function notification($mode, $handle_id, $image_name)
    {
        global $user, $db, $album_id, $image_id, $image_data, $album_data;
        $help_mode = $mode . '_id';
        $mode_id = ${$help_mode};
        $mode_notification = $mode == 'album' ? 'image' : 'comment';
        // Get banned User ID's
        $sql = 'SELECT ban_userid
			FROM ' . BANLIST_TABLE . '
			WHERE ban_userid <> 0
				AND ban_exclude <> 1';
        $result = $db->sql_query($sql);
        $sql_ignore_users = ANONYMOUS . ', ' . $user->data['user_id'];
        while ($row = $db->sql_fetchrow($result)) {
            $sql_ignore_users .= ', ' . (int) $row['ban_userid'];
        }
        $db->sql_freeresult($result);
        $notify_rows = array();
        // -- get album_userids	|| image_userids
        $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
			FROM ' . GALLERY_WATCH_TABLE . ' w, ' . USERS_TABLE . ' u
			WHERE w.' . $help_mode . ' = ' . $handle_id . "\n\t\t\t\tAND w.user_id NOT IN ({$sql_ignore_users})\n\t\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
				AND u.user_id = w.user_id';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $notify_rows[$row['user_id']] = array('user_id' => $row['user_id'], 'username' => $row['username'], 'user_email' => $row['user_email'], 'user_jabber' => $row['user_jabber'], 'user_lang' => $row['user_lang'], 'notify_type' => $mode != 'album' ? 'image' : 'album', 'template' => "new{$mode_notification}_notify", 'method' => $row['user_notify_type'], 'allowed' => false);
        }
        $db->sql_freeresult($result);
        if (!sizeof($notify_rows)) {
            return;
        }
        // Get album_user_id to check for personal albums.
        $sql = 'SELECT album_id, album_user_id
			FROM ' . GALLERY_ALBUMS_TABLE . '
			WHERE album_id = ' . $album_id;
        $result = $db->sql_query($sql);
        $album = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (empty($album)) {
            trigger_error('ALBUM_NOT_EXIST');
        }
        // Make sure users are allowed to view the album
        $i_view_ary = $groups_ary = $groups_row = array();
        $sql_array = array('SELECT' => 'pr.i_view, p.perm_system, p.perm_group_id, p.perm_user_id', 'FROM' => array(GALLERY_PERMISSIONS_TABLE => 'p'), 'LEFT_JOIN' => array(array('FROM' => array(GALLERY_ROLES_TABLE => 'pr'), 'ON' => 'p.perm_role_id = pr.role_id')), 'WHERE' => $album['album_user_id'] == phpbb_gallery_album::PUBLIC_ALBUM ? 'p.perm_album_id = ' . $album_id : 'p.perm_system <> ' . phpbb_gallery_album::PUBLIC_ALBUM, 'ORDER_BY' => 'pr.i_view ASC');
        $sql = $db->sql_build_query('SELECT', $sql_array);
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            if ($row['perm_group_id']) {
                $groups_ary[] = $row['perm_group_id'];
                $groups_row[$row['perm_group_id']] = $row;
            } else {
                if (!isset($i_view_ary[$row['perm_user_id']]) || isset($i_view_ary[$row['perm_user_id']]) && $i_view_ary[$row['perm_user_id']] < $row['i_view']) {
                    if (!$row['perm_system']) {
                        $i_view_ary[$row['perm_user_id']] = $row['i_view'];
                    } elseif ($row['perm_system'] == phpbb_gallery_auth::OWN_ALBUM && $album['album_user_id'] == $row['perm_user_id']) {
                        $i_view_ary[$row['perm_user_id']] = $row['i_view'];
                    } elseif ($row['perm_system'] == phpbb_gallery_auth::PERSONAL_ALBUM && $album['album_user_id'] != $row['perm_user_id']) {
                        $i_view_ary[$row['perm_user_id']] = $row['i_view'];
                    }
                }
            }
        }
        $db->sql_freeresult($result);
        if (sizeof($groups_ary)) {
            // Get all users by their group permissions
            $sql = 'SELECT user_id, group_id
				FROM ' . USER_GROUP_TABLE . '
				WHERE ' . $db->sql_in_set('group_id', $groups_ary) . '
					AND user_pending = 0';
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                if (!isset($i_view_ary[$row['user_id']]) || isset($i_view_ary[$row['user_id']]) && $i_view_ary[$row['user_id']] < $groups_row[$row['group_id']]['i_view']) {
                    if (!$groups_row[$row['group_id']]['perm_system']) {
                        $i_view_ary[$row['user_id']] = $groups_row[$row['group_id']]['i_view'];
                    } else {
                        if ($groups_row[$row['group_id']]['perm_system'] == phpbb_gallery_auth::OWN_ALBUM && $album['album_user_id'] == $row['user_id']) {
                            $i_view_ary[$row['user_id']] = $groups_row[$row['group_id']]['i_view'];
                        } else {
                            if ($groups_row[$row['group_id']]['perm_system'] == phpbb_gallery_auth::PERSONAL_ALBUM && $album['album_user_id'] != $row['user_id']) {
                                $i_view_ary[$row['user_id']] = $groups_row[$row['group_id']]['i_view'];
                            }
                        }
                    }
                }
            }
            $db->sql_freeresult($result);
        }
        // Now, we have to do a little step before really sending, we need to distinguish our users a little bit. ;)
        $msg_users = $delete_ids = $update_notification = array();
        foreach ($notify_rows as $user_id => $row) {
            if ($i_view_ary[$row['user_id']] != phpbb_gallery_auth::ACL_YES || !trim($row['user_email'])) {
                $delete_ids[$row['notify_type']][] = $row['user_id'];
            } else {
                $msg_users[] = $row;
                $update_notification[$row['notify_type']][] = $row['user_id'];
            }
        }
        unset($notify_rows);
        // Now, we are able to really send out notifications
        if (sizeof($msg_users)) {
            if (!class_exists('messenger')) {
                phpbb_gallery_url::_include('functions_messenger', 'phpbb');
            }
            $messenger = new messenger();
            $msg_list_ary = array();
            foreach ($msg_users as $row) {
                $pos = !isset($msg_list_ary[$row['template']]) ? 0 : sizeof($msg_list_ary[$row['template']]);
                $msg_list_ary[$row['template']][$pos]['method'] = $row['method'];
                $msg_list_ary[$row['template']][$pos]['email'] = $row['user_email'];
                $msg_list_ary[$row['template']][$pos]['jabber'] = $row['user_jabber'];
                $msg_list_ary[$row['template']][$pos]['name'] = $row['username'];
                $msg_list_ary[$row['template']][$pos]['lang'] = $row['user_lang'];
            }
            unset($msg_users);
            foreach ($msg_list_ary as $email_template => $email_list) {
                foreach ($email_list as $addr) {
                    $messenger->template($email_template, $addr['lang']);
                    $messenger->to($addr['email'], $addr['name']);
                    $messenger->im($addr['jabber'], $addr['name']);
                    $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($addr['name']), 'IMAGE_NAME' => htmlspecialchars_decode($image_name), 'ALBUM_NAME' => htmlspecialchars_decode($album_data['album_name']), 'U_ALBUM' => phpbb_gallery_url::create_link('full', 'album', "album_id={$album_id}"), 'U_IMAGE' => phpbb_gallery_url::create_link('full', 'image_page', "album_id={$album_id}&amp;image_id={$image_id}"), 'U_NEWEST_POST' => phpbb_gallery_url::create_link('full', 'viewtopic', "album_id={$album_id}&amp;image_id={$image_id}"), 'U_STOP_WATCHING_IMAGE' => phpbb_gallery_url::create_link('full', 'posting', "mode=image&amp;submode=unwatch&amp;album_id={$album_id}&amp;image_id={$image_id}"), 'U_STOP_WATCHING_ALBUM' => phpbb_gallery_url::create_link('full', 'posting', "mode=album&amp;submode=unwatch&amp;album_id={$album_id}")));
                    $messenger->send($addr['method']);
                }
            }
            unset($msg_list_ary);
            $messenger->save_queue();
        }
        // Now delete the user_ids not authorised to receive notifications on this image/album
        if (!empty($delete_ids['image'])) {
            $sql = 'DELETE FROM ' . GALLERY_WATCH_TABLE . "\n\t\t\t\tWHERE image_id = {$image_id}\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $delete_ids['image']);
            $db->sql_query($sql);
        }
        if (!empty($delete_ids['album'])) {
            $sql = 'DELETE FROM ' . GALLERY_WATCH_TABLE . "\n\t\t\t\tWHERE album_id = {$album_id}\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $delete_ids['album']);
            $db->sql_query($sql);
        }
    }