📄 displaying.php
字号:
//
// 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] == '') )
{
$upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />';
}
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)
);
}
}
}
}
}
//
// END DISPLAY ATTACHMENTS -> PREVIEW
//
//
// Assign Variables and Definitions based on the fetched Attachments - internal
// used by all displaying functions, the Data was collected before, it's only dependend on the template used. :)
// before this function is usable, init_display_attachments have to be called for specific pages (pm, posting, review etc...)
//
function display_attachments($post_id)
{
global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $db, $lang, $phpEx, $attachments, $upload_icons, $attach_config;
$num_attachments = count($attachments['_' . $post_id]);
if ($num_attachments == 0)
{
return;
}
$template->assign_block_vars('postrow.attach', array());
for ($i = 0; $i < $num_attachments; $i++)
{
//
// Some basic things...
//
$filename = $upload_dir . '/' . $attachments['_' . $post_id][$i]['physical_filename'];
$thumbnail_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . $attachments['_' . $post_id][$i]['physical_filename'];
$upload_image = '';
if ( ($attach_config['upload_img'] != '') && (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) == '') )
{
$upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />';
}
else if (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '')
{
$upload_image = '<img src="' . $upload_icons[$attachments['_' . $post_id][$i]['extension']] . '" alt="" border="0" />';
}
$filesize = $attachments['_' . $post_id][$i]['filesize'];
$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 = $attachments['_' . $post_id][$i]['real_filename'];
$comment = stripslashes(trim(nl2br($attachments['_' . $post_id][$i]['comment'])));
$attachments['_' . $post_id][$i]['extension'] = strtolower(trim($attachments['_' . $post_id][$i]['extension']));
$denied = false;
//
// Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
//
if ( (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions)) )
{
$denied = true;
$template->assign_block_vars('postrow.attach.denyrow', array(
'L_DENIED' => sprintf($lang['Extension_disabled_after_posting'], $attachments['_' . $post_id][$i]['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[$attachments['_' . $post_id][$i]['extension']]) == STREAM_CAT)
{
$stream = TRUE;
}
else if (intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == SWF_CAT)
{
$swf = TRUE;
}
else if ( (intval($display_categories[$attachments['_' . $post_id][$i]['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[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT) && ($attachments['_' . $post_id][$i]['thumbnail'] == 1) )
{
$thumbnail = TRUE;
$image = FALSE;
}
if ( (!$image) && (!$stream) && (!$swf) && (!$thumbnail) )
{
$link = TRUE;
}
if ($image)
{
//
// Images
//
if ((intval($attach_config['allow_ftp_upload'])) && (trim($attach_config['download_path']) == ''))
{
$img_source = append_sid('download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id']);
$download_link = TRUE;
}
else
{
$img_source = $filename;
$download_link = FALSE;
}
$template->assign_block_vars('postrow.attach.cat_images', array(
'DOWNLOAD_NAME' => $display_name,
'S_UPLOAD_IMAGE' => $upload_image,
'IMG_SRC' => $img_source,
'FILESIZE' => $filesize,
'SIZE_VAR' => $size_lang,
'COMMENT' => $comment,
'L_DOWNLOADED_VIEWED' => $lang['Viewed'],
'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']))
);
//
// Directly Viewed Image ... update the download count
//
if (!$download_link)
{
$sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . '
SET download_count = download_count + 1
WHERE attach_id = ' . $attachments['_' . $post_id][$i]['attach_id'];
if ( !(attach_sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Couldn\'t update attachment download count.', '', __LINE__, __FILE__, $sql);
}
}
}
if ($thumbnail)
{
//
// Images, but display Thumbnail
//
if ( (intval($attach_config['allow_ftp_upload'])) && (trim($attach_config['download_path']) == '') )
{
$thumb_source = append_sid('download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1');
}
else
{
$thumb_source = $thumbnail_filename;
}
$template->assign_block_vars('postrow.attach.cat_thumb_images', array(
'DOWNLOAD_NAME' => $display_name,
'S_UPLOAD_IMAGE' => $upload_image,
'IMG_SRC' => append_sid('download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id']),
'IMG_THUMB_SRC' => $thumb_source,
'FILESIZE' => $filesize,
'SIZE_VAR' => $size_lang,
'COMMENT' => $comment,
'L_DOWNLOADED_VIEWED' => $lang['Viewed'],
'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']))
);
}
if ($stream)
{
//
// Streams
//
$template->assign_block_vars('postrow.attach.cat_stream', array(
'U_DOWNLOAD_LINK' => $filename,
'S_UPLOAD_IMAGE' => $upload_image,
// 'U_DOWNLOAD_LINK' => append_sid('download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id']),
'DOWNLOAD_NAME' => $display_name,
'FILESIZE' => $filesize,
'SIZE_VAR' => $size_lang,
'COMMENT' => $comment,
'L_DOWNLOADED_VIEWED' => $lang['Viewed'],
'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']))
);
//
// Viewed/Heared File ... update the download count (download.php is not called here)
//
$sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . '
SET download_count = download_count + 1
WHERE attach_id = ' . $attachments['_' . $post_id][$i]['attach_id'];
if ( !(attach_sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Couldn\'t update attachment download count', '', __LINE__, __FILE__, $sql);
}
}
if ($swf)
{
//
// Macromedia Flash Files
//
list($width, $height) = swf_getdimension($filename);
$template->assign_block_vars('postrow.attach.cat_swf', 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['Viewed'],
'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']),
'WIDTH' => $width,
'HEIGHT' => $height)
);
//
// Viewed/Heared File ... update the download count (download.php is not called here)
//
$sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . '
SET download_count = download_count + 1
WHERE attach_id = ' . $attachments['_' . $post_id][$i]['attach_id'];
if ( !(attach_sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, 'Couldn\'t update attachment download count', '', __LINE__, __FILE__, $sql);
}
}
if ($link)
{
$target_blank = ( (intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT) ) ? 'target="_blank"' : '';
//
// display attachment
//
$template->assign_block_vars('postrow.attach.attachrow', array(
'U_DOWNLOAD_LINK' => append_sid('download.' . $phpEx . '?id=' . $attachments['_' . $post_id][$i]['attach_id']),
'S_UPLOAD_IMAGE' => $upload_image,
'DOWNLOAD_NAME' => $display_name,
'FILESIZE' => $filesize,
'SIZE_VAR' => $size_lang,
'COMMENT' => $comment,
'TARGET_BLANK' => $target_blank,
'L_DOWNLOADED_VIEWED' => $lang['Downloaded'],
'L_DOWNLOAD_COUNT' => sprintf($lang['Download_number'], $attachments['_' . $post_id][$i]['download_count']))
);
}
}
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -