fixed delete post bug, use extension cache while posting, fix download counter for images

git-svn-id: file:///svn/phpbb/trunk@3838 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-04-15 18:56:31 +00:00
parent 93cb1853b5
commit 42b50a5d0f
3 changed files with 22 additions and 25 deletions

View file

@ -785,7 +785,7 @@ function obtain_attach_extensions(&$extensions)
else else
{ {
// Don't count on forbidden extensions table, because it is not allowed to allow forbidden extensions at all // Don't count on forbidden extensions table, because it is not allowed to allow forbidden extensions at all
$sql = "SELECT e.extension, g.cat_id, g.download_mode, g.upload_icon $sql = "SELECT e.extension, g.*
FROM " . EXTENSIONS_TABLE . " e, " . EXTENSION_GROUPS_TABLE . " g FROM " . EXTENSIONS_TABLE . " e, " . EXTENSION_GROUPS_TABLE . " g
WHERE e.group_id = g.group_id WHERE e.group_id = g.group_id
AND g.allow_group = 1"; AND g.allow_group = 1";
@ -800,6 +800,7 @@ function obtain_attach_extensions(&$extensions)
$extensions[$extension]['display_cat'] = intval($row['cat_id']); $extensions[$extension]['display_cat'] = intval($row['cat_id']);
$extensions[$extension]['download_mode'] = intval($row['download_mode']); $extensions[$extension]['download_mode'] = intval($row['download_mode']);
$extensions[$extension]['upload_icon'] = trim($row['upload_icon']); $extensions[$extension]['upload_icon'] = trim($row['upload_icon']);
$extensions[$extension]['max_filesize'] = intval($row['max_filesize']);
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);

View file

@ -956,7 +956,7 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, $post_data)
$forum_update_sql = ''; $forum_update_sql = '';
$user_update_sql = ''; $user_update_sql = '';
$topic_update_sql = 'topic_replies = topic_replies - 1, topic_replies_real = topic_replies_real - 1, '; $topic_update_sql = 'topic_replies = topic_replies - 1, topic_replies_real = topic_replies_real - 1';
// Only one post... delete topic // Only one post... delete topic
if ($post_data['topic_first_post_id'] == $post_data['topic_last_post_id']) if ($post_data['topic_first_post_id'] == $post_data['topic_last_post_id'])
@ -1401,16 +1401,20 @@ function upload_attachment($filename)
$filedata['filesize'] = (!@filesize($file)) ? intval($_FILES['size']) : @filesize($file); $filedata['filesize'] = (!@filesize($file)) ? intval($_FILES['size']) : @filesize($file);
$sql = "SELECT g.allow_group, g.max_filesize, g.cat_id $extensions = array();
FROM " . EXTENSION_GROUPS_TABLE . " g, " . EXTENSIONS_TABLE . " e obtain_attach_extensions($extensions);
WHERE (g.group_id = e.group_id) AND (e.extension = '" . $filedata['extension'] . "')";
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result); // Check Extension
$db->sql_freeresult($result); if (!in_array($filedata['extension'], $extensions['_allowed_']))
{
$filedata['error'] = true;
$filedata['err_msg'] = sprintf($user->lang['DISALLOWED_EXTENSION'], $filedata['extension']);
$filedata['post_attach'] = false;
return ($filedata);
}
$allowed_filesize = ( intval($row['max_filesize']) != 0 ) ? intval($row['max_filesize']) : intval($config['max_filesize']); $allowed_filesize = ($extensions[$filedata['extension']]['max_filesize'] != 0) ? $extensions[$filedata['extension']]['max_filesize'] : $config['max_filesize'];
$cat_id = intval($row['cat_id']); $cat_id = $extensions[$filedata['extension']]['display_cat'];
// check Filename // check Filename
if ( preg_match("/[\\/:*?\"<>|]/i", $filename) ) if ( preg_match("/[\\/:*?\"<>|]/i", $filename) )
@ -1430,14 +1434,6 @@ function upload_attachment($filename)
return ($filedata); return ($filedata);
} }
// Check Extension
if (intval($row['allow_group']) == 0)
{
$filedata['error'] = true;
$filedata['err_msg'] = sprintf($user->lang['DISALLOWED_EXTENSION'], $filedata['extension']);
$filedata['post_attach'] = false;
return ($filedata);
}
/* /*
// Check Image Size, if it is an image // Check Image Size, if it is an image
if ( (!$acl->gets('m_', 'a_')) && ($cat_id == IMAGE_CAT) ) if ( (!$acl->gets('m_', 'a_')) && ($cat_id == IMAGE_CAT) )

View file

@ -1027,18 +1027,18 @@ if ($row = $db->sql_fetchrow($result))
// NOTE: If you want to use the download.php everytime an image is displayed inlined, replace the // 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): // Section between BEGIN and END with (Without the // of course):
// $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&amp;id=' . $attachment['attach_id']; // $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&amp;id=' . $attachment['attach_id'];
// $download_link = TRUE; // $linked_image = TRUE;
// //
// BEGIN // BEGIN
if ((intval($config['ftp_upload'])) && (trim($config['upload_dir']) == '')) if ((intval($config['ftp_upload'])) && (trim($config['upload_dir']) == ''))
{ {
$img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&amp;id=' . $attachment['attach_id']; $img_source = $phpbb_root_path . 'download.' . $phpEx . $SID . '&amp;id=' . $attachment['attach_id'];
$download_link = TRUE; $linked_image = TRUE;
} }
else else
{ {
$img_source = $filename; $img_source = $filename;
$download_link = FALSE; $linked_image = FALSE;
} }
// END // END
@ -1046,9 +1046,9 @@ if ($row = $db->sql_fetchrow($result))
$download_link = $img_source; $download_link = $img_source;
// Directly Viewed Image ... update the download count // Directly Viewed Image ... update the download count
if (!$download_link) if (!$linked_image)
{ {
$update_count = true; $update_count = TRUE;
} }
} }
@ -1134,9 +1134,9 @@ if ($row = $db->sql_fetchrow($result))
if ($update_count) if ($update_count)
{ {
$sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . ' $sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . "
SET download_count = download_count + 1 SET download_count = download_count + 1
WHERE attach_id = ' . $attachment['attach_id']; WHERE attach_id = " . $attachment['attach_id'];
$db->sql_query($sql); $db->sql_query($sql);
} }
} }