/includes/pages/guestban.php
PHP | 545 lines | 474 code | 32 blank | 39 comment | 128 complexity | f4b598c603e4b5e997a1ab5cfc8e7fd0 MD5 | raw file
- <?php
- // GAMEDATA
- if( AdminServ::isAdminLevel('Admin') ){
- if( !$client->query('GameDataDirectory') ){
- AdminServ::error();
- }
- else{
- $gameDataDirectory = $client->getResponse();
- $playlistDirectory = Folder::read($gameDataDirectory.'Config', array(), AdminServConfig::$PLAYLIST_HIDDEN_FILES, AdminServConfig::RECENT_STATUS_PERIOD);
- }
- }
-
- // ACTIONS
- // Vider la liste
- if( isset($_GET['clean']) ){
- $clean = strtolower($_GET['clean']);
- if($clean == 'banlist'){
- if( !$client->query('CleanBanList') ){
- AdminServ::error();
- }
- }
- else if($clean == 'ignorelist'){
- if( !$client->query('CleanIgnoreList') ){
- AdminServ::error();
- }
- }
- else if($clean == 'guestlist'){
- if( !$client->query('CleanGuestList') ){
- AdminServ::error();
- }
- }
- else if($clean == 'blacklist'){
- if( !$client->query('CleanBlackList') ){
- AdminServ::error();
- }
- }
- }
- // Blacklister
- else if( isset($_POST['blackListPlayer']) ){
- // Création du tableau de joueurs ŕ blacklister
- $blackListPlayer = array();
- if( isset($_POST['banlist']) && count($_POST['banlist']) > 0 ){
- $blackListPlayer = array_merge($blackListPlayer, $_POST['banlist']);
- }
- if( isset($_POST['guestlist']) && count($_POST['guestlist']) > 0 ){
- $blackListPlayer = array_merge($blackListPlayer, $_POST['guestlist']);
- }
- if( isset($_POST['ignorelist']) && count($_POST['ignorelist']) > 0 ){
- $blackListPlayer = array_merge($blackListPlayer, $_POST['ignorelist']);
- }
- $blackListPlayer = array_unique($blackListPlayer);
-
- // BlackList de toutes les listes
- if( count($blackListPlayer) > 0 ){
- foreach($blackListPlayer as $player){
- if( !$client->query('BlackList', $player) ){
- AdminServ::error();
- break;
- }
- }
- }
- }
- // Retirer un joueur d'une ou plusieurs listes
- else if( isset($_POST['removeList']) ){
- if( isset($_POST['banlist']) && count($_POST['banlist']) > 0 ){
- foreach($_POST['banlist'] as $player){
- if( !$client->query('UnBan', $player) ){
- AdminServ::error();
- break;
- }
- }
- }
- else if( isset($_POST['blacklist']) && count($_POST['blacklist']) > 0 ){
- foreach($_POST['blacklist'] as $player){
- if( !$client->query('UnBlackList', $player) ){
- AdminServ::error();
- break;
- }
- }
- }
- else if( isset($_POST['guestlist']) && count($_POST['guestlist']) > 0 ){
- foreach($_POST['guestlist'] as $player){
- if( !$client->query('RemoveGuest', $player) ){
- AdminServ::error();
- break;
- }
- }
- }
- else if( isset($_POST['ignorelist']) && count($_POST['ignorelist']) > 0 ){
- foreach($_POST['ignorelist'] as $player){
- if( !$client->query('UnIgnore', $player) ){
- AdminServ::error();
- break;
- }
- }
- }
- }
-
-
- // AJOUTER
- else if( isset($_POST['addPlayer']) ){
- // Variables
- $addPlayerList = $_POST['addPlayerList'];
- $addPlayerLogin = strtolower( trim($_POST['addPlayerLogin']) );
- $addPlayerTypeList = $_POST['addPlayerTypeList'];
-
- // PlayerLogin
- if($addPlayerList != 'none' && $addPlayerList != 'more'){
- $playerlogin = $addPlayerList;
- }else{
- $playerlogin = $addPlayerLogin;
- }
-
- // Requęte
- if($playerlogin != 'Login joueur'){
- // Inviter
- if($addPlayerTypeList == 'guestlist'){
- if( !$client->query('AddGuest', $playerlogin) ){
- AdminServ::error();
- }
- }
- // Blacklister
- else if($addPlayerTypeList == 'blacklist'){
- if( !$client->query('BlackList', $playerlogin) ){
- AdminServ::error();
- }
- }
- }
- }
-
-
- // PLAYLISTS LOCAL
- else if( isset($_POST['savePlaylist']) && isset($_POST['playlist']) && count($_POST['playlist'] > 0) ){
- $i = 0;
- foreach($_POST['playlist'] as $playlist){
- // Guestlist
- if($_POST['playlistType'][$i] == 'guestlist'){
- if( !$client->query('SaveGuestList', $playlist) ){
- AdminServ::error();
- break;
- }
- }
- // BlackList
- else{
- if( !$client->query('SaveBlackList', $playlist) ){
- AdminServ::error();
- break;
- }
- }
- $i++;
- }
- }
- else if( isset($_POST['loadPlaylist']) && isset($_POST['playlist']) && count($_POST['playlist'] > 0) ){
- $i = 0;
- foreach($_POST['playlist'] as $playlist){
- // Guestlist
- if($_POST['playlistType'][$i] == 'guestlist'){
- if( !$client->query('LoadGuestList', $playlist) ){
- AdminServ::error();
- break;
- }
- }
- // BlackList
- else{
- if( !$client->query('LoadBlackList', $playlist) ){
- AdminServ::error();
- break;
- }
- }
- $i++;
- }
- }
- else if( isset($_POST['deletePlaylist']) && isset($_POST['playlist']) && count($_POST['playlist'] > 0) ){
- foreach($_POST['playlist'] as $playlist){
- if( !File::delete($gameDataDirectory.'Config/'.$playlist) ){
- AdminServ::error('Impossible de supprimer la playlist : '.$playlist);
- break;
- }
- }
- }
- else if( isset($_POST['createPlaylistValid']) && isset($_POST['createPlaylistName']) && $_POST['createPlaylistName'] != null ){
- // Fichier
- $filename = Str::replaceChars($_POST['createPlaylistName']);
-
- // Guestlist
- if($_POST['createPlaylistType'] == 'guestlist'){
- if( !$client->query('SaveGuestList', $filename) ){
- AdminServ::error();
- }
- }
- // Blacklist
- else{
- if( !$client->query('SaveBlackList', $filename) ){
- AdminServ::error();
- }
- }
- }
-
- // LECTURE
- if( !$client->query('GetBanList', AdminServConfig::LIMIT_PLAYERS_LIST, 0) ){
- AdminServ::error();
- }
- else{
- $banList = $client->getResponse();
- $countBanList = count($banList);
- }
- if( !$client->query('GetBlackList', AdminServConfig::LIMIT_PLAYERS_LIST, 0) ){
- AdminServ::error();
- }
- else{
- $blackList = $client->getResponse();
- $countBlackList = count($blackList);
- }
- if( !$client->query('GetGuestList', AdminServConfig::LIMIT_PLAYERS_LIST, 0) ){
- AdminServ::error();
- }
- else{
- $guestList = $client->getResponse();
- $countGuestList = count($guestList);
- }
- if( !$client->query('GetIgnoreList', AdminServConfig::LIMIT_PLAYERS_LIST, 0) ){
- AdminServ::error();
- }
- else{
- $ignoreList = $client->getResponse();
- $countIgnoreList = count($ignoreList);
- }
-
- // Liste des joueurs présent sur le serveur
- $playerList = AdminServUI::getPlayerList();
-
-
- // HTML
- $client->Terminate();
- AdminServUI::getHeader();
- ?>
- <section class="cadre left">
- <form method="post" action="?p=<?php echo USER_PAGE; ?>">
- <div id="banlist">
- <h1>Banlist<?php if($countBanList > 0){ echo ' ('.$countBanList.')'; } ?></h1>
- <div class="title-detail">
- <ul>
- <li><a class="cleanList" href="?p=<?php echo USER_PAGE; ?>&clean=banlist" data-empty="La liste est déjŕ vide.">Vider la liste</a></li>
- <li><input type="checkbox" name="checkAllBanlist" id="checkAllBanlist" value=""<?php if($countBanList == 0){ echo ' disabled="disabled"'; } ?> /></li>
- </ul>
- </div>
- <table>
- <thead>
- <tr>
- <th class="thleft">Login</th>
- <th>Adresse IP</th>
- <th>Client</th>
- <th class="thright"></th>
- </tr>
- </thead>
- <tbody>
- <?php
- $showBanList = null;
-
- // Liste des joueurs
- if( $countBanList > 0 ){
- $i = 0;
- foreach($banList as $player){
- // Ligne
- $showBanList .= '<tr class="'; if($i%2){ $showBanList .= 'even'; }else{ $showBanList .= 'odd'; } $showBanList .= '">'
- .'<td class="imgleft"><img src="'. AdminServConfig::PATH_RESSOURCES .'images/16/solo.png" alt="" />'.$player['Login'].'</td>'
- .'<td>'.$player['IPAddress'].'</td>'
- .'<td>'.$player['ClientName'].'</td>'
- .'<td class="checkbox"><input type="checkbox" name="banlist[]" value="'.$player['Login'].'" /></td>'
- .'</tr>';
- $i++;
- }
- }
- else{
- $showBanList .= '<tr class="no-line"><td class="center" colspan="4">Aucun joueur</td></tr>';
- }
-
- // Affichage
- echo $showBanList;
- ?>
- </tbody>
- </table>
- </div>
-
- <div id="blacklist">
- <h1>Blacklist<?php if($countBlackList > 0){ echo ' ('.$countBlackList.')'; } ?></h1>
- <div class="title-detail">
- <ul>
- <li><a class="cleanList" href="?p=<?php echo USER_PAGE; ?>&clean=blacklist" data-empty="La liste est déjŕ vide.">Vider la liste</a></li>
- <li><input type="checkbox" name="checkAllBlacklist" id="checkAllBlacklist" value=""<?php if($countBlackList == 0){ echo ' disabled="disabled"'; } ?> /></li>
- </ul>
- </div>
- <table>
- <thead>
- <tr>
- <th class="thleft">Login</th>
- <th class="thright"></th>
- </tr>
- </thead>
- <tbody>
- <?php
- $showBlackList = null;
-
- // Liste des joueurs
- if( $countBlackList > 0 ){
- $i = 0;
- foreach($blackList as $player){
- // Ligne
- $showBlackList .= '<tr class="'; if($i%2){ $showBlackList .= 'even'; }else{ $showBlackList .= 'odd'; } $showBlackList .= '">'
- .'<td class="imgleft"><img src="'. AdminServConfig::PATH_RESSOURCES .'images/16/solo.png" alt="" />'.$player['Login'].'</td>'
- .'<td class="checkbox"><input type="checkbox" name="blacklist[]" value="'.$player['Login'].'" /></td>'
- .'</tr>';
- $i++;
- }
- }
- else{
- $showBlackList .= '<tr class="no-line"><td class="center" colspan="2">Aucun joueur</td></tr>';
- }
-
- // Affichage
- echo $showBlackList;
- ?>
- </tbody>
- </table>
- </div>
-
- <div id="guestlist">
- <h1>Guestlist<?php if($countGuestList > 0){ echo ' ('.$countGuestList.')'; } ?></h1>
- <div class="title-detail">
- <ul>
- <li><a class="cleanList" href="?p=<?php echo USER_PAGE; ?>&clean=guestlist" data-empty="La liste est déjŕ vide.">Vider la liste</a></li>
- <li><input type="checkbox" name="checkAllGuestlist" id="checkAllGuestlist" value=""<?php if($countGuestList == 0){ echo ' disabled="disabled"'; } ?> /></li>
- </ul>
- </div>
- <table>
- <thead>
- <tr>
- <th class="thleft">Login</th>
- <th class="thright"></th>
- </tr>
- </thead>
- <tbody>
- <?php
- $showGuestList = null;
-
- // Liste des joueurs
- if( $countGuestList > 0 ){
- $i = 0;
- foreach($guestList as $player){
- // Ligne
- $showGuestList .= '<tr class="'; if($i%2){ $showGuestList .= 'even'; }else{ $showGuestList .= 'odd'; } $showGuestList .= '">'
- .'<td class="imgleft"><img src="'. AdminServConfig::PATH_RESSOURCES .'images/16/solo.png" alt="" />'.$player['Login'].'</td>'
- .'<td class="checkbox"><input type="checkbox" name="guestlist[]" value="'.$player['Login'].'" /></td>'
- .'</tr>';
- $i++;
- }
- }
- else{
- $showGuestList .= '<tr class="no-line"><td class="center" colspan="2">Aucun joueur</td></tr>';
- }
-
- // Affichage
- echo $showGuestList;
- ?>
- </tbody>
- </table>
- </div>
-
- <div id="ignorelist">
- <h1>Ignorelist<?php if($countIgnoreList > 0){ echo ' ('.$countIgnoreList.')'; } ?></h1>
- <div class="title-detail">
- <ul>
- <li><a class="cleanList" href="?p=<?php echo USER_PAGE; ?>&clean=ignorelist" data-empty="La liste est déjŕ vide.">Vider la liste</a></li>
- <li><input type="checkbox" name="checkAllIgnorelist" id="checkAllIgnorelist" value=""<?php if($countIgnoreList == 0){ echo ' disabled="disabled"'; } ?> /></li>
- </ul>
- </div>
- <table>
- <thead>
- <tr>
- <th class="thleft">Login</th>
- <th class="thright"></th>
- </tr>
- </thead>
- <tbody>
- <?php
- $showIgnoreList = null;
-
- // Liste des joueurs
- if( $countIgnoreList > 0 ){
- $i = 0;
- foreach($ignoreList as $player){
- // Ligne
- $showIgnoreList .= '<tr class="'; if($i%2){ $showIgnoreList .= 'even'; }else{ $showIgnoreList .= 'odd'; } $showIgnoreList .= '">'
- .'<td class="imgleft"><img src="'. AdminServConfig::PATH_RESSOURCES .'images/16/solo.png" alt="" />'.$player['Login'].'</td>'
- .'<td class="checkbox"><input type="checkbox" name="ignorelist[]" value="'.$player['Login'].'" /></td>'
- .'</tr>';
- $i++;
- }
- }
- else{
- $showIgnoreList .= '<tr class="no-line"><td class="center" colspan="2">Aucun joueur</td></tr>';
- }
-
- // Affichage
- echo $showIgnoreList;
- ?>
- </tbody>
- </table>
- </div>
-
- <div class="options">
- <div class="fright">
- <div class="selected-files-label locked">
- <span class="selected-files-title">Pour la sélection</span>
- <span class="selected-files-count">(0)</span>
- <div class="selected-files-option">
- <input class="button dark" type="submit" name="blackListPlayer" id="blackListPlayer" value="Blacklister" />
- <input class="button dark" type="submit" name="removeList" id="removeList" value="Retirer de la liste" />
- </div>
- </div>
- </div>
- </div>
- </form>
- </section>
-
- <section class="cadre right">
- <h1>Ajouter</h1>
- <div class="content last addPlayer">
- <form method="post" action="?p=<?php echo USER_PAGE; ?>">
- <div>
- <select class="width2" name="addPlayerList" id="addPlayerList"<?php if($playerList == null){ echo ' hidden="hidden"'; } ?>>
- <option value="none">Sélectionnez un joueur</option>
- <option value="more">Entrez un autre login</option>
- </select>
- <input class="text width2" type="text" name="addPlayerLogin" id="addPlayerLogin" data-default-value="Login joueur" value="Login joueur"<?php if($playerList != null){ echo ' hidden="hidden"'; } ?> />
- <select class="addPlayerTypeList" name="addPlayerTypeList" id="addPlayerTypeList">
- <option value="none">Ajouter ŕ la</option>
- <option value="guestlist">Guestlist</option>
- <option value="blacklist">Blacklist</option>
- </select>
- <input class="button light" type="submit" name="addPlayer" id="addPlayer" value="Ajouter" />
- </div>
- </form>
- </div>
-
- <div id="playlists">
- <form method="post" action="?p=<?php echo USER_PAGE; ?>">
- <h1>Playlists
- <div id="form-new-playlist" hidden="hidden">
- <select name="createPlaylistType" id="createPlaylistType">
- <option value="none">Type</option>
- <option value="guestlist">Guestlist</option>
- <option value="blacklist">Blacklist</option>
- </select>
- <input class="text" type="text" name="createPlaylistName" id="createPlaylistName" data-playlistname="Nom de la playlist" value="Nom de la playlist" />
- <input class="button light" type="submit" name="createPlaylistValid" id="createPlaylistValid" value="Créer" />
- </div>
- </h1>
- </form>
- <div class="title-detail">
- <ul>
- <li><a id="clickNewPlaylist" href="" data-cancel="Annuler" data-newplaylist="Nouvelle playlist">Nouvelle playlist</a></li>
- <li><input type="checkbox" name="checkAllPlaylists" id="checkAllPlaylists" value="" /></li>
- </ul>
- </div>
-
- <form method="post" action="?p=<?php echo USER_PAGE; ?>">
- <table>
- <thead>
- <tr>
- <th class="thleft">Playlist</th>
- <th>Type</th>
- <th>Contient</th>
- <th>Modifié le</th>
- <th class="thright"></th>
- </tr>
- </thead>
- <tbody>
- <?php
- $showPlaylists = null;
-
- // Liste des playlists
- if( isset($playlistDirectory['files']) && count($playlistDirectory['files']) > 0 ){
- $i = 0;
- foreach($playlistDirectory['files'] as $file){
- $ext = File::getExtension($file['filename']);
- if($ext == 'txt' || $ext = 'text' || $ext == 'xml'){
- $data = AdminServ::getPlaylistData($gameDataDirectory.'Config/'.$file['filename']);
- if( isset($data['logins']) ){
- $countDataLogins = count($data['logins']);
- if($countDataLogins > 1){
- $nbPlayers = $countDataLogins.' joueurs';
- }
- else{
- $nbPlayers = '1 joueur';
- }
- }
- else{
- $nbPlayers = '0 joueur';
- }
-
- // Ligne
- $showPlaylists .= '<tr class="'; if($i%2){ $showPlaylists .= 'even'; }else{ $showPlaylists .= 'odd'; } $showPlaylists .= '">'
- .'<td class="imgleft"><img src="'. AdminServConfig::PATH_RESSOURCES .'images/16/finishgrey.png" alt="" /><span title="'.$file['filename'].'">'.substr($file['filename'], 0, -4).'</span></td>'
- .'<td class="center">'.ucfirst($data['type']).'</td>'
- .'<td class="center">'.$nbPlayers.'</td>'
- .'<td class="center">'.date('d-m-Y', $file['mtime']).'</td>'
- .'<td class="checkbox">'
- .'<input type="checkbox" name="playlist[]" value="'.$file['filename'].'" />'
- .'<input type="hidden" name="playlistType[]" value="'.$data['type'].'" />'
- .'</td>'
- .'</tr>';
- $i++;
- }
- }
- }
- else{
- $showPlaylists .= '<tr class="no-line"><td class="center" colspan="4">Aucune playlist</td></tr>';
- }
-
- // Affichage
- echo $showPlaylists;
- ?>
- </tbody>
- </table>
- </form>
-
- <div class="options">
- <div class="fright">
- <div class="selected-files-label locked">
- <span class="selected-files-title">Pour la sélection</span>
- <span class="selected-files-count">(0)</span>
- <div class="selected-files-option">
- <input class="button dark" type="submit" name="deletePlaylist" id="deletePlaylist" value="Supprimer" />
- <input class="button dark" type="submit" name="loadPlaylist" id="loadPlaylist" value="Charger" />
- <input class="button dark" type="submit" name="savePlaylist" id="savePlaylist" value="Sauvegarder" />
- </div>
- </div>
- </div>
- </div>
- </div>
- </section>
- <?php
- AdminServUI::getFooter();
- ?>