auth.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
class auth extends client_service {
public function login(){
$params=$this->AuthInfo;
$username=$params['user'];
$passhash=$params['passhash'];
$token=$params['token'];
$app_type=$params['appType'];
$session_id=$params['session'];
$ip=$_SERVER['REMOTE_ADDR'];
$language=isset($params['language'])?$params['language']:'en';
$this->Response->setDebug('parameters',$params);
setcookie("kt_language", $language, 2147483647, '/');
$kt =& $this->KT;
if ($username != 'admin') {
require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php');
if (!BaobabKeyUtil::checkIfLicensed(true)) {
return array('authenticated'=> false, 'message'=> 'license_expired');
}
}
$user=$kt->get_user_object_by_username($username);
if(!PEAR::isError($user)){
$password=$user->getPassword();
$localPassHash=md5($password.$token);
if($localPassHash==$passhash){
$session=new stdClass();
$this->Response->setDebug('trying to start session with',array('username'=>$username,'password'=>$password));
$session = $kt->start_session($username, $params['pass'],NULL,$app_type);
if(!PEAR::isError($session)){
$this->Response->setStatus('session_id',$session->get_session());
}else{
$this->Response->setDebug('failed login',print_r($session,true));
throw new Exception('Unknown Login Error');
return false;
}
}else{
throw new Exception('Incorrect Credentials');
return false;
}
}else{
throw new Exception('Unrecognized User');
return false;
}
return true;
}
public function pickup_session(){
$params=$this->AuthInfo;
$app_type=$params['appType'];
$session_id=$params['session'];
$ip=$_SERVER['REMOTE_ADDR'];
$session = $this->KT->get_active_session($session_id, $ip, $app_type);
if (PEAR::isError($session)){
return false;
}
$this->Response->setStatus('session_id',$session->get_session());
return true;
}
}
?>