I am currently migrating 3.10 to 4 and have a problem with an external php application which uses joomla authentication session
I'm not a coder and what I am using was found on this forum many years ago, hopefully someone can advise on what I have to modify to make it compatible with J4
The application references two files;
getauthgroup.phpand joomla-auth.php
The start of the application then references;
This works as intended on J3 where the application authenticates based on who is logged into the joomla site so no double log in needed. In J4 I get;
I'm not a coder and what I am using was found on this forum many years ago, hopefully someone can advise on what I have to modify to make it compatible with J4
The application references two files;
getauthgroup.php
Code:
<?phpsession_start();include 'joomla-auth.php'; $user = JFactory::getUser(); $db = JFactory::getDBO(); $db->setQuery($db->getQuery(true) ->select('*') ->from("#__usergroups") ); $groups=$db->loadRowList(); $userGroups = $user->groups; $return=array(); foreach ($groups as $key=>$g){ if (array_key_exists($g[0],$userGroups)) array_push($return,$g[4]); } $groups=$return; /////printing groupnames for current user///////////// ?>
Code:
<?phpsession_start();define( '_JEXEC', 1 );define('JPATH_BASE', dirname(__FILE__));define( 'DS', DIRECTORY_SEPARATOR );require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );defined('_JEXEC');/* Create the Application */$mainframe =& JFactory::getApplication('site');/* Make sure we are logged in at all. */if (JFactory::getUser()->id == 0) die("Access denied: login required."); ?>
Code:
<?phpdefine( '_JEXEC', 1 );define( 'JPATH_BASE', realpath(dirname(__FILE__).'/..' ));define( 'DS', DIRECTORY_SEPARATOR );require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );$mainframe =& JFactory::getApplication('site');$mainframe->initialise();define("ABS_PATH", $_SERVER['DOCUMENT_ROOT']);include(ABS_PATH . "/joomla-auth.php");include(ABS_PATH . "/getauthgroup.php");$user =& JFactory::getUser();$usr_id = $user->get('id');$name = $user->get('name');$session =JFactory::getSession();include("connection.php");?>
Code:
Exceptionin /home/nsjxccou/public_html/libraries/src/Factory.php (line 158)Factory::getApplication()in /home/nsjxccou/public_html/joomla-auth.php (line 12)include('/home/nsjxccou/public_html/joomla-auth.php')in /home/nsjxccou/public_html/bookings/Login.php (line 15)
Statistics: Posted by Sc00by121 — Mon Feb 05, 2024 2:31 pm