* added faq management - add/edit/move/hide/delete from website

* moved install pages to twig
* load monsters and spells on installation of the AAC
This commit is contained in:
slawkens
2017-10-12 17:40:02 +02:00
parent 315e0400ff
commit f84ae88aa4
27 changed files with 683 additions and 361 deletions

View File

@@ -62,9 +62,9 @@ function next_buttons($previous = true, $next = true)
$ret .= '<input class="button" type="submit" onclick="document.getElementById(\'step\').value=\'' . $steps[$i + 1] . '\';" value="' . $locale['next'] . '" />';
*/
if($previous)
$ret .= '<input type="button" class="button" onclick="document.getElementById(\'step\').value=\'' . $steps[$i - 1] . '\'; this.form.submit();" value="' . $locale['previous'] . '" />';
$ret .= '<input type="button" class="button" onclick="document.getElementById(\'step\').value=\'' . $steps[$i - 1] . '\'; this.form.submit();" value="&laquo; ' . $locale['previous'] . '" />';
if($next)
$ret .= '<input type="button" class="button" onclick="document.getElementById(\'step\').value=\'' . $steps[$i + 1] . '\'; this.form.submit();" value="' . $locale['next'] . '" />';
$ret .= '<input type="button" class="button" onclick="document.getElementById(\'step\').value=\'' . $steps[$i + 1] . '\'; this.form.submit(); " value="' . $locale['next'] . ' &raquo;" />';
$ret .= '</div>';
return $ret;

View File

@@ -10,6 +10,16 @@ require(BASE . 'install/includes/functions.php');
require(BASE . 'install/includes/locale.php');
require(BASE . 'config.local.php');
// twig
require_once LIBS . 'Twig/Autoloader.php';
Twig_Autoloader::register();
$twig_loader = new Twig_Loader_Filesystem(SYSTEM . 'templates');
$twig = new Twig_Environment($twig_loader, array(
'cache' => CACHE . 'twig/',
'auto_reload' => true
));
if(isset($_POST['vars']))
{
foreach($_POST['vars'] as $key => $value)

View File

@@ -1,32 +1,14 @@
<?php
defined('MYAAC') or die('Direct access not allowed!');
?>
<form action="<?php echo BASE_URL; ?>install/" method="post" autocomplete="off">
<input type="hidden" name="step" id="step" value="finish" />
<table>
<?php
require(BASE . 'install/includes/config.php');
if(!$error) {
require(BASE . 'install/includes/database.php');
foreach(array(USE_ACCOUNT_NAME ? 'account' : 'account_id', 'password') as $value)
echo '
<tr>
<td>
<label for="vars_' . $value . '">
<span>' . $locale['step_admin_' . $value] . '</span>
</label>
<br>
<input type="text" name="vars[' . $value . ']" id="vars_' . $value . '"' . (isset($_SESSION['var_' . $value]) ? ' value="' . $_SESSION['var_' . $value] . '"' : '') . '/>
</td>
<td>
<em>' . $locale['step_admin_' . $value . '_desc'] . '</em>
</td>
</tr>';
echo $twig->render('install.admin.html.twig', array(
'locale' => $locale,
'session' => $_SESSION,
'buttons' => next_buttons(true, $error ? false : true)
));
}
?>
</table>
<?php echo next_buttons(true, $error ? false : true);
?>
</form>
?>

View File

@@ -1,7 +1,7 @@
<?php
defined('MYAAC') or die('Direct access not allowed!');
$clients = array(
$clients_list = array(
710,
740,
750,
@@ -65,51 +65,19 @@ $clients = array(
1098,
);
?>
<form action="<?php echo BASE_URL; ?>install/" method="post" autocomplete="off">
<input type="hidden" name="step" id="step" value="database" />
<table>
<?php
foreach(array('server_path', 'mail_admin', 'mail_address') as $value)
echo '
<tr>
<td>
<label for="vars_' . $value . '">
<span>' . $locale['step_config_' . $value] . '</span>
</label>
<br>
<input type="text" name="vars[' . $value . ']" id="vars_' . $value . '"' . (isset($_SESSION['var_' . $value]) ? ' value="' . $_SESSION['var_' . $value] . '"' : '') . '/>
</td>
<td>
<em>' . $locale['step_config_' . $value . '_desc'] . '</em>
</td>
</tr>';
$clients = array();
foreach($clients_list as $client) {
$client_version = (string)($client / 100);
if(strpos($client_version, '.') == false)
$client_version .= '.0';
$clients[$client] = $client_version;
}
echo '
<tr>
<td>
<label for="vars_client">
<span>' . $locale['step_config_client'] . '</span>
</label>
<br>
<select name="vars[client]" id="vars_client">';
//$i = 0;
foreach($clients as $client) {
$client_version = (string)($client / 100);
if(strpos($client_version, '.') == false)
$client_version .= '.0';
echo '<option value="' . $client . '">' . $client_version . '</option>';
}
echo '
</td>
<td>
<em>' . $locale['step_config_client_desc'] . '</em>
</td>
</tr>';
?>
</table>
<?php
echo next_buttons(true, true);
?>
</form>
echo $twig->render('install.config.html.twig', array(
'clients' => $clients,
'locale' => $locale,
'session' => $_SESSION,
'buttons' => next_buttons()
));
?>

View File

@@ -6,14 +6,11 @@ if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['save
}
else {
require(SYSTEM . 'init.php');
//require(BASE . 'install/includes/config.php');
if(!$error) {
//require(BASE . 'install/includes/database.php');
if(USE_ACCOUNT_NAME)
$account = isset($_SESSION['var_account']) ? $_SESSION['var_account'] : NULL;
$account = isset($_SESSION['var_account']) ? $_SESSION['var_account'] : null;
else
$account_id = isset($_SESSION['var_account_id']) ? $_SESSION['var_account_id'] : NULL;
$account_id = isset($_SESSION['var_account_id']) ? $_SESSION['var_account_id'] : null;
$password = $_SESSION['var_password'];
@@ -23,7 +20,7 @@ else {
$salt = generateRandomString(10, false, true, true);
$password = $salt . $password;
}
/*
$account_db = new OTS_Account();
$account_db->load(1);
if($account_db->isLoaded()) {
@@ -38,12 +35,12 @@ else {
if(USE_ACCOUNT_NAME)
$new_account->create('dummy_account', 1);
else
$new_account->create(NULL, 1);
$new_account->create(null, 1);
$new_account->setPassword('for sample characters. ' . generateRandomString(10));
$new_account->save();
}
*/
$account_db = new OTS_Account();
if(isset($account))
$account_db->find($account);
@@ -177,6 +174,14 @@ INSERT INTO `myaac_news` (`id`, `type`, `date`, `category`, `title`, `body`, `pl
if($success) {
success($locale['step_database_imported_players']);
}
require LIBS . 'creatures.php';
if(Creatures::loadFromXML())
success($locale['step_database_loaded_creatures']);
require LIBS . 'spells.php';
if(Spells::loadFromXML())
success($locale['step_database_loaded_spells']);
$locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(ADMIN_URL, $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']);
$locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(BASE_URL, $locale['step_finish_homepage'], true), $locale['step_finish_desc']);

View File

@@ -1,10 +1,8 @@
<?php
defined('MYAAC') or die('Direct access not allowed!');
?>
<form action="<?php echo BASE_URL; ?>install/" method="post">
<input type="hidden" name="step" id="step" value="requirements" />
<textarea rows="10" cols="80" readonly="1"><?php echo file_get_contents(BASE . 'LICENSE'); ?></textarea>
<?php echo next_buttons();
?>
</form>
echo $twig->render('install.license.html.twig', array(
'license' => file_get_contents(BASE . 'LICENSE'),
'buttons' => next_buttons()
));
?>

View File

@@ -5,29 +5,23 @@ if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['save
}
else {
unset($_SESSION['saved']);
?>
<form action="<?php echo BASE_URL; ?>install/" method="post">
<input type="hidden" name="step" id="step" value="license" />
<div class="input"><p><?php echo $locale['step_welcome_desc']; ?></p>
<select name="lang">
<?php
foreach(get_locales() as $tmp_locale)
{
$lang_file_main = LOCALE . $tmp_locale . '/main.php';
$lang_file_install = LOCALE . $tmp_locale . '/install.php';
if(@file_exists($lang_file_main)
&& @file_exists($lang_file_install))
{
require($lang_file_main);
echo '<option value="' . $tmp_locale . '">' . $locale['name'] . '</option>';
}
}
?>
</select>
</div>
<?php echo next_buttons(false, true); ?>
</form>
<?php
$locales = array();
foreach(get_locales() as $tmp_locale)
{
$lang_file_main = LOCALE . $tmp_locale . '/main.php';
$lang_file_install = LOCALE . $tmp_locale . '/install.php';
if(@file_exists($lang_file_main)
&& @file_exists($lang_file_install))
{
require($lang_file_main);
$locales[] = array('id' => $tmp_locale, 'name' => $locale['name']);
}
}
echo $twig->render('install.welcome.html.twig', array(
'locales' => $locales,
'locale' => $locale,
'buttons' => next_buttons(false, true)
));
}
?>