<?php

/**
 *      【橙创家校通v4.0】 (C)2010-2012 Tuntron Inc.
 *      
 *    	 http://www.tuntron.com   QQ：1121251729
 *
 *      &登录模块首页&
 */
 
if (!defined('IS_RUN')) die('Forbidden');

switch($c){
	
	case "":
		if(intval($_G['user']['uid']) > 0) Note("请勿重复登录系统！");
		
		location(SITEURL);
		
		break;
	
	//登录
	case "ac":
	if($_G['user'] != '') location(SITEURL);
	
	$loginname= _post('loginname','','trim'); //支持手机号码和家校通账户登录
	
	$pwd = _post('pwd','','trim');
	
	$verifycode= _post('verifycode','','trim'); 
	
	$jumpurl = base64_decode(_post('jumpurl','','trim'));
	
	$cktime = 0; //默认记录登录时间为一天
	
	//if($loginname =='' || $pwd=='') Note("手机号码或密码不能为空！");
	
	$isphonenum = isphonenum($loginname);
	
	if($isphonenum){
		
		//$strUser = $new['user']->find('user',array(
		//	'email'=>$email,
	//	));
		
		//Note("手机登录账户！");
		
	}else{
		
		//Note("登录账户！");
		
	}
		if($_SESSION['LoginError']>=$_G['siteinfo']['SiteVerifyCode']&&strtolower($_SESSION['VerifyCode'])!==strtolower($verifycode)) {
				$_SESSION['VerifyCode']='';
				Note('验证码输入错误！');
			};
		
		$return = G_class('user')->login($loginname, $pwd, $cktime);
		
		if($return=='') {
			session_start();
			$_SESSION['LoginError']=$_SESSION['LoginError']+1;
			Note('用户名或者密码错误！');
		}else{
			$_SESSION['LoginError']='';
		}
		location($jumpurl?$jumpurl:SITEURL);

	break;
	
	//退出
	case "out":
		$jumpurl = _get('jumpurl');
		G_class('user')->logout();
		
		location($jumpurl?SITEURL.'?jumpurl='.$jumpurl:SITEURL);
	
	break;
	
	
}

?>