English 中文(简体)
Can I used Joomla s authentication system to allow/prevent access to a standalone script?
原标题:
  • 时间:2009-12-21 18:51:52
  •  标签:
  • joomla1.5

We ve developed a few standalone php scripts and want to limit access to them. We use Joomla 1.5 as our main front end and I m wondering if we can use the authentication from Joomla to determine if a user is logged in or not from within our application which is outside the Joomla framework. If we can avoid integrating the joomla framework into our code, it would be preferred.

Not being an expert on Joomla s authentication system, does anyone have any idea to tell whether a user is logged in or not? I assume we would look at the session id and then use that to do a database query to see who the user is and if they re logged in?

问题回答

There are some tools found at :

http://extensions.joomla.org/extensions/access-a-security/authentication-external

Which should be able to answer your question. From LDAP to NDIS, there are a variety of ways to make this happen.

This is late in the game, but in case someone else needs it.: You can access most of the Joomla Envrionment quite easily:

  1. Create a joomla platform file to include as shown below:
  2. Include that file in your script

yourscript.php

require_once( joomla_platform.php );
$user =& JFactory::getUser();
if($user->gid <25) {
    die ("YOU CANT BE HERE");
}

joomla_platform.php

<?php
    /* Force Debugging here, otherwise the loaded configuration will define it. */
    define(  JDEBUG , 1 );
    /* If not already done, initialize Joomla framework */
    if (!defined( _JEXEC )) {
        define(  _JEXEC , 1 );
        //        define( JPATH_BASE , dirname(__FILE__) );
        define ( JPATH_BASE , "c:\wamp\www\hosted\newday");
        define(  DS , DIRECTORY_SEPARATOR );
        /* Required Files */
        require_once ( JPATH_BASE .DS. includes .DS. defines.php  );
        require_once ( JPATH_BASE .DS. includes .DS. framework.php  );
        /* To use Joomla s Database Class */
        require_once ( JPATH_BASE .DS. libraries .DS. joomla .DS. factory.php  );
        require_once ( JPATH_LIBRARIES.DS. joomla .DS. import.php ); // Joomla library imports.
        /* Create the Application */
        global $mainframe;
        $mainframe =& JFactory::getApplication( site );

        global $mainframe;
    }
/*    $config = new JConfig(); */
/*    $db = &JFactory::getDBO(); */
?>




相关问题
My Joomla site got hacked. Is database also corrupted?

The only php page that I see with the code is the index.php, so I replace it with a backup and everyday I see it change to: Parse error: syntax error, unexpected < in /nfs/c05/h02/mnt/73056/...

menu with section title and description in joomla

I need to create a menu with a list of sections AND their descriptions. How can I do that in Joomla? the desired layout is something like: Video Only the newest TV series! Music Browse our latest ...

Joomla conditional menu item

I d like to create a menu item in Joomla that points to one article when the user is logged out, and a different article when the user is logged in. I tried creating two menu items, and make them ...

Joomla Cant Connect to DB

This sounds really easy to fix but I ve been working on it for awhile. Database Error: Unable to connect to the database:Could not connect to MySQL I had to make a local copy of Joomla for backup ...

热门标签