sibtracker/system/forum/ajax/addpost.php
2019-05-18 13:46:03 +08:00

59 lines
1.7 KiB
PHP

<?php
include 'init.php';
$ajax_start = true;
$tpl = new dle_template;
$tpl->dir = ROOT_DIR.'/templates/'.$_REQUEST['skin'];
define('TEMPLATE_DIR', $tpl->dir);
$name = convert_unicode($_POST['name'], $config['charset']);
$mail = convert_unicode($_POST['mail'], $config['charset']);
$post_text = trim(convert_unicode($_POST['post_text'], $config['charset']));
$topic_title = convert_unicode($_POST['topic_title'], $config['charset']);
$topic_id = intval($_POST['topic_id']);
$forum_id = intval($_POST['forum_id']);
$post_id = $_POST['post_id'];
$ajax_adds = TRUE;
$access_mod = array(1);
require_once SYSTEM_DIR.'/forum/action/addpost.php';
$clear_value = "form.post_text.value = '';";
if(!$add_post_error){
$result_posts = $db->query("SELECT * FROM " . PREFIX . "_forum_posts LEFT JOIN " . USERPREFIX . "_users ON " . PREFIX . "_forum_posts.post_author=" . USERPREFIX . "_users.name WHERE " . PREFIX . "_forum_posts.topic_id = '$topic_id' ORDER BY pid DESC LIMIT 1");
$tid = $topic_id;
require_once SYSTEM_DIR.'/forum/sources/showposts.php';
$tpl->result['content'] = "<div id=\"blind-animation\" style=\"display:none\">".$tpl->result['posts']."<div>";
$tpl->result['content'] = str_replace('{THEME}', $config['http_home_url'].'templates/'.$_REQUEST['skin'], $tpl->result['content']);
$tpl->result['content'] .= <<<HTML
<script language='JavaScript' type="text/javascript">
var timeval = new Date().getTime();
var form = document.getElementById('forum-post-form');
{$clear_value}
</script>
HTML;
}
else
{
$tpl->result['content'] = "<script language=\"JavaScript\" type=\"text/javascript\">\n alert ('".$add_post_error."');\n </script>";
}
@header("Content-type: text/html; charset=".$config['charset']);
echo $tpl->result['content'];
?>