<?php
$menumark = 'lesson_list';
switch ($act) {
	//#####################@ 免费课程 @#####################//
	case 'free':
		$menumark = 'lesson_free';
		$info = $db->pe_select('page', array('page_id'=>1));
		
		$seo = pe_seo('免费课程');
		include(pe_tpl('page_view.html'));
	break;
	//#####################@ 课程列表 @#####################//
	case 'list':
		$menumark = 'lesson_vip';
		$cache_package = cache::get('package');
		$cache_category = cache::get('category');
		$cache_category_arr = cache::get('category_arr');
		if($_g_cid){
			if($cache_category[$_g_cid]['vip'] and $user['user_level']!=9){
				$r = $db->pe_select('editsetting', array('name'=>'tip_vip'));
				$tip=$r['content'];
				pe_alert($tip,'user.php');
			}
			if ($user['user_tjnum'] < $cache_category[$_g_cid]['ips']) {
	       			exit('<script>alert("该栏目为vip栏目，推广'.$cache_category[$_g_cid]['ips'].'个积分即可成为vip会员，您的推广积分还未达到'.$cache_category[$_g_cid]['ips'].'个，请继续努力！");window.location.href = "user.php";</script>');
       	 	}
			if($user['tj_user_num']<$cache_category[$_g_cid]['tj_num'])
					exit('<script>alert("你推广的积分质量不高，系统监测，怀疑有作弊嫌疑，请继续努力！");window.location.href = "user.php";</script>');
		}
		//默认显示的第一个套餐
		if (!$_g_package_id) {
			$cache_package_0 = current($cache_package);
			$_g_package_id = $cache_package_0['package_id'];		
		}
		$category_pid_arr = $cache_category_arr[0];
		pe_lead('include/class/categorytree.class.php');
		$class_category = new category();
		if($_g_cid){
			
			//获取子分类数组
			$category_id_arr = $class_category->getcid_arr($cache_category, $_g_cid, $init = 1);
			$category_id_arr[] = $_g_cid;
			//获取顶级分类id
			$category_tid = $class_category->gettid($cache_category, $_g_cid);

			$sqlwhere = " and `category_id` in('".implode("','", (array)$category_id_arr)."')";
			$_g_keyword && $sqlwhere .= " and `lesson_name` like '%".pe_dbhold($_g_keyword)."%'";
			$sqlwhere .= " order by `lesson_state` desc, `lesson_id` desc";
			$info_list = $db->pe_selectall('lesson', $sqlwhere, '*', array(10, $_g_page));
		}
		$seo = pe_seo('网商大学');
		include(pe_tpl('lesson_list.html'));
	break;
	//#####################@ 付费提示 @#####################//
	case 'stop':
		$info = $db->pe_select('package', array('package_id'=>$_g_package_id));
		
		include(pe_tpl('lesson_stop.html'));
	break;
	//#####################@ 课程内容 @#####################//
	default:
		$menumark = 'lesson_vip';
		$lesson_id = intval($_g_id);
		$cache_package = cache::get('package');
		$cache_category = cache::get('category');
		$cache_category_arr = cache::get('category_arr');

		$info = $db->pe_select('lesson', array('lesson_id'=>$lesson_id));
		$info['lesson_down'] = explode(';', trim(htmlspecialchars_decode($info['lesson_down']), ';'));
		$user = $db->pe_select('user', array('user_id'=>$_s_user_id));
		if($cache_category[$info['category_id']]['vip'] and $user['user_level']!=9){
				$r = $db->pe_select('editsetting', array('name'=>'tip_vip'));
				$tip=$r['content'];
				pe_alert($tip,'user.php');
			}
		
		if($user['tj_user_num']<$info['tj_num'])
				exit('<script>alert("你推广的积分质量不高，系统监测，怀疑有作弊嫌疑，请继续努力！");window.location.href = "user.php";</script>');
		/*
		$sql='select count(1) from '.dbpre.'user where user_id_tj='.$_s_user_id;
		$num=$db->sql_num($sql);
		if($num<$info['tj_num'])exit('<script>alert("您的推广注册人数还未达到'.$info['tj_num'].'个，请继续努力！");window.location.href = "user.php";</script>');
		*/
		//获取当前课程所属套餐
		$cache_category = cache::get('category');
		$info['package_id'] = $cache_category[$info['category_id']]['package_id'];
		
		$db->pe_update('lesson', array('lesson_id'=>$lesson_id), array('lesson_clicknum'=>$info['lesson_clicknum']+1));

		$cache_package = cache::get('package');
		$cache_category = cache::get('category');
		$cache_category_arr = cache::get('category_arr');

		$_g_package_id = $info['package_id'];
		$category_pid_arr = $db->pe_selectall('category', array('package_id'=>$_g_package_id, 'category_pid'=>0, 'order by'=>'category_id asc'));
		
		pe_lead('include/class/categorytree.class.php');
		$class_category = new category();
		
		$_g_category_id = $info['category_id'];
		//获取子分类数组
		$category_id_arr = $class_category->getcid_arr($cache_category, $_g_category_id, $init = 1);
		$category_id_arr[] = $_g_category_id;
		//获取顶级分类id
		$category_tid = $class_category->gettid($cache_category, $_g_category_id);


		$seo = pe_seo($info['lesson_name']);
		include(pe_tpl('lesson_view.html'));
	break;
	 pe_seo($info['lesson_name']);
		include(pe_tpl('lesson_view.html'));
	break;
}
pe_result();
?> 