<commit_before><?php
class controller_ChangeController extends HttpController
{
	const AUTO_LOGIN_COOKIE = 'autologin';
	
	/**
	 * @return Request
	 */
	private function getRequest()
	{
		return $this->getContext()->getRequest();
	}

	/**
	 * Set the context lang
	 */
	private function setLangFromRequest()
	{
		$request = $this->getRequest();
		$lang = $request->getParameter(K::LANG_ACCESSOR);
		if (!f_util_StringUtils::isEmpty($lang))
		{
			$requestContext = RequestContext::getInstance();
			$requestContext->setLang($lang);
		}
	}
	
	protected function setRequestContextMode()
	{
	    RequestContext::getInstance()->setMode(RequestContext::FRONTOFFICE_MODE);
	}

	public function dispatch()
	{
		// Handle auto-login.
		$us = users_UserService::getInstance();
		if (is_null($us->getCurrentFrontEndUser()) && isset($_COOKIE[self::AUTO_LOGIN_COOKIE]))
		{
			$autoLoginInfos = $_COOKIE[self::AUTO_LOGIN_COOKIE];
			$login = $autoLoginInfos['login'];
			$passwd = $<PASSWORD>['<PASSWORD>'];
				
			$website = website_WebsiteModuleService::getInstance()->getCurrentWebsite();
			$user = $us->getFrontendUserByLogin($login, $website->getId());
			if ($user !== null && $user->isPublished() && sha1($user->getPasswordmd5()) == $passwd)
			{
				if (Framework::isDebugEnabled())
				{
					Framework::debug(__METHOD__ . ' auto-login with ' . $login);
				}
				$us->authenticateFrontEndUser($user);
			}
			else if (Framework::isDebugEnabled())
			{
				Framework::debug(__METHOD__ . ' auto-login skipped because the user with login ' . $login . ' doesn\'t exist, is not published or the password is wrong.');
			}
		}
		
		$this->setLangFromRequest();
		$this->setRequestContextMode();
		parent::dispatch();
	}
<commit_msg>Fix ticket 76963 : http://www.rbschange.fr/tickets/76963.html<commit_after><?php
class controller_ChangeController extends HttpController
{
	const AUTO_LOGIN_COOKIE = 'autologin';
	
	/**
	 * @return Request
	 */
	private function getRequest()
	{
		return $this->getContext()->getRequest();
	}

	/**
	 * Set the context lang
	 */
	private function setLangFromRequest()
	{
		$request = $this->getRequest();
		$lang = $request->getParameter(K::LANG_ACCESSOR);
		if (!f_util_StringUtils::isEmpty($lang))
		{
			$requestContext = RequestContext::getInstance();
			$requestContext->setLang($lang);
		}
	}
	
	protected function setRequestContextMode()
	{
	    RequestContext::getInstance()->setMode(RequestContext::FRONTOFFICE_MODE);
	}

	public function dispatch()
	{
		$clusterScale = ModuleService::getInstance()->moduleExists("modules_clusterscale");
		if ($clusterScale)
		{
			$this->setRequestContextMode();
		}
		// Handle auto-login.
		$us = users_UserService::getInstance();
		if (is_null($us->getCurrentFrontEndUser()) && isset($_COOKIE[self::AUTO_LOGIN_COOKIE]))
		{
			$autoLoginInfos = $_COOKIE[self::AUTO_LOGIN_COOKIE];
			$login = $autoLoginInfos['login'];
			$passwd = $autoLoginInfos['passwd'];
				
			$website = website_WebsiteModuleService::getInstance()->getCurrentWebsite();
			$user = $us->getFrontendUserByLogin($login, $website->getId());
			if ($user !== null && $user->isPublished() && sha1($user->getPasswordmd5()) == $passwd)
			{
				if (Framework::isDebugEnabled())
				{
					Framework::debug(__METHOD__ . ' auto-login with ' . $login);
				}
				$us->authenticateFrontEndUser($user);
			}
			else if (Framework::isDebugEnabled())
			{
				Framework::debug(__METHOD__ . ' auto-login skipped because the user with login ' . $login . ' doesn\'t exist, is not published or the password is wrong.');
			}
		}
		
		$this->setLangFromRequest();
		if (!$clusterScale)
		{
			$this->setRequestContextMode();
		}
		parent::dispatch();
	}

{'fraction_non_alphanumeric': 0.16327085031241512, 'fraction_numerical': 0.0038033143167617496, 'mean_word_length': 4.528528528528528, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5377483', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1169, 'n_words': 198}