<?php
switch ($act) {
	//#####################@ 推广联盟  @#####################//

	case 'tgpic':
	case 'tgword':
		$menumark = 'package';
		$user = $db->pe_select('user', array('user_id'=>$_s_user_id));
		$info = $db->pe_select('package', array('package_id'=>$_g_id), '`package_tgpic`, `package_tgword`, `package_domainmark`, `package_name`, `package_money`');

		$info_list = $act == 'tgpic' ? (array)unserialize($info['package_tgpic']) : (array)unserialize($info['package_tgword']);

		
		$maindomain = "http://";
		$name="";
		$money="";
		$urlmodel = $pe['url_model'] == 'pathinfo_safe' ? '/index.php' : '';
		//tg
		if ($info['package_name']) {
			$name .= "{$info['package_name']}";
		}
		if ($info['package_money']) {
			$money .= "{$info['package_money']}";
		}
		
		if ($info['package_domainmark']) {
			$maindomain = "{$info['package_domainmark']}/?u={$user['user_id']}";
		}else {
		    $maindomain = "{$pe['host_root']}index.php?mod=product&id={$_g_id}&u={$user['user_id']}";
		}

		$seo = pe_seo('推广联盟');
		include(pe_tpl('package_tg_dialog.html'));
	break;
	//#####################@ 推广联盟  @#####################//
	case 'tg':
		//搜索
		
		$_g_keyword && $sqlwhere .= " and `package_name` like '%{$_g_keyword}%' or `package_description` like '%{$_g_keyword}%'";
		if($_GET['ratio']==0){
		$ratio=1;
		}else{
		$ratio=0;
		}
		if($_GET['broke']==0){
		$broke=1;
		}else{
		$broke=0;
		}
        if($ratio==0){
		$sqlwhere .= " order by `package_tc1_free` asc";
		}elseif($ratio==1){
		$sqlwhere .= " order by `package_tc1_free` desc";
		}elseif($broke==0){
		$sqlwhere .= " order by `package_money` desc";
		}elseif($broke==1){
		$sqlwhere .= " order by `package_money` asc";
		}else{
		$sqlwhere .= " order by `package_id` asc";
		}

		$menumark = 'package';
		$cache_packagetype = cache::get('packagetype');
		if(empty($_g_tid))
			$info_list = $db->pe_selectall('package', $sqlwhere, '*',array(20, $_g_page));
		else {
			$info_list = $db->pe_selectall('package',array('package_type'=>$_g_tid));
			}
		
		$info= $db->pe_selectall('notice', " and `notice_id` in(4,5,6)");
		$seo = pe_seo('推广联盟');
		include(pe_tpl('package_tg.html'));
	break;
	
	case 'zt':
		//搜索
		$_g_keyword && $sqlwhere .= " and `package_name` like '%{$_g_keyword}%' or `package_description` like '%{$_g_keyword}%'";
		$sqlwhere .= " order by `package_id` asc";
		
		$user = $db->pe_select('user', array('user_id'=>$_s_user_id));
		
		$menumark = 'package';
		$cache_packagetype = cache::get('packagetype');
		if(empty($_g_tid))
			$info_list = $db->pe_selectall('package', $sqlwhere, '*',array(20, $_g_page));
		else {
			
			$info_list = $db->pe_selectall('package',array('package_type'=>$_g_tid));
			}
		//只有一个套餐的时候
		$maindomain = "http://{$info['user_subdomain']}.{$pe['domain_mark']}/";
		//有多个套餐的时候
		$maindomain_many = $pe['url_model']=='pathinfo_safe' ? "{$maindomain}index.php/" : $maindomain;
		$info = $db->pe_selectall('notice', " and `notice_id` in(4,5,6)");
		$seo = pe_seo('推广联盟');
		include(pe_tpl('package_zt.html'));
	break;
	
	case 'zc':
		$menumark = 'package';
		$cache_packagetype = cache::get('packagetype');
		if(empty($_g_tid))
			$info_list = $db->pe_selectall('package', $sqlwhere, '*',array(20, $_g_page));
		else{
			
			$info_list = $db->pe_selectall('package',array('package_type'=>$_g_tid));
		}
		
		$info = $db->pe_selectall('notice', " and `notice_id` in(4,5,6)");
		$seo = pe_seo('推广联盟');
		include(pe_tpl('package_zc.html'));
		break;
	case 'buy':
		$menumark = 'package';
		$info_list = $db->pe_selectall('product', array('package_id'=>intval($_g_id),'order by'=>'`product_order` asc,`product_id` asc'));
		$banks=unserialize(base64_decode($cache_setting['bank_info']['setting_value']));
		//$action = "user.php?mod=package&act=addsql";
		$seo = pe_seo('购买产品');
		include(pe_tpl('package_buy.html'));
	break;
	case 'show':
	 	$info = $db->pe_select('package', array('package_id'=>$_g_id));
		
		$seo = pe_seo('推广联盟');
		include(pe_tpl('package_tg_show.html'));
	break;
}
?>