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

$userid = aac('user')->isLogin();

switch($ts){
	case "list":
	
			$kw=urldecode(tsFilter($_GET['kw']));

			$page = isset($_GET['page']) ? intval($_GET['page']) : '1';
			
			$url = tsUrl('attach','editor',array('ts'=>'list','page'=>''));

			$lstart = $page*10-10;
			
			if($kw=='')
			{
				$attachlist = $new['attach']->findAll('attach',array('userid'=>$userid),'addtime desc',null,$lstart.',10');
				$albumNum = $new['attach']->findCount('attach');
			}else
			{
				$kw = t($kw);
				$attachlist = $db->fetch_all_assoc("select * from ".dbprefix."attach WHERE `userid` = '$userid' AND `attachname` like '%$kw%' order by addtime desc limit $lstart,10");
				$albumNum = $db->once_num_rows("select * from ".dbprefix."attach WHERE `userid` = '$userid' AND attachname like '%$kw%'");
			}

			$pageUrl = pagination($albumNum, 10, $page, $url);
						
			include template("editor");
		break;
	case "upload":
			$albumid=0;
			include template("upload");
		break;
}