I have a problem, i was using a PHP class on our shared hosting environment that calls wkhtmltopdf to generate PDF files, due to server attacks the Host disabled proc_open and shell_Exec and all functions that could cause problems if used by an attacker. All was working fine before the Host disabled those functions. In the PHP class that I use there’s the method below that does not work anymore due to the disabling of the proc_open function. Is there any altenative that I could use in the place of the method below that will return the exact results? Any help highly appreciated.
private static function _pipeExec($cmd,$input=''){
$proc=proc_open($cmd,array(0=>array('pipe','r'),1=>array('pipe','w'),2=>array('pipe','w')),$pipes);
fwrite($pipes[0],$input);
fclose($pipes[0]);
$stdout=stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr=stream_get_contents($pipes[2]);
fclose($pipes[2]);
$rtn=proc_close($proc);
return array(
'stdout'=>$stdout,
'stderr'=>$stderr,
'return'=>$rtn
);
}
The
disable_functionssetting can only be changed inphp.iniitself, which means that it’s server wide and applies to ALL sites on a shared host.Here are your options:
You can ask your current hosting provider to move your site to a dedicated machine (or VPS).
Go somewhere else, find a provider that doesn’t have these limitations; this takes some time, but might be worth it.
DIY. Setting up a server is not recommended unless you know what you’re doing, but if you do, then any platform hosting provider will do; nowadays you can run a small dedicated site for about $5,- per month on Amazon.
The last option also buys you the option of “outsourcing” the PDF generation so that the rest of your site still runs on your current host.