<commit_before><?php
/**
 * Wikidot - free wiki collaboration software
 * Copyright (c) 2008, Wikidot Inc.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * For more information about licensing visit:
 * http://www.wikidot.org/license
 * 
 * @category Ozone
 * @package Ozone_Web
 * @version $Id$
 * @copyright Copyright (c) 2008, Wikidot Inc.
 * @license http://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License
 */

/**
 * Parameters for the web request.
 *
 */
class ParameterList {

	private $parameterArray = array ();
	private $parameterTypes = array ();
	private $parameterFrom = array();
	
	private $allParameters = array();

	public function initParameterList($runData) {
		
		if($runData->isAjaxMode()){
			$this->allParameters['AMODULE'] = array();
			foreach ($_POST as $key => $value) {
			  // 	if magic_quotes_gpc are set, reove escaping
			 	if(get_magic_quotes_gpc()){
				    $value = stripslashes($value);
			 	}
	
				$value = $this->fixNewLines($value);
				
				$this->parameterArray[$key] = $value;
				$this->parameterTypes[$key] = "AMODULE";
				$this->parameterFrom[$key] = 0; // 0 means "direct", + values means 'inherited'
				$this->allParameters['AMODULE'][$key] = $value;
				
			}
		} else{
			//initialize GET parameters from the url... because of mod_rewrite	
			$qs =  $_SERVER['QUERY_STRING'];
			/* Check if there is a "?" char - if so, remove it. */
			$qs = preg_replace(';\?.*$;', '', $qs);
			$splited = explode("/",$qs);
			if(count($splited)>= 1){
				$this->parameterArray['template'] = $splited[0];
				$this->parameterTypes['template'] = "GET";
			}
			
			// now populate other parameters...
			$this->allParameters['GET'] = array();
			for($i=1; $i<count($splited); $i+=2){
				$key = $splited[$i];
				$value=$splited[$i+1];
				$this->parameterArray[$key] = urldecode($value);
				$this->parameterTypes[$key] = "GET";
				$this->parameterFrom[$key] = 0;
				$this->allParameters['GET'][$key] = urldecode($value);
			}

			// POST parameters are not affected by mod_rewrite
			$this->allParameters['POST'] = array();
			foreach ($_POST as $key => $value) {
			  // 	if magic_quotes_gpc are set, reove escaping
			 	if(get_magic_quotes_gpc()){
				    $value = stripslashes($value);
			 	}
	
				$value = $this->fixNewLines($value);
				
				$this->parameterArray[$key] = $value;
				$this->parameterTypes[$key] = "POST";<commit_msg>* ParameterList now reads parameters from normal GET class (URL).<commit_after><?php
/**
 * Wikidot - free wiki collaboration software
 * Copyright (c) 2008, Wikidot Inc.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * For more information about licensing visit:
 * http://www.wikidot.org/license
 * 
 * @category Ozone
 * @package Ozone_Web
 * @version $Id$
 * @copyright Copyright (c) 2008, Wikidot Inc.
 * @license http://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License
 */

/**
 * Parameters for the web request.
 *
 */
class ParameterList {

	private $parameterArray = array ();
	private $parameterTypes = array ();
	private $parameterFrom = array();
	
	private $allParameters = array();

	public function initParameterList($runData) {
		
		if($runData->isAjaxMode()){
			$this->allParameters['AMODULE'] = array();
			foreach ($_POST as $key => $value) {
			  // 	if magic_quotes_gpc are set, reove escaping
			 	if(get_magic_quotes_gpc()){
				    $value = stripslashes($value);
			 	}
	
				$value = $this->fixNewLines($value);
				
				$this->parameterArray[$key] = $value;
				$this->parameterTypes[$key] = "AMODULE";
				$this->parameterFrom[$key] = 0; // 0 means "direct", + values means 'inherited'
				$this->allParameters['AMODULE'][$key] = $value;
				
			}
		} else{
			//initialize GET parameters from the url... because of mod_rewrite	
			$qs =  $_SERVER['QUERY_STRING'];
			/* Check if there is a "?" char - if so, remove it. */
			$qs = preg_replace(';\?.*$;', '', $qs);
			$splited = explode("/",$qs);
			if(count($splited)>= 1){
				$this->parameterArray['template'] = $splited[0];
				$this->parameterTypes['template'] = "GET";
			}
			
			/* Additionally parse the usual GET parameters. */
			$uri = $_SERVER['REQUEST_URI'];
			$uri = preg_replace(';^[^\?]*\?;', '', $uri);
			$uriPairs = explode('&', $uri);
			foreach($uriPairs as $uriPair){
				$u = explode('=', $uriPair);
				$key = $u[0];
				$value = $u[1];
				$this->parameterArray[$key] = urldecode($value);
				$this->parameterTypes[$key] = "GET";
				$this->parameterFrom[$key] = 0;
				$this->allParameters['GET'][$key] = urldecode($value);
			}
			
			// now populate other parameters...
			$this->allParameters['GET'] = array();
			for($i=1; $i<count($splited); $i+=2){
				$key = $splited[$i];
				$value=$splited[$i+1];
				$this->parameterArray[$key] = urldecode($value);
				$this->parameterTypes[$key] = "GET";
				$this->parameterFrom[$key] = 0;
				$this->allParameters['GET'][$key] = urldecode($value);
			}
			

			// POST parameters are not affected by mod_rewrite
			$this->allParameters['POST'] = array();
			foreach ($_POST as $key => $value) {
			  // 	if magic_quotes_gpc are set, reove escaping
			 	if(get_magic_quotes_gpc()){
				    $value = stripslashes($value);
			 	}
	
				$value = $this->fixNewLines($value);
				
				$this->parameterArray[$key] = $value;
				$this->parameterTypes[$key] = "POST";
{'fraction_non_alphanumeric': 0.16234282985834791, 'fraction_numerical': 0.006525545121757122, 'mean_word_length': 3.5078909612625537, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '4135126', 'n_tokens_mistral': 2342, 'n_tokens_neox': 1977, 'n_words': 550}