<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Pratik Setup</title>
</head>

<body>
<div style="text-align: center;">
<div style="margin: auto;display: inline-block;text-align: left;border: 1px solid #cdcdcd;padding: 10px;border-radius: 5px;">
<?php if(is_file(dirname(__FILE__).'/config.php')){
	echo ("Kurulum daha Önce Yapılmış. <a href='/pratik'>Yönetici Girişi</a>");
} else if(isset($_POST['create'])) {
	$data = $_POST['config'];
	include_once('pratik/Helpers/Pratik_db.php');
	$pratikDb = new pratikDb();
	$pratikDb->connect($data['DBHOST'], $data['DBUSER'], $data['DBPASS'], $data['DBNAME']);
	if($pratikDb)
	{
		
		$configFile = fopen("config.php", "w+") or die("Unable to open config.php file!");
		$config = "<?php
// PRATİK ---------------------------------------------------------------------
define('PRTK',dirname(__FILE__));
define('SUBFOLDER','/".trim($data['subfolder'])."');
define('ADMIN','admin');
define('THEME','default');
define('ADMINPATH', PRTK.'/theme'.'/'.ADMIN);
define('ADMINURL', SUBFOLDER.'/theme'.'/'.ADMIN);
define('SITEPATH', PRTK.'/theme'.'/'.THEME);
define('SITEURL', SUBFOLDER.'/theme'.'/'.THEME);
define('VIEWPATH', PRTK.'/theme'.'/'.ADMIN);
define('VIEWURL', SUBFOLDER.'/theme'.'/'.ADMIN);
define('WRITEURL', SUBFOLDER.'/writable/');
define('XMLPOSTSIZE', 262144);
define('WAIT', ".$data['WAIT'].");
define('IWAIT', ".$data['IWAIT'].");
define('DBHOST','".$data['DBHOST']."');
define('DBUSER','".$data['DBUSER']."');
define('DBPASS','".$data['DBPASS']."');
define('DBNAME','".$data['DBNAME']."');
define('DBPREFIX','".$data['DBPREFIX']."');
?>";
		fwrite($configFile, $config);
		fclose($configFile);
		// users table
		$pratikDb->query("CREATE TABLE IF NOT EXISTS `".$data['DBPREFIX']."users` (`id` INT NOT NULL AUTO_INCREMENT,  `code` varchar(16) NOT NULL,  `name` varchar(64) NOT NULL,
  `surname` varchar(64) NOT NULL,  `email` varchar(128) NOT NULL, `password` varchar(64) NOT NULL,  `birthdate` varchar(16) NOT NULL,  `phone` varchar(12) NOT NULL,
  `mobile` varchar(12) NOT NULL,  `alc` int(11) NOT NULL,  `state` tinyint(1) NOT NULL,  `image` varchar(255) NOT NULL , PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
		$pratikDb->query("CREATE TABLE IF NOT EXISTS `".$data['DBPREFIX']."users_values` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `owner` int(11) NOT NULL,  `key` varchar(35) NOT NULL,  `lang` varchar(5) NOT NULL,  `val` text NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
		$pratikDb->query("CREATE TABLE IF NOT EXISTS `".$data['DBPREFIX']."users_metas` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `owner` int(11) NOT NULL,  `key` varchar(35) NOT NULL,  `lang` varchar(5) NOT NULL,  `val` text NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
		$createuser = $pratikDb->query("INSERT INTO `".$data['DBPREFIX']."users` (`id`, `code`, `name`, `surname`, `email`, `password`, `birthdate`, `phone`, `mobile`, `alc`, `state`, `image`) VALUES
(1, '', 'ADMIN', 'ADMIN', '".$pratikDb->real_escape_string($data['email'])."', '".$pratikDb->real_escape_string($data['password'])."', '', '', '', 1, 1, '');");
		// settings table
		
	}
?>
Kurulum Tamamlandı :)
<?php } else { ?>
<form method="post" enctype="multipart/form-data" name="form1" id="form1" accept-charset="UTF-8">
  <table border="0" cellspacing="3">
    <tbody>
      <tr>
        <td colspan="3" align="center">PRATIK YAPILANDIRMA</td>
      </tr>
      <tr>
        <td>Site Yolu</td>
        <td>:</td>
        <td><input type="text" name="config[subfolder]" id="config[subfolder]"></td>
      </tr>
      <tr>
        <td>Veri Tabanı Sunucusu</td>
        <td>:</td>
        <td><input type="text" name="config[DBHOST]" id="config[DBHOST]"></td>
      </tr>
      <tr>
        <td>Veri Tabanı Kullanıcı</td>
        <td>:</td>
        <td><input type="text" name="config[DBUSER]" id="config[DBUSER]"></td>
      </tr>
      <tr>
        <td>Veri Tabanı Şifre</td>
        <td>:</td>
        <td><input type="text" name="config[DBPASS]" id="config[DBPASS]"></td>
      </tr>
      <tr>
        <td>Veri Tabanı Adı</td>
        <td>:</td>
        <td><input type="text" name="config[DBNAME]" id="config[DBNAME]"></td>
      </tr>
      <tr>
        <td>Veri Tabanı Tablo Öneki</td>
        <td>:</td>
        <td><input type="text" name="config[DBPREFIX]" id="config[DBPREFIX]"></td>
      </tr>
      <tr>
        <td>Dahili Bekleme</td>
        <td>:</td>
        <td><input name="config[IWAIT]" type="text" id="config[IWAIT]" value="0"></td>
      </tr>
      <tr>
        <td>Java Bekleme</td>
        <td>:</td>
        <td><input name="config[WAIT]" type="text" id="config[WAIT]" value="0"></td>
      </tr>
      <tr>
        <td>Kullanıcı Emaili</td>
        <td>:</td>
        <td><input type="text" name="config[email]" id="config[email]"></td>
      </tr>
      <tr>
        <td>Kullanıcı Şifresi</td>
        <td>:</td>
        <td><input type="text" name="config[password]" id="config[password]"></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>
        <input type="hidden" name="create">
        <input type="submit" name="submit" id="submit" value="Oluştur" >
        </td>
      </tr>
    </tbody>
  </table>
</form>
<?php } ?>
	</div>
	</div>
</body>
</html>
