diff --git a/upload/ajax/posts.php b/upload/ajax/posts.php index 7998be6de..10c8c4efd 100644 --- a/upload/ajax/posts.php +++ b/upload/ajax/posts.php @@ -48,10 +48,16 @@ switch($this->request['type']) case 'reply'; if(!$post) $this->ajax_die('not post'); + + $is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post); if(bf($userdata['user_opt'], 'user_opt', 'allow_post')) { $this->ajax_die($lang['RULES_REPLY_CANNOT']); } + else if(!$is_auth['auth_reply']) + { + $this->ajax_die(sprintf($lang['SORRY_AUTH_REPLY'], strip_tags($is_auth['auth_reply_type']))); + } // Use trim to get rid of spaces placed there by MS-SQL 2000 $quote_username = (trim($post['post_username']) != '') ? $post['post_username'] : get_username($post['poster_id']); @@ -77,7 +83,7 @@ switch($this->request['type']) $message = (string) $this->request['message']; if(!trim($message)) $this->ajax_die($lang['EMPTY_MESSAGE']); $message = bbcode2html($message); - $this->response['message_html'] = $message; + $this->response['view_message'] = $message; break; case 'edit': @@ -103,8 +109,8 @@ switch($this->request['type']) $this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies'])); } } - DB()->query("UPDATE ". BB_POSTS_TEXT ." SET post_text = '". DB()->escape($text) ."' WHERE post_id = $post_id LIMIT 1"); - add_search_words($post_id, stripslashes($text), stripslashes($post['topic_title'])); + DB()->query("UPDATE ". BB_POSTS_TEXT ." SET post_text = '". DB()->escape($text) ."' WHERE post_id = $post_id LIMIT 1"); + add_search_words($post_id, stripslashes($text), stripslashes($post['topic_title'])); update_post_html(array( 'post_id' => $post_id, 'post_text' => $text, @@ -203,6 +209,51 @@ switch($this->request['type']) break; case 'add': + if (!isset($this->request['topic_id'])) + { + $this->ajax_die('empty topic_id'); + } + $topic_id = (int) $this->request['topic_id']; + $t_data = DB()->fetch_row("SELECT t.*, f.* + FROM ". BB_TOPICS ." t, ". BB_FORUMS ." f + WHERE t.topic_id = $topic_id + AND f.forum_id = t.forum_id + LIMIT 1"); + if(!$t_data) bb_die($lang['TOPIC_POST_NOT_EXIST']); + + $is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post); + if(bf($userdata['user_opt'], 'user_opt', 'allow_post')) + { + $this->ajax_die($lang['RULES_REPLY_CANNOT']); + } + else if(!$is_auth['auth_reply']) + { + $this->ajax_die(sprintf($lang['SORRY_AUTH_REPLY'], strip_tags($is_auth['auth_reply_type']))); + } + + $message = (string) $this->request['message']; + $message = prepare_message($message); + + if($bb_cfg['max_smilies']) + { + $count_smilies = substr_count(bbcode2html($text), 'sql_nextid(); + DB()->sql_query("INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_text) VALUES ($post_id, '". DB()->escape($message) ."')"); + + add_search_words($post_id, stripslashes($message), stripslashes($t_data['topic_title'])); + update_post_html(array( + 'post_id' => $post_id, + 'post_text' => $message, + )); + + $this->response['redirect'] = make_url(POST_URL . $post_id .'#'. $post_id); break; default: diff --git a/upload/config.php b/upload/config.php index a59964d42..2e144c542 100644 --- a/upload/config.php +++ b/upload/config.php @@ -57,7 +57,7 @@ $bb_cfg['css_ver'] = 1; // Increase number of revision after update $bb_cfg['tp_version'] = '2.0.2'; -$bb_cfg['tp_release_state'] = 'TP II r133'; +$bb_cfg['tp_release_state'] = 'TP II r138'; $bb_cfg['tp_release_date'] = '24-07-2011'; $bb_cfg['board_disabled_msg'] = 'форум временно отключен'; // 'forums temporarily disabled'; // show this msg if board has been disabled via ON/OFF trigger diff --git a/upload/misc/js/bbcode.js b/upload/misc/js/bbcode.js index aecda72b3..02b62438f 100644 --- a/upload/misc/js/bbcode.js +++ b/upload/misc/js/bbcode.js @@ -295,19 +295,6 @@ BBCode.prototype = { } -// Called before form submitting. -function checkForm(form) { - var formErrors = false; - if (form.message.value.length < 2) { - formErrors = "Please enter the message."; - } - if (formErrors) { - setTimeout(function() { alert(formErrors) }, 100); - return false; - } - return true; -} - // Emulation of innerText for Mozilla. if (window.HTMLElement && window.HTMLElement.prototype.__defineSetter__) { HTMLElement.prototype.__defineSetter__("innerText", function (sText) { diff --git a/upload/templates/default/posting_editor.tpl b/upload/templates/default/posting_editor.tpl index 5301c3b75..3a24bda52 100644 --- a/upload/templates/default/posting_editor.tpl +++ b/upload/templates/default/posting_editor.tpl @@ -2,13 +2,11 @@
@@ -148,10 +146,42 @@ ajax.callback.posts = function(data){
{CAPTCHA_HTML}
   - - + +
+ +