mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
Move commands and downloads pages into database
Available under "Pages" in Admin Panel
This commit is contained in:
parent
ba1d52d6dd
commit
bc3fd61bde
@ -27,7 +27,7 @@ session_start();
|
||||
|
||||
define('MYAAC', true);
|
||||
define('MYAAC_VERSION', '0.8-dev');
|
||||
define('DATABASE_VERSION', 26);
|
||||
define('DATABASE_VERSION', 27);
|
||||
define('TABLE_PREFIX', 'myaac_');
|
||||
define('START_TIME', microtime(true));
|
||||
define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX'));
|
||||
|
@ -273,10 +273,4 @@ $config = array(
|
||||
|
||||
'monsters' => array(),
|
||||
'npc' => array()
|
||||
);
|
||||
|
||||
// download link to client.
|
||||
$config['client_download'] = 'http://tibia-clients.com/clients/download/'. $config['client'] .'/exe/windows';
|
||||
$config['client_download_linux'] = 'http://tibia-clients.com/clients/download/'. $config['client'] .'/tar/linux';
|
||||
|
||||
?>
|
||||
);
|
@ -52,7 +52,7 @@ if(!$error) {
|
||||
|
||||
$locale['step_database_importing'] = str_replace('$DATABASE_NAME$', config('database_name'), $locale['step_database_importing']);
|
||||
success($locale['step_database_importing']);
|
||||
|
||||
|
||||
if(isset($database_error)) { // we failed connect to the database
|
||||
error($database_error);
|
||||
}
|
||||
@ -72,10 +72,6 @@ if(!$error) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
$content .= '$config[\'client_download\'] = \'http://tibia-clients.com/clients/download/\'. $config[\'client\'] . \'/exe/windows\';';
|
||||
$content .= PHP_EOL;
|
||||
$content .= '$config[\'client_download_linux\'] = \'http://tibia-clients.com/clients/download/\'. $config[\'client\'] . \'/tar/linux\';';
|
||||
$content .= PHP_EOL;
|
||||
$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) . '_\';';
|
||||
|
@ -89,6 +89,9 @@ if(!databaseMigration20($content)) {
|
||||
// add z_polls tables
|
||||
require_once SYSTEM . 'migrations/22.php';
|
||||
|
||||
// add myaac_pages pages
|
||||
require_once SYSTEM . 'migrations/27.php';
|
||||
|
||||
$locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(str_replace('tools/', '',ADMIN_URL), $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']);
|
||||
$locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(str_replace('tools/', '', BASE_URL), $locale['step_finish_homepage'], true), $locale['step_finish_desc']);
|
||||
$locale['step_finish_desc'] = str_replace('$LINK$', generateLink('https://my-aac.org', 'https://my-aac.org', true), $locale['step_finish_desc']);
|
||||
|
37
system/migrations/27.php
Normal file
37
system/migrations/27.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
$query = $db->query("SELECT `id` FROM `" . TABLE_PREFIX . "pages` WHERE `name` LIKE " . $db->quote('downloads') . " LIMIT 1;");
|
||||
if($query->rowCount() === 0) {
|
||||
$db->exec("INSERT INTO `myaac_pages` (`id`, `name`, `title`, `body`, `date`, `player_id`, `php`, `access`, `hidden`) VALUES
|
||||
(null, 'downloads', 'Downloads', '<p> </p>
|
||||
<p> </p>
|
||||
<div style=\"text-align: center;\">We''re using official Tibia Client <strong>{{ config.client / 100 }}</strong><br />
|
||||
<p>Download Tibia Client <strong>{{ config.client / 100 }}</strong> for Windows <a href=\"https://drive.google.com/drive/folders/0B2-sMQkWYzhGSFhGVlY2WGk5czQ\" target=\"_blank\" rel=\"noopener\">HERE</a>.</p>
|
||||
<h2>IP Changer:</h2>
|
||||
<a href=\"https://static.otland.net/ipchanger.exe\" target=\"_blank\" rel=\"noopener\">HERE</a></div>', 0, 1, 0, 1, 0);");
|
||||
}
|
||||
|
||||
$query = $db->query("SELECT `id` FROM `" . TABLE_PREFIX . "pages` WHERE `name` LIKE " . $db->quote('commands') . " LIMIT 1;");
|
||||
if($query->rowCount() === 0) {
|
||||
$db->exec("INSERT INTO `myaac_pages` (`id`, `name`, `title`, `body`, `date`, `player_id`, `php`, `access`, `hidden`) VALUES
|
||||
(null, 'commands', 'Commands', '<table style=\"border-collapse: collapse; width: 87.8471%; height: 57px;\" border=\"1\">
|
||||
<tbody>
|
||||
<tr style=\"height: 18px;\">
|
||||
<td style=\"width: 33.3333%; background-color: #505050; height: 18px;\"><span style=\"color: #ffffff;\"><strong>Words</strong></span></td>
|
||||
<td style=\"width: 33.3333%; background-color: #505050; height: 18px;\"><span style=\"color: #ffffff;\"><strong>Description</strong></span></td>
|
||||
</tr>
|
||||
<tr style=\"height: 18px; background-color: #f1e0c6;\">
|
||||
<td style=\"width: 33.3333%; height: 18px;\"><em>!example</em></td>
|
||||
<td style=\"width: 33.3333%; height: 18px;\">This is just an example</td>
|
||||
</tr>
|
||||
<tr style=\"height: 18px; background-color: #d4c0a1;\">
|
||||
<td style=\"width: 33.3333%; height: 18px;\"><em>!buyhouse</em></td>
|
||||
<td style=\"width: 33.3333%; height: 18px;\">Buy house you are looking at</td>
|
||||
</tr>
|
||||
<tr style=\"height: 18px; background-color: #f1e0c6;\">
|
||||
<td style=\"width: 33.3333%; height: 18px;\"><em>!aol</em></td>
|
||||
<td style=\"width: 33.3333%; height: 18px;\">Buy AoL</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>', 0, 1, 0, 1, 0);");
|
||||
}
|
@ -1,193 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Commands
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Commands';
|
||||
|
||||
if($config['otserv_version'] == TFS_03):
|
||||
?>
|
||||
List of all your commands, you can check in game, by writing - <b>/commands</b>.<br/><br/>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<!--
|
||||
To get info ingame about specified command, you can write - <b>/man commandName</b> or <b>commandName man</b>. Example: <b>/man serverinfo</b>, <b>/man !sellhouse</b>, <b>!deathlist man</b>, <b>!buypremium man</b>.
|
||||
<br/><br/>
|
||||
-->
|
||||
|
||||
<?php
|
||||
$canEdit = hasFlag(FLAG_CONTENT_COMMANDS) || superAdmin();
|
||||
if($canEdit)
|
||||
{
|
||||
if(!empty($action))
|
||||
{
|
||||
if($action == 'delete' || $action == 'edit' || $action == 'hide' || $action == 'moveup' || $action == 'movedown')
|
||||
$id = $_REQUEST['id'];
|
||||
|
||||
if(isset($_REQUEST['words']))
|
||||
$words = $_REQUEST['words'];
|
||||
|
||||
if(isset($_REQUEST['description']))
|
||||
$description = stripslashes($_REQUEST['description']);
|
||||
|
||||
$errors = array();
|
||||
|
||||
if($action == 'add') {
|
||||
if(Commands::add($words, $description, $errors))
|
||||
$words = $description = '';
|
||||
}
|
||||
else if($action == 'delete') {
|
||||
Commands::delete($id, $errors);
|
||||
}
|
||||
else if($action == 'edit')
|
||||
{
|
||||
if(isset($id) && !isset($words)) {
|
||||
$command = Commands::get($id);
|
||||
$words = $command['words'];
|
||||
$description = $command['description'];
|
||||
}
|
||||
else {
|
||||
Commands::update($id, $words, $description);
|
||||
$action = $words = $description = '';
|
||||
}
|
||||
}
|
||||
else if($action == 'hide') {
|
||||
Commands::toggleHidden($id, $errors);
|
||||
}
|
||||
else if($action == 'moveup') {
|
||||
Commands::move($id, -1, $errors);
|
||||
}
|
||||
else if($action == 'movedown') {
|
||||
Commands::move($id, 1, $errors);
|
||||
}
|
||||
|
||||
if(!empty($errors))
|
||||
$twig->display('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
$twig->display('commands.form.html.twig', array(
|
||||
'link' => getLink('commands/' . ($action == 'edit' ? 'edit' : 'add')),
|
||||
'action' => $action,
|
||||
'id' => isset($id) ? $id : null,
|
||||
'words' => isset($words) ? $words : null,
|
||||
'description' => isset($description) ? $description : null
|
||||
));
|
||||
}
|
||||
|
||||
$commands =
|
||||
$db->query('SELECT `id`, `words`, `description`' .
|
||||
($canEdit ? ', `hidden`, `ordering`' : '') .
|
||||
' FROM `' . TABLE_PREFIX . 'commands`' .
|
||||
(!$canEdit ? ' WHERE `hidden` != 1' : '') .
|
||||
' ORDER BY `ordering`;');
|
||||
|
||||
$last = $commands->rowCount();
|
||||
$twig->display('commands.html.twig', array(
|
||||
'commands' => $commands,
|
||||
'last' => $last,
|
||||
'canEdit' => $canEdit
|
||||
));
|
||||
|
||||
class Commands
|
||||
{
|
||||
static public function add($words, $description, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($words[0]) && isset($description[0]))
|
||||
{
|
||||
$query = $db->select(TABLE_PREFIX . 'commands', array('words' => $words));
|
||||
|
||||
if($query === false)
|
||||
{
|
||||
$query =
|
||||
$db->query(
|
||||
'SELECT ' . $db->fieldName('ordering') .
|
||||
' FROM ' . $db->tableName(TABLE_PREFIX . 'commands') .
|
||||
' ORDER BY ' . $db->fieldName('ordering') . ' DESC LIMIT 1'
|
||||
);
|
||||
|
||||
$ordering = 0;
|
||||
if($query->rowCount() > 0) {
|
||||
$query = $query->fetch();
|
||||
$ordering = $query['ordering'] + 1;
|
||||
}
|
||||
$db->insert(TABLE_PREFIX . 'commands', array('words' => $words, 'description' => $description, 'ordering' => $ordering));
|
||||
}
|
||||
else
|
||||
$errors[] = 'Command with this words already exists.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'Please fill all inputs.';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function get($id) {
|
||||
global $db;
|
||||
return $db->select(TABLE_PREFIX . 'commands', array('id' => $id));
|
||||
}
|
||||
|
||||
static public function update($id, $words, $description) {
|
||||
global $db;
|
||||
$db->update(TABLE_PREFIX . 'commands', array('words' => $words, 'description' => $description), array('id' => $id));
|
||||
}
|
||||
|
||||
static public function delete($id, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
if(self::get($id) !== false)
|
||||
$db->delete(TABLE_PREFIX . 'commands', array('id' => $id));
|
||||
else
|
||||
$errors[] = 'Command with id ' . $id . ' does not exists.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'id not set';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function toggleHidden($id, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
$query = self::get($id);
|
||||
if($query !== false)
|
||||
$db->update(TABLE_PREFIX . 'commands', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
|
||||
else
|
||||
$errors[] = 'Command with id ' . $id . ' does not exists.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'id not set';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function move($id, $i, &$errors)
|
||||
{
|
||||
global $db;
|
||||
$query = self::get($id);
|
||||
if($query !== false)
|
||||
{
|
||||
$ordering = $query['ordering'] + $i;
|
||||
$old_record = $db->select(TABLE_PREFIX . 'commands', array('ordering' => $ordering));
|
||||
if($old_record !== false)
|
||||
$db->update(TABLE_PREFIX . 'commands', array('ordering' => $query['ordering']), array('ordering' => $ordering));
|
||||
|
||||
$db->update(TABLE_PREFIX . 'commands', array('ordering' => $ordering), array('id' => $id));
|
||||
}
|
||||
else
|
||||
$errors[] = 'Command with id ' . $id . ' does not exists.';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Downloads
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
$title = 'Downloads';
|
||||
|
||||
$twig->display('downloads.html.twig');
|
||||
?>
|
@ -1,10 +0,0 @@
|
||||
<br/><br/>
|
||||
<div style="text-align:center">
|
||||
We're using official Tibia Client <strong>{{ config.client / 100 }}</strong><br/>
|
||||
<p>Download Tibia client {{ config.client / 100 }} for windows <a href="{{ config.client_download }}">HERE</a>.</p>
|
||||
<p>Download Tibia client {{ config.client / 100 }} for linux <a href="{{ config.client_download_linux }}">HERE</a>.</p>
|
||||
|
||||
<h2>IP Changer:</h2>
|
||||
|
||||
<a href="https://static.otland.net/ipchanger.exe" target="_blank">HERE</a>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user