<?php

/*
+--------------------------------------------------------------------------
|   Invision Power Board v1.1
|   ========================================
|   by Matthew Mecham
|   (c) 2001,2002 Invision Power Services
|   http://www.ibforums.com
|   ========================================
|   Web: http://www.ibforums.com
|   Email: phpboards@ibforums.com
|   Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
|   > Admin Category functions
|   > Module written by Matt Mecham
|   > Date started: 1st march 2002
|
|	> Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/



$idx = new ad_cat();


class ad_cat {

	var $base_url;

	function ad_cat() {
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		//---------------------------------------
		// Kill globals - globals bad, Homer good.
		//---------------------------------------
		
		$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
		
		foreach ( $tmp_in as $k => $v )
		{
			unset($$k);
		}

		switch($IN['code'])
		{
			case 'new':
				$this->new_form();
				break;
			case 'donew':
				$this->do_new();
				break;
			//+-------------------------
			case 'edit':
				$this->show_cats();
				break;
			case 'doeditform':
				$this->edit_form();
				break;
			case 'doedit':
				$this->do_edit();
				break;
			//+-------------------------
			case 'remove':
				$this->remove_form();
				break;
			case 'doremove':
				$this->do_remove();
				break;
			//+-------------------------
			case 'reorder':
				$this->reorder_form(); //Get it? No... ok.
				break;
			case 'doreorder':
				$this->do_reorder();
				break;
			
			default:
				$this->show_cats();
				break;
		}
		
	}
	
	
	
	//+---------------------------------------------------------------------------------
	//
	// RE-ORDER CATEGORY
	//
	//+---------------------------------------------------------------------------------
	
	function reorder_form() {
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		$ADMIN->page_title = "论坛分类排序";
		$ADMIN->page_detail  = "如果需要对论坛分类进行重新排序，那么只要从下拉菜单中选择你满意的排列序号，然后确认就可以了。";
		
		$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'doreorder'),
												  2 => array( 'act'   , 'cat'     ),
											) );
		
		
		$SKIN->td_header[] = array( "&nbsp;"       , "10%" );
		$SKIN->td_header[] = array( "论坛分类和栏目名称"   , "60%" );
		$SKIN->td_header[] = array( "主题回复"        , "15%" );
		$SKIN->td_header[] = array( "主题发表"       , "15%" );
		
		$ADMIN->html .= $SKIN->start_table( "你的论坛分类和栏目" );
		
		$cats   = array();
		$forums = array();
		
		$DB->query("SELECT * from ibf_categories WHERE id > 0 ORDER BY position ASC");
		while ($r = $DB->fetch_row())
		{
			$cats[] = $r;
		}
		
		$DB->query("SELECT * from ibf_forums ORDER BY position ASC");
		while ($r = $DB->fetch_row())
		{
			$forums[] = $r;
		}
		
		
		// Build up the drop down box
		
		$form_array = array();
		
		for ($i = 1 ; $i <= count($cats) ; $i++ )
		{
			$form_array[] = array( $i , $i );
		}
		
		
		$last_cat_id = -1;
		
		foreach ($cats as $c)
		{
			
			$ADMIN->html .= $SKIN->add_td_row( array(  $SKIN->form_dropdown( 'POS_'.$c['id'], $form_array, $c['position'] ),
													   $c['name'],
													   '&nbsp;',
													   '&nbsp;',
											 ), 'catrow'     );
			$last_cat_id = $c['id'];
			
			
			foreach($forums as $r)
			{	
			
				if ($r['category'] == $last_cat_id)
				{
					$ADMIN->html .= $SKIN->add_td_row( array(
															   '&nbsp;',
															   "<b>".$r['name']."</b><br>".$r['description'],
															   $r['posts'],
															   $r['topics'],
													 )      );
				}
			}
		}
		
		$ADMIN->html .= $SKIN->end_form("调整论坛分类排序");
		
		$ADMIN->html .= $SKIN->end_table();
		
		$ADMIN->output();
		
	}
	
	//+---------------------------------------------------------------------------------
	
	function do_reorder() {
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		$cat_query = $DB->query("SELECT id from ibf_categories");
		
		while ( $r = $DB->fetch_row($cat_query) )
		{
			$order_query = $DB->query("UPDATE ibf_categories SET position='".$IN[ 'POS_' . $r['id'] ]."' WHERE id='".$r['id']."'");
		}
		
		$ADMIN->save_log("调整论坛分类排序");
		
		$ADMIN->done_screen("论坛分类排序已经调整", "论坛分类排序", "act=cat" );
		
	}
	
	
	//+---------------------------------------------------------------------------------
	//
	// REMOVE CATEGORY
	//
	//+---------------------------------------------------------------------------------
	
	function remove_form() {
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		$form_array = array();
		
		if ($IN['c'] == "")
		{
			$ADMIN->error("没有找到需要更新的论坛分类ID。");
		}
		
		$DB->query("SELECT id, name FROM ibf_categories WHERE id > 0 ");
		
		//+-------------------------------
		// Make sure we have more than 1
		// category..
		//+-------------------------------
		
		if ($DB->get_num_rows() < 2)
		{
			$ADMIN->error("无法删除这个论坛分类，请尝试建立其它论坛分类");
		}
		
		while ( $r = $DB->fetch_row() )
		{
			if ($r['id'] == $IN['c'])
			{
				continue;
			}
			
			$form_array[] = array( $r['id'] , $r['name'] );
		}
		
		//+-------------------------------
		// Get the details for this category...
		//+-------------------------------
		
		$DB->query("SELECT * FROM ibf_categories WHERE id='".$IN['c']."'");
		$cat = $DB->fetch_row();
		
		//+-------------------------------
		
		$ADMIN->page_title = "删除论坛分类：'{$cat['name']}'";
		
		$ADMIN->page_detail = "删除论坛分类前，我们需要决定如何处理论坛分类下的论坛栏目。";
		
		//+-------------------------------
		
		$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'doremove'),
												  2 => array( 'act'   , 'cat'     ),
												  3 => array( 'c'     , $IN['c']  ),
												  4 => array( 'name'  , $cat['name'] ),
											) );
		
		//+-------------------------------
		
		$SKIN->td_header[] = array( "&nbsp;"  , "40%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "60%" );
		
		//+-------------------------------
		
		$ADMIN->html .= $SKIN->start_table( "必须进行选择或填写" );
		
		$ADMIN->html .= $SKIN->add_td_row( array( "<b>删除论坛分类：</b>" , $cat['name'] )      );
									     
		$ADMIN->html .= $SKIN->add_td_row( array( "<b>将此论坛分类下存在的所有论坛栏目移动到：</b>" ,
												  $SKIN->form_dropdown( "MOVE_ID", $form_array )
									     )      );
									     
		$ADMIN->html .= $SKIN->end_form("移动论坛栏目并删除论坛分类");
										 
		$ADMIN->html .= $SKIN->end_table();
		
		$ADMIN->output();
		
		
	}
	
	//+---------------------------------------------------------------------------------
	
	function do_remove() {
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		if ($IN['c'] == "")
		{
			$ADMIN->error("没有找到论坛分类ID信息。");
		}
		
		if ($IN['MOVE_ID'] == "")
		{
			$ADMIN->error("没有找到论坛分类ID文件。");
		}
		
		
		$DB->query("UPDATE ibf_forums SET category='".$IN['MOVE_ID']."' WHERE category='".$IN['c']."'");
		
		$DB->query("DELETE FROM ibf_categories WHERE id='".$IN['c']."'");
		
		$ADMIN->save_log("删除论坛分类：'{$IN['name']}'");
		
		$ADMIN->done_screen("论坛分类已经删除", "论坛分类控制面板", "act=cat" );
		
	}
	
	//+---------------------------------------------------------------------------------
	//
	// EDIT CATEGORY
	//
	//+---------------------------------------------------------------------------------
	
	function edit_form() {
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		$subcats = array();
		
		$DB->query("SELECT id, name FROM ibf_categories WHERE id > 0");
		
		while ( $r = $DB->fetch_row() )
		{
			if ($r['id'] == $IN['c'])
			{
				continue;
			}
			
			$subcats[] = array( $r['id'] , $r['name'] );
		}
		
		$DB->query("SELECT * FROM ibf_categories WHERE id='".$IN['c']."'");
		$cat = $DB->fetch_row();
		
		$ADMIN->page_title = "编辑论坛分类";
		
		$ADMIN->page_detail = "你可以在下面编辑论坛分类信息，如果你希望在论坛分类名称前添加图片，那么只需要在分类名称适当位置输入图片地址和链接就可以了。";
		
		//+-------------------------------
		
		$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'doedit'),
												  2 => array( 'VIEW'  , '*'    ),
												  3 => array( 'act'   , 'cat'  ),
												  4 => array( 'c'     , $IN['c'] ),
											) );
		
		//+-------------------------------
		
		$SKIN->td_header[] = array( "&nbsp;"  , "30%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "60%" );
		
		//+-------------------------------
		
		$ADMIN->html .= $SKIN->start_table( "必须进行选择或填写" );
		
		$ADMIN->html .= $SKIN->add_td_row( array( "<b>论坛分类名称：</b>" ,
												  $SKIN->form_input("CAT_NAME", $cat['name'])
									     )      );
									     
		$ADMIN->html .= $SKIN->add_td_row( array( "<b>论坛分类状态：</b>" ,
												  $SKIN->form_dropdown( "CAT_STATE",
																			array( 
																					0 => array( 1, '显示' ),
																					1 => array( 0, '隐藏'  ),
																				 ),
												  						$cat['state']
												  					  )
									     )      );
									     
		/*$ADMIN->html .= $SKIN->end_table();
		
		//+-------------------------------
		
		$SKIN->td_header[] = array( "&nbsp;"  , "30%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "60%" );
		
		$ADMIN->html .= $SKIN->start_table( "Optional" );
		
		$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category Sponsor Image</b><br>(Example: http://www.domain.com/image.gif)" ,
												  $SKIN->form_input("IMAGE", $cat['image'])
									     )      );
									     
		$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category Sponsor Link</b><br>(Example: http://www.domain.com/)" ,
												  $SKIN->form_input("URL", $cat['url'])
									     )      );*/
									     
		$ADMIN->html .= $SKIN->end_form("编辑论坛分类");
										 
		$ADMIN->html .= $SKIN->end_table();
		
		$ADMIN->output();
			
			
	}

	//+---------------------------------------------------------------------------------
	
	function do_edit() {
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		$IN['CAT_NAME'] = trim($IN['CAT_NAME']);
		
		if ($IN['CAT_NAME'] == "")
		{
			$ADMIN->error("你必须输入论坛分类名称");
		}
		
		if ($IN['c'] == "")
		{
			$ADMIN->error("没有找到需要更新的论坛分类ID。");
		}
		
		$db_string = $DB->compile_db_update_string( array (
															'state'         => $IN['CAT_STATE'],
															'name'          => $IN['CAT_NAME'],
															'description'   => $IN['CAT_DESC'],
															'image'         => $IN['IMAGE'],
															'url'           => $IN['URL'],
												  )       );
												  
		$DB->query("UPDATE ibf_categories SET $db_string WHERE id='".$IN['c']."'");
		
		$ADMIN->save_log("编辑论坛分类：'{$IN['CAT_NAME']}'");
		
		$ADMIN->done_screen("论坛分类：'{$IN['CAT_NAME']}' 完成编辑", "论坛分类控制面板", "act=cat" );
		
	}

	
	//+---------------------------------------------------------------------------------
	//
	// SHOW CATS
	// Renders a complete listing of all the forums and categories.
	//
	//+---------------------------------------------------------------------------------
	
	function show_cats() {
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		$ADMIN->page_title   = "论坛分类和论坛栏目全局管理";
		$ADMIN->page_detail  = "你可以根据下面的提示对论坛分类和论坛栏目进行快速管理和设置。".
							   "<br><table cellpadding='3' cellspacing='0' border='0' align='left' width='100%'>".
							   "<tr><td><b>编辑设置</b></td><td>允许你对论坛栏目进行编辑</td></tr>". "<tr><td><b>删除</b></td><td>删除论坛栏目并且移动栏目内的主题和帖子到你选择的论坛栏目</td></tr>".
							   "<tr><td><b>清空</b></td><td>删除栏目内的所有主题和帖子 - 需要进行确认</td></tr>".
							   "<tr><td><b>编辑权限</b></td><td>编辑论坛用户团队访问论坛栏目时的权限</td></tr>".
							   "<tr><td><img src='{$SKIN->img_url}/acp_rules.gif' border='0' align='absmiddle'></td><td><b>论坛规则</b> - 添加/编辑/删除 论坛栏目规则内容</td></tr>".
							   "<tr><td><img src='{$SKIN->img_url}/acp_edit.gif' border='0' align='absmiddle'></td><td><b>主题界面</b> - 添加/编辑/删除 论坛栏目主题界面</td></tr>".
							   "<tr><td><img src='{$SKIN->img_url}/acp_resync.gif' border='0' align='absmiddle'></td><td><b>重新计算</b> - 重新计算论坛栏目内主题、帖子、最后发表信息</td></tr>".
							   "</table>";
		$cats     = array();
		$forums   = array();
		$children = array();
		$skins    = array();
		
		$DB->query("SELECT * from ibf_categories WHERE id > 0 ORDER BY position ASC");
		while ($r = $DB->fetch_row())
		{
			$cats[$r['id']] = $r;
		}
		
		$DB->query("SELECT * from ibf_forums ORDER BY position ASC");
		while ($r = $DB->fetch_row())
		{
			
			if ($r['parent_id'] > 0)
			{
				$children[ $r['parent_id'] ][] = $r;
			}
			else
			{
				$forums[] = $r;
			}
			
		}
		
		$DB->query("SELECT uid, sname, sid FROM ibf_skins");
		while ($s = $DB->fetch_row())
		{
			$skins[$s['sid']] = $s['sname'];
		}
		
		$SKIN->td_header[] = array( "&nbsp;"       , "5%" );
		$SKIN->td_header[] = array( "论坛分类/栏目名称"   , "30%" );
		$SKIN->td_header[] = array( "回复"        , "10%" );
		$SKIN->td_header[] = array( "主题"       , "10%" );
		$SKIN->td_header[] = array( "&nbsp;"       , "15%" );
		$SKIN->td_header[] = array( "&nbsp;"       , "15%" );
		$SKIN->td_header[] = array( "&nbsp;"       , "15%" );
		
		$ADMIN->html .= $SKIN->start_table("你的论坛分类和论坛栏目信息");
		
		$last_cat_id = -1;
		
		foreach ($cats as $c)
		{
			
		
			$ADMIN->html .= $SKIN->add_td_row( array(
													   array($c['name'], 2),
													   '&nbsp;',
													   '&nbsp;',
													   "<a href='{$ADMIN->base_url}&act=cat&code=doeditform&c={$c['id']}'>编辑</a>",
													   '&nbsp;',
													   "<a href='{$ADMIN->base_url}&act=cat&code=remove&c={$c['id']}'>删除</a>",
											 ), 'catrow'     );
			$last_cat_id = $c['id'];
			
			
			foreach($forums as $r)
			{	
			
				if ($r['category'] == $last_cat_id)
				{
					
					if ( ($r['skin_id'] != "") and ($r['skin_id'] >= 0) )
					{
						$skin_stuff = "<br>[ "."使用主题界面：".$skins[$r['skin_id']]." ]";
					}
					else
					{
						$skin_stuff = "";
					}
				
					if ($r['subwrap'] == 1)
					{
					
						if ($r['sub_can_post'])
						{
							$ADMIN->html .= $SKIN->add_td_row( array(
																	   "&nbsp;&gt;",
																	   "<b>".$r['name']."</b>$skin_stuff<br>".$r['description'],
																	   $r['posts'],
																	   $r['topics'],
																	   "<a href='{$ADMIN->base_url}&act=forum&code=subedit&f={$r['id']}'>编辑设置</a><br><br>".
																	   "<a href='{$ADMIN->base_url}&act=forum&code=pedit&f={$r['id']}'>编辑权限</a>",
																	   
																	   "<center><a href='{$ADMIN->base_url}&act=forum&code=frules&f={$r['id']}'><img src='{$SKIN->img_url}/acp_rules.gif' border='0' title='论坛规则'></a>&nbsp;&nbsp;".
																	   "<a href='{$ADMIN->base_url}&act=forum&code=skinedit&f={$r['id']}'><img src='{$SKIN->img_url}/acp_edit.gif' border='0' title='主题选项'></a>&nbsp;&nbsp;".
																	   "<a href='{$ADMIN->base_url}&act=forum&code=recount&f={$r['id']}'><img src='{$SKIN->img_url}/acp_resync.gif' border='0' title='重新计算'></a></center>",
																	   
																	   "<a href='{$ADMIN->base_url}&act=forum&code=subdelete&f={$r['id']}'>删除</a><br><br>".
																	   "<a href='{$ADMIN->base_url}&act=forum&code=empty&f={$r['id']}'>清空</a>",
															 )  , 'catrow2'    );
						}
						else
						{
							$ADMIN->html .= $SKIN->add_td_row( array(
																	  "&nbsp;&gt;",
																	   "<b>".$r['name']."</b>$skin_stuff",
																	   "-",
																	   "-",
																	   "<a href='{$ADMIN->base_url}&act=forum&code=subedit&f={$r['id']}'>编辑</a>",
																	   "<a href='{$ADMIN->base_url}&act=forum&code=skinedit&f={$r['id']}'>主题选项</a>",
																	   "<a href='{$ADMIN->base_url}&act=forum&code=subdelete&f={$r['id']}'>删除</a>",
															 )  , 'catrow2'    );
						}
					}
					else
					{
						$ADMIN->html .= $SKIN->add_td_row( array(
																   array("<b>".$r['name']."</b>$skin_stuff<br>".$r['description'], 2),
																   $r['posts'],
																   $r['topics'],
																   "<a href='{$ADMIN->base_url}&act=forum&code=edit&f={$r['id']}'>编辑设置</a><br><br>".
																   "<a href='{$ADMIN->base_url}&act=forum&code=pedit&f={$r['id']}'>编辑权限</a>",
																   
																   "<center><a href='{$ADMIN->base_url}&act=forum&code=frules&f={$r['id']}'><img src='{$SKIN->img_url}/acp_rules.gif' border='0' title='论坛规则'></a>&nbsp;&nbsp;".
																   "<a href='{$ADMIN->base_url}&act=forum&code=skinedit&f={$r['id']}'><img src='{$SKIN->img_url}/acp_edit.gif' border='0' title='主题选项'></a>&nbsp;&nbsp;".
																   "<a href='{$ADMIN->base_url}&act=forum&code=recount&f={$r['id']}'><img src='{$SKIN->img_url}/acp_resync.gif' border='0' title='重新计算'></a></center>",
																   
																   "<a href='{$ADMIN->base_url}&act=forum&code=delete&f={$r['id']}'>删除</a><br><br>".
																   "<a href='{$ADMIN->base_url}&act=forum&code=empty&f={$r['id']}'>清空</a>",
														 )      );
					}
													 
					if ( ( isset($children[ $r['id'] ]) ) and ( count ($children[ $r['id'] ]) > 0 ) )
					{
						foreach($children[ $r['id'] ] as $idx => $rd)
						{
						
							if ( ($rd['skin_id'] != "") and ($rd['skin_id'] >= 0) )
							{
								$skin_stuff = "<br>[ "."使用主题界面：".$skins[$rd['skin_id']]." ]";
							}
							else
							{
								$skin_stuff = "";
							}
					
							$ADMIN->html .= $SKIN->add_td_row( array(
															   "&nbsp;&gt;",
															   "<b>".$rd['name']."</b>$skin_stuff<br>".$rd['description'],
															   $rd['posts'],
															   $rd['topics'],
															   "<a href='{$ADMIN->base_url}&act=forum&code=edit&f={$rd['id']}'>编辑设置</a><br><br>".
															   "<a href='{$ADMIN->base_url}&act=forum&code=pedit&f={$rd['id']}'>编辑权限</a>",
															   "<center><a href='{$ADMIN->base_url}&act=forum&code=frules&f={$rd['id']}'><img src='{$SKIN->img_url}/acp_rules.gif' border='0' title='论坛规则'></a>&nbsp;&nbsp;".
															   "<a href='{$ADMIN->base_url}&act=forum&code=skinedit&f={$rd['id']}'><img src='{$SKIN->img_url}/acp_edit.gif' border='0' title='主题选项'></a>&nbsp;&nbsp;".
															   "<a href='{$ADMIN->base_url}&act=forum&code=recount&f={$rd['id']}'><img src='{$SKIN->img_url}/acp_resync.gif' border='0' title='重新计算'></a></center>",
															   "<a href='{$ADMIN->base_url}&act=forum&code=delete&f={$rd['id']}'>删除</a><br><br>".
															   "<a href='{$ADMIN->base_url}&act=forum&code=empty&f={$rd['id']}'>清空</a>",
													 ) , 'subforum' );
						}
					}					 
												
				}
			}
		}
		
		$ADMIN->html .= $SKIN->end_table();
		
		$ADMIN->output();
		
	}
	
	//+---------------------------------------------------------------------------------
	//
	// NEW CATEGORY
	//
	//+---------------------------------------------------------------------------------
	
	function new_form() {
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_GET_VARS;
		
		$cat_name = "";
		
		if ($HTTP_GET_VARS['name'] != "")
		{
			$cat_name = stripslashes(urldecode($HTTP_GET_VARS['name']));
		}
		
		$ADMIN->page_title = "添加论坛分类";
		
		$ADMIN->page_detail = "你可以在下面添加论坛分类，如果你希望在论坛分类名称前添加图片，那么只需要在分类名称适当位置输入图片地址和链接就可以了。";
		
		//+-------------------------------
		
		$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'donew'),
												  2 => array( 'act'   , 'cat'  ),
											) );
		
		//+-------------------------------
		
		$SKIN->td_header[] = array( "&nbsp;"  , "30%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "60%" );
		
		//+-------------------------------
		
		$ADMIN->html .= $SKIN->start_table( "必须进行选择或填写" );
		
		$ADMIN->html .= $SKIN->add_td_row( array( "<b>论坛分类名称：</b>" ,
												  $SKIN->form_input("CAT_NAME", $cat_name)
									     )      );
									     
		$ADMIN->html .= $SKIN->add_td_row( array( "<b>论坛分类状态：</b>" ,
												  $SKIN->form_dropdown( "CAT_STATE",
																			array( 
																					0 => array( 1, '显示' ),
																					1 => array( 0, '隐藏'  ),
																				 ),
												  						"1"
												  					  )
									     )      );
									     
		/*$ADMIN->html .= $SKIN->end_table();
		
		//+-------------------------------
		
		$SKIN->td_header[] = array( "&nbsp;"  , "30%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "60%" );
		
		$ADMIN->html .= $SKIN->start_table( "Optional" );
		
		$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category Sponsor Image</b><br>(Example: http://www.domain.com/image.gif)" ,
												  $SKIN->form_input("IMAGE")
									     )      );
									     
		$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category Sponsor Link</b><br>(Example: http://www.domain.com/)" ,
												  $SKIN->form_input("URL")
									     )      );*/
		
		$ADMIN->html .= $SKIN->end_form("添加论坛分类");
										 
		$ADMIN->html .= $SKIN->end_table();
		
		$ADMIN->output();
			
			
	}


	//+---------------------------------------------------------------------------------
	
	function do_new() {
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
		
		$IN['CAT_NAME'] = trim($IN['CAT_NAME']);
		
		if ($IN['CAT_NAME'] == "")
		{
			$ADMIN->error("你必须输入论坛分类名称");
		}
		
		// Get the new cat id. We could use auto_incrememnt, but we need the ID to use as the default
		// category position...
		
		$DB->query("SELECT MAX(id) as top_cat FROM ibf_categories");   //ooh, top cat - he's the leader of our gang..
		$row = $DB->fetch_row();
		
		if ($row['top_cat'] < 1) $row['top_cat'] = 0;
		
		$row['top_cat']++;
		
		$db_string = $DB->compile_db_insert_string( array (
															'id'            => $row['top_cat'],
															'position'      => $row['top_cat'],
															'state'         => $IN['CAT_STATE'],
															'name'          => $IN['CAT_NAME'],
															'description'   => $IN['CAT_DESC'],
															'image'         => $IN['IMAGE'],
															'url'           => $IN['URL'],
												  )       );
												  
		$DB->query("INSERT INTO ibf_categories (".$db_string['FIELD_NAMES'].") VALUES (".$db_string['FIELD_VALUES'].")");
		
		$ADMIN->save_log("添加论坛分类：'{$IN['CAT_NAME']}'");
		
		$ADMIN->done_screen("论坛分类 {$IN['CAT_NAME']} 添加完成", "论坛分类控制面板", "act=cat" );
		
		
		
	}


	
}


?>