Location: PHPKode > projects > iLP System > Release 2.2/upload/install.php
<?php
/**
 * iLP System Installation (Deutsch-Du)
 * 
 * @author:  Florian "ApoY2k" Peschka <hide@address.com>
 * @package: apoy2k.ilp.wrynn.lib.lang
 * @license: CreativeCommons (by-nc-sa)
 * @version: 2.2
 */
session_start();
error_reporting(E_WARNING);

// Datei als HTML identifizieren
header('Content-Type: text/html');

// HTML-Header erzeugen
$html = '<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<title>
			Installation – iLP System
		</title>
		<link rel="stylesheet" type="text/css" href="lib/style.css" />
		<style type="text/css">
		<!--
			#install {
				max-width: 120ex;
				width: 90%;
				min-width: 80ex;
				margin: 0 2ex;
			}
			
			#install h1 {
				margin: 0 5ex;
				font-size: 150%;
				font-weight: bold;
				font-variant: small-caps;
				letter-spacing: 3px;
			}
			
			#install #content h1 {
				margin: 0;
			}
			
			#install #content ul {
				margin: 0 3ex;
			}
			
			#install #content ul li {
				margin: 1ex;
			}
			
			#install #content ul li img {
				vertical-align: text-bottom;
			}
			
			#install #content.languages {
				text-align: center;
				padding: 10ex;
			}
			
			#install #content.languages a:link, #install #content.languages a:visited {
				border: 1px solid #698fa2;
				padding: 2ex;
			}
			
			#install #content.languages a:hover {
				background: #fff;
				text-decoration: none;
			}
		-->
		</style>
	</head>
	<body>
		<div id="outer">
			<div id="logo">
				<img src="images/ilp_wrynn.png" alt="iLP Logo" />
			</div>
			<div id="install">';

// Dateistruktur überprüfen
$basedir = preg_split('/install.php/', dirname(__FILE__));
define('BASEDIR', $basedir[0].'/');

// Create ilpUrlEncode to prevent error messages from missing function
function ilpUrlEncode() { };

// Check lib-directory and search for installed languages
if (!isset($_GET['step']))
{
	$html .= '<div id="content" class="languages">';
	
	$dir_handler = opendir(BASEDIR.'lib/');
	while ($file = readdir($dir_handler))
	{
		if (strpos($file, 'lang'))
		{
			$language = substr($file, 9, 4);
			$html .= '<a href="?step=0&lang='.$language.'">'.$language.'</a> ';
		}
	}
	
	$html .= '</div>';
}

// Wenn kein Schritt angegeben ist, Startseite anzeigen
elseif (isset($_GET['lang']))
{

	// Include language file
	require_once(BASEDIR.'lib/lib.lang.'.$_GET['lang'].'.php');
	
	if (0 == $_GET['step'])
	{
		$html .= '<h1>'.$lang['install']['header'].'</h1>
					<div id="content">
						<p>
							'.$lang['install']['welcome']['header'].'
						</p>
						<p>
							'.$lang['install']['welcome']['text'].'
						</p>
						<ul>';
		
		// Kontrollvariable zur Überprüfung, ob alle Kriterien erfüllt sind
		$check = 0;
		
		// PHP-Datei überprüfen
		$html .= '<li class="';
		if (version_compare(PHP_VERSION, '5.0.0', '>='))
		{
			$check++;
			$html .= 'correct"><img src="images/icons/accept.png" alt="icon" />';
		}
		else
		{
			$check--;
			$html .= 'warning"><img src="images/icons/cross.png" alt="icon" />';
		}
		
		$html .= ' '.$lang['install']['reqs']['php5'].'</li>';
		
		// Benötigte Extensions prüfen
		$extensions = get_loaded_extensions();
		
		// Die SimpleXML-Extension wird für das Auslesen der Gegenstands-Tooltips sowie der Spieler-Tooltips benötigt
		$html .= '<li class="';
		if (in_array('SimpleXML', $extensions))
		{
			$check++;
			$html .= 'correct"><img src="images/icons/accept.png" alt="icon" />';
		}
		else
		{
			$check--;
			$html .= 'warning"><img src="images/icons/cross.png" alt="icon" />';
		}
		
		$html .= ' '.$lang['install']['reqs']['simplexml'].'</li>';
		
		// Mit der PDO-Extension werden alle Datenbankabfragen gehandhabt
		$html .= '<li class="';
		if (in_array('PDO', $extensions))
		{
			$check++;
			$html .= 'correct"><img src="images/icons/accept.png" alt="icon" />';
		}
		else
		{
			$chek--;
			$html .= 'warning"><img src="images/icons/cross.png" alt="icon" />';
		}
		$html .= ' '.$lang['install']['reqs']['pdo'].'</li>';
		
		// Die PDO-Extension für den Umgang mit MySQL-Datenbanken
		$html .= '<li class="';
		if (in_array('pdo_mysql', $extensions))
		{
			$check++;
			$html .= 'correct"><img src="images/icons/accept.png" alt="icon" />';
		}
		else
		{
			$check--;
			$html .= 'warning"><img src="images/icons/cross.png" alt="icon" />';
		}
		$html .= ' '.$lang['install']['reqs']['pdo_mysql'].'</li>';
		
		// Wenn der Ordner beschreibbar ist, wird versucht die Rechte manuell zu setzen
		$html .= '<li class="';
		if (is_writable(BASEDIR) || chmod(BASEDIR, 0777))
		{
			$check++;
			$html .= 'correct"><img src="images/icons/accept.png" alt="icon" />';
		}
		else
		{
			$check--;
			$html .= 'warning"><img src="images/icons/cross.png" alt="icon" />';
		}
		$html .= ' '.$lang['install']['reqs']['chmod'].' <em>'.BASEDIR.'</em></li>';
		
		$html .= '</ul><br />';
		
		// Wenn alle Kriterien erfüllt sind, kann mit der Installaion begonnen werden
		if (5 == $check)
		{
			$html .= '<form method="post" action="install.php?step=1&lang='.$_GET['lang'].'">
							<fieldset>
								<legend><img src="images/icons/disk.png" alt="icon" /> '.$lang['install']['start']['header'].'</legend>
								<p>
									'.$lang['install']['start']['text'].'
								</p>
							</fieldset>
							<div>
								<input type="submit" value="'.$lang['install']['start']['header'].'" />
							</div>
						</form>';
		}
		else
		{
			$html .= '<div class="warning">
							<h1>'.$lang['install']['error']['header'].'</h1>
							<p>
								'.$lang['install']['reqs']['error'].'
							</p>
						</div>';
		}
	}
	
	elseif (1 == $_GET['step'])
	{
		$html .= '<h1>'.$lang['install']['step'].' 1 / 4: '.$lang['install']['db']['header'].'</h1>
				<div id="content">
					<p>
						'.$lang['install']['db']['text'].'
					</p>
					<form method="post" action="install.php?step=10&lang='.$_GET['lang'].'">
						<fieldset>
							<legend><img src="images/icons/database_connect.png" alt="icon"> '.$lang['install']['db']['header'].'</legend>
							<div class="inputGroup">
								<div class="inputName">
									<label for="install_db_host">
										'.$lang['install']['db']['host'].'
									</label>
								</div>
								<div class="inputField">
									<input type="text" name="install_db_host" id="install_db_host" value="localhost" readonly="readonly" />
									<div class="inputDesc">
										<label for="install_db_host">
											'.$lang['install']['db']['hostinfo'].'
										</label>
									</div>
								</div>
							</div>
							<div class="inputGroup">
								<div class="inputName">
									<label for="install_db_name">
										'.$lang['install']['db']['name'].'
									</label>
								</div>
								<div class="inputField">
									<input type="text" name="install_db_name" id="install_db_name"';
			
			isset($_SESSION['install']['db']['name']) ? $html .= ' value="'.$_SESSION['install']['db']['name'].'"' : null;
			
			$html .= ' />
									<div class="inputDesc">
										<label for="install_db_name">
											'.$lang['install']['db']['nameinfo'].'
										</label>
									</div>
								</div>
							</div>
							<div class="inputGroup">
								<div class="inputName">
									<label for="install_db_user">
										'.$lang['install']['db']['user'].'
									</label>
								</div>
								<div class="inputField">
									<input type="text" name="install_db_user" id="install_db_user"';
			
			isset($_SESSION['install']['db']['user']) ? $html .= ' value="'.$_SESSION['install']['db']['user'].'"' : null;
			
			$html .= ' />
									<div class="inputDesc">
										<label for="install_db_user">
											'.$lang['install']['db']['userinfo'].'
										</label>
									</div>
								</div>
							</div>
							<div class="inputGroup">
								<div class="inputName">
									<label for="install_db_password">
										'.$lang['install']['db']['pass'].'
									</label>
								</div>
								<div class="inputField">
									<input type="text" name="install_db_password" id="install_db_password" />
									<div class="inputDesc">
										<label for="install_db_password">
											'.$lang['install']['db']['passinfo'].'
										</label>
									</div>
								</div>
							</div>
						</fieldset>
						<div>
							<input type="submit" value="'.$lang['install']['continue'].'" />
						</div>
					</form>';
	}
	
	elseif (10 == $_GET['step'])
	{
		$html .= '<h1>'.$lang['install']['db']['checked'].'</h1>
					<div id="content">';
		try
		{
			new PDO('mysql:dbname='.$_POST['install_db_name'].';host='.$_POST['install_db_host'], $_POST['install_db_user'], $_POST['install_db_password']);
			
			
			// Prüfen, ob die Datenbankdaten korrekt eingegeben wurden
			if (
				(
					isset($_POST['install_db_host'])
					&& '' != $_POST['install_db_host']
					&& isset($_POST['install_db_name'])
					&& '' != $_POST['install_db_name']
					&& isset($_POST['install_db_user'])
					&& '' != $_POST['install_db_user']
					&& isset($_POST['install_db_password'])
					&& '' != $_POST['install_db_password']
				)
				|| isset($_SESSION['install']['db'])
				)
			{
				$_SESSION['install']['db']['host'] = $_POST['install_db_host'];
				$_SESSION['install']['db']['name'] = $_POST['install_db_name'];
				$_SESSION['install']['db']['user'] = $_POST['install_db_user'];
				$_SESSION['install']['db']['password'] = $_POST['install_db_password'];
			
				$html .= '<p>
							'.$lang['install']['db']['checked_ok'].'<br /><br />
							<a href="install.php?step=2&lang='.$_GET['lang'].'">'.$lang['install']['continue'].' &gt;&gt;</a>
						</p>
					</div>';
			
			}
			else
			{
				$html .= '<div class="warning">
							<h1>'.$lang['install']['error']['header'].'</h1>
							<p>
								'.$lang['install']['error']['notempty'].'<br /><br />
								<a href="install.php?step=1&lang='.$_GET['lang'].'">&lt;&lt; '.$lang['install']['back'].'</a>
							</p>
						</div>';
			}
		}
		catch (PDOException $e)
		{
			$html .= '<div class="warning">
						<h1>'.$lang['install']['error']['header'].'</h1>
						<p>
							'.$lang['install']['db']['error'].'<br /><br />
							<a href="install.php?step=1&lang='.$_GET['lang'].'">&lt;&lt; '.$lang['install']['back'].'</a>
						</p>
					</div>';
		}
	}
	
	elseif (2 == $_GET['step'])
	{
		
		$html .= '<h1>'.$lang['install']['step'].' 2 / 4: '.$lang['install']['admin']['header'].'</h1>
				<div id="content">
					<p>
						'.$lang['install']['admin']['text'].'
					</p>';
		
		$html .= '<form method="post" action="install.php?step=3&lang='.$_GET['lang'].'">
						<input type="hidden" name="install_db_host" value="'.$_SESSION['install']['db']['host'].'" />
						<input type="hidden" name="install_db_name" value="'.$_SESSION['install']['db']['name'].'" />
						<input type="hidden" name="install_db_user" value="'.$_SESSION['install']['db']['user'].'" />
						<input type="hidden" name="install_db_password" value="'.$_SESSION['install']['db']['password'].'" />
						<fieldset>
							<legend><img src="images/icons/user_gray.png" alt="icon" /> '.$lang['install']['admin']['header'].'</legend>
							<div class="inputGroup">
								<div class="inputName">
									<label for="install_admin_login">
										'.$lang['install']['admin']['name'].'
									</label>
								</div>
								<div class="inputField">
									<input type="text" name="install_admin_login" id="install_admin_login"';
		
		isset($_SESSION['install']['admin']['login']) ? $html .= ' value="'.$_SESSION['install']['admin']['login'].'"' : null;
		
		$html .= ' />
									<div class="inputDesc">
										<label for="install_admin_login">
											'.$lang['install']['admin']['nameinfo'].'
										</label>
									</div>
								</div>
							</div>
							<div class="inputGroup">
								<div class="inputName">
									<label for="install_admin_password">
										'.$lang['install']['admin']['pass'].'
									</label>
								</div>
								<div class="inputField">
									<input type="text" name="install_admin_password" id="install_admin_password" />
									<div class="inputDesc">
										<label for="install_admin_password">
											'.$lang['install']['admin']['passinfo'].'
										</label>
									</div>
								</div>
							</div>
							<div class="inputGroup">
								<div class="inputName">
									<label for="install_admin_password_check">
										'.$lang['install']['admin']['passconfirm'].'
									</label>
								</div>
								<div class="inputField">
									<input type="text" name="install_admin_password_check" id="install_admin_password_check" />
									<div class="inputDesc">
										<label for="install_admin_password_check">
											'.$lang['install']['admin']['passconfirminfo'].'
										</label>
									</div>
								</div>
							</div>
						</fieldset>
						<div>
							<input type="submit" value="'.$lang['install']['continue'].'" />
						</div>
					</form>';
	}
	
	elseif (3 == $_GET['step'])
	{
		
		$html .= '<h1>'.$lang['install']['step'].' 3 / 4: '.$lang['install']['guild']['header'].'</h1>
				<div id="content">
					<p>
						'.$lang['install']['guild']['text'].'
					</p>';
		
		// Prüfen, ob die Administratordaten korrekt eingegeben wurden
		if (
			(
				isset($_POST['install_admin_login'])
				&& '' != $_POST['install_admin_login']
				&& isset($_POST['install_admin_password'])
				&& '' != $_POST['install_admin_password']
				&& isset($_POST['install_admin_password_check'])
				&& '' != $_POST['install_admin_password_check']
			)
				|| isset($_SESSION['install']['admin'])
			)
		{
			if (
				(
					(
						isset($_POST['install_admin_password'])
						&& isset($_POST['install_admin_password_check'])
					)
					&& $_POST['install_admin_password'] == $_POST['install_admin_password_check']
				)
				|| isset($_SESSION['install']['admin'])
				)
			{
				
				if (!isset($_SESSION['install']['admin']))
				{
					$_SESSION['install']['admin']['login'] = $_POST['install_admin_login'];
					$_SESSION['install']['admin']['password'] = md5(sha1($_POST['install_admin_password']));
				}
				
				$html .= '<form method="post" action="install.php?step=4&lang='.$_GET['lang'].'">
						<input type="hidden" name="install_db_host" value="'.$_SESSION['install']['db']['host'].'" />
						<input type="hidden" name="install_db_name" value="'.$_SESSION['install']['db']['name'].'" />
						<input type="hidden" name="install_db_user" value="'.$_SESSION['install']['db']['user'].'" />
						<input type="hidden" name="install_db_password" value="'.$_SESSION['install']['db']['password'].'" />
						<input type="hidden" name="install_admin_login" value="'.$_SESSION['install']['admin']['login'].'" />
						<input type="hidden" name="install_admin_password" value="'.$_SESSION['install']['admin']['password'].'" />
						<fieldset>
							<legend><img src="images/icons/group.png" alt="icon" /> '.$lang['install']['guild']['header'].'</legend>
							<div class="inputGroup">
								<div class="inputName">
									<label for="install_guild_name">
										'.$lang['install']['guild']['name'].'
									</label>
								</div>
								<div class="inputField">
									<input type="text" name="install_guild_name" id="install_guild_name"';
			
			isset($_SESSION['install']['guild']['name']) ? $html .= ' value="'.$_SESSION['install']['guild']['name'].'"' : null;
			
			$html .= ' />
									<div class="inputDesc">
										<label for="install_guild_name">
											'.$lang['install']['guild']['nameinfo'].'
										</label>
									</div>
								</div>
							</div>
							<div class="inputGroup">
								<div class="inputName">
									<label for="install_guild_realm">
										'.$lang['install']['guild']['realm'].'
									</label>
								</div>
								<div class="inputField">
									<input type="text" name="install_guild_realm" id="install_guild_realm" ';
			
			isset($_SESSION['install']['guild']['realm']) ? $html .= ' value="'.$_SESSION['install']['guild']['realm'].'"' : null;
			
			$html .= ' />
									<div class="inputDesc">
										<label for="install_guild_realm">
											'.$lang['install']['guild']['realminfo'].'
										</label>
									</div>
								</div>
							</div>
							<div class="inputGroup">
								<div class="inputName">
									<label for="install_guild_region">
										'.$lang['install']['guild']['region'].'
									</label>
								</div>
								<div class="inputField">
									<select name="install_guild_region" id="install_guild_region" size="1">
										<option value="eu" selected="selected">EU</option>
										<option value="us">US</option>
										<option value="tw">TW</option>
										<option value="cn">CN</option>
									</select>
									<div class="inputDesc">
										<label for="install_guild_region">
											'.$lang['install']['guild']['regioninfo'].'
										</label>
									</div>
								</div>
							</div>
						</fieldset>
						<div>
							<input type="submit" value="'.$lang['install']['continue'].'" />
						</div>
					</form>';
			}
			else
			{
				$html .= '<div class="warning">
						<h1>'.$lang['install']['error']['header'].'</h1>
						<p>
							'.$lang['install']['error']['passconfirm'].'<br /><br />
							<a href="install.php?step=2&lang='.$_GET['lang'].'">&lt;&lt; '.$lang['install']['back'].'</a>
						</p>
					</div>';
			}
		}
		else
		{
			$html .= '<div class="warning">
						<h1>'.$lang['install']['error']['header'].'</h1>
						<p>
							'.$lang['install']['error']['notempty'].'<br /><br />
							<a href="install.php?step=2&lang='.$_GET['lang'].'">&lt;&lt; Zurück</a>
						</p>
					</div>';
		}
	}
	
	elseif (4 == $_GET['step'])
	{
		$html .= '<h1>'.$lang['install']['step'].' 4 / 4: '.$lang['install']['run']['header'].'</h1>
				<div id="content">
					<p>
						'.$lang['install']['run']['text'].'
					</p>';
		
		// Prüfen, ob die Gildendaten korrekt eingegeben wurden
		if (isset($_POST['install_guild_name']) && '' != $_POST['install_guild_name'] && isset($_POST['install_guild_realm']) && '' != $_POST['install_guild_realm'] && isset($_POST['install_guild_region']) && '' != $_POST['install_guild_region'])
		{
			if (!isset($_SESSION['install']['guild']))
			{
				$_SESSION['install']['guild']['name'] = $_POST['install_guild_name'];
				$_SESSION['install']['guild']['realm'] = $_POST['install_guild_realm'];
				$_SESSION['install']['guild']['region'] = $_POST['install_guild_region'];
			}
			
			$html .= '<form method="post" action="index.php">
						<fieldset>
							<legend><img src="images/icons/hourglass.png" alt="icon" /> '.$lang['install']['run']['header'].'</legend>';
			
			// Datenbank beschreiben
			try
			{
				// Verbindung aufbauen
				$db = new PDO('mysql:dbname='.$_SESSION['install']['db']['name'].';host='.$_SESSION['install']['db']['host'], $_SESSION['install']['db']['user'], $_SESSION['install']['db']['password']);
				
				$html .= '<ul><li class="correct">'.$lang['install']['run']['connection'].'</li>';
				
				// Struktur erstellen
				$db->exec("SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'");
				$db->exec("SET AUTOCOMMIT=0");
				$db->exec("START TRANSACTION");
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_actionlog` (`id` int(11) NOT NULL auto_increment, `date` timestamp NOT NULL default CURRENT_TIMESTAMP, `actor` mediumint(9) NOT NULL, `victim` mediumint(9) NOT NULL, `action` tinytext collate utf8_unicode_ci NOT NULL, `values` tinytext collate utf8_unicode_ci NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['actionlog'].'</li>';
				
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_config` (`id` smallint(6) NOT NULL auto_increment, `config_type` varchar(255) collate utf8_unicode_ci NOT NULL, `config_value` varchar(255) collate utf8_unicode_ci NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['config'].'</li>';
				
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_events` (`id` smallint(6) NOT NULL auto_increment, `type` smallint(6) NOT NULL, `date` date NOT NULL, `created_id` smallint(6) NOT NULL, `comment` text collate utf8_unicode_ci NOT NULL, `value` mediumint(9) NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['event'].'</li>';
				
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_event_attends` (`id` int(11) NOT NULL auto_increment, `event_id` smallint(6) NOT NULL, `user_id` smallint(6) NOT NULL, `value` mediumint(9) NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['attend'].'</li>';
				
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_event_types` (`id` smallint(6) NOT NULL auto_increment, `name` varchar(200) collate utf8_unicode_ci NOT NULL, `icon` varchar(50) collate utf8_unicode_ci NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['eventtypes'].'</li>';
				
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_itemcache` (`item_id` int(6) NOT NULL, `quality` tinyint(1) NOT NULL, `name_en` varchar(255) collate utf8_unicode_ci NOT NULL, `name_de` varchar(255) collate utf8_unicode_ci NOT NULL, `name_es` varchar(255) collate utf8_unicode_ci NOT NULL, `name_fr` varchar(255) collate utf8_unicode_ci NOT NULL, `name_ru` varchar(255) collate utf8_unicode_ci NOT NULL, PRIMARY KEY  (`item_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['itemcache'].'</li>';
				
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_items` (`id` smallint(6) NOT NULL auto_increment, `user_id` smallint(6) NOT NULL, `item_id` int(5) NOT NULL default '0', `item_value` mediumint(9) NOT NULL default '0', PRIMARY KEY  (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['item'].'</li>';
				
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_loots` (`id` smallint(6) NOT NULL auto_increment, `event_id` smallint(6) NOT NULL, `looter_id` smallint(6) NOT NULL, `item_id` mediumint(9) NOT NULL, `value` smallint(6) NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['loot'].'</li>';
				
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_reqs` (`id` smallint(6) NOT NULL auto_increment, `type` smallint(6) NOT NULL, `date_sent` date NOT NULL default '0000-00-00', `date_read` date NOT NULL default '0000-00-00', `date_edit` date NOT NULL default '0000-00-00', `sent_id` smallint(6) NOT NULL, `read_id` smallint(6) NOT NULL, `edit_id` smallint(6) NOT NULL, `req_values` tinytext collate utf8_unicode_ci NOT NULL, `req_msg` text collate utf8_unicode_ci NOT NULL, `req_answer` text collate utf8_unicode_ci NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['reqs'].'</li>';
				
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_req_types` (`id` smallint(6) NOT NULL auto_increment, `name` varchar(255) collate utf8_unicode_ci NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['reqtypes'].'</li>';
				
				$db->exec("CREATE TABLE IF NOT EXISTS `ilp_users` (`id` smallint(6) NOT NULL auto_increment, `login` varchar(50) collate utf8_unicode_ci NOT NULL, `pw` varchar(40) collate utf8_unicode_ci NOT NULL, `email` varchar(100) collate utf8_unicode_ci NOT NULL, `locked` tinyint(1) NOT NULL default '1', `officer` tinyint(1) NOT NULL default '0', `char` tinytext collate utf8_unicode_ci NOT NULL, `lang` varchar(50) collate utf8_unicode_ci NOT NULL default 'deDE-informal', `tooltip_locale` varchar(2) collate utf8_unicode_ci NOT NULL default 'de', PRIMARY KEY  (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
				
				$html .= '<li class="correct">'.$lang['install']['run']['user'].'</li>';
				
				
				// Standarddaten schreiben
				$db->exec("INSERT INTO `ilp_config` VALUES(1, 'locale', '".$_GET['lang']."')");
				$db->exec("INSERT INTO `ilp_config` VALUES(2, 'lang_tooltip', '".substr($_GET['lang'], 0, 2)."')");
				$db->exec("INSERT INTO `ilp_config` VALUES(6, 'default_slots', '5')");
				$db->exec("INSERT INTO `ilp_config` VALUES(11, 'last_loots', '10')");
				$db->exec("INSERT INTO `ilp_config` VALUES(12, 'last_events', '8')");
				$db->exec("INSERT INTO `ilp_config` VALUES(15, 'locked', '0')");
				
				$html .= '<li class="correct">'.$lang['install']['run']['savedconfig'].'</li>';
				
				$db->exec("INSERT INTO `ilp_users` VALUES(0, 'Gast', '', '', 1, 0, 'a:3:{s:4:\"name\";s:4:\"Gast\";s:5:\"class\";s:4:\"none\";s:4:\"spec\";s:1:\"0\";}', '".$_GET['lang']."', '".substr($_GET['lang'], 0, 2)."')");
				
				$html .= '<li class="correct">'.$lang['install']['run']['savedguest'].'</li>';
				
				$db->exec("INSERT INTO `ilp_req_types` VALUES(1, '".$lang['reqs']['type']['item']."')");
				$db->exec("INSERT INTO `ilp_req_types` VALUES(2, '".$lang['reqs']['type']['char']."')");
				
				$html .= '<li class="correct">'.$lang['install']['run']['savedreqtypes'].'</li>';
				
				// Bei der Installation angegebene Daten schreiben
				$prep_conf_guild_name	= $db->prepare("INSERT INTO `ilp_config` VALUES(3, 'guild_name', ?)");
				$prep_conf_guild_realm	= $db->prepare("INSERT INTO `ilp_config` VALUES(4, 'guild_realm', ?)");
				$prep_conf_guild_region = $db->prepare("INSERT INTO `ilp_config` VALUES(5, 'guild_region', ?)");
				$prep_user_admin		= $db->prepare("INSERT INTO `ilp_users` VALUES(1, ?, ?, '', 0, 1, 'a:3:{s:4:\"name\";s:13:\"Administrator\";s:5:\"class\";s:4:\"none\";s:4:\"spec\";s:1:\"0\";}', '".$_GET['lang']."', '".substr($_GET['lang'], 0, 2)."')");
				
				// Benutzerdaten schreiben
				$prep_conf_guild_name->execute(array($_SESSION['install']['guild']['name']));
				$prep_conf_guild_realm->execute(array($_SESSION['install']['guild']['realm']));
				$prep_conf_guild_region->execute(array($_SESSION['install']['guild']['region']));
				
				$html .= '<li class="correct">'.$lang['install']['run']['savedguild'].'</li>';
				
				$prep_user_admin->execute(array($_SESSION['install']['admin']['login'], $_SESSION['install']['admin']['password']));
				
				$html .= '<li class="correct">'.$lang['install']['run']['savedadmin'].'</li>';
				
				$db->exec("INSERT INTO `ilp_config` VALUES(16, 'ilpversion_releasedate', '20100505')");
				$db->exec("INSERT INTO `ilp_config` VALUES(17, 'ilpversion_id', '2.2')");
				
				$html .= '<li class="correct">'.$lang['install']['run']['savedversion'].'</li>';
				
				// Datenbankdatei erstellen
				if (false != fopen(BASEDIR.'lib/lib.config.db.php', 'w'))
				{
					$file = fopen(BASEDIR.'lib/lib.config.db.php', 'w');
					
					$write = fwrite($file, '<?php
$db = new PDO(\'mysql:dbname='.$_SESSION['install']['db']['name'].';host=localhost\', \''.$_SESSION['install']['db']['user'].'\', \''.$_SESSION['install']['db']['password'].'\');
?>');
				}
				else
				{
					$html .= '<li class="warning">'.$lang['install']['error']['chmod'].'
					<strong>'.BASEDIR.'lib/lib.config.db.php</strong>:<br /><br />
					<textarea cols="75" rows="3">&lt;?php
$db = new PDO(\'mysql:dbname='.$_SESSION['install']['db']['name'].';host=localhost\', \''.$_SESSION['install']['db']['user'].'\', \''.$_SESSION['install']['db']['password'].'\');
?&gt;</textarea>';
				}
				
				$html .= '</ul>
						<p>
							'.$lang['install']['success'][0].'
						</p>
						<p>
							'.$lang['install']['success'][1].'
						</p>
						</fieldset>
						<div>
							<input type="submit" value="'.$lang['install']['finish'].'" />
						</div>
					</form>';
			}
			catch (PDOException $e)
			{
				$html .= '<div class="warning">
						<h1>'.$lang['install']['error']['header'].'</h1>
						<p>
							'.$lang['install']['error']['write'].'<br /><br />
							'.$e->getMessage().'
						</p>
						<pre style="color: gray; padding: 0 0 1ex 3ex; font-size: 11px;">'.$e->getTraceAsString().'</pre>
					</div>
				</fieldset>
			</form>';
			}
		}
		else
		{
			$html .= '<div class="warning">
						<h1>'.$lang['install']['error']['header'].'</h1>
						<p>
							'.$lang['install']['error']['notempty'].'<br /><br />
							<a href="install.php?step=3&lang='.$_GET['lang'].'">&lt;&lt; '.$lang['install']['back'].'</a>
						</p>
					</div>';
		}
	}
}

$html .= '</div>
			</div>
		</div>
	</body>
</html>
';

echo $html;
?>
Return current item: iLP System