Advertisement
Guest User

Untitled

a guest
May 5th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.22 KB | None | 0 0
  1. <?php session_start(); ?>
  2. <!DOCTYPE html>
  3. <html>
  4. <?php
  5. if(!isset($_SESSION['SteamID']))
  6. header('Location: index.php');
  7.  
  8. require 'include/config.php';
  9. require 'include/common_db.php';
  10. require 'tmp/head.php';
  11.  
  12. if($cur_admin['Admin'] == 0)
  13. header('Location: index.php');
  14. ?>
  15. <body>
  16. <div id="menu-corner">
  17. <?php require 'tmp/menu.php'; ?>
  18. </div>
  19.  
  20. <div id="content">
  21. <?php
  22. if(empty($_GET)) {
  23. $req = $db->query('SELECT * FROM '.$db->prefix.'whitelist');
  24. if (!$db->num_rows($req)) {
  25. echo '<font color="red">Aucune demande pour le moment</font>';
  26. }
  27. while($data = $db->fetch_assoc($req)) {
  28. if($data['edit'] == 1)
  29. $edit = "<font color='green'>Demande en cours d'edition par le joueur</font>";
  30. else
  31. $edit = "";
  32. echo '<b>Motivation : </b>'.$data['Motivation'].'<br>';
  33. echo '<b>Age : </b>'.$data['Age'];
  34. echo '<br><a href="admin_whitelist.php?id='.$data['id'].'">Voir</a>';
  35. echo $edit;
  36. echo '<hr>';
  37. }
  38. } else {
  39. $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
  40. $req = $db->query('SELECT * FROM '.$db->prefix.'whitelist WHERE id = "'.$id.'"');
  41. $cur_whitelist = $db->fetch_assoc($req);
  42.  
  43. echo '
  44. <h3>'.$cur_whitelist['UserName'].' - '.$cur_whitelist['SteamID'].'</h3>
  45. <b>Demande : </b> '.$cur_whitelist['Motivation'].'<br>
  46. <b> Age : </b> '.$cur_whitelist['Age'].'<br>
  47. <b> Profil URL : </b> '.$cur_whitelist['ProfilURL'].'<br><br>
  48. <b> Le '.date('d/m/Y', $cur_whitelist['time']).' &agrave; '.date('H:i:s', $cur_whitelist['time']).'</b>
  49. <hr>
  50. <h3 style="font-size:30px;"><b> Commentaire : </b></h3><br>
  51. ';
  52.  
  53. $req = $db->query('SELECT * FROM '.$db->prefix.'commentaire WHERE whitelist = "'.$cur_whitelist['id'].'" ORDER BY id DESC');
  54.  
  55. while($data = $db->fetch_assoc($req))
  56. echo '<h3>'.$data['Pseudo'].'</h3>'.$data['commentaire'].'';
  57.  
  58. if(isset($_POST['sendcommen'])) {
  59. $db->query('INSERT INTO '.$db->prefix.'commentaire (`commentaire`, `Pseudo`, `time`, `whitelist`) VALUES(\''.$db->escape($_POST['commentaire']).'\', \''.$db->escape($_SESSION['UserName']).'\', \''.time().'\', \''.$cur_whitelist['id'].'\')');
  60. $db->query('INSERT INTO '.$db->prefix.'notification (`text`,`vue`,`SteamID`) VALUES(\'Vous avez reçus un nouveau commentaire\', \'0\', \''.$cur_whitelist['SteamID'].'\')');
  61. header('Location: admin_whitelist.php');
  62. }
  63. if(isset($_POST['sendcommen_edit'])) {
  64. $db->query('INSERT INTO '.$db->prefix.'commentaire (`commentaire`, `Pseudo`, `time`, `whitelist`) VALUES(\''.$db->escape($_POST['commentaire']).'\', \''.$db->escape($_SESSION['UserName']).'\', \''.time().'\', \''.$cur_whitelist['id'].'\')');
  65. $db->query('UPDATE '.$db->prefix.'whitelist SET edit=\'1\' WHERE id = "'.$cur_whitelist['id'].'"');
  66. $db->query('INSERT INTO '.$db->prefix.'notification (`text`,`vue`,`SteamID`) VALUES(\'Vous avez un nouveau commentaire dans votre demande de whitelist avec la possiblité de modifier vos motivations\', \'0\', \''.$cur_whitelist['SteamID'].'\')');
  67. header('Location: admin_whitelist.php');
  68. }
  69. if(isset($_POST['sendcommen_refu'])) {
  70. $db->query('DELETE FROM '.$db->prefix.'whitelist WHERE id='.$cur_whitelist['id']);
  71. $db->query('INSERT INTO '.$db->prefix.'notification (`text`,`vue`,`SteamID`) VALUES(\'Votre candidature a été rejeté, Merci de reposté ultérieurement\', \'0\', \''.$cur_whitelist['SteamID'].'\')');
  72. $db->query('UPDATE '.$db->prefix.'users SET whitelist=\'0\' WHERE SteamID = "'.$cur_whitelist['SteamID'].'"');
  73. header('Location: admin_whitelist.php');
  74. }
  75. if(isset($_POST['sendcommen_accept'])) {
  76. $SteamID = 'ulx adduserid .'$cur_whitelist['SteamID'].' wl';
  77. $db->query('DELETE FROM '.$db->prefix.'whitelist WHERE id='.$cur_whitelist['id']);
  78. $db->query('INSERT INTO '.$db->prefix.'notification (`text`,`vue`,`SteamID`) VALUES(\'Vous êtes acceptez, Maintenant vous pouvez vous connectez sur le serveur\', \'0\', \''.$cur_whitelist['SteamID'].'\')');
  79. $db->query('UPDATE '.$db->prefix.'users SET whitelist=\'1\' WHERE SteamID = "'.$cur_whitelist['SteamID'].'"');
  80. /**
  81. * Return a byte and split it out of the string
  82. * - unsigned char
  83. *
  84. * @param string $string String
  85. */
  86. function getByte(&$string)
  87. {
  88. $data = substr($string, 0, 1);
  89.  
  90. $string = substr($string, 1);
  91.  
  92. $data = unpack('Cvalue', $data);
  93.  
  94. return $data['value'];
  95. }
  96.  
  97. /**
  98. * Return an unsigned short and split it out of the string
  99. * - unsigned short (16 bit, big endian byte order)
  100. *
  101. * @param string $string String
  102. */
  103. function getShortUnsigned(&$string)
  104. {
  105. $data = substr($string, 0, 2);
  106.  
  107. $string = substr($string, 2);
  108.  
  109. $data = unpack('nvalue', $data);
  110.  
  111. return $data['value'];
  112. }
  113.  
  114. /**
  115. * Return a signed short and split it out of the string
  116. * - signed short (16 bit, machine byte order)
  117. *
  118. * @param string $string String
  119. */
  120. function getShortSigned(&$string)
  121. {
  122. $data = substr($string, 0, 2);
  123.  
  124. $string = substr($string, 2);
  125.  
  126. $data = unpack('svalue', $data);
  127.  
  128. return $data['value'];
  129. }
  130.  
  131. /**
  132. * Return a long and split it out of the string
  133. * - unsigned long (32 bit, little endian byte order)
  134. *
  135. * @param string $string String
  136. */
  137. function getLong(&$string)
  138. {
  139. $data = substr($string, 0, 4);
  140.  
  141. $string = substr($string, 4);
  142.  
  143. $data = unpack('Vvalue', $data);
  144.  
  145. return $data['value'];
  146. }
  147.  
  148. /**
  149. * Return a float and split it out of the string
  150. *
  151. * @param string $string String
  152. */
  153. function getFloat(&$string)
  154. {
  155. $data = substr($string, 0, 4);
  156.  
  157. $string = substr($string, 4);
  158.  
  159. $array = unpack("fvalue", $data);
  160.  
  161. return $array['value'];
  162. }
  163.  
  164. /**
  165. * Return a string and split it out of the string
  166. *
  167. * @param string $string String
  168. */
  169. function getString(&$string)
  170. {
  171. $data = "";
  172.  
  173. $byte = substr($string, 0, 1);
  174.  
  175. $string = substr($string, 1);
  176.  
  177. while (ord($byte) != "0")
  178. {
  179. $data .= $byte;
  180. $byte = substr($string, 0, 1);
  181. $string = substr($string, 1);
  182. }
  183.  
  184. return $data;
  185. }
  186. // Constant
  187. define('PACKET_SIZE', '1400');
  188. define('SERVERQUERY_INFO', "\xFF\xFF\xFF\xFFTSource Engine Query");
  189. define ('REPLY_INFO', "\x49");
  190. define('SERVERQUERY_GETCHALLENGE', "\xFF\xFF\xFF\xFF\x57");
  191. define ('REPLY_GETCHALLENGE', "\x41");
  192. define('SERVERDATA_AUTH', 3) ;
  193. define ('SERVERDATA_EXECCOMMAND', 2) ;
  194.  
  195. // Ip address and port
  196. $_ip = '37.187.229.147'; // server ip
  197. $_port = '27015'; // server port
  198. $_password = 'XXXXXXXXXX'; // your rcon password
  199. $command = $SteamID;
  200. $s2 = '';
  201. $requestId = 1;
  202.  
  203. // open connection with server
  204. $socket = fsockopen ('tcp://'.$_ip, $_port, $errno, $errstr, 30) ;
  205.  
  206. // Send auth packet
  207.  
  208. // Construct packet
  209. $data = pack("VV", $requestId, SERVERDATA_AUTH).$_password.chr(0).$s2.chr(0);
  210.  
  211. // Prefix the packet by its size
  212. $data = pack("V",strlen($data)).$data;
  213.  
  214. // Send packet
  215. fwrite ($socket, $data, strlen($data)) ;
  216.  
  217. $requestId++ ;
  218.  
  219. // Check if auth is successful
  220. $junk = fread ($socket, PACKET_SIZE) ;
  221.  
  222. $string = fread ($socket, PACKET_SIZE) ;
  223. $size = getLong($string) ;
  224. $id = getLong ($string) ;
  225.  
  226. if ($id == -1)
  227. {
  228. // Error
  229. die ('Auth failed: bad password !') ;
  230. }
  231.  
  232. // Sending the command and getting the answer
  233. $data = pack ("VV", $requestId, SERVERDATA_EXECCOMMAND).$command.chr(0).$s2.chr(0) ;
  234.  
  235. // Prefix the packet by its size
  236. $data = pack ("V", strlen ($data)).$data ;
  237.  
  238. // Send packet
  239. fwrite ($socket, $data, strlen($data)) ;
  240.  
  241. $requestId++ ;
  242.  
  243. // Read response
  244. $i = 0 ;
  245. $text = '' ;
  246. while ($string = fread($socket, 4))
  247. {
  248. $info[$i]['size'] = getLong($string) ;
  249. $string = fread($socket, $info[$i]['size']) ;
  250. $info[$i]['id'] = getLong ($string) ;
  251. $info[$i]['type'] = getLong ($string) ;
  252. $info[$i]['s1'] = getString ($string) ;
  253. $info[$i]['s2'] = getString ($string) ;
  254. $text .= $info[$i]['s1'] ;
  255. $i++ ;
  256. }
  257. }
  258. ?>
  259. <center>
  260. <br>
  261. <form method="post" action="">
  262. <textarea name="commentaire" style="width:90%;height:200px;"></textarea>
  263. <input type="submit" name="sendcommen" value="Envoyer juste un commentaire">
  264. <input type="submit" name="sendcommen_edit" value="Envoyer un commentaire avec la chance de modifier la motivation">
  265. <input type="submit" name="sendcommen_refu" value="Refuser le joueur">
  266. <input type="submit" name="sendcommen_accept" value="Accepter le joueur">
  267. </form>
  268. </center>
  269. <?php
  270. }
  271. ?>
  272. </div>
  273. <?php require 'tmp/footer.php'; ?>
  274. </body>
  275. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement