Exemplo n.º 1
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.º 2
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.º 3
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.º 4
0
    if (phpbb_gallery_misc::display_captcha('comment')) {
        // Get the captcha instance
        phpbb_gallery_url::_include('captcha/captcha_factory', 'phpbb');
        $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']);
        $captcha->init(CONFIRM_POST);
        $template->assign_vars(array('S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template()));
    }
    // Different link, when we rate and dont comment
    if (!$s_hide_comment_input) {
        $template->assign_var('S_COMMENT_ACTION', phpbb_gallery_url::append_sid('posting', "album_id={$album_id}&amp;image_id={$image_id}&amp;mode=comment&amp;submode=add"));
    }
}
/**
* Listing comment
*/
if (phpbb_gallery_config::get('allow_comments') && phpbb_gallery::$auth->acl_check('c_read', $album_id, $album_data['album_user_id']) && time() > $album_data['contest_start'] + $album_data['contest_end']) {
    $user->add_lang('viewtopic');
    $start = request_var('start', 0);
    $sort_order = request_var('sort_order', 'ASC') == 'ASC' ? 'ASC' : 'DESC';
    $template->assign_vars(array('S_ALLOWED_READ_COMMENTS' => true, 'IMAGE_COMMENTS' => $image_data['image_comments'], 'SORT_ASC' => $sort_order == 'ASC' ? true : false));
    if ($image_data['image_comments'] > 0) {
        if (!class_exists('bbcode')) {
            phpbb_gallery_url::_include('bbcode', 'phpbb');
        }
        $bbcode = new bbcode();
        $comments = $users = $user_cache = array();
        $users[] = $image_data['image_user_id'];
        $sql = 'SELECT *
			FROM ' . GALLERY_COMMENTS_TABLE . '
			WHERE comment_image_id = ' . $image_id . '
			ORDER BY comment_id ' . $sort_order;
Exemplo n.º 5
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.º 6
0
 /**
  * Submit rating for an image.
  *
  * @param	int		$user_id
  * @param	int		$points
  * @param	string	$user_ip	Can be empty, function falls back to $user->ip
  */
 public function submit_rating($user_id = false, $points = false, $user_ip = false)
 {
     switch (self::MODE_SELECT) {
         //@todo: self::MODE_THUMB:
         //@todo: self::MODE_STARS:
         case self::MODE_SELECT:
         default:
             global $user;
             $user_id = $user_id ? $user_id : $user->data['user_id'];
             $points = $points ? $points : request_var('rating', 0);
             $points = max(1, min($points, phpbb_gallery_config::get('max_rating')));
             break;
     }
     if ($user_id == ANONYMOUS || $this->get_user_rating($user_id)) {
         return false;
     }
     $this->insert_rating($user_id, $points, $user_ip);
     $this->recalc_image_rating($this->image_id);
     $this->user_rating[$user_id] = $points;
 }
Exemplo n.º 7
0
                            $template->assign_block_vars('imageblock.imagerow.noimage', array());
                            continue;
                        }
                        // Assign the image to the template-block
                        phpbb_gallery_image::assign_block('imageblock.imagerow.image', $rowset[$j], $rowset[$j]['album_status'], phpbb_gallery_config::get('search_display'), $rowset[$j]['album_user_id']);
                    }
                }
            }
        } else {
            $sql_array = array('SELECT' => 'c.*, i.*', 'FROM' => array(GALLERY_COMMENTS_TABLE => 'c'), 'LEFT_JOIN' => array(array('FROM' => array(GALLERY_IMAGES_TABLE => 'i'), 'ON' => 'c.comment_image_id = i.image_id')), 'WHERE' => $sql_where, 'ORDER_BY' => $sql_order);
            $sql = $db->sql_build_query('SELECT', $sql_array);
            $result = $db->sql_query($sql);
            while ($commentrow = $db->sql_fetchrow($result)) {
                $image_id = $commentrow['image_id'];
                $album_id = $commentrow['image_album_id'];
                $template->assign_block_vars('commentrow', array('U_COMMENT' => phpbb_gallery_url::append_sid('image_page', "album_id={$album_id}&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');
}
Exemplo n.º 8
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.º 9
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')));
    }
Exemplo n.º 10
0
 /**
  * Provide an opportunity to customise some advanced settings during the install
  * in case it is necessary for them to be set to access later
  */
 function obtain_advanced_settings($mode, $sub)
 {
     global $user, $template, $phpbb_root_path, $phpEx, $db;
     $create = request_var('create', '');
     if ($create) {
         // Add modules
         $choosen_acp_module = request_var('acp_module', 0);
         $choosen_ucp_module = request_var('ucp_module', 0);
         $choosen_log_module = request_var('log_module', 0);
         switch (phpbb_gallery_config::get('version')) {
             case '0.1.2':
             case '0.1.3':
             case '0.2.0':
             case '0.2.1':
             case '0.2.2':
             case '0.2.3':
             case '0.3.0':
             case '0.3.1':
             case '0.3.2-RC1':
             case '0.3.2-RC2':
             case '0.4.0-RC1':
             case '0.4.0-RC2':
             case '0.4.0-RC3':
             case '0.4.0':
                 break;
             case '0.4.1':
                 // Logs
                 $gallery_log = array('module_basename' => 'logs', 'module_enabled' => 1, 'module_display' => 1, 'parent_id' => $choosen_log_module, 'module_class' => 'acp', 'module_langname' => 'ACP_GALLERY_LOGS', 'module_mode' => 'gallery', 'module_auth' => 'acl_a_viewlogs');
                 add_module($gallery_log);
             case '0.5.0':
             case '0.5.1':
             case '0.5.2':
             case '0.5.3':
             case '0.5.4':
             case '1.0.0-dev':
             case '1.0.0-RC1':
             case '1.0.0-RC2':
             case '1.0.0':
             case '1.0.1-dev':
             case '1.0.1':
             case '1.0.2-dev':
             case '1.0.2-RC1':
                 // Add album-BBCode
                 add_bbcode('album');
             case '1.0.2':
             case '1.0.3-RC1':
             case '1.0.3-RC2':
             case '1.0.3':
             case '1.0.4':
             case '1.0.5-RC1':
                 trigger_error('VERSION_NOT_SUPPORTED', E_USER_ERROR);
             case '1.0.5':
                 break;
         }
         $s_hidden_fields = '';
         $url = append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&amp;sub=final");
     } else {
         $data = array('acp_module' => phpbb_gallery_constants::MODULE_DEFAULT_ACP, 'log_module' => phpbb_gallery_constants::MODULE_DEFAULT_LOG, 'ucp_module' => phpbb_gallery_constants::MODULE_DEFAULT_UCP);
         $modules = $this->gallery_config_options;
         switch (phpbb_gallery_config::get('version')) {
             case '1.0.5-RC1':
             case '1.0.5':
             case '1.0.4':
             case '1.0.3':
             case '1.0.3-RC2':
             case '1.0.3-RC1':
             case '1.0.2':
             case '1.0.2-RC1':
             case '1.0.2-dev':
             case '1.0.1':
                 $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => '', 'LEGEND_EXPLAIN' => $user->lang['BBCODES_NEEDS_REPARSE']));
             case '1.0.1-dev':
             case '1.0.0':
             case '1.0.0-RC2':
             case '1.0.0-RC1':
             case '1.0.0-dev':
             case '0.5.4':
             case '0.5.3':
             case '0.5.2':
             case '0.5.1':
             case '0.5.0':
                 // needs to be moved before the first unset.
                 unset($modules['legend1']);
                 unset($modules['log_module']);
             case '0.4.1':
                 unset($modules['acp_module']);
                 unset($modules['ucp_module']);
                 // We need to build all modules before this version
                 break;
         }
         foreach ($modules as $config_key => $vars) {
             if (!is_array($vars) && strpos($config_key, 'legend') === false) {
                 continue;
             }
             if (strpos($config_key, 'legend') !== false) {
                 $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => $user->lang[$vars]));
                 continue;
             }
             $options = isset($vars['options']) ? $vars['options'] : '';
             $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => $user->lang[$vars['lang']], 'S_EXPLAIN' => $vars['explain'], 'S_LEGEND' => false, 'TITLE_EXPLAIN' => $vars['explain'] ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '', 'CONTENT' => $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options)));
         }
         $s_hidden_fields = '<input type="hidden" name="create" value="true" />';
         $url = append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&amp;sub=advanced");
     }
     $submit = $user->lang['NEXT_STEP'];
     $template->assign_vars(array('TITLE' => $user->lang['STAGE_ADVANCED'], 'BODY' => $user->lang['STAGE_ADVANCED_EXPLAIN'], 'L_SUBMIT' => $submit, 'S_HIDDEN' => $s_hidden_fields, 'U_ACTION' => $url));
 }
Exemplo n.º 11
0
 /**
  * Set users default group
  *
  * borrowed from phpBB3
  * @author: phpBB Group
  * @function: group_set_user_default
  */
 public static function group_set_user_default($user_id_ary, $sql_ary)
 {
     global $db;
     if (empty($user_id_ary)) {
         return;
     }
     if (isset($sql_ary['user_colour'])) {
         // Update any cached colour information for these users
         $sql = 'UPDATE ' . GALLERY_ALBUMS_TABLE . " SET album_last_user_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\t\tWHERE " . $db->sql_in_set('album_last_user_id', $user_id_ary);
         $db->sql_query($sql);
         $sql = 'UPDATE ' . GALLERY_COMMENTS_TABLE . " SET comment_user_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\t\tWHERE " . $db->sql_in_set('comment_user_id', $user_id_ary);
         $db->sql_query($sql);
         $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . " SET image_user_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\t\tWHERE " . $db->sql_in_set('image_user_id', $user_id_ary);
         $db->sql_query($sql);
         if (in_array(phpbb_gallery_config::get('newest_pega_user_id'), $user_id_ary)) {
             phpbb_gallery_config::set('newest_pega_user_colour', $sql_ary['user_colour']);
         }
     }
 }
Exemplo n.º 12
0
    /**
     * Delete album content:
     * Deletes all images, comments, rates, image-files, etc.
     */
    public function delete_album_content($album_id)
    {
        global $cache, $db;
        $album_id = (int) $album_id;
        // Before we remove anything we make sure we are able to adjust the image counts later. ;)
        $sql = 'SELECT image_user_id
			FROM ' . GALLERY_IMAGES_TABLE . '
			WHERE image_album_id = ' . $album_id . '
				AND image_status <> ' . phpbb_gallery_image::STATUS_UNAPPROVED;
        $result = $db->sql_query($sql);
        $image_counts = array();
        while ($row = $db->sql_fetchrow($result)) {
            $image_counts[$row['image_user_id']] = !empty($image_counts[$row['image_user_id']]) ? $image_counts[$row['image_user_id']] + 1 : 1;
        }
        $db->sql_freeresult($result);
        $sql = 'SELECT image_id, image_filename, image_album_id
			FROM ' . GALLERY_IMAGES_TABLE . '
			WHERE image_album_id = ' . $album_id;
        $result = $db->sql_query($sql);
        $filenames = $deleted_images = array();
        while ($row = $db->sql_fetchrow($result)) {
            $deleted_images[] = $row['image_id'];
            $filenames[(int) $row['image_id']] = $row['image_filename'];
        }
        $db->sql_freeresult($result);
        if (!empty($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 ' . LOG_TABLE . "\n\t\t\tWHERE album_id = {$album_id}\n\t\t\t\tAND log_type = " . LOG_GALLERY;
        $db->sql_query($sql);
        //@todo: merge queries into loop
        $sql = 'DELETE FROM ' . GALLERY_PERMISSIONS_TABLE . '
			WHERE perm_album_id = ' . $album_id;
        $db->sql_query($sql);
        $sql = 'DELETE FROM ' . GALLERY_CONTESTS_TABLE . '
			WHERE contest_album_id = ' . $album_id;
        $db->sql_query($sql);
        $table_ary = array(GALLERY_WATCH_TABLE, GALLERY_MODSCACHE_TABLE);
        foreach ($table_ary as $table) {
            $db->sql_query("DELETE FROM {$table} WHERE album_id = {$album_id}");
        }
        // Adjust users image counts
        if (!empty($image_counts)) {
            foreach ($image_counts as $image_user_id => $substract) {
                $sql = 'UPDATE ' . GALLERY_USERS_TABLE . '
					SET user_images = 0
					WHERE user_id = ' . $image_user_id . '
						AND user_images < ' . $substract;
                $db->sql_query($sql);
                $sql = 'UPDATE ' . GALLERY_USERS_TABLE . '
					SET user_images = user_images - ' . $substract . '
					WHERE user_id = ' . $image_user_id . '
						AND user_images >= ' . $substract;
                $db->sql_query($sql);
            }
        }
        // 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');
        return array();
    }
Exemplo n.º 13
0
 /**
  * User authorisation levels output
  *
  * @param	string	$mode			Can only be 'album' so far.
  * @param	int		$album_id		The current album the user is in.
  * @param	int		$album_status	The albums status bit.
  * @param	int		$album_user_id	The user-id of the album owner. Saves us a call to the cache if it is set.
  *
  * borrowed from phpBB3
  * @author: phpBB Group
  * @function: gen_forum_auth_level
  */
 public function gen_auth_level($mode, $album_id, $album_status, $album_user_id = -1)
 {
     global $template, $user;
     $locked = $album_status == ITEM_LOCKED && !gallery_acl_check('m_', $album_id, $album_user_id) ? true : false;
     $rules = array($this->acl_check('i_view', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_VIEW_CAN'] : $user->lang['ALBUM_VIEW_CANNOT'], $this->acl_check('i_upload', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_UPLOAD_CAN'] : $user->lang['ALBUM_UPLOAD_CANNOT'], $this->acl_check('i_edit', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_EDIT_CAN'] : $user->lang['ALBUM_EDIT_CANNOT'], $this->acl_check('i_delete', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_DELETE_CAN'] : $user->lang['ALBUM_DELETE_CANNOT']);
     if (phpbb_gallery_config::get('allow_comments') && $this->acl_check('c_read', $album_id, $album_user_id)) {
         $rules[] = $this->acl_check('c_post', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_COMMENT_CAN'] : $user->lang['ALBUM_COMMENT_CANNOT'];
     }
     if (phpbb_gallery_config::get('allow_rates')) {
         $rules[] = $this->acl_check('i_rate', $album_id, $album_user_id) && !$locked ? $user->lang['ALBUM_RATE_CAN'] : $user->lang['ALBUM_RATE_CANNOT'];
     }
     foreach ($rules as $rule) {
         $template->assign_block_vars('rules', array('RULE' => $rule));
     }
     return;
 }
Exemplo n.º 14
0
                        if ($user->data['user_id'] != $comment_data['comment_user_id']) {
                            add_log('gallery', $image_data['image_album_id'], $image_data['image_id'], 'LOG_GALLERY_COMMENT_DELETED', $image_data['image_name']);
                        }
                        $submit = true;
                        $message = $user->lang['DELETED_COMMENT'] . '<br />';
                    } else {
                        if (isset($_POST['cancel'])) {
                            $message = $user->lang['DELETED_COMMENT_NOT'] . '<br />';
                            $submit = true;
                        } else {
                            confirm_box(false, 'DELETE_COMMENT2', $s_hidden_fields);
                        }
                    }
                    break;
            }
            $template->assign_vars(array('ERROR' => $error, 'MESSAGE' => $comment, 'USERNAME' => $comment_username, 'REQ_USERNAME' => $comment_username_req, 'L_COMMENT_LENGTH' => sprintf($user->lang['COMMENT_LENGTH'], phpbb_gallery_config::get('comment_length')), 'IMAGE_RSZ_WIDTH' => phpbb_gallery_config::get('medium_width'), 'IMAGE_RSZ_HEIGHT' => phpbb_gallery_config::get('medium_height'), 'U_IMAGE' => $image_id ? phpbb_gallery_url::append_sid('image', "album_id={$album_id}&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);
}
Exemplo n.º 15
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();
Exemplo n.º 16
0
    /**
     * Handle user- & total image_counter
     *
     * @param	array	$image_id_ary	array with the image_ids which changed their status
     * @param	bool	$add			are we adding or removing the images
     * @param	bool	$readd			is it possible that there are images which aren't really changed
     */
    public static function handle_counter($image_id_ary, $add, $readd = false)
    {
        global $db;
        $num_images = $num_comments = 0;
        $sql = 'SELECT SUM(image_comments) comments
			FROM ' . GALLERY_IMAGES_TABLE . '
			WHERE image_status ' . ($readd ? '=' : '<>') . ' ' . self::STATUS_UNAPPROVED . '
				AND ' . $db->sql_in_set('image_id', $image_id_ary) . '
			GROUP BY image_user_id';
        $result = $db->sql_query($sql);
        $num_comments = $db->sql_fetchfield('comments');
        $db->sql_freeresult($result);
        $sql = 'SELECT COUNT(image_id) images, image_user_id
			FROM ' . GALLERY_IMAGES_TABLE . '
			WHERE image_status ' . ($readd ? '=' : '<>') . ' ' . self::STATUS_UNAPPROVED . '
				AND ' . $db->sql_in_set('image_id', $image_id_ary) . '
			GROUP BY image_user_id';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $sql_ary = array('user_id' => $row['image_user_id'], 'user_images' => $row['images']);
            phpbb_gallery_hookup::add_image($row['image_user_id'], $add ? $row['images'] : 0 - $row['images']);
            $num_images = $num_images + $row['images'];
            $sql = 'UPDATE ' . GALLERY_USERS_TABLE . '
				SET user_images = user_images ' . ($add ? '+ ' : '- ') . $row['images'] . '
				WHERE ' . $db->sql_in_set('user_id', $row['image_user_id']);
            $db->sql_query($sql);
            if ($db->sql_affectedrows() != 1) {
                $sql = 'INSERT INTO ' . GALLERY_USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
                $db->sql_query($sql);
            }
        }
        $db->sql_freeresult($result);
        if ($add) {
            phpbb_gallery_config::inc('num_images', $num_images);
            phpbb_gallery_config::inc('num_comments', $num_comments);
        } else {
            phpbb_gallery_config::dec('num_images', $num_images);
            phpbb_gallery_config::dec('num_comments', $num_comments);
        }
    }
Exemplo n.º 17
0
    public static function end($album_id, $contest_id, $end_time)
    {
        global $db;
        $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . '
			SET image_contest = ' . phpbb_gallery_image::NO_CONTEST . '
			WHERE image_album_id = ' . $album_id;
        $db->sql_query($sql);
        $sql = 'SELECT image_id
			FROM ' . GALLERY_IMAGES_TABLE . '
			WHERE image_album_id = ' . $album_id . '
			ORDER BY ' . self::get_tabulation();
        $result = $db->sql_query_limit($sql, self::NUM_IMAGES);
        $first = (int) $db->sql_fetchfield('image_id');
        $second = (int) $db->sql_fetchfield('image_id');
        $third = (int) $db->sql_fetchfield('image_id');
        $db->sql_freeresult($result);
        $sql = 'UPDATE ' . GALLERY_CONTESTS_TABLE . '
			SET contest_marked = ' . phpbb_gallery_image::NO_CONTEST . ",\n\t\t\t\tcontest_first = {$first},\n\t\t\t\tcontest_second = {$second},\n\t\t\t\tcontest_third = {$third}\n\t\t\tWHERE contest_id = " . (int) $contest_id;
        $db->sql_query($sql);
        $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . '
			SET image_contest_end = ' . (int) $end_time . ',
				image_contest_rank = 1
			WHERE image_id = ' . $first;
        $db->sql_query($sql);
        $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . '
			SET image_contest_end = ' . (int) $end_time . ',
				image_contest_rank = 2
			WHERE image_id = ' . $second;
        $db->sql_query($sql);
        $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . '
			SET image_contest_end = ' . (int) $end_time . ',
				image_contest_rank = 3
			WHERE image_id = ' . $third;
        $db->sql_query($sql);
        phpbb_gallery_config::inc('contests_ended', 1);
    }
Exemplo n.º 18
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')));
 }
    function main($id, $mode)
    {
        global $db, $user, $auth, $cache, $template;
        phpbb_gallery::init();
        $user->add_lang(array('mods/gallery_acp', 'mods/gallery'));
        $submit = isset($_POST['submit']) ? true : false;
        $form_key = 'acp_time';
        add_form_key($form_key);
        switch ($mode) {
            case 'main':
                // Disable some Options if they can not be used
                if (!function_exists('exif_read_data')) {
                    $this->display_vars['vars']['exif_data']['type'] = 'custom';
                    $this->display_vars['vars']['exif_data']['explain'] = true;
                    $this->display_vars['vars']['exif_data']['method'] = 'disabled_boolean';
                }
                if (!function_exists('imagerotate')) {
                    $this->display_vars['vars']['allow_rotate_images']['type'] = 'custom';
                    $this->display_vars['vars']['allow_rotate_images']['explain'] = true;
                    $this->display_vars['vars']['allow_rotate_images']['method'] = 'disabled_boolean';
                }
                break;
            default:
                trigger_error('NO_MODE', E_USER_ERROR);
                break;
        }
        phpbb_gallery_config::load(true);
        $this->new_config = phpbb_gallery_config::get_array();
        $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
        $error = array();
        // We validate the complete config if whished
        validate_config_vars($this->display_vars['vars'], $cfg_array, $error);
        if ($submit && !check_form_key($form_key)) {
            $error[] = $user->lang['FORM_INVALID'];
        }
        // Do not write values if there is an error
        if (sizeof($error)) {
            $submit = false;
        }
        // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
        foreach ($this->display_vars['vars'] as $config_name => $null) {
            if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
                continue;
            }
            $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
            if ($submit) {
                // Check for RRC-display-options
                if (isset($null['method']) && ($null['method'] == 'rrc_display' || $null['method'] == 'rrc_modes')) {
                    // Changing the value, casted by int to not mess up anything
                    $config_value = (int) array_sum(request_var($config_name, array(0)));
                }
                // Recalculate the Watermark-position
                if (isset($null['method']) && $null['method'] == 'watermark_position') {
                    // Changing the value, casted by int to not mess up anything
                    $config_value = request_var('watermark_position_x', 0) + request_var('watermark_position_y', 0);
                }
                if ($config_name == 'link_thumbnail') {
                    $update_bbcode = request_var('update_bbcode', '');
                    // Update the BBCode
                    if ($update_bbcode) {
                        if (!class_exists('acp_bbcodes')) {
                            phpbb_gallery_url::_include('acp/acp_bbcodes', 'phpbb');
                        }
                        $acp_bbcodes = new acp_bbcodes();
                        $bbcode_match = '[album]{NUMBER}[/album]';
                        $bbcode_tpl = $this->bbcode_tpl($config_value);
                        $sql_ary = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl);
                        $sql_ary = array_merge($sql_ary, array('bbcode_match' => $bbcode_match, 'bbcode_tpl' => $bbcode_tpl, 'display_on_posting' => true, 'bbcode_helpline' => 'GALLERY_HELPLINE_ALBUM'));
                        $sql = 'UPDATE ' . BBCODES_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE bbcode_tag = '" . $sql_ary['bbcode_tag'] . "'";
                        $db->sql_query($sql);
                        $cache->destroy('sql', BBCODES_TABLE);
                    }
                }
                phpbb_gallery_config::set($config_name, $config_value);
            }
        }
        if ($submit) {
            $cache->destroy('sql', CONFIG_TABLE);
            trigger_error($user->lang['GALLERY_CONFIG_UPDATED'] . adm_back_link($this->u_action));
        }
        $this->tpl_name = 'acp_board';
        $this->page_title = $this->display_vars['title'];
        $template->assign_vars(array('L_TITLE' => $user->lang[$this->display_vars['title']], 'L_TITLE_EXPLAIN' => $user->lang[$this->display_vars['title'] . '_EXPLAIN'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action));
        // Output relevant page
        foreach ($this->display_vars['vars'] as $config_key => $vars) {
            if (!is_array($vars) && strpos($config_key, 'legend') === false) {
                continue;
            }
            if (strpos($config_key, 'legend') !== false) {
                $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
                continue;
            }
            $this->new_config[$config_key] = phpbb_gallery_config::get($config_key);
            $type = explode(':', $vars['type']);
            $l_explain = '';
            if ($vars['explain']) {
                $l_explain = isset($user->lang[$vars['lang'] . '_EXP']) ? $user->lang[$vars['lang'] . '_EXP'] : '';
            }
            $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
            if (empty($content)) {
                continue;
            }
            $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
            unset($this->display_vars['vars'][$config_key]);
        }
    }
Exemplo n.º 20
0
 /**
  * Generate personal album for user, when moving image into it
  */
 public static function generate_personal_album($album_name, $user_id, $user_colour, $gallery_user)
 {
     global $cache, $db;
     $album_data = array('album_name' => $album_name, 'parent_id' => 0, 'album_desc_options' => 7, 'album_desc' => '', 'album_parents' => '', 'album_type' => self::TYPE_UPLOAD, 'album_status' => self::STATUS_UNLOCKED, 'album_user_id' => $user_id, 'album_last_username' => '', 'album_last_user_colour' => $user_colour);
     $db->sql_query('INSERT INTO ' . GALLERY_ALBUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $album_data));
     $personal_album_id = $db->sql_nextid();
     $gallery_user->update_data(array('personal_album_id' => $personal_album_id));
     phpbb_gallery_config::inc('num_pegas', 1);
     // Update the config for the statistic on the index
     phpbb_gallery_config::set('newest_pega_user_id', $user_id);
     phpbb_gallery_config::set('newest_pega_username', $album_name);
     phpbb_gallery_config::set('newest_pega_user_colour', $user_colour);
     phpbb_gallery_config::set('newest_pega_album_id', $personal_album_id);
     $cache->destroy('_albums');
     $cache->destroy('sql', GALLERY_ALBUMS_TABLE);
     return $personal_album_id;
 }
Exemplo n.º 21
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));
 }
Exemplo n.º 22
0
 public static function display_captcha($mode)
 {
     static $gallery_display_captcha;
     if (isset($gallery_display_captcha[$mode])) {
         return $gallery_display_captcha[$mode];
     }
     global $config, $user;
     $gallery_display_captcha[$mode] = $user->data['user_id'] == ANONYMOUS && phpbb_gallery_config::get('captcha_' . $mode) && version_compare($config['version'], '3.0.5', '>');
     return $gallery_display_captcha[$mode];
 }
Exemplo n.º 23
0
 public static function load($load_default = false)
 {
     global $config;
     foreach ($config as $config_name => $config_value) {
         // Load all config values of the gallery
         if (strpos($config_name, self::$prefix) === 0) {
             $config_name = substr($config_name, strlen(self::$prefix));
             settype($config_value, gettype(self::$default_config[$config_name]));
             self::$config[$config_name] = $config_value;
         }
     }
     if ($load_default) {
         // Should we load the default-config?
         self::$config = self::$config + self::$default_config;
     }
 }