PageRenderTime 46ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/includes/pages/guestban.php

http://adminserv.googlecode.com/
PHP | 545 lines | 474 code | 32 blank | 39 comment | 128 complexity | f4b598c603e4b5e997a1ab5cfc8e7fd0 MD5 | raw file
  1. <?php
  2. // GAMEDATA
  3. if( AdminServ::isAdminLevel('Admin') ){
  4. if( !$client->query('GameDataDirectory') ){
  5. AdminServ::error();
  6. }
  7. else{
  8. $gameDataDirectory = $client->getResponse();
  9. $playlistDirectory = Folder::read($gameDataDirectory.'Config', array(), AdminServConfig::$PLAYLIST_HIDDEN_FILES, AdminServConfig::RECENT_STATUS_PERIOD);
  10. }
  11. }
  12. // ACTIONS
  13. // Vider la liste
  14. if( isset($_GET['clean']) ){
  15. $clean = strtolower($_GET['clean']);
  16. if($clean == 'banlist'){
  17. if( !$client->query('CleanBanList') ){
  18. AdminServ::error();
  19. }
  20. }
  21. else if($clean == 'ignorelist'){
  22. if( !$client->query('CleanIgnoreList') ){
  23. AdminServ::error();
  24. }
  25. }
  26. else if($clean == 'guestlist'){
  27. if( !$client->query('CleanGuestList') ){
  28. AdminServ::error();
  29. }
  30. }
  31. else if($clean == 'blacklist'){
  32. if( !$client->query('CleanBlackList') ){
  33. AdminServ::error();
  34. }
  35. }
  36. }
  37. // Blacklister
  38. else if( isset($_POST['blackListPlayer']) ){
  39. // Création du tableau de joueurs ŕ blacklister
  40. $blackListPlayer = array();
  41. if( isset($_POST['banlist']) && count($_POST['banlist']) > 0 ){
  42. $blackListPlayer = array_merge($blackListPlayer, $_POST['banlist']);
  43. }
  44. if( isset($_POST['guestlist']) && count($_POST['guestlist']) > 0 ){
  45. $blackListPlayer = array_merge($blackListPlayer, $_POST['guestlist']);
  46. }
  47. if( isset($_POST['ignorelist']) && count($_POST['ignorelist']) > 0 ){
  48. $blackListPlayer = array_merge($blackListPlayer, $_POST['ignorelist']);
  49. }
  50. $blackListPlayer = array_unique($blackListPlayer);
  51. // BlackList de toutes les listes
  52. if( count($blackListPlayer) > 0 ){
  53. foreach($blackListPlayer as $player){
  54. if( !$client->query('BlackList', $player) ){
  55. AdminServ::error();
  56. break;
  57. }
  58. }
  59. }
  60. }
  61. // Retirer un joueur d'une ou plusieurs listes
  62. else if( isset($_POST['removeList']) ){
  63. if( isset($_POST['banlist']) && count($_POST['banlist']) > 0 ){
  64. foreach($_POST['banlist'] as $player){
  65. if( !$client->query('UnBan', $player) ){
  66. AdminServ::error();
  67. break;
  68. }
  69. }
  70. }
  71. else if( isset($_POST['blacklist']) && count($_POST['blacklist']) > 0 ){
  72. foreach($_POST['blacklist'] as $player){
  73. if( !$client->query('UnBlackList', $player) ){
  74. AdminServ::error();
  75. break;
  76. }
  77. }
  78. }
  79. else if( isset($_POST['guestlist']) && count($_POST['guestlist']) > 0 ){
  80. foreach($_POST['guestlist'] as $player){
  81. if( !$client->query('RemoveGuest', $player) ){
  82. AdminServ::error();
  83. break;
  84. }
  85. }
  86. }
  87. else if( isset($_POST['ignorelist']) && count($_POST['ignorelist']) > 0 ){
  88. foreach($_POST['ignorelist'] as $player){
  89. if( !$client->query('UnIgnore', $player) ){
  90. AdminServ::error();
  91. break;
  92. }
  93. }
  94. }
  95. }
  96. // AJOUTER
  97. else if( isset($_POST['addPlayer']) ){
  98. // Variables
  99. $addPlayerList = $_POST['addPlayerList'];
  100. $addPlayerLogin = strtolower( trim($_POST['addPlayerLogin']) );
  101. $addPlayerTypeList = $_POST['addPlayerTypeList'];
  102. // PlayerLogin
  103. if($addPlayerList != 'none' && $addPlayerList != 'more'){
  104. $playerlogin = $addPlayerList;
  105. }else{
  106. $playerlogin = $addPlayerLogin;
  107. }
  108. // Requęte
  109. if($playerlogin != 'Login joueur'){
  110. // Inviter
  111. if($addPlayerTypeList == 'guestlist'){
  112. if( !$client->query('AddGuest', $playerlogin) ){
  113. AdminServ::error();
  114. }
  115. }
  116. // Blacklister
  117. else if($addPlayerTypeList == 'blacklist'){
  118. if( !$client->query('BlackList', $playerlogin) ){
  119. AdminServ::error();
  120. }
  121. }
  122. }
  123. }
  124. // PLAYLISTS LOCAL
  125. else if( isset($_POST['savePlaylist']) && isset($_POST['playlist']) && count($_POST['playlist'] > 0) ){
  126. $i = 0;
  127. foreach($_POST['playlist'] as $playlist){
  128. // Guestlist
  129. if($_POST['playlistType'][$i] == 'guestlist'){
  130. if( !$client->query('SaveGuestList', $playlist) ){
  131. AdminServ::error();
  132. break;
  133. }
  134. }
  135. // BlackList
  136. else{
  137. if( !$client->query('SaveBlackList', $playlist) ){
  138. AdminServ::error();
  139. break;
  140. }
  141. }
  142. $i++;
  143. }
  144. }
  145. else if( isset($_POST['loadPlaylist']) && isset($_POST['playlist']) && count($_POST['playlist'] > 0) ){
  146. $i = 0;
  147. foreach($_POST['playlist'] as $playlist){
  148. // Guestlist
  149. if($_POST['playlistType'][$i] == 'guestlist'){
  150. if( !$client->query('LoadGuestList', $playlist) ){
  151. AdminServ::error();
  152. break;
  153. }
  154. }
  155. // BlackList
  156. else{
  157. if( !$client->query('LoadBlackList', $playlist) ){
  158. AdminServ::error();
  159. break;
  160. }
  161. }
  162. $i++;
  163. }
  164. }
  165. else if( isset($_POST['deletePlaylist']) && isset($_POST['playlist']) && count($_POST['playlist'] > 0) ){
  166. foreach($_POST['playlist'] as $playlist){
  167. if( !File::delete($gameDataDirectory.'Config/'.$playlist) ){
  168. AdminServ::error('Impossible de supprimer la playlist : '.$playlist);
  169. break;
  170. }
  171. }
  172. }
  173. else if( isset($_POST['createPlaylistValid']) && isset($_POST['createPlaylistName']) && $_POST['createPlaylistName'] != null ){
  174. // Fichier
  175. $filename = Str::replaceChars($_POST['createPlaylistName']);
  176. // Guestlist
  177. if($_POST['createPlaylistType'] == 'guestlist'){
  178. if( !$client->query('SaveGuestList', $filename) ){
  179. AdminServ::error();
  180. }
  181. }
  182. // Blacklist
  183. else{
  184. if( !$client->query('SaveBlackList', $filename) ){
  185. AdminServ::error();
  186. }
  187. }
  188. }
  189. // LECTURE
  190. if( !$client->query('GetBanList', AdminServConfig::LIMIT_PLAYERS_LIST, 0) ){
  191. AdminServ::error();
  192. }
  193. else{
  194. $banList = $client->getResponse();
  195. $countBanList = count($banList);
  196. }
  197. if( !$client->query('GetBlackList', AdminServConfig::LIMIT_PLAYERS_LIST, 0) ){
  198. AdminServ::error();
  199. }
  200. else{
  201. $blackList = $client->getResponse();
  202. $countBlackList = count($blackList);
  203. }
  204. if( !$client->query('GetGuestList', AdminServConfig::LIMIT_PLAYERS_LIST, 0) ){
  205. AdminServ::error();
  206. }
  207. else{
  208. $guestList = $client->getResponse();
  209. $countGuestList = count($guestList);
  210. }
  211. if( !$client->query('GetIgnoreList', AdminServConfig::LIMIT_PLAYERS_LIST, 0) ){
  212. AdminServ::error();
  213. }
  214. else{
  215. $ignoreList = $client->getResponse();
  216. $countIgnoreList = count($ignoreList);
  217. }
  218. // Liste des joueurs présent sur le serveur
  219. $playerList = AdminServUI::getPlayerList();
  220. // HTML
  221. $client->Terminate();
  222. AdminServUI::getHeader();
  223. ?>
  224. <section class="cadre left">
  225. <form method="post" action="?p=<?php echo USER_PAGE; ?>">
  226. <div id="banlist">
  227. <h1>Banlist<?php if($countBanList > 0){ echo ' ('.$countBanList.')'; } ?></h1>
  228. <div class="title-detail">
  229. <ul>
  230. <li><a class="cleanList" href="?p=<?php echo USER_PAGE; ?>&amp;clean=banlist" data-empty="La liste est déjŕ vide.">Vider la liste</a></li>
  231. <li><input type="checkbox" name="checkAllBanlist" id="checkAllBanlist" value=""<?php if($countBanList == 0){ echo ' disabled="disabled"'; } ?> /></li>
  232. </ul>
  233. </div>
  234. <table>
  235. <thead>
  236. <tr>
  237. <th class="thleft">Login</th>
  238. <th>Adresse IP</th>
  239. <th>Client</th>
  240. <th class="thright"></th>
  241. </tr>
  242. </thead>
  243. <tbody>
  244. <?php
  245. $showBanList = null;
  246. // Liste des joueurs
  247. if( $countBanList > 0 ){
  248. $i = 0;
  249. foreach($banList as $player){
  250. // Ligne
  251. $showBanList .= '<tr class="'; if($i%2){ $showBanList .= 'even'; }else{ $showBanList .= 'odd'; } $showBanList .= '">'
  252. .'<td class="imgleft"><img src="'. AdminServConfig::PATH_RESSOURCES .'images/16/solo.png" alt="" />'.$player['Login'].'</td>'
  253. .'<td>'.$player['IPAddress'].'</td>'
  254. .'<td>'.$player['ClientName'].'</td>'
  255. .'<td class="checkbox"><input type="checkbox" name="banlist[]" value="'.$player['Login'].'" /></td>'
  256. .'</tr>';
  257. $i++;
  258. }
  259. }
  260. else{
  261. $showBanList .= '<tr class="no-line"><td class="center" colspan="4">Aucun joueur</td></tr>';
  262. }
  263. // Affichage
  264. echo $showBanList;
  265. ?>
  266. </tbody>
  267. </table>
  268. </div>
  269. <div id="blacklist">
  270. <h1>Blacklist<?php if($countBlackList > 0){ echo ' ('.$countBlackList.')'; } ?></h1>
  271. <div class="title-detail">
  272. <ul>
  273. <li><a class="cleanList" href="?p=<?php echo USER_PAGE; ?>&amp;clean=blacklist" data-empty="La liste est déjŕ vide.">Vider la liste</a></li>
  274. <li><input type="checkbox" name="checkAllBlacklist" id="checkAllBlacklist" value=""<?php if($countBlackList == 0){ echo ' disabled="disabled"'; } ?> /></li>
  275. </ul>
  276. </div>
  277. <table>
  278. <thead>
  279. <tr>
  280. <th class="thleft">Login</th>
  281. <th class="thright"></th>
  282. </tr>
  283. </thead>
  284. <tbody>
  285. <?php
  286. $showBlackList = null;
  287. // Liste des joueurs
  288. if( $countBlackList > 0 ){
  289. $i = 0;
  290. foreach($blackList as $player){
  291. // Ligne
  292. $showBlackList .= '<tr class="'; if($i%2){ $showBlackList .= 'even'; }else{ $showBlackList .= 'odd'; } $showBlackList .= '">'
  293. .'<td class="imgleft"><img src="'. AdminServConfig::PATH_RESSOURCES .'images/16/solo.png" alt="" />'.$player['Login'].'</td>'
  294. .'<td class="checkbox"><input type="checkbox" name="blacklist[]" value="'.$player['Login'].'" /></td>'
  295. .'</tr>';
  296. $i++;
  297. }
  298. }
  299. else{
  300. $showBlackList .= '<tr class="no-line"><td class="center" colspan="2">Aucun joueur</td></tr>';
  301. }
  302. // Affichage
  303. echo $showBlackList;
  304. ?>
  305. </tbody>
  306. </table>
  307. </div>
  308. <div id="guestlist">
  309. <h1>Guestlist<?php if($countGuestList > 0){ echo ' ('.$countGuestList.')'; } ?></h1>
  310. <div class="title-detail">
  311. <ul>
  312. <li><a class="cleanList" href="?p=<?php echo USER_PAGE; ?>&amp;clean=guestlist" data-empty="La liste est déjŕ vide.">Vider la liste</a></li>
  313. <li><input type="checkbox" name="checkAllGuestlist" id="checkAllGuestlist" value=""<?php if($countGuestList == 0){ echo ' disabled="disabled"'; } ?> /></li>
  314. </ul>
  315. </div>
  316. <table>
  317. <thead>
  318. <tr>
  319. <th class="thleft">Login</th>
  320. <th class="thright"></th>
  321. </tr>
  322. </thead>
  323. <tbody>
  324. <?php
  325. $showGuestList = null;
  326. // Liste des joueurs
  327. if( $countGuestList > 0 ){
  328. $i = 0;
  329. foreach($guestList as $player){
  330. // Ligne
  331. $showGuestList .= '<tr class="'; if($i%2){ $showGuestList .= 'even'; }else{ $showGuestList .= 'odd'; } $showGuestList .= '">'
  332. .'<td class="imgleft"><img src="'. AdminServConfig::PATH_RESSOURCES .'images/16/solo.png" alt="" />'.$player['Login'].'</td>'
  333. .'<td class="checkbox"><input type="checkbox" name="guestlist[]" value="'.$player['Login'].'" /></td>'
  334. .'</tr>';
  335. $i++;
  336. }
  337. }
  338. else{
  339. $showGuestList .= '<tr class="no-line"><td class="center" colspan="2">Aucun joueur</td></tr>';
  340. }
  341. // Affichage
  342. echo $showGuestList;
  343. ?>
  344. </tbody>
  345. </table>
  346. </div>
  347. <div id="ignorelist">
  348. <h1>Ignorelist<?php if($countIgnoreList > 0){ echo ' ('.$countIgnoreList.')'; } ?></h1>
  349. <div class="title-detail">
  350. <ul>
  351. <li><a class="cleanList" href="?p=<?php echo USER_PAGE; ?>&amp;clean=ignorelist" data-empty="La liste est déjŕ vide.">Vider la liste</a></li>
  352. <li><input type="checkbox" name="checkAllIgnorelist" id="checkAllIgnorelist" value=""<?php if($countIgnoreList == 0){ echo ' disabled="disabled"'; } ?> /></li>
  353. </ul>
  354. </div>
  355. <table>
  356. <thead>
  357. <tr>
  358. <th class="thleft">Login</th>
  359. <th class="thright"></th>
  360. </tr>
  361. </thead>
  362. <tbody>
  363. <?php
  364. $showIgnoreList = null;
  365. // Liste des joueurs
  366. if( $countIgnoreList > 0 ){
  367. $i = 0;
  368. foreach($ignoreList as $player){
  369. // Ligne
  370. $showIgnoreList .= '<tr class="'; if($i%2){ $showIgnoreList .= 'even'; }else{ $showIgnoreList .= 'odd'; } $showIgnoreList .= '">'
  371. .'<td class="imgleft"><img src="'. AdminServConfig::PATH_RESSOURCES .'images/16/solo.png" alt="" />'.$player['Login'].'</td>'
  372. .'<td class="checkbox"><input type="checkbox" name="ignorelist[]" value="'.$player['Login'].'" /></td>'
  373. .'</tr>';
  374. $i++;
  375. }
  376. }
  377. else{
  378. $showIgnoreList .= '<tr class="no-line"><td class="center" colspan="2">Aucun joueur</td></tr>';
  379. }
  380. // Affichage
  381. echo $showIgnoreList;
  382. ?>
  383. </tbody>
  384. </table>
  385. </div>
  386. <div class="options">
  387. <div class="fright">
  388. <div class="selected-files-label locked">
  389. <span class="selected-files-title">Pour la sélection</span>
  390. <span class="selected-files-count">(0)</span>
  391. <div class="selected-files-option">
  392. <input class="button dark" type="submit" name="blackListPlayer" id="blackListPlayer" value="Blacklister" />
  393. <input class="button dark" type="submit" name="removeList" id="removeList" value="Retirer de la liste" />
  394. </div>
  395. </div>
  396. </div>
  397. </div>
  398. </form>
  399. </section>
  400. <section class="cadre right">
  401. <h1>Ajouter</h1>
  402. <div class="content last addPlayer">
  403. <form method="post" action="?p=<?php echo USER_PAGE; ?>">
  404. <div>
  405. <select class="width2" name="addPlayerList" id="addPlayerList"<?php if($playerList == null){ echo ' hidden="hidden"'; } ?>>
  406. <option value="none">Sélectionnez un joueur</option>
  407. <option value="more">Entrez un autre login</option>
  408. </select>
  409. <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"'; } ?> />
  410. <select class="addPlayerTypeList" name="addPlayerTypeList" id="addPlayerTypeList">
  411. <option value="none">Ajouter ŕ la</option>
  412. <option value="guestlist">Guestlist</option>
  413. <option value="blacklist">Blacklist</option>
  414. </select>
  415. <input class="button light" type="submit" name="addPlayer" id="addPlayer" value="Ajouter" />
  416. </div>
  417. </form>
  418. </div>
  419. <div id="playlists">
  420. <form method="post" action="?p=<?php echo USER_PAGE; ?>">
  421. <h1>Playlists
  422. <div id="form-new-playlist" hidden="hidden">
  423. <select name="createPlaylistType" id="createPlaylistType">
  424. <option value="none">Type</option>
  425. <option value="guestlist">Guestlist</option>
  426. <option value="blacklist">Blacklist</option>
  427. </select>
  428. <input class="text" type="text" name="createPlaylistName" id="createPlaylistName" data-playlistname="Nom de la playlist" value="Nom de la playlist" />
  429. <input class="button light" type="submit" name="createPlaylistValid" id="createPlaylistValid" value="Créer" />
  430. </div>
  431. </h1>
  432. </form>
  433. <div class="title-detail">
  434. <ul>
  435. <li><a id="clickNewPlaylist" href="" data-cancel="Annuler" data-newplaylist="Nouvelle playlist">Nouvelle playlist</a></li>
  436. <li><input type="checkbox" name="checkAllPlaylists" id="checkAllPlaylists" value="" /></li>
  437. </ul>
  438. </div>
  439. <form method="post" action="?p=<?php echo USER_PAGE; ?>">
  440. <table>
  441. <thead>
  442. <tr>
  443. <th class="thleft">Playlist</th>
  444. <th>Type</th>
  445. <th>Contient</th>
  446. <th>Modifié le</th>
  447. <th class="thright"></th>
  448. </tr>
  449. </thead>
  450. <tbody>
  451. <?php
  452. $showPlaylists = null;
  453. // Liste des playlists
  454. if( isset($playlistDirectory['files']) && count($playlistDirectory['files']) > 0 ){
  455. $i = 0;
  456. foreach($playlistDirectory['files'] as $file){
  457. $ext = File::getExtension($file['filename']);
  458. if($ext == 'txt' || $ext = 'text' || $ext == 'xml'){
  459. $data = AdminServ::getPlaylistData($gameDataDirectory.'Config/'.$file['filename']);
  460. if( isset($data['logins']) ){
  461. $countDataLogins = count($data['logins']);
  462. if($countDataLogins > 1){
  463. $nbPlayers = $countDataLogins.' joueurs';
  464. }
  465. else{
  466. $nbPlayers = '1 joueur';
  467. }
  468. }
  469. else{
  470. $nbPlayers = '0 joueur';
  471. }
  472. // Ligne
  473. $showPlaylists .= '<tr class="'; if($i%2){ $showPlaylists .= 'even'; }else{ $showPlaylists .= 'odd'; } $showPlaylists .= '">'
  474. .'<td class="imgleft"><img src="'. AdminServConfig::PATH_RESSOURCES .'images/16/finishgrey.png" alt="" /><span title="'.$file['filename'].'">'.substr($file['filename'], 0, -4).'</span></td>'
  475. .'<td class="center">'.ucfirst($data['type']).'</td>'
  476. .'<td class="center">'.$nbPlayers.'</td>'
  477. .'<td class="center">'.date('d-m-Y', $file['mtime']).'</td>'
  478. .'<td class="checkbox">'
  479. .'<input type="checkbox" name="playlist[]" value="'.$file['filename'].'" />'
  480. .'<input type="hidden" name="playlistType[]" value="'.$data['type'].'" />'
  481. .'</td>'
  482. .'</tr>';
  483. $i++;
  484. }
  485. }
  486. }
  487. else{
  488. $showPlaylists .= '<tr class="no-line"><td class="center" colspan="4">Aucune playlist</td></tr>';
  489. }
  490. // Affichage
  491. echo $showPlaylists;
  492. ?>
  493. </tbody>
  494. </table>
  495. </form>
  496. <div class="options">
  497. <div class="fright">
  498. <div class="selected-files-label locked">
  499. <span class="selected-files-title">Pour la sélection</span>
  500. <span class="selected-files-count">(0)</span>
  501. <div class="selected-files-option">
  502. <input class="button dark" type="submit" name="deletePlaylist" id="deletePlaylist" value="Supprimer" />
  503. <input class="button dark" type="submit" name="loadPlaylist" id="loadPlaylist" value="Charger" />
  504. <input class="button dark" type="submit" name="savePlaylist" id="savePlaylist" value="Sauvegarder" />
  505. </div>
  506. </div>
  507. </div>
  508. </div>
  509. </div>
  510. </section>
  511. <?php
  512. AdminServUI::getFooter();
  513. ?>