Jump to content


Photo

Can't post


  • Please log in to reply
6 replies to this topic

#1 Anidazen

Anidazen
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 04 April 2006 - 01:52 PM

Edit: Issues with not being able to post were sorted by removing the php opening and closing tags when I was editing to find out what the problem was. (Using the tags gets you a 406 browser error?) Can a moderator please change the topic title to something more suitable for my problem (ie. "Opening/parsing .CGI output issues") and remove this notice for me please? :)




A script I'm working on requires opening a .CGI file as if it was a user entering data into a search form.

The URL I need to parse is: [a href=\"http://www.bookryanair.com/skylights/cgi-bin/skylights.cgi\" target=\"_blank\"]http://www.bookryanair.com/skylights/cgi-bin/skylights.cgi[/a]



I am having trouble understanding how to open files in this way. I cannot even bring up the page, never-mind send variables to it as a user would.

Here is the code I am using so far -- to be honest, it's compiled from snippets and examples as much as my own knowledge, and very-heavily from the documentation - but in theory this should be working?


I'd be very grateful if someone could let me know where I am going wrong.





$boundary = "---------------------".substr(md5(rand(0,32000)),0,10);

// Build the header
$header = "POST /skylights/cig-bin/skylights.cgi HTTP/1.0\r\n";
$header .= "Host: bookryanair.com \r\n";
$header .= "Content-type: multipart/form-data, boundary=$boundary\r\n";
// attach post vars
foreach($_POST AS $index => $value){
$data .="--$boundary\r\n";
$data .= "Content-Disposition: form-data; name=\"".$index."\"\r\n";
$data .= "\r\n".$value."\r\n";
$data .="--$boundary\r\n";
}


$fp = fsockopen("bookryanair.com", 80);

fputs($fp, $header.$data);
while (!feof($fp)) {
$itemstat .= fread($fp, 1000);
}


echo $itemstat;

#2 Anidazen

Anidazen
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 05 April 2006 - 12:39 AM

Nobody can help me? :(

#3 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,664 posts
  • LocationLos Angeles, CA USA

Posted 05 April 2006 - 02:56 AM

[!--quoteo(post=361788:date=Apr 4 2006, 04:39 PM:name=Anidazen)--][div class=\'quotetop\']QUOTE(Anidazen @ Apr 4 2006, 04:39 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Nobody can help me? :(
[/quote]

Yes, well it's a form, so one common solution to that is to use the CURL library calls.

#4 Anidazen

Anidazen
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 06 April 2006 - 07:55 AM

Ok thankyou. I looked at them myself -- but I need to compile a special version of PHP?

I am using rented webspace, not a dedicated server. How can I find out if this supports cURL?

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 April 2006 - 08:49 AM

To all your servers current configuration state use the phpinfo function. Create a new file called phpinfo.php and put this in it:
<?php

p.hpinfo();
//NOTE: make sure you remove the . between the p and the h

?>
Now save your file and upload this file to your webshot. Now go to www.mysite.com/phpinfo.php

You should no get a big page full of all configuration settinsg for your PHP setup and a few server sided settings too. Now scroll down and see if you can see a big header saying CURL if there is then you have cURL available to you.

#6 Anidazen

Anidazen
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 06 April 2006 - 03:47 PM

Thankyou very much for your help.


CURL looks usable, and similar to file handle functions fopen() etc.

The only thing I just cannot understand is how I can use that to send post or get variables (the ones which you can't just put in the URL). I've read through the documentation and couldn't work it out. :(

#7 Anidazen

Anidazen
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 06 April 2006 - 09:45 PM

Anyone can link me a site or tutorial that will help explain how to pass variables with CURL?

Yes I have read what I could understand in the PHP Docs and other places, but I just don't get it. :(




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users