AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.111
Web Server : Apache
System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : coopiak ( 151928)
PHP Version : 8.3.23
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/coopiak/dansnotreville-fr/nice/modules/mod_cblogin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/dansnotreville-fr/nice/modules/mod_cblogin/helper.php
<?php
/**
* Community Builder (TM)
* @version $Id: $
* @package CommunityBuilder
* @copyright (C) 2004-2023 www.joomlapolis.com / Lightning MultiCom SA - and its licensors, all rights reserved
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2
*/

use CBLib\Application\Application;
use CBLib\Registry\GetterInterface;
use Joomla\CMS\Helper\AuthenticationHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Uri\Uri;

if ( ! ( defined( '_VALID_CB' ) || defined( '_JEXEC' ) || defined( '_VALID_MOS' ) ) ) { die( 'Direct Access to this location is not allowed.' ); }

class modCBLoginHelper
{
	/**
	 * Gets type of module depending on user login state.
	 *
	 * @return string  'login' or 'logout'
	 */
	static function getType()
	{
		global $_CB_framework;

		return ( $_CB_framework->myId() > 0 ) ? 'logout' : 'login';
	}

	/**
	 * Retrieve the URL where the user should be returned after logging in
	 *
	 * @param   \Joomla\Registry\Registry  $params  module parameters
	 * @param   string                     $type    return type
	 * @return  string
	 */
	public static function getJoomlaReturnUrl($params, $type)
	{
		$item = Application::Cms()->getApplication()->getMenu()->getItem($params->get($type));

		if ($item)
		{
			$lang = '';

			if ($item->language !== '*' && Multilanguage::isEnabled())
			{
				$lang = '&lang=' . $item->language;
			}

			return 'index.php?Itemid=' . $item->id . $lang;
		}
		// Stay on the same page
		return Uri::getInstance()->toString();
	}

	/**
	 * Computes the return-url for the module
	 *
	 * @param  \Joomla\Registry\Registry $params
	 * @param  string                    $type
	 * @param  array                     $attribs
	 * @return string
	 */
	static function getReturnURL( $params, $type, $attribs )
	{
		global $_CB_framework, $cbSpecialReturnAfterLogin, $cbSpecialReturnAfterLogout;

		static $returnUrl			=	null;

		if ( ! isset( $returnUrl ) ) {
			if ( isset( $attribs['return_url'] ) && $attribs['return_url'] ) {
				// Redirect was sent with the module render object so use it:
				$returnUrl			=	$attribs['return_url'];
			} else {
				$returnUrl			=	Application::Input()->get( 'get/return', '', GetterInterface::BASE64 );

				if ( $returnUrl ) {
					$returnUrl		=	base64_decode( $returnUrl );
				}
			}

			// Try to find the return URL from login session (e.g. access denied cases):
			if ( ! $returnUrl ) {
				$returnUrl					=	$_CB_framework->getUserState( 'users.login.form.return', null );

				if ( ! $returnUrl ) {
					$data					=	$_CB_framework->getUserState( 'users.login.form.data', array() );
					$returnUrl				=	( isset( $data['return'] ) ? $data['return'] : null );

					if ( $returnUrl ) {
						$data['return']		=	null;

						// remove it from state data so navigating away doesn't cause us to return to a past place:
						$_CB_framework->setUserState( 'users.login.form.data', $data );
					}
				} else {
					// remove it from state form so navigating away doesn't cause us to return to a past place:
					$_CB_framework->setUserState( 'users.login.form.return', null );
				}
			}

			if ( $returnUrl ) {
				if ( ! Application::Router()->isInternal( $returnUrl ) ) {
					// The URL isn't internal to the site; reset it to index to be safe:
					$returnUrl		=	'index.php';
				}
			} else {
				$returnUrl			=	static::getJoomlaReturnUrl( $params, $type );
				}
			if ( ! $returnUrl ) {
				$isHttps			=	( isset( $_SERVER['HTTPS'] ) && ( ! empty( $_SERVER['HTTPS'] ) ) && ( $_SERVER['HTTPS'] != 'off' ) );
				$returnUrl			=	'http' . ( $isHttps ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST'];

				if ( ( ! empty( $_SERVER['PHP_SELF'] ) ) && ( ! empty( $_SERVER['REQUEST_URI'] ) ) ) {
					$returnUrl		.=	$_SERVER['REQUEST_URI'];
				} else {
					$returnUrl		.=	$_SERVER['SCRIPT_NAME'];

					if ( isset( $_SERVER['QUERY_STRING'] ) && ( ! empty( $_SERVER['QUERY_STRING'] ) ) ) {
						$returnUrl	.=	'?' . $_SERVER['QUERY_STRING'];
					}
				}
			}

			$returnUrl				=	cbUnHtmlspecialchars( preg_replace( '/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/', '""', preg_replace( '/eval\((.*)\)/', '', htmlspecialchars( urldecode( $returnUrl ) ) ) ) );

			if ( preg_match( '/index.php\?option=com_comprofiler&task=confirm&confirmCode=|index.php\?option=com_comprofiler&view=confirm&confirmCode=|index.php\?option=com_comprofiler&task=login|index.php\?option=com_comprofiler&view=login/', $returnUrl ) ) {
				$returnUrl			=	'index.php';
			}
		}

		$secureForm					=	(int) $params->get( 'https_post', 0 );

		if ( $type == 'login' ) {
			$loginReturnUrl 		=	$params->get( 'login', $returnUrl );

			if ( isset( $cbSpecialReturnAfterLogin ) ) {
				$loginReturnUrl		=	$cbSpecialReturnAfterLogin;
			}

			$url					=	cbSef( $loginReturnUrl, true, 'html', $secureForm );
		} elseif ( $type == 'logout' ) {
			$logoutReturnUrl 		=	$params->get( 'logout', 'index.php' );

			if ( $logoutReturnUrl == '#' ) {
				$logoutReturnUrl	=	$returnUrl;
			}

			if ( isset( $cbSpecialReturnAfterLogout ) ) {
				$logoutReturnUrl	=	$cbSpecialReturnAfterLogout;
			}

			$url					=	cbSef( $logoutReturnUrl, true, 'html', $secureForm );
		} else {
			$url					=	$returnUrl;
		}

		return base64_encode( $url );
	}

	/**
	 * Triggers CB plugins for $location
	 *
	 * @param  \Joomla\Registry\Registry  $params
	 * @param  string                     $type
	 * @param  string                     $location
	 * @param  string                     $tag
	 * @param  int                        $horizontal
	 * @param  string                     $prefixHtml
	 * @param  string                     $suffixHtml
	 * @param  string                     $prefixCSS
	 * @return null|string
	 */
	static function getPlugins( $params, $type, $location = 'beforeButton', $tag = 'div', $horizontal = 0, $prefixHtml = '', $suffixHtml = '', $prefixCSS = '' )
	{
		global $_PLUGINS;

		if ( ! $location ) {
			$location									=	'beforeButton';
		}

		if ( ! $tag ) {
			$tag										=	'div';
		}

		if ( $type == 'logout' ) {
			$pluginClassPrefix							=	'cbLogoutForm';
			$pluginsTrigger								=	'onAfterLogoutForm';
		} else {
			$pluginClassPrefix							=	'cbLoginForm';
			$pluginsTrigger								=	'onAfterLoginForm';
		}

		$pluginDisplays									=	array();

		if ( $params->get( 'cb_plugins', 1 ) ) {
			$classSuffix								=	$params->get( 'moduleclass_sfx' );
			$usernameInputLength						=	(int) $params->get( 'name_length', 14 );
			$passwordInputLength						=	(int) $params->get( 'pass_length', 14 );

			$pluginsResults								=	$_PLUGINS->trigger( $pluginsTrigger, array( $usernameInputLength, $passwordInputLength, $horizontal, $classSuffix, &$params ) );

			if ( count( $pluginsResults ) > 0 ) foreach ( $pluginsResults as $pR ) {
				if ( is_array( $pR ) ) foreach ( $pR as $pK => $pV ) {
					if ( $pV != '' ) {
						$pluginDisplays[$pK][]			=	$pV;
					}
				} elseif ( $pR != '' ) {
					$pluginDisplays['beforeButton'][]	=	$pR;
				}
			}
		}

		$return											=	null;

		if ( isset( $pluginDisplays[$location] ) ) {
			$return										.=	$prefixHtml;

			foreach ( $pluginDisplays[$location] as $pV ) {
				$return									.=	( $tag ? '<' . htmlspecialchars( $tag ) . ' class="' . ( $prefixCSS ? $prefixCSS . ' ' : null ) . $pluginClassPrefix . ucfirst( htmlspecialchars( $location ) ) . '">' : null )
														.		$pV
														.	( $tag ? '</' . htmlspecialchars( $tag ) . '>' : null );
			}

			$return										.=	$suffixHtml;
		}

		return $return;
	}

	/**
	 * Gets 2-factor authentication methods
	 *
	 * @return array
	 */
	static function getTwoFactorMethods()
	{
		if ( checkJversion( '4.0+' ) ) {
			return [];
		}

		return JAuthenticationHelper::getTwoFactorMethods();
	}

	/**
	 * Gets additional login buttons (e.g. webauthn)
	 *
	 * @param int $id
	 * @return array
	 */
	static function getExtraButtons( $id )
	{
		if ( checkJversion( '<4.0' ) ) {
			return [];
		}

		return AuthenticationHelper::getLoginButtons( $id );
	}
}

Anon7 - 2022
AnonSec Team