<commit_before><?php
/* Copyright (C) NAVER <http://www.navercorp.com> */

/**
 * @class ModuleHandler
 * @author NAVER (<EMAIL>)
 * Handling modules
 *
 * @remarks This class is to excute actions of modules.
 *          Constructing an instance without any parameterconstructor, it finds the target module based on Context.
 *          If there is no act on the found module, excute an action referencing action_forward.
 * */
class ModuleHandler extends Handler
{

	var $module = NULL; ///< Module
	var $act = NULL; ///< action
	var $mid = NULL; ///< Module ID
	var $document_srl = NULL; ///< Document Number
	var $module_srl = NULL; ///< Module Number
	var $module_info = NULL; ///< Module Info. Object
	var $error = NULL; ///< an error code.
	var $httpStatusCode = NULL; ///< http status code.

	/**
	 * prepares variables to use in moduleHandler
	 * @param string $module name of module
	 * @param string $act name of action
	 * @param int $mid
	 * @param int $document_srl
	 * @param int $module_srl
	 * @return void
	 * */

	public function __construct($module = '', $act = '', $mid = '', $document_srl = '', $module_srl = '')
	{
		// If XE has not installed yet, set module as install
		if(!Context::isInstalled())
		{
			$this->module = 'install';
			$this->act = Context::get('act');
			return;
		}

		$oContext = Context::getInstance();
		if($oContext->isSuccessInit == FALSE)
		{
			$logged_info = Context::get('logged_info');
			if($logged_info->is_admin != "Y")
			{
				$this->error = 'msg_invalid_request';
				return;
			}
		}

		// Set variables from request arguments
		$this->module = $module ? $module : Context::get('module');
		$this->act = $act ? $act : Context::get('act');
		$this->mid = $mid ? $mid : Context::get('mid');
		$this->document_srl = $document_srl ? (int) $document_srl : (int) Context::get('document_srl');
		$this->module_srl = $module_srl ? (int) $module_srl : (int) Context::get('module_srl');
        if($entry = Context::get('entry'))
        {
            $this->entry = Context::convertEncodingStr($entry);
        }
        if(!$this->module && $this->mid === 'admin')
        {
        	Context::set('module', $this->module = 'admin');
        	Context::set('mid', $this->mid = null);
        }

		// Validate variables to prevent XSS
		$isInvalid = NULL;
		if($this->module && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->module))
		{
			$isInvalid = TRUE;
		}
		if($this->mid && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->mid))
		{
			$isInvalid = TRUE;
		}
		if($this->act && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->act))
		{
			$isInvalid = TRUE;
		}
		if($isInvalid)
		{
			htmlHeader();
			echo Context::getLang("msg_invalid_request");
			htmlFooter();
			Context::close();
			exit;
		}

		if(isset($this->act) && (strlen($this->act) >= 4 && substr_compare($this->act, 'disp', 0, 4) === 0))
		{
			if(Context::get('_use_ssl') == 'optional' && Context::isExistsSSLAction($this->act) && RX_SSL)<commit_msg>Fix incorrect SSL detection<commit_after><?php
/* Copyright (C) NAVER <http://www.navercorp.com> */

/**
 * @class ModuleHandler
 * @author NAVER (<EMAIL>)
 * Handling modules
 *
 * @remarks This class is to excute actions of modules.
 *          Constructing an instance without any parameterconstructor, it finds the target module based on Context.
 *          If there is no act on the found module, excute an action referencing action_forward.
 * */
class ModuleHandler extends Handler
{

	var $module = NULL; ///< Module
	var $act = NULL; ///< action
	var $mid = NULL; ///< Module ID
	var $document_srl = NULL; ///< Document Number
	var $module_srl = NULL; ///< Module Number
	var $module_info = NULL; ///< Module Info. Object
	var $error = NULL; ///< an error code.
	var $httpStatusCode = NULL; ///< http status code.

	/**
	 * prepares variables to use in moduleHandler
	 * @param string $module name of module
	 * @param string $act name of action
	 * @param int $mid
	 * @param int $document_srl
	 * @param int $module_srl
	 * @return void
	 * */

	public function __construct($module = '', $act = '', $mid = '', $document_srl = '', $module_srl = '')
	{
		// If XE has not installed yet, set module as install
		if(!Context::isInstalled())
		{
			$this->module = 'install';
			$this->act = Context::get('act');
			return;
		}

		$oContext = Context::getInstance();
		if($oContext->isSuccessInit == FALSE)
		{
			$logged_info = Context::get('logged_info');
			if($logged_info->is_admin != "Y")
			{
				$this->error = 'msg_invalid_request';
				return;
			}
		}

		// Set variables from request arguments
		$this->module = $module ? $module : Context::get('module');
		$this->act = $act ? $act : Context::get('act');
		$this->mid = $mid ? $mid : Context::get('mid');
		$this->document_srl = $document_srl ? (int) $document_srl : (int) Context::get('document_srl');
		$this->module_srl = $module_srl ? (int) $module_srl : (int) Context::get('module_srl');
        if($entry = Context::get('entry'))
        {
            $this->entry = Context::convertEncodingStr($entry);
        }
        if(!$this->module && $this->mid === 'admin')
        {
        	Context::set('module', $this->module = 'admin');
        	Context::set('mid', $this->mid = null);
        }

		// Validate variables to prevent XSS
		$isInvalid = NULL;
		if($this->module && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->module))
		{
			$isInvalid = TRUE;
		}
		if($this->mid && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->mid))
		{
			$isInvalid = TRUE;
		}
		if($this->act && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->act))
		{
			$isInvalid = TRUE;
		}
		if($isInvalid)
		{
			htmlHeader();
			echo Context::getLang("msg_invalid_request");
			htmlFooter();
			Context::close();
			exit;
		}

		if(isset($this->act) && (strlen($this->act) >= 4 && substr_compare($this->act, 'disp', 0, 4) === 0))
		{
			if(Context::get('_use_ssl') == 'optional' && Context::isExistsSSLAction($this->act) && !RX_SSL)
{'fraction_non_alphanumeric': 0.19258635214827297, 'fraction_numerical': 0.003369839932603201, 'mean_word_length': 3.2279202279202277, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3090115', 'n_tokens_mistral': 2180, 'n_tokens_neox': 1987, 'n_words': 482}