diff --git a/LICENSE b/LICENSE
index 32a6bfc..5ef16a8 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2017 Sam
+Copyright (c) 2020 Samerton
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index f9f3783..717dc5a 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,16 @@
# Nameless-Infractions
-Infractions module for Nameless 2
+The Infractions module for Nameless v2 allows you to display a list of ingame punishments on your website.
-**This module is in development, and is not yet ready for use.**
\ No newline at end of file
+### Supported Plugins
+- LiteBans
+
+If you would like to request plugin support, please open an issue on [GitHub](https://github.com/samerton/Nameless-Infractions/issues).
+
+### Requirements
+- NamelessMC version 2 (from commit [6b6222c](https://github.com/NamelessMC/Nameless/commit/6b6222c020ddea84fe9e653b5715b6f8fda8c1b4) or pre-release 7 onwards)
+- One of the previously mentioned supported plugins installed and configured to use MySQL
+
+### Installation
+- Upload the contents of the **upload** directory straight into your NamelessMC installation's directory
+- Activate the module in the StaffCP -> Modules tab
+- Configure your Infractions plugin information in the StaffCP -> Infractions tab
\ No newline at end of file
diff --git a/modules/Infractions/classes/LiteBans.php b/modules/Infractions/classes/LiteBans.php
deleted file mode 100644
index ba769bc..0000000
--- a/modules/Infractions/classes/LiteBans.php
+++ /dev/null
@@ -1,177 +0,0 @@
- 'litebans_bans',
- 'kicks_table' => 'litebans_kicks',
- 'mutes_table' => 'litebans_mutes',
- 'warnings_table' => 'litebans_warnings',
- 'history_table' => 'litebans_history'
- );
- }
-
- $this->_extra = $inf_extra['litebans'];
- }
-
- // Retrieve a list of all infractions, either from cache or database
- public function listInfractions(){
- // Cached?
- $cache = $this->_cache;
- $cache->setCache('infractions_infractions');
- if($cache->isCached('infractions')){
- $infractions = $cache->retrieve('infractions');
- } else {
- $this->initDB();
-
- $bans = $this->listBans();
- $kicks = $this->listKicks();
- $mutes = $this->listMutes();
- $warnings = $this->listWarnings();
-
- // Merge
- $infractions = array_merge($bans, $kicks, $mutes, $warnings);
-
- // Sort by date
- usort($infractions, array($this, 'date_compare'));
-
- $cache->setCache('infractions_infractions');
- $cache->store('infractions', $infractions, 120);
- }
-
- return $infractions;
- }
-
- // List all bans
- public function listBans(){
- // Cached?
- $cache = $this->_cache;
- $cache->setCache('infractions_bans');
- if($cache->isCached('bans')){
- $bans = $cache->retrieve('bans');
- } else {
- $bans = $this->_db->query(
- 'SELECT bans.id, bans.ip, bans.uuid, bans.reason, bans.banned_by_uuid, bans.banned_by_name, bans.removed_by_uuid, bans.banned_by_name, bans.removed_by_date, bans.time, bans.until, bans.ipban, bans.active, bans.server_scope, bans.server_origin, history.name, "ban" as type' .
- ' FROM ' . $this->_extra['bans_table'] . ' AS bans' .
- ' LEFT JOIN (SELECT name, uuid FROM ' . $this->_extra['history_table'] . ') AS history ON bans.uuid = history.uuid' .
- ' ORDER BY bans.time DESC', array()
- );
-
- if($bans->count()){
- $cache->store('bans', $bans->results(), 120);
- $bans = $bans->results();
- } else $bans = array();
- }
-
- return $bans;
- }
-
- // List all kicks
- public function listKicks(){
- // Cached?
- $cache = $this->_cache;
- $cache->setCache('infractions_kicks');
- if($cache->isCached('kicks')){
- $kicks = $this->_cache->retrieve('kicks');
- } else {
- $kicks = $this->_db->query(
- 'SELECT bans.id, bans.ip, bans.uuid, bans.reason, bans.banned_by_uuid, bans.banned_by_name, bans.time, bans.server_scope, bans.server_origin, history.name, "kick" as type' .
- ' FROM ' . $this->_extra['kicks_table'] . ' AS bans' .
- ' LEFT JOIN (SELECT name, uuid FROM ' . $this->_extra['history_table'] . ') AS history ON bans.uuid = history.uuid' .
- ' ORDER BY bans.time DESC', array()
- );
-
- if($kicks->count()){
- $cache->store('kicks', $kicks->results(), 120);
- $kicks = $kicks->results();
- } else $kicks = array();
- }
-
- return $kicks;
- }
-
- // List all mutes
- public function listMutes(){
- // Cached?
- $cache = $this->_cache;
- $cache->setCache('infractions_mutes');
- if($cache->isCached('mutes')){
- $mutes = $this->_cache->retrieve('mutes');
- } else {
- $mutes = $this->_db->query(
- 'SELECT bans.id, bans.ip, bans.uuid, bans.reason, bans.banned_by_uuid, bans.banned_by_name, bans.removed_by_uuid, bans.banned_by_name, bans.removed_by_date, bans.time, bans.until, bans.ipban, bans.active, bans.server_scope, bans.server_origin, history.name, "mute" as type' .
- ' FROM ' . $this->_extra['mutes_table'] . ' AS bans' .
- ' LEFT JOIN (SELECT name, uuid FROM ' . $this->_extra['history_table'] . ') AS history ON bans.uuid = history.uuid' .
- ' ORDER BY bans.time DESC', array()
- );
-
- if($mutes->count()){
- $cache->store('mutes', $mutes->results(), 120);
- $mutes = $mutes->results();
- } else $mutes = array();
- }
-
- return $mutes;
- }
-
- // List all warnings
- public function listWarnings(){
- // Cached?
- $cache = $this->_cache;
- $cache->setCache('infractions_warnings');
- if($cache->isCached('warnings')){
- $warnings = $this->_cache->retrieve('warnings');
- } else {
- $warnings = $this->_db->query(
- 'SELECT bans.id, bans.ip, bans.uuid, bans.reason, bans.banned_by_uuid, bans.banned_by_name, bans.removed_by_uuid, bans.banned_by_name, bans.removed_by_date, bans.time, bans.until, bans.ipban, bans.active, bans.server_scope, bans.server_origin, history.name, "warning" as type' .
- ' FROM ' . $this->_extra['warnings_table'] . ' AS bans' .
- ' LEFT JOIN (SELECT name, uuid FROM ' . $this->_extra['history_table'] . ') AS history ON bans.uuid = history.uuid' .
- ' ORDER BY bans.time DESC', array()
- );
-
- if($warnings->count()){
- $cache->store('warnings', $warnings->results(), 120);
- $warnings = $warnings->results();
- } else $warnings = array();
- }
-
- return $warnings;
- }
-
- // Get a username from a UUID
- public function getUsername($uuid){
- $user = $this->_db->query('SELECT `name` FROM ' . $this->_extra['history_table'] . ' WHERE uuid = ?', array($uuid));
-
- if($user->count()) return $user->first()->name;
- else return false;
- }
-
- // Get creation time from infraction
- public static function getCreationTime($item){
- if(isset($item->time)){
- return $item->time;
- } else return false;
- }
-
-}
\ No newline at end of file
diff --git a/modules/Infractions/pages/admin.php b/modules/Infractions/pages/admin.php
deleted file mode 100644
index e69de29..0000000
diff --git a/custom/panel_templates/Default/infractions/index.tpl b/upload/custom/panel_templates/Default/infractions/index.tpl
similarity index 100%
rename from custom/panel_templates/Default/infractions/index.tpl
rename to upload/custom/panel_templates/Default/infractions/index.tpl
diff --git a/custom/templates/Default/infractions/infractions.tpl b/upload/custom/templates/Default/infractions/infractions.tpl
similarity index 97%
rename from custom/templates/Default/infractions/infractions.tpl
rename to upload/custom/templates/Default/infractions/infractions.tpl
index 1e4c753..d410fcc 100644
--- a/custom/templates/Default/infractions/infractions.tpl
+++ b/upload/custom/templates/Default/infractions/infractions.tpl
@@ -1,88 +1,88 @@
-{include file='header.tpl'}
-{include file='navbar.tpl'}
-
-
-
-
-
{$INFRACTIONS}
- {if isset($INFRACTIONS_LIST)}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {$USERNAME} |
- {$STAFF_MEMBER} |
- {$ISSUED} |
- {$ACTION} |
- {$REASON} |
-
-
-
-
-
- {foreach from=$INFRACTIONS_LIST item=infraction}
-
- {$infraction.username} |
- {$infraction.staff_member} |
- {$infraction.issued} |
-
- {if $infraction.action_id == 1 || $infraction.action_id == 2}
- {$infraction.action}
- {elseif $infraction.action_id == 3 || $infraction.action_id == 4}
- {$infraction.action}
- {elseif $infraction.action_id == 5}
- {$infraction.action}
- {elseif $infraction.action_id == 6}
- {$infraction.action}
- {else}
- {$infraction.action}
- {/if}
-
- {if $infraction.action_id eq 1 OR $infraction.action_id eq 3}
- {if $infraction.revoked == 1}
- {$infraction.revoked_full}
- {else}
- {$infraction.revoked_full}
- {/if}
- {/if}
- |
- {$infraction.reason} |
-
-
- {/foreach}
-
-
-
- {$PAGINATION}
- {else}
-
{$NO_INFRACTIONS}
- {/if}
-
-
-
-
+{include file='header.tpl'}
+{include file='navbar.tpl'}
+
+
+
+
+
{$INFRACTIONS}
+ {if isset($INFRACTIONS_LIST)}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {$USERNAME} |
+ {$STAFF_MEMBER} |
+ {$ISSUED} |
+ {$ACTION} |
+ {$REASON} |
+
+
+
+
+
+ {foreach from=$INFRACTIONS_LIST item=infraction}
+
+ {$infraction.username} |
+ {$infraction.staff_member} |
+ {$infraction.issued} |
+
+ {if $infraction.action_id == 1 || $infraction.action_id == 2}
+ {$infraction.action}
+ {elseif $infraction.action_id == 3 || $infraction.action_id == 4}
+ {$infraction.action}
+ {elseif $infraction.action_id == 5}
+ {$infraction.action}
+ {elseif $infraction.action_id == 6}
+ {$infraction.action}
+ {else}
+ {$infraction.action}
+ {/if}
+
+ {if $infraction.action_id eq 1 OR $infraction.action_id eq 3}
+ {if $infraction.revoked == 1}
+ {$infraction.revoked_full}
+ {else}
+ {$infraction.revoked_full}
+ {/if}
+ {/if}
+ |
+ {$infraction.reason} |
+
+
+ {/foreach}
+
+
+
+ {$PAGINATION}
+ {else}
+
{$NO_INFRACTIONS}
+ {/if}
+
+
+
+
{include file='footer.tpl'}
\ No newline at end of file
diff --git a/custom/templates/Default/infractions/profile_tab.tpl b/upload/custom/templates/Default/infractions/profile_tab.tpl
similarity index 100%
rename from custom/templates/Default/infractions/profile_tab.tpl
rename to upload/custom/templates/Default/infractions/profile_tab.tpl
diff --git a/custom/templates/DefaultRevamp/infractions/infractions.tpl b/upload/custom/templates/DefaultRevamp/infractions/infractions.tpl
similarity index 97%
rename from custom/templates/DefaultRevamp/infractions/infractions.tpl
rename to upload/custom/templates/DefaultRevamp/infractions/infractions.tpl
index 3075e5e..7a420ad 100644
--- a/custom/templates/DefaultRevamp/infractions/infractions.tpl
+++ b/upload/custom/templates/DefaultRevamp/infractions/infractions.tpl
@@ -1,71 +1,71 @@
-{include file='header.tpl'}
-{include file='navbar.tpl'}
-
-
-
-
{$INFRACTIONS}
-
- {if isset($INFRACTIONS_LIST)}
-
-
-
-
-
-
-
-
-
-
-
-
- {$USERNAME} |
- {$STAFF_MEMBER} |
- {$ISSUED} |
- {$ACTION} |
- {$REASON} |
-
-
-
-
-
- {foreach from=$INFRACTIONS_LIST item=infraction}
-
- {$infraction.username} |
- {$infraction.staff_member} |
- {$infraction.issued} |
-
- {if $infraction.action_id == 1 || $infraction.action_id == 2}
- {$infraction.action}
- {elseif $infraction.action_id == 3 || $infraction.action_id == 4}
- {$infraction.action}
- {elseif $infraction.action_id == 5}
- {$infraction.action}
- {elseif $infraction.action_id == 6}
- {$infraction.action}
- {else}
- {$infraction.action}
- {/if}
-
- {if $infraction.action_id eq 1 OR $infraction.action_id eq 3}
- {if $infraction.revoked == 1}
- {$infraction.revoked_full}
- {else}
- {$infraction.revoked_full}
- {/if}
- {/if}
- |
- {$infraction.reason} |
-
-
- {/foreach}
-
-
-
- {$PAGINATION}
- {else}
-
{$NO_INFRACTIONS}
- {/if}
-
-
-
+{include file='header.tpl'}
+{include file='navbar.tpl'}
+
+
+
+
{$INFRACTIONS}
+
+ {if isset($INFRACTIONS_LIST)}
+
+
+
+
+
+
+
+
+
+
+
+
+ {$USERNAME} |
+ {$STAFF_MEMBER} |
+ {$ISSUED} |
+ {$ACTION} |
+ {$REASON} |
+
+
+
+
+
+ {foreach from=$INFRACTIONS_LIST item=infraction}
+
+ {$infraction.username} |
+ {$infraction.staff_member} |
+ {$infraction.issued} |
+
+ {if $infraction.action_id == 1 || $infraction.action_id == 2}
+ {$infraction.action}
+ {elseif $infraction.action_id == 3 || $infraction.action_id == 4}
+ {$infraction.action}
+ {elseif $infraction.action_id == 5}
+ {$infraction.action}
+ {elseif $infraction.action_id == 6}
+ {$infraction.action}
+ {else}
+ {$infraction.action}
+ {/if}
+
+ {if $infraction.action_id eq 1 OR $infraction.action_id eq 3}
+ {if $infraction.revoked == 1}
+ {$infraction.revoked_full}
+ {else}
+ {$infraction.revoked_full}
+ {/if}
+ {/if}
+ |
+ {$infraction.reason} |
+
+
+ {/foreach}
+
+
+
+ {$PAGINATION}
+ {else}
+
{$NO_INFRACTIONS}
+ {/if}
+
+
+
{include file='footer.tpl'}
\ No newline at end of file
diff --git a/modules/Infractions/classes/BungeeAdminTools.php b/upload/modules/Infractions/classes/BungeeAdminTools.php
similarity index 96%
rename from modules/Infractions/classes/BungeeAdminTools.php
rename to upload/modules/Infractions/classes/BungeeAdminTools.php
index 85cffac..ce37125 100644
--- a/modules/Infractions/classes/BungeeAdminTools.php
+++ b/upload/modules/Infractions/classes/BungeeAdminTools.php
@@ -1,115 +1,115 @@
-_prefix = 'bat_';
- }
-
- // Retrieve a list of all infractions, either from cache or database
- public function listInfractions(){
- // Cached?
- $this->_cache->setCache('infractions_infractions');
- if($this->_cache->isCached('infractions')){
- $infractions = $this->_cache->retrieve('infractions');
- } else {
- $bans = $this->listBans();
- $kicks = $this->listKicks();
- $mutes = $this->listMutes();
-
- // Merge
- $infractions = array_merge($bans, $kicks, $mutes);
-
- // Sort by date
- usort($infractions, array($this, 'date_compare'));
-
- $this->_cache->store('infractions', $infractions, 120);
- }
-
- return $infractions;
- }
-
- // List all bans
- public function listBans(){
- // Cached?
- $this->_cache->setCache('infractions_bans');
- if($this->_cache->isCached('bans')){
- $bans = $this->_cache->retrieve('bans');
- } else {
- $bans = $this->orderQuery('ban', 'ban_id <> 0', 'ban_begin', 'DESC');
-
- if(count($bans))
- $this->_cache->store('bans', $bans, 120);
- else $bans = array();
- }
-
- return $bans;
- }
-
- // List all kicks
- public function listKicks(){
- // Cached?
- $this->_cache->setCache('infractions_kicks');
- if($this->_cache->isCached('kicks')){
- $kicks = $this->_cache->retrieve('kicks');
- } else {
- $kicks = $this->orderQuery('kick', 'kick_id <> 0', 'kick_date', 'DESC');
-
- if(count($kicks))
- $this->_cache->store('kicks', $kicks, 120);
- else $kicks = array();
- }
-
- return $kicks;
- }
-
- // List all mutes
- public function listMutes(){
- // Cached?
- $this->_cache->setCache('infractions_mutes');
- if($this->_cache->isCached('mutes')){
- $mutes = $this->_cache->retrieve('mutes');
- } else {
- $mutes = $this->orderQuery('mute', 'mute_id <> 0', 'mute_begin', 'DESC');
-
- if(count($mutes))
- $this->_cache->store('mutes', $mutes, 120);
- else $mutes = array();
- }
-
- return $mutes;
- }
-
- // Get a username from a UUID
- public function getUsername($uuid){
- $user = $this->query('players', array('uuid', '=', $uuid));
-
- if(count($user)) return $user[0]->BAT_player;
- else return false;
- }
-
- // Get creation time from infraction
- public static function getCreationTime($item){
- if(isset($item->ban_begin)){
- return $item->ban_begin;
- } else if(isset($item->kick_date)){
- return $item->kick_date;
- } else if(isset($item->mute_begin)) {
- return $item->mute_begin;
- } else return false;
- }
-
+_prefix = 'bat_';
+ }
+
+ // Retrieve a list of all infractions, either from cache or database
+ public function listInfractions(){
+ // Cached?
+ $this->_cache->setCache('infractions_infractions');
+ if($this->_cache->isCached('infractions')){
+ $infractions = $this->_cache->retrieve('infractions');
+ } else {
+ $bans = $this->listBans();
+ $kicks = $this->listKicks();
+ $mutes = $this->listMutes();
+
+ // Merge
+ $infractions = array_merge($bans, $kicks, $mutes);
+
+ // Sort by date
+ usort($infractions, array($this, 'date_compare'));
+
+ $this->_cache->store('infractions', $infractions, 120);
+ }
+
+ return $infractions;
+ }
+
+ // List all bans
+ public function listBans(){
+ // Cached?
+ $this->_cache->setCache('infractions_bans');
+ if($this->_cache->isCached('bans')){
+ $bans = $this->_cache->retrieve('bans');
+ } else {
+ $bans = $this->orderQuery('ban', 'ban_id <> 0', 'ban_begin', 'DESC');
+
+ if(count($bans))
+ $this->_cache->store('bans', $bans, 120);
+ else $bans = array();
+ }
+
+ return $bans;
+ }
+
+ // List all kicks
+ public function listKicks(){
+ // Cached?
+ $this->_cache->setCache('infractions_kicks');
+ if($this->_cache->isCached('kicks')){
+ $kicks = $this->_cache->retrieve('kicks');
+ } else {
+ $kicks = $this->orderQuery('kick', 'kick_id <> 0', 'kick_date', 'DESC');
+
+ if(count($kicks))
+ $this->_cache->store('kicks', $kicks, 120);
+ else $kicks = array();
+ }
+
+ return $kicks;
+ }
+
+ // List all mutes
+ public function listMutes(){
+ // Cached?
+ $this->_cache->setCache('infractions_mutes');
+ if($this->_cache->isCached('mutes')){
+ $mutes = $this->_cache->retrieve('mutes');
+ } else {
+ $mutes = $this->orderQuery('mute', 'mute_id <> 0', 'mute_begin', 'DESC');
+
+ if(count($mutes))
+ $this->_cache->store('mutes', $mutes, 120);
+ else $mutes = array();
+ }
+
+ return $mutes;
+ }
+
+ // Get a username from a UUID
+ public function getUsername($uuid){
+ $user = $this->query('players', array('uuid', '=', $uuid));
+
+ if(count($user)) return $user[0]->BAT_player;
+ else return false;
+ }
+
+ // Get creation time from infraction
+ public static function getCreationTime($item){
+ if(isset($item->ban_begin)){
+ return $item->ban_begin;
+ } else if(isset($item->kick_date)){
+ return $item->kick_date;
+ } else if(isset($item->mute_begin)) {
+ return $item->mute_begin;
+ } else return false;
+ }
+
}
\ No newline at end of file
diff --git a/modules/Infractions/classes/Infractions.php b/upload/modules/Infractions/classes/Infractions.php
similarity index 90%
rename from modules/Infractions/classes/Infractions.php
rename to upload/modules/Infractions/classes/Infractions.php
index 47bb6d5..3cbdf16 100644
--- a/modules/Infractions/classes/Infractions.php
+++ b/upload/modules/Infractions/classes/Infractions.php
@@ -1,48 +1,49 @@
-_db_details = $inf_db;
- $this->_language = $language;
- $this->_cache = new Cache(array('name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/infractions/'));
- }
-
- // Connect to database
- protected function initDB(){
- if($this->_db)
- return;
-
- $this->_db = new DB_Custom($this->_db_details['address'], $this->_db_details['name'], $this->_db_details['username'], $this->_db_details['password'], $this->_db_details['port']);
- }
-
- // Order array of objects using created attribute
- protected function date_compare($a, $b){
- if(!isset($a->created) || !isset($b->created)){
- $a->created = $this->getCreationTime($a);
- $b->created = $this->getCreationTime($b);
- }
-
- if($a->created == $b->created) return 0;
- return ($a->created < $b->created) ? 1 : -1;
- }
-
- // Abstract functions to be extended
- abstract public function listInfractions();
-
+_db_details = $inf_db;
+ $this->_language = $language;
+ $this->_cache = new Cache(array('name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/infractions/'));
+ }
+
+ // Connect to database
+ protected function initDB(){
+ if($this->_db)
+ return;
+
+ $this->_db = new DB_Custom($this->_db_details['address'], $this->_db_details['name'], $this->_db_details['username'], $this->_db_details['password'], $this->_db_details['port']);
+ }
+
+ // Order array of objects using created attribute
+ protected function date_compare($a, $b){
+ if(!isset($a->created) || !isset($b->created)){
+ $a->created = $this->getCreationTime($a);
+ $b->created = $this->getCreationTime($b);
+ }
+
+ if($a->created == $b->created) return 0;
+ return ($a->created < $b->created) ? 1 : -1;
+ }
+
+ // Abstract functions to be extended
+ abstract public function listInfractions($page, $limit);
+ abstract protected function getTotal();
+
}
\ No newline at end of file
diff --git a/upload/modules/Infractions/classes/LiteBans.php b/upload/modules/Infractions/classes/LiteBans.php
new file mode 100644
index 0000000..3543a06
--- /dev/null
+++ b/upload/modules/Infractions/classes/LiteBans.php
@@ -0,0 +1,202 @@
+ 'litebans_bans',
+ 'kicks_table' => 'litebans_kicks',
+ 'mutes_table' => 'litebans_mutes',
+ 'warnings_table' => 'litebans_warnings',
+ 'history_table' => 'litebans_history'
+ );
+ }
+
+ $this->_extra = $inf_extra['litebans'];
+ }
+
+ // Retrieve a list of all infractions, either from cache or database
+ public function listInfractions($page, $limit){
+ // Cached?
+ $cache = $this->_cache;
+ $cache->setCache('infractions_infractions');
+ if($cache->isCached('infractions' . $page)){
+ $infractions = $cache->retrieve('infractions' . $page);
+ } else {
+ $this->initDB();
+
+ $total = $this->getTotal()->first()->total;
+ $infractions = $this->listAll($page, $limit)->results();
+ $infractions['total'] = $total;
+
+ $cache->setCache('infractions_infractions');
+ $cache->store('infractions' . $page, $infractions, 120);
+ }
+
+ return $infractions;
+ }
+
+ // List all infractions
+ public function listAll($page, $limit){
+ $start = ($page - 1) * $limit;
+
+ return $this->_db->query(
+ '(' . $this->getBansQuery() . ') UNION ' .
+ '(' . $this->getKicksQuery() . ') UNION ' .
+ '(' . $this->getMutesQuery() . ') UNION ' .
+ '(' . $this->getWarningsQuery() . ') ORDER BY `time` DESC LIMIT ?,?',
+ array($start, $limit)
+ );
+ }
+
+ // List all bans
+ public function listBans(){
+ // Cached?
+ $cache = $this->_cache;
+ $cache->setCache('infractions_bans');
+ if($cache->isCached('bans')){
+ $bans = $cache->retrieve('bans');
+ } else {
+ $bans = $this->_db->query($this->getBansQuery(), array());
+
+ if($bans->count()){
+ $cache->store('bans', $bans->results(), 120);
+ $bans = $bans->results();
+ } else $bans = array();
+ }
+
+ return $bans;
+ }
+
+ // List all kicks
+ public function listKicks(){
+ // Cached?
+ $cache = $this->_cache;
+ $cache->setCache('infractions_kicks');
+ if($cache->isCached('kicks')){
+ $kicks = $this->_cache->retrieve('kicks');
+ } else {
+ $kicks = $this->_db->query($this->getKicksQuery(), array());
+
+ if($kicks->count()){
+ $cache->store('kicks', $kicks->results(), 120);
+ $kicks = $kicks->results();
+ } else $kicks = array();
+ }
+
+ return $kicks;
+ }
+
+ // List all mutes
+ public function listMutes(){
+ // Cached?
+ $cache = $this->_cache;
+ $cache->setCache('infractions_mutes');
+ if($cache->isCached('mutes')){
+ $mutes = $this->_cache->retrieve('mutes');
+ } else {
+ $mutes = $this->_db->query($this->getMutesQuery(), array());
+
+ if($mutes->count()){
+ $cache->store('mutes', $mutes->results(), 120);
+ $mutes = $mutes->results();
+ } else $mutes = array();
+ }
+
+ return $mutes;
+ }
+
+ // List all warnings
+ public function listWarnings(){
+ // Cached?
+ $cache = $this->_cache;
+ $cache->setCache('infractions_warnings');
+ if($cache->isCached('warnings')){
+ $warnings = $this->_cache->retrieve('warnings');
+ } else {
+ $warnings = $this->_db->query($this->getWarningsQuery(), array());
+
+ if($warnings->count()){
+ $cache->store('warnings', $warnings->results(), 120);
+ $warnings = $warnings->results();
+ } else $warnings = array();
+ }
+
+ return $warnings;
+ }
+
+ // Get a username from a UUID
+ public function getUsername($uuid){
+ $user = $this->_db->query('SELECT `name` FROM ' . $this->_extra['history_table'] . ' WHERE uuid = ?', array($uuid));
+
+ if($user->count()) return $user->first()->name;
+ else return false;
+ }
+
+ // Get creation time from infraction
+ public static function getCreationTime($item){
+ if(isset($item->time)){
+ return $item->time;
+ } else return false;
+ }
+
+ // Get total rows
+ protected function getTotal(){
+ return $this->_db->query(
+ 'SELECT (SELECT COUNT(*) FROM ' . $this->_extra['bans_table'] . ') + (SELECT COUNT(*) FROM ' . $this->_extra['kicks_table'] . ') + (SELECT COUNT(*) FROM ' . $this->_extra['mutes_table'] . ') + (SELECT COUNT(*) FROM ' . $this->_extra['warnings_table'] . ') AS total', array()
+ );
+ }
+
+ // Get bans query
+ private function getBansQuery(){
+ return 'SELECT bans.id, bans.ip, bans.uuid, bans.reason, bans.banned_by_uuid, bans.banned_by_name, bans.removed_by_uuid, bans.removed_by_name, bans.removed_by_date, bans.time, bans.until, bans.ipban, bans.active, bans.server_scope, bans.server_origin, history.name, "ban" as type' .
+ ' FROM ' . $this->_extra['bans_table'] . ' AS bans' .
+ ' LEFT JOIN (SELECT name, uuid FROM ' . $this->_extra['history_table'] . ') AS history ON bans.uuid = history.uuid' .
+ ' ORDER BY bans.time DESC';
+ }
+
+ // Get kicks
+ private function getKicksQuery(){
+ return 'SELECT bans.id, bans.ip, bans.uuid, bans.reason, bans.banned_by_uuid, bans.banned_by_name, "" as removed_by_uuid, "" as removed_by_name, "" as removed_by_date, bans.time, "" as until, "" as ipban, "" as active, bans.server_scope, bans.server_origin, history.name, "kick" as type' .
+ ' FROM ' . $this->_extra['kicks_table'] . ' AS bans' .
+ ' LEFT JOIN (SELECT name, uuid FROM ' . $this->_extra['history_table'] . ') AS history ON bans.uuid = history.uuid' .
+ ' ORDER BY bans.time DESC';
+ }
+
+ // Get mutes
+ private function getMutesQuery(){
+ return 'SELECT bans.id, bans.ip, bans.uuid, bans.reason, bans.banned_by_uuid, bans.banned_by_name, bans.removed_by_uuid, bans.removed_by_name, bans.removed_by_date, bans.time, bans.until, bans.ipban, bans.active, bans.server_scope, bans.server_origin, history.name, "mute" as type' .
+ ' FROM ' . $this->_extra['mutes_table'] . ' AS bans' .
+ ' LEFT JOIN (SELECT name, uuid FROM ' . $this->_extra['history_table'] . ') AS history ON bans.uuid = history.uuid' .
+ ' ORDER BY bans.time DESC';
+ }
+
+ // Get warnings
+ private function getWarningsQuery(){
+ return 'SELECT bans.id, bans.ip, bans.uuid, bans.reason, bans.banned_by_uuid, bans.banned_by_name, bans.removed_by_uuid, bans.removed_by_name, bans.removed_by_date, bans.time, bans.until, bans.ipban, bans.active, bans.server_scope, bans.server_origin, history.name, "warning" as type' .
+ ' FROM ' . $this->_extra['warnings_table'] . ' AS bans' .
+ ' LEFT JOIN (SELECT name, uuid FROM ' . $this->_extra['history_table'] . ') AS history ON bans.uuid = history.uuid' .
+ ' ORDER BY bans.time DESC';
+ }
+
+}
\ No newline at end of file
diff --git a/modules/Infractions/config.php b/upload/modules/Infractions/config.php
similarity index 100%
rename from modules/Infractions/config.php
rename to upload/modules/Infractions/config.php
diff --git a/modules/Infractions/extra.php b/upload/modules/Infractions/extra.php
similarity index 96%
rename from modules/Infractions/extra.php
rename to upload/modules/Infractions/extra.php
index 3253423..984dbaf 100644
--- a/modules/Infractions/extra.php
+++ b/upload/modules/Infractions/extra.php
@@ -1,13 +1,13 @@
- array(
- 'bans_table' => 'litebans_bans',
- 'kicks_table' => 'litebans_kicks',
- 'mutes_table' => 'litebans_mutes',
- 'warnings_table' => 'litebans_warnings',
- 'history_table' => 'litebans_history'
- )
+ array(
+ 'bans_table' => 'litebans_bans',
+ 'kicks_table' => 'litebans_kicks',
+ 'mutes_table' => 'litebans_mutes',
+ 'warnings_table' => 'litebans_warnings',
+ 'history_table' => 'litebans_history'
+ )
);
\ No newline at end of file
diff --git a/modules/Infractions/init.php b/upload/modules/Infractions/init.php
similarity index 96%
rename from modules/Infractions/init.php
rename to upload/modules/Infractions/init.php
index c3ec99e..6596b52 100644
--- a/modules/Infractions/init.php
+++ b/upload/modules/Infractions/init.php
@@ -1,17 +1,17 @@
- 'Infractions',
- 'search' => 'Search',
- 'username' => 'Username',
- 'staff_member' => 'Staff Member',
- 'action' => 'Action',
- 'reason' => 'Reason',
- 'view' => 'View',
- 'issued' => 'Issued',
- 'ban' => 'Ban',
- 'temp_ban' => 'Temp Ban',
- 'mute' => 'Mute',
- 'temp_mute' => 'Temp Mute',
- 'kick' => 'Kick',
- 'warning' => 'Warning',
- 'expired' => 'Expired',
- 'active' => 'Active',
- 'no_infractions' => 'No infractions found.',
- 'unknown' => 'Unknown',
-
- /*
- * Staff Panel
- */
- 'infractions_settings' => 'Infractions Settings',
- 'link_location' => 'Link Location',
- 'plugin' => 'Plugin Integration',
- 'database_settings' => 'Update Database Settings',
- 'database_address' => 'Database Address',
- 'database_name' => 'Database Name',
- 'database_username' => 'Database Username',
- 'database_port' => 'Database Port',
- 'database_password' => 'Database Password',
- 'infractions_settings_updated_successfully' => 'Infractions settings have been updated successfully.',
- 'unable_to_write_infractions_config' => 'Unable to write to file modules/infractions/config.php. Please check file permissions.',
-);
+ 'Infractions',
+ 'search' => 'Search',
+ 'username' => 'Username',
+ 'staff_member' => 'Staff Member',
+ 'action' => 'Action',
+ 'reason' => 'Reason',
+ 'view' => 'View',
+ 'issued' => 'Issued',
+ 'ban' => 'Ban',
+ 'temp_ban' => 'Temp Ban',
+ 'mute' => 'Mute',
+ 'temp_mute' => 'Temp Mute',
+ 'kick' => 'Kick',
+ 'warning' => 'Warning',
+ 'expired' => 'Expired',
+ 'active' => 'Active',
+ 'no_infractions' => 'No infractions found.',
+ 'unknown' => 'Unknown',
+
+ /*
+ * Staff Panel
+ */
+ 'infractions_settings' => 'Infractions Settings',
+ 'link_location' => 'Link Location',
+ 'plugin' => 'Plugin Integration',
+ 'database_settings' => 'Update Database Settings',
+ 'database_address' => 'Database Address',
+ 'database_name' => 'Database Name',
+ 'database_username' => 'Database Username',
+ 'database_port' => 'Database Port',
+ 'database_password' => 'Database Password',
+ 'infractions_settings_updated_successfully' => 'Infractions settings have been updated successfully.',
+ 'unable_to_write_infractions_config' => 'Unable to write to file modules/infractions/config.php. Please check file permissions.',
+);
diff --git a/modules/Infractions/language/Romanian/infractions.php b/upload/modules/Infractions/language/Romanian/infractions.php
similarity index 93%
rename from modules/Infractions/language/Romanian/infractions.php
rename to upload/modules/Infractions/language/Romanian/infractions.php
index 4ce87cc..b8ae1d3 100644
--- a/modules/Infractions/language/Romanian/infractions.php
+++ b/upload/modules/Infractions/language/Romanian/infractions.php
@@ -1,50 +1,50 @@
- 'Infracțiuni',
- 'search' => 'Căutare',
- 'username' => 'Nume de utilizator',
- 'staff_member' => 'Membru Staff',
- 'action' => 'Acțiune',
- 'reason' => 'Motiv',
- 'view' => 'Vizualizare',
- 'issued' => 'Emis',
- 'ban' => 'Banat',
- 'temp_ban' => 'Banat temporar',
- 'mute' => 'Mute',
- 'temp_mute' => 'Mute temporar',
- 'kick' => 'Kick',
- 'warning' => 'Avertisment',
- 'expired' => 'Expirat',
- 'active' => 'Activ',
- 'no_infractions' => 'Nu s-au găsit infracțiuni.',
- 'unknown' => 'Necunoscut',
-
- /*
- * Staff Panel
- */
- 'infractions_settings' => 'Infractions Settings',
- 'link_location' => 'Link Location',
- 'plugin' => 'Plugin Integration',
- 'database_settings' => 'Update Database Settings',
- 'database_address' => 'Database Address',
- 'database_name' => 'Database Name',
- 'database_username' => 'Database Username',
- 'database_port' => 'Database Port',
- 'database_password' => 'Database Password',
- 'infractions_settings_updated_successfully' => 'Infractions settings have been updated successfully.',
- 'unable_to_write_infractions_config' => 'Unable to write to file modules/infractions/config.php. Please check file permissions.',
-);
+ 'Infracțiuni',
+ 'search' => 'Căutare',
+ 'username' => 'Nume de utilizator',
+ 'staff_member' => 'Membru Staff',
+ 'action' => 'Acțiune',
+ 'reason' => 'Motiv',
+ 'view' => 'Vizualizare',
+ 'issued' => 'Emis',
+ 'ban' => 'Banat',
+ 'temp_ban' => 'Banat temporar',
+ 'mute' => 'Mute',
+ 'temp_mute' => 'Mute temporar',
+ 'kick' => 'Kick',
+ 'warning' => 'Avertisment',
+ 'expired' => 'Expirat',
+ 'active' => 'Activ',
+ 'no_infractions' => 'Nu s-au găsit infracțiuni.',
+ 'unknown' => 'Necunoscut',
+
+ /*
+ * Staff Panel
+ */
+ 'infractions_settings' => 'Infractions Settings',
+ 'link_location' => 'Link Location',
+ 'plugin' => 'Plugin Integration',
+ 'database_settings' => 'Update Database Settings',
+ 'database_address' => 'Database Address',
+ 'database_name' => 'Database Name',
+ 'database_username' => 'Database Username',
+ 'database_port' => 'Database Port',
+ 'database_password' => 'Database Password',
+ 'infractions_settings_updated_successfully' => 'Infractions settings have been updated successfully.',
+ 'unable_to_write_infractions_config' => 'Unable to write to file modules/infractions/config.php. Please check file permissions.',
+);
diff --git a/modules/Infractions/module.php b/upload/modules/Infractions/module.php
similarity index 96%
rename from modules/Infractions/module.php
rename to upload/modules/Infractions/module.php
index 39103fb..478ea01 100644
--- a/modules/Infractions/module.php
+++ b/upload/modules/Infractions/module.php
@@ -1,129 +1,129 @@
-_language = $language;
- $this->_infractions_language = $infractions_language;
- $this->_cache = $cache;
-
- $name = 'Infractions';
- $author = 'Samerton';
- $module_version = '1.0.0';
- $nameless_version = '2.0.0-pr6';
-
- parent::__construct($this, $name, $author, $module_version, $nameless_version);
-
- // Define URLs which belong to this module
- $pages->add('Infractions', '/panel/infractions', 'pages/panel/index.php');
- $pages->add('Infractions', '/infractions', 'pages/infractions.php');
- }
-
- public function onInstall(){
- // Install module
- // Queries
- $queries = new Queries();
- try {
- // Update main admin group permissions
- $group = $queries->getWhere('groups', array('id', '=', 2));
- $group = $group[0];
-
- $group_permissions = json_decode($group->permissions, TRUE);
- $group_permissions['admincp.infractions.settings'] = 1;
-
- $group_permissions = json_encode($group_permissions);
- $queries->update('groups', 2, array('permissions' => $group_permissions));
- } catch(Exception $e){
- // Error
- }
- }
-
- public function onUninstall(){
- // Uninstall module
- }
-
- public function onEnable(){
- // No actions necessary
- }
-
- public function onDisable(){
- // No actions necessary
- }
-
- public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template){
- // Permissions
- PermissionHandler::registerPermissions('Infractions', array(
- 'admincp.infractions.settings' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_infractions_language->get('infractions', 'infractions_settings')
- ));
-
- // navigation link location
- $cache->setCache('infractions_module_cache');
- if(!$cache->isCached('link_location')){
- $link_location = 1;
- $cache->store('link_location', 1);
- } else {
- $link_location = $cache->retrieve('link_location');
- }
-
- // Add link to navbar
- $cache->setCache('navbar_order');
- if(!$cache->isCached('infractions_order')){
- $order = 14;
- $cache->store('infractions_order', 14);
- } else {
- $order = $cache->retrieve('infractions_order');
- }
- $cache->setCache('navbar_icons');
- if(!$cache->isCached('infractions_icon'))
- $icon = '';
- else
- $icon = $cache->retrieve('infractions_icon');
-
- switch($link_location){
- case 1:
- // Navbar
- $navs[0]->add('infractions', $this->_infractions_language->get('infractions', 'infractions'), URL::build('/infractions'), 'top', null, $order, $icon);
- break;
- case 2:
- // "More" dropdown
-
- $navs[0]->addItemToDropdown('more_dropdown', 'infractions', $this->_infractions_language->get('infractions', 'infractions'), URL::build('/infractions'), 'top', null, $icon, $order);
- break;
- case 3:
- // Footer
- $navs[0]->add('infractions', $this->_infractions_language->get('infractions', 'infractions'), URL::build('/infractions'), 'footer', null, $order, $icon);
- break;
- }
-
- if(defined('BACK_END')){
- if($user->hasPermission('admincp.infractions.settings')){
- $cache->setCache('panel_sidebar');
- if(!$cache->isCached('infractions_order')){
- $order = 23;
- $cache->store('infractions_order', 23);
- } else {
- $order = $cache->retrieve('infractions_order');
- }
- if(!$cache->isCached('infractions_icon')){
- $icon = '';
- $cache->store('infractions_icon', $icon);
- } else {
- $icon = $cache->retrieve('infractions_icon');
- }
- $navs[2]->add('infractions_divider', mb_strtoupper($this->_infractions_language->get('infractions', 'infractions'), 'UTF-8'), 'divider', 'top', null, $order, '');
- $navs[2]->add('infractions', $this->_infractions_language->get('infractions', 'infractions'), URL::build('/panel/infractions'), 'top', null, $order + 0.1, $icon);
- }
- }
-
- }
+_language = $language;
+ $this->_infractions_language = $infractions_language;
+ $this->_cache = $cache;
+
+ $name = 'Infractions';
+ $author = 'Samerton';
+ $module_version = '1.0.0';
+ $nameless_version = '2.0.0-pr7';
+
+ parent::__construct($this, $name, $author, $module_version, $nameless_version);
+
+ // Define URLs which belong to this module
+ $pages->add('Infractions', '/panel/infractions', 'pages/panel/index.php');
+ $pages->add('Infractions', '/infractions', 'pages/infractions.php');
+ }
+
+ public function onInstall(){
+ // Install module
+ // Queries
+ $queries = new Queries();
+ try {
+ // Update main admin group permissions
+ $group = $queries->getWhere('groups', array('id', '=', 2));
+ $group = $group[0];
+
+ $group_permissions = json_decode($group->permissions, TRUE);
+ $group_permissions['admincp.infractions.settings'] = 1;
+
+ $group_permissions = json_encode($group_permissions);
+ $queries->update('groups', 2, array('permissions' => $group_permissions));
+ } catch(Exception $e){
+ // Error
+ }
+ }
+
+ public function onUninstall(){
+ // Uninstall module
+ }
+
+ public function onEnable(){
+ // No actions necessary
+ }
+
+ public function onDisable(){
+ // No actions necessary
+ }
+
+ public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template){
+ // Permissions
+ PermissionHandler::registerPermissions('Infractions', array(
+ 'admincp.infractions.settings' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_infractions_language->get('infractions', 'infractions_settings')
+ ));
+
+ // navigation link location
+ $cache->setCache('infractions_module_cache');
+ if(!$cache->isCached('link_location')){
+ $link_location = 1;
+ $cache->store('link_location', 1);
+ } else {
+ $link_location = $cache->retrieve('link_location');
+ }
+
+ // Add link to navbar
+ $cache->setCache('navbar_order');
+ if(!$cache->isCached('infractions_order')){
+ $order = 14;
+ $cache->store('infractions_order', 14);
+ } else {
+ $order = $cache->retrieve('infractions_order');
+ }
+ $cache->setCache('navbar_icons');
+ if(!$cache->isCached('infractions_icon'))
+ $icon = '';
+ else
+ $icon = $cache->retrieve('infractions_icon');
+
+ switch($link_location){
+ case 1:
+ // Navbar
+ $navs[0]->add('infractions', $this->_infractions_language->get('infractions', 'infractions'), URL::build('/infractions'), 'top', null, $order, $icon);
+ break;
+ case 2:
+ // "More" dropdown
+
+ $navs[0]->addItemToDropdown('more_dropdown', 'infractions', $this->_infractions_language->get('infractions', 'infractions'), URL::build('/infractions'), 'top', null, $icon, $order);
+ break;
+ case 3:
+ // Footer
+ $navs[0]->add('infractions', $this->_infractions_language->get('infractions', 'infractions'), URL::build('/infractions'), 'footer', null, $order, $icon);
+ break;
+ }
+
+ if(defined('BACK_END')){
+ if($user->hasPermission('admincp.infractions.settings')){
+ $cache->setCache('panel_sidebar');
+ if(!$cache->isCached('infractions_order')){
+ $order = 23;
+ $cache->store('infractions_order', 23);
+ } else {
+ $order = $cache->retrieve('infractions_order');
+ }
+ if(!$cache->isCached('infractions_icon')){
+ $icon = '';
+ $cache->store('infractions_icon', $icon);
+ } else {
+ $icon = $cache->retrieve('infractions_icon');
+ }
+ $navs[2]->add('infractions_divider', mb_strtoupper($this->_infractions_language->get('infractions', 'infractions'), 'UTF-8'), 'divider', 'top', null, $order, '');
+ $navs[2]->add('infractions', $this->_infractions_language->get('infractions', 'infractions'), URL::build('/panel/infractions'), 'top', null, $order + 0.1, $icon);
+ }
+ }
+
+ }
}
\ No newline at end of file
diff --git a/modules/Infractions/pages/infractions.php b/upload/modules/Infractions/pages/infractions.php
similarity index 96%
rename from modules/Infractions/pages/infractions.php
rename to upload/modules/Infractions/pages/infractions.php
index 675a5c2..72603e8 100644
--- a/modules/Infractions/pages/infractions.php
+++ b/upload/modules/Infractions/pages/infractions.php
@@ -1,228 +1,230 @@
-get('infractions', 'infractions');
-require_once(ROOT_PATH . '/core/templates/frontend_init.php');
-
-// Get page
-if(isset($_GET['p'])){
- if(!is_numeric($_GET['p'])){
- Redirect::to(URL::build('/infractions'));
- die();
- } else $p = $_GET['p'];
-} else $p = 1;
-
-$timeago = new Timeago(TIMEZONE);
-
-if(!file_exists(ROOT_PATH . '/modules/Infractions/config.php')){
- die('Please configure the Infractions module in the StaffCP first!');
-}
-require(ROOT_PATH . '/modules/Infractions/config.php');
-if(!isset($inf_db)) {
- die('Please configure the Infractions module in the StaffCP first!');
-}
-require(ROOT_PATH . '/core/integration/uuid.php');
-require_once(ROOT_PATH . '/modules/Infractions/classes/Infractions.php');
-switch($inf_config['plugin']) {
- case 'litebans':
- // Litebans integration
- require_once(ROOT_PATH . '/modules/Infractions/classes/LiteBans.php');
- $infractions = new LiteBans($inf_db, $infractions_language);
- break;
- default:
- die('Plugin not supported!');
- break;
-}
-
-if(!isset($_GET['view']) && !isset($_GET['id'])){
- $infractions_list = $infractions->listInfractions();
-
- if(count($infractions_list)) {
- // Pagination
- $paginator = new Paginator((isset($template_pagination) ? $template_pagination : array()));
- $results = $paginator->getLimited($infractions_list, 10, $p, count($infractions_list));
- $pagination = $paginator->generate(7, URL::build('/infractions', true));
-
- $smarty->assign('PAGINATION', $pagination);
-
- $infractions_array = array();
- $users_array = array();
-
- foreach($results->data as $result){
- // Check if the user exists
- if(!isset($users_array[$result->name])){
- $query_user = new User($result->name, 'username');
- if($query_user->exists()){
- $users_array[$result->name] = array(
- 'profile' => URL::build('/profile/' . Output::getClean($result->name)),
- 'style' => $user->getGroupClass($query_user->data()->id),
- 'avatar' => $user->getAvatar($query_user->data()->id)
- );
- } else {
- $users_array[$result->name] = array(
- 'profile' => null,
- 'style' => null,
- 'avatar' => Util::getAvatarFromUUID($result->uuid)
- );
- }
- }
- if(!isset($users_array[$result->banned_by_name])){
- $query_user = new User($result->banned_by_name, 'username');
- if($query_user->exists()){
- $users_array[$result->banned_by_name] = array(
- 'profile' => URL::build('/profile/' . Output::getClean($result->banned_by_name)),
- 'style' => $user->getGroupClass($query_user->data()->id),
- 'avatar' => $user->getAvatar($query_user->data()->id)
- );
- } else {
- $users_array[$result->banned_by_name] = array(
- 'profile' => null,
- 'style' => null,
- 'avatar' => Util::getAvatarFromUUID($result->banned_by_uuid)
- );
- }
- }
- if(isset($result->removed_by_name) && !isset($users_array[$result->removed_by_name])){
- $query_user = new User($result->removed_by_name);
- if($query_user->exists()){
- $users_array[$result->removed_by_name] = array(
- 'profile' => URL::build('/profile/' . Output::getClean($result->removed_by_name)),
- 'style' => $user->getGroupClass($query_user->data()->id),
- 'avatar' => $user->getAvatar($query_user->data()->id)
- );
- } else {
- $users_array[$result->removed_by_name] = array(
- 'profile' => null,
- 'style' => null,
- 'avatar' => Util::getAvatarFromUUID($result->removed_by_uuid)
- );
- }
- }
-
- if(isset($result->removed_by_uuid) && isset($result->removed_by_name) && isset($result->removed_by_date)){
- $removed_by_uuid = $result->removed_by_uuid;
- $removed_by_name = $result->removed_by_name;
- $removed_by_date = round($result->removed_by_date / 1000);
- $removed_by_link = $users_array[$result->removed_by_name]['profile'];
- $removed_by_style = $users_array[$result->removed_by_name]['style'];
- $removed_by_avatar = $users_array[$result->removed_by_name]['avatar'];
- } else {
- $removed_by_uuid = null;
- $removed_by_name = null;
- $removed_by_date = null;
- $removed_by_link = null;
- $removed_by_style = null;
- $removed_by_avatar = null;
- }
-
- switch($result->type){
- case 'ban':
- if($result->until > 0) {
- $type_id = 1; // temp ban
- $type = $infractions_language->get('infractions', 'temp_ban');
- } else {
- $type_id = 2; // ban
- $type = $infractions_language->get('infractions', 'ban');
- }
- break;
- case 'mute':
- if($result->until > 0) {
- $type_id = 3; // temp mute
- $type = $infractions_language->get('infractions', 'temp_mute');
- } else {
- $type_id = 4; // mute
- $type = $infractions_language->get('infractions', 'mute');
- }
- break;
- case 'kick':
- $type_id = 5; // kick
- $type = $infractions_language->get('infractions', 'kick');
- break;
- case 'warning':
- $type_id = 6; // warning
- $type = $infractions_language->get('infractions', 'warning');
- break;
- default:
- $type_id = 7; // unknown
- $type = $infractions_language->get('infractions', 'unknown');
- break;
- }
-
- $infractions_array[] = array(
- 'username' => Output::getClean($result->name),
- 'profile' => $users_array[$result->name]['profile'],
- 'username_style' => $users_array[$result->name]['style'],
- 'avatar' => $users_array[$result->name]['avatar'],
- 'staff_member' => Output::getClean($result->banned_by_name),
- 'staff_member_link' => $users_array[$result->banned_by_name]['profile'],
- 'staff_member_style' => $users_array[$result->banned_by_name]['style'],
- 'staff_member_avatar' => $users_array[$result->banned_by_name]['avatar'],
- 'revoked_staff_member' => Output::getClean($result->banned_by_name),
- 'revoked_staff_member_link' => $users_array[$result->banned_by_name]['profile'],
- 'revoked_staff_member_style' => $users_array[$result->banned_by_name]['style'],
- 'revoked_staff_member_avatar' => $users_array[$result->banned_by_name]['avatar'],
- 'issued' => $timeago->inWords(date('d M Y, H:i', (int)($result->time / 1000)), $language->getTimeLanguage()),
- 'issued_full' => date('d M Y, H:i', (int)($result->time / 1000)),
- 'action' => $type,
- 'action_id' => $type_id,
- 'expires' => (($type_id == 1 || $type_id == 3) ? $timeago->inWords(date('d M Y, H:i', (int)($result->until / 1000)), $language->getTimeLanguage()) : null),
- 'expires_full' => (($type_id == 1 || $type_id == 3) ? date('d M Y, H:i', (int)($result->until / 1000)) : null),
- 'revoked' => ((isset($result->active) && $result->active == 1) ? 0 : 1),
- 'revoked_full' => ((!isset($result->active) || $result->active == 0) ? $infractions_language->get('infractions', 'expired') : $infractions_language->get('infractions', 'active')),
- 'reason' => Output::getPurified($result->reason),
- 'view_link' => URL::build('/infractions/' . Output::getClean($result->type) . '/' . $result->id)
- );
- }
- $infractions_list = null;
-
- // Smarty variables
- $smarty->assign(array(
- 'INFRACTIONS' => $infractions_language->get('infractions', 'infractions'),
- 'INFRACTIONS_LIST' => $infractions_array,
- 'SEARCH' => $infractions_language->get('infractions', 'search'),
- 'TOKEN' => Token::generate(),
- 'USERNAME' => $infractions_language->get('infractions', 'username'),
- 'STAFF_MEMBER' => $infractions_language->get('infractions', 'staff_member'),
- 'ACTION' => $infractions_language->get('infractions', 'action'),
- 'REASON' => $infractions_language->get('infractions', 'reason'),
- 'VIEW' => $infractions_language->get('infractions', 'view'),
- 'ISSUED' => $infractions_language->get('infractions', 'issued')
- ));
- } else
- $smarty->assign(array(
- 'INFRACTIONS' => $infractions_language->get('infractions', 'infractions'),
- 'NO_INFRACTIONS' => $infractions_language->get('infractions', 'no_infractions')
- ));
-
- $template_file = 'infractions/infractions.tpl';
-} else if(isset($_GET['view'])) {
-
-} else if(isset($_GET['id'])) {
-
-}
-
-// Load modules + template
-Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets);
-
-$page_load = microtime(true) - $start;
-define('PAGE_LOAD_TIME', str_replace('{x}', round($page_load, 3), $language->get('general', 'page_loaded_in')));
-
-$template->onPageLoad();
-
-$smarty->assign('WIDGETS', $widgets->getWidgets());
-
-require(ROOT_PATH . '/core/templates/navbar.php');
-require(ROOT_PATH . '/core/templates/footer.php');
-
-// Display template
+get('infractions', 'infractions');
+require_once(ROOT_PATH . '/core/templates/frontend_init.php');
+
+// Get page
+if(isset($_GET['p'])){
+ if(!is_numeric($_GET['p'])){
+ Redirect::to(URL::build('/infractions'));
+ die();
+ } else $p = $_GET['p'];
+} else $p = 1;
+
+$timeago = new Timeago(TIMEZONE);
+
+if(!file_exists(ROOT_PATH . '/modules/Infractions/config.php')){
+ die('Please configure the Infractions module in the StaffCP first!');
+}
+require(ROOT_PATH . '/modules/Infractions/config.php');
+if(!isset($inf_db)) {
+ die('Please configure the Infractions module in the StaffCP first!');
+}
+require(ROOT_PATH . '/core/integration/uuid.php');
+require_once(ROOT_PATH . '/modules/Infractions/classes/Infractions.php');
+switch($inf_config['plugin']) {
+ case 'litebans':
+ // Litebans integration
+ require_once(ROOT_PATH . '/modules/Infractions/classes/LiteBans.php');
+ $infractions = new LiteBans($inf_db, $infractions_language);
+ break;
+ default:
+ die('Plugin not supported!');
+ break;
+}
+
+if(!isset($_GET['view']) && !isset($_GET['id'])){
+ $infractions_list = $infractions->listInfractions($p, 10);
+
+ if(count($infractions_list)) {
+ // Pagination
+ $paginator = new Paginator((isset($template_pagination) ? $template_pagination : array()));
+ $paginator->setValues($infractions_list['total'], 10, $p);
+ $pagination = $paginator->generate(7, URL::build('/infractions', true));
+
+ $smarty->assign('PAGINATION', $pagination);
+
+ unset($infractions_list['total']);
+
+ $infractions_array = array();
+ $users_array = array();
+
+ foreach($infractions_list as $result){
+ // Check if the user exists
+ if(!isset($users_array[$result->name])){
+ $query_user = new User($result->name, 'username');
+ if($query_user->exists()){
+ $users_array[$result->name] = array(
+ 'profile' => URL::build('/profile/' . Output::getClean($result->name)),
+ 'style' => $user->getGroupClass($query_user->data()->id),
+ 'avatar' => $user->getAvatar($query_user->data()->id)
+ );
+ } else {
+ $users_array[$result->name] = array(
+ 'profile' => null,
+ 'style' => null,
+ 'avatar' => Util::getAvatarFromUUID($result->uuid)
+ );
+ }
+ }
+ if(!isset($users_array[$result->banned_by_name])){
+ $query_user = new User($result->banned_by_name, 'username');
+ if($query_user->exists()){
+ $users_array[$result->banned_by_name] = array(
+ 'profile' => URL::build('/profile/' . Output::getClean($result->banned_by_name)),
+ 'style' => $user->getGroupClass($query_user->data()->id),
+ 'avatar' => $user->getAvatar($query_user->data()->id)
+ );
+ } else {
+ $users_array[$result->banned_by_name] = array(
+ 'profile' => null,
+ 'style' => null,
+ 'avatar' => Util::getAvatarFromUUID($result->banned_by_uuid)
+ );
+ }
+ }
+ if(isset($result->removed_by_name) && !isset($users_array[$result->removed_by_name])){
+ $query_user = new User($result->removed_by_name);
+ if($query_user->exists()){
+ $users_array[$result->removed_by_name] = array(
+ 'profile' => URL::build('/profile/' . Output::getClean($result->removed_by_name)),
+ 'style' => $user->getGroupClass($query_user->data()->id),
+ 'avatar' => $user->getAvatar($query_user->data()->id)
+ );
+ } else {
+ $users_array[$result->removed_by_name] = array(
+ 'profile' => null,
+ 'style' => null,
+ 'avatar' => Util::getAvatarFromUUID($result->removed_by_uuid)
+ );
+ }
+ }
+
+ if(isset($result->removed_by_uuid) && isset($result->removed_by_name) && isset($result->removed_by_date)){
+ $removed_by_uuid = $result->removed_by_uuid;
+ $removed_by_name = $result->removed_by_name;
+ $removed_by_date = round($result->removed_by_date / 1000);
+ $removed_by_link = $users_array[$result->removed_by_name]['profile'];
+ $removed_by_style = $users_array[$result->removed_by_name]['style'];
+ $removed_by_avatar = $users_array[$result->removed_by_name]['avatar'];
+ } else {
+ $removed_by_uuid = null;
+ $removed_by_name = null;
+ $removed_by_date = null;
+ $removed_by_link = null;
+ $removed_by_style = null;
+ $removed_by_avatar = null;
+ }
+
+ switch($result->type){
+ case 'ban':
+ if($result->until > 0) {
+ $type_id = 1; // temp ban
+ $type = $infractions_language->get('infractions', 'temp_ban');
+ } else {
+ $type_id = 2; // ban
+ $type = $infractions_language->get('infractions', 'ban');
+ }
+ break;
+ case 'mute':
+ if($result->until > 0) {
+ $type_id = 3; // temp mute
+ $type = $infractions_language->get('infractions', 'temp_mute');
+ } else {
+ $type_id = 4; // mute
+ $type = $infractions_language->get('infractions', 'mute');
+ }
+ break;
+ case 'kick':
+ $type_id = 5; // kick
+ $type = $infractions_language->get('infractions', 'kick');
+ break;
+ case 'warning':
+ $type_id = 6; // warning
+ $type = $infractions_language->get('infractions', 'warning');
+ break;
+ default:
+ $type_id = 7; // unknown
+ $type = $infractions_language->get('infractions', 'unknown');
+ break;
+ }
+
+ $infractions_array[] = array(
+ 'username' => Output::getClean($result->name),
+ 'profile' => $users_array[$result->name]['profile'],
+ 'username_style' => $users_array[$result->name]['style'],
+ 'avatar' => $users_array[$result->name]['avatar'],
+ 'staff_member' => Output::getClean($result->banned_by_name),
+ 'staff_member_link' => $users_array[$result->banned_by_name]['profile'],
+ 'staff_member_style' => $users_array[$result->banned_by_name]['style'],
+ 'staff_member_avatar' => $users_array[$result->banned_by_name]['avatar'],
+ 'revoked_staff_member' => Output::getClean($result->banned_by_name),
+ 'revoked_staff_member_link' => $users_array[$result->banned_by_name]['profile'],
+ 'revoked_staff_member_style' => $users_array[$result->banned_by_name]['style'],
+ 'revoked_staff_member_avatar' => $users_array[$result->banned_by_name]['avatar'],
+ 'issued' => $timeago->inWords(date('d M Y, H:i', (int)($result->time / 1000)), $language->getTimeLanguage()),
+ 'issued_full' => date('d M Y, H:i', (int)($result->time / 1000)),
+ 'action' => $type,
+ 'action_id' => $type_id,
+ 'expires' => (($type_id == 1 || $type_id == 3) ? $timeago->inWords(date('d M Y, H:i', (int)($result->until / 1000)), $language->getTimeLanguage()) : null),
+ 'expires_full' => (($type_id == 1 || $type_id == 3) ? date('d M Y, H:i', (int)($result->until / 1000)) : null),
+ 'revoked' => ((isset($result->active) && $result->active == 1) ? 0 : 1),
+ 'revoked_full' => ((!isset($result->active) || $result->active == 0) ? $infractions_language->get('infractions', 'expired') : $infractions_language->get('infractions', 'active')),
+ 'reason' => Output::getPurified($result->reason),
+ 'view_link' => URL::build('/infractions/' . Output::getClean($result->type) . '/' . $result->id)
+ );
+ }
+ $infractions_list = null;
+
+ // Smarty variables
+ $smarty->assign(array(
+ 'INFRACTIONS' => $infractions_language->get('infractions', 'infractions'),
+ 'INFRACTIONS_LIST' => $infractions_array,
+ 'SEARCH' => $infractions_language->get('infractions', 'search'),
+ 'TOKEN' => Token::generate(),
+ 'USERNAME' => $infractions_language->get('infractions', 'username'),
+ 'STAFF_MEMBER' => $infractions_language->get('infractions', 'staff_member'),
+ 'ACTION' => $infractions_language->get('infractions', 'action'),
+ 'REASON' => $infractions_language->get('infractions', 'reason'),
+ 'VIEW' => $infractions_language->get('infractions', 'view'),
+ 'ISSUED' => $infractions_language->get('infractions', 'issued')
+ ));
+ } else
+ $smarty->assign(array(
+ 'INFRACTIONS' => $infractions_language->get('infractions', 'infractions'),
+ 'NO_INFRACTIONS' => $infractions_language->get('infractions', 'no_infractions')
+ ));
+
+ $template_file = 'infractions/infractions.tpl';
+} else if(isset($_GET['view'])) {
+
+} else if(isset($_GET['id'])) {
+
+}
+
+// Load modules + template
+Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets);
+
+$page_load = microtime(true) - $start;
+define('PAGE_LOAD_TIME', str_replace('{x}', round($page_load, 3), $language->get('general', 'page_loaded_in')));
+
+$template->onPageLoad();
+
+$smarty->assign('WIDGETS', $widgets->getWidgets());
+
+require(ROOT_PATH . '/core/templates/navbar.php');
+require(ROOT_PATH . '/core/templates/footer.php');
+
+// Display template
$template->displayTemplate($template_file, $smarty);
\ No newline at end of file
diff --git a/modules/Infractions/pages/panel/index.php b/upload/modules/Infractions/pages/panel/index.php
similarity index 95%
rename from modules/Infractions/pages/panel/index.php
rename to upload/modules/Infractions/pages/panel/index.php
index 543a0a0..cc7f7e8 100644
--- a/modules/Infractions/pages/panel/index.php
+++ b/upload/modules/Infractions/pages/panel/index.php
@@ -1,190 +1,190 @@
-isLoggedIn()){
- if(!$user->canViewACP()){
- // No
- Redirect::to(URL::build('/'));
- die();
- }
- if(!$user->isAdmLoggedIn()){
- // Needs to authenticate
- Redirect::to(URL::build('/panel/auth'));
- die();
- } else {
- if(!$user->hasPermission('admincp.infractions.settings')){
- require_once(ROOT_PATH . '/404.php');
- die();
- }
- }
-} else {
- // Not logged in
- Redirect::to(URL::build('/login'));
- die();
-}
-
-define('PAGE', 'panel');
-define('PARENT_PAGE', 'infractions');
-define('PANEL_PAGE', 'infractions');
-$page_title = $infractions_language->get('infractions', 'infractions');
-require_once(ROOT_PATH . '/core/templates/backend_init.php');
-
-// Handle input
-if(Input::exists()){
- $errors = array();
- if(Token::check(Input::get('token'))){
- // Get link location
- if(isset($_POST['link_location'])){
- switch($_POST['link_location']){
- case 1:
- case 2:
- case 3:
- case 4:
- $location = $_POST['link_location'];
- break;
- default:
- $location = 1;
- }
- } else
- $location = 1;
-
- // Update Link location cache
- $cache->setCache('infractions_module_cache');
- $cache->store('link_location', $location);
-
- // Update config
- $config_path = ROOT_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'Infractions' . DIRECTORY_SEPARATOR . 'config.php';
- if(file_exists($config_path)){
- if(is_writable($config_path)){
- require(ROOT_PATH . '/modules/Infractions/config.php');
- // Build new email config
- $config = ' \'' . str_replace('\'', '\\\'', (!empty($_POST['host']) ? $_POST['host'] : $inf_db['address'])) . '\',' . PHP_EOL .
- ' \'port\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['port']) ? $_POST['port'] : $inf_db['port'])) . '\',' . PHP_EOL .
- ' \'name\' => \'' . str_replace('\'', '\\\'', ((!empty($_POST['name'])) ? $_POST['name'] : $inf_db['name'])) . '\',' . PHP_EOL .
- ' \'username\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['username']) ? $_POST['username'] : $inf_db['username'])) . '\',' . PHP_EOL .
- ' \'password\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['password']) ? $_POST['password'] : $inf_db['password'])) . '\',' . PHP_EOL .
- ');' . PHP_EOL .
- '$inf_config = array(' . PHP_EOL .
- ' \'plugin\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['plugin']) ? $_POST['plugin'] : $inf_config['plugin'])) . '\',' . PHP_EOL .
- ');';
- $file = fopen($config_path, 'w');
- fwrite($file, $config);
- fclose($file);
-
- } else {
- // Permissions incorrect
- $errors[] = $language->get('admin', 'unable_to_write_infractions_config');
- }
-
- } else {
- // Create one now
- if(is_writable(ROOT_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'Infractions')){
- // Build new email config
- $config = ' \'' . str_replace('\'', '\\\'', (!empty($_POST['host']) ? $_POST['host'] : '')) . '\',' . PHP_EOL .
- ' \'port\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['port']) ? $_POST['port'] : 3306)) . '\',' . PHP_EOL .
- ' \'name\' => \'' . str_replace('\'', '\\\'', ((!empty($_POST['name'])) ? $_POST['name'] : '')) . '\',' . PHP_EOL .
- ' \'username\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['username']) ? $_POST['username'] : '')) . '\',' . PHP_EOL .
- ' \'password\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['password']) ? $_POST['password'] : '')) . '\',' . PHP_EOL .
- ');' . PHP_EOL .
- '$inf_config = array(' . PHP_EOL .
- ' \'plugin\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['plugin']) ? $_POST['plugin'] : 'litebans')) . '\',' . PHP_EOL .
- ');';
- $file = fopen($config_path, 'w');
- fwrite($file, $config);
- fclose($file);
-
- } else {
- $errors[] = $language->get('admin', 'unable_to_write_infractions_config');
- }
- }
-
- if(!count($errors)){
- // Redirect to refresh config values
- Session::flash('infractions_success', $infractions_language->get('infractions', 'infractions_settings_updated_successfully'));
- Redirect::to(URL::build('/panel/infractions'));
- die();
- }
- } else {
- // Invalid token
- $errors[] = $language->get('general', 'invalid_token');
- }
-}
-
-if(!isset($inf_db) && file_exists(ROOT_PATH . '/modules/Infractions/config.php')){
- require_once(ROOT_PATH . '/modules/Infractions/config.php');
-}
-
-// Retrive link_location from cache
-$cache->setCache('infractions_module_cache');
-$link_location = $cache->retrieve('link_location');
-
-// Load modules + template
-Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets);
-
-if(Session::exists('infractions_success'))
- $success = Session::flash('infractions_success');
-
-if(isset($success))
- $smarty->assign(array(
- 'SUCCESS' => $success,
- 'SUCCESS_TITLE' => $language->get('general', 'success')
- ));
-
-if(isset($errors) && count($errors))
- $smarty->assign(array(
- 'ERRORS' => $errors,
- 'ERRORS_TITLE' => $language->get('general', 'error')
- ));
-
-$smarty->assign(array(
- 'PARENT_PAGE' => PARENT_PAGE,
- 'PAGE' => PANEL_PAGE,
- 'DASHBOARD' => $language->get('admin', 'dashboard'),
- 'INFO' => $language->get('general', 'info'),
- 'INFRACTIONS' => $infractions_language->get('infractions', 'infractions'),
- 'DATABASE_SETTINGS' => $infractions_language->get('infractions', 'database_settings'),
- 'PLUGIN' => $infractions_language->get('infractions', 'plugin'),
- 'PLUGIN_VALUE' => (!empty($inf_config['plugin']) ? Output::getClean($inf_config['plugin']) : 'litebans'),
- 'LINK_LOCATION' => $infractions_language->get('infractions', 'link_location'),
- 'LINK_LOCATION_VALUE' => $link_location,
- 'LINK_NAVBAR' => $language->get('admin', 'page_link_navbar'),
- 'LINK_MORE' => $language->get('admin', 'page_link_more'),
- 'LINK_FOOTER' => $language->get('admin', 'page_link_footer'),
- 'LINK_NONE' => $language->get('admin', 'page_link_none'),
- 'ADDRESS' => $infractions_language->get('infractions', 'database_address'),
- 'ADDRESS_VALUE' => (!empty($inf_db['address']) ? Output::getClean($inf_db['address']) : ''),
- 'NAME' => $infractions_language->get('infractions', 'database_name'),
- 'NAME_VALUE' => (!empty($inf_db['name']) ? Output::getClean($inf_db['name']) : ''),
- 'USERNAME' => $infractions_language->get('infractions', 'database_username'),
- 'USERNAME_VALUE' => (!empty($inf_db['username']) ? Output::getClean($inf_db['username']) : ''),
- 'PORT' => $infractions_language->get('infractions', 'database_port'),
- 'PORT_VALUE' => (!empty($inf_db['port']) ? Output::getClean($inf_db['port']) : '3306'),
- 'PASSWORD' => $infractions_language->get('infractions', 'database_password'),
- 'INFO' => $language->get('general', 'info'),
- 'PASSWORD_HIDDEN' => $language->get('admin', 'email_password_hidden'),
- 'TOKEN' => Token::get(),
- 'SUBMIT' => $language->get('general', 'submit')
-));
-
-$page_load = microtime(true) - $start;
-define('PAGE_LOAD_TIME', str_replace('{x}', round($page_load, 3), $language->get('general', 'page_loaded_in')));
-
-$template->onPageLoad();
-
-require(ROOT_PATH . '/core/templates/panel_navbar.php');
-
-// Display template
+isLoggedIn()){
+ if(!$user->canViewACP()){
+ // No
+ Redirect::to(URL::build('/'));
+ die();
+ }
+ if(!$user->isAdmLoggedIn()){
+ // Needs to authenticate
+ Redirect::to(URL::build('/panel/auth'));
+ die();
+ } else {
+ if(!$user->hasPermission('admincp.infractions.settings')){
+ require_once(ROOT_PATH . '/404.php');
+ die();
+ }
+ }
+} else {
+ // Not logged in
+ Redirect::to(URL::build('/login'));
+ die();
+}
+
+define('PAGE', 'panel');
+define('PARENT_PAGE', 'infractions');
+define('PANEL_PAGE', 'infractions');
+$page_title = $infractions_language->get('infractions', 'infractions');
+require_once(ROOT_PATH . '/core/templates/backend_init.php');
+
+// Handle input
+if(Input::exists()){
+ $errors = array();
+ if(Token::check(Input::get('token'))){
+ // Get link location
+ if(isset($_POST['link_location'])){
+ switch($_POST['link_location']){
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ $location = $_POST['link_location'];
+ break;
+ default:
+ $location = 1;
+ }
+ } else
+ $location = 1;
+
+ // Update Link location cache
+ $cache->setCache('infractions_module_cache');
+ $cache->store('link_location', $location);
+
+ // Update config
+ $config_path = ROOT_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'Infractions' . DIRECTORY_SEPARATOR . 'config.php';
+ if(file_exists($config_path)){
+ if(is_writable($config_path)){
+ require(ROOT_PATH . '/modules/Infractions/config.php');
+ // Build new email config
+ $config = ' \'' . str_replace('\'', '\\\'', (!empty($_POST['host']) ? $_POST['host'] : $inf_db['address'])) . '\',' . PHP_EOL .
+ ' \'port\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['port']) ? $_POST['port'] : $inf_db['port'])) . '\',' . PHP_EOL .
+ ' \'name\' => \'' . str_replace('\'', '\\\'', ((!empty($_POST['name'])) ? $_POST['name'] : $inf_db['name'])) . '\',' . PHP_EOL .
+ ' \'username\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['username']) ? $_POST['username'] : $inf_db['username'])) . '\',' . PHP_EOL .
+ ' \'password\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['password']) ? $_POST['password'] : $inf_db['password'])) . '\',' . PHP_EOL .
+ ');' . PHP_EOL .
+ '$inf_config = array(' . PHP_EOL .
+ ' \'plugin\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['plugin']) ? $_POST['plugin'] : $inf_config['plugin'])) . '\',' . PHP_EOL .
+ ');';
+ $file = fopen($config_path, 'w');
+ fwrite($file, $config);
+ fclose($file);
+
+ } else {
+ // Permissions incorrect
+ $errors[] = $infractions_language->get('infractions', 'unable_to_write_infractions_config');
+ }
+
+ } else {
+ // Create one now
+ if(is_writable(ROOT_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'Infractions')){
+ // Build new email config
+ $config = ' \'' . str_replace('\'', '\\\'', (!empty($_POST['host']) ? $_POST['host'] : '')) . '\',' . PHP_EOL .
+ ' \'port\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['port']) ? $_POST['port'] : 3306)) . '\',' . PHP_EOL .
+ ' \'name\' => \'' . str_replace('\'', '\\\'', ((!empty($_POST['name'])) ? $_POST['name'] : '')) . '\',' . PHP_EOL .
+ ' \'username\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['username']) ? $_POST['username'] : '')) . '\',' . PHP_EOL .
+ ' \'password\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['password']) ? $_POST['password'] : '')) . '\',' . PHP_EOL .
+ ');' . PHP_EOL .
+ '$inf_config = array(' . PHP_EOL .
+ ' \'plugin\' => \'' . str_replace('\'', '\\\'', (!empty($_POST['plugin']) ? $_POST['plugin'] : 'litebans')) . '\',' . PHP_EOL .
+ ');';
+ $file = fopen($config_path, 'w');
+ fwrite($file, $config);
+ fclose($file);
+
+ } else {
+ $errors[] = $infractions_language->get('admin', 'unable_to_write_infractions_config');
+ }
+ }
+
+ if(!count($errors)){
+ // Redirect to refresh config values
+ Session::flash('infractions_success', $infractions_language->get('infractions', 'infractions_settings_updated_successfully'));
+ Redirect::to(URL::build('/panel/infractions'));
+ die();
+ }
+ } else {
+ // Invalid token
+ $errors[] = $language->get('general', 'invalid_token');
+ }
+}
+
+if(!isset($inf_db) && file_exists(ROOT_PATH . '/modules/Infractions/config.php')){
+ require_once(ROOT_PATH . '/modules/Infractions/config.php');
+}
+
+// Retrive link_location from cache
+$cache->setCache('infractions_module_cache');
+$link_location = $cache->retrieve('link_location');
+
+// Load modules + template
+Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets);
+
+if(Session::exists('infractions_success'))
+ $success = Session::flash('infractions_success');
+
+if(isset($success))
+ $smarty->assign(array(
+ 'SUCCESS' => $success,
+ 'SUCCESS_TITLE' => $language->get('general', 'success')
+ ));
+
+if(isset($errors) && count($errors))
+ $smarty->assign(array(
+ 'ERRORS' => $errors,
+ 'ERRORS_TITLE' => $language->get('general', 'error')
+ ));
+
+$smarty->assign(array(
+ 'PARENT_PAGE' => PARENT_PAGE,
+ 'PAGE' => PANEL_PAGE,
+ 'DASHBOARD' => $language->get('admin', 'dashboard'),
+ 'INFO' => $language->get('general', 'info'),
+ 'INFRACTIONS' => $infractions_language->get('infractions', 'infractions'),
+ 'DATABASE_SETTINGS' => $infractions_language->get('infractions', 'database_settings'),
+ 'PLUGIN' => $infractions_language->get('infractions', 'plugin'),
+ 'PLUGIN_VALUE' => (!empty($inf_config['plugin']) ? Output::getClean($inf_config['plugin']) : 'litebans'),
+ 'LINK_LOCATION' => $infractions_language->get('infractions', 'link_location'),
+ 'LINK_LOCATION_VALUE' => $link_location,
+ 'LINK_NAVBAR' => $language->get('admin', 'page_link_navbar'),
+ 'LINK_MORE' => $language->get('admin', 'page_link_more'),
+ 'LINK_FOOTER' => $language->get('admin', 'page_link_footer'),
+ 'LINK_NONE' => $language->get('admin', 'page_link_none'),
+ 'ADDRESS' => $infractions_language->get('infractions', 'database_address'),
+ 'ADDRESS_VALUE' => (!empty($inf_db['address']) ? Output::getClean($inf_db['address']) : ''),
+ 'NAME' => $infractions_language->get('infractions', 'database_name'),
+ 'NAME_VALUE' => (!empty($inf_db['name']) ? Output::getClean($inf_db['name']) : ''),
+ 'USERNAME' => $infractions_language->get('infractions', 'database_username'),
+ 'USERNAME_VALUE' => (!empty($inf_db['username']) ? Output::getClean($inf_db['username']) : ''),
+ 'PORT' => $infractions_language->get('infractions', 'database_port'),
+ 'PORT_VALUE' => (!empty($inf_db['port']) ? Output::getClean($inf_db['port']) : '3306'),
+ 'PASSWORD' => $infractions_language->get('infractions', 'database_password'),
+ 'INFO' => $language->get('general', 'info'),
+ 'PASSWORD_HIDDEN' => $language->get('admin', 'email_password_hidden'),
+ 'TOKEN' => Token::get(),
+ 'SUBMIT' => $language->get('general', 'submit')
+));
+
+$page_load = microtime(true) - $start;
+define('PAGE_LOAD_TIME', str_replace('{x}', round($page_load, 3), $language->get('general', 'page_loaded_in')));
+
+$template->onPageLoad();
+
+require(ROOT_PATH . '/core/templates/panel_navbar.php');
+
+// Display template
$template->displayTemplate('infractions/index.tpl', $smarty);
\ No newline at end of file
diff --git a/modules/Infractions/profile_tab.php b/upload/modules/Infractions/profile_tab.php
similarity index 94%
rename from modules/Infractions/profile_tab.php
rename to upload/modules/Infractions/profile_tab.php
index d7441d5..949689a 100644
--- a/modules/Infractions/profile_tab.php
+++ b/upload/modules/Infractions/profile_tab.php
@@ -1,11 +1,11 @@
-