[pmwiki-users] Get referrer page?

H. Fox haganfox at users.sourceforge.net
Mon Jun 5 14:19:41 CDT 2006


On 6/5/06, The Editor <editor at fast.st> wrote:
> I take this to mean there's no simple way to use a page variable or
> something that shows what page in the wiki, the user clicked over
> from.  Rats!  That could have had some creative uses.

Do you need it only for certain specific links?  If so, you might try...

in config.php

   $FmtPV['$ReferPage'] = @$_GET['refer'];

in Group2.Page2

   {$ReferPage}

in Group1.Page1

   [[Group2.Page2?refer={$FullName}]]

Here's a (no doubt inelegant) way to get it from the browser.  Note
that some more error checking should probably be added and, as Jo has
written, whether it works depends on the browser providing the
referrer and that won't always happen.

$http_host = @$_SERVER['HTTP_HOST'];
if (@$_SERVER['HTTP_REFERER']
  && preg_match("!//$http_host!",$_SERVER['HTTP_REFERER']))
{
  $tmp = explode('?', $_SERVER['HTTP_REFERER']);
  $tmp = explode('/', $tmp[0]);
  $tmp = array_slice($tmp, -2);
  if (!empty($tmp[1]))
    $FmtPV['$ReferPage'] = "'".implode('.', $tmp)."'";
}

Hagan

> On 6/5/06, Joachim Durchholz <jo at durchholz.org> wrote:
> > The Editor schrieb:
> > > Is there some way to retrieve the referring group.page in a PmWiki
> > > page?
> >
> > The user's browser is supposed to supply that information (some don't;
> > i.e. don't rely on it for critical things, it may be switched off or
> > even spoofed).
> > If the browser plays nice, PHP will know about it. It might take a
> > recipe to parse that information, check whether it's a referring PmWiki
> > page from the same site, and set up the page variable.
> >
> > Regards,
> > Jo




More information about the pmwiki-users mailing list