<?php
/**
* iLP System Offiziere Systemeinstellungen
*
* Autor: Florian "ApoY2k" Peschka
* Projekt: iLP System
* Paket: apoy2k.ilp.wrynn
* Lizenz: CreativeCommons (by-nc-sa)
* Kontakt: hide@address.com
* Version: 2.1.1
*/
if (!isset($tpl['url'][1]))
{
$tpl['system']['tooltip_locale_array'] = array(
'de' => 'Deutsch',
'en' => 'English',
'fr' => 'Français',
'es' => 'Español',
'ru' => 'ÑÑÑÑкий'
);
$tpl['system']['region_array'] = array(
'eu' => 'EU',
'us' => 'US',
'tw' => 'TW',
'cn' => 'CN'
);
$tpl['headincludes'][] = 'system.form';
}
elseif (isset($tpl['url'][1]) && 'do' == $tpl['url'][1])
{
// Ãnderungen speichern
$system = $db->prepare("UPDATE ilp_config SET config_value = ? WHERE config_type = ?");
if ($_POST['system_lang_system'] != $_SESSION['config']['locale']) $system->execute(array($_POST['system_lang_system'], 'locale'));
if ($_POST['system_tooltip_locale'] != $_SESSION['config']['lang_tooltip']) $system->execute(array($_POST['system_tooltip_locale'], 'lang_tooltip'));
if ($_POST['system_guild_name'] != $_SESSION['config']['guild_name']) $system->execute(array($_POST['system_guild_name'], 'guild_name'));
if ($_POST['system_guild_realm'] != $_SESSION['config']['guild_realm']) $system->execute(array($_POST['system_guild_realm'], 'guild_realm'));
if ($_POST['system_guild_region'] != $_SESSION['config']['guild_region']) $system->execute(array($_POST['system_guild_region'], 'guild_region'));
if ($_POST['system_list_slots'] != $_SESSION['config']['default_slots']) $system->execute(array($_POST['system_list_slots'], 'default_slots'));
if ($_POST['system_display_loots'] != $_SESSION['config']['last_loots']) $system->execute(array($_POST['system_display_loots'], 'last_loots'));
if ($_POST['system_display_events'] != $_SESSION['config']['last_events']) $system->execute(array($_POST['system_display_events'], 'last_events'));
writeLog($tpl['user']['id'], $tpl['user']['id'], 'officer_change_system');
header('Location: index.php?ilp='.ilpUrlEncode('system'));
}
// Logfile anzeigen
elseif (isset($tpl['url'][1]) && 'log' == $tpl['url'][1])
{
// Zusätzliche Header laden
$tpl['headincludes'][] = 'system.log';
// Filtereinstellungen in das Formular speichern
isset($_POST['show_time_start']) ? $tpl['show_time_start'] = $_POST['show_time_start'] : $tpl['show_time_start'] = '';
isset($_POST['show_time_stop']) ? $tpl['show_time_stop'] = $_POST['show_time_stop'] : $tpl['show_time_stop'] = '';
isset($_POST['show_time_bool']) ? $tpl['show_time_bool'] = $_POST['show_time_bool'] : $tpl['show_time_bool'] = '1';
isset($_POST['show_actor']) ? $tpl['show_actor'] = $_POST['show_actor'] : $tpl['show_actor'] = '*';
isset($_POST['show_actor_bool']) ? $tpl['show_actor_bool'] = $_POST['show_actor_bool'] : $tpl['show_actor_bool'] = '1';
isset($_POST['show_victim']) ? $tpl['show_victim'] = $_POST['show_victim'] : $tpl['show_victim'] = '*';
isset($_POST['show_victim_bool']) ? $tpl['show_victim_bool'] = $_POST['show_victim_bool'] : $tpl['show_victim_bool'] = '1';
isset($_POST['show_action']) ? $tpl['show_action'] = $_POST['show_action'] : $tpl['show_action'] = '*';
isset($_POST['show_action_bool']) ? $tpl['show_action_bool'] = $_POST['show_action_bool'] : $tpl['show_action_bool'] = '1';
isset($_POST['show_maxlogs']) ? $tpl['show_maxlogs'] = $_POST['show_maxlogs'] : $tpl['show_maxlogs'] = '';
if (isset($tpl['url'][2]) && 'filter' == $tpl['url'][2])
{
// Zusammenstellung der SQL-Abfrage
$sql = 'SELECT * FROM ilp_actionlog WHERE ';
if (0 == $_POST['show_time_bool'])
{ $sql .= 'date NOT BETWEEN '; }
else { $sql .= 'date BETWEEN '; }
if (!isset($_POST['show_time_start']) || '*' == $_POST['show_time_start'] || '' == $_POST['show_time_start'])
{ $sql .= '0 AND '; }
else { $sql .= '\''.$_POST['show_time_start'].' 00:00:00\' AND '; }
if (!isset($_POST['show_time_stop']) || '*' == $_POST['show_time_stop'] || '' == $_POST['show_time_stop'])
{ $sql .= 'NOW() '; }
else { $sql .= '\''.$_POST['show_time_stop'].' 23:59:59\' '; }
$sql .= 'AND actor ';
if ('*' == $_POST['show_actor'])
{
if(0 == $_POST['show_actor_bool'])
{ $sql .= '< 0 '; }
else { $sql .= '>= 0 '; }
}
else
{
if(0 == $_POST['show_actor_bool'])
{ $sql .= '!= '.$_POST['show_actor'].' '; }
else { $sql .= '= '.$_POST['show_actor'].' '; }
}
$sql .= 'AND victim ';
if ('*' == $_POST['show_victim'])
{
if(0 == $_POST['show_victim_bool'])
{ $sql .= '< 0 '; }
else { $sql .= '>= 0 '; }
}
else
{
if(0 == $_POST['show_victim_bool'])
{ $sql .= '!= '.$_POST['show_victim'].' '; }
else { $sql .= '= '.$_POST['show_victim'].' '; }
}
$sql .= 'AND action ';
if ('*' == $_POST['show_action'])
{
if(0 == $_POST['show_action_bool'])
{ $sql .= '!= 0'; }
else { $sql .= '!= \'\''; }
}
else
{
if(0 == $_POST['show_action_bool'])
{ $sql .= '!= \''.$_POST['show_action'].'\''; }
else { $sql .= '= \''.$_POST['show_action'].'\''; }
}
$sql .= 'ORDER BY date DESC, id DESC ';
if (isset($_POST['show_maxlogs']) && '*' != $_POST['show_maxlogs'] && '' != $_POST['show_maxlogs'])
{
$sql .= 'LIMIT 0, '.$_POST['show_maxlogs'].' ';
}
}
else
{
$sql = 'SELECT * FROM ilp_actionlog ORDER BY date DESC, id DESC LIMIT 0, 20';
}
// Spieler suchen und als Array für Filter speichern
$getusers = $db->query("SELECT id AS user_id, `char` FROM ilp_users");
$getusers->execute();
while ($row = $getusers->fetch(PDO::FETCH_ASSOC))
{
$row['char'] = unserialize($row['char']);
$tpl['chars'][] = $row;
}
$tpl['chars'] = sortUsers($tpl['chars']);
// Handlungen als Array speichern
foreach ($lang['log'] as $key => $action)
{
$tpl['actions'][$key] = $action;
}
// Log auslesen
$getlog = $db->query($sql);
if (is_object($getlog))
{
// Userdaten auslesen und genaue Logdaten speichern
while ($row = $getlog->fetch(PDO::FETCH_ASSOC))
{
$getactor = $db->query("SELECT `char` FROM ilp_users WHERE id = ".$row['actor']);
$getvictim = $db->query("SELECT `char` FROM ilp_users WHERE id = ".$row['victim']);
$row['actor_char'] = $getactor->fetch(PDO::FETCH_ASSOC);
$row['actor_char'] = unserialize($row['actor_char']['char']);
$row['victim_char'] = $getvictim->fetch(PDO::FETCH_ASSOC);
$row['victim_char'] = unserialize($row['victim_char']['char']);
$row['values'] = unserialize($row['values']);
$tpl['log'][] = $row;
}
}
else
{
$tpl['error']['action'] = 'Log anzeigen';
$tpl['error']['actor'] = $tpl['user']['login'].' â ID: '.$tpl['user']['id'];
$tpl['error']['location'] = 'system.php:163';
$tpl['error']['result'] = serialize($db->errorInfo());
$tpl['error']['level'] = '0 (base-php)';
}
}
// Caches löschen
elseif ('caches' == $tpl['url'][1])
{
// Zusätzlich Header laden
$tpl['headincludes'][] = 'system.cache';
// Benutzer suchen
$getusers = $db->query("SELECT `char` FROM ilp_users");
$users = $getusers->fetchAll(PDO::FETCH_ASSOC);
// Armorylite für jeden Benutzer aufrufen
foreach ($users as $user)
{
$user['char'] = unserialize($user['char']);
$tpl['users'][] = $user;
}
$tpl['user_count'] = count($tpl['users']);
$tpl['users'] = sortUsers($tpl['users']);
$tpl['users'] = base64_encode(serialize($tpl['users']));
if (isset($tpl['url'][2]) && 'itemcache' == $tpl['url'][2])
{
// Gegenstandscache laden
$deletecache = $db->query("TRUNCATE TABLE ilp_itemcache");
header('Location: index.php?ilp='.ilpUrlEncode('system;caches'));
}
elseif (isset($tpl['url'][2]) && 'playercache' == $tpl['url'][2])
{
// Zusätzliche Header laden
$tpl['headincludes'][] = 'system.playercache.proccess';
}
}
?>