Hi,
I've been working on an XML-RPC server & client just for the fun of it. Well, I wanted to write an IP check function where the server retrives the IP forwarded by the client... Well, it turns out its being more of a problem that I had thought to put in effect.
Heres the server code:
<?php
function server_checkip($method_name,$params,$app_data)
{
$IP = $params[0];
If ($IP == "127.0.0.1")
{
return "$IP has been allowed by the server!";
} else {
return "$IP has been denied by the server!";
}
}
?>
And... Heres the client code!
<?php
$IP = $REMOTE_ADDR;
$results = xu_rpc_http_concise(
array(
'method' => "ipcheck",
'args' => array($IP),
'host' => $host,
'uri' => $uri,
'port' => 80
)
);
print $results;
?>
Can anyone tell me what I'm doing wrong, and an code example of what I need to do, to get this working?
Much Appreciated,
Aric Holland
XML-RPC Server Side Code Problem...
Moderator: General Moderators
-
Aric_Holland
- Forum Newbie
- Posts: 5
- Joined: Sat Aug 09, 2008 6:23 pm
- Location: Maui, HI
- lukewilkins
- Forum Commoner
- Posts: 55
- Joined: Tue Aug 12, 2008 2:42 pm
Re: XML-RPC Server Side Code Problem...
So at this time you are unable to get it to pass the client IP address? This is because 'REMOTE_ADDR' is stored within the $_SERVER predefined variables.
Replace
$IP = $REMOTE_ADDR;
with
$IP = $_SERVER['REMOTE_ADDR'];
As well, why are you putting the IP in to an array in your xu_rpc_http_concise() function?
Hope that helps, let me know if I completely misunderstood what you were asking.
Luke
Replace
$IP = $REMOTE_ADDR;
with
$IP = $_SERVER['REMOTE_ADDR'];
As well, why are you putting the IP in to an array in your xu_rpc_http_concise() function?
Hope that helps, let me know if I completely misunderstood what you were asking.
Luke