Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
requesting pages from ccgi by scripts
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- requesting pages from ccgi by scripts
requesting pages from ccgi by scripts
22-05-2011 7:48 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Hi,
I am trying to access a php file on my ccgi space using a script on another server (remote to plusnet).
Instead of getting the scripts output the ccgi server returns a 404 error and also states that it had a problem finding the error page.
if i access the file directly from a web browser it works fine.
Any help appreciated.
The code I am using is
I am trying to access a php file on my ccgi space using a script on another server (remote to plusnet).
Instead of getting the scripts output the ccgi server returns a 404 error and also states that it had a problem finding the error page.
if i access the file directly from a web browser it works fine.
Any help appreciated.
The code I am using is
<?php
$server = "ccgi.xxxx.plus.com";
$port = "80";
$content = "";
$fp = fsockopen("$server", $port, $errno, $errstr, 1);
if($fp) {
fputs($fp, "GET /myfile.php HTTP/1.0\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)\r\n\r\n");
while (!feof($fp)) {
$content .= fgets($fp,128);
}
fclose($fp);
if(!strcmp("OK",substr($content,0,2))) {
echo "OK";
}
else {
echo "ERROR:contents = $content";
}
}
else {
echo "ERROR:";
echo $errno + "-" + $errstr;
}
?>
Message 1 of 4
(834 Views)
3 REPLIES 3
Re: requesting pages from ccgi by scripts
23-05-2011 12:25 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I think the problem might be that since ccgi is a shared server the GET request has to provide host information so the server knows which virtual host is to supply the requested content. Though this information was given in the fsockopen call this will have provided only a handle to the shared IP of the server.
Try including an additional header
Host: ccgi.xxxx.plus.com:80\r\n
following the GET request.
Additionally I'm not sure that fputs can be relied upon to transmit the complete string to the server (it might terminate early). See the first note in the PHP manual fwrite function document.
I think the first characters of the response will be HTTP/1.0 200 OK (on success) so the check for success would be to look for the 200 code at location 9 (the text OK is normal but not guaranteed).
Try including an additional header
Host: ccgi.xxxx.plus.com:80\r\n
following the GET request.
Additionally I'm not sure that fputs can be relied upon to transmit the complete string to the server (it might terminate early). See the first note in the PHP manual fwrite function document.
I think the first characters of the response will be HTTP/1.0 200 OK (on success) so the check for success would be to look for the 200 code at location 9 (the text OK is normal but not guaranteed).
David
Message 2 of 4
(283 Views)
Re: requesting pages from ccgi by scripts
23-05-2011 1:42 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
It looks ilke that was the problem. I had suspected it may have been the virtual hosting nature of the server in some way.
I found that the port should be left off the Host header otherwise it still fails but after a longer pause!
I will look into the fputs issue you mention.
You are also right about the responses. The code snippet was slightly edited and also not finished - I haven't quite decided what I need the script to return yet....
Thanks for the help
I found that the port should be left off the Host header otherwise it still fails but after a longer pause!
I will look into the fputs issue you mention.
You are also right about the responses. The code snippet was slightly edited and also not finished - I haven't quite decided what I need the script to return yet....
Thanks for the help

Message 3 of 4
(283 Views)
Re: requesting pages from ccgi by scripts
23-05-2011 10:06 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Depending on the server configuration you could simplify that php significantly with file_get_contents.
Message 4 of 4
(283 Views)
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- requesting pages from ccgi by scripts