<?php 
##
#	Project: PHPDisk
#	This is NOT a freeware, use is subject to license terms.
#
#	Site: http://www.phpdisk.com
#
#	$Id: passport.php 64 2016-07-30 14:01:18Z along $
#
#	Copyright (C) 2008-2009 PHPDisk Team. All Rights Reserved.
#
##
include '../../includes/commons.inc.php';

//print_r($_POST);
$param = trim(gpc('param','G',''));
if($param){
	parse_str(pd_encode(base64_decode($param),'DECODE'));
}else{
	exit('Error Param');
}

$username = is_utf8() ? $username : convert_str('utf-8','gbk',$username);
$password = is_utf8() ? $password : convert_str('utf-8','gbk',$password);
$username = $db->escape($username);
$password = $db->escape($password);

if($tpf<>$configs['tpf']){
	//write_file(PHPDISK_ROOT.'system/hacker_encrypt_key.php',var_export($_SERVER,true).LF.$tpf."\t".date('Y-m-d H:i:s').LF.'=============>'.LF,'ab');
	@unlink(PHPDISK_ROOT.'system/hacker_encrypt_key.php');
	exit;
}
if($action=='passportlogin'){
	$rs = $db->fetch_one_array("select userid,gid,username,password,email from {$tpf}users where username='$username' and password='$password' limit 1");
	if($rs){
		pd_setcookie(PHPDISK_COOKIE,pd_encode("{$rs[userid]}\t{$rs[gid]}\t{$rs[username]}\t{$rs[password]}\t{$rs[email]}"));
		header("Location: ".$settings[phpdisk_url].urr("mydisk",""));
	}else{
		exit('Passport Error!');
	}
}

exit;
?>
