ILIAS
release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
◀ ilDoc Overview
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
?>
Auth_Container
Definition:
Container.php:39
Auth_Container_Pear
Definition:
PEAR.php:57
$code
$code
Definition:
example_050.php:99
AUTH_LOG_DEBUG
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition:
Auth.php:59
$client
$client
Definition:
cfg.loadtest.template.php:22
$data
$data
Definition:
example_011.php:126
PEAR\raiseError
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
This method is a wrapper that returns an instance of the configured error class with this object's de...
Definition:
PEAR.php:524
Auth_Container\log
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition:
Container.php:246
Auth_Container_Pear\$karma
$karma
Definition:
PEAR.php:75
Auth_Container_Pear\$url
$url
Definition:
PEAR.php:66
Auth_Container_Pear\Auth_Container_Pear
Auth_Container_Pear($data=null)
Constructor.
Definition:
PEAR.php:89
Auth_Container_Pear\fetchData
fetchData($username, $password)
Get user information from pear.php.net.
Definition:
PEAR.php:120
Services
PEAR
lib
Auth
Container
PEAR.php
Generated on Wed Aug 27 2025 19:01:00 for ILIAS by
1.8.13 (using
Doxyfile
)