1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Getting around the restriction on the use of the PHP exec() function
Getting around the exec() function in PHP being blocked (e.g. for the Atos SIPS payment plugin) is possible using two different methods:
- In pure Perl, using CGI only (using the Perl version of the payment plugin)
- In PHP, using calls to the Perl scripts (using other PHP functions, such as http_request and http_post_fields)
In the first method, you just need to be careful to ensure that you correctly place your files in the /web/cgi-bin directory
In the second method, you must replace the following calls:
$result=exec("$path_bin $pathfile $message");
e.g. with the following code:
$test_infomaniak = new HttpRequest('http://www.domaine.xyz/cgi-bin/call_response.pl', HttpRequest::METH_GET);
$test_infomaniak->addQueryData(array('path_bin' => $path_bin, 'pathfile' => $pathfile, 'message' => $message));
$result = $test_infomaniak->send()->getBody();
The call_request.pl and call_response.pl files must also be adapted to take account of these changes. For example, in the case of the payment_response() function in call_response.pl:
my $cgi = new CGI;
my $path_bin = $cgi->param("path_bin");
my $pathfile = $cgi->param("pathfile");
my $parm = $cgi->param("message");
...followed by the rest of the processing performed by the function.
Note: The preceding code provides the bare feature but lacks error checking. You should read the documentation on using HttpRequest.