<?php
if(!$_SESSION['admin_id']){
	pe_goto("index.php");
}
$menumark = "prodv_list";
switch ($act) {
	case 'tgpic':
	case 'tgword':
		if (isset($_p_pesubmit)) {
			foreach ($_p_info as $k => &$v) {
				$v = trim($v);
			}
			$tg = serialize($_p_info);
			if ($db->pe_update('prodv', array('id'=>$_g_id), array("{$act}"=>$tg))) {
				pe_success('广告代码修改成功!');
			}
			else {
				pe_error('广告代码修改失败...');
			}		
		}
		else{
			$info = $db->pe_select('prodv', array('id'=>$_g_id));
			$info_list = (array)unserialize($info["{$act}"]);

			include(pe_tpl('package_tgdialog.html'));
		}
	break;
	case 'add':
		if($_p_dosubmit){
			if ($_FILES['thumb']['size']) {
				pe_lead('include/class/upload.class.php');
				$upload = new upload($_FILES['thumb']);
				$_p_info['thumb'] = $upload->fileurl;
			}
			$_p_info['addtime']=TIME;
			if ($db->pe_insert('prodv',pe_dbhold($_p_info, array('content')))){
				//更新缓存
				pe_success('积分产品增加成功!', "admin.php?mod=prodv&act=list");
			}
			else {
				pe_error('积分产品增加失败!');
			}
		}
		else{
			$package_tpl = pe_dirlist("{$pe['path_root']}template/default/index/diy_*.html");
			$seo = pe_seo('增加积分产品', '', '', 'admin');
			include(pe_tpl('prodv_add.html'));
		}	
	break;
	case 'edit':
		if($_p_dosubmit){	
			if ($_FILES['thumb']['size']) {
				pe_lead('include/class/upload.class.php');
				$upload = new upload($_FILES['thumb']);
				$_p_info['thumb'] = $upload->fileurl;
			}
			if ($db->pe_update('prodv',array('id'=>$_g_id),pe_dbhold($_p_info, array('content')))){
				//更新缓存
				pe_success('积分产品修改成功!', "admin.php?mod=prodv&act=list");
			}
			else {
				pe_error('积分产品修改失败!');
			}
		}
		else{
			$info = $db->pe_select('prodv', array('id'=>$_g_id));
			$package_tpl = pe_dirlist("{$pe['path_root']}template/default/index/diy_*.html");
			$seo = pe_seo('修改积分产品', '', '', 'admin');
			include(pe_tpl('prodv_add.html'));
		}	
	break;
	default :
		$info_list = $db->pe_selectall('prodv',array('order by'=>'status desc'));
		$seo = pe_seo('积分产品列表', '', '', 'admin');
		include(pe_tpl('prodv_list.html'));
	break;
}
pe_result();
?>