<?php
if(!$_SESSION['admin_id']){
	pe_goto("index.php");
}
$menumark = 'link';
switch ($act) {
	case 'add':
		if($_p_dosubmit){
			$_p_info['addtime']=TIME;
			if($db->pe_insert('link',$_p_info))
				pe_success('友情链接添加成功','admin.php?mod=link');
			else pe_error('友情链接添加失败','admin.php?mod=link&act=add');
		}
		else{
			$seo = pe_seo('添加友情链接', '', '', 'admin');
			include(pe_tpl('link_add.html'));
		}
	break;
	case 'edit':
		if($_p_dosubmit){
			if(empty($_p_info['elite']))$_p_info['elite']=0;
			if($db->pe_update('link',array('id'=>$_g_id),$_p_info))
				pe_success('友情链接添加成功','admin.php?mod=link');
			else pe_error('友情链接添加失败','admin.php?mod=link&act=add');
		}
		else{
			$info=$db->pe_select('link',array('id'=>$_g_id));
			$seo = pe_seo('添加友情链接', '', '', 'admin');
			include(pe_tpl('link_add.html'));
		}
	break;
	case 'delete':
		if($db->pe_delete('link',array('id'=>$_g_id)))
			pe_success('友情链接删除成功','admin.php?mod=link');
		else pe_error('友情链接删除失败','admin.php?mod=link');
	break;
	default:
		$data=array();
		$where='';
		if($_g_s)$where['status']=$_g_s;
		$data=$db->pe_selectall('link',$where);
		$elite=array(0=>'<font color="#ff0000">×</font>',1=>'<font color="#0000ff">√</font>');
		$status=array(1=>'<font color="#ff0000">×</font>',9=>'<font color="#0000ff">√</font>');
		$seo = pe_seo('友情链接', '', '', 'admin');
		include(pe_tpl('link_list.html'));
	break;
}
pe_result();
?>