[Clipart] shell.php

Jonadab the Unsightly One jonadab at bright.net
Thu Dec 30 17:34:09 PST 2004


Jon Phillips <jon at rejon.org> writes:

> <?php
>      $site_root = '';
>      include $site_root . "includes/header.php";
> ?>
> 
> $CONTENT$
> 
> <?php include $site_root . "includes/footer.php"; ?>

The problem may be in the files it includes, then.

It isn't just my scripts that have this problem; it happens to the
browse script (which I think is called navigate) also.  In short,
anything outside the root directory gets these broken links, if it
uses shell.php

> So, Jonadab, is your script just scraping the webpage after it has
> been served by apache?

Yes.  I think all of the Perl scripts are doing that currently, except
for the ones (such as the wiki) that don't include its contents at all.

> I think there should be a cleaner and more efficient solution than
> this. 

Yeah, but I don't know anything at all about PHP, and this is the
method that was suggested to me initially, and I went with it.  If you
know a way to get the PHP script's output without going through
Apache, I'd be pleased to make that adjustment.  (If nothing else, it
would probably improve performance significantly.)

> Here is one solution:
>
> <?php virtual ("../path/to/script.cgi"); ?>

That's backwards from what we need to do.  I don't know enough about
PHP to know if it's even possible to execute a PHP script without
going through Apache, but if so, I'd do that.  I doubt very much
whether it would solve this problem, though.  Fundamentally, whatever
hoops we're jumping through, we *are* getting the PHP script's output
and using it; it is that output that contains the broken links.

> Otherwise, we could make shell.php insert some $SITE_ROOT$ into all
> site-relative links that you could then replace with your script.

I'm confused as to why shell.php considers the site root to be the
current directory, rather than the site root directory, but
fundamentally I don't know enough PHP to understand what's going on.

For example, when the PHP code has stuff like this:

<a href="<?php echo $site_root_menu; ?>status/index.php">1702 Clips + 8 artists

I get lost there.  $site_root_menu is presumably a variable.  (Is it
just being interpolated there, or what?  That seems like horribly
verbose and overwrought syntax for mere interpolation...)  I looked
for where it's assigned, but...

if ( isset($_GET['site_root_menu']) ) {
    $site_root_menu = $_GET['site_root_menu'];
} else {
    $site_root_menu = $site_root;
}

Now I'm thoroughly lost.  I understand the if/else construct, of
course, but I don't see where the isset function is defined.  (Is that
a function?  It looks like a function call there.  Maybe it's a
builtin?  What does it do?  Test for definedness?  That's a wild
guess.)  Also, I have *absolutely* no clue what the $_GET['foo']
syntax means.  I could take potshot guesses, but they'd be pretty
arbitrary:  it could be another kind of function call, possibly one
that dereferences a variable and calls the closure it holds, with the
single-quoted string as an argument.  But I don't see where the
variable $_GET is assigned a coderef, so probably not.  Or it could be
some kind of lookup, in an alist or hash or whatnot, except that I
don't see where the variable $_GET is assigned any such data
structure, so probably not.  My best guess is that it's some peculiar
PHP syntactic sugar for who only knows what.  Could be related to the
the GET CGI method, perhaps, but the PHP people were last I checked
still holding onto their assertion that PHP is "not CGI, better than
CGI", so I doubt they'd use standard CGI terminology in that way.
Even if it were, that doesn't really tell me what it does.

You can now see why I have not attempted to fix this problem.  I don't
have the necessary background knowledge.  The only programming
languages I'm really fluent in are Perl, Inform, and elisp.  (I used
to say BASIC also, but it's been a long time now...)

-- 
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,"ten.thgirb\@badanoj$/ --";$\=$ ;-> ();print$/




More information about the clipart mailing list