ILIAS
release_4-3 Revision
◀ ilDoc Overview
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Groups
Pages
PEAR.php
Go to the documentation of this file.
1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
3
29
require_once
'HTTP/Client.php'
;
33
require_once
'Auth/Container.php'
;
34
57
class
Auth_Container_Pear
extends
Auth_Container
58
{
59
// {{{ properties
60
66
var
$url
=
'https://pear.php.net/rest-login.php/'
;
67
75
var
$karma
= array();
76
77
// }}}
78
// {{{ Auth_Container_Pear() [constructor]
79
89
function
Auth_Container_Pear
(
$data
= null)
90
{
91
if
(!is_array(
$data
)) {
92
PEAR::raiseError
(
'The options for Auth_Container_Pear must be an array'
);
93
}
94
if
(isset(
$data
[
'karma'
])) {
95
if
(is_array(
$data
[
'karma'
])) {
96
$this->karma =
$data
[
'karma'
];
97
}
else
{
98
$this->karma = array(
$data
[
'karma'
]);
99
}
100
}
101
102
if
(isset(
$data
[
'url'
])) {
103
$this->url =
$data
[
'url'
];
104
}
105
}
106
107
// }}}
108
// {{{ fetchData()
109
120
function
fetchData
($username, $password)
121
{
122
$this->
log
(
'Auth_Container_PEAR::fetchData() called.'
,
AUTH_LOG_DEBUG
);
123
124
$client
=
new
HTTP_Client;
125
126
$this->
log
(
'Auth_Container_PEAR::fetchData() getting salt.'
,
AUTH_LOG_DEBUG
);
127
$code =
$client
->get($this->url .
'/getsalt'
);
128
if
($code != 200) {
129
return
PEAR::raiseError
(
'Bad response to salt request.'
, $code);
130
}
131
$resp =
$client
->currentResponse();
132
$salt = $resp[
'body'
];
133
134
$this->
log
(
'Auth_Container_PEAR::fetchData() calling validate.'
,
AUTH_LOG_DEBUG
);
135
$postOptions = array(
136
'username'
=> $username,
137
'password'
=> md5($salt . md5($password))
138
);
139
if
(is_array($this->karma) && count($this->karma) > 0) {
140
$postOptions[
'karma'
] = implode(
','
, $this->karma);
141
}
142
143
$code =
$client
->post($this->url .
'/validate'
, $postOptions);
144
if
($code != 200) {
145
return
PEAR::raiseError
(
'Bad response to validate request.'
, $code);
146
}
147
$resp =
$client
->currentResponse();
148
149
list($code, $message) = explode(
' '
, $resp[
'body'
], 1);
150
if
($code != 8) {
151
return
PEAR::raiseError
($message, $code);
152
}
153
return
true
;
154
}
155
156
// }}}
157
158
}
159
?>
Services
PEAR
lib
Auth
Container
PEAR.php
Generated on Sat Apr 30 2016 19:01:09 for ILIAS by
1.8.1.2 (using
Doxyfile
)