<?php
 
defined('IN_HS') or exit('Access Denied');
switch($action)
{
case 'manage':
$page = isset($page) ?intval($page) : 1;
$pagesize = $HS['pagesize'] ?$HS['pagesize'] : 30;
$offset = ($page-1)*$pagesize;
$condition = '';
$condition .= $itemname ?" and itemname like '%$itemname%'": '';
$condition .= $itemid ?" and itemid= '$itemid'": '';
$r = $db->get_one("SELECT count(*) as num FROM ".TABLE_ITEMS." WHERE 1 $condition");
$sumnums = $r['num'];
$pages = phppages($r['num'],$page,$pagesize);
$items = array();
$result = $db->query("SELECT * FROM ".TABLE_ITEMS." WHERE 1 $condition ORDER BY itemid DESC LIMIT $offset,$pagesize");
while($r = $db->fetch_array($result))
{
$items[] = $r;
}
include admintpl('items');
break;
case 'import':
$handle = fopen(HS_ROOT."/items.csv","r");
if(!$handle) showmessage("打开文件失败！请将items.csv放到网站根目录下。");
$db->query("DELETE FROM ".TABLE_ITEMS."");
while ($data = fgetcsv($handle,"",",")) {
if($data[0] !='ID'&&$data[13] !='1')
{
$db->query("INSERT INTO ".TABLE_ITEMS." (`itemid`,`itemname`,`itemmemo`) VALUES ('$data[0]','$data[1]','$data[60]')");
}
}
fclose($handle);
showmessage("所有装备数据已导入成功！","goback");
break;
}
?>