<?php
#######################################################|#
#|                    HabboMCMS - TheRox
#|                    Powered by HoloCMS 
#|            Copyright 2011-2012 ALL RIGHTS RESERVED
#######################################################|#

require_once('../global.php');
require_once('../INC/class.session.php');

if(getContent('forum-enabled') !== "0"){ header("Location: index.php"); exit; }

$message = Filter($_POST['message']);
$topicTitle = Filter($_POST['topicName']);

if(empty($topicTitle)){ echo "Topic title may not be blank"; exit; }

mysql_query("INSERT INTO cms_forum_threads (forumid,type,title,author,date,lastpost_author,lastpost_date,views,posts,unix) VALUES ('".$_POST['groupId']."','1','".$topicTitle."','".$name."','".$date_full."','".$name."','".$date_full."','0','0','".strtotime('now')."')") or die(mysql_error());
mysql_query("UPDATE users SET postcount = postcount + 1 WHERE id = '".$my_id."' LIMIT 1");

$check = mysql_query("SELECT id FROM cms_forum_threads WHERE forumid='".$_POST['groupId']."' ORDER BY id DESC LIMIT 1") or die(mysql_error());
$row = mysql_fetch_assoc($check);

$threadid = $row['id'];

mysql_query("INSERT INTO cms_forum_posts (forumid,threadid,message,author,date) VALUES ('".$_POST['groupId']."','".$threadid."','".$message."','".$name."','".$date_full."')");

echo "viewthread.php?thread=".$threadid."&page=1";

?>