// Постим благодарность
$post_MB = $MB / (1024 * 1024);
$post_message = 'Спасибо за оценку на toptema.com [b]' . (string) $ratio . '[/b] пользователю [url=http://' . $bb_cfg['server_name'] . 'profile.php?mode=viewprofile&u=' . $userid. '][b]' . get_username($userid) . '[/b][/url]. ';
$post_message .= 'Начислен upload в размере ' . (string) $post_MB . 'Mb';
$post_message = prepare_message($post_message, $bbcode_on, $smilies_on, $bbcode_uid);
$sql = "SELECT forum_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id";
if ( !($result = DB()->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not read information.", '', __LINE__, __FILE__, $sql);
}
while ($row = DB()->sql_fetchrow($result))
{
$forum_id = $row['forum_id'];
}
if ( !(isset($forum_id)) )
{
message_die(GENERAL_ERROR, "Could not read information.", '', __LINE__, __FILE__, $sql);
}
$sql = "INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_smilies, enable_sig) VALUES ($topic_id, $forum_id, " . $user_id . ", '$post_username', $current_time, '". $user_ip ."', $bbcode_on, $smilies_on, $attach_sig)";
if (!DB()->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}
$post_id = DB()->sql_nextid();
$sql = "INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_subject, $bbcode_uid, post_text) VALUES ($post_id, '$post_subject', '$bbcode_uid', '$post_message')";
if (!DB()->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}
update_post_html(array(
'post_id' => $post_id,
'post_text' => $post_message,
'$bbcode_uid' => $$bbcode_uid,
'enable_smilies' => $smilies_on,
));
$topic_update_sql = "topic_last_post_id = $post_id, topic_last_post_time = ". TIMENOW .", topic_replies = topic_replies + 1";
$sql = "UPDATE " . BB_TOPICS . " SET
$topic_update_sql
WHERE topic_id = $topic_id";
if (!DB()->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}
$forum_update_sql = "forum_last_post_id = $post_id, forum_posts = forum_posts + 1";
$sql = "UPDATE " . BB_FORUMS . " SET
$forum_update_sql
WHERE forum_id = $forum_id";
if (!DB()->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
}