mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-18 22:58:10 +01:00
changed attachment processing (posting), the old way was a mess. :)
git-svn-id: file:///svn/phpbb/trunk@3960 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
3a4e4374dc
commit
9def7a65e3
@ -147,7 +147,7 @@ function format_display($message, $html, $bbcode, $uid, $url, $smilies, $sig)
|
||||
|
||||
// If we allow users to disable display of emoticons
|
||||
// we'll need an appropriate check and preg_replace here
|
||||
$message = (empty($smilies) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message);
|
||||
$message = (empty($smilies) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $message);
|
||||
|
||||
// Replace naughty words such as farty pants
|
||||
if (sizeof($censors))
|
||||
@ -585,11 +585,7 @@ function upload_attachment($filename)
|
||||
|
||||
// Opera add the name to the mime type
|
||||
$filedata['mimetype'] = ( strstr($filedata['mimetype'], '; name') ) ? str_replace(strstr($filedata['mimetype'], '; name'), '', $filedata['mimetype']) : $filedata['mimetype'];
|
||||
$filedata['extension'] = strrchr(strtolower($filename), '.');
|
||||
$filedata['extension'][0] = ' ';
|
||||
$filedata['extension'] = strtolower(trim($filedata['extension']));
|
||||
$filedata['extension'] = (is_array($filedata['extension'])) ? '' : $filedata['extension'];
|
||||
|
||||
$filedata['extension'] = array_pop(explode('.', strtolower($filename)));
|
||||
$filedata['filesize'] = (!@filesize($file)) ? intval($_FILES['size']) : @filesize($file);
|
||||
|
||||
$extensions = array();
|
||||
@ -929,7 +925,7 @@ function phpbb_unlink($filename, $mode = 'file', $use_ftp = false)
|
||||
|
||||
|
||||
// Submit Post
|
||||
function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_uid, $poll, $attachment_data, $post_data)
|
||||
function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_uid, $poll, $attachment_data, $filename_data, $post_data)
|
||||
{
|
||||
global $db, $auth, $user, $config, $phpEx, $SID, $template;
|
||||
|
||||
@ -950,7 +946,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
|
||||
'topic_type' => $topic_type,
|
||||
'topic_approved' => ($auth->acl_get('f_moderate', $post_data['forum_id']) && !$auth->acl_get('f_ignorequeue', $post_data['forum_id'])) ? 0 : 1,
|
||||
'icon_id' => $post_data['icon_id'],
|
||||
'topic_attachment' => (sizeof($attachment_data['physical_filename'])) ? 1 : 0,
|
||||
'topic_attachment' => (sizeof($filename_data['physical_filename'])) ? 1 : 0,
|
||||
'topic_poster' => intval($user->data['user_id']),
|
||||
'topic_first_poster_name' => ($username != '') ? stripslashes($username) : (($user->data['user_id'] == ANONYMOUS) ? '' : stripslashes($user->data['username']))
|
||||
);
|
||||
@ -1052,32 +1048,32 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
|
||||
}
|
||||
|
||||
// Submit Attachments
|
||||
if (count($attachment_data['attach_id']) && !empty($post_data['post_id']) && ($mode == 'post' || $mode == 'reply' || $mode == 'edit'))
|
||||
if (count($attachment_data) && !empty($post_data['post_id']) && ($mode == 'post' || $mode == 'reply' || $mode == 'edit'))
|
||||
{
|
||||
for ($i = 0; $i < count($attachment_data['attach_id']); $i++)
|
||||
foreach ($attachment_data as $attach_row)
|
||||
{
|
||||
if ($attachment_data['attach_id'][$i] != '-1')
|
||||
if ($attach_row['attach_id'] != '-1')
|
||||
{
|
||||
// update entry in db if attachment already stored in db and filespace
|
||||
$attach_sql = array(
|
||||
'comment' => trim($attachment_data['comment'][$i])
|
||||
'comment' => trim($attach_row['comment'])
|
||||
);
|
||||
|
||||
$sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' WHERE attach_id = ' . $attachment_data['attach_id'][$i];
|
||||
$sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' WHERE attach_id = ' . intval($attach_row['attach_id']);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
// insert attachment into db
|
||||
$attach_sql = array(
|
||||
'physical_filename' => $attachment_data['physical_filename'][$i],
|
||||
'real_filename' => $attachment_data['real_filename'][$i],
|
||||
'comment' => trim($attachment_data['comment'][$i]),
|
||||
'extension' => $attachment_data['extension'][$i],
|
||||
'mimetype' => $attachment_data['mimetype'][$i],
|
||||
'filesize' => $attachment_data['filesize'][$i],
|
||||
'filetime' => $attachment_data['filetime'][$i],
|
||||
'thumbnail' => $attachment_data['thumbnail'][$i]
|
||||
'physical_filename' => $attach_row['physical_filename'],
|
||||
'real_filename' => $attach_row['real_filename'],
|
||||
'comment' => trim($attach_row['comment']),
|
||||
'extension' => $attach_row['extension'],
|
||||
'mimetype' => $attach_row['mimetype'],
|
||||
'filesize' => $attach_row['filesize'],
|
||||
'filetime' => $attach_row['filetime'],
|
||||
'thumbnail' => $attach_row['thumbnail']
|
||||
);
|
||||
|
||||
$sql = 'INSERT INTO ' . ATTACHMENTS_DESC_TABLE . ' ' . $db->sql_build_array('INSERT', $attach_sql);
|
||||
@ -1096,7 +1092,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
|
||||
}
|
||||
}
|
||||
|
||||
if (count($attachment_data['attach_id']) > 0)
|
||||
if (count($attachment_data))
|
||||
{
|
||||
$sql = "UPDATE " . POSTS_TABLE . "
|
||||
SET post_attachment = 1
|
||||
|
@ -55,6 +55,9 @@ class parse_message
|
||||
var $message = '';
|
||||
var $disabled_bbcodes = array();
|
||||
|
||||
var $attachment_data = array();
|
||||
var $filename_data = array();
|
||||
|
||||
function parse_message($message_type)
|
||||
{
|
||||
$this->message_mode = $message_type;
|
||||
@ -543,26 +546,26 @@ class parse_message
|
||||
return;
|
||||
}
|
||||
|
||||
function parse_attachments($mode, $post_id, $submit, $preview, $refresh, &$attachment_data)
|
||||
function parse_attachments($mode, $post_id, $submit, $preview, $refresh)
|
||||
{
|
||||
global $config, $_FILE, $_POST, $auth, $user;
|
||||
|
||||
$error = false;
|
||||
$error_msg = '';
|
||||
|
||||
$num_attachments = count($attachment_data['attach_id']);
|
||||
$attachment_data['filecomment'] = ( isset($_POST['filecomment']) ) ? trim( strip_tags($_POST['filecomment'])) : '';
|
||||
$attachment_data['filename'] = ( $_FILES['fileupload']['name'] != 'none' ) ? trim($_FILES['fileupload']['name']) : '';
|
||||
$num_attachments = count($this->attachment_data);
|
||||
$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;
|
||||
|
||||
if ( $submit && ($mode == 'post' || $mode == 'reply' || $mode == 'edit') && $attachment_data['filename'] != '')
|
||||
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) )
|
||||
{
|
||||
$filedata = upload_attachment($attachment_data['filename']);
|
||||
$filedata = upload_attachment($this->filename_data['filename']);
|
||||
|
||||
if ($filedata['error'])
|
||||
{
|
||||
@ -572,19 +575,22 @@ class parse_message
|
||||
|
||||
if (($filedata['post_attach']) && (!$error))
|
||||
{
|
||||
array_unshift($attachment_data['physical_filename'], $filedata['destination_filename']);
|
||||
array_unshift($attachment_data['comment'], $attachment_data['filecomment']);
|
||||
array_unshift($attachment_data['real_filename'], $filedata['filename']);
|
||||
array_unshift($attachment_data['extension'], $filedata['extension']);
|
||||
array_unshift($attachment_data['mimetype'], $filedata['mimetype']);
|
||||
array_unshift($attachment_data['filesize'], $filedata['filesize']);
|
||||
array_unshift($attachment_data['filetime'], $filedata['filetime']);
|
||||
array_unshift($attachment_data['attach_id'], '-1');
|
||||
array_unshift($attachment_data['thumbnail'], $filedata['thumbnail']);
|
||||
$new_entry = array(
|
||||
'physical_filename' => $filedata['destination_filename'],
|
||||
'comment' => $this->filename_data['filecomment'],
|
||||
'real_filename' => $filedata['filename'],
|
||||
'extension' => $filedata['extension'],
|
||||
'mimetype' => $filedata['mimetype'],
|
||||
'filesize' => $filedata['filesize'],
|
||||
'filetime' => $filedata['filetime'],
|
||||
'attach_id' => '-1',
|
||||
'thumbnail' => $filedata['thumbnail']
|
||||
);
|
||||
|
||||
$attachment_data['filecomment'] = '';
|
||||
$this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data);
|
||||
$this->filename_data['filecomment'] = '';
|
||||
|
||||
// This Variable is set to FALSE here, because the Attachment Mod enter Attachments into the
|
||||
// This Variable is set to FALSE here, because Attachments are entered into the
|
||||
// Database in two modes, one if the id_list is -1 and the second one if post_attach is true
|
||||
// Since post_attach is automatically switched to true if an Attachment got added to the filesystem,
|
||||
// but we are assigning an id of -1 here, we have to reset the post_attach variable to FALSE.
|
||||
@ -607,74 +613,27 @@ class parse_message
|
||||
// Perform actions on temporary attachments
|
||||
if ($delete_file)
|
||||
{
|
||||
// store old values
|
||||
$actual_list = ( isset($_POST['attachment_list']) ) ? $_POST['attachment_list'] : array();
|
||||
$actual_comment_list = ( isset($_POST['comment_list']) ) ? $_POST['comment_list'] : array();
|
||||
$actual_filename_list = ( isset($_POST['filename_list']) ) ? $_POST['filename_list'] : array();
|
||||
$actual_extension_list = ( isset($_POST['extension_list']) ) ? $_POST['extension_list'] : array();
|
||||
$actual_mimetype_list = ( isset($_POST['mimetype_list']) ) ? $_POST['mimetype_list'] : array();
|
||||
$actual_filesize_list = ( isset($_POST['filesize_list']) ) ? $_POST['filesize_list'] : array();
|
||||
$actual_filetime_list = ( isset($_POST['filetime_list']) ) ? $_POST['filetime_list'] : array();
|
||||
$actual_id_list = ( isset($_POST['attach_id_list']) ) ? $_POST['attach_id_list'] : array();
|
||||
$actual_thumbnail_list = ( isset($_POST['attach_thumbnail_list']) ) ? $_POST['attach_thumbnail_list'] : array();
|
||||
|
||||
// clean values
|
||||
|
||||
$attachment_data['physical_filename'] = array();
|
||||
$attachment_data['comment'] = array();
|
||||
$attachment_data['real_filename'] = array();
|
||||
$attachment_data['extension'] = array();
|
||||
$attachment_data['mimetype'] = array();
|
||||
$attachment_data['filesize'] = array();
|
||||
$attachment_data['filetime'] = array();
|
||||
$attachment_data['attach_id'] = array();
|
||||
$attachment_data['thumbnail'] = array();
|
||||
|
||||
// restore values :)
|
||||
if( isset($_POST['attachment_list']) )
|
||||
foreach ($_POST['delete_file'] as $index => $value)
|
||||
{
|
||||
for ($i = 0; $i < count($actual_list); $i++)
|
||||
// delete selected attachment
|
||||
if ($this->attachment_data[$index]['attach_id'] == '-1')
|
||||
{
|
||||
$restore = false;
|
||||
if ($delete_file)
|
||||
{
|
||||
if (!isset($_POST['delete_file'][$actual_list[$i]]))
|
||||
{
|
||||
$restore = true;
|
||||
}
|
||||
}
|
||||
phpbb_unlink($this->attachment_data[$index]['physical_filename'], 'file', $config['use_ftp_upload']);
|
||||
|
||||
if ($restore)
|
||||
if ($this->attachment_data[$index]['thumbnail'] == 1)
|
||||
{
|
||||
$attachment_data['physical_filename'][] = $actual_list[$i];
|
||||
$attachment_data['comment'][] = $actual_comment_list[$i];
|
||||
$attachment_data['real_filename'][] = $actual_filename_list[$i];
|
||||
$attachment_data['extension'][] = $actual_extension_list[$i];
|
||||
$attachment_data['mimetype'][] = $actual_mimetype_list[$i];
|
||||
$attachment_data['filesize'][] = $actual_filesize_list[$i];
|
||||
$attachment_data['filetime'][] = $actual_filetime_list[$i];
|
||||
$attachment_data['attach_id'][] = $actual_id_list[$i];
|
||||
$attachment_data['thumbnail'][] = $actual_thumbnail_list[$i];
|
||||
}
|
||||
else
|
||||
{
|
||||
// delete selected attachment
|
||||
if ($actual_id_list[$i] == '-1')
|
||||
{
|
||||
phpbb_unlink($actual_list[$i], 'file', $config['use_ftp_upload']);
|
||||
|
||||
if ($actual_thumbnail_list[$i] == 1)
|
||||
{
|
||||
phpbb_unlink('t_' . $actual_list[$i], 'thumbnail', $config['use_ftp_upload']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete_attachment($post_id, $actual_id_list[$i]);
|
||||
}
|
||||
phpbb_unlink('t_' . $this->attachment_data[$index]['physical_filename'], 'thumbnail', $config['use_ftp_upload']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete_attachment($post_id, intval($this->attachment_data[$index]['attach_id']));
|
||||
}
|
||||
unset($this->attachment_data[$index]);
|
||||
}
|
||||
|
||||
// a quick way to reindex the array. :)
|
||||
$this->attachment_data = array_merge($this->attachment_data);
|
||||
}
|
||||
else if ( ($edit_comment) || ($add_file) || ($preview) )
|
||||
{
|
||||
@ -682,19 +641,17 @@ class parse_message
|
||||
{
|
||||
$actual_comment_list = ( isset($_POST['comment_list']) ) ? $_POST['comment_list'] : '';
|
||||
|
||||
$attachment_data['comment'] = array();
|
||||
|
||||
for ($i = 0; $i < count($attachment_data['physical_filename']); $i++)
|
||||
foreach ($actual_comment_list as $index => $entry)
|
||||
{
|
||||
$attachment_data['comment'][$i] = $actual_comment_list[$i];
|
||||
$this->attachment_data[$index]['comment'] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
if ((($add_file) || ($preview) ) && ($attachment_data['filename'] != '') )
|
||||
if ((($add_file) || ($preview) ) && ($this->filename_data['filename'] != '') )
|
||||
{
|
||||
if ( $num_attachments < $config['max_attachments'] ) //|| $auth->acl_gets('m_', 'a_', $forum_id) )
|
||||
{
|
||||
$filedata = upload_attachment($attachment_data['filename']);
|
||||
$filedata = upload_attachment($this->filename_data['filename']);
|
||||
|
||||
if ($filedata['error'])
|
||||
{
|
||||
@ -704,17 +661,20 @@ class parse_message
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
array_unshift($attachment_data['physical_filename'], $filedata['destination_filename']);
|
||||
array_unshift($attachment_data['comment'], $attachment_data['filecomment']);
|
||||
array_unshift($attachment_data['real_filename'], $filedata['filename']);
|
||||
array_unshift($attachment_data['extension'], $filedata['extension']);
|
||||
array_unshift($attachment_data['mimetype'], $filedata['mimetype']);
|
||||
array_unshift($attachment_data['filesize'], $filedata['filesize']);
|
||||
array_unshift($attachment_data['filetime'], $filedata['filetime']);
|
||||
array_unshift($attachment_data['attach_id'], '-1');
|
||||
array_unshift($attachment_data['thumbnail'], $filedata['thumbnail']);
|
||||
$new_entry = array(
|
||||
'physical_filename' => $filedata['destination_filename'],
|
||||
'comment' => $this->filename_data['filecomment'],
|
||||
'real_filename' => $filedata['filename'],
|
||||
'extension' => $filedata['extension'],
|
||||
'mimetype' => $filedata['mimetype'],
|
||||
'filesize' => $filedata['filesize'],
|
||||
'filetime' => $filedata['filetime'],
|
||||
'attach_id' => '-1',
|
||||
'thumbnail' => $filedata['thumbnail']
|
||||
);
|
||||
|
||||
$attachment_data['filecomment'] = '';
|
||||
$this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data);
|
||||
$this->filename_data['filecomment'] = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -150,6 +150,8 @@ switch ($mode)
|
||||
trigger_error($user->lang['NO_MODE']);
|
||||
}
|
||||
|
||||
$message_parser = new parse_message(0); // <- TODO: add constant (MSG_POST/MSG_PM)
|
||||
|
||||
if ($sql != '')
|
||||
{
|
||||
$result = $db->sql_query($sql);
|
||||
@ -230,43 +232,23 @@ if ($sql != '')
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$attachment_data = array();
|
||||
|
||||
$attachment_data['filecomment'] = ( isset($_POST['filecomment']) ) ? trim( strip_tags($_POST['filecomment'])) : '';
|
||||
$attachment_data['filename'] = ( $_FILES['fileupload']['name'] != 'none' ) ? trim($_FILES['fileupload']['name']) : '';
|
||||
$message_parser->filename_data['filecomment'] = ( isset($_POST['filecomment']) ) ? trim( strip_tags($_POST['filecomment'])) : '';
|
||||
$message_parser->filename_data['filename'] = ( $_FILES['fileupload']['name'] != 'none' ) ? trim($_FILES['fileupload']['name']) : '';
|
||||
|
||||
// Get Attachment Data
|
||||
$attachment_data['physical_filename'] = ( isset($_POST['attachment_list']) ) ? $_POST['attachment_list'] : array();
|
||||
$attachment_data['comment'] = ( isset($_POST['comment_list']) ) ? $_POST['comment_list'] : array();
|
||||
$attachment_data['real_filename'] = ( isset($_POST['filename_list']) ) ? $_POST['filename_list'] : array();
|
||||
$attachment_data['extension'] = ( isset($_POST['extension_list']) ) ? $_POST['extension_list'] : array();
|
||||
$attachment_data['mimetype'] = ( isset($_POST['mimetype_list']) ) ? $_POST['mimetype_list'] : array();
|
||||
$attachment_data['filesize'] = ( isset($_POST['filesize_list']) ) ? $_POST['filesize_list'] : array();
|
||||
$attachment_data['filetime'] = ( isset($_POST['filetime_list']) ) ? $_POST['filetime_list'] : array();
|
||||
$attachment_data['attach_id'] = ( isset($_POST['attach_id_list']) ) ? $_POST['attach_id_list'] : array();
|
||||
$attachment_data['thumbnail'] = ( isset($_POST['attach_thumbnail_list']) ) ? $_POST['attach_thumbnail_list'] : array();
|
||||
$message_parser->attachment_data = (isset($_POST['attachment_data'])) ? $_POST['attachment_data'] : array();
|
||||
|
||||
if (($post_attachment) && (!$submit) && (!$refresh) && (!$preview) && ($mode == 'edit'))
|
||||
{
|
||||
$sql = "SELECT d.*
|
||||
FROM " . ATTACHMENTS_TABLE . " a, " . ATTACHMENTS_DESC_TABLE . " d
|
||||
WHERE a.post_id = " . $post_id . "
|
||||
$sql = 'SELECT d.*
|
||||
FROM ' . ATTACHMENTS_TABLE . ' a, ' . ATTACHMENTS_DESC_TABLE . ' d
|
||||
WHERE a.post_id = ' . $post_id . '
|
||||
AND a.attach_id = d.attach_id
|
||||
ORDER BY d.filetime DESC";
|
||||
ORDER BY d.filetime ' . ((!$config['display_order']) ? 'DESC' : 'ASC');
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$attachment_data['attach_id'][] = intval($row['attach_id']);
|
||||
$attachment_data['physical_filename'][] = trim($row['physical_filename']);
|
||||
$attachment_data['comment'][] = trim($row['comment']);
|
||||
$attachment_data['real_filename'][] = trim($row['real_filename']);
|
||||
$attachment_data['extension'][] = trim($row['extension']);
|
||||
$attachment_data['mimetype'][] = trim($row['mimetype']);
|
||||
$attachment_data['filesize'][] = intval($row['filesize']);
|
||||
$attachment_data['filetime'][] = intval($row['filetime']);
|
||||
$attachment_data['thumbnail'][] = intval($row['thumbnail']);
|
||||
}
|
||||
$message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result));
|
||||
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
@ -352,8 +334,6 @@ if ( ($mode == 'edit') && ($post_edit_locked) && (!$auth->acl_gets('m_', 'a_', $
|
||||
trigger_error($user->lang['CANNOT_EDIT_POST_LOCKED']);
|
||||
}
|
||||
|
||||
$message_parser = new parse_message(0); // <- TODO: add constant (MSG_POST/MSG_PM)
|
||||
|
||||
if ($mode == 'edit')
|
||||
{
|
||||
$message_parser->bbcode_uid = $row['bbcode_uid'];
|
||||
@ -677,7 +657,7 @@ if (($submit) || ($preview) || ($refresh))
|
||||
}
|
||||
}
|
||||
|
||||
if (($result = $message_parser->parse_attachments($mode, $post_id, $submit, $preview, $refresh, $attachment_data)) != '')
|
||||
if (($result = $message_parser->parse_attachments($mode, $post_id, $submit, $preview, $refresh)) != '')
|
||||
{
|
||||
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result;
|
||||
}
|
||||
@ -823,7 +803,7 @@ if (($submit) || ($preview) || ($refresh))
|
||||
'bbcode_bitfield' => $message_parser->bbcode_bitfield
|
||||
);
|
||||
|
||||
submit_post($mode, $message_parser->message, $subject, $username, $topic_type, $message_parser->bbcode_uid, $poll, $attachment_data, $post_data);
|
||||
submit_post($mode, $message_parser->message, $subject, $username, $topic_type, $message_parser->bbcode_uid, $poll, $message_parser->attachment_data, $message_parser->filename_data, $post_data);
|
||||
}
|
||||
|
||||
$post_text = $message_parser->message;
|
||||
@ -1096,50 +1076,44 @@ if (($perm['f_attach']) || ($perm['m_edit']))
|
||||
'S_SHOW_ATTACH_BOX' => true)
|
||||
);
|
||||
|
||||
if (count($attachment_data['physical_filename']) > 0)
|
||||
if (count($message_parser->attachment_data))
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_HAS_ATTACHMENTS' => true)
|
||||
);
|
||||
|
||||
for ($i = 0; $i < count($attachment_data['physical_filename']); $i++)
|
||||
$count = 0;
|
||||
foreach ($message_parser->attachment_data as $attach_row)
|
||||
{
|
||||
$attachment_data['real_filename'][$i] = stripslashes($attachment_data['real_filename'][$i]);
|
||||
$hidden = '';
|
||||
$attach_row['real_filename'] = stripslashes($attach_row['real_filename']);
|
||||
|
||||
$hidden = '<input type="hidden" name="attachment_list[]" value="' . $attachment_data['physical_filename'][$i] . '" />';
|
||||
$hidden .= '<input type="hidden" name="filename_list[]" value="' . $attachment_data['real_filename'][$i] . '" />';
|
||||
$hidden .= '<input type="hidden" name="extension_list[]" value="' . $attachment_data['extension'][$i] . '" />';
|
||||
$hidden .= '<input type="hidden" name="mimetype_list[]" value="' . $attachment_data['mimetype'][$i] . '" />';
|
||||
$hidden .= '<input type="hidden" name="filesize_list[]" value="' . $attachment_data['filesize'][$i] . '" />';
|
||||
$hidden .= '<input type="hidden" name="filetime_list[]" value="' . $attachment_data['filetime'][$i] . '" />';
|
||||
$hidden .= '<input type="hidden" name="attach_id_list[]" value="' . $attachment_data['attach_id'][$i] . '" />';
|
||||
$hidden .= '<input type="hidden" name="attach_thumbnail_list[]" value="' . $attachment_data['thumbnail'][$i] . '" />';
|
||||
foreach ($attach_row as $key => $value)
|
||||
{
|
||||
$hidden .= '<input type="hidden" name="attachment_data[' . $count . '][' . $key . ']" value="' . $value . '" />';
|
||||
}
|
||||
|
||||
if ( $attachment_data['attach_id'][$i] == '-1' )
|
||||
{
|
||||
$download_link = $config['upload_dir'] . '/' . $attachment_data['physical_filename'][$i];
|
||||
}
|
||||
else
|
||||
{
|
||||
$download_link = $phpbb_root_path . "download." . $phpEx . "$SID?id=" . $attachment_data['attach_id'][$i];
|
||||
}
|
||||
$download_link = ($attach_row['attach_id'] == '-1') ? $config['upload_dir'] . '/' . $attach_row['physical_filename'] : $phpbb_root_path . 'download.' . $phpEx . $SID . '&id=' . intval($attach_row['attach_id']);
|
||||
|
||||
$template->assign_block_vars('attach_row', array(
|
||||
'FILENAME' => $attachment_data['real_filename'][$i],
|
||||
'ATTACH_FILENAME' => $attachment_data['physical_filename'][$i],
|
||||
'FILE_COMMENT' => stripslashes(htmlspecialchars($attachment_data['comment'][$i])),
|
||||
'ATTACH_ID' => $attachment_data['attach_id'][$i],
|
||||
'FILENAME' => $attach_row['real_filename'],
|
||||
'ATTACH_FILENAME' => $attach_row['physical_filename'],
|
||||
'FILE_COMMENT' => stripslashes(htmlspecialchars($attach_row['comment'])),
|
||||
'ATTACH_ID' => $attach_row['attach_id'],
|
||||
'ASSOC_INDEX' => $count,
|
||||
|
||||
'U_VIEW_ATTACHMENT' => $download_link,
|
||||
'S_HIDDEN' => $hidden)
|
||||
);
|
||||
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'FILE_COMMENT' => stripslashes(htmlspecialchars($attachment_data['filecomment'])),
|
||||
'FILE_COMMENT' => stripslashes(htmlspecialchars($message_parser->filename_data['filecomment'])),
|
||||
'FILESIZE' => $config['max_filesize'],
|
||||
'FILENAME' => $attachment_data['filename'])
|
||||
'FILENAME' => $message_parser->filename_data['filename'])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,9 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1"><b class="gen">{L_FILE_COMMENT}</b></td>
|
||||
<td class="row2"><textarea class="post" name="comment_list[]" rows="3" cols="35" wrap="virtual" size=40>{attach_row.FILE_COMMENT}</textarea> <input class="liteoption" type="submit" name="edit_comment[{attach_row.ATTACH_FILENAME}]" value="{L_UPDATE_COMMENT}" /> <input class="liteoption" type="submit" name="delete_file[{attach_row.ATTACH_FILENAME}]" value="{L_DELETE_FILE}" /></td>
|
||||
<td class="row2"><textarea class="post" name="comment_list[{attach_row.ASSOC_INDEX}]" rows="3" cols="35" wrap="virtual" size=40>{attach_row.FILE_COMMENT}</textarea>
|
||||
<input class="liteoption" type="submit" name="edit_comment[{attach_row.ASSOC_INDEX}]" value="{L_UPDATE_COMMENT}" />
|
||||
<input class="liteoption" type="submit" name="delete_file[{attach_row.ASSOC_INDEX}]" value="{L_DELETE_FILE}" /></td>
|
||||
</tr>
|
||||
{attach_row.S_HIDDEN}
|
||||
<!-- END attach_row -->
|
||||
|
@ -821,7 +821,7 @@ if (count($attach_list))
|
||||
FROM ' . ATTACHMENTS_TABLE . ' a, ' . ATTACHMENTS_DESC_TABLE . ' d
|
||||
WHERE a.post_id IN (' . implode(', ', $attach_list) . ')
|
||||
AND a.attach_id = d.attach_id
|
||||
ORDER BY d.filetime ' . ((!$config['display_order']) ? 'ASC' : 'DESC') . ', a.post_id ASC';
|
||||
ORDER BY d.filetime ' . ((!$config['display_order']) ? 'DESC' : 'ASC') . ', a.post_id ASC';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
|
Loading…
x
Reference in New Issue
Block a user