rxu, по-видимому мне
Да пожалуйста! Сделано на скорую руку, но работает...
Меняем в listener.php
Код: Выделить всё
//Replacement
$attach_in_quote = array();
$message_parser->message = substr($message_parser->message, 0, strlen($message_parser->message) - 9); //Del "[/quote]\n"
preg_match_all('/\[attachment=\d+\](.*)\[\/attachment\]/U', $message_parser->message, $attach_in_quote);
$sql_attach = 'SELECT attach_id, real_filename, mimetype, extension, thumbnail
FROM ' . ATTACHMENTS_TABLE . '
WHERE post_msg_id = ' . $post_id;
$result_attach = $this->db->sql_query($sql_attach);
while ($attach_row = $this->db->sql_fetchrow($result_attach))
{
if (in_array($attach_row['real_filename'], $attach_in_quote[1]))
{
//Replace inline attachments
if (strpos($attach_row['mimetype'], 'image/') !== false)
{
if (!empty($this->config['seoimg_version']))
{
$type_link = ($attach_row['thumbnail']) ? 'thumb' : 'small';
$img_link = generate_board_url() ."/{$type_link}/{$attach_row['attach_id']}.{$attach_row['extension']}";
}
else
{
$type_link = ($attach_row['thumbnail']) ? '&t=1' : '';
$img_link = generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'] . $type_link;
}
//Replase image inline attachments in [img]
$message_parser->message = preg_replace('/\[attachment=\d+\]' . preg_quote($attach_row['real_filename']) . '\[\/attachment\]/', $img_open_tag . $img_link . $img_close_tag, $message_parser->message);
}
else
{
//Replase other inline attachments in [url]
if ($allow_url)
{
$message_parser->message = preg_replace('/\[attachment=\d+\]' . preg_quote($attach_row['real_filename']) . '\[\/attachment\]/', '[url=' . generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'] . ']' . $attach_row['real_filename'] . '[/url]', $message_parser->message);
}
else
{
$message_parser->message = preg_replace('/\[attachment=\d+\]' . preg_quote($attach_row['real_filename']) . '\[\/attachment\]/', generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'], $message_parser->message);
}
}
//Fix if there the same filenames
$key_attach = array_search($attach_row['real_filename'], $attach_in_quote[1]);
if ($key_attach !== false)
{
unset($attach_in_quote[1][$key_attach]);
}
}
else
{
//Replace (not-inline) attachments
if (strpos($attach_row['mimetype'], 'image/') !== false)
{
if (!empty($this->config['seoimg_version']))
{
$type_link = ($attach_row['thumbnail']) ? 'thumb' : 'small';
$img_link = generate_board_url() ."/{$type_link}/{$attach_row['attach_id']}.{$attach_row['extension']}";
}
else
{
$type_link = ($attach_row['thumbnail']) ? '&t=1' : '';
$img_link = generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'] . $type_link;
}
//Replace image attachments in [img]
$message_parser->message .= "\n" . $img_open_tag . $img_link . $img_close_tag;
}
else
{
//Replace other attachments in [url]
if ($allow_url)
{
$message_parser->message .= "\n[url=" . generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'] . ']' . $attach_row['real_filename'] . '[/url]';
}
else
{
$message_parser->message .= "\n" . generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'] . ' ';
}
}
}
}
на
Код: Выделить всё
//Replacement
$attach_in_quote = array();
$message_parser->message = substr($message_parser->message, 0, strlen($message_parser->message) - 10); //Del "[/quote]\n"
preg_match_all('/\[attachment=(.*)\]/U', $message_parser->message, $attach_in_quote);
$message_parser->message = trim($message_parser->message);
$message_parser->message .= "\n";
$sql_attach = 'SELECT attach_id, real_filename, mimetype, extension, thumbnail
FROM ' . ATTACHMENTS_TABLE . '
WHERE post_msg_id = ' . $post_id . ' ORDER BY filetime';
$result_attach = $this->db->sql_query($sql_attach);
$i = ((int) mysqli_num_rows($result_attach) - 1);
while ($attach_row = $this->db->sql_fetchrow($result_attach))
{
if (in_array($i, $attach_in_quote[1]))
{
//Replace inline attachments
if (strpos($attach_row['mimetype'], 'image/') !== false)
{
if (!empty($this->config['seoimg_version']))
{
$type_link = ($attach_row['thumbnail']) ? 'thumb' : 'inline';
$img_link = generate_board_url() ."/{$type_link}/{$attach_row['attach_id']}.{$attach_row['extension']}";
}
else
{
$type_link = ($attach_row['thumbnail']) ? '&t=1' : '';
$img_link = generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'] . $type_link;
}
//Replase image inline attachments in [img]
$message_parser->message = preg_replace('/\[attachment=' . $i . '\]' . preg_quote($attach_row['real_filename']) . '\[\/attachment\]/', $img_open_tag . $img_link . $img_close_tag, $message_parser->message);
}
else
{
//Replase other inline attachments in [url]
if ($allow_url)
{
$message_parser->message = preg_replace('/\[attachment=' . $i . '\]' . preg_quote($attach_row['real_filename']) . '\[\/attachment\]/', '[url=' . generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'] . ']' . $attach_row['real_filename'] . '[/url]', $message_parser->message);
}
else
{
$message_parser->message = preg_replace('/\[attachment=' . $i . '\]' . preg_quote($attach_row['real_filename']) . '\[\/attachment\]/', generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'], $message_parser->message);
}
}
}
else
{
//Replace (not-inline) attachments
if (strpos($attach_row['mimetype'], 'image/') !== false)
{
if (!empty($this->config['seoimg_version']))
{
$type_link = ($attach_row['thumbnail']) ? 'thumb' : 'inline';
$img_link = generate_board_url() ."/{$type_link}/{$attach_row['attach_id']}.{$attach_row['extension']}";
}
else
{
$type_link = ($attach_row['thumbnail']) ? '&t=1' : '';
$img_link = generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'] . $type_link;
}
//Replace image attachments in [img]
$message_parser->message .= $img_open_tag . $img_link . $img_close_tag;
}
else
{
//Replace other attachments in [url]
if ($allow_url)
{
$message_parser->message .= "\n[url=" . generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'] . ']' . $attach_row['real_filename'] . '[/url]';
}
else
{
$message_parser->message .= "\n" . generate_board_url() . '/download/file.php?id=' . (int) $attach_row['attach_id'] . ' ';
}
}
}
$i--;
}