* switch to 0.7.5-dev

* fix when config.local.php doesn't exist
* fix when reinstalling aac with samples already installed
* some optimisations to installation script
* forgot to fclose on config.local.php
This commit is contained in:
slawkens1 2017-12-24 13:00:14 +01:00
parent b83fb05b82
commit 4d690992ac
9 changed files with 67 additions and 17 deletions

View File

@ -26,7 +26,7 @@
session_start();
define('MYAAC', true);
define('MYAAC_VERSION', '0.7.4');
define('MYAAC_VERSION', '0.7.5-dev');
define('DATABASE_VERSION', 20);
define('TABLE_PREFIX', 'myaac_');
define('START_TIME', microtime(true));

View File

@ -56,7 +56,9 @@ else if(preg_match("/^(.*)\.(gif|jpg|png|jpeg|tiff|bmp|css|js|less|map|html|php|
exit;
}
require_once(BASE . 'config.local.php');
if(file_exists(BASE . 'config.local.php'))
require_once(BASE . 'config.local.php');
if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed']))
{
header('Location: ' . BASE_URL . 'install/');

View File

@ -5,7 +5,9 @@ require('../common.php');
require(SYSTEM . 'functions.php');
require(BASE . 'install/includes/functions.php');
require(BASE . 'install/includes/locale.php');
require(BASE . 'config.local.php');
if(file_exists(BASE . 'config.local.php'))
require(BASE . 'config.local.php');
// twig
require_once LIBS . 'Twig/Autoloader.php';
@ -31,15 +33,31 @@ if(!in_array($step, $steps)) // check if step is valid
die('ERROR: Unknown step.');
$errors = array();
if($step == 'database')
{
foreach($_POST['vars'] as $key => $value)
{
if($step == 'database') {
foreach($_SESSION as $key => $value) {
if(strpos($key, 'var_') === false || strpos($key, 'account') !== false || strpos($key, 'password') !== false) {
continue;
}
$key = str_replace('var_', '', $key);
if($key != 'usage' && empty($value))
{
$errors[] = $locale['please_fill_all'];
break;
}
else if($key == 'server_path')
{
$config['server_path'] = $value;
// take care of trailing slash at the end
if($config['server_path'][strlen($config['server_path']) - 1] != '/')
$config['server_path'] .= '/';
if(!file_exists($config['server_path'] . 'config.lua')) {
$errors[] = $locale['step_database_error_config'];
break;
}
}
else if($key == 'mail_admin' && !Validator::email($value))
{
$errors[] = $locale['step_config_mail_admin_error'];
@ -56,6 +74,16 @@ if($step == 'database')
$step = 'config';
}
}
else if($step == 'admin') {
$config_failed = true;
if(file_exists(BASE . 'config.local.php') && isset($config['installed']) && $config['installed'] && isset($_SESSION['saved'])) {
$config_failed = false;
}
if($config_failed) {
$step = 'database';
}
}
else if($step == 'finish') {
// password
$password = $_SESSION['var_password'];

View File

@ -23,7 +23,7 @@ $failed = false;
// start validating
version_check($locale['step_requirements_php_version'], (PHP_VERSION_ID >= 50300), PHP_VERSION);
foreach(array('config.local.php', 'images/guilds', 'images/houses', 'images/gallery') as $value)
foreach(array('images/guilds', 'images/houses', 'images/gallery') as $value)
{
$perms = (int) substr(decoct(fileperms(BASE . $value)), 2);
version_check($locale['step_requirements_write_perms'] . ': ' . $value, $perms >= 660);

View File

@ -9,7 +9,7 @@ $clients_list = array(
770,
772,
780,
7920,
792,
800,
810,
821,

View File

@ -13,6 +13,8 @@ if(!isset($_SESSION['var_server_path'])) {
if(!$error) {
$content = "<?php";
$content .= PHP_EOL;
$content .= '// place for your configuration directives, so you can later easily update myaac';
$content .= PHP_EOL;
foreach($_SESSION as $key => $value)
{
if(strpos($key, 'var_') !== false)
@ -221,7 +223,7 @@ if(!$error) {
}
}
if(!$error && (!isset($_SESSION['saved']))) {
if(!$error) {
$content .= '$config[\'installed\'] = true;';
$content .= PHP_EOL;
@ -243,16 +245,21 @@ if(!$error) {
$content .= '$config[\'session_prefix\'] = \'myaac_' . generateRandomString(8, true, false, true, false) . '_\';';
$content .= PHP_EOL;
$content .= '$config[\'cache_prefix\'] = \'myaac_' . generateRandomString(8, true, false, true, false) . '_\';';
$content .= PHP_EOL;
$file = fopen(BASE . 'config.local.php', 'a+');
if($file) {
$saved = true;
if(!$error) {
$saved = file_put_contents(BASE . 'config.local.php', $content);
}
if($saved) {
if(!$error) {
fwrite($file, $content);
$_SESSION['saved'] = true;
}
}
else {
$_SESSION['config_content'] = $content;
unset($_SESSION['saved']);
$locale['step_database_error_file'] = str_replace('$FILE$', '<b>' . BASE . 'config.local.php</b>', $locale['step_database_error_file']);
warning($locale['step_database_error_file'] . '<br/>
<textarea cols="70" rows="10">' . $content . '</textarea>');

View File

@ -192,13 +192,26 @@ else {
error(Spells::getLastError());
}
if(count($highscores_ignored_ids) == 0) {
$query = $db->query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . ") ORDER BY `id`;");
$highscores_ignored_ids = array();
if($query->rowCount() > 0) {
foreach($query->fetchAll() as $result)
$highscores_ignored_ids[] = $result['id'];
}
else {
$highscores_ignored_ids[] = 0;
}
}
$content = PHP_EOL;
$content .= '$config[\'highscores_ids_hidden\'] = array(' . implode(', ', $highscores_ignored_ids) . ');';
$content .= PHP_EOL;
$file = fopen(BASE . 'config.local.php', 'a+');
if($file) {
fwrite($file, $content);
fclose($file);
}
else {
$locale['step_database_error_file'] = str_replace('$FILE$', '<b>' . BASE . 'config.local.php</b>', $locale['step_database_error_file']);

View File

@ -58,7 +58,7 @@ $locale['step_database'] = 'Import schema';
$locale['step_database_title'] = 'Import MySQL schema';
$locale['step_database_importing'] = 'Your database is MySQL. Importing schema now...';
$locale['step_database_error_path'] = 'Please specify server path.';
$locale['step_database_error_config'] = 'Cannot find config file. Is your server path correct? Go back and check again.';
$locale['step_database_error_config'] = 'Cannot find config.lua file. Is your server path correct? Go back and check again.';
$locale['step_database_error_database_empty'] = 'Cannot determine database type from config.lua. Your OTS is unsupported by this AAC.';
$locale['step_database_error_only_mysql'] = 'This AAC supports only MySQL. From your config file it seems that your OTS is using: $DATABASE_TYPE$ database. Please change your database to MySQL and then follow the installation again.';
$locale['step_database_error_table'] = 'Table $TABLE$ doesn\'t exist. Please import your OTS database schema first.';

View File

@ -58,7 +58,7 @@ $locale['step_database'] = 'Baza Danych';
$locale['step_database_title'] = 'Baza MySQL';
$locale['step_database_importing'] = 'Twoja baza to MySQL. Importowanie schematu...';
$locale['step_database_error_path'] = 'Proszę podać ścieżkę do serwera.';
$locale['step_database_error_config'] = 'Nie można znaleźć pliku config. Jest Twoja ścieżka do katalogu serwera poprawna? Wróć się i sprawdź ponownie.';
$locale['step_database_error_config'] = 'Nie można znaleźć pliku config.lua. Czy ścieżka do katalogu serwera jest poprawna? Wróć się i sprawdź ponownie.';
$locale['step_database_error_database_empty'] = 'Nie można wykryć typu bazy danych z pliku config.lua. Prawdopodobnie Twój OTS nie jest wspierany przez ten AAC.';
$locale['step_database_error_only_mysql'] = 'Ten AAC wspiera tylko bazy danych MySQL. Z Twojego pliku config wynika, że Twój serwera używa bazy: $DATABASE_TYPE$. Proszę zmienić typ bazy na MySQL i ponownie przystąpić do instalacji.';
$locale['step_database_error_table'] = 'Tabela $TABLE$ nie istnieje. Proszę najpierw zaimportować schemat bazy danych serwera OTS.';