<?php

/*


//Announcement hack v1.0 by Manick (IBRESOURCE.COM)


*/




$idx = new ad_announce();


class ad_announce {

	var $base_url;
	var $parser;
	var $post;
	var $new_annc;

	function ad_announce() {
		global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;


		switch($IN['code'])
		{

			case 'add':
				$this->add_announcement_form();
				break;


			case 'doadd':
				$this->add_announcement();
				break;

			case 'edit':
				$this->edit_announcement_form();
				break;

			case 'doedit':
				$this->edit_announcement();
				break;

			case 'delete':
				$this->delete_announcement_form();
				break;

			case 'dodelete':
				$this->delete_announcement();
				break;
				
			default:
				$this->main_screen();
				break;
		}
		


	}
	


	//+---------------------------------------------------------------------------------
	//
	// Show "Management" Screen
	//
	//+---------------------------------------------------------------------------------
	
	function main_screen()
	{
		global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
	


		$ADMIN->page_title = "论坛公告管理";
		
		$ADMIN->page_detail = "你可以在此管理你的论坛公告内容，只有管理员才能发布论坛公告。<br><b>注意：</b> 论坛公告主题为粗体表示公告不过期。";
		
		$g_array = array();
		
		$SKIN->td_header[] = array( "论坛公告/论坛栏目名称"   , "50%" );
		$SKIN->td_header[] = array( "选项"     		, "50%" );
		
		//+-------------------------------
		
		$ADMIN->html .= $SKIN->start_table( "论坛栏目公告" );

		$announcements	=	Array();
		$categories	=	Array();
		$forums		=	Array();


		$DB->query("SELECT c.id, c.name from ibf_categories c where c.id > '0' order by c.position");

		while ($cat = $DB->fetch_row())
		{
		$categories[] 	= 	$cat;
		}


		$DB->query("SELECT f.id, f.name, f.parent_id, f.subwrap, f.category, f.sub_can_post from ibf_forums f order by f.position");

		while ($for = $DB->fetch_row())
		{
		$forums[$for[category]][]		=	$for;
		}


		$DB->query("SELECT * FROM ibf_announcements ORDER by a_start DESC");

		while ($ann = $DB->fetch_row())
		{
			$announcements[$ann[a_forum]][] = $ann;
		}





  		      for ($i	= 0; $i < count($categories); $i++)
			{


			$ADMIN->html .= $SKIN->add_td_row( array( $categories[$i]['name'], "&nbsp;" ), 'catrow'      );
					
			$cat_id	=	$categories[$i][id];



			for ($g = 0; $g < count($forums[$cat_id]); $g++)
			{



				if ($forums[$cat_id][$g][parent_id] > 0)
				{
				$pretext = "----论坛分栏目：";
				$css = "subforum";
				$linkage	=	"<center><a href='{$ADMIN->base_url}&act=announcement&code=add&id=".$forums[$cat_id][$g]['id']."'><strong>添加论坛公告</strong></a></center>";
				}

				else if ($forums[$cat_id][$g][subwrap])
				{
					if ($forums[$cat_id][$g][sub_can_post])
					{
					$pretext = "--论坛分类：";
					$css = "catrow2";
					$linkage	=	"<center><a href='{$ADMIN->base_url}&act=announcement&code=add&id=".$forums[$cat_id][$g]['id']."'><strong>添加论坛公告</strong></a></center>";
					}
					else
					{
					$pretext = "<strong>--论坛子分类：</strong>";
					$css = "subforum";
					$linkage	=	"";
					}
				}


				else
				{
				$pretext = "--论坛栏目：";
				$css = "catrow2";
				$linkage	=	"<center><a href='{$ADMIN->base_url}&act=announcement&code=add&id=".$forums[$cat_id][$g]['id']."'><strong>添加论坛公告</strong></a></center>";
				}




				$ADMIN->html .= $SKIN->add_td_row( array( $pretext . " " . $forums[$cat_id][$g]['name'],
											      $linkage									      
									     ),  $css    );



				for ($a = 0; $a < count($announcements[$forums[$cat_id][$g]['id']]); $a++)
				{

				$ADMIN->html .= $SKIN->add_td_row( array( (!$announcements[$forums[$cat_id][$g]['id']][$a][a_expire] ? "<b>" : "")."------论坛公告：" . $announcements[$forums[$cat_id][$g]['id']][$a][a_title] .(!$announcements[$forums[$cat_id][$g]['id']][$a][a_expire] ? "</b>" : ""),
											      "<center><a href='{$ADMIN->base_url}&act=announcement&code=edit&id=".$announcements[$forums[$cat_id][$g]['id']][$a][a_id]."'>编辑</a>&nbsp;&nbsp;<a href='{$ADMIN->base_url}&act=announcement&code=delete&id=".$announcements[$forums[$cat_id][$g]['id']][$a][a_id]."'>删除</a></center>"
									     )      );
				}


				

			}

			}
			


		$ADMIN->html .= $SKIN->end_table();


								     
		$SKIN->td_header[] = array( "论坛公告/论坛公告/论坛栏目名称"   , "50%" );
		$SKIN->td_header[] = array( "选项 -- (<a href='{$ADMIN->base_url}&act=announcement&code=add&id=global'>添加论坛全局公告</a>)"	, "50%" );


		$ADMIN->html .= $SKIN->start_table( "论坛全局公告" );
		


			for ($g = 0; $g < count($announcements[0]); $g++)
			{

			$ADMIN->html .= $SKIN->add_td_row( array( (!$announcements[0][$g]['a_expire'] ? "<b>" : "") . "论坛公告：" . $announcements[0][$g]['a_title'] . (!$announcements[0][$g]['a_expire'] ? "</b>" : ""),
										      "<center><a href='{$ADMIN->base_url}&act=announcement&code=edit&id=".$announcements[0][$g][a_id]."'>编辑</a>&nbsp;&nbsp;<a href='{$ADMIN->base_url}&act=announcement&code=delete&id=".$announcements[0][$g][a_id]."'>删除</a></center>"									      
								     )      );
			}

										 
		$ADMIN->html .= $SKIN->end_table();


		$ADMIN->output();

		
	}




	//*************************************************************//
        //add_announcement();					       \\
	//*************************************************************//

	function add_announcement()
	{


		$this->process();

		die();


	}


	//*************************************************************//
        //delete_announcement()				       \\
	//*************************************************************//

	function delete_announcement()
	{
		global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;


		$id	=	$IN['id'];

		if (!is_numeric($id))
		{
			$ADMIN->error("无法找到指定的ID！");
		}


		$DB->query("DELETE FROM ibf_announcements WHERE a_id='".$id."'");

		$ADMIN->done_screen("论坛公告已经删除", "论坛公告管理", "act=announcement" );

	}





	//+---------------------------------------------------------------------------------
	//
	// delete_announcement_form
	//
	//+---------------------------------------------------------------------------------
	
	function delete_announcement_form()
	{
		global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		if ($IN['id'] == "")
		{
			$ADMIN->error("无法读取论坛公告ID，请检查后再试");
		}
		
	
		$ADMIN->page_title = "删除论坛公告";
		
		$ADMIN->page_detail = "请在删除前确信选择了正确的论坛公告。";
		
		
		//+-------------------------------
		

		$DB->query("SELECT * FROM ibf_announcements WHERE a_id='".$IN['id']."'");

		$ann	=	$DB->fetch_row();


		//+-------------------------------
		
		$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'dodelete'  ),
												  2 => array( 'act'   , 'announcement'     ),
												  3 => array( 'id'    , $IN['id']   ),
									     )      );
									     
		
		
		//+-------------------------------
		

		$ADMIN->html .= $SKIN->start_table( "删除确认：".$ann['a_title'] );
		
		$ADMIN->html .= $SKIN->end_form("删除论坛公告");
										 
		$ADMIN->html .= $SKIN->end_table();
		
		$ADMIN->output();
			
			
	}





	//+---------------------------------------------------------------------------------
	//
	// add_announcement_form
	//
	//+---------------------------------------------------------------------------------
	
	function add_announcement_form()
	{
		global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		if ($IN['id'] == "")
		{
			$ADMIN->error("无法找到论坛ID，请检查后再试");
		}

		$global = 0;

		if ($IN['id']<>"global")
		{

			$DB->query("SELECT name,id FROM ibf_forums WHERE id='".$IN['id']."'");
			$cat = $DB->fetch_row();

			if (!$cat['id'])
			{
				$ADMIN->error("无法找到论坛栏目ID，请检查后再试");
			}

		}

		else
		{

		$global = 1;

		}
		

	
		$ADMIN->page_title = "添加论坛公告";
		
		$ADMIN->page_detail = "你可以在此添加论坛栏目公告或论坛全局公告。";
		
		
		//+-------------------------------
		
		
		
		
		$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'doadd'  ),
												  2 => array( 'act'   , 'announcement'     ),
												  3 => array( 'id'    , $IN['id']   ),
					     ), 'REPLIER'      );





		//+-------------------------------
		
		$SKIN->td_header[] = array( "&nbsp;"  , "20%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "80%" );
		
		//+-------------------------------
					


		if ($global)
		{
		$title = "论坛全局公告";
		}
		else
		{
		$title = "论坛栏目公告：" . $cat[name];
		}


		$ADMIN->html .= $this->table_top();

		$ADMIN->html .= $SKIN->start_table( $title );
	

		$ADMIN->html .= $this->topictitle_fields(Array());

		$ADMIN->html .= $this->startend_fields(Array('start_time'=>$this->date_array(''), 'end_time'=>$this->date_array(time() + 60*60*24*30)));

		$ADMIN->html .= $this->nameField($MEMBER['name']);

		$smilies      = $this->html_add_smilie_box();

		$ADMIN->html .= $this->postbox_buttons(Array('sig_checked'=>'checked', 'smilies_checked'=>'checked', 'smilies'=>$smilies));

			     		
		$ADMIN->html .= $SKIN->end_form("添加论坛公告");
										 
		$ADMIN->html .= $SKIN->end_table();

	
		$ADMIN->output();
			
			
	}





	//+---------------------------------------------------------------------------------
	//
	// edit_announcement_form
	//
	//+---------------------------------------------------------------------------------
	
	function edit_announcement_form()
	{
		global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;


       		require "./sources/lib/post_parser.php";
        
        	$this->parser = new post_parser(1);

		if ($IN['id'] == "")
		{
			$ADMIN->error("无法找到论坛栏目ID，请检查后再试");
		}


		$DB->query("SELECT a.*,m.name,m.id FROM ibf_announcements a, ibf_members m WHERE a.a_id='".$IN['id']."' AND m.id=a.a_mid");
	
		$ann	=	$DB->fetch_row();


		$global = $ann['a_forum'] ? '0' : '1';

		if (!$ann['a_id'])
		{
			$ADMIN->error("无法找到指定的公告内容");
		}

	
		$ADMIN->page_title = "编辑论坛公告";
		
		$ADMIN->page_detail = "你可以在此编辑一个栏目或全局公告";
		
		
		//+-------------------------------
		
		
		
		
		$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'doedit'  ),
												  2 => array( 'act'   , 'announcement'     ),
												  3 => array( 'id'    , $IN['id']   ),
					     ), 'REPLIER'      );





		//+-------------------------------
		
		$SKIN->td_header[] = array( "&nbsp;"  , "20%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "80%" );
		
		//+-------------------------------
					


		if ($global)
		{
		$title = "全局公告";
		}
		else
		{
		$title = "论坛公告：" . $ann[a_title];
		}


		$ADMIN->html .= $this->table_top();

		$ADMIN->html .= $SKIN->start_table( $title );
	

		$ADMIN->html .= $this->topictitle_fields($ann);

		$ADMIN->html .= $this->startend_fields(Array('start_time'=>$this->date_array($ann[a_start]), 'end_time'=>$this->date_array($ann[a_end])));

		$ADMIN->html .= $this->nameField($ann[name]);

		$smilies      = $this->html_add_smilie_box();

		$ADMIN->html .= $this->postbox_buttons(Array('sig_checked'=> $ann[a_use_sig] ? 'checked' : '', 'smilies_checked'=> $ann[a_use_smile] ? 'checked' : "", 'smilies'=>$smilies, 'post'=>$this->parser->unconvert($ann[a_text], '1', '1')));

			     		
		$ADMIN->html .= $SKIN->end_form("更新论坛公告");
										 
		$ADMIN->html .= $SKIN->end_table();

	
		$ADMIN->output();
			
			
	}



	//*************************************************************//
        //edit_announcement();					       \\
	//*************************************************************//

	function edit_announcement()
	{


		$this->process();

		die();


	}




	//*************************************************************//
        //DATE ARRAY						       \\
	//*************************************************************//

	function date_array($time)
	{

	if ($time=="")
	{
	$time = time();
	}


	if ($time <= '0')
	{
	return "";
	}


	return @date("Y-m-d H:i:s", $time);
	}







    /*****************************************************/
	// HTML: add smilie box.
	// ------------------
	// Inserts the clickable smilies box
	/*****************************************************/
	
	function html_add_smilie_box() {
		global $ibforums, $INFO, $DB;
		
		$ibforums->vars['EMOTICONS_URL']   = $INFO['html_url'] . '/emoticons';

		$show_table = 0;
		$count      = 0;
		$smilies    = "<tr align='center'>\n";
		
		// Get the smilies from the DB
		
		$DB->query("SELECT * FROM ibf_emoticons WHERE clickable='1'");
		
		while ($elmo = $DB->fetch_row() ) {
		
			$show_table++;
			$count++;
			
			$smilies .= "<td><a href=\"javascript:emoticon('".$elmo['typed']."')\"><img src=\"".$ibforums->vars['EMOTICONS_URL']."/".$elmo['image']."\" alt='smilie' border='0'></a>&nbsp;</td>\n";
			
			if ($count == $ibforums->vars['emo_per_row']) {
				$smilies .= "</tr>\n\n<tr align='center'>";
				$count = 0;
			}
		}
		
		if ($count != $ibforums->vars['emo_per_row']) {
			for ($i = $count ; $i < $ibforums->vars['emo_per_row'] ; ++$i) {
				$smilies .= "<td>&nbsp;</td>\n";
			}
			$smilies .= "</tr>";
		}
		
		$table = $this->smilie_table();
		
		if ($show_table != 0) {
			$table = preg_replace( "/<!--THE SMILIES-->/", $smilies, $table );
			return $table;
		}
	
	}




///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Post parsing stuff



	/*****************************************************/
	// compile post
	// ------------------
	// Compiles all the incoming information into an array
	// which is returned to the accessor
	/*****************************************************/
	
	function compile_post() {
		global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
		

		

        	require "./sources/lib/post_parser.php";
        
        	$this->parser = new post_parser(1);


		$id	=	$IN['id'];


		if ($IN['code']=='doadd')
		{

			if ($id=="global")
			{
			$id 	=	0;
			}
			else
			{
			$DB->query("SELECT id FROM ibf_forums where id='".$id."'");
			$new_id =	$DB->fetch_row();
			$id	=	$new_id[id];

			if ($id=="")
			{
			$ADMIN->error("无法找到论坛栏目");
			}
			}
		}
		
		// sort out some of the form data, check for posting length, etc.
		// THIS MUST BE CALLED BEFORE CHECKING ATTACHMENTS
		
		$IN['enablesig'] = $IN['enablesig'] == 'yes' ? 1 : 0;
		$IN['enableemo'] = $IN['enableemo'] == 'yes' ? 1 : 0;
		
		// Do we have a valid post?
		
		if (strlen( trim($HTTP_POST_VARS['Post']) ) < 1) {
			$ADMIN->error("你必须在文本框中输入文本内容");
		}


		//Check author

		$DB->query("SELECT id FROM ibf_members WHERE name='".$IN['UserName']."'");

		$author = $DB->fetch_row();

		if ($author[id]=="" OR !$author[id])
		{
			$ADMIN->error("公告发布作者无效");
		}


		if ($IN['end_time']=="")
		{
			$expire	=	'0';
			$end_time	=	"";
		}
		else
		{
			$expire	=	'1';
			$end_time	=	@strtotime($IN['end_time']);
		}


		if ($IN['start_time']=="")
		{
			$ADMIN->error("公告开始时间无效");
		}

		$start_time	=	@strtotime($IN['start_time']);

		
		$post = array(
						'author_id'   => $author[id],
						'use_sig'     => $IN['enablesig'],
						'use_emo'     => $IN['enableemo'],

						'start_time'  => $start_time,
						'end_time'    => $end_time,
						'expire'      => $expire,
						'forum'	      => $id,


						'post'        => $this->parser->convert( array( TEXT    => $IN['Post'],
																		SMILIES => $IN['enableemo'],
																		CODE    => '1',
																		HTML    => '1'
																	  )
															   ),
											 );
					 
	    // If we had any errors, parse them back to this class
	    // so we can track them later.
	    
	    if ($this->parser->error)
		{
		$ADMIN->error($this->parser->error);
		}
					 
		return $post;
	}


	/*****************************************************/
	// 
	// PROCESS Input
	// 
	// 
	/*****************************************************/


	function process() {
	
		global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
		
		//-------------------------------------------------
		// Parse the post, and check for any errors.
		//-------------------------------------------------
		
		$this->post   = $this->compile_post();
		
		//-------------------------------------------------
		// check to make sure we have a valid topic title
		//-------------------------------------------------


				
		$IN['Title'] = str_replace( "<br>", "", $IN['Title'] );
		
		$IN['Title'] = trim(stripslashes($IN['Title']));
		
		if ( (strlen($IN['Title']) < 2) or (!$IN['Title'])  )
		{
			$ADMIN->error("你输入的公告标题必须大于 2 个字符");
		}
		
		if ( strlen($HTTP_POST_VARS['Title']) > 64 )
		{
			$ADMIN->error("你输入的公告标题必须小于 65 个字符");
		}
		

		//-------------------------------------------------
		// If we don't have any errors yet, parse the upload
		//-------------------------------------------------
		
		if ($IN['code']=='doedit')
		{
		$this->edit_ann();
		}
		else
		{
		$this->add_new_ann();
		}
		
	}
	
	
	/*****************************************************/
	// 
	// Add new announcement
	// 
	// 
	/*****************************************************/

	
	function add_new_ann() {
		
		global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS, $ibforums;
		
		
		//-------------------------------------------------
		// Build the master array
		//-------------------------------------------------



		$this->new_annc = array(
							'a_mid'		=>	$this->post[author_id],
							'a_title'	=>	$IN['Title'],
							'a_desc'	=>	$IN['Desc'],
							'a_text'	=>	$this->post[post],
							'a_expire'	=>	$this->post[expire],
							'a_start'	=>	$this->post[start_time],
							'a_end'		=>	$this->post[end_time],
							'a_forum'	=>	$this->post[forum],
							'a_use_sig'	=>	$this->post[use_sig],
							'a_use_smile'	=>	$this->post[use_emo]

							 );
							
		
	
		$db_string = $DB->compile_db_insert_string( $this->new_annc );
		
		$DB->query("INSERT INTO ibf_announcements (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");



		$ADMIN->done_screen("论坛公告已经添加", "论坛公告管理", "act=announcement" );

		
	}



	/*****************************************************/
	// 
	// Edit announcement
	// 
	// 
	/*****************************************************/

	function edit_ann() {
		
		global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS, $ibforums;
		
		
		//-------------------------------------------------
		// Build the master array
		//-------------------------------------------------



		$this->new_annc = array(
							'a_mid'		=>	$this->post[author_id],
							'a_title'	=>	$IN['Title'],
							'a_desc'	=>	$IN['Desc'],
							'a_text'	=>	$this->post[post],
							'a_expire'	=>	$this->post[expire],
							'a_start'	=>	$this->post[start_time],
							'a_end'		=>	$this->post[end_time],
							'a_use_sig'	=>	$this->post[use_sig],
							'a_use_smile'	=>	$this->post[use_emo]

							 );
							
		
	
		$db_string = $DB->compile_db_update_string( $this->new_annc );
		
		$DB->query("UPDATE ibf_announcements SET $db_string WHERE a_id='".$IN[id]."'");



		$ADMIN->done_screen("论坛公告已经编辑", "论坛公告管理", "act=announcement" );

		
	}




/*****************************************************/
// 
// 
// SKINS
// 
// 
/*****************************************************/


function startend_fields($data) {

return <<<EOF
        <tr> 
          <td id="catrow" colspan="2">论坛公告持续时间</td>
        </tr>
        <tr> 
          <td id='tdrow1'><b>公告开始时间</b><BR>(yyyy-mm-dd hh:mm:ss)</td>
          <td id='tdrow2' width="100%" valign="top"><input type='text' size='40' maxlength='50' name='start_time' value='{$data[start_time]}' tabindex='3' id='textinput'></td>
        </tr>
        <tr> 
          <td id='tdrow1'><b>公告结束时间</b><BR>(yyyy-mm-dd hh:mm:ss)<br>留空表示不设置公告结束时间</td>
          <td id='tdrow2' width="100%" valign="top"><input type='text' size='40' maxlength='40' name='end_time' value='{$data[end_time]}' tabindex='4' id='textinput'></td>
        </tr>
EOF;
}





function topictitle_fields($data) {

return <<<EOF
        <tr> 
          <td id="catrow" colspan="2">论坛公告参数设置</td>
        </tr>
        <tr> 
          <td id='tdrow1'>论坛公告标题</td>
          <td id='tdrow2' width="100%" valign="top"><input type='text' size='40' maxlength='50' name='Title' value='{$data[a_title]}' tabindex='1' id='textinput'></td>
        </tr>
        <tr> 
          <td id='tdrow1'>论坛公告描述</td>
          <td id='tdrow2' width="100%" valign="top"><input type='text' size='40' maxlength='40' name='Desc' value='{$data[a_desc]}' tabindex='2' id='textinput'></td>
        </tr>
EOF;
}


function table_top() {

return <<<EOF
	<script language='Javascript' type='text/javascript'>
		<!--
		function PopUp(url, name, width,height,center,resize,scroll,posleft,postop) {
			if (posleft != 0) { x = posleft }
			if (postop  != 0) { y = postop  }
		
			if (!scroll) { scroll = 1 }
			if (!resize) { resize = 1 }
		
			if ((parseInt (navigator.appVersion) >= 4 ) && (center)) {
			  X = (screen.width  - width ) / 2;
			  Y = (screen.height - height) / 2;
			}
			if (scroll != 0) { scroll = 1 }
		
			var Win = window.open( url, name, 'width='+width+',height='+height+',top='+Y+',left='+X+',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
	     }
		//-->
	</script>

EOF;
}



function nameField($data) {

return <<<EOF
        <tr> 
          <td id="catrow" colspan="2">公告发布作者信息</td>
        </tr>
        <tr> 
          <td id="tdrow1">公告发布作者</td>
          <td id="tdrow2" width="100%"><input type='text' size='40' maxlength='40' name='UserName' id='textinput' tabindex='5' value='$data'></td>
        </tr>
EOF;
}






function postbox_buttons($data) {

global $INFO;

return <<<EOF
<script language="javascript1.2">
<!--

	
	
function emo_pop()
{
	
  window.open('index.{$INFO['php_ext']}?act=legends&CODE=emoticons&s={$ibforums->session_id}','Legends','width=250,height=500,resizable=yes,scrollbars=yes'); 
     
}	

	
	function ValidateForm() {
		MessageLength  = document.REPLIER.Post.value.length;
		errors = "";
	
		if (MessageLength < 2) {
			 errors = "你必须输入公告内容！";
		}

		if (errors != "") {
			alert(errors);
			return false;
		} else {
			document.REPLIER.submit.disabled = true;
			return true;
		}
	}
	
	
	
	// IBC Code stuff
	var text_enter_url      = "输入超链接的完整URL";
	var text_enter_url_name = "输入网页的标题";
	var text_enter_image    = "输入图片完整的URL";
	var text_enter_email    = "输入电子邮件地址";
	var text_enter_flash    = "输入Flash的完整URL。";
	var text_code           = "用法：[CODE] 您的代码 [/CODE]";
	var text_quote          = "用法：[QUOTE] 您的引用文章 [/QUOTE]";
	var error_no_url        = "请输入URL";
	var error_no_title      = "请输入标题";
	var error_no_email      = "您必须输入电子邮件地址";
	var error_no_width      = "请输入宽度";
	var error_no_height     = "请输入高度";
	var prompt_start        = "请输入需要格式化的文本";

	var text_enter_number	= "请输入能够查看隐藏内容所需的发帖数量";
	var text_enter_text		= "输入需要隐藏的内容";
	var error_no_number		= "你必须输入发帖数量";
	var error_no_text		= "你必须输入隐藏内容";
	var help_hidep			= "插入隐藏内容 (ALT + F)";
	
	var help_bold           = "插入粗体字（ALT + B）";
	var help_italic         = "插入斜体字（ALT + I）";
	var help_under          = "插入下划线（ALT + U）";
	var help_font           = "插入字体标签";
	var help_size           = "插入字体大小标签";
	var help_color          = "插入字体颜色标签";
	var help_close          = "关闭所有打开标签";
	var help_url            = "插入超级链接（ALT+ H）";
	var help_img            = "插入图片（ALT + G）";
	var help_email          = "插入电子邮件地址（ALT + E）";
	var help_quote          = "插入引用文本（ALT + Q）";
	var help_list           = "创建一个列表（ALT + L）";
	var help_code           = "插入代码引用（ALT + P）";
	var help_click_close    = "点击按钮再次关闭";
	var list_prompt         = "输入列表项目。点击“取消”或者留空来结束此列表";

	//-->
</script>
<script language='Javascript' src='html/ibfcode.js'></script>

        <tr> 
          <td id="catrow" colspan="2">论坛快捷代码按钮</td>
        </tr>
        <tr> 
          <td id='tdrow1'>你可以用鼠标指向代码按钮获取帮助信息，同时按下键盘 'ALT' 和 'c' 可以关闭当前标签</td>
          <td id='tdrow2' width="100%" valign="top">
<table cellpadding='2' cellspacing='2' width='100%' align='center'>
                		<tr>
                			<td nowrap width='10%'>
							  <input type='button' accesskey='b' value=' B '       onClick='simpletag("B")'       id='textinput' title="BOLD: [Control / Alt] + b"      name='bold'   style="font-weight:bold">
							  <input type='button' accesskey='i' value=' I '       onClick='simpletag("I")'       id='textinput' title="ITALIC: [Control / Alt] + i"    name='italic' style="font-style:italic">
							  <input type='button' accesskey='u' value=' U '       onClick='simpletag("U")'       id='textinput' title="UNDERLINE: [Control / Alt] + u" name='under' style="text-decoration:underline">
							  
							  <select name='ffont' id='textinput' onchange="alterfont(this.options[this.selectedIndex].value, 'FONT')">
							  <option value='0'>字体</option>
							  <option value='Arial' style='font-family:Arial'>Arial</option>
							  <option value='Times' style='font-family:Times'>Times</option>
							  <option value='Courier' style='font-family:Courier'>Courier</option>
							  <option value='Impact' style='font-family:Impact'>Impact</option>
							  <option value='Geneva' style='font-family:Geneva'>Geneva</option>
							  <option value='Optima' style='font-family:Optima'>Optima</option>
							  </select><select name='fsize' id='textinput' onchange="alterfont(this.options[this.selectedIndex].value, 'SIZE')">
							  <option value='0'>尺寸</option>
							  <option value='1'>Small</option>
							  <option value='7'>Large</option>
							  <option value='14'>Largest</option>
							  </select><select name='fcolor' id='textinput' onchange="alterfont(this.options[this.selectedIndex].value, 'COLOR')">
							  <option value='0'>颜色</option>
							  <option value='blue' style='color:blue'>Blue</option>
							  <option value='red' style='color:red'>Red</option>
							  <option value='purple' style='color:purple'>Purple</option>
							  <option value='orange' style='color:orange'>Orange</option>
							  <option value='yellow' style='color:yellow'>Yellow</option>
							  <option value='gray' style='color:orange'>Gray</option>
							  <option value='green' style='color:green'>Green</option>
							  </select>
							</td>
							<td align='left'nowrap width='10%'><input type='button' accesskey='c' value=' x '       onClick='closelast()'          id='textinput' title="Close Current Tag: [Control / Alt] + c"      name='bold'   style="color:red"> 关闭当前标签</td>
						 </tr>
						 <tr>
						    <td align='left'>
							  <input type='button' accesskey='h' value=' http:// ' onClick='tag_url()'            id='textinput' title="HYPERLINK: [Control / Alt] + h" style="text-decoration:underline;color:blue">
							  <input type='button' accesskey='g' value=' IMG '     onClick='tag_image()'          id='textinput' title="IMG: [Control / Alt] + g"       >
							  <input type='button' accesskey='e' value='  @  '     onClick='tag_email()'          id='textinput' title="EMAIL: [Control / Alt] + e"     style="text-decoration:underline;color:blue">
							  <input type='button' accesskey='q' value=' Quote '   onClick='simpletag("QUOTE")'   id='textinput' title="QUOTE: [Control / Alt] + q" name='quote'>
							  <input type='button' accesskey='p' value=' Code '    onClick='simpletag("CODE")'    id='textinput' title="CODE: [Control / Alt] + p"  name='code'>
							  <input type='button' accesskey='s' value=' SQL '     onClick='simpletag("SQL")'    id='textinput' title="SQL: [Control / Alt] + s"   name='code'>
							  <input type='button' accesskey='t' value=' HTML '     onClick='simpletag("HTML")'    id='textinput' title="SQL: [Control / Alt] + t"   name='code'>
							</td>
							<td align='left'>
							  <input type='button' accesskey='x' value=' X '       onClick='closeall()'          id='textinput' title="Close Current Tag: [Control / Alt] + x"      name='bold'   style="color:red;font-weight:bold"> 关闭所有标签
							</td>
						</tr>
					</table>
          </td>
        </tr>
        <tr> 
          <td id="catrow" colspan="2">论坛公告内容</td>
        </tr>
        <tr> 
          <td id='tdrow1'>$data[smilies]<br><br><img src="/spacer.gif" alt="" width="180" height="1"></td>
          <td id='tdrow2' width="100%" valign="top"><textarea cols='80' rows='15' wrap='soft' name='Post' tabindex='6' id='textinput'>$data[post]</textarea><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td><input type='checkbox' name='enableemo' value='yes' $data[smilies_checked]></td>
                <td width="100%">您希望在帖子 <b>使用</b> 表情图标吗？</td>
              </tr>
              <tr> 
                <td><input type='checkbox' name='enablesig' value='yes' $data[sig_checked]></td>
                <td width="100%">是否在帖子中加入签名？</td>
              </tr>
            </table></td>
        </tr>
EOF;
}

function smilie_table() {
global $ibforums;
return <<<EOF
    <table align="center" cellspacing='1' cellpadding='3' border='0' id='tdrow1' style="border-width:1px; border-style:solid; width:95%" align='left'>
    <tr>
        <td colspan='{$ibforums->vars['emo_per_row']}' align='center'>可用表情</td>
    </tr>
    <!--THE SMILIES-->
    <tr>
        <td colspan='{$ibforums->vars['emo_per_row']}' id='tdrow2' align='center'><a href='javascript:emo_pop()'>所有表情符号</a></td>
    </tr>
    </table>
EOF;
}


}
?>