I'm new to PHP and was given a code snippet that looks like this:
{
$DB = new DB('xxxxxx','oooooo','gggggg');
$return_result = false;
$this->clear_data();
$m = new xmlrpcmsg(
'ldapxml.authorize'
, array(
new xmlrpcval($user_name, "string")
, new xmlrpcval($password, "string")
)
);
// this is just a temp server for now
$c = new xmlrpc_client(XMLRPC_CLIENT_PATH, XMLRPC_CLIENT_SERVER, XMLRPC_CLIENT_PORT);
$c->return_type = 'phpvals';
$r = $c->send($m);
if ( !$r->faultCode() )
{
$v = $r->value();
if ( $v )
{
$return_result = true;
$this->put('username', $user_name);
$this->put('IP', $_SERVER['REMOTE_ADDR']);
$this->put($this->_valid_session_flag, 1);
// grab the users info
$m = new xmlrpcmsg(
'ldapxml.getAttibutes'
, array(
new xmlrpcval($user_name, "string")
, new xmlrpcval($password, "string")
)
);
$query = "SELECT email FROM auth WHERE email = '".$email."'";
$result = mydb::cxn()->query($query);
if ($result != $user_name)
{
echo '<p style="color: red;">There was an error logging in...</p>';
}
$c = new xmlrpc_client(XMLRPC_CLIENT_PATH, XMLRPC_CLIENT_SERVER, XMLRPC_CLIENT_PORT);
$c->return_type = 'phpvals';
$r = $c->send($m);
if ( !$r->faultCode() )
{
$v = $r->value();
if ( $v )
{
$this->put('title', $v['title']);
$this->put('email', $v['mail']);
}
}
//}
}
else {
echo '<p style="color: red;">There was an error logging in...</p>';
}
}
return $return_result
What does this code do? Can someone break it down for me, line by line and helpt me wrap my head around it? Will it work?