 |
Title: Interserver Communications Marked Cool (Review this resource) Author: davidlo Posted On: 2004-12-20 Category: Home > PHP Tutorials
Popularity:
Description: How to let two separated HTTP and PHP systems communicate with each other without using sockets.
Total Hits: 1800 Total Votes: 0
Total Points: 0 (1 reviews)
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.
|
|
 |