You should have received a copy of the GNU General Public License
    along with GlobalBan.  If not, see <http://www.gnu.org/licenses/>.
*/
// This is the page that the ES script calls to ban
require_once ROOTDIR . "/include/class.rcon.php";
require_once ROOTDIR . "/include/database/class.BanQueries.php";
require_once ROOTDIR . "/include/database/class.UserQueries.php";
require_once ROOTDIR . "/include/database/class.LengthQueries.php";
require_once ROOTDIR . "/include/database/class.ServerQueries.php";
require_once ROOTDIR . "/include/objects/class.Length.php";
require_once ROOTDIR . "/include/objects/class.Server.php";
require_once ROOTDIR . "/include/database/class.ReasonQueries.php";
$lan_file = ROOTDIR . '/languages/' . $LANGUAGE . '/lan_processServerBan.php';
include file_exists($lan_file) ? $lan_file : ROOTDIR . "/languages/English/lan_processServerBan.php";
// Initialize Objects
$reasonQueries = new ReasonQueries();
// For getting from URL which is used by ES
$hash = $_GET['hash'];
// User is passed if given from ES (admin's Steam ID)
$steamId = $_GET['steamId'];
// One being banned
$lengthId = $_GET['len'];
// The ID of the ban length or the real length if timescale specified
$timeScale = $_GET['ts'];
// If this is set to "ignore" that means the length is the lengthID
$reason = $_GET['r'];
// Reason of ban
$banner = $_GET['b'];
// Steam ID of banner
$serverId = $_GET['sid'];
$nameOfBanned = $_GET['name'];
<script src="javascript/functions.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript">
function deleteVerify(id, reason) {
  if(confirm("<?php 
echo $LAN_BANREASONS_001;
?>
 "+reason+" <?php 
echo $LAN_BANREASONS_002;
?>
")) {
    document.getElementById("deleteReason"+id).submit();
  }
}
</script>
<?php 
$reasonQueries = new ReasonQueries();
$error = false;
// If this is set, then that means a server is being added
if (isset($_POST['submitAdd'])) {
    // Convert + to |plus|
    // Convert & to |amp|
    $reasonText = $_POST['reasonText'];
    $reasonText = str_replace("&", "|amp|", $reasonText);
    $reasonText = str_replace("+", "|plus|", $reasonText);
    $newReasonId = $reasonQueries->addReason($reasonText);
    if ($newReasonId < 1) {
        $error = true;
    }
}
// If a reason is being deleted
if (isset($_POST['deleteReason'])) {
/**
 * This creates a text file called es_GlobalBan_Reason_db.txt which the sever admin
 * must place in eventscripts/GlobalBan whenever they add or remove ban reasons. 
 * This is the ONLY file that does not use index.php as a reference 
 */
define("ROOTDIR", dirname(__FILE__));
// Global Constant of root directory
require_once ROOTDIR . "/include/database/class.Database.php";
//Database class
require_once ROOTDIR . "/include/database/class.ReasonQueries.php";
//Database class
header('Content-Type: text');
header('Content-Disposition: attachment; filename="es_GlobalBan_Reason_db.txt"');
$db = new Database();
// Create a new database object
$reasonQueries = new ReasonQueries();
$reasons = $reasonQueries->getReasonList();
?>
GlobalBan_Reason
{
<?php 
for ($i = 0; $i < count($reasons); $i++) {
    $reason = $reasons[$i];
    ?>
   "<?php 
    echo $reason->getId();
    ?>
"
   {
    "reasonId"       "<?php 
    echo $reason->getId();
     // If length is 0, don't bother checking expire_date
     if ($lengthInSec == 0) {
         // Send rcon command to kick user
         kickUser($steamId, $serverId, $menssageTOplayer, $messageTOserver);
         $kickedByBan = true;
     } else {
         // Check expire date to today's date
         if ($bannedUser->getExpireDate() > $now) {
             kickUser($steamId, $serverId, $menssageTOplayer, $messageTOserver);
             $kickedByBan = true;
         }
     }
 }
 if (!$kickedByBan && $config->adviseInGame != 5 && ($lengthInSec >= $config->adviseInGameLenght || $lengthInSec == 0)) {
     if ($banQueries->doesBanExist($steamId)) {
         $reasonQueries = new ReasonQueries();
         $bannedUser = $banQueries->getBannedUserBySteamId($steamId);
         $serverQueries = new ServerQueries();
         $server = $serverQueries->getServer($serverId);
         $r = new rcon($server->getIp(), $server->getPort(), $server->getRcon());
         $r->Auth();
         if ($config->adviseInGame < 4) {
             $r->sendRconCommand("ma_chat " . $LANCHECKUSER_006 . ": " . $nameOfBanned . " - \"" . $steamId . "\" | " . $bannedUser->getName() . " | " . $LANCHECKUSER_007 . ": " . $reasonQueries->getReason($bannedUser->getReasonId()));
             $r->sendRconCommand("ma_chat " . $LANCHECKUSER_008 . ": " . $bannedUser->getBanner() . " | " . $LANCHECKUSER_009 . ": " . $length->getReadable() . " | " . $LANCHECKUSER_010 . ": " . gmdate('d M Y H:i:s', $bannedUser->getAddDate()));
         }
         if ($config->adviseInGame == 1) {
             $r->sendRconCommand("ma_msay 10 #ALL -> ** GlobalBan: " . $LANCHECKUSER_006 . " **\\n " . $nameOfBanned . "\\n " . $bannedUser->getName() . "\\n " . $steamId . "\\n-> ********************\\n\\n " . $LANCHECKUSER_007 . ": " . $reasonQueries->getReason($bannedUser->getReasonId()) . "\\n " . $LANCHECKUSER_010 . ": " . gmdate('d M Y H:i:s', $bannedUser->getAddDate()) . " \\n " . $LANCHECKUSER_008 . ": " . $bannedUser->getBanner() . "\\n " . $LANCHECKUSER_009 . ": " . $length->getReadable() . "\\n-> ********************");
         }
         if ($config->adviseInGame != 3) {
             $r->sendRconCommand("ma_psay " . $steamId . " ** GlobalBan: " . $LANCHECKUSER_011 . " " . $nameOfBanned . " " . $steamId . " " . $LANCHECKUSER_012 . ": " . $reasonQueries->getReason($bannedUser->getReasonId()));
             $r->sendRconCommand("ma_psay " . $steamId . " ** GlobalBan: " . $LANCHECKUSER_013 . " " . gmdate('d M Y H:i:s', $bannedUser->getAddDate()) . " " . $LANCHECKUSER_014);
    GlobalBan is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with GlobalBan.  If not, see <http://www.gnu.org/licenses/>.
*/
require_once ROOTDIR . "/include/database/class.ReasonQueries.php";
$id = $_GET['id'];
$reason = $_GET['reason'];
// Convert |plus| to +
// Convert |amp| to &
$reason = str_replace("|amp|", "&", $reason);
$reason = str_replace("|plus|", "+", $reason);
$reasonQueries = new ReasonQueries();
$reasonQueries->updateBanReason($reason, $id);
// Convert & back to |amp| since & is an XML special character
$reason = str_replace("&", "|amp|", $reason);
// Send back the new active state
header('Content-Type: text/xml');
header("Cache-Control: no-cache, must-revalidate");
echo "<?xml version=\"1.0\" ?>";
?>
<root>
  <id><?php 
echo $id;
?>
</id>
	<reason><?php 
echo $reason;
    ?>
  <?php 
    echo $LAN_BANLIST_007;
    if (!empty($bansAdmin)) {
        ?>
  <?php 
        echo $LAN_BANLIST_008;
        ?>
 <span class="adminSelect"><?php 
        echo $bansAdmin;
        ?>
</span> 
<?php 
    }
    if (!empty($bansReason_id)) {
        $reasonQueries = new ReasonQueries();
        ?>
  <?php 
        echo $LAN_BANLIST_009;
        ?>
 <span class="reasonSelect"><?php 
        echo $reasonQueries->getReason($bansReason_id);
        ?>
</span> 
<?php 
    }
    ?>
 <?php 
    echo $LAN_BANLIST_010 . number_format($startRange + 1, 0, ",", ".") . " " . $LAN_BANLIST_011 . number_format($endRange, 0, ",", ".") . " " . $LAN_BANLIST_012 . number_format($banCount, 0, ",", ".");
    ?>
</b></div>
    You should have received a copy of the GNU General Public License
    along with GlobalBan.  If not, see <http://www.gnu.org/licenses/>.
*/
require_once ROOTDIR . "/include/class.rcon.php";
require_once ROOTDIR . "/include/database/class.BanQueries.php";
require_once ROOTDIR . "/include/database/class.ServerQueries.php";
include_once ROOTDIR . "/include/database/class.UserQueries.php";
include_once ROOTDIR . "/include/database/class.LengthQueries.php";
require_once ROOTDIR . "/include/objects/class.Server.php";
require_once ROOTDIR . "/include/objects/class.Length.php";
require_once ROOTDIR . "/include/database/class.ReasonQueries.php";
$lan_file = ROOTDIR . '/languages/' . $LANGUAGE . '/lan_processWebBan.php';
include file_exists($lan_file) ? $lan_file : ROOTDIR . "/languages/English/lan_processWebBan.php";
// Initialize Objects
$reasonQueries = new ReasonQueries();
// Variables
$steamId = $_POST['steamId'];
$lengthId = $_POST['length'];
// Length ID
$reason = $_POST['reason'];
// Reason id number
$bannedName = $_POST['bannedName'];
// Name of person banned
$serverId = $_POST['server'];
// Server ID
// Make sure the user has the privileges
if ($member || $admin || $banManager || $fullPower) {
    $allowedToBan = true;
}
if ($allowedToBan) {
*/
if ($member || $admin || $banManager || $fullPower) {
    require_once ROOTDIR . "/include/database/class.ServerQueries.php";
    require_once ROOTDIR . "/include/database/class.ReasonQueries.php";
    require_once ROOTDIR . "/include/database/class.BanQueries.php";
    include_once ROOTDIR . "/include/database/class.LengthQueries.php";
    require_once ROOTDIR . "/include/database/class.UserQueries.php";
    // User specific queries
    require_once ROOTDIR . "/include/objects/class.User.php";
    // User class to store user info
    include_once ROOTDIR . "/include/objects/class.Length.php";
    $lan_file = ROOTDIR . '/languages/' . $LANGUAGE . '/lan_updateBan.php';
    include file_exists($lan_file) ? $lan_file : ROOTDIR . "/languages/English/lan_updateBan.php";
    // Initialize Objects
    $serverQueries = new ServerQueries();
    $reasonQueries = new ReasonQueries();
    $banQueries = new BanQueries();
    $lengthQueries = new LengthQueries();
    $userQuery = new UserQueries();
    $userEdit = new User();
    // Ban ID
    $banId = $_GET['banId'];
    // Get the list of servers
    $serverList = $serverQueries->getServers();
    // List of Admins
    $banAmins = $reasonQueries->getAdminsList();
    // List of Reasons
    $banReasons = $reasonQueries->getReasonList();
    // Banned user information
    $bannedUser = $banQueries->getBannedUser($banId);
    // List of Ban Lengths