diff --git a/upload/ajax.php b/upload/ajax.php
index aab823594..d077d7d1f 100644
--- a/upload/ajax.php
+++ b/upload/ajax.php
@@ -17,7 +17,6 @@ if (file_exists(BB_DISABLED))
switch ($ajax->action)
{
case 'view_post':
- case 'view_message':
require(INC_DIR .'bbcode.php');
break;
@@ -72,7 +71,6 @@ class ajax_common
'change_torrent' => array('user'),
'view_post' => array('guest'),
- 'view_message' => array('guest'),
'view_torrent' => array('guest'),
'user_register' => array('guest'),
'posts' => array('guest'),
@@ -372,16 +370,6 @@ class ajax_common
require(AJAX_DIR .'view_post.php');
}
- function view_message ()
- {
- global $lang;
-
- $message = (string) $this->request['message'];
- if(!trim($message)) $this->ajax_die($lang['EMPTY_MESSAGE']);
- $message = bbcode2html($message);
- $this->response['html'] = $message;
- }
-
function change_tor_status ()
{
require(AJAX_DIR .'change_tor_status.php');
diff --git a/upload/ajax/posts.php b/upload/ajax/posts.php
index 75bf4efcc..bc8b41532 100644
--- a/upload/ajax/posts.php
+++ b/upload/ajax/posts.php
@@ -30,7 +30,7 @@ if (!defined('WORD_LIST_OBTAINED'))
switch($this->request['type'])
{
case 'delete';
- if(!$post) bb_die('not post');
+ if(!$post) $this->ajax_die('not post');
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
@@ -43,14 +43,14 @@ switch($this->request['type'])
$this->response['hide'] = true;
$this->response['post_id'] = $post_id;
}
else
- {
bb_die(sprintf($lang['SORRY_AUTH_DELETE'], strip_tags($is_auth['auth_delete_type'])));
}
+ {
$this->ajax_die(sprintf($lang['SORRY_AUTH_DELETE'], strip_tags($is_auth['auth_delete_type'])));
}
break;
- case 'quote';
- if(!$post) bb_die('not post');
+ case 'reply';
+ if(!$post) $this->ajax_die('not post');
if(bf($userdata['user_opt'], 'user_opt', 'allow_post'))
{
- bb_die($lang['RULES_REPLY_CANNOT']);
+ $this->ajax_die($lang['RULES_REPLY_CANNOT']);
}
// Use trim to get rid of spaces placed there by MS-SQL 2000
@@ -73,8 +73,133 @@ switch($this->request['type'])
$this->response['message'] = $message;
break;
- case 'add':
- $this->ajax_die('off');
+ case 'view_message':
+ $message = (string) $this->request['message'];
+ if(!trim($message)) $this->ajax_die($lang['EMPTY_MESSAGE']);
+ $message = bbcode2html($message);
+ $this->response['message_html'] = $message;
+ break;
+
+ case 'edit':
+ case 'editor':
+ if(!$post) $this->ajax_die('not post');
+
+ if(mb_strlen($post['post_text'], 'UTF-8') > 1000)
+ {
$this->response['redirect'] = make_url('posting.php?mode=editpost&p='. $post_id);
}
+ else if($this->request['type'] == 'editor')
+ {
+ $text = (string) $this->request['text'];
+ $text = prepare_message($text);
+
+ if(mb_strlen($text) > 2)
+ {
+ if($text != $post['post_text'])
+ {
+ if($bb_cfg['max_smilies'])
+ {
+ $count_smilies = substr_count(bbcode2html($text), ' $post_id,
+ 'post_text' => $text,
+ ));
+ }
+ }
+ else $this->ajax_die($lang['EMPTY_MESSAGE']);
+
+ $this->response['html'] = bbcode2html($text);
+ }
+ else
+ {
+ $is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
+ if ($post['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod'])
+ {
+ $this->ajax_die($lang['TOPIC_LOCKED']);
+ }
+ else if(!$is_auth['auth_edit'])
+ {
+ $this->ajax_die(sprintf($lang['SORRY_AUTH_EDIT'], strip_tags($is_auth['auth_edit_type'])));
+ }
+
+ // Запрет на редактирование раздачи юзером
+ if ($post['allow_reg_tracker'] && ($post['topic_first_post_id'] == $post_id) && !IS_AM)
+ {
+ $tor_status = DB()->fetch_row("SELECT tor_status FROM ". BB_BT_TORRENTS ." WHERE topic_id = {$post['topic_id']} LIMIT 1", 'tor_status');
+ if ($tor_status != false)
+ {
+ // по статусу раздачи
+ if (isset($bb_cfg['tor_cannot_edit'][$tor_status]))
+ {
+ $this->ajax_die("Вы не можете редактировать сообщение со статусом {$lang['tor_status'][$tor_status]}");
+ }
+ // проверенный, через время
+ if ($tor_status == TOR_APPROVED)
+ {
+ $days_after_last_edit = $bb_cfg['dis_edit_tor_after_days'];
+ $last_edit_time = max($post['post_time'], $post['post_edit_time']) + 86400*$days_after_last_edit;
+ $disallowed_by_forum_perm = in_array($post['forum_id'], $bb_cfg['dis_edit_tor_forums']);
+ $disallowed_by_user_opt = bf($user->opt, 'user_opt', 'dis_edit_release');
+
+ if ($last_edit_time < TIMENOW && ($disallowed_by_forum_perm || $disallowed_by_user_opt))
+ {
+ $how_msg = ($disallowed_by_user_opt) ? 'Вам запрещено' : 'Вы не можете';
+ $this->ajax_die("$how_msg редактировать сообщение со статусом {$lang['tor_status'][$tor_status]} по прошествии $days_after_last_edit дней");
+ }
+ }
+ }
+ }
+
+ $this->response['text'] = '
+