<commit_before><?php
/*	Project:	EQdkp-Plus
 *	Package:	EQdkp-plus
 *	Link:		http://eqdkp-plus.eu
 *
 *	Copyright (C) 2006-2016 EQdkp-Plus Developer Team
 *
 *	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.
 *
 *	You should have received a copy of the GNU Affero General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

if(!defined('EQDKP_INC')) {
	header('HTTP/1.0 404 Not Found');exit;
}
class install extends gen_class {

	private $current_step	= 'start';
	private $previous		= 'start';
	private $steps			= array();
	private $globals		= array();
	private $included		= array();
	private $initialised	= array();
	private $order			= array();
	private $done			= array();
	private $retry_step		= false;

	public  $data			= array();

	public function init() {
		// start the installation
		$this->pdl->register_type("install_error", null, array($this, 'install_error'), array(DEBUG));
		$this->pdl->register_type("install_warning", null, array($this, 'install_warning'), array(DEBUG));
		$this->pdl->register_type("install_success", null, array($this, 'install_success'), array(DEBUG));
		$this->current_step = $this->in->get('current_step', 'start');

		//dont let them install, if already installed (but show clean end of installation
		if(defined('EQDKP_INSTALLED') && EQDKP_INSTALLED) {
			if($this->current_step == 'end' && !$this->in->exists('next')) {
				$config = str_replace('define(\'EQDKP_INSTALLED\', true);'."\n", '', file_get_contents($this->root_path.'config.php'));
				registry::register('file_handler', array('installer'))->putContent($this->root_path.'config.php', $config);
				unset($config);
			} elseif($this->current_step != 'end') {
				echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
				<html>
					<head>
						<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
						<link rel="stylesheet" type="text/css" media="screen" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" />
						<title>Installation - Error</title>
					</head>
					<body>
					<div class="ui-widget">
						<div class="ui-state-error ui-corner-all" style="padding: 0pt 0.7em;">
							<p>
							<strong>Alert:</strong> Already Installed. Remove the \'install\' folder, or remove your config.php to install again.</p>
						</div>
					</div>

					</body>
				</html>';
				die();
			}
		}

		$this->data = ($this->in->exists('step_data')) ? unserialize(base64_decode($this->in->get('step_data'))) : array();
		if($this->in->exists('next') && $this->current_step == 'end') $this->parse_end();
		if($this->in->exists('install_done')) {
			$this->done = (strpos($this->in->get('install_done'), ',') !== false) ? explode(',', $this->in->get('install_done')) : (($this->in->get('install_done') != '') ? array($this->in->get('install_done')) : array());
		}
		$this->init_language();
		$this->scan_steps();
		if(!(in_array($this->current_step, array_keys($this->steps)) || $this->current_step == 'start') && $this->current_step != 'end') $this->pdl->log('install_error', 'invalid current step');
		if($this->in->exists('select')) {
			$this->current_step = $this->in->get('select');
		} elseif($this->in->exists('next') || $this->in->exists('prev') || $this->current_step == 'start' || $this->in->exists('skip')) {
			if($this->current_step == 'start' || $this->in->exists('skip') || ($this->current_step != 'end' && $this->parse_step() && $this->in->exists('next'))) $this->next_step();<commit_msg>Better error message<commit_after><?php
/*	Project:	EQdkp-Plus
 *	Package:	EQdkp-plus
 *	Link:		http://eqdkp-plus.eu
 *
 *	Copyright (C) 2006-2016 EQdkp-Plus Developer Team
 *
 *	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.
 *
 *	You should have received a copy of the GNU Affero General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

if(!defined('EQDKP_INC')) {
	header('HTTP/1.0 404 Not Found');exit;
}
class install extends gen_class {

	private $current_step	= 'start';
	private $previous		= 'start';
	private $steps			= array();
	private $globals		= array();
	private $included		= array();
	private $initialised	= array();
	private $order			= array();
	private $done			= array();
	private $retry_step		= false;

	public  $data			= array();

	public function init() {
		// start the installation
		$this->pdl->register_type("install_error", null, array($this, 'install_error'), array(DEBUG));
		$this->pdl->register_type("install_warning", null, array($this, 'install_warning'), array(DEBUG));
		$this->pdl->register_type("install_success", null, array($this, 'install_success'), array(DEBUG));
		$this->current_step = $this->in->get('current_step', 'start');

		//dont let them install, if already installed (but show clean end of installation
		if(defined('EQDKP_INSTALLED') && EQDKP_INSTALLED) {
			if($this->current_step == 'end' && !$this->in->exists('next')) {
				$config = str_replace('define(\'EQDKP_INSTALLED\', true);'."\n", '', file_get_contents($this->root_path.'config.php'));
				registry::register('file_handler', array('installer'))->putContent($this->root_path.'config.php', $config);
				unset($config);
			} elseif($this->current_step != 'end') {
				echo '<!DOCTYPE html>
						<html>
						<head>
							<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

							<title>EQdkp Plus - '.$strErrorName.'</title>
							<style type="text/css">
							/* body */
							html {
								height: 100%;
							}

							body {
								background: #F5F5F5; /* Old browsers */
								font-size: 14px;
								font-family: \'Segoe UI\', \'Lucida Grande\', \'Helvetica Neue\', Helvetica, Arial, sans-serif;
								color: #000000;
								padding:0;
							  	margin:0;
								height: 100%;
								line-height: 20px;
							}

							.wrapper{
							
							}

							.header {
								padding-top: 20px;
								font-size: 45px;
								font-weight: 300;
								text-shadow: 1px 1px 2px #fff;
								filter: dropshadow(color=#fff, offx=1, offy=1);
								border: none;
								color:  #fff;
								text-align:center;
								vertical-align: middle;
								background-color: #2e78b0;
								height: 60px;
							}

							
							.footer {
								margin-top: 10px;
								color: #000;
								text-align: center;
								font-size: 11px;
							}

							.footer a, .footer a:link, .footer a:visited {
								color: #000;
								text-decoration: none;
							}

							.footer a:hover {
								text-decoration: underline;
							}

							.innerWrapper {
								margin-right: auto;
								margin-left: auto;
								padding: 10px;
								margin-bottom: 20px;
								margin-top: 10px;
								width: 700px;
							}

							h1, h2, h3 {
								font-family: \'Trebuchet MS\',Arial,sans-serif;
							    font-weight: bold;
							    margin-bottom: 10px;
							    padding-bottom: 5px;
								border-bottom: 1px solid #CCCCCC;
								margin-top: 5px;
							}

							h1 {
							    font-size: 20px;
							}

							h2 {
								font-size: 18px;
							}

							h3 {
								font-size: 14px;
								border-bottom: none;
								margin-bottom: 5px;
							}

							/* Links */
							a,a:link,a:active,a:visited {
								color: #4E7FA8;
								text-decoration: none;
							}

							a:hover {
								color: #000;
								text-decoration: none;
							}

							.inlineCode {
							    background-color: #ffffff;
							    border: 1px solid #cccccc;
							    border-radius: 3px;
							    display: inline-block;
							    font-family: Consolas, \'Courier New\', monospace;
							    margin: 0 2px;
							    padding: 0 5px;
							    word-break: break-all;
							    word-wrap: break-word;
							}

						</style>
						</head>

						<body>

						<div class="wrapper">
							<div class="header">
								EQdkp Plus '.$strErrorName.'
							</div>

							<div class="innerWrapper">
								<h1>Installation error</h1><br />
								EQdkp Plus is already installed. You can delete this <span class="inlineCode">install</span> folder.<br />
								If you want to reinstall, please remove the file <span class="inlineCode">config.php</span> from the root folder of your EQdkp Plus installation.
						</div>

					</div>
					<div class="footer">
						<a href="'.EQDKP_PROJECT_URL.'" target="_new">EQDKP Plus</a> &copy; 2003 - '.date('Y').' by EQDKP Plus Developer Team
					</div>
					</body>
					</html>';
				die();
			}
		}

		$this->data = ($this->in->exists('step_data')) ? unserialize(base64_decode($this->in->get('step_data'))) : array();
		if($this->in->exists('next') && $this->current_step == 'end') $this->parse_end();
		if($this->in->exists('install_done')) {
			$this->done = (strpos($this->in->get('install_done'), ',') !== false) ? explode(',', $this->in->get('install_done')) : (($this->in->get('install_done') != '') ? array($this->in->get('install_done')) : array());
		}
		$this->init_language();
		$this->scan_steps();
		if(!(in_array($this->current_step, array_keys($this->steps)) || $this->current_step == 'start') && $this->current_step != 'end') $this->pdl->log('install_error', 'invalid current step');
		if($this->in->exists('select')) {
			$this->current_step = $this->in->get('select');
		} elseif($this->in->exists('next') || $this->in->exists('prev') || $this->current_step == 'start' || $this->in->exists('skip')) {
			if($this->current_step == 'start' || $this->in->exists('skip') || ($this->current_step != 'end' && $this->parse_step() && $this->in->exists('next'))) $this->next_step();
{'fraction_non_alphanumeric': 0.17817456548580113, 'fraction_numerical': 0.013771488270491026, 'mean_word_length': 3.0515582916506347, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 182, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7216255', 'n_tokens_mistral': 4492, 'n_tokens_neox': 3419, 'n_words': 797}