UseModWiki | RecentChanges | Preferences

i have access to a web server that will allow me to run php but not cgi. However, the php is not run in "safe mode", which mean i can call other programs from within php. i wrote a wrapper to allow me to run cgi programs by setting up some of the cgi environment. -- [BayleShanks]

http://rescomp.stanford.edu/~bshanks/wrap_cgi_php/wrap_cgi_php (try [this] untested one if you only have php3)

disclaimers: i don't know php or cgi. the wrapper adds a second or two to each page access (i think the extra time is a fixed cost, rather than slowness which will get longer the more computation is needed by the cgi). it probably has bugs. it does not support ISINDEX. it has only been tested a few times by myself. it is probably better just to get cgi to work on your server.


a 2 page piece of code hardly deserves to be licenced, but i'm releasing it under the GPL licence anyhow. so no selling stuff, guys :)

You seem to misunderstand the GPL. The GPL allows selling stuff and you cannot forbid it.[1] -- AKF

instructions for use with UseMod:

1) download the program. store it in the same folder as wiki.pl. rename it so that it has the extension ".php" (or maybe .php3 or .php_something_else?). you can rename the wrap_cgi_php part, too, if you want (i called it "wiki.php").

2) copy the UseMod config file to the same directory as the wikidb, if you haven't done so already. now change the config option "$FullUrl" to the full url of the wrap_php_cgi.php script.

explanation: the underlying perl script needs to know that it should direct the user to ask for the php wrapper rather than for the cgi. In other words, all user URLs should say wrap_cgi_php.php, not wiki.pl. The user will request wrap_cgi_php.php, and wrap_cgi_php.php then calls wiki.pl.


beats me. if you are having problems with redirects, you might try changing the UseMod config option "RedirType" to 2. you can post a question on this page or you can email me at bshanks2@nospam.com (yahoo, i mean).

The wrapper currently has a bug that occurs if a backslash is ever in any page. When you save edited text containing backslashes, the backslashes are each doubled! This quickly gets out of hand, as you can imagine. Since I only use the script for my homepage and a few other things, I haven't needed to/bothered to fix this yet.

Anybody got a fix for that by now? Eg. quotation marks get escaped via backslash as well and they appear in the text as in \".

instructions for use with other cgi programs

1) change the value of the variable "$cgi_script" at the top of wrap_cgi_php.php to the filename of the cgi that you want to execute.

2) you may need to do something analogous to step (2) for the UseMod case. Here are some ideas:

    a) you could edit the source of your cgi program to tell it to direct the user to wrap_cgi_php.php instead of the name of the cgi itself.
       (or, if it's cool like UseMod, maybe there's a config option)

   b) you could rename wrap_cgi_php.cgi to whatever the cgi script thinks its name is (in the UseMod case, that would be wiki.pl).
      call the cgi script something else (and point to the real cgi script with $cgi_script inside the disguised wrap_cgi_php.php)

    c) you could change wrap_cgi_php.cgi so that it scans the outgoing html for instances of the filename of the underlying cgi script,
       and then replaces those with the filename of wrap_cgi_php.php. There is already a function in wrap_cgi_php.php that gets to look
       at and change anything in the outgoing http and html right before it gets sent ("ob_handle"). You could put it there.

All possible links here are dead. Where can I find a working script, or get more information about how to "wrap" cgi or perl in php? (On some of my providers servers theres php but not perl, so Im very interested in this solution . :) DanKoehl

http://rescomp.stanford.edu/~bshanks/wrap_cgi_php/wrap_cgi_php is not dead -- BayleShanks

UseModWiki | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited April 26, 2010 12:16 pm by AKF (diff)