Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100 off


PHP Tutorials and Scripts   




Title: Interserver Communications    Marked Cool    (Review this resource)
Author: davidlo
Posted On: 2004-12-20
Category: Home > PHP Tutorials

Popularity: 1 points out of 10    

Description: How to let two separated HTTP and PHP systems communicate with each other without using sockets.

Total Hits: 1532     Total Votes: 0     Total Points: 0 (1 reviews)    

Page Navigation:  [1]  [2]  [3]


Interserver Communications




Part II

Now let's add some very rudimentary authentication in the client.php file:

<?php 
if(!($_GET['user']=="user" && $_GET['password']=="password"))
     exit();
//terminate it on the spot
//if not dead yet, proceed
echo "OK";
?>
 
client.php now expects to receive the username through the 'user' GET variable, and the password through the 'password' GET variable. That means now we must slightly modify the requester.php file
<?php 
$str = file_get_contents("http://server/client.php?user=user&password=password");
echo "Server returned $str"; 
?>
 
If you run it as is, you should still get "Server returned OK". However, if you change the expected variables in client.php or the GET parameters in requester.php, you'll get "Server returned". In other words, $str is blank. If you wanted to, you could replace the exit() code in client.php with die("Authentication failed"), but in my personal opinion you've just alerted a cracker that you have a server/client scheme going on.

Now that we've secured it, we may now actually have the client act upon data passed to it.



Page Navigation:  [1]  [2]  [3]



© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.