<?php
require("header.php");

/***********************  UPDATE **************************************/
InitGP(array('id','action',));
if ($action == 'm') {
	$sql = "SELECT discuss_presentation,discuss_management,discuss_pub FROM ".$db_tablepre."discuss WHERE discuss_id=".$id;
	$query = sql_return($sql,2);
	$discuss_pub = $query['discuss_pub'];

	$discuss_presentation = $query['discuss_presentation'];
	$count = substr_count($query['discuss_presentation'],'|');
	if ($count>1) $discuss_management = substr($query['discuss_management'],strpos($query['discuss_management'],'|')+1,-1);

}
elseif ($action == 'm_up'){
	InitGP(array('discuss_presentation','discuss_management','discuss_pub','u_password',));

	$sql = "SELECT * FROM ".$db_tablepre."discuss d LEFT JOIN  ".$db_tablepre."user u ON d.discuss_uid=u.u_id WHERE u.u_password='".md5($u_password)."' AND d.discuss_id=".$id;
	sql_return($sql,3) || Showmsg('discuss_pub_userPassword_err');

	if ($discuss_management) {
		$discuss_management = explode('|',GetCookie('user_name_2').'|'.$discuss_management);

		foreach ($discuss_management as $value){
			$value == GetCookie('user_name_2');
			$sql = "SELECT * FROM ".$db_tablepre."user WHERE u_name_2=".$value;
			sql_return($sql,3) || Showmsg('discuss_pub_user_err');
		}
		$discuss_management = join('|',$discuss_management);
		$discuss_management .= '|';
	}
	else $discuss_management = GetCookie('user_name_2').'|';




	$sql = "UPDATE ".$db_tablepre."discuss SET discuss_presentation='".$discuss_presentation."',discuss_management='".$discuss_management."',discuss_pub=".$discuss_pub." WHERE discuss_id=".$id;
	sql_return($sql) && Showmsg('post_Success');
}
else {
	$sql = "SELECT * FROM ".$db_tablepre."discuss WHERE discuss_uid=".GetCookie('user_id')." GROUP BY discuss_uptimes DESC ";
	$query = sql_return($sql);

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