<?php

/*
+--------------------------------------------------------------------------
|   Invision Power Board v1.3 Final
|   ========================================
|   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: Warning Functions
|   > Module written by Matt Mecham
|   > Date started: 23rd April 2003
|
|	> Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/

if ( ! defined( 'IN_ACP' ) )
{
	print "<h1>您沒有權限瀏覽此頁</h1>您不能夠直接瀏覽這個網頁內容。如果你最近進行升級，確定您已升級 'admin.php'。";
	exit();
}

$idx = new ad_warning();

$root_path = "";

class ad_warning {

	var $base_url;

	function ad_warning()
	{
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $ibforums;
		
		//---------------------------------------
		// Kill globals - globals bad, Homer good.
		//---------------------------------------
		
		$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
		
		foreach ( $tmp_in as $k => $v )
		{
			unset($$k);
		}
		
		$ADMIN->nav[] = array( 'act=warn', '警告設定' );
		
		$ADMIN->page_detail = "您可以在這裡修改警告參數";
		$ADMIN->page_title  = "會員警告設定";
		
		//---------------------------------------

		switch($IN['code'])
		{
			
			//---------------------
			default:
				$this->overview();
				break;
		}
		
	}
	
	
	//---------------------------------------------------------------
	//
	// Overview: show um.. overview.
	//
	//---------------------------------------------------------------
	
	function overview()
	{
		global $IN, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $ibforums;
		
		$unit_map = array(
						   'd'  => 'Day(s)' ,
						   'h'  => 'Hour(s)',
						 );
		
		$SKIN->td_header[] = array( "警告層級"   , "20%" );
		$SKIN->td_header[] = array( "細節"      , "80%" );
		
		$ADMIN->html .= $SKIN->start_table( "目前啟用的自動任務" );
		
		$warns = array();
		
		$DB->query("SELECT * from ibf_warn_settings ORDER BY warn_level");
		
		while ( $r = $DB->fetch_row() )
		{
			$warns[ $r['warn_level'] ][] = $r;
		}
			
		if ( count($warns) > 0 )
		{
			foreach( $warns as $id => $data )
			{
				$tmp = "";
				
				$ban = "";
				$mod = "";
				$nop = "";
				
				if ( $data['warn_ban'] != "" )
				{
					if ( $data['warn_ban'] == 'p' )
					{
						$ban = "永久封鎖";
					}
					else
					{
						list ($val, $unit) = explode( ',', $data['warn_ban'] );
						
						$ban = "暫時停權： ".$val." ".$unit_map[$unit];
					}
				}
				
				if ( $data['warn_modq'] != "" )
				{
					if ( $data['warn_modq'] == 'p' )
					{
						$mod = "永久發表管制";
					}
					else
					{
						list ($val, $unit) = explode( ',', $data['warn_modq'] );
						
						$mod = "需要發表管制： ".$val." ".$unit_map[$unit];
					}
				}
				
				if ( $data['warn_nopost'] != "" )
				{
					if ( $data['warn_nopost'] == 'p' )
					{
						$nop = "永久發表封鎖中";
					}
					else
					{
						list ($val, $unit) = explode( ',', $data['warn_nopost'] );
						
						$nop = "Post ban for ".$val." ".$unit_map[$unit];
					}
				}
				
				$html = "<table width='100%' cellpadding='4'>";
				
				if ( $ban != "" )
				{
					$html .= "<tr>
								<td width='20%'><strong>封鎖</strong></td>
								<td width='30%'>$ban</td>
								<td width='25%'>編輯</td>
								<td width='25%'>移除</td>
							  </tr>";
				}
				
				if ( $mod != "" )
				{
					$html .= "<tr>
								<td width='20%'><strong>發表管制</strong></td>
								<td width='30%'>$mod</td>
								<td width='25%'>編輯</td>
								<td width='25%'>移除</td>
							  </tr>";
				}
				
				if ( $nop != "" )
				{
					$html .= "<tr>
								<td width='20%'><strong>發表封鎖</strong></td>
								<td width='30%'>$nop</td>
								<td width='25%'>編輯</td>
								<td width='25%'>移除</td>
							  </tr>";
				}
				
				$html .= "</table>";
				
				
				$ADMIN->html .= $SKIN->add_td_row( array( "<b>{$warns['warn_level']}</b>",
														  $html
										 )      );
			}
		}
		
		$ADMIN->html .= $SKIN->add_td_basic( '新增自動任務', 'center', 'pformstrip' );
										 
		$ADMIN->html .= $SKIN->end_table();
		
		//+-------------------------------
		//+-------------------------------
		
		$ADMIN->output();
	

		
		
	}
	
	
	
	
	
	
	
}

?>