예제 #1
0
/**
* BEGIN DISPLAY ATTACHMENTS -> PREVIEW
*/
function display_attachments_preview($attachment_list, $attachment_filesize_list, $attachment_filename_list, $attachment_comment_list, $attachment_extension_list, $attachment_thumbnail_list)
{
    // Begin PNphpBB2 Module
    //	global $attach_config, $is_auth, $allowed_extensions, $lang, $userdata, $display_categories, $upload_dir, $upload_icons, $template, $db, $theme;
    global $phpbb_root_path, $attach_config, $is_auth, $allowed_extensions, $lang, $userdata, $display_categories, $upload_dir, $upload_icons, $template, $db, $phpbb_theme;
    // End PNphpBB2 Module
    if (sizeof($attachment_list) != 0) {
        init_display_template('preview', '{ATTACHMENTS}');
        init_complete_extensions_data();
        $template->assign_block_vars('postrow', array());
        $template->assign_block_vars('postrow.attach', array());
        $template->assign_vars(array('T_BODY_TEXT' => '#' . $phpbb_theme['body_text'], 'T_TR_COLOR3' => '#' . $phpbb_theme['tr_color3']));
        for ($i = 0, $size = sizeof($attachment_list); $i < $size; $i++) {
            $filename = $upload_dir . '/' . basename($attachment_list[$i]);
            $thumb_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . basename($attachment_list[$i]);
            $filesize = $attachment_filesize_list[$i];
            $size_lang = $filesize >= 1048576 ? $lang['MB'] : ($filesize >= 1024 ? $lang['KB'] : $lang['Bytes']);
            if ($filesize >= 1048576) {
                $filesize = round(round($filesize / 1048576 * 100) / 100, 2);
            } else {
                if ($filesize >= 1024) {
                    $filesize = round(round($filesize / 1024 * 100) / 100, 2);
                }
            }
            $display_name = $attachment_filename_list[$i];
            $comment = $attachment_comment_list[$i];
            $comment = str_replace("\n", '<br />', $comment);
            $extension = $attachment_extension_list[$i];
            $denied = false;
            // Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
            if (!in_array($extension, $allowed_extensions)) {
                $denied = true;
                $template->assign_block_vars('postrow.attach.denyrow', array('L_DENIED' => sprintf($lang['Extension_disabled_after_posting'], $extension)));
            }
            if (!$denied) {
                // Some basic Template Vars
                $template->assign_vars(array('L_DESCRIPTION' => $lang['Description'], 'L_DOWNLOAD' => $lang['Download'], 'L_FILENAME' => $lang['File_name'], 'L_FILESIZE' => $lang['Filesize']));
                // define category
                $image = FALSE;
                $stream = FALSE;
                $swf = FALSE;
                $thumbnail = FALSE;
                $link = FALSE;
                if (intval($display_categories[$extension]) == STREAM_CAT) {
                    $stream = TRUE;
                } else {
                    if (intval($display_categories[$extension]) == SWF_CAT) {
                        $swf = TRUE;
                    } else {
                        if (intval($display_categories[$extension]) == IMAGE_CAT && intval($attach_config['img_display_inlined'])) {
                            if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0) {
                                list($width, $height) = image_getdimension($filename);
                                if ($width == 0 && $height == 0) {
                                    $image = TRUE;
                                } else {
                                    if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height'])) {
                                        $image = TRUE;
                                    }
                                }
                            } else {
                                $image = TRUE;
                            }
                        }
                    }
                }
                if (intval($display_categories[$extension]) == IMAGE_CAT && intval($attachment_thumbnail_list[$i]) == 1) {
                    $thumbnail = TRUE;
                    $image = FALSE;
                }
                if (!$image && !$stream && !$swf && !$thumbnail) {
                    $link = TRUE;
                }
                if ($image) {
                    // Images
                    $template->assign_block_vars('postrow.attach.cat_images', array('DOWNLOAD_NAME' => $display_name, 'IMG_SRC' => $filename, 'FILESIZE' => $filesize, 'SIZE_VAR' => $size_lang, 'COMMENT' => $comment, 'L_DOWNLOADED_VIEWED' => $lang['Viewed']));
                }
                if ($thumbnail) {
                    // Images, but display Thumbnail
                    $template->assign_block_vars('postrow.attach.cat_thumb_images', array('DOWNLOAD_NAME' => $display_name, 'IMG_SRC' => $filename, 'IMG_THUMB_SRC' => $thumb_filename, 'FILESIZE' => $filesize, 'SIZE_VAR' => $size_lang, 'COMMENT' => $comment, 'L_DOWNLOADED_VIEWED' => $lang['Viewed']));
                }
                if ($stream) {
                    // Streams
                    $template->assign_block_vars('postrow.attach.cat_stream', array('U_DOWNLOAD_LINK' => $filename, 'DOWNLOAD_NAME' => $display_name, 'FILESIZE' => $filesize, 'SIZE_VAR' => $size_lang, 'COMMENT' => $comment, 'L_DOWNLOADED_VIEWED' => $lang['Viewed']));
                }
                if ($swf) {
                    // Macromedia Flash Files
                    list($width, $height) = swf_getdimension($filename);
                    $template->assign_block_vars('postrow.attach.cat_swf', array('U_DOWNLOAD_LINK' => $filename, 'DOWNLOAD_NAME' => $display_name, 'FILESIZE' => $filesize, 'SIZE_VAR' => $size_lang, 'COMMENT' => $comment, 'L_DOWNLOADED_VIEWED' => $lang['Viewed'], 'WIDTH' => $width, 'HEIGHT' => $height));
                }
                if ($link) {
                    $upload_image = '';
                    if ($attach_config['upload_img'] != '' && $upload_icons[$extension] == '') {
                        // Begin PNphpBB2 Module
                        //						$upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />';
                        $upload_image = '<img src="' . $phpbb_root_path . $attach_config['upload_img'] . '" alt="" />';
                        // End PNphpBB2 Module
                    } else {
                        if (trim($upload_icons[$extension]) != '') {
                            $upload_image = '<img src="' . $upload_icons[$extension] . '" alt="" border="0" />';
                        }
                    }
                    $target_blank = 'target="_blank"';
                    // display attachment
                    $template->assign_block_vars('postrow.attach.attachrow', array('U_DOWNLOAD_LINK' => $filename, 'S_UPLOAD_IMAGE' => $upload_image, 'DOWNLOAD_NAME' => $display_name, 'FILESIZE' => $filesize, 'SIZE_VAR' => $size_lang, 'COMMENT' => $comment, 'L_DOWNLOADED_VIEWED' => $lang['Downloaded'], 'TARGET_BLANK' => $target_blank));
                }
            }
        }
    }
}
예제 #2
0
if (intval($switch_attachment) != 0 && !intval($attach_config['disable_mod']) && $is_auth['auth_download'] && $is_auth['auth_view']) {
    $post_id_array = array();
    for ($i = 0; $i < $total_posts; $i++) {
        if ($postrow[$i]['post_attachment'] == 1) {
            $post_id_array[] = $postrow[$i]['post_id'];
        }
    }
    if (count($post_id_array) > 0) {
        $rows = get_attachments_from_post($post_id_array);
        $num_rows = count($rows);
        if ($num_rows > 0) {
            reset($attachments);
            for ($i = 0; $i < $num_rows; $i++) {
                $attachments['_' . $rows[$i]['post_id']][] = $rows[$i];
            }
            init_complete_extensions_data();
            $template->assign_vars(array('L_POSTED_ATTACHMENTS' => $lang['Posted_attachments'], 'L_KILOBYTE' => $lang['KB']));
        }
    }
}
# Update the topic view counter
$db->sql_query("UPDATE " . TOPICS_TABLE . " SET topic_views = topic_views + 1 WHERE topic_id = {$topic_id}");
if (is_active('coppermine')) {
    list($ugall, $ugalldir) = $db->sql_ufetchrow("SELECT prefix, dirname FROM " . $prefix . "_cpg_installs");
} else {
    $ugall = false;
}
$ugalleries = array();
# Okay, let's do the loop, yeah come on baby let's do the loop
# and it goes like this ...
for ($i = 0; $i < $total_posts; $i++) {
예제 #3
0
/**
* Initializes some templating variables for displaying Attachments in Posts
*/
function init_display_post_attachments($switch_attachment)
{
    global $attach_config, $is_auth, $template, $lang, $postrow, $total_posts, $attachments, $forum_row, $t_data;
    if (empty($t_data) && !empty($forum_row)) {
        $switch_attachment = $forum_row['topic_attachment'];
    }
    if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || !($is_auth['auth_download'] && $is_auth['auth_view'])) {
        init_display_template('body', '{postrow.ATTACHMENTS}', 'viewtopic_attach_guest.tpl');
        return;
    }
    $post_id_array = array();
    for ($i = 0; $i < $total_posts; $i++) {
        if ($postrow[$i]['post_attachment'] == 1) {
            $post_id_array[] = (int) $postrow[$i]['post_id'];
        }
    }
    if (sizeof($post_id_array) == 0) {
        return;
    }
    $rows = get_attachments_from_post($post_id_array);
    $num_rows = sizeof($rows);
    if ($num_rows == 0) {
        return;
    }
    @reset($attachments);
    for ($i = 0; $i < $num_rows; $i++) {
        $attachments['_' . $rows[$i]['post_id']][] = $rows[$i];
        //bt
        if ($rows[$i]['tracker_status']) {
            if (defined('TORRENT_POST')) {
                bb_die('Multiple registered torrents in one topic<br /><br />first torrent found in post_id = ' . TORRENT_POST . '<br />current post_id = ' . $rows[$i]['post_id'] . '<br /><br />attachments info:<br /><pre style="text-align: left;">' . print_r($rows, TRUE) . '</pre>');
            }
            define('TORRENT_POST', $rows[$i]['post_id']);
        }
        //bt end
    }
    init_display_template('body', '{postrow.ATTACHMENTS}');
    init_complete_extensions_data();
}
예제 #4
0
function display_attachments_preview($attachment_list)
{
    //atm just return
    return;
    global $attach_config, $is_auth, $allowed_extensions, $lang, $userdata, $display_categories, $upload_dir, $upload_icons, $template, $db, $bgcolor2, $textcolor2;
    if (count($attachment_list) < 1) {
        return;
    }
    init_display_template('preview', '{ATTACHMENTS}');
    init_complete_extensions_data();
    $template->assign_block_vars('postrow', array());
    // Another 'i have to fix minor phpBB2 Bugs...' patch
    $template->assign_vars(array('T_BODY_TEXT' => $textcolor2, 'T_TR_COLOR3' => $bgcolor2));
    $blockvar = 'postrow.attachment';
    //
    // Some basic Template Vars
    //
    $template->assign_vars(array('L_DESCRIPTION' => $lang['Description'], 'L_DOWNLOAD' => $lang['Download'], 'L_FILENAME' => $lang['File_name'], 'L_FILESIZE' => $lang['Filesize']));
    for ($i = 0, $attach_count = count($attachment_list); $i < $attach_count; ++$i) {
        $extension = strtolower(trim($attachment_list[$i]['extension']));
        //
        // Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
        //
        if (!in_array($extension, $allowed_extensions)) {
            $template->assign_block_vars($blockvar . '.denyrow', array('L_DENIED' => sprintf($lang['Extension_disabled_after_posting'], $extension)));
        } else {
            $filename = $upload_dir . '/' . $attachment_list[$i]['physical_filename'];
            //
            // define category
            //
            $display = 'DEF_CAT';
            if (intval($display_categories[$extension]) == STREAM_CAT) {
                $display = 'STREAM_CAT';
            } else {
                if (intval($display_categories[$extension]) == SWF_CAT) {
                    $display = 'SWF_CAT';
                } else {
                    if (intval($display_categories[$extension]) == IMAGE_CAT && intval($attachment_list[$i]['thumbnail']) == 1) {
                        $display = 'THUMB_CAT';
                    } else {
                        if (intval($display_categories[$extension]) == IMAGE_CAT && intval($attach_config['img_display_inlined'])) {
                            if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0) {
                                list($width, $height) = image_getdimension($filename);
                                if ($width == 0 && $height == 0) {
                                    $display = 'IMAGE_CAT';
                                } else {
                                    if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height'])) {
                                        $display = 'IMAGE_CAT';
                                    }
                                }
                            } else {
                                $display = 'IMAGE_CAT';
                            }
                        }
                    }
                }
            }
            $blockname = $blockvar;
            switch ($display) {
                // Macromedia Flash Files
                case 'SWF_CAT':
                    list($width, $height) = swf_getdimension($filename);
                    break;
                    // display attachment
                // display attachment
                default:
                    $upload_image = '';
                    if ($attach_config['upload_img'] != '' && $upload_icons[$extension] == '') {
                        $upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" />';
                    } else {
                        if (trim($upload_icons[$extension]) != '') {
                            $upload_image = '<img src="' . $upload_icons[$extension] . '" alt="" />';
                        }
                    }
                    break;
            }
            $template->assign_block_vars($blockname, array('S_DEF_CAT' => false, 'S_IMAGE_CAT' => false, 'S_THUMB_CAT' => false, 'S_STREAM_CAT' => false, 'S_SWF_CAT' => false, 'S_' . $display => true, 'DOWNLOAD_NAME' => $attachment_list[$i]['real_filename'], 'S_UPLOAD_IMAGE' => $upload_image, 'FILESIZE' => filesize_to_human($attachment_list[$i]['filesize']), 'COMMENT' => htmlprepare($attachment_list[$i]['comment'], true), 'L_DOWNLOADED_VIEWED' => $display == 'DEF_CAT' ? $lang['Downloaded'] : $lang['Viewed'], 'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachment_list[$i]['download_count']), 'IMG_SRC' => $filename, 'IMG_THUMB_SRC' => '', 'U_DOWNLOAD_LINK' => $filename, 'WIDTH' => isset($width) ? $width : '', 'HEIGHT' => isset($height) ? $height : '', 'TARGET_BLANK' => intval($display_categories[$attachment_list[$i]['extension']]) == IMAGE_CAT || $display == 'DEF_CAT' ? 'target="_blank"' : ''));
        }
    }
}