mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
thumbnail creation support
git-svn-id: file:///svn/phpbb/trunk@4160 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
4f2cf69b68
commit
2e13c45371
4 changed files with 634 additions and 201 deletions
|
@ -38,13 +38,13 @@ if (!$auth->acl_get('a_attach'))
|
|||
trigger_error($user->lang['NO_ADMIN']);
|
||||
}
|
||||
|
||||
$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : '';
|
||||
$mode = (isset($_REQUEST['mode'])) ? trim(htmlspecialchars($_REQUEST['mode'])) : '';
|
||||
|
||||
$config_sizes = array('max_filesize' => 'size', 'attachment_quota' => 'quota_size', 'max_filesize_pm' => 'pm_size');
|
||||
|
||||
foreach ($config_sizes as $cfg_key => $var)
|
||||
{
|
||||
$$var = (isset($_REQUEST[$var])) ? htmlspecialchars($_REQUEST[$var]) : '';
|
||||
$$var = (isset($_REQUEST[$var])) ? trim(htmlspecialchars($_REQUEST[$var])) : '';
|
||||
}
|
||||
|
||||
$submit = (isset($_POST['submit'])) ? TRUE : FALSE;
|
||||
|
@ -54,8 +54,8 @@ $error = $notify = false;
|
|||
$error_msg = $notify_msg = '';
|
||||
|
||||
// Pull all config data
|
||||
$sql = "SELECT *
|
||||
FROM " . CONFIG_TABLE;
|
||||
$sql = 'SELECT *
|
||||
FROM ' . CONFIG_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
|
@ -92,7 +92,7 @@ while ($row = $db->sql_fetchrow($result))
|
|||
}
|
||||
}
|
||||
|
||||
if ($submit && $mode == 'manage')
|
||||
if ($submit && ($mode == 'manage' || $mode == 'cats'))
|
||||
{
|
||||
// Update Extension Group Filesizes
|
||||
if ($config_name == 'max_filesize')
|
||||
|
@ -103,14 +103,14 @@ while ($row = $db->sql_fetchrow($result))
|
|||
if ($old_size != $new_size)
|
||||
{
|
||||
// See, if we have a similar value of old_size in Extension Groups. If so, update these values.
|
||||
$sql = "UPDATE " . EXTENSION_GROUPS_TABLE . "
|
||||
SET max_filesize = " . $new_size . "
|
||||
WHERE max_filesize = " . $old_size;
|
||||
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . "
|
||||
SET max_filesize = $new_size
|
||||
WHERE max_filesize = $old_size";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
set_config($config_name, stripslashes($new[$config_name]));
|
||||
set_config($config_name, str_replace('\\\\', '\\', addslashes($new[$config_name])));
|
||||
|
||||
if (in_array($config_name, array('max_filesize', 'attachment_quota', 'max_filesize_pm')))
|
||||
{
|
||||
|
@ -129,14 +129,7 @@ if ($submit && ($mode == 'manage' || $mode == 'cats'))
|
|||
// Adjust the Upload Directory
|
||||
if (!$new['use_ftp_upload'])
|
||||
{
|
||||
if ( ($new['upload_dir'][0] == '/') || ( ($new['upload_dir'][0] != '/') && ($new['upload_dir'][1] == ':') ) )
|
||||
{
|
||||
$upload_dir = $new['upload_dir'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$upload_dir = $phpbb_root_path . $new['upload_dir'];
|
||||
}
|
||||
$upload_dir = ($new['upload_dir'][0] == '/' || ($new['upload_dir'][0] != '/' && $new['upload_dir'][1] == ':')) ? $new['upload_dir'] : $phpbb_root_path . $new['upload_dir'];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -170,54 +163,38 @@ if ($search_imagick)
|
|||
{
|
||||
$imagick = '';
|
||||
|
||||
if (eregi('convert', $imagick))
|
||||
$exe = ((defined('PHP_OS')) && (preg_match('#win#i', PHP_OS))) ? '.exe' : '';
|
||||
|
||||
if (empty($_ENV['MAGICK_HOME']))
|
||||
{
|
||||
$locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/');
|
||||
|
||||
foreach ($locations as $location)
|
||||
{
|
||||
if (file_exists($location . 'convert' . $exe) && is_executable($location . 'convert' . $exe))
|
||||
{
|
||||
$imagick = str_replace('\\', '/', $location);
|
||||
continue;
|
||||
}
|
||||
else if ($imagick != 'none')
|
||||
{
|
||||
if (!eregi('WIN', PHP_OS))
|
||||
{
|
||||
$retval = @exec('whereis convert');
|
||||
$paths = explode(' ', $retval);
|
||||
|
||||
if (is_array($paths))
|
||||
{
|
||||
foreach($paths as $path)
|
||||
{
|
||||
if (basename($path) == 'convert')
|
||||
{
|
||||
$imagick = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (eregi('WIN', PHP_OS))
|
||||
else
|
||||
{
|
||||
$path = 'c:/imagemagick/convert.exe';
|
||||
|
||||
if (@file_exists($path))
|
||||
{
|
||||
$imagick = $path;
|
||||
}
|
||||
}
|
||||
$imagick = str_replace('\\', '/', $_ENV['MAGICK_HOME']);
|
||||
}
|
||||
|
||||
$new['img_imagick'] = (@file_exists(trim($imagick))) ? trim($imagick) : '';
|
||||
$new['img_imagick'] = $imagick . 'convert' . $exe;
|
||||
}
|
||||
|
||||
// Check Settings
|
||||
if ($submit && $mode == 'manage')
|
||||
{
|
||||
$upload_dir = ( ($new['upload_dir'][0] == '/') || ($new['upload_dir'][0] != '/' && $new['upload_dir'][1] == ':') ) ? $new['upload_dir'] : $phpbb_root_path . $new['upload_dir'];
|
||||
|
||||
test_upload($error, $error_msg, $upload_dir, $new['ftp_path'], $new['use_ftp_upload'], false);
|
||||
}
|
||||
|
||||
|
||||
if ($submit && $mode == 'cats')
|
||||
{
|
||||
$upload_dir = ( ($new['upload_dir'][0] == '/') || ($new['upload_dir'][0] != '/' && $new['upload_dir'][1] == ':') ) ? $new['upload_dir'] . '/thumbs' : $phpbb_root_path . $new['upload_dir'] . '/thumbs';
|
||||
test_upload($error, $error_msg, $upload_dir, $new['ftp_path'] . '/thumbs', $new['use_ftp_upload'], true);
|
||||
}
|
||||
|
||||
|
@ -244,31 +221,45 @@ if ($submit && $mode == 'extensions')
|
|||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ( ($row['comment'] != $extensions[$row['extension_id']]['comment']) || (intval($row['group_id']) != intval($extensions[$row['extension_id']]['group_id'])) )
|
||||
if ($row['comment'] != $extensions[$row['extension_id']]['comment'] || intval($row['group_id']) != intval($extensions[$row['extension_id']]['group_id']))
|
||||
{
|
||||
$sql = "UPDATE " . EXTENSIONS_TABLE . "
|
||||
SET comment = '" . $extensions[$row['extension_id']]['comment'] . "', group_id = " . $extensions[$row['extension_id']]['group_id'] . "
|
||||
WHERE extension_id = " . $row['extension_id'];
|
||||
$db->sql_query($sql);
|
||||
add_log('admin', 'LOG_ATTACH_EXT_UPDATE', $row['extension']);
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Delete Extension ?
|
||||
$extension_id_list = (isset($_POST['extension_id_list'])) ? $_POST['extension_id_list'] : array();
|
||||
|
||||
$extension_id_sql = implode(', ', $extension_id_list);
|
||||
|
||||
if ($extension_id_sql != '')
|
||||
{
|
||||
$sql = 'DELETE
|
||||
FROM ' . EXTENSIONS_TABLE . '
|
||||
WHERE extension_id IN (' . $extension_id_sql . ')';
|
||||
FROM ' . EXTENSIONS_TABLE . "
|
||||
WHERE extension_id IN ($extension_id_sql)";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'SELECT extension
|
||||
FROM ' . EXTENSIONS_TABLE . "
|
||||
WHERE extension_id IN ($extension_id_sql)";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$extension_list = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$extension_list[] = $row['extension'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
add_log('admin', 'LOG_ATTACH_EXT_DEL', implode(', ', $extension_list));
|
||||
}
|
||||
|
||||
// Add Extension ?
|
||||
$add_extension = ( isset($_POST['add_extension']) ) ? trim(strip_tags($_POST['add_extension'])) : '';
|
||||
$add_extension = (isset($_POST['add_extension'])) ? strtolower(trim(strip_tags($_POST['add_extension']))) : '';
|
||||
$add_extension_explain = (isset($_POST['add_extension_explain'])) ? trim(strip_tags($_POST['add_extension_explain'])) : '';
|
||||
$add_extension_group = (isset($_POST['add_group_select'])) ? intval($_POST['add_group_select']) : '';
|
||||
$add = (isset($_POST['add_extension_check'])) ? TRUE : FALSE;
|
||||
|
@ -278,20 +269,20 @@ if ($submit && $mode == 'extensions')
|
|||
if (!$error)
|
||||
{
|
||||
// check extension
|
||||
$sql = "SELECT extension
|
||||
FROM " . EXTENSIONS_TABLE;
|
||||
$sql = 'SELECT extension
|
||||
FROM ' . EXTENSIONS_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (strtolower(trim($row['extension'])) == strtolower(trim($add_extension)))
|
||||
if ($row['extension'] == $add_extension)
|
||||
{
|
||||
$error = TRUE;
|
||||
if( isset($error_msg) )
|
||||
{
|
||||
$error_msg .= '<br />';
|
||||
}
|
||||
$error_msg .= sprintf($user->lang['EXTENSION_EXIST'], strtolower(trim($add_extension)));
|
||||
$error_msg .= sprintf($user->lang['EXTENSION_EXIST'], $add_extension);
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
@ -299,29 +290,30 @@ if ($submit && $mode == 'extensions')
|
|||
// Extension Forbidden ?
|
||||
if (!$error)
|
||||
{
|
||||
$sql = "SELECT extension
|
||||
FROM " . FORBIDDEN_EXTENSIONS_TABLE;
|
||||
$sql = 'SELECT extension
|
||||
FROM ' . FORBIDDEN_EXTENSIONS_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (strtolower(trim($row['extension'])) == strtolower(trim($add_extension)))
|
||||
if ($row['extension'] == $add_extension)
|
||||
{
|
||||
$error = TRUE;
|
||||
if( isset($error_msg) )
|
||||
{
|
||||
$error_msg .= '<br />';
|
||||
}
|
||||
$error_msg .= sprintf($user->lang['CANNOT_ADD_FORBIDDEN_EXTENSION'], strtolower(trim($add_extension)));
|
||||
$error_msg .= sprintf($user->lang['CANNOT_ADD_FORBIDDEN_EXTENSION'], $add_extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$sql = "INSERT INTO " . EXTENSIONS_TABLE . " (group_id, extension, comment)
|
||||
VALUES (" . $add_extension_group . ", '" . strtolower(trim($add_extension)) . "', '" . trim($add_extension_explain) . "')";
|
||||
$sql = 'INSERT INTO ' . EXTENSIONS_TABLE . " (group_id, extension, comment)
|
||||
VALUES ($add_extension_group, '" . $add_extension . "', '" . trim($add_extension_explain) . "')";
|
||||
$db->sql_query($sql);
|
||||
add_log('admin', 'LOG_ATTACH_EXT_ADD', $add_extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -373,7 +365,9 @@ if ($submit && $mode == 'ext_groups')
|
|||
'max_filesize' => $filesize_list[$i]
|
||||
);
|
||||
|
||||
$sql = "UPDATE " . EXTENSION_GROUPS_TABLE . " SET " . $db->sql_build_array('UPDATE', $group_sql) . " WHERE group_id = " . $group_change_list[$i];
|
||||
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . "
|
||||
SET " . $db->sql_build_array('UPDATE', $group_sql) . "
|
||||
WHERE group_id = " . $group_change_list[$i];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
|
@ -384,9 +378,9 @@ if ($submit && $mode == 'ext_groups')
|
|||
{
|
||||
$l_group_list = '';
|
||||
|
||||
$sql = "SELECT group_name
|
||||
FROM " . EXTENSION_GROUPS_TABLE . "
|
||||
WHERE group_id IN (" . implode(', ', $group_id_list) . ")";
|
||||
$sql = 'SELECT group_name
|
||||
FROM ' . EXTENSION_GROUPS_TABLE . '
|
||||
WHERE group_id IN (' . implode(', ', $group_id_list) . ')';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
|
@ -395,9 +389,9 @@ if ($submit && $mode == 'ext_groups')
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$sql = "DELETE
|
||||
FROM " . EXTENSION_GROUPS_TABLE . "
|
||||
WHERE group_id IN (" . implode(', ', $group_id_list) . ")";
|
||||
$sql = 'DELETE
|
||||
FROM ' . EXTENSION_GROUPS_TABLE . '
|
||||
WHERE group_id IN (' . implode(', ', $group_id_list) . ')';
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Set corresponding Extensions to a pending Group
|
||||
|
@ -422,8 +416,8 @@ if ($submit && $mode == 'ext_groups')
|
|||
if ($extension_group != '' && $add)
|
||||
{
|
||||
// check Extension Group
|
||||
$sql = "SELECT group_name
|
||||
FROM " . EXTENSION_GROUPS_TABLE;
|
||||
$sql = 'SELECT group_name
|
||||
FROM ' . EXTENSION_GROUPS_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
|
@ -453,23 +447,24 @@ if ($submit && $mode == 'ext_groups')
|
|||
'max_filesize' => $filesize
|
||||
);
|
||||
|
||||
$sql = "INSERT INTO " . EXTENSION_GROUPS_TABLE . " " . $db->sql_build_array('INSERT', $group_sql);
|
||||
$sql = 'INSERT INTO ' . EXTENSION_GROUPS_TABLE . ' ' .
|
||||
$db->sql_build_array('INSERT', $group_sql);
|
||||
$db->sql_query($sql);
|
||||
|
||||
add_log('admin', 'LOG_ATTACH_EXTGROUP_ADD', $extension_group);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT e.extension, g.*
|
||||
FROM " . EXTENSIONS_TABLE . " e, " . EXTENSION_GROUPS_TABLE . " g
|
||||
$sql = 'SELECT e.extension, g.*
|
||||
FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g
|
||||
WHERE e.group_id = g.group_id
|
||||
AND g.allow_group = 1";
|
||||
AND g.allow_group = 1';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$extensions = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$extension = strtolower(trim($row['extension']));
|
||||
$extension = $row['extension'];
|
||||
|
||||
$extensions['_allowed_'][] = $extension;
|
||||
$extensions[$extension]['display_cat'] = intval($row['cat_id']);
|
||||
|
@ -680,10 +675,10 @@ if ($mode == 'manage')
|
|||
|
||||
if ($mode == 'cats')
|
||||
{
|
||||
$sql = "SELECT group_name, cat_id
|
||||
FROM " . EXTENSION_GROUPS_TABLE . "
|
||||
$sql = 'SELECT group_name, cat_id
|
||||
FROM ' . EXTENSION_GROUPS_TABLE . '
|
||||
WHERE cat_id > 0
|
||||
ORDER BY cat_id";
|
||||
ORDER BY cat_id';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$s_assigned_groups = array();
|
||||
|
@ -717,7 +712,7 @@ if ($mode == 'cats')
|
|||
<?php
|
||||
|
||||
// Check Thumbnail Support
|
||||
if ( ($new['img_imagick'] == '') && (count(get_supported_image_types()) == 0) )
|
||||
if ($new['img_imagick'] == '' && count(get_supported_image_types()) == 0)
|
||||
{
|
||||
$new['img_create_thumbnail'] = '0';
|
||||
}
|
||||
|
@ -757,6 +752,7 @@ if ($mode == 'cats')
|
|||
|
||||
if ($mode == 'ext_groups')
|
||||
{
|
||||
// SELFNOTE: DO NOT FORGET TO TALK ABOUT IT!
|
||||
// $img_path = $config['upload_icons_path'];
|
||||
$img_path = 'images/upload_icons';
|
||||
|
||||
|
@ -865,8 +861,8 @@ if ($mode == 'ext_groups')
|
|||
</tr>
|
||||
<?
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM " . EXTENSION_GROUPS_TABLE;
|
||||
$sql = 'SELECT *
|
||||
FROM ' . EXTENSION_GROUPS_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
|
@ -931,9 +927,9 @@ if ($mode == 'ext_groups')
|
|||
|
||||
if ($viewgroup != -1 && $viewgroup == $row['group_id'])
|
||||
{
|
||||
$sql = "SELECT comment, extension
|
||||
FROM " . EXTENSIONS_TABLE . "
|
||||
WHERE group_id = " . intval($viewgroup);
|
||||
$sql = 'SELECT comment, extension
|
||||
FROM ' . EXTENSIONS_TABLE . '
|
||||
WHERE group_id = ' . intval($viewgroup);
|
||||
$e_result = $db->sql_query($sql);
|
||||
|
||||
while ($e_row = $db->sql_fetchrow($e_result))
|
||||
|
@ -1183,19 +1179,12 @@ function category_select($select_name, $group_id = -1)
|
|||
|
||||
if ($group_id != -1)
|
||||
{
|
||||
$sql = "SELECT cat_id
|
||||
FROM " . EXTENSION_GROUPS_TABLE . "
|
||||
WHERE group_id = " . intval($group_id);
|
||||
$sql = 'SELECT cat_id
|
||||
FROM ' . EXTENSION_GROUPS_TABLE . '
|
||||
WHERE group_id = ' . intval($group_id);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if (!($row = $db->sql_fetchrow($result)))
|
||||
{
|
||||
$cat_type = NONE_CAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cat_type = $row['cat_id'];
|
||||
}
|
||||
$cat_type = (!($row = $db->sql_fetchrow($result))) ? NONE_CAT : $row['cat_id'];
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
@ -1276,14 +1265,7 @@ function download_select($select_name, $group_id = -1)
|
|||
WHERE group_id = " . intval($group_id);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if (!($row = $db->sql_fetchrow($result)))
|
||||
{
|
||||
$download_mode = INLINE_LINK;
|
||||
}
|
||||
else
|
||||
{
|
||||
$download_mode = $row['download_mode'];
|
||||
}
|
||||
$download_mode = (!($row = $db->sql_fetchrow($result))) ? INLINE_LINK : $row['download_mode'];
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
|
|
@ -546,7 +546,7 @@ function upload_attachment($filename)
|
|||
|
||||
$filedata = array();
|
||||
$filedata['error'] = array();
|
||||
$filedata['post_attach'] = ($filename != '') ? true : false;
|
||||
$filedata['post_attach'] = ($filename != '') ? TRUE : FALSE;
|
||||
|
||||
if (!$filedata['post_attach'])
|
||||
{
|
||||
|
@ -569,7 +569,7 @@ function upload_attachment($filename)
|
|||
if (!in_array($filedata['extension'], $extensions['_allowed_']))
|
||||
{
|
||||
$filedata['error'][] = sprintf($user->lang['DISALLOWED_EXTENSION'], $filedata['extension']);
|
||||
$filedata['post_attach'] = false;
|
||||
$filedata['post_attach'] = FALSE;
|
||||
return $filedata;
|
||||
}
|
||||
|
||||
|
@ -580,7 +580,7 @@ function upload_attachment($filename)
|
|||
if ( preg_match("/[\\/:*?\"<>|]/i", $filename) )
|
||||
{
|
||||
$filedata['error'][] = sprintf($user->lang['INVALID_FILENAME'], $filename);
|
||||
$filedata['post_attach'] = false;
|
||||
$filedata['post_attach'] = FALSE;
|
||||
return $filedata;
|
||||
}
|
||||
|
||||
|
@ -588,7 +588,7 @@ function upload_attachment($filename)
|
|||
if ( ($file == 'none') )
|
||||
{
|
||||
$filedata['error'][] = (@ini_get('upload_max_filesize') == '') ? $user->lang['ATTACHMENT_PHP_SIZE_NA'] : sprintf($user->lang['ATTACHMENT_PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
|
||||
$filedata['post_attach'] = false;
|
||||
$filedata['post_attach'] = FALSE;
|
||||
return $filedata;
|
||||
}
|
||||
|
||||
|
@ -702,13 +702,11 @@ function upload_attachment($filename)
|
|||
|
||||
$filedata['filename'] = str_replace("'", "\'", $filedata['filename']);
|
||||
|
||||
/*
|
||||
// Do we have to create a thumbnail ?
|
||||
if ($cat_id == IMAGE_CAT && $config['img_create_thumbnail'])
|
||||
{
|
||||
$filedata['thumbnail'] = 1;
|
||||
}
|
||||
*/
|
||||
|
||||
// Upload Attachment
|
||||
if (!$config['use_ftp_upload'])
|
||||
|
@ -801,20 +799,17 @@ function move_uploaded_attachment($upload_mode, $source_filename, &$filedata)
|
|||
*/
|
||||
}
|
||||
|
||||
$filedata['thumbnail'] = 0;
|
||||
/* if ($filedata['thumbnail'])
|
||||
if ($filedata['thumbnail'])
|
||||
{
|
||||
if ($upload_mode == 'ftp')
|
||||
/* if ($upload_mode == 'ftp')
|
||||
{
|
||||
$source = $source_filename;
|
||||
$destination = 'thumbs/t_' . $destination_filename;
|
||||
}
|
||||
else
|
||||
{
|
||||
{*/
|
||||
$source = $config['upload_dir'] . '/' . $destination_filename;
|
||||
$destination = phpbb_realpath($config['upload_dir']);
|
||||
$destination .= '/thumbs/t_' . $destination_filename;
|
||||
}
|
||||
$destination = $config['upload_dir'] . '/thumbs/t_' . $destination_filename;
|
||||
|
||||
if (!create_thumbnail($source, $destination, $filedata['mimetype']))
|
||||
{
|
||||
|
@ -823,7 +818,7 @@ function move_uploaded_attachment($upload_mode, $source_filename, &$filedata)
|
|||
$filedata['thumbnail'] = 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -1461,4 +1456,459 @@ function user_notification($mode, $subject, $forum_id, $topic_id, $post_id)
|
|||
}
|
||||
}
|
||||
|
||||
// Read DWord (4 Bytes) from File
|
||||
function read_dword($fp)
|
||||
{
|
||||
$data = fread($fp, 4);
|
||||
$value = ord($data[0]) + (ord($data[1])<<8)+(ord($data[2])<<16)+(ord($data[3])<<24);
|
||||
if ($value >= 4294967294)
|
||||
{
|
||||
$value -= 4294967296;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
// Read Word (2 Bytes) from File - Note: It's an Intel Word
|
||||
function read_word($fp)
|
||||
{
|
||||
$data = fread($fp, 2);
|
||||
return ord($data[1]) * 256 + ord($data[0]);
|
||||
}
|
||||
|
||||
// Read Byte
|
||||
function read_byte($fp)
|
||||
{
|
||||
$data = fread($fp, 1);
|
||||
return ord($data);
|
||||
}
|
||||
|
||||
|
||||
// Get Image Dimensions... only a test for now, used within create_thumbnail
|
||||
function image_getdimension($file)
|
||||
{
|
||||
$size = @getimagesize($file);
|
||||
|
||||
if ($size[0] != 0 || $size[1] != 0)
|
||||
{
|
||||
return $size;
|
||||
}
|
||||
|
||||
// Try to get the Dimension manually, depending on the mimetype
|
||||
$fp = @fopen($file, 'rb');
|
||||
if (!$fp)
|
||||
{
|
||||
return $size;
|
||||
}
|
||||
|
||||
$error = FALSE;
|
||||
|
||||
// BMP - IMAGE
|
||||
$tmp_str = fread($fp, 2);
|
||||
if ($tmp_str == 'BM')
|
||||
{
|
||||
$length = read_dword($fp);
|
||||
|
||||
if ($length <= 6)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$i = read_dword($fp);
|
||||
if ($i != 0)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$i = read_dword($fp);
|
||||
|
||||
if ($i != 0x3E && $i != 0x76 && $i != 0x436 && $i != 0x36)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$tmp_str = fread($fp, 4);
|
||||
$width = read_dword($fp);
|
||||
$height = read_dword($fp);
|
||||
|
||||
if ($width > 3000 || $height > 3000)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
'6'
|
||||
);
|
||||
}
|
||||
|
||||
$error = FALSE;
|
||||
fclose($fp);
|
||||
|
||||
// GIF - IMAGE
|
||||
$fp = @fopen($file, 'rb');
|
||||
|
||||
$tmp_str = fread($fp, 3);
|
||||
|
||||
if ($tmp_str == 'GIF')
|
||||
{
|
||||
$tmp_str = fread($fp, 3);
|
||||
$width = read_word($fp);
|
||||
$height = read_word($fp);
|
||||
|
||||
$info_byte = fread($fp, 1);
|
||||
$info_byte = ord($info_byte);
|
||||
if (($info_byte & 0x80) != 0x80 && ($info_byte & 0x80) != 0)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (($info_byte & 8) != 0)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
'1'
|
||||
);
|
||||
}
|
||||
|
||||
$error = FALSE;
|
||||
fclose($fp);
|
||||
|
||||
// JPG - IMAGE
|
||||
$fp = @fopen($file, 'rb');
|
||||
|
||||
$tmp_str = fread($fp, 4);
|
||||
$w1 = read_word($fp);
|
||||
if (intval($w1) < 16)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$tmp_str = fread($fp, 4);
|
||||
if ($tmp_str == 'JFIF')
|
||||
{
|
||||
$o_byte = fread($fp, 1);
|
||||
if (intval($o_byte) != 0)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$str = fread($fp, 2);
|
||||
$b = read_byte($fp);
|
||||
|
||||
if ($b != 0 && $b != 1 && $b != 2)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$width = read_word($fp);
|
||||
$height = read_word($fp);
|
||||
|
||||
if ($width <= 0 || $height <= 0)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
'2'
|
||||
);
|
||||
}
|
||||
|
||||
$error = FALSE;
|
||||
fclose($fp);
|
||||
|
||||
// PCX - IMAGE - I do not think we need this, does browser actually support this imagetype? ;)
|
||||
// But let me have the fun...
|
||||
/*
|
||||
$fp = @fopen($file, 'rb');
|
||||
|
||||
$tmp_str = fread($fp, 3);
|
||||
|
||||
if (((ord($tmp_str[0]) == 10)) && ( (ord($tmp_str[1]) == 0) || (ord($tmp_str[1]) == 2) || (ord($tmp_str[1]) == 3) || (ord($tmp_str[1]) == 4) || (ord($tmp_str[1]) == 5) ) && ( (ord($tmp_str[2]) == 1) ) )
|
||||
{
|
||||
$b = fread($fp, 1);
|
||||
|
||||
if (ord($b) != 1 && ord($b) != 2 && ord($b) != 4 && ord($b) != 8 && ord($b) != 24)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$xmin = read_word($fp);
|
||||
$ymin = read_word($fp);
|
||||
$xmax = read_word($fp);
|
||||
$ymax = read_word($fp);
|
||||
$tmp_str = fread($fp, 52);
|
||||
|
||||
$b = fread($fp, 1);
|
||||
if ($b != 0)
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$width = $xmax - $xmin + 1;
|
||||
$height = $ymax - $ymin + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = TRUE;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
fclose($fp);
|
||||
return array(
|
||||
$width,
|
||||
$height,
|
||||
'7'
|
||||
);
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
*/
|
||||
return $size;
|
||||
}
|
||||
|
||||
// Calculate the needed size for Thumbnail
|
||||
// I am sure i had this grabbed from some site... source: unknown
|
||||
function get_img_size_format($width, $height)
|
||||
{
|
||||
// Change these two values to define the Thumbnail Size
|
||||
$max_width = 300;
|
||||
$max_height = 85;
|
||||
|
||||
if ($height > $max_height)
|
||||
{
|
||||
$new_width = ($max_height / $height) * $width;
|
||||
$new_height = $max_height;
|
||||
|
||||
if ($new_width > $max_width)
|
||||
{
|
||||
$new_height = ($max_width / $new_width) * $new_height;
|
||||
$new_width = $max_width;
|
||||
}
|
||||
}
|
||||
else if ($width > $max_width)
|
||||
{
|
||||
$new_height = ($max_width / $width) * $height;
|
||||
$new_width = $max_width;
|
||||
|
||||
if ($new_height > $max_height)
|
||||
{
|
||||
$new_width = ($max_height / $new_height) * $new_width;
|
||||
$new_height = $max_height;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_width = $width;
|
||||
$new_height = $height;
|
||||
}
|
||||
|
||||
return array(
|
||||
round($new_width),
|
||||
round($new_height)
|
||||
);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Create Thumbnail
|
||||
function create_thumbnail($source, $new_file, $mimetype)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$source = realpath($source);
|
||||
$min_filesize = intval($config['img_min_thumb_filesize']);
|
||||
|
||||
$img_filesize = (file_exists($source)) ? @filesize($source) : FALSE;
|
||||
|
||||
if (!$img_filesize || $img_filesize <= $min_filesize)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$size = image_getdimension($source);
|
||||
|
||||
if ($size[0] == 0 && $size[1] == 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$new_size = get_img_size_format($size[0], $size[1]);
|
||||
|
||||
$tmp_path = '';
|
||||
$old_file = '';
|
||||
|
||||
/*
|
||||
if (intval($config['allow_ftp_upload']))
|
||||
{
|
||||
$old_file = $new_file;
|
||||
|
||||
$tmp_path = explode('/', $source);
|
||||
$tmp_path[count($tmp_path)-1] = '';
|
||||
$tmp_path = implode('/', $tmp_path);
|
||||
|
||||
if ($tmp_path == '')
|
||||
{
|
||||
$tmp_path = '/tmp';
|
||||
}
|
||||
|
||||
$value = trim($tmp_path);
|
||||
|
||||
if ($value[strlen($value)-1] == '/')
|
||||
{
|
||||
$value[strlen($value)-1] = ' ';
|
||||
}
|
||||
|
||||
$new_file = trim($value) . '/t00000';
|
||||
}
|
||||
*/
|
||||
|
||||
$used_imagick = FALSE;
|
||||
|
||||
if ($config['img_imagick'] != '')
|
||||
{
|
||||
if (is_array($size) && count($size) > 0)
|
||||
{
|
||||
@exec($config['img_imagick'] . ' -quality 75 -antialias -sample ' . $new_size[0] . 'x' . $new_size[1] . ' ' . $source . ' +profile "*" ' . $new_file);
|
||||
if (file_exists($new_file))
|
||||
{
|
||||
$used_imagick = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$used_imagick)
|
||||
{
|
||||
$type = $size[2];
|
||||
$supported_types = get_supported_image_types();
|
||||
|
||||
if (in_array($type, $supported_types))
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case '1' :
|
||||
$image = imagecreatefromgif($source);
|
||||
$new_image = imagecreate($new_size[0], $new_size[1]);
|
||||
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
|
||||
imagegif($new_image, $new_file);
|
||||
break;
|
||||
|
||||
case '2' :
|
||||
$image = imagecreatefromjpeg($source);
|
||||
$new_image = imagecreate($new_size[0], $new_size[1]);
|
||||
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
|
||||
imagejpeg($new_image, $new_file, 90);
|
||||
break;
|
||||
|
||||
case '3' :
|
||||
$image = imagecreatefrompng($source);
|
||||
$new_image = imagecreate($new_size[0], $new_size[1]);
|
||||
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
|
||||
imagepng($new_image, $new_file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists($new_file))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* if (intval($config['allow_ftp_upload']))
|
||||
{
|
||||
$result = ftp_file($new_file, $old_file, $this->type, TRUE); // True for disable error-mode
|
||||
if (!$result)
|
||||
{
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{*/
|
||||
|
||||
@chmod($new_file, 0666);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -644,7 +644,7 @@ class parse_message
|
|||
|
||||
function emoticons($smile)
|
||||
{
|
||||
global $db, $user;
|
||||
global $db, $user, $phpbb_root_path;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM " . SMILIES_TABLE;
|
||||
|
@ -656,7 +656,7 @@ class parse_message
|
|||
do
|
||||
{
|
||||
$match[] = "#(?<=.\W|\W.|^\W)" . preg_quote($row['code'], '#') . "(?=.\W|\W.|\W$)#";
|
||||
$replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILE_PATH}/' . $row['smile_url'] . '" border="0" alt="' . $row['emoticon'] . '" title="' . $row['emoticon'] . '" /><!-- s' . $row['code'] . ' -->';
|
||||
$replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILE_PATH}/' . $phpbb_root_path . $row['smile_url'] . '" border="0" alt="' . $row['emoticon'] . '" title="' . $row['emoticon'] . '" /><!-- s' . $row['code'] . ' -->';
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
|
||||
|
@ -675,19 +675,19 @@ class parse_message
|
|||
$this->filename_data['filecomment'] = (isset($_POST['filecomment'])) ? trim( strip_tags($_POST['filecomment'])) : '';
|
||||
$this->filename_data['filename'] = ($_FILES['fileupload']['name'] != 'none') ? trim($_FILES['fileupload']['name']) : '';
|
||||
|
||||
$add_file = ( isset($_POST['add_file']) ) ? true : false;
|
||||
$delete_file = ( isset($_POST['delete_file']) ) ? true : false;
|
||||
$edit_comment = ( isset($_POST['edit_comment']) ) ? true : false;
|
||||
$add_file = (isset($_POST['add_file'])) ? TRUE : FALSE;
|
||||
$delete_file = (isset($_POST['delete_file'])) ? TRUE : FALSE;
|
||||
$edit_comment = (isset($_POST['edit_comment'])) ? TRUE : FALSE;
|
||||
|
||||
if ($submit && ($mode == 'post' || $mode == 'reply' || $mode == 'edit') && $this->filename_data['filename'] != '')
|
||||
{
|
||||
if ( $num_attachments < $config['max_attachments'] ) //|| $auth->acl_gets('m_', 'a_', $forum_id) )
|
||||
if ($num_attachments < $config['max_attachments'] || $auth->acl_gets('m_', 'a_'))
|
||||
{
|
||||
$filedata = upload_attachment($this->filename_data['filename']);
|
||||
|
||||
$error = $filedata['error'];
|
||||
|
||||
if (($filedata['post_attach']) && (!count($error)))
|
||||
if ($filedata['post_attach'] && !count($error))
|
||||
{
|
||||
$new_entry = array(
|
||||
'physical_filename' => $filedata['destination_filename'],
|
||||
|
@ -712,7 +712,7 @@ class parse_message
|
|||
// This is very relevant, because it could happen that the post got not submitted, but we do not
|
||||
// know this circumstance here. We could be at the posting page or we could be redirected to the entered
|
||||
// post. :)
|
||||
$filedata['post_attach'] = false;
|
||||
$filedata['post_attach'] = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -748,7 +748,7 @@ class parse_message
|
|||
// a quick way to reindex the array. :)
|
||||
$this->attachment_data = array_merge($this->attachment_data);
|
||||
}
|
||||
else if ( ($edit_comment) || ($add_file) || ($preview) )
|
||||
else if ($edit_comment || $add_file || $preview)
|
||||
{
|
||||
if ($edit_comment)
|
||||
{
|
||||
|
@ -760,7 +760,7 @@ class parse_message
|
|||
}
|
||||
}
|
||||
|
||||
if ((($add_file) || ($preview) ) && ($this->filename_data['filename'] != '') )
|
||||
if (($add_file || $preview) && $this->filename_data['filename'] != '')
|
||||
{
|
||||
if ($num_attachments < $config['max_attachments'] || $auth->acl_gets('m_', 'a_'))
|
||||
{
|
||||
|
|
|
@ -156,6 +156,7 @@ $lang = array_merge($lang, array(
|
|||
'LOG_ACL_PRESET_DEL' => '<b>Deleted permission preset</b><br />» %s',
|
||||
'LOG_ATTACH_EXT_ADD' => '<b>Added or edited attachment extension</b><br />» %s',
|
||||
'LOG_ATTACH_EXT_DEL' => '<b>Removed attachment extension</b><br />» %s',
|
||||
'LOG_ATTACH_EXT_UPDATE' => '<b>Updated attachment extension</b><br />» %s',
|
||||
'LOG_ATTACH_EXTGROUP_ADD' => '<b>Added or edited extension group</b><br />» %s',
|
||||
'LOG_ATTACH_EXTGROUP_DEL' => '<b>Removed extension group</b><br />» %s',
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue