NYCPHP Meetup

NYPHP.org

[nycphp-talk] calling another script within php

Nasir Zubair nasir81 at gmail.com
Tue Apr 19 17:50:17 EDT 2005


This is the code I used for interface between CPanel frontend and my
scripts a while ago. The code assumes that you need to login
(.htaccess authentication only) and it assumes you are doing GETs, but
POST isn't too hard to implement either.

Hope it helps.

$domainname = "mydomain.com";
$user		= "loginusername";
$pass		= "loginpass";

$socket = fsockopen($domainname,80);
$authstr = "$user:$pass";
$login = base64_encode($authstr);
$in = "GET /cgi-bin/myscript.cgi\r\n";
$in .= "HTTP/1.0\r\n";
$in .= "Authorization: Basic $login \r\n\r\n";

$results = fputs($socket,$in);

if($socket)
{
	while (!feof($socket))
	{
		$HTML .= fgets ($socket,128);
	}
}

fclose( $socket );
return $HTML;



On 4/19/05, Wai Siow <rs234 at cornell.edu> wrote:
> Hi all:
> 
> I want to call a cgi script with the client's remote address using php...
> which means I am trying to trick the cgi script into thinking that the
> client is the one who requested the cgi script.
> 
> I looked at and tried Pear's HTTP_Request but couldn't get it working,
> what do I need to do to make it work, or is there something else in which
> I can use that'd work?
> 
> Wai (Raymond) Siow
> Web Application Developer / Programmer
> Web Development Team
> Cornell Cooperative Extension
> Email: r s two three four at cornell dot edu
> Phone: (six-o-seven) two-five-five-seven-nine-four-nine
> 
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
> 


-- 
Nasir Zubair
http://www.nasir.us/



More information about the talk mailing list