<?php
require("header.php");
require(R_P.'require/f_channel.php');

/***********************  UPDATE **************************************/
InitGP(array('pub','id',));
if ($pub == 'yes') {
	InitGP(array('discuss_bc_id','discuss_channel','discuss_cg','discuss_title','discuss_presentation',));
	$user_group = GetCookie('user_group');
	$uid = GetCookie('user_id');
	$user_name_2 = GetCookie('user_name_2').'|';

	$uid || Showmsg('log');

	$sql = "SELECT * FROM ".$db_tablepre."user  WHERE  u_id=".$uid." AND u_money>=20";
	sql_return($sql,3) || Showmsg('discuss_pub_money_err');

	$sql = "SELECT * FROM ".$db_tablepre."discuss  WHERE  discuss_title='".$discuss_title."' " ;
	sql_return($sql,3) && Showmsg('discuss_pub_title_err');

	$sql ="SELECT count(discuss_uid) as countIdNum FROM ".$db_tablepre."discuss  WHERE discuss_uid='".$uid."' " ;
	$user_group && $result = sql_return($sql,2) ;
	$result['countIdNum'] >=5 && Showmsg('discuss_pub_num_err');


	channelChk($discuss_channel);

	$sql1 = "INSERT INTO ".$db_tablepre."discuss (discuss_uid,discuss_bc_id,discuss_channel,discuss_cg,discuss_title,discuss_presentation,discuss_uptimes,discuss_management) VALUES (".$uid.", ".$discuss_bc_id.",".$discuss_channel.",".$discuss_cg.",'".$discuss_title."','".$discuss_presentation."','".$timestamp."','".$user_name_2."')";

	$sql2 = "UPDATE ".$db_tablepre."user SET u_money=u_money-20 WHERE u_id=".$uid;

	sql_return($sql1) && sql_return($sql2) && Cookie('user_money',GetCookie('user_money')-20) && Showmsg('post_Success');

}else {
	$sql = "SELECT  * FROM ".$db_tablepre."channel  WHERE BC_Tschannel=".$id.' order by BC_order asc ';
	$query = sql_return($sql);
	$sql = "SELECT  * FROM ".$db_tablepre."channel  WHERE BC_id=".$id;
	$query_cg = sql_return($sql,2);
	$cg = explode('|',$query_cg['BC_categories']);
	$bc_id = $query_cg['BC_id'];
}



require PrintEot($self_template,'U');
?>