From 817d58f1bea60d3b6c89a01331836387bdbb0227 Mon Sep 17 00:00:00 2001
From: VBoss
Date: Tue, 19 Jan 2016 01:35:20 +0100
Subject: [PATCH] Step 2 of installation process - creating config file
---
.gitignore | 1 +
App/Config/local.neon.temp | 67 ++++
.../Presenters/ConfigPresenter.php | 209 +++++++++++
.../Presenters/DataFormPresenter.php | 20 +
.../Templates/Config/default.latte | 15 +
.../Templates/DataForm/default.latte | 18 +
App/Templates/Homepage/default.latte | 0
www/install/data/constant_format.tpl | 296 ---------------
www/install/process.php | 96 +----
www/install/templates/config.tpl | 345 ------------------
10 files changed, 331 insertions(+), 736 deletions(-)
create mode 100644 App/Config/local.neon.temp
create mode 100644 App/InstallModule/Presenters/DataFormPresenter.php
create mode 100644 App/InstallModule/Templates/Config/default.latte
create mode 100644 App/InstallModule/Templates/DataForm/default.latte
delete mode 100644 App/Templates/Homepage/default.latte
delete mode 100644 www/install/data/constant_format.tpl
delete mode 100644 www/install/templates/config.tpl
diff --git a/.gitignore b/.gitignore
index f3b655f3..eeb42fcc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ Desktop.ini
.idea
/vendor/
+/App/Config/local.neon
diff --git a/App/Config/local.neon.temp b/App/Config/local.neon.temp
new file mode 100644
index 00000000..692eeb7b
--- /dev/null
+++ b/App/Config/local.neon.temp
@@ -0,0 +1,67 @@
+config:
+ serverName: %SERVERNAME%
+ timeZone: %STIMEZONE%
+
+ starDate: %SSTARTDATE%
+ starTime: %SSTARTTIME%
+
+ speed: %SPEED%
+
+ worldSize: %MAX%
+
+ troopSpeed: %INCSPEED%
+
+ evansionSpeed: %EVASIONSPEED%
+
+ traderCapacity: %TRADERCAP%
+
+ crannyCapacity: %CRANNYCAP%
+
+ trapMultiplier: %TRAPPERCAP%
+
+ storageMultiplier: %STORAGE_MULTIPLIER%
+
+ quest: %QUEST%
+
+ protection: %BEGINNER%
+
+ worldWonder: %WW%
+
+ showNatars: %SHOW_NATARS%
+
+ natarsMultiplier: %NATARS_UNITS%
+
+ natureRegeneration: %NATURE_REGTIME%
+
+ autoActivation: %ACTIVATE%
+
+ plusTime: %PLUS_TIME%
+
+ productionBoostTime: %PLUS_PRODUCTION%
+
+ medalInterval: %MEDALINTERVAL%
+
+ greatWorkShop: %GREAT_WKS%
+
+ tourTreshold: %TS_THRESHOLD%
+
+ registraionOpen: %REG_OPEN%
+
+ peace: %PEACE%
+
+ log: %LOG%
+
+ newsBoxOne: %BOX1%
+ newsBoxTwo: %BOX2%
+ newsBoxThree: %BOX3%
+
+ dibi:
+ host: %SSERVER%
+ username: %SUSER%
+ password: %SPASS%
+ database: %SDB%
+ lazy: TRUE
+
+ adminStatistics: %ARANK%
+ adminName: %ANAME%
+ adminEmail: %AEMAIL%
diff --git a/App/InstallModule/Presenters/ConfigPresenter.php b/App/InstallModule/Presenters/ConfigPresenter.php
index 22b4b010..48d787ee 100644
--- a/App/InstallModule/Presenters/ConfigPresenter.php
+++ b/App/InstallModule/Presenters/ConfigPresenter.php
@@ -17,4 +17,213 @@ public function renderDefault()
{
}
+
+
+ /**
+ * @return Nette\Application\UI\Form
+ */
+ protected function createComponentConfigForm()
+ {
+ $form = new Nette\Application\UI\Form();
+
+ $form->addGroup('Server related');
+
+ $form->addText('ServerName', 'Server name')
+ ->setRequired();
+
+ $form->addSelect('timeZone', 'Time zone', [
+ 'Africa',
+ 'America',
+ 'Antarctica',
+ 'Arctic',
+ 'Asia',
+ 'Atlantic',
+ 'Australia',
+ 'Europe (Bucharest)',
+ 'Europe (London)',
+ 'Indian',
+ 'Pacific',
+ ]);
+
+ $form->addText('speed', 'Speed')
+ ->setDefaultValue(1);
+
+ $form->addText('troopSpeed', 'Troop speed')
+ ->setDefaultValue(1);
+
+ $form->addText('evasionSpeed', 'Evasion speed')
+ ->setDefaultValue(1);
+
+ $form->addText('traderMultiplier', 'Trader multiplier')
+ ->setDefaultValue(1);
+
+ $form->addText('crannyMultiplier', 'Cranny multiplier')
+ ->setDefaultValue(1);
+
+ $form->addText('storageMultiplier', 'Storage multiplier')
+ ->setDefaultValue(1);
+
+ $form->addText('trapMultiplier', 'Trap multiplier')
+ ->setDefaultValue(1);
+
+ $form->addText('natarMultiplier', 'Natar multiplier')
+ ->setDefaultValue(1);
+
+ $form->addText('worldSize', 'World size (square)')
+ ->setDefaultValue(100);
+
+ $form->addCheckbox('registrationOpen', 'Open registrations')
+ ->setDefaultValue(TRUE);
+
+ $form->addSelect('beginnerProtection', 'Beginner protection', [
+ Nette\Utils\DateTime::HOUR * 2 => '2 Hours',
+ Nette\Utils\DateTime::HOUR * 6 => '6 Hour',
+ Nette\Utils\DateTime::HOUR * 12 => '12 Hour',
+ Nette\Utils\DateTime::DAY * 1 => '1 Day',
+ Nette\Utils\DateTime::DAY * 2 => '2 Days',
+ Nette\Utils\DateTime::DAY * 3 => '3 Days',
+ Nette\Utils\DateTime::DAY * 7 => '7 Days',
+ ]);
+
+ $form->addSelect('plusLength', 'Plus length', [
+ Nette\Utils\DateTime::HOUR * 12 => '12 Hour',
+ Nette\Utils\DateTime::DAY * 1 => '1 Day',
+ Nette\Utils\DateTime::DAY * 2 => '2 Days',
+ Nette\Utils\DateTime::DAY * 3 => '3 Days',
+ Nette\Utils\DateTime::DAY * 7 => '7 Days',
+ ]);
+
+ $form->addSelect('productionBoostLength', 'Production boost length', [
+ Nette\Utils\DateTime::HOUR * 12 => '12 Hour',
+ Nette\Utils\DateTime::DAY * 1 => '1 Day',
+ Nette\Utils\DateTime::DAY * 2 => '2 Days',
+ Nette\Utils\DateTime::DAY * 3 => '3 Days',
+ Nette\Utils\DateTime::DAY * 7 => '7 Days',
+ ]);
+
+ $form->addSelect('natureRegeneration', 'Nature troops regeneration time', [
+ Nette\Utils\DateTime::HOUR * 2 => '2 Hours',
+ Nette\Utils\DateTime::HOUR * 6 => '6 Hour',
+ Nette\Utils\DateTime::HOUR * 12 => '12 Hour',
+ Nette\Utils\DateTime::DAY * 1 => '1 Day',
+ ]);
+
+ $form->addSelect('medalInterval', 'Medal interval', [
+ Nette\Utils\DateTime::DAY * 1 => '1 Day',
+ Nette\Utils\DateTime::DAY * 2 => '2 Days',
+ Nette\Utils\DateTime::DAY * 3 => '3 Days',
+ Nette\Utils\DateTime::DAY * 7 => '7 Days',
+ ]);
+
+ $form->addText('tourThreshold', 'Tour threshold')
+ ->setDefaultValue(20);
+
+ $form->addCheckbox('greatWorkshop', 'Great workshop');
+
+ $form->addCheckbox('worldWonder', 'World wonder');
+
+ $form->addCheckbox('showNatarStatistics', 'Show natars in statistics');
+
+ $form->addSelect('peaceSystem', 'Peace system', [
+ 'None',
+ 'Normal',
+ 'Christmas',
+ 'New year',
+ 'Easter',
+ ]);
+
+ $form->addGroup('Admin account');
+
+ $form->addText('adminName', 'Admin name');
+ $form->addText('adminEmail', 'Admin email');
+
+ $form->addCheckbox('showAdminStatistics', 'Show admin in statistics');
+
+ $form->addGroup('Sql related');
+
+ $form->addText('hostname', 'Hostname');
+ $form->addText('username', 'Username');
+ $form->addPassword('password', 'Password');
+ $form->addText('dbName', 'Database name');
+
+ $form->addGroup('Other');
+ $form->addCheckbox('newsBoxOne', 'Newsbox 1');
+ $form->addCheckbox('newsBoxTwo', 'Newsbox 2');
+ $form->addCheckbox('newsBoxThree', 'Newsbox 3');
+
+ $form->addCheckbox('log', 'Log actions');
+
+ $form->addCheckbox('quest', 'Enable quests');
+ $form->addCheckbox('questExtended', 'Enable extended quests');
+
+ $form->addCheckbox('autoActivate', 'Auto activate accounts');
+
+ $form->addGroup('Start time');
+ $form->addText('startDate', 'Start date Year-month-day format')
+ ->setDefaultValue(Nette\Utils\DateTime::from('now')->format('Y-m-d'));
+ $form->addText('startTime', 'Start time')
+ ->setDefaultValue(Nette\Utils\DateTime::from('now')->format('H:i'));
+
+ $form->onSuccess[] = [$this, 'processConfig'];
+
+ $form->addSubmit('Next', 'Next');
+
+ return $form;
+ }
+
+
+ /**
+ * @param Nette\Application\UI\Form $form
+ */
+ public function processConfig(Nette\Application\UI\Form $form)
+ {
+ $data = $form->getValues();
+ $text = file_get_contents(__DIR__ . '/../../Config/local.neon.temp');
+
+ $text = preg_replace("'%SERVERNAME%'", $data->ServerName, $text);
+ $text = preg_replace("'%STIMEZONE%'", $data->timeZone, $text);
+ $text = preg_replace("'%SSTARTDATE%'", $data->startDate, $text);
+ $text = preg_replace("'%SSTARTTIME%'", $data->startTime, $text);
+ $text = preg_replace("'%SPEED%'", $data->speed, $text);
+ $text = preg_replace("'%INCSPEED%'", $data->troopSpeed, $text);
+ $text = preg_replace("'%EVASIONSPEED%'", $data->evasionSpeed, $text);
+ $text = preg_replace("'%TRADERCAP%'", $data->traderMultiplier, $text);
+ $text = preg_replace("'%CRANNYCAP%'", $data->crannyMultiplier, $text);
+ $text = preg_replace("'%TRAPPERCAP%'", $data->trapMultiplier, $text);
+ $text = preg_replace("'%STORAGE_MULTIPLIER%'", $data->storageMultiplier, $text);
+ $text = preg_replace("'%MAX%'", $data->worldSize, $text);
+
+ $text = preg_replace("'%SSERVER%'", $data->hostname, $text);
+ $text = preg_replace("'%SUSER%'", $data->username, $text);
+ $text = preg_replace("'%SPASS%'", $data->password, $text);
+ $text = preg_replace("'%SDB%'", $data->dbName, $text);
+
+ $text = preg_replace("'%AEMAIL%'", $data->adminEmail, $text);
+ $text = preg_replace("'%ANAME%'", $data->adminName, $text);
+ $text = preg_replace("'%LOG%'", $data->log, $text);
+ $text = preg_replace("'%ACTIVATE%'", $data->autoActivate, $text);
+ $text = preg_replace("'%ARANK%'", $data->showAdminStatistics, $text);
+ $text = preg_replace("'%QUEST%'", $data->quest, $text);
+ $text = preg_replace("'%BEGINNER%'", $data->beginnerProtection, $text);
+
+ $text = preg_replace("'%BOX1%'", $data->newsBoxOne, $text);
+ $text = preg_replace("'%BOX2%'", $data->newsBoxTwo, $text);
+ $text = preg_replace("'%BOX3%'", $data->newsBoxThree, $text);
+
+ $text = preg_replace("'%PLUS_TIME%'", $data->plusLength, $text);
+ $text = preg_replace("'%PLUS_PRODUCTION%'", $data->productionBoostLength, $text);
+ $text = preg_replace("'%MEDALINTERVAL%'", $data->medalInterval, $text);
+ $text = preg_replace("'%GREAT_WKS%'", $data->greatWorkshop, $text);
+ $text = preg_replace("'%TS_THRESHOLD%'", $data->tourThreshold, $text);
+ $text = preg_replace("'%WW%'", $data->worldWonder, $text);
+ $text = preg_replace("'%SHOW_NATARS%'", $data->showNatarStatistics, $text);
+ $text = preg_replace("'%NATARS_UNITS%'", $data->natarMultiplier, $text);
+ $text = preg_replace("'%NATURE_REGTIME%'", $data->natureRegeneration, $text);
+ $text = preg_replace("'%REG_OPEN%'", $data->registrationOpen, $text);
+ $text = preg_replace("'%PEACE%'", $data->peaceSystem, $text);
+
+ file_put_contents(__DIR__ . '/../../Config/local.neon', $text);
+
+ $this->redirect('Install:DataForm:default');
+ }
}
\ No newline at end of file
diff --git a/App/InstallModule/Presenters/DataFormPresenter.php b/App/InstallModule/Presenters/DataFormPresenter.php
new file mode 100644
index 00000000..222b6d24
--- /dev/null
+++ b/App/InstallModule/Presenters/DataFormPresenter.php
@@ -0,0 +1,20 @@
+
+ Step 2 from 7
+
+
+ {control configForm}
+{/block}
\ No newline at end of file
diff --git a/App/InstallModule/Templates/DataForm/default.latte b/App/InstallModule/Templates/DataForm/default.latte
new file mode 100644
index 00000000..e9586799
--- /dev/null
+++ b/App/InstallModule/Templates/DataForm/default.latte
@@ -0,0 +1,18 @@
+{block customJS}
+ {include ../script.tpl}
+{/block}
+
+{block menu}
+ {include ../menu.latte}
+{/block}
+
+{block content}
+
+ Step 3 from 7
+
+
+
+
+ Next
+
+{/block}
\ No newline at end of file
diff --git a/App/Templates/Homepage/default.latte b/App/Templates/Homepage/default.latte
deleted file mode 100644
index e69de29b..00000000
diff --git a/www/install/data/constant_format.tpl b/www/install/data/constant_format.tpl
deleted file mode 100644
index 942588b7..00000000
--- a/www/install/data/constant_format.tpl
+++ /dev/null
@@ -1,296 +0,0 @@
-
diff --git a/www/install/process.php b/www/install/process.php
index 21031210..03c92676 100644
--- a/www/install/process.php
+++ b/www/install/process.php
@@ -1,14 +1,5 @@
constForm();
+
} else
if(isset($_POST['substruc'])) {
$this->createStruc();
@@ -31,91 +22,6 @@ function Process() {
}
}
- function constForm() {
- $myFile = "include/constant.php";
- $fh = fopen($myFile, 'w') or die("
Can't open file: install\include\constant.php");
- $text = file_get_contents("data/constant_format.tpl");
- $text = preg_replace("'%SERVERNAME%'", $_POST['servername'], $text);
- $text = preg_replace("'%SSTARTDATE%'", $_POST['start_date'], $text);
- $text = preg_replace("'%SSTARTTIME%'", $_POST['start_time'], $text);
- $tz = explode(",",$_POST['tzone']);
- $text = preg_replace("'%STIMEZONE%'", $tz[1], $text);
- $text = preg_replace("'%LANG%'", $_POST['lang'], $text);
- $text = preg_replace("'%SPEED%'", $_POST['speed'], $text);
- $text = preg_replace("'%INCSPEED%'", $_POST['incspeed'], $text);
- $text = preg_replace("'%EVASIONSPEED%'", $_POST['evasionspeed'], $text);
- $text = preg_replace("'%TRADERCAP%'", $_POST['tradercap'], $text);
- $text = preg_replace("'%CRANNYCAP%'", $_POST['crannycap'], $text);
- $text = preg_replace("'%TRAPPERCAP%'", $_POST['trappercap'], $text);
- $text = preg_replace("'%STORAGE_MULTIPLIER%'", $_POST['storage_multiplier'], $text);
- $text = preg_replace("'%UTRACK%'", $_POST['trackusers'], $text);
- $text = preg_replace("'%UTOUT%'", $_POST['timeout'], $text);
- $text = preg_replace("'%AUTOD%'", $_POST['autodel'], $text);
- $text = preg_replace("'%AUTODT%'", $_POST['autodeltime'], $text);
- $text = preg_replace("'%MAX%'", $_POST['wmax'], $text);
- $text = preg_replace("'%GP%'", $_POST['gpack'], $text);
- $text = preg_replace("'%SSERVER%'", $_POST['sserver'], $text);
- $text = preg_replace("'%SUSER%'", $_POST['suser'], $text);
- $text = preg_replace("'%SPASS%'", $_POST['spass'], $text);
- $text = preg_replace("'%SDB%'", $_POST['sdb'], $text);
- $text = preg_replace("'%PREFIX%'", $_POST['prefix'], $text);
- $text = preg_replace("'%CONNECTT%'", $_POST['connectt'], $text);
- $text = preg_replace("'%AEMAIL%'", $_POST['aemail'], $text);
- $text = preg_replace("'%ANAME%'", $_POST['aname'], $text);
- $text = preg_replace("'%SUBDOM%'", $_POST['subdom'], $text);
- $text = preg_replace("'%LOGBUILD%'", $_POST['log_build'], $text);
- $text = preg_replace("'%LOGTECH%'", $_POST['log_tech'], $text);
- $text = preg_replace("'%LOGLOGIN%'", $_POST['log_login'], $text);
- $text = preg_replace("'%LOGGOLDFIN%'", $_POST['log_gold_fin'], $text);
- $text = preg_replace("'%LOGADMIN%'", $_POST['log_admin'], $text);
- $text = preg_replace("'%LOGWAR%'", $_POST['log_war'], $text);
- $text = preg_replace("'%LOGMARKET%'", $_POST['log_market'], $text);
- $text = preg_replace("'%LOGILLEGAL%'", $_POST['log_illegal'], $text);
- $text = preg_replace("'%MINUSERLENGTH%'", $_POST['userlength'], $text);
- $text = preg_replace("'%MINPASSLENGTH%'", $_POST['passlength'], $text);
- $text = preg_replace("'%SPECIALCHARS%'", $_POST['specialchars'], $text);
- $text = preg_replace("'%ACTIVATE%'", $_POST['activate'], $text);
- $text = preg_replace("'%ARANK%'", $_POST['admin_rank'], $text);
- $text = preg_replace("'%QUEST%'", $_POST['quest'], $text);
- $text = preg_replace("'%QTYPE%'", $_POST['qtype'], $text);
- $text = preg_replace("'%BEGINNER%'", $_POST['beginner'], $text);
- $text = preg_replace("'%STARTTIME%'", time(), $text);
- $text = preg_replace("'%DOMAIN%'", $_POST['domain'], $text);
- $text = preg_replace("'%HOMEPAGE%'", $_POST['homepage'], $text);
- $text = preg_replace("'%SERVER%'", $_POST['server'], $text);
- $text = preg_replace("'%LIMIT_MAILBOX%'", $_POST['limit_mailbox'], $text);
- $text = preg_replace("'%MAX_MAILS%'", $_POST['max_mails'], $text);
- $text = preg_replace("'%DEMOLISH%'", $_POST['demolish'], $text);
- $text = preg_replace("'%BOX1%'", $_POST['box1'], $text);
- $text = preg_replace("'%BOX2%'", $_POST['box2'], $text);
- $text = preg_replace("'%BOX3%'", $_POST['box3'], $text);
- $text = preg_replace("'%VILLAGE_EXPAND%'", $_POST['village_expand'], $text);
- $text = preg_replace("'%ERRORREPORT%'", $_POST['error'], $text);
- $text = preg_replace("'%ERROR%'", $_POST['error'], $text);
- $text = preg_replace("'%GP_LOCATE%'", $_POST['gp_locate'], $text);
- $text = preg_replace("'%PLUS_TIME%'", $_POST['plus_time'], $text);
- $text = preg_replace("'%PLUS_PRODUCTION%'", $_POST['plus_production'], $text);
- $text = preg_replace("'%MEDALINTERVAL%'", $_POST['medalinterval'], $text);
- $text = preg_replace("'%GREAT_WKS%'", $_POST['great_wks'], $text);
- $text = preg_replace("'%TS_THRESHOLD%'", $_POST['ts_threshold'], $text);
- $text = preg_replace("'%WW%'", $_POST['ww'], $text);
- $text = preg_replace("'%SHOW_NATARS%'", $_POST['show_natars'], $text);
- $text = preg_replace("'%NATARS_UNITS%'", $_POST['natars_units'], $text);
- $text = preg_replace("'%NATURE_REGTIME%'", $_POST['nature_regtime'], $text);
- $text = preg_replace("'%T4_COMING%'", $_POST['t4_coming'], $text);
- $text = preg_replace("'%REG_OPEN%'", $_POST['reg_open'], $text);
- $text = preg_replace("'%PEACE%'", $_POST['peace'], $text);
-
- fwrite($fh, $text);
-
- if(file_exists("include/constant.php")) {
- header("Location: index.php?s=2");
- } else {
- header("Location: index.php?s=1&c=1");
- }
-
- fclose($fh);
- }
function createStruc() {
global $database;
diff --git a/www/install/templates/config.tpl b/www/install/templates/config.tpl
deleted file mode 100644
index ac8d3402..00000000
--- a/www/install/templates/config.tpl
+++ /dev/null
@@ -1,345 +0,0 @@
-Error creating constant.php check cmod.
";
-}
-?>
-
-
-
-
- ADMIN ACCOUNT
-
-
-
-
- SQL RELATED
-
-
-
-
-
-
-
-
-
-
- NEWSBOX OPTIONS
-
- Newsbox 1: | |
- Newsbox 2: | |
- Newsbox 3: | |
-
-
-
-
- LOG RELATED (You should disable them)
-
- Log Building: | |
- Log Tech: | |
- Log Login: | |
-
- Log Gold: | |
- Log Admin: | |
- Log War: | |
- Log Market: | |
- Log Illegal: | |
- Log : | |
-
-
-
-
- EXTRA OPTIONS
-
-
-
- Server Start Settings
-
-
-
-
-
-
-
-