diff options
-rw-r--r-- | phpBB/adm/admin_attachments.php | 401 | ||||
-rw-r--r-- | phpBB/common.php | 8 | ||||
-rw-r--r-- | phpBB/includes/template.php | 2 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_basic.sql | 5 | ||||
-rw-r--r-- | phpBB/language/en/lang_admin.php | 22 | ||||
-rw-r--r-- | phpBB/templates/subSilver/viewtopic_attach_body.html | 36 | ||||
-rw-r--r-- | phpBB/viewtopic.php | 251 |
7 files changed, 444 insertions, 281 deletions
diff --git a/phpBB/adm/admin_attachments.php b/phpBB/adm/admin_attachments.php index 22de35990b..39e1bb8c3f 100644 --- a/phpBB/adm/admin_attachments.php +++ b/phpBB/adm/admin_attachments.php @@ -38,150 +38,6 @@ if (!$auth->acl_get('a_attach')) trigger_error($user->lang['NO_ADMIN']); } -function size_select($select_name, $size_compare) -{ - global $user; - - $size_types_text = array($user->lang['BYTES'], $user->lang['KB'], $user->lang['MB']); - $size_types = array('b', 'kb', 'mb'); - - $select_field = '<select name="' . $select_name . '">'; - - for ($i = 0; $i < count($size_types_text); $i++) - { - $selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : ''; - - $select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>'; - } - - $select_field .= '</select>'; - - return ($select_field); -} - -function test_upload(&$error, &$error_msg, $upload_dir, $ftp_path, $ftp_upload_allowed, $create_directory = false) -{ - global $user; - - $error = FALSE; - - // Does the target directory exist, is it a directory and writeable. (only test if ftp upload is disabled) - if (!$ftp_upload_allowed) - { - if ($create_directory) - { - if (!@file_exists($upload_dir)) - { - @mkdir($upload_dir, 0755); - @chmod($upload_dir, 0777); - } - } - - if (!@file_exists($upload_dir)) - { - $error = TRUE; - $error_msg = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $new['upload_dir']) . '<br />'; - } - - if (!$error && !is_dir($upload_dir)) - { - $error = TRUE; - $error_msg = sprintf($user->lang['DIRECTORY_IS_NOT_A_DIR'], $new['upload_dir']) . '<br />'; - } - - if (!$error) - { - if ( !($fp = @fopen($upload_dir . '/0_000000.000', 'w')) ) - { - $error = TRUE; - $error_msg = sprintf($user->lang['DIRECTORY_NOT_WRITEABLE'], $new['upload_dir']) . '<br />'; - } - else - { - @fclose($fp); - @unlink($upload_dir . '/0_000000.000'); - } - } - } - else - { - // Check FTP Settings - $server = ( empty($new['ftp_server']) ) ? 'localhost' : $new['ftp_server']; - $conn_id = @ftp_connect($server); - - if (!$conn_id) - { - $error = TRUE; - $error_msg = sprintf($user->lang['FTP_ERROR_CONNECT'], $server) . '<br />'; - } - - $login_result = @ftp_login($conn_id, $new['ftp_user'], $new['ftp_pass']); - - if (!$login_result && !$error) - { - $error = TRUE; - $error_msg = sprintf($user->lang['FTP_ERROR_LOGIN'], $new['ftp_user']) . '<br />'; - } - - if (!@ftp_pasv($conn_id, intval($new['ftp_pasv_mode']))) - { - $error = TRUE; - $error_msg = $user->lang['FTP_ERROR_PASV_MODE']; - } - - if (!$error) - { - // Check Upload - $tmpfname = @tempnam('/tmp', 't0000'); - @unlink($tmpfname); // unlink for safety on php4.0.3+ - $fp = @fopen($tmpfname, 'w'); - @fwrite($fp, 'test'); - @fclose($fp); - - if ($create_directory) - { - $result = @ftp_chdir($conn_id, $ftp_path); - - if (!$result) - { - @ftp_mkdir($conn_id, $ftp_path); - } - } - - $result = @ftp_chdir($conn_id, $ftp_path); - - if (!$result) - { - $error = TRUE; - $error_msg = sprintf($user->lang['FTP_ERROR_PATH'], $ftp_path) . '<br />'; - } - else - { - $res = @ftp_put($conn_id, 't0000', $tmpfname, FTP_ASCII); - - if (!$res) - { - $error = TRUE; - $error_msg = sprintf($user->lang['FTP_ERROR_UPLOAD'], $ftp_path) . '<br />'; - } - else - { - $res = @ftp_delete($conn_id, 't0000'); - - if (!$res) - { - $error = TRUE; - $error_msg = sprintf($user->lang['FTP_ERROR_DELETE'], $ftp_path) . '<br />'; - } - } - } - - @ftp_quit($conn_id); - @unlink($tmpfname); - } - } -} - $mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; $config_sizes = array('max_filesize' => 'size', 'attachment_quota' => 'quota_size', 'max_filesize_pm' => 'pm_size'); @@ -263,11 +119,11 @@ while ($row = $db->sql_fetchrow($result)) } } -if ($submit && $mode == 'manage') +if ($submit && ($mode == 'manage' || $mode == 'cats')) { add_log('admin', 'LOG_SETTING_CONFIG'); $notify = TRUE; - $notify_msg = $user->lang['Config_updated']; + $notify_msg = $user->lang['ATTACH_CONFIG_UPDATED']; } // Adjust the Upload Directory @@ -292,6 +148,10 @@ switch ($mode) case 'manage': $l_title = 'ATTACHMENT_CONFIG'; break; + + case 'cats': + $l_title = 'MANAGE_CATEGORIES'; + break; } // Temporary Language Variables @@ -546,6 +406,255 @@ if ($mode == 'manage') <?php } +if ($mode == 'cats') +{ + $sql = "SELECT group_name, cat_id + FROM " . EXTENSION_GROUPS_TABLE . " + WHERE cat_id > 0 + ORDER BY cat_id"; + $result = $db->sql_query($sql); + + $s_assigned_groups = array(); + + while ($row = $db->sql_fetchrow($result)) + { + $s_assigned_groups[$row['cat_id']][] = $row['group_name']; + } + + $display_inlined_yes = ($new['img_display_inlined']) ? 'checked="checked"' : ''; + $display_inlined_no = (!$new['img_display_inlined']) ? 'checked="checked"' : ''; + + $create_thumbnail_yes = ($new['img_create_thumbnail']) ? 'checked="checked"' : ''; + $create_thumbnail_no = (!$new['img_create_thumbnail']) ? 'checked="checked"' : ''; + +?> + <table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> + <tr> + <th align="center" colspan="2"><?php echo $user->lang['SETTINGS_CAT_IMAGES']; ?></th> + </tr> + <tr> + <td class="spacer" colspan="2" height="1"><img src="../images/spacer.gif" alt="" width="1" height="1" /></td> + </tr> + <tr> + <th align="center" colspan="2"><?php echo $user->lang['ASSIGNED_GROUP']; ?>: <?php echo ( (count($s_assigned_groups[IMAGE_CAT])) ? implode(', ', $s_assigned_groups[IMAGE_CAT]) : $user->lang['NONE']); ?></th> + </tr> + <tr> + <td class="row1" width="50%"><?php echo $user->lang['DISPLAY_INLINED']; ?>:<br /><span class="gensmall"><?php echo $user->lang['DISPLAY_INLINED_EXPLAIN']; ?></span></td> + <td class="row2"><input type="radio" name="img_display_inlined" value="1" <?php echo $display_inlined_yes ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="img_display_inlined" value="0" <?php echo $display_inlined_no ?> /> <?php echo $user->lang['NO']; ?></td> + </tr> +<?php + + // Check Thumbnail Support + if ( ($new['img_imagick'] == '') && (count(get_supported_image_types()) == 0) ) + { + $new['img_create_thumbnail'] = '0'; + } + else + { +?> + <tr> + <td class="row1" width="50%"><?php echo $user->lang['CREATE_THUMBNAIL']; ?>:<br /><span class="gensmall"><?php echo $user->lang['CREATE_THUMBNAIL_EXPLAIN']; ?></span></td> + <td class="row2"><input type="radio" name="img_create_thumbnail" value="1" <?php echo $create_thumbnail_yes; ?> /> <?php echo $user->lang['YES']; ?> <input type="radio" name="img_create_thumbnail" value="0" <?php echo $create_thumbnail_no; ?> /> <?php echo $user->lang['NO']; ?></td> + </tr> + <tr> + <td class="row1" width="50%"><?php echo $user->lang['MIN_THUMB_FILESIZE']; ?>:<br /><span class="gensmall"><?php echo $user->lang['MIN_THUMB_FILESIZE_EXPLAIN']; ?></span></td> + <td class="row2"><input type="text" size="7" maxlength="15" name="img_min_thumb_filesize" value="<?php echo $new['img_min_thumb_filesize']; ?>" class="post" /> <?php echo $user->lang['BYTES']; ?></td> + </tr> +<?php + } +?> + <tr> + <td class="row1" width="50%"><?php echo $user->lang['IMAGICK_PATH']; ?>:<br /><span class="gensmall"><?php echo $user->lang['IMAGICK_PATH_EXPLAIN']; ?></span></td> + <td class="row2"><input type="text" size="20" maxlength="200" name="img_imagick" value="<?php echo $new['img_imagick']; ?>" class="post" /></td> + </tr> + <tr> + <td class="row1" width="50%"><?php echo $user->lang['MAX_IMAGE_SIZE']; ?>:<br /><span class="gensmall"><?php echo $user->lang['MAX_IMAGE_SIZE_EXPLAIN']; ?></span></td> + <td class="row2"><input type="text" size="3" maxlength="4" name="img_max_width" value="<?php echo $new['img_max_width']; ?>" class="post" /> x <input type="text" size="3" maxlength="4" name="img_max_height" value="<?php echo $new['img_max_height']; ?>" class="post" /></td> + </tr> + <tr> + <td class="row1" width="50%"><?php echo $user->lang['IMAGE_LINK_SIZE']; ?>:<br /><span class="gensmall"><?php echo $user->lang['IMAGE_LINK_SIZE_EXPLAIN']; ?></span></td> + <td class="row2"><input type="text" size="3" maxlength="4" name="img_link_width" value="<?php echo $new['img_link_width']; ?>" class="post" /> x <input type="text" size="3" maxlength="4" name="img_link_height" value="<?php echo $new['img_link_height']; ?>" class="post" /></td> + </tr> + <tr> + <td class="cat" colspan="2" align="center"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="mainoption" /> <input type="submit" name="search_imagick" value="<?php echo $user->lang['SEARCH_IMAGICK']; ?>" class="liteoption" /> <input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="liteoption" /></td> + </tr> +</table></form> + +<br clear="all" /> + +<?php +} + page_footer(); +// Generate select form +function size_select($select_name, $size_compare) +{ + global $user; + + $size_types_text = array($user->lang['BYTES'], $user->lang['KB'], $user->lang['MB']); + $size_types = array('b', 'kb', 'mb'); + + $select_field = '<select name="' . $select_name . '">'; + + for ($i = 0; $i < count($size_types_text); $i++) + { + $selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : ''; + + $select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>'; + } + + $select_field .= '</select>'; + + return ($select_field); +} + +// Test Settings +function test_upload(&$error, &$error_msg, $upload_dir, $ftp_path, $ftp_upload_allowed, $create_directory = false) +{ + global $user; + + $error = FALSE; + + // Does the target directory exist, is it a directory and writeable. (only test if ftp upload is disabled) + if (!$ftp_upload_allowed) + { + if ($create_directory) + { + if (!@file_exists($upload_dir)) + { + @mkdir($upload_dir, 0755); + @chmod($upload_dir, 0777); + } + } + + if (!@file_exists($upload_dir)) + { + $error = TRUE; + $error_msg = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $new['upload_dir']) . '<br />'; + } + + if (!$error && !is_dir($upload_dir)) + { + $error = TRUE; + $error_msg = sprintf($user->lang['DIRECTORY_IS_NOT_A_DIR'], $new['upload_dir']) . '<br />'; + } + + if (!$error) + { + if ( !($fp = @fopen($upload_dir . '/0_000000.000', 'w')) ) + { + $error = TRUE; + $error_msg = sprintf($user->lang['DIRECTORY_NOT_WRITEABLE'], $new['upload_dir']) . '<br />'; + } + else + { + @fclose($fp); + @unlink($upload_dir . '/0_000000.000'); + } + } + } + else + { + // Check FTP Settings + $server = ( empty($new['ftp_server']) ) ? 'localhost' : $new['ftp_server']; + $conn_id = @ftp_connect($server); + + if (!$conn_id) + { + $error = TRUE; + $error_msg = sprintf($user->lang['FTP_ERROR_CONNECT'], $server) . '<br />'; + } + + $login_result = @ftp_login($conn_id, $new['ftp_user'], $new['ftp_pass']); + + if (!$login_result && !$error) + { + $error = TRUE; + $error_msg = sprintf($user->lang['FTP_ERROR_LOGIN'], $new['ftp_user']) . '<br />'; + } + + if (!@ftp_pasv($conn_id, intval($new['ftp_pasv_mode']))) + { + $error = TRUE; + $error_msg = $user->lang['FTP_ERROR_PASV_MODE']; + } + + if (!$error) + { + // Check Upload + $tmpfname = @tempnam('/tmp', 't0000'); + @unlink($tmpfname); // unlink for safety on php4.0.3+ + $fp = @fopen($tmpfname, 'w'); + @fwrite($fp, 'test'); + @fclose($fp); + + if ($create_directory) + { + $result = @ftp_chdir($conn_id, $ftp_path); + + if (!$result) + { + @ftp_mkdir($conn_id, $ftp_path); + } + } + + $result = @ftp_chdir($conn_id, $ftp_path); + + if (!$result) + { + $error = TRUE; + $error_msg = sprintf($user->lang['FTP_ERROR_PATH'], $ftp_path) . '<br />'; + } + else + { + $res = @ftp_put($conn_id, 't0000', $tmpfname, FTP_ASCII); + + if (!$res) + { + $error = TRUE; + $error_msg = sprintf($user->lang['FTP_ERROR_UPLOAD'], $ftp_path) . '<br />'; + } + else + { + $res = @ftp_delete($conn_id, 't0000'); + + if (!$res) + { + $error = TRUE; + $error_msg = sprintf($user->lang['FTP_ERROR_DELETE'], $ftp_path) . '<br />'; + } + } + } + + @ftp_quit($conn_id); + @unlink($tmpfname); + } + } +} + +// Get supported Image types +function get_supported_image_types() +{ + $types = array(); + + if (@extension_loaded('gd')) + { + if (@function_exists('imagegif')) + { + $types[] = '1'; + } + if (@function_exists('imagejpeg')) + { + $types[] = '2'; + } + if (@function_exists('imagepng')) + { + $types[] = '3'; + } + } + + return ($types); +} + ?>
\ No newline at end of file diff --git a/phpBB/common.php b/phpBB/common.php index 413968087a..5e5a5378c0 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -112,9 +112,11 @@ define('PHYSICAL_LINK', 2); // Categories - Attachments define('NONE_CAT', 0); -define('IMAGE_CAT', 1); -define('STREAM_CAT', 2); -//define('SWF_CAT', 3); +define('IMAGE_CAT', 1); // Inline Images +define('WM_CAT', 2); // Windows Media Files - Streaming +define('RM_CAT', 3); // Real Media Files - Streaming +define('THUMB_CAT', 4); // Not used within the database, only while displaying posts +//define('SWF_CAT', 5); // Replaced by [flash] ? or an additional possibility ? // BBCode UID length define('BBCODE_UID_LEN', 5); diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 631942f4bd..542ae39435 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -373,7 +373,7 @@ class Template $template_php = str_replace(' ?><?php ', '', $template_php); - return (!$no_echo) ? $template_php : "\$$echo_var .= '" . addslashes($template_php) . "'"; + return (!$no_echo) ? str_replace("\\'", "'", $template_php) : "\$$echo_var .= '" . addslashes($template_php) . "'"; } function compile_var_tags(&$text_blocks) diff --git a/phpBB/install/schemas/mysql_basic.sql b/phpBB/install/schemas/mysql_basic.sql index a81b28cc84..18206aa616 100644 --- a/phpBB/install/schemas/mysql_basic.sql +++ b/phpBB/install/schemas/mysql_basic.sql @@ -98,6 +98,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_filesize', '26 INSERT INTO phpbb_config (config_name, config_value) VALUES ('attachment_quota', '52428800'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments', '3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_dir', 'files'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_display_inlined', '1'); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_users', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_date', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_user_id', '2', 1); @@ -384,8 +385,8 @@ INSERT INTO phpbb_extension_groups (group_id, group_name, cat_id, allow_group, d INSERT INTO phpbb_extension_groups (group_id, group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize) VALUES (2, 'Archives', 0, 1, 1, '', 0); INSERT INTO phpbb_extension_groups (group_id, group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize) VALUES (3, 'Plain Text', 0, 0, 1, '', 0); INSERT INTO phpbb_extension_groups (group_id, group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize) VALUES (4, 'Documents', 0, 0, 1, '', 0); -INSERT INTO phpbb_extension_groups (group_id, group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize) VALUES (5, 'Real Media', 0, 0, 2, '', 0); -INSERT INTO phpbb_extension_groups (group_id, group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize) VALUES (6, 'Streams', 2, 0, 1, '', 0); +INSERT INTO phpbb_extension_groups (group_id, group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize) VALUES (5, 'Real Media', 3, 0, 2, '', 0); +INSERT INTO phpbb_extension_groups (group_id, group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize) VALUES (6, 'Windows Media', 2, 0, 1, '', 0); # -- extensions INSERT INTO phpbb_extensions (extension_id, group_id, extension, comment) VALUES (1, 1, 'gif', ''); diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index afe39d5fd9..d8e9b16974 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -875,6 +875,9 @@ $lang = array_merge($lang, array( 'EVT_IN' => 'in', 'EVT_CREATED' => 'The event has been successfully created.', + 'ATTACHMENTS' => 'Attachments', + 'ATTACH_CONFIG_UPDATED' => 'Attachment configuration updated successfully', + 'ATTACHMENT_CONFIG' => 'Attachment Configuration', 'ATTACH_MANAGE_URL' => 'Configuration', 'ATTACH_CATS_URL' => 'Special Categories', @@ -926,6 +929,25 @@ $lang = array_merge($lang, array( 'FTP_ERROR_UPLOAD' => 'Could not upload files to ftp directory: \'%s\'. Please check your FTP Settings.', 'FTP_ERROR_DELETE' => 'Could not delete files in ftp directory: \'%s\'. Please check your FTP Settings.', + 'MANAGE_CATEGORIES' => 'Manage Special Categories', + 'MANAGE_CATEGORIES_EXPLAIN' => 'Here you can configure the Special Categories. You can set up Special Parameters and Conditions for the Special Categories assigned to one or more Extension Groups.', + 'SETTINGS_CAT_IMAGES' => 'Settings for Special Category: Images', + 'ASSIGNED_GROUP' => 'Assigned Group', + 'DISPLAY_INLINED' => 'Display Images Inlined', + 'DISPLAY_INLINED_EXPLAIN' => 'Choose whether to display images directly within the post (yes) or to display images as a link ?', + 'CREATE_THUMBNAIL' => 'Create Thumbnail', + 'CREATE_THUMBNAIL_EXPLAIN' => 'Always create a Thumbnail. This feature overrides nearly all Settings within this Special Category, except of the Maximum Image Dimensions. With this Feature a Thumbnail will be displayed within the post, the User can click it to open the real Image.<br />Please Note that this feature requires Imagick to be installed, if it\'s not installed or if Safe-Mode is enabled the GD-Extension of PHP will be used. If the Image-Type is not supported by PHP, this Feature will be not used.', + 'MIN_THUMB_FILESIZE' => 'Minimum Thumbnail Filesize', + 'MIN_THUMB_FILESIZE_EXPLAIN' => 'If an Image is smaller than this defined Filesize no Thumbnail will be created, because it\'s small enough.', + 'IMAGICK_PATH' => 'Imagick Program (Complete Path)', + 'IMAGICK_PATH_EXPLAIN' => 'Enter the Path to the convert program of imagick, normally /usr/bin/convert (on windows: c:/imagemagick/convert.exe).', + 'SEARCH_IMAGICK' => 'Search Imagick', + 'MAX_IMAGE_SIZE' => 'Maximum Image Dimensions', + 'MAX_IMAGE_SIZE_EXPLAIN' => 'Here you can define the maximum allowed Image Dimension to be attached (Width x Height in pixels).<br />If it is set to 0x0, this feature is disabled. With some Images this Feature will not work due to limitations in PHP.', + 'IMAGE_LINK_SIZE' => 'Image Link Dimensions', + 'IMAGE_LINK_SIZE_EXPLAIN' => 'If this defined Dimension of an Image is reached, the Image will be displayed as a Link, rather than displaying it inlined,<br />if Inline View is enabled (Width x Height in pixels).<br />If it is set to 0x0, this feature is disabled. With some Images this Feature will not work due to limitations in PHP.', + + 'WELCOME_INSTALL' => 'Welcome to phpBB 2 Installation', 'INITIAL_CONFIG' => 'Basic Configuration', 'DB_CONFIG' => 'Database Configuration', diff --git a/phpBB/templates/subSilver/viewtopic_attach_body.html b/phpBB/templates/subSilver/viewtopic_attach_body.html index c94d378f5c..b1fa754d56 100644 --- a/phpBB/templates/subSilver/viewtopic_attach_body.html +++ b/phpBB/templates/subSilver/viewtopic_attach_body.html @@ -4,7 +4,7 @@ <!-- IF postrow.attachment.IS_DENIED --> <span class="postbody">[{postrow.attachment.L_DENIED}]</span><br /><br /> <!-- ENDIF --> - <!-- IF postrow.attachment.IS_STREAM --> + <!-- IF postrow.attachment.IS_WM_STREAM --> <span class="postbody">{postrow.attachment.COMMENT}</span><br /> <object id="wmp" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,0,0" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"> <param name="FileName" value="{postrow.attachment.U_DOWNLOAD_LINK}"> @@ -19,6 +19,40 @@ <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows95/downloads/contents/wurecommended/s_wufeatured/mediaplayer/default.asp" src="{postrow.attachment.U_DOWNLOAD_LINK}" name=MediaPlayer2 showcontrols=1 showdisplay=0 showstatusbar=1 autosize=1 autostart=0 visible=1 animationatstart=0 loop=0></embed> </object> <br /><span class="gensmall">{postrow.attachment.DOWNLOAD_NAME} - {postrow.attachment.L_DOWNLOADED_VIEWED} {postrow.attachment.L_DOWNLOAD_COUNT}</span><br /><br /> + <!-- ELSEIF postrow.attachment.IS_RM_STREAM --> + <span class="postbody">{postrow.attachment.COMMENT}</span><br /> + + <object id=rmstream_{postrow.attachment.ATTACH_ID} classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="0" height="0"> + <param name="src" value="{postrow.attachment.FORUM_URL}/{postrow.attachment.U_DOWNLOAD_LINK}"> + <param name="autostart" value="false"> + <param name="controls" value="ImageWindow"> + <param name="console" value="{postrow.attachment.U_DOWNLOAD_LINK}"> + <param name="prefetch" value="true"> + <embed name=rmstream_{postrow.attachment.ATTACH_ID} type="audio/x-pn-realaudio-plugin" src="{postrow.attachment.FORUM_URL}/{postrow.attachment.U_DOWNLOAD_LINK}" width="0" height="0" autostart="false" controls="ImageWindow" console="video" prefetch="true"></embed> + </object> + <br /> + <object id=ctrls_{postrow.attachment.ATTACH_ID} classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="0" height="36"> + <param name="controls" value="ControlPanel"> + <param name="console" value="{postrow.attachment.U_DOWNLOAD_LINK}"> + <embed name=ctrls_{postrow.attachment.ATTACH_ID} type="audio/x-pn-realaudio-plugin" width="0" height="36" controls="ControlPanel" console="video"></embed> + </object> + + <script language="Javascript"> + <!-- + + while (!document.rmstream_{postrow.attachment.ATTACH_ID}.GetClipWidth()) + { + } + + var width = document.rmstream_{postrow.attachment.ATTACH_ID}.GetClipWidth(); + var height = document.rmstream_{postrow.attachment.ATTACH_ID}.GetClipHeight(); + + document.rmstream_{postrow.attachment.ATTACH_ID}.width = width; + document.rmstream_{postrow.attachment.ATTACH_ID}.height = height; + document.ctrls_{postrow.attachment.ATTACH_ID}.width = width; + //--> + </script> + <br /><span class="gensmall">{postrow.attachment.DOWNLOAD_NAME} - {postrow.attachment.L_DOWNLOADED_VIEWED} {postrow.attachment.L_DOWNLOAD_COUNT}</span><br /><br /> <!-- ELSEIF postrow.attachment.IS_IMAGE --> <span class="postbody">{postrow.attachment.COMMENT}<br /> <img src="{postrow.attachment.U_DOWNLOAD_LINK}" alt="{postrow.attachment.DOWNLOAD_NAME}" /></span> diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 9d9068b72d..0e64b3314a 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1102,8 +1102,7 @@ foreach ($rowset as $key => $row) $comment = stripslashes(trim(nl2br($attachment['comment']))); $denied = false; - - // Admin is allowed to view forbidden Attachments + if ((!in_array($attachment['extension'], $extensions['_allowed_']))) { $denied = true; @@ -1116,165 +1115,161 @@ foreach ($rowset as $key => $row) if (!$denied) { - // define category - $image = FALSE; - $stream = FALSE; -// $swf = FALSE; - $thumbnail = FALSE; - $link = FALSE; - $l_downloaded_viewed = ''; $download_link = ''; $additional_array = array(); - switch (intval($extensions[$attachment['extension']]['display_cat'])) + $display_cat = intval($extensions[$attachment['extension']]['display_cat']); + + if ($display_cat == IMAGE_CAT) { - case STREAM_CAT: - $stream = TRUE; - break; -/* - case SWF_CAT: - $swf = TRUE; - break; -*/ - case IMAGE_CAT: + if ($attachment['thumbnail']) + { + $display_cat = THUMB_CAT; + } + else + { + $display_cat = NONE_CAT; + if (intval($config['img_display_inlined'])) { if ( (intval($config['img_link_width']) != 0) || (intval($config['img_link_height']) != 0) ) { list($width, $height) = image_getdimension($filename); - $image = (($width == 0) && ($height == 0)) ? true : ((($width <= intval($config['img_link_width'])) && ($height <= intval($config['img_link_height']))) ? true : false); + $display_cat = (($width == 0) && ($height == 0)) ? IMAGE_CAT : ((($width <= intval($config['img_link_width'])) && ($height <= intval($config['img_link_height']))) ? IMAGE_CAT : NONE_CAT); } } else { - $image = TRUE; + $display_cat = IMAGE_CAT; } - - if ($attachment['thumbnail']) + } + } + + switch ($display_cat) + { + case IMAGE_CAT: + // Images + // NOTE: If you want to use the download.php everytime an image is displayed inlined, replace the + // Section between BEGIN and END with (Without the // of course): + // $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; + // + // BEGIN + if (!empty($config['ftp_upload']) && trim($config['upload_dir']) == '') { - $thumbnail = TRUE; - $image = FALSE; + $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; } + else + { + $img_source = $filename; + $update_count[] = $attachment['attach_id']; + } + // END + + $l_downloaded_viewed = $user->lang['VIEWED']; + $download_link = $img_source; break; - } - + + case THUMB_CAT: + // Images, but display Thumbnail + // NOTE: If you want to use the download.php everytime an thumnmail is displayed inlined, replace the + // Section between BEGIN and END with (Without the // of course): + // $thumb_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'] . '&thumb=1'; + // + // BEGIN + if (!empty($config['allow_ftp_upload']) && trim($config['upload_dir']) == '') + { + $thumb_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'] . '&thumb=1'; + } + else + { + $thumb_source = $thumbnail_filename; + } + // END - // && !$swf - if (!$image && !$stream && !$thumbnail) - { - $link = TRUE; - } + $l_downloaded_viewed = $user->lang['VIEWED']; + $download_link = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; - if ($image) - { - // Images - // NOTE: If you want to use the download.php everytime an image is displayed inlined, replace the - // Section between BEGIN and END with (Without the // of course): - // $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; - // - // BEGIN - if (!empty($config['ftp_upload']) && trim($config['upload_dir']) == '') - { - $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; - } - else - { - $img_source = $filename; - $update_count[] = $attachment['attach_id']; - } - // END + $additional_array = array( + 'IMG_THUMB_SRC' => $thumb_source + ); + break; - $l_downloaded_viewed = $user->lang['VIEWED']; - $download_link = $img_source; - } - - if ($thumbnail) - { - // Images, but display Thumbnail - // NOTE: If you want to use the download.php everytime an thumnmail is displayed inlined, replace the - // Section between BEGIN and END with (Without the // of course): - // $thumb_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'] . '&thumb=1'; - // - // BEGIN - if (!empty($config['allow_ftp_upload']) && trim($config['upload_dir']) == '') - { - $thumb_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id'] . '&thumb=1'; - } - else - { - $thumb_source = $thumbnail_filename; - } - // END + case WM_CAT: + // Windows Media Streams + $l_downloaded_viewed = $user->lang['VIEWED']; + $download_link = $filename; - $l_downloaded_viewed = $user->lang['VIEWED']; - $download_link = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; + // Viewed/Heared File ... update the download count (download.php is not called here) + if (!preg_match("#&t=$topic_id#", $user->data['session_page'])) + { + $update_count[] = $attachment['attach_id']; + } + break; - $additional_array = array( - 'IMG_THUMB_SRC' => $thumb_source - ); - } + case RM_CAT: + // Real Media Streams + $l_downloaded_viewed = $user->lang['VIEWED']; + $download_link = $filename; - if ($stream) - { - // Streams - $l_downloaded_viewed = $user->lang['VIEWED']; - $download_link = $filename; -// $download_link = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; + $additional_array = array( + 'FORUM_URL' => generate_board_url(), + 'ATTACH_ID' => $attachment['attach_id'] + ); - // Viewed/Heared File ... update the download count (download.php is not called here) - if (!preg_match("#&t=$topic_id#", $user->data['session_page'])) - { - $update_count[] = $attachment['attach_id']; - } - } + // Viewed/Heared File ... update the download count (download.php is not called here) + if (!preg_match("#&t=$topic_id#", $user->data['session_page'])) + { + $update_count[] = $attachment['attach_id']; + } + break; /* - if ($swf) - { - // Macromedia Flash Files - list($width, $height) = swf_getdimension($filename); + case SWF_CAT: + // Macromedia Flash Files + list($width, $height) = swf_getdimension($filename); - $l_downloaded_viewed = $user->lang['VIEWED']; - $download_link = $filename; + $l_downloaded_viewed = $user->lang['VIEWED']; + $download_link = $filename; - $additional_array = array( - 'WIDTH' => $width, - 'HEIGHT' => $height - ); + $additional_array = array( + 'WIDTH' => $width, + 'HEIGHT' => $height + ); - // Viewed/Heared File ... update the download count (download.php is not called here) - $update_count[] = $attachment['attach_id']; - } + // Viewed/Heared File ... update the download count (download.php is not called here) + if (!preg_match("#&t=$topic_id#", $user->data['session_page'])) + { + $update_count[] = $attachment['attach_id']; + } + break; */ - if ($link) - { - $l_downloaded_viewed = $user->lang['DOWNLOADED']; - $download_link = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; + default: + $l_downloaded_viewed = $user->lang['DOWNLOADED']; + $download_link = $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . $attachment['attach_id']; + break; } - - if ($image || $thumbnail || $stream || $link) - { - $template_array = array_merge($additional_array, array( -// 'IS_FLASH' => ($swf) ? true : false, - 'IS_STREAM' => ($stream) ? true : false, - 'IS_THUMBNAIL' => ($thumbnail) ? true : false, - 'IS_IMAGE' => ($image) ? true : false, - 'DOWNLOAD_NAME' => $display_name, - 'FILESIZE' => $filesize, - 'SIZE_VAR' => $size_lang, - 'COMMENT' => $comment, - - 'U_DOWNLOAD_LINK' => $download_link, - - 'UPLOAD_IMG' => $upload_image, - - 'L_DOWNLOADED_VIEWED' => $l_downloaded_viewed, - 'L_DOWNLOAD_COUNT' => sprintf($user->lang['DOWNLOAD_NUMBER'], $attachment['download_count'])) - ); + + $template_array = array_merge($additional_array, array( +// 'IS_FLASH' => ($display_cat == SWF_CAT) ? true : false, + 'IS_WM_STREAM' => ($display_cat == WM_CAT) ? true : false, + 'IS_RM_STREAM' => ($display_cat == RM_CAT) ? true : false, + 'IS_THUMBNAIL' => ($display_cat == THUMB_CAT) ? true : false, + 'IS_IMAGE' => ($display_cat == IMAGE_CAT) ? true : false, + 'DOWNLOAD_NAME' => $display_name, + 'FILESIZE' => $filesize, + 'SIZE_VAR' => $size_lang, + 'COMMENT' => $comment, + + 'U_DOWNLOAD_LINK' => $download_link, + + 'UPLOAD_IMG' => $upload_image, + + 'L_DOWNLOADED_VIEWED' => $l_downloaded_viewed, + 'L_DOWNLOAD_COUNT' => sprintf($user->lang['DOWNLOAD_NUMBER'], $attachment['download_count'])) + ); - $template->assign_block_vars('postrow.attachment', $template_array); - } + $template->assign_block_vars('postrow.attachment', $template_array); } } } |