<?php
if(!$_SESSION['admin_id']){
	pe_goto("index.php");
}
$menumark = 'cache_list';
switch ($act) {
	//#####################@ 缓存更新sql @#####################//
	case 'updatesql':
		switch ($_g_cache) {
			case 'category':
				cache::write('category', $db->index('category_id')->pe_selectall('category', array('order by'=>'category_order asc, category_id asc'), '*'));
				cache::write('category_arr', $db->index('category_pid|category_id')->pe_selectall('category', array('order by'=>'category_order asc, category_id asc'), '*'));
				cache::write('package');
				cache::write('noticeclass', $db->index('noticeclass_id')->pe_selectall('noticeclass', array('order by'=>'noticeclass_order asc, noticeclass_id asc'), '*'));
			break;
			case 'setting':
				cache::write('setting', 'setting_key');
			break;
			case 'template':
				pe_dirdel("{$pe['path_root']}data/cache/template");
			break;
			case 'attachment':
				pe_dirdel("{$pe['path_root']}data/cache/attachment");
			break;
			case 'thumb':
				pe_dirdel("{$pe['path_root']}data/cache/thumb");
			break;
			default:
				cache::write('category', $db->index('category_id')->pe_selectall('category', array('order by'=>'category_order asc'), '*'));
				cache::write('category_arr', $db->index('category_pid|category_id')->pe_selectall('category', array('order by'=>'category_order asc'), '*'));
				cache::write('package');
				cache::write('noticeclass', $db->index('noticeclass_id')->pe_selectall('noticeclass', array('order by'=>'noticeclass_order asc, noticeclass_id asc'), '*'));
				cache::write('setting', 'setting_key');
				pe_dirdel("{$pe['path_root']}data/cache/template");
				pe_dirdel("{$pe['path_root']}data/cache/attachment");
				pe_dirdel("{$pe['path_root']}data/cache/thumb");
			break;
		}
		pe_success('缓存更新成功!');
	break;
	//#####################@ 缓存列表 @#####################//
	default:
		//数据库缓存
		$info_list['category']['cache_name'] = '课程信息';
		$info_list['category']['cache_text'] = '网站【套餐信息】或【课程分类】显示错乱或不显示时，可尝试更新此项解决。';
		$category_size = filesize("{$pe['path_root']}data/cache/category.cache.php");
		$category_size += filesize("{$pe['path_root']}data/cache/category_arr.cache.php");
		$category_size += filesize("{$pe['path_root']}data/cache/package.cache.php");
		$info_list['category']['cache_size'] = round($category_size/1024, 1);

		$info_list['setting']['cache_name'] = '网站信息';
		$info_list['setting']['cache_text'] = '网站【基本信息】显示错乱或不显示时，可尝试更新此项解决。';
		$info_list['setting']['cache_size'] = round(filesize("{$pe['path_root']}data/cache/setting.cache.php")/1024, 1);

		//数据缓存
		$info_list['template']['cache_name'] = '模板信息';
		$info_list['template']['cache_text'] = '网站页面显示错乱或不显示时，可尝试更新此项解决。';
		$info_list['template']['cache_size'] = round(pe_dirsize("{$pe['path_root']}data/cache/template")/1024, 1);

		$info_list['attachment']['cache_name'] = '附件信息';
		$info_list['attachment']['cache_text'] = '只要有附件缓存存在，就可以更新此项。';
		$info_list['attachment']['cache_size'] = round(pe_dirsize("{$pe['path_root']}data/cache/attachment")/1024, 1);

		$info_list['thumb']['cache_name'] = '缩略图信息';
		$info_list['thumb']['cache_text'] = '只要有缩略图缓存存在，就可以更新此项。';
		$info_list['thumb']['cache_size'] = round(pe_dirsize("{$pe['path_root']}data/cache/thumb")/1024, 1);

		$seo = pe_seo('缓存管理', '', '', 'admin');
		include(pe_tpl('cache_list.html'));
	break;
}
pe_result();
?>