<?php 
defined('IN_TS') or die('Access Denied.');

switch($ts){
	case "":
		$arrSlides = $db->fetch_all_assoc("select * from ".dbprefix."mobileslide order by sort asc");

		$title = '幻灯设置';
		include template("admin/setad");
		break;
		
	case "do":
	
		$ids= $_POST['id'];
		$slidetitles= $_POST['slidetitle'];
		$slidedescs = $_POST['slidedesc'];//幻灯关键词

		$slideimgs = $_POST['slideimg'];
	    $sorts=$_POST['sort'];
		
		foreach($ids as $key=>$item){
			
			$id= intval($item);
			$slidetitle= trim($slidetitles[$key])?trim($slidetitles[$key]):' ';
			$slidedesc = trim($slidedescs[$key]);
			$slideimg  = trim($slideimgs[$key]);
			
			$sortid=trim($sorts[$key]);

			if(empty($slideimg)) qiMsg("必须选择幻灯图片","<a href=\"index.php?app=mobile&ac=admin&mg=setad\">点击返回</a>");
			if(empty($slidedesc)) qiMsg("关键词必须填写","<a href=\"index.php?app=mobile&ac=admin&mg=setad\">点击返回</a>");
			
			if($slidetitle){
				$db->query("update ".dbprefix."mobileslide set `title`= '".$slidetitle."',`desc`='".$slidedesc."',`img`='".$slideimg."',`sort`='$sortid',`addtime`='".time()."' where id='$id'");
			}
		}
		
		qiMsg("幻灯设置成功^_^","<a href=\"index.php?app=mobile&ac=admin&mg=setad\">点击返回</a>");

		
	
		break;

		case "del":
	
		$id= intval($_GET['id']);
		$db->query("DELETE FROM ".dbprefix."mobileslide where id='$id'");
		
		qiMsg("幻灯删除成功^_^","<a href=\"index.php?app=mobile&ac=admin&mg=setad\">点击返回</a>");

		
	
		break;
}