PHP -> PHP Communication Function

This function is used to communicate with a PHP script on another webserver.

function export($addr, $extra_dir, $get_data = '')
{
        if(!$addr) error('export(), ' . __LINE__ . ': No server address provided');
        $fp = fsockopen($addr, 80);
        if(isset($get_data) && !is_null($get_data)) $extra_dir .= "?{$get_data}";
        if($fp)
        {
                $out = "GET /{$extra_dir} HTTP/1.1\r\n";
                $out .= "Host: {$addr}\r\n";
                $out .= "Connection: Close\r\n\r\n";
                fwrite($fp, $out);
                fclose($fp);
        }
}


$addr is a simple subdomain + domain.
$extra_dir is any directories added on to the domain.
$get_data is any GET data you'd like to pass.

Example:

I have a script at http://www.sineful.com/my_scripts/script.php, and I want to pass it "action=reload&data=1"

export('www.sineful.com', 'my_scripts/script.php', 'action=reload&data=1');

Posted by Audeuro (Guildmaster) on Friday, July 27, 2007 11:03PM - 0 comments / Members say: yea +0, nay -0
(Edited on Thursday, September 20, 2007 08:13PM)

« PHP -> DM Communication Function · hub_get_contents() »

Login to post a comment.

PHP

Joined: Jul 27, 07

Blog Calendar

July 2007
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
 
  Dec»