PHP 7.1 and authentication

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
Sc00by121
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Mar 04, 2013 8:51 pm

PHP 7.1 and authentication

Post by Sc00by121 » Tue Jul 04, 2017 6:57 pm

Some years ago I found code on this forum that allowed me to fetch login and group details from the session and to allow authentication on a home made php application. This works fine when on PHP 5.6

When I switch over to PHP7 this stops working.

I am using Gantry and when I click on the link from the menu to load the homemade program (the link in the menu is purely a link to direct php file) I get:

Failed to load 'rt_xenon' template: Please install Gantry 5 Framework!

The file I am linking to calls 2 php files (below). If I comment out the calling of the two files the program loads fine. If I put them back in I get the problem.

I'm thinking that the code is not compatible with 7.1 but I don't know what it should be. I would have been on early Joomla 3 so perhaps something has been updated?

Further testing is showing that the issue seems to be with the getauthgroup file. If I leave in joomla-auth.php it continues to load fine but adding in the bottom file causes the issue.

Can anyone help?

joomla-auth.php

Code: Select all

<?php
session_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' );

/* 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.");
    
?>
getauthgroup.php

Code: Select all

<?php
session_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/////////////
         
?>
Last edited by toivo on Tue Jul 04, 2017 7:30 pm, edited 1 time in total.
Reason: mod note: moved to 3.x Coding

Locked

Return to “Joomla! 3.x Coding”