[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [gopher] Noob question about Gophernicus and PHP



Kim Holviala <kim@...> writes:

> 
> On Jan 30, 2014, at 13:16, Peter Garner <ipad@...> wrote:
> 
> > I've set up PHP for Gophernicus and have confirmed
> > that I can run a test php script from the command line and
> > I've updated my xinetd.conf to include the -f flag.
> > 
> > However, I need some clarification on how to call a php 
> > script: at the moment my php(-cli) is located in 
> > /usr/lib/gophernicus/filters and I have a helloworld.php in
> > there as well.
> 
> Yeah... the documentation could be a bit better. You should complain
directly to the idiot who wrot.... 
> 
> .... oh, it was me? Then it's just a feature, not a bug :D.
> 
> OK, here's how it works:
> 
> I have "-f /usr/lib/gophernicus/filters" in my gophernicus options. That
makes gophernicus to search
> for "filters" from that directory - filter being an executable which
filters content files into
> something else before sending them to the client.
> 
> My php filter looks like this:
> 
> $ ls -la /usr/lib/gophernicus/filters/php
> lrwxrwxrwx 1 root root 17 Jan 25 15:09 /usr/lib/gophernicus/filters/php ->
../../../bin/php5
> 
> What it means is that all files ending with .php will be filtered through
the ../../../bin/php5 binary (in
> other words, /usr/bin/php5). Since gopher is not html make sure you point
that to the CLI version of php,
> not the CGI version (and it seems that you did). Instead of symlinking you
can also copy the php binary there
> which you seem to have done.
> 
> I then write a simple PHP file and save it as /var/gopher/phpinfo.php:
> 
> <?php
> 	phpinfo();
> ?>
> 
> The end result is here:
> gopher://gophernicus.org/0/phpinfo.php
> 
> The only mistake you made was putting the content into the filter
directory - only filters go to the filter
> directory, php files will live normally anywhere under /var/gopher/. Also
since this is gopher you need
> to make sure to have your filetype in the url (that "0/" above just before
phpinfo).
> 
> - Kim
> 

Perfect - all good now thanks. Yes, please have a word with your 
doc writer ;-)  Here's a quick 'n dirty working script:

<?php
print 'iYou said: ' . $_SERVER["QUERY_STRING"];
?>

and the gophermap:

 -- Test Area - expect things to fail -----------------------------
7Test Thing 1   /Test/q.php     gopher.petergarner.net  70

And now, I'm off to look at PHP's gopher facilities. Thanks for the help!



_______________________________________________
Gopher-Project mailing list
Gopher-Project@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/gopher-project




Reply to: