ob_end_clean(); $result['success'] = true; $result['type'] = $type; // var_dump($out); $result['html'] = iconv('CP1251', 'UTF-8', $out); } echo json_encode($result); exit; break; case 'comment': $id = __paramInit('int', 'id'); if (!$id && !$uid && !isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { exit; } require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/articles_comments.php'; $comment = articles_comments::getComment($id); $attaches = articles_comments::getAttaches($id, true); $result = array(); $result['success'] = false; if (hasPermissions('articles') || $uid == $comment['from_id']) { $comment['msgtext'] = preg_replace("/\\h/", ' ', $comment['msgtext']); $tidy = new tidy(); $comment['msgtext'] = $tidy->repairString(str_replace(array(' '), array(' '), iconv('CP1251', 'UTF-8', nl2br($comment['msgtext']))), array('show-body-only' => true, 'wrap' => '0'), 'raw'); $comment['msgtext'] = preg_replace("/\\h/", ' ', $comment['msgtext']); $comment['msgtext'] = preg_replace('/\\n?<br\\s?\\/?>\\n?/', "\n", $comment['msgtext']); $comment['msgtext'] = html_entity_decode($comment['msgtext']); $result['success'] = true; $result['data'] = $comment; $result['attaches'] = $attaches; } echo json_encode($result);