Hi there again

I'm installing a PayBox payment system on a shared hosting and i can't use shell_exec() to send the vars to the cgi module.

the only possiblity i have is to send the vars as POST vars but i obviously don't want to put them in hidden form fields in the page as it would be a huge security hole

so i was thinking i could make a sort of processing page that would format the vars as POST vars and then send them to teh cgi module without actually displaying a page - but i can't figure out how to do this, or even if it's possible

has anyone ever done this before (send POST vars without using a form) ??

thanks

    that looks promising

    I'm not too sure about the requirements, though

    on my hosting when i do phpinfo() I get

    CURL support enabled
    CURL Information libcurl/7.15.5 OpenSSL/0.9.8c zlib/1.2.3 libidn/0.6.5

    I assume if they've enabled CURL support then i would be able to use it no problem

    does that set-up look ok to you ?

      Looks OK to me, though I wouldn't bet the house and farm on it until I saw it actually work. 😉 But I've seen very few (if any?) web hosts that do not have it enabled.

        I've been looking at a cURL tutorial that suggests using this code :

        				 
        $cmd = "../../cgi-bin/modulev2.cgi $PBX";
        echo $cmd;
        
        $curlPost = urlencode($cmd);
        $ch = curl_init();
        
        curl_setopt($ch, CURLOPT_URL, '../../cgi-bin/modulev2.cgi');
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 0);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
        $data = curl_exec($ch);
        echo $data;
        curl_close($ch);

        I'm trying to simulate this form

        echo "<form name=\"form\" id=\"form\" action=\"../../cgi-bin/modulev2.cgi\" method=\"post\">\n";
        echo "<input type=\"hidden\" name=\"PBX_MODE\" value=\"1\"> <!-- passage par formulaire --><br>\n";
        echo "<input type=\"hidden\" name=\"PBX_SITE\" value=\"".$PBX_SITE."\"> <br>\n";
        echo "<input type=\"hidden\" name=\"PBX_RANG\" value=\"".$PBX_RANG."\"> <br>\n";
        echo "<input type=\"hidden\" name=\"PBX_IDENTIFIANT\" value=\"".$PBX_IDENTIFIANT."\"><br>\n";
        echo "<input type=\"hidden\" name=\"PBX_TOTAL\" value=\"".$PBX_TOTAL."\"> <br>\n";
        echo "<input type=\"hidden\" name=\"PBX_DEVISE\" value=\"".$PBX_DEVISE."\"> <br>\n";
        echo "<input type=\"hidden\" name=\"PBX_CMD\" value=\"".$PBX_CMD."\"> <br>\n";
        echo "<input type=\"hidden\" name=\"PBX_PORTEUR\" value=\"".$PBX_PORTEUR."\"> <br>\n";
        echo "<input type=\"hidden\" name=\"PBX_RETOUR\" value=\"".$PBX_RETOUR."\"> <br>\n";
        echo "<input type=\"hidden\" name=\"PBX_EFFECTUE\" value=\"".$PBX_EFFECTUE."\"> <br>\n";
        echo "<input type=\"hidden\" name=\"PBX_REFUSE\" value=\"".$PBX_REFUSE."\"> <br>\n";
        echo "<input type=\"hidden\" name=\"PBX_ANNULE\" value=\"".$PBX_ANNULE."\"><br>\n";
        echo "<input type=\"hidden\" name=\"PBX_TXT\" value=\"".$PBX_TXT."\"><br>\n";
        echo "<input type=\"hidden\" name=\"PBX_WAIT\" value=\"".$PBX_WAIT."\"><br>\n";
        echo "<input type=\"hidden\" name=\"PBX_BOUTPI\" value=\"".$PBX_BOUTPI."\"><br>\n";
        echo "<input type=\"hidden\" name=\"PBX_BKGD\" value=\"".$PBX_BKGD."\"><br>\n";
        echo "<input type=\"hidden\" name=\"PBX_LANGUE\" value=\"".$PBX_LANGUE."\"><br>\n";
        echo "<input type=\"hidden\" name=\"PBX_ERREUR\" value=\"".$PBX_ERREUR."\"><br>\n";
        echo "<input type=\"hidden\" name=\"PBX_TYPECARTE\" value=\"".$PBX_TYPECARTE."\"><br>\n";
        //echo "<input type=\"submit\" name=\"bouton_paiement\" value=\"paiement\"> <br>\n";
        echo "</form>\n";

        what is supposed to happen is that the cgi module gets the vars and then sends the user on into the payment pages on the payment server

        here, however, nothing happens and i get this output in the $data variable

        HTTP/1.1 200 OK Date: Wed, 02 Apr 2008 14:29:35 GMT Server: Apache X-Powered-By: PHP/4.4.8 Vary: Host Transfer-Encoding: chunked Content-Type: text/html

        have i not understood something ?

          You need to build your post data into a string just like you would for a URL query string:

          $curlPost  = "PBX_MODE=1" .
                       "&PBX_SITE=" . urlencode($PBX_SITE) .
                       "&PBX_RANG=" . urlencode($PBX_RANG) .
                       // etc. for rest of fields...
                       "&PBX_TYPECARTE=" . urlencode($PBX_TYPECARTE);
          
          // then use the above string as your value for the CURLOPT_POSTFIELDS:
          curl_setopt($ch, CURLOPT_POST, 0);  // this must precede the following line
          curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
          

            i forgot to put that in - in my code the $PBX variable is set up like this

            $PBX = "PBX_MODE=".$PBX_MODE." PBX_SITE=".$PBX_SITE." PBX_RANG=".$PBX_RANG." PBX_IDENTIFIANT=".$PBX_IDENTIFIANT." PBX_WAIT=".$PBX_WAIT." PBX_TXT=".$PBX_TXT." PBX_BOUTPI=".$PBX_BOUTPI." PBX_BKGD=".$PBX_BKGD." PBX_TOTAL=".$PBX_TOTAL." PBX_DEVISE=".$PBX_DEVISE." PBX_CMD=".$PBX_CMD." PBX_PORTEUR=".$PBX_PORTEUR." PBX_EFFECTUE=".$PBX_EFFECTUE." PBX_REFUSE=".$PBX_REFUSE." PBX_ANNULE=".$PBX_ANNULE." PBX_ERREUR=".$PBX_ERREUR." PBX_RETOUR=".$PBX_RETOUR;
            
            $cmd = "../../cgi-bin/modulev2.cgi $PBX";
            echo $cmd;
            $curlPost = urlencode($cmd);
            
            

            and when i echo the $cmd it all looks ok

              oh i didn't notice the "&" between the vars !

                IT WORKS ! woohoo wahaaaaaa !!

                this has been doing my head in for nearly a week !!!

                many thanks for helping me with this 🙂 🙂 🙂

                  2 years later

                  Hello All,

                  I am trying to setup Paybox in windows vista. I am calling a cgi script one form like below.

                  <FORM ACTION='/paybox/cgi-bin/modulev2.cgi' METHOD="post">
                    <INPUT TYPE="hidden" NAME="PBX_MODE"  VALUE = '1'>
                    <INPUT TYPE="hidden" NAME= "PBX_SITE"  VALUE = '1999888'>
                    <INPUT TYPE="hidden" NAME= "PBX_RANG"  VALUE = '99'>
                    <INPUT TYPE="hidden" NAME= "PBX_IDENTIFIANT"  VALUE = '2'>
                    <INPUT TYPE="hidden" NAME= "PBX_TOTAL"  VALUE = '1500'>
                    <INPUT TYPE="hidden" NAME= "PBX_DEVISE"  VALUE = '978'>
                    <INPUT TYPE="hidden" NAME= "PBX_CMD"  VALUE = 'ma_reference_123456'>
                    <INPUT TYPE="hidden" NAME= "PBX_PORTEUR"  VALUE = 'client@test.com'>
                    <INPUT TYPE="hidden" NAME= "PBX_RETOUR"  VALUE = 'montant:M;ref:R;auto:A;trans:T'>
                    <INPUT TYPE="hidden" NAME= "PBX_EFFECTUE"  VALUE = 'http://localhost/paybox/response.php'>
                    <INPUT TYPE="hidden" NAME= "PBX_REFUSE"  VALUE = 'http://localhost/paybox/response.php'>
                    <INPUT TYPE="hidden" NAME= "PBX_ANNULE"  VALUE = 'http://localhost/paybox/response.php'>
                    <INPUT TYPE="submit" NAME= "bouton_paiement"  VALUE = 'Paiement'>
                  </FORM>

                  But it's giving me an error like "500 Internal server error"

                  I am not able to resolve the issue.

                  Please let me know if you face same problem while calling a cgi script directly in form or install Paybox....

                  Thanks in advance....

                  Regards,
                  Paresh

                    a year later

                    SteamPunk, j'ai besoin de votre aide.
                    Je ne parviens pas &#224; installer mon module paybox avec php et la commance shell_exec()
                    Avez vous un exemple de code entier pour me sauver?
                    Au secour !
                    chh(at)dit(point)fr

                      Write a Reply...