<?php
/**
 * @version $Id: special.inc.php v2.0 $
 * @package PBDigg
 * @copyright Copyright (C) 2007 - 2008 PBDigg.com. All Rights Reserved.
 * @license PBDigg is free software and use is subject to license terms
 */

if(!defined('IN_ADMIN') || !isset($_PBDEV['PHP_SELF']) || !preg_match('/[\/\\\\]admincp\.php$/i', $_PBDEV['PHP_SELF']))
{
	exit('Access Denied');
}
define('PB_CSCRIPT', 'special');
allowdo('setspecial');
$baseurl = 'admincp.php?action=special&type=';

if (!$type || $type == 'add')
{
	$type = 'add';
}
elseif ($type == 'list')
{
	$sql = '';
	if ($orderby == 'createdate' && in_array($ad, array('ASC', 'DESC')))
	{
		$newad = ($ad == 'DESC') ? 'ASC' : 'DESC';
		$sql .= ' ORDER BY createdate '.$ad;
	}
	$rt = $DB->db_fetch_one_array("SELECT COUNT(*) num FROM {$db_prefix}special");
	$totalRecords = (int)$rt['num'];
	$pageSize = 30;
	$page = !isPage($page) ? 1 : $page;
	$start_limit = ($page -1) * $pageSize;
	$mult = cpmultLink($page, $totalRecords, 'admincp.php?action=special&type=list&orderby='.$orderby.'&ad='.$ad.'&', $pageSize);
	$DB->db_query("SELECT * FROM {$db_prefix}special");
	$special = array();
	while ($rt = $DB->db_fetch_array())
	{
		$rt['sdesc'] = PBSubstr($rt['sdesc'], 100);
		$rt['ifopenword'] = $rt['ifopen'] ? '开启' : '<span class="r">关闭</span>';
	}
}
elseif ($type == 'edit')
{
	
}
elseif ($type == 'del')
{
	
}
elseif ($type == 'status')
{
	
}
else
{
	redirect('未定义操作', 'admincp.php?action=main');
}

$TPL->assign('menu', $m_special);
?>