[imp] other files using horde/imp login mechanism outside of tree

Jan Schneider jan@horde.org
Thu, 24 Jan 2002 19:25:48 +0100


Zitat von Zachary Denison <zacharydenison@yahoo.com>:

> I am trying to make my own pages that use the horde
> login mechanism (which is itself configured to use the
> IMP login mechanism).   When  I create this simple
> hello.php file inside the main horde directory, it
> works fine, as you would expect.  What I would like to
> do, is have php files outside the horde directory use
> the horde login infrastructure.  So as a test I placed
> this hello.php one level up from the horde directory,
> and I modified HORDE_BASE accordingly by appending a
> /horde to it.   For some reason now, it authenticates
> properly but cannot find the hello.php page to
> redirect to.  Does anyone know why this might be.   I
> would like to create many directories and
> subdirectories on my site, and have all the php files
> use the horde / imp login mechanism site wide.
> 
> I should also let you know I have the php include_path
> set to the current directory, the horde directory, the
> imp directory, and both lib directories.

That's not necessary if build correct include statements. The Horde 
files "find" each other without the include_path being set.

> <?  
> // this file is hello.php
> 
> define('HORDE_BASE', dirname(__FILE__) . "/horde/");
> require_once(HORDE_BASE . '/lib/base.php');
> 
> $user=Auth::getAuth();
> 
> if($user){
>          print "Hello $user";
> } else {
>          header( 'Location: ' .
> Horde::applicationUrl("login.php?url=hello.php", true)
>   );
>          exit;
> }
> ?>

Horde::applicationUrl() is the problem. It builds the complete path based 
on the webroot of the current application. As you didn't build a complete 
horde module that registers itself with $registry->pushApp('HelloWorld'), 
applicationUrl() thinks you're still in the application Horde, thus 
searching for hello.php in the Horde directory (defined in registry.php). 
You should use Horde::url() instead and build the correct path on your own.

Jan.

--
::::::::::::::::::::::::::::::::::::::::
AMMMa AG - discover your knowledge
:::::::::::::::::::::::::::
Detmolder Str. 25-33 :: D-33604 Bielefeld
fon +49.521.96878-0 :: fax  +49.521.96878-20
http://www.ammma.de
::::::::::::::::::::::::::::::::::::::::::::::