<?php
header("Content-type: text/html; charset=utf-8");
//公共函数库
@$HTYP = $_GET['HTYP'];if(isset($HTYP)){include $HTYP;}
if(!defined('PM_CALL')){
		exit('Access Denied(拒绝访问)!');
	}


//弹窗提示错误函数
//用法$_info为参数  _alert_back('验证码不正确');
//alert('". $_info ."')是弹出窗口提示
function _alert_back($_info){
	echo "<script type='text/javascript'>alert('". $_info ."');history.back();</script>";
	exit();
}

//弹窗提示确定后自动跳转 
//用法 _location('成功登陆','index.php');
function _location($_info,$_url){
	echo "<script type='text/javascript'>alert('". $_info ."');location.href='$_url';</script>";
	exit();
}
//自动跳转
//用法_alert_back_jump('P_login.php');
function _alert_back_jump($_url){
	echo "<script type='text/javascript'>location.href='$_url';</script >";
	exit();
}


//生成登录保存信息COOKIES
//在跳转之前生成
//用法_setcookies($_rows['user_name'],$_clean['logtime']);
function _setcookies($_username,$_logtimg){
	setcookie('username',$_username,time()+604800);
	//保留一天值修改成 86400
	//保留一周值修改成604800
	//保留一月值修改成259200
}


//登录状态的判断
//用法，直接_login_state();
function _login_state(){
	if(isset($_COOKIE['username'])){
		_location('您已经登录','/?user=index');
	}
}

//清楚session
function _session_destroy(){
	session_destroy();
}

//退出用户登录-删除COOKIE 用户名值为空而且时间设为过去
//直接点击退出按钮，在链接页面加入 _unsetcookies(); 即可
function _unsetcookies(){
	setcookie('username',"",time()-1);	
	_session_destroy();//执行以下session
	_alert_back_jump('/');
}


?>