<commit_before><?php

/**
 * kitEvent
 *
 * @author <NAME> <<EMAIL>>
 * @link https://addons.phpmanufaktur.de/de/addons/kitevent.php
 * @copyright 2011-2012 phpManufaktur by <NAME>
 * @license http://www.gnu.org/licenses/gpl.html GNU Public License (GPL)
 */

// include class.secure.php to protect this file and the whole CMS!
if (defined('WB_PATH')) {
  if (defined('LEPTON_VERSION')) include (WB_PATH . '/framework/class.secure.php');
}
else {
  $oneback = "../";
  $root = $oneback;
  $level = 1;
  while (($level < 10) && (!file_exists($root . '/framework/class.secure.php'))) {
    $root .= $oneback;
    $level += 1;
  }
  if (file_exists($root . '/framework/class.secure.php')) {
    include ($root . '/framework/class.secure.php');
  }
  else {
    trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
  }
}
// end include class.secure.php

require_once(WB_PATH.'/modules/'.basename(dirname(__FILE__)).'/initialize.php');
require_once(WB_PATH.'/include/captcha/captcha.php');
require_once(WB_PATH.'/framework/class.wb.php');
require_once(WB_PATH.'/modules/droplets_extension/interface.php');

class eventFrontend {
	const request_action				= 'act';
	const request_event					= 'evt';
	const request_year					= 'y';
	const request_month					= 'm';
	const request_day						= 'd';
	const request_event_id			= 'id';
	const request_event_detail	= 'det';
	const request_free_fields		= 'ff';
	const request_perma_link		= 'perl';

	const request_must_fields	= 'mf';

	const request_title				= 'title';
	const request_first_name	= 'fn';
	const request_last_name		= 'ln';
	const request_company			= 'com';
	const request_street			= 'str';
	const request_zip					= 'zip';
	const request_city				= 'cty';
	const request_email				= 'eml';
	const request_phone				= 'phn';
	const request_best_time		= 'bt';
	const request_confirm			= 'con';
	const request_terms				= 'trm';
	const request_privacy			= 'prv';
	const request_message			= 'msg';
	const request_captcha			= 'cpt';

	const action_default 			= 'def';
	const action_day					= 'day';
	const action_event				= 'evt';
	const action_order				= 'ord';
	const action_order_check	= 'chk';

	const param_view					= 'view';
	const param_preset				= 'preset';
	const param_detail				= 'detail';
	const param_group					= 'group';
	const param_event_id			= 'event_id';
	const param_ignore_topics	= 'ignore_topics';
	const param_response_id		= 'response_id'; // noch inaktiv!!!
	const param_search				= 'search';
	const param_header				= 'header';
	const param_css						= 'css';

	const view_id							= 'id';
	const view_day						= 'day';
	const view_week						= 'week';
	const view_month					= 'month';
	const view_active					= 'active';

	private $params = array(
		self::param_view				=> self::view_active,
		self::param_preset			=> 1,
		self::param_detail			=> false,
		self::param_group				=> '',
		self::param_event_id		=> -1,
		self::param_response_id => -1,
		self::param_ignore_topics => false,
		self::param_search			=> false,
		self::param_header			=> false,
		self::param_css					=> true
	);

	private $template_path;
	private $page_link;

	public function __construct() {
		global $kitLibrary;
		$url = '';
		$_SESSION['FRONTEND'] = true;
		$kitLibrary->getPageLinkByPageID(PAGE_ID, $url);
		$this->page_link = $url;
		$this->template_path = WB_PATH.'/modules/kit_event/htt/'.$this->params[self::param_preset].'/'.KIT_EVT_LANGUAGE.'/';
		date_default_timezone_set(event_cfg_time_zone);
	} // __construct();

	public function getParams() {
		return $this->params;
	} // getParams()

	public function setParams($params = array()) {
		$this->params = $params;
		$this->template_path = WB_PATH.'/modules/kit_event/htt/'.$this->params[self::param_preset].'/'.KIT_EVT_LANGUAGE.'/';
		if (!file_exists($this->template_path)) {
			$this->setError(sprintf(event_error_preset_not_exists, '/modules/kit_event/htt/'.$this->params[self::param_preset].'/'.KIT_EVT_LANGUAGE.'/'));
			return false;
		}
		return true;
	} // setParams()

	/**
    * Set $this->error to $error
    *
    * @param STR $error
    */
  public function setError($error) {
  	$debug = debug_backtrace();
    $caller = next($debug);
  	$this->error = sprintf('<div class="evt_error">[%s::%s - %s] %s</div>', basename($caller['file']), $caller['function'], $caller['line'], $error);
  } // setError()

  /**
    * Get Error from $this->error;
    *
    * @return STR $this->error
    */
  public function getError() {
    return $this->error;
  } // getError()

  /**
    * Check if $this->error is empty
    *
    * @return BOOL
    */
  public function isError() {
    return (bool) !empty($this->error);
  } // isError

  /**
   * Reset Error to empty String
   */
  public function clearError() {
  	$this->error = '';
  }

  /** Set $this->message to $message
    *
    * @param STR $message
    */
  public function setMessage($message) {
    $this->message = sprintf('<div class="evt_message">%s</div>', $message);
  } // setMessage()

  /**
    * Get Message from $this->message;
    *
    * @return STR $this->message
    */
  public function getMessage() {
    return $this->message;
  } // getMessage()

  /**
    * Check if $this->message is empty
    *
    * @return BOOL
    */
  public function isMessage() {
    return (bool) !empty($this->message);
  } // isMessage

  /**
   * Return Version of Module
   *
   * @return FLOAT
   */
  public function getVersion() {
    // read info.php into array
    $info_text = file(WB_PATH.'/modules/'.basename(dirname(__FILE__)).'/info.php');
    if ($info_text == false) {
      return -1;
    }
    // walk through array
    foreach ($info_text as $item) {
      if (strpos($item, '$module_version') !== false) {
        // split string $module_version
        $value = explode('=', $item);
        // return floatval
        return floatval(preg_replace('([\'";,\(\)[:space:][:alpha:]])', '', $value[1]));
      }
    }
    return -1;
  } // getVersion()

  /**
   * Verhindert XSS Cross Site Scripting
   *
   * @param REFERENCE $_REQUEST Array
   * @return $request
   */
	public function xssPrevent(&$request) {
  	if (is_string($request)) {
	    $request = html_entity_decode($request);
	    $request = strip_tags($request);
	    $request = trim($request);
	    $request = stripslashes($request);
  	}
	  return $request;
  } // xssPrevent()

  public function getTemplate($template, $template_data) {
  	global $parser;
  	try {
  		$result = $parser->get($this->template_path.$template, $template_data);
  	} catch (Exception $e) {
  		$this->setError(sprintf(event_error_template_error, $template, $e->getMessage()));
  		return false;
  	}
  	return $result;
  } // getTemplate()

  /**
   * Action Handler der class.frontend.php
   * Diese Funktion wird generell von aussen aufgerufen und steuert die Klasse.
   * @return STR result dialog
   */
  public function action() {
  	if ($this->isError()) return $this->getError();
  	$html_allowed = array();
  	foreach ($_REQUEST as $key => $value) {
  		if (!in_array($key, $html_allowed)) {
   			$_REQUEST[$key] = $this->xssPrevent($value);
  		}
  	}
  	if ((isset($_REQUEST[self::request_perma_link]) && is_numeric($_REQUEST[self::request_perma_link])) || ($this->params[self::param_event_id] !== -1)) {
  		$_REQUEST[self::request_action] = self::action_event;
  		$_REQUEST[self::request_event] = self::view_id;
  		$_REQUEST[self::request_event_id] = (isset($_REQUEST[self::request_perma_link]) && is_numeric($_REQUEST[self::request_perma_link])) ? $_REQUEST[self::request_perma_link] : $this->params[self::param_event_id];
  		$_REQUEST[self::request_event_detail] = (isset($_REQUEST[self::request_event_detail])) ? $_REQUEST[self::request_event_detail] : $this->params[self::param_detail];
  	}<commit_msg>fixed problem in parameter handling in action()<commit_after><?php

/**
 * kitEvent
 *
 * @author <NAME>sch <<EMAIL>>
 * @link https://addons.phpmanufaktur.de/de/addons/kitevent.php
 * @copyright 2011-2012 phpManufaktur by <NAME>
 * @license http://www.gnu.org/licenses/gpl.html GNU Public License (GPL)
 */

// include class.secure.php to protect this file and the whole CMS!
if (defined('WB_PATH')) {
  if (defined('LEPTON_VERSION')) include (WB_PATH . '/framework/class.secure.php');
}
else {
  $oneback = "../";
  $root = $oneback;
  $level = 1;
  while (($level < 10) && (!file_exists($root . '/framework/class.secure.php'))) {
    $root .= $oneback;
    $level += 1;
  }
  if (file_exists($root . '/framework/class.secure.php')) {
    include ($root . '/framework/class.secure.php');
  }
  else {
    trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
  }
}
// end include class.secure.php

require_once(WB_PATH.'/modules/'.basename(dirname(__FILE__)).'/initialize.php');
require_once(WB_PATH.'/include/captcha/captcha.php');
require_once(WB_PATH.'/framework/class.wb.php');
require_once(WB_PATH.'/modules/droplets_extension/interface.php');

class eventFrontend {
	const request_action				= 'act';
	const request_event					= 'evt';
	const request_year					= 'y';
	const request_month					= 'm';
	const request_day						= 'd';
	const request_event_id			= 'id';
	const request_event_detail	= 'det';
	const request_free_fields		= 'ff';
	const request_perma_link		= 'perl';

	const request_must_fields	= 'mf';

	const request_title				= 'title';
	const request_first_name	= 'fn';
	const request_last_name		= 'ln';
	const request_company			= 'com';
	const request_street			= 'str';
	const request_zip					= 'zip';
	const request_city				= 'cty';
	const request_email				= 'eml';
	const request_phone				= 'phn';
	const request_best_time		= 'bt';
	const request_confirm			= 'con';
	const request_terms				= 'trm';
	const request_privacy			= 'prv';
	const request_message			= 'msg';
	const request_captcha			= 'cpt';

	const action_default 			= 'def';
	const action_day					= 'day';
	const action_event				= 'evt';
	const action_order				= 'ord';
	const action_order_check	= 'chk';

	const param_view					= 'view';
	const param_preset				= 'preset';
	const param_detail				= 'detail';
	const param_group					= 'group';
	const param_event_id			= 'event_id';
	const param_ignore_topics	= 'ignore_topics';
	const param_response_id		= 'response_id'; // noch inaktiv!!!
	const param_search				= 'search';
	const param_header				= 'header';
	const param_css						= 'css';

	const view_id							= 'id';
	const view_day						= 'day';
	const view_week						= 'week';
	const view_month					= 'month';
	const view_active					= 'active';

	private $params = array(
		self::param_view				=> self::view_active,
		self::param_preset			=> 1,
		self::param_detail			=> false,
		self::param_group				=> '',
		self::param_event_id		=> -1,
		self::param_response_id => -1,
		self::param_ignore_topics => false,
		self::param_search			=> false,
		self::param_header			=> false,
		self::param_css					=> true
	);

	private $template_path;
	private $page_link;

	public function __construct() {
		global $kitLibrary;
		$url = '';
		$_SESSION['FRONTEND'] = true;
		$kitLibrary->getPageLinkByPageID(PAGE_ID, $url);
		$this->page_link = $url;
		$this->template_path = WB_PATH.'/modules/kit_event/htt/'.$this->params[self::param_preset].'/'.KIT_EVT_LANGUAGE.'/';
		date_default_timezone_set(event_cfg_time_zone);
	} // __construct();

	public function getParams() {
		return $this->params;
	} // getParams()

	public function setParams($params = array()) {
		$this->params = $params;
		$this->template_path = WB_PATH.'/modules/kit_event/htt/'.$this->params[self::param_preset].'/'.KIT_EVT_LANGUAGE.'/';
		if (!file_exists($this->template_path)) {
			$this->setError(sprintf(event_error_preset_not_exists, '/modules/kit_event/htt/'.$this->params[self::param_preset].'/'.KIT_EVT_LANGUAGE.'/'));
			return false;
		}
		return true;
	} // setParams()

	/**
    * Set $this->error to $error
    *
    * @param STR $error
    */
  public function setError($error) {
  	$debug = debug_backtrace();
    $caller = next($debug);
  	$this->error = sprintf('<div class="evt_error">[%s::%s - %s] %s</div>', basename($caller['file']), $caller['function'], $caller['line'], $error);
  } // setError()

  /**
    * Get Error from $this->error;
    *
    * @return STR $this->error
    */
  public function getError() {
    return $this->error;
  } // getError()

  /**
    * Check if $this->error is empty
    *
    * @return BOOL
    */
  public function isError() {
    return (bool) !empty($this->error);
  } // isError

  /**
   * Reset Error to empty String
   */
  public function clearError() {
  	$this->error = '';
  }

  /** Set $this->message to $message
    *
    * @param STR $message
    */
  public function setMessage($message) {
    $this->message = sprintf('<div class="evt_message">%s</div>', $message);
  } // setMessage()

  /**
    * Get Message from $this->message;
    *
    * @return STR $this->message
    */
  public function getMessage() {
    return $this->message;
  } // getMessage()

  /**
    * Check if $this->message is empty
    *
    * @return BOOL
    */
  public function isMessage() {
    return (bool) !empty($this->message);
  } // isMessage

  /**
   * Return Version of Module
   *
   * @return FLOAT
   */
  public function getVersion() {
    // read info.php into array
    $info_text = file(WB_PATH.'/modules/'.basename(dirname(__FILE__)).'/info.php');
    if ($info_text == false) {
      return -1;
    }
    // walk through array
    foreach ($info_text as $item) {
      if (strpos($item, '$module_version') !== false) {
        // split string $module_version
        $value = explode('=', $item);
        // return floatval
        return floatval(preg_replace('([\'";,\(\)[:space:][:alpha:]])', '', $value[1]));
      }
    }
    return -1;
  } // getVersion()

  /**
   * Verhindert XSS Cross Site Scripting
   *
   * @param REFERENCE $_REQUEST Array
   * @return $request
   */
	public function xssPrevent(&$request) {
  	if (is_string($request)) {
	    $request = html_entity_decode($request);
	    $request = strip_tags($request);
	    $request = trim($request);
	    $request = stripslashes($request);
  	}
	  return $request;
  } // xssPrevent()

  public function getTemplate($template, $template_data) {
  	global $parser;
  	try {
  		$result = $parser->get($this->template_path.$template, $template_data);
  	} catch (Exception $e) {
  		$this->setError(sprintf(event_error_template_error, $template, $e->getMessage()));
  		return false;
  	}
  	return $result;
  } // getTemplate()

  /**
   * Action Handler der class.frontend.php
   * Diese Funktion wird generell von aussen aufgerufen und steuert die Klasse.
   * @return STR result dialog
   */
  public function action() {
  	if ($this->isError()) return $this->getError();
  	$html_allowed = array();
  	foreach ($_REQUEST as $key => $value) {
  	  if (stripos($key, 'amp;') == 0) {
        // fix the problem, that the server does not proper rewrite &amp; to &
        $key = substr($key, 4);
        $_REQUEST[$key] = $value;
        unset($_REQUEST['amp;'.$key]);
      }
      if (!in_array($key, $html_allowed)) {
   			$_REQUEST[$key] = $this->xssPrevent($value);
  		}
  	}
  	if ((isset($_REQUEST[self::request_perma_link]) && is_numeric($_REQUEST[self::request_perma_link])) || ($this->params[self::param_event_id] !== -1)) {
  		$_REQUEST[self::request_action] = self::action_event;
  		$_REQUEST[self::request_event] = self::view_id;
  		$_REQUEST[self::request_event_id] = (isset($_REQUEST[self::request_perma_link]) && is_numeric($_REQUEST[self::request_perma_link])) ? $_REQUEST[self::request_perma_link] : $this->params[self::param_event_id];
  		$_REQUEST[self::request_event_detail] = (isset($_REQUEST[self::request_event_detail])) ? $_REQUEST[self::request_event_detail] : $this->params[self::param_detail];
  	}
{'fraction_non_alphanumeric': 0.169880277252678, 'fraction_numerical': 0.002520478890989288, 'mean_word_length': 3.5011344299489506, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 117, 'https://': 2, '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': '7275427', 'n_tokens_mistral': 5924, 'n_tokens_neox': 5591, 'n_words': 1080}