Склеивание сообщений

  • Thread starter Thread starter Bustra
  • Start date Start date
Alexander.S, все гуд. frost444 выложил ведь готовое, надо только выдрать
 
Gemini_13, Ну я и хотел узнать, аякс присобачили ли) Будем ждать уже адаптированный с аяксом.
 
Alexander.S, код от frost444 и так уже адаптированный

Для тех кто не может выпилить

SQL
PHP:
INSERT INTO bb_config (config_name, config_value) VALUES ('join_interval', '18');

Открыть /root/ajax/posts.php

Найти
PHP:
if(!$t_data) $this->ajax_die($lang['TOPIC_POST_NOT_EXIST']);

Добавить после
PHP:
if ($userdata['user_id'] != ANONYMOUS )
        {
            $poster_id = $userdata['user_id'];
 
            $sql = "SELECT post_id, poster_id, post_time, MAX(post_time) FROM " . BB_POSTS . " WHERE topic_id = $topic_id GROUP BY post_time ORDER BY post_time DESC LIMIT 1";
 
            if ( !($result = DB()->sql_query($sql)) )
            {
                message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
            }
            $post_id_last_row = DB()->sql_fetchrow($result);
            $post_data['poster_post'] = ($post_id_last_row['poster_id'] == $userdata['user_id']);
            $post_id = $post_id_last_row['post_id'];
            $current_time = time();
            $difference_time = $current_time - $post_id_last_row['post_time'];
            $hours = floor($difference_time/60/60);
            $minutes = floor($difference_time/60%60);
            $seconds = $difference_time%60;
            $separator = '[br][size=9][color=#999999] добавлено спустя'. delta_time($post_id_last_row['post_time'], TIMENOW, 'seconds'). ':[/color][/size][br]';
 
            if ($post_id_last_row['poster_id'] == $poster_id && $post_data['poster_post'] && $t_data['topic_replies'] >= 1 && ( $difference_time < ( $bb_cfg['join_interval'] * 3600 ) ) )
            {
                $sql = "SELECT post_text FROM " . BB_POSTS_TEXT . " WHERE post_id = $post_id";
                if ( !($result = DB()->sql_query($sql)) )
                    {
                        message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
                    }
                $last_message_row = DB()->sql_fetchrow($result);
   
                // i don't know much about parsing the message, so it may well be that, there are some wrongs, anyway all seems to work fine
                $last_message = str_replace(':', '', $last_message_row['post_text']);
                $last_message = preg_replace('/:[0-9a-z:]+]/si', ']', $last_message);
                $last_message = addslashes($last_message);
   
            }
        }

Найти
PHP:
DB()->sql_query("INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_time, poster_ip) VALUES ($topic_id, ". $t_data['forum_id'] .", ". $userdata['user_id'] .", '". TIMENOW ."', '". USER_IP ."')");

Добавить выше

PHP:
        if ( !empty($last_message) )
    {
        $messages = ( $last_message != $message ) ? $last_message . $separator . $message : $message;
        $added = 1;
            if(mb_strlen($messages) > 2)
            {
                if($messages != $messages['post_text'])
                {
                    DB()->sql_query("UPDATE ". BB_POSTS_TEXT ." SET post_text = '". DB()->escape($messages) ."' WHERE post_id = $post_id LIMIT 1");
                    add_search_words($post_id, stripslashes($messages), stripslashes($messages['topic_title']));
                    update_post_html(array(
                        'post_id'        => $post_id,
                        'post_text'      => $messages,
                    ));
        $this->response['html'] = bbcode2html($messages);
        $this->response['post_id'] = $post_id;
        $this->response['redirect'] = make_url(POST_URL . "$post_id#$post_id");
        }
}
    }else{

Найти
PHP:
$this->response['redirect'] = make_url(POST_URL . $post_id .'#'. $post_id);

Добавить после

PHP:
}

EoM
 
Хмм, странно всё сделал как по инструкции, но нечего не работает... Нотисов тоже нету.
 
Хмм, странно всё сделал как по инструкции, но нечего не работает... Нотисов тоже нету.
SQL
PHP:
INSERT INTO bb_config (config_name, config_value) VALUES ('join_interval', '18');
Запрос сделал?
 
Сделал конечно.

Code:
Notice: Undefined variable: added in ***/includes/functions_post.php on line 57

а там


Code:
            if ( $added && $mode == 'editpost' )

и криво чёт склеивает, иногда хорошо иногда криво...
 

Alexander.S, посмотри вот в этой строке дописывал ли &$added
PHP:
//
// Post a new topic/reply/poll or edit existing post/poll
//
function submit_post($mode, &$post_data, &$message, &$meta,
 
Alexander.S, посмотри вот в этой строке дописывал ли &$added
PHP:
//
// Post a new topic/reply/poll or edit existing post/poll
//
function submit_post($mode, &$post_data, &$message, &$meta,

угу, вот эта строчка у меня

PHP:
//
// Post a new topic/reply/poll or edit existing post/poll
//
function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, $post_username, $post_subject, $post_message, $poll_title, &$poll_options, &$poll_length, &$added, $update_post_time)
 
Alexander.S, тогда затрудняюсь ответить. проверь еще разок установку, именно обрати внимание на установку до поискомых строк и после. тут уже гадать нету смысла. в functions_post.php у меня только 2 раза втречаеться $added. по какой инструкции ставил мод?
 
Back
Top