Cannot execute lynx in safe mode
My implementation of the pseudo-code for expiredpagehandler.php4 hasn't been working, and it's taken me a while to figure what's going wrong. Basically, I can't get the script to invoke lynx. I tried using exec, but I got an error message indicating that it couldn't find lynx. I managed to discover the path to the lynx program using the which command, so I then tried exec again with the full path, like this:
exec ("/usr/local/bin/lynx -dump $url");
Still no joy; the error message indicated that lynx couldn't be found.
I looked for an alternative, and discovered shell_exec. Still no joy, but this gave me a much more helpful error message implying (I think) that the script wasn't allowed to invoke lynx because it was being executed in safe mode. I suppose the system has been configured so that all php scripts execute in safe mode at LSBU. Hmmm!
Then it occurred to me to try using the fpassthru function. I tried this...
$handle = fopen($url, "r"); fpassthru($handle); fclose($handle);...in place of the single line of code which attempted to invoke
lynx. It worked, but the url that got recorded in the ExpiryData.xml file was the url of my php script rather than the url of the web page it had "hit". Hmmm!
Note from Mike C. (25-Aug-2006)
"Yes safemode forbids launching other programs. It's the same problem we had with file creation. But we are able to turn off safemode ourselves, by including a php.ini file which does so, in the same directory as the script lives."