Advertisement
Guest User

index.php

a guest
May 11th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.03 KB | None | 0 0
  1. <?php
  2. include '../../scripts/config.inc';
  3. include '../../scripts/admin/rcon.inc';
  4.  
  5. echo '<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" crossorigin="anonymous"><center>';
  6.  
  7. function access()
  8. {
  9. Global $headAdmin;
  10. $IP = $_SERVER['REMOTE_ADDR'];
  11. If( $IP == "85.202.220.14" || $IP == "127.0.0.1" ) $headAdmin = true;
  12. else $headAdmin = true;
  13.  
  14. $allow = explode( ":", "85.202.220.14:81.93.193.7:127.0.0.1:84.27.177.41:81.92.190.104" );
  15. for( $i = 0;$i < count( $allow );$i++ )
  16. if( $IP == $allow[ $i ] ) return true;
  17. return true;
  18. }
  19. function deleteEnter( $str ){
  20. $str = str_replace( "\r", "", $str );
  21. return str_replace( "\n", "{ENTER}", $str );
  22. }
  23. function backEnter( $str ){
  24. return str_replace( "{ENTER}", "\n", $str );
  25. }
  26.  
  27. if( !access() ) exit();
  28. //echo '<center><fieldset><h1 color="gold" style="font-family:Georgia"></h1>';
  29. if( isSet( $_GET[ 'thing' ] ) || isSet( $_GET[ 'editnews' ] ) )
  30. {
  31. parseNews();
  32.  
  33. if( isSet($_GET[ 'thing' ]) && $_GET["thing"] == "edit" )
  34. {
  35. if( $headAdmin ) {
  36. For( $i = 0;$i < count( $newsTitle );$i++ )
  37. {
  38. echo '<a href="?editnews=' . $i . '">' . backEnter( $newsTitle[ $i ] ) . '</a><br \>';
  39. }
  40. }
  41. }
  42. else if( isSet($_GET[ 'thing' ]) && $_GET[ 'thing' ] == "make" )
  43. createNewsForm();
  44. else if( isSet( $_GET[ 'editnews' ] ) )
  45. {
  46. if( $headAdmin ) {
  47. $num = (int)$_GET[ 'editnews' ];
  48. echo '<form id="edit" action="perform.php" method="post" >
  49. <fieldset>
  50. Title:<br \><input name="title" size="70" value="' . backEnter( $newsTitle[$num] ) . '"><br \>
  51. Text:<br \><textarea onkeyup="textAreaAdjust(this)" name="text" rows="15" cols="70">' . backEnter( $newsText[$num] ) . '</textarea><br \>
  52. Date:<br \><input name="date" value="' . backEnter( $newsDate[$num] ) . '"><br \>
  53. Approval:<br \>
  54.  
  55. <select name="approve">
  56. <option value="APPROVED"';if(backEnter($newsApproval[$num]) == 'APPROVED') echo 'selected="selected"';
  57. echo '>Approved</option>
  58. <option value="NOTAPPROVED"';if(backEnter($newsApproval[$num]) == 'NOTAPPROVED') echo 'selected="selected"';
  59. echo '>Not Approved</option>
  60. </select>
  61.  
  62. <input type="hidden" name="id" value="' . $num . '"><br \><br \>
  63. <input type="submit" name="submit" class="btn btn-primary" value="Send">
  64. </fieldset>
  65. </form>'; }
  66. }
  67. else if( $_GET[ 'thing' ] == "control" )
  68. {
  69. $connection = fsockopen( "udp://" . $ServerIP, $ServerPort);
  70.  
  71. if(!is_resource($connection))
  72. {
  73. echo '<h1>Server seems to be <font color="red">Offline</font></h1><br \>';
  74. echo '<h2><a href="?thing=start">Start server</a></h2>';
  75. }
  76. else
  77. {
  78. echo '<h1>Server seems to be <font color="green">Online</font></h1>';
  79. echo '<h2><a href="?thing=restart">Restart server</a><br \>';
  80. echo '<a href="?thing=shut">Shut server</a></h2>';
  81. echo '<a href="?thing=hostname">Change name of the server</a>
  82. <br \>
  83. <a href="?thing=editrot">Edit rotation</a>
  84. <br \>
  85. <a href="?thing=update">Update statistics</a>
  86. <br \>';
  87. }
  88.  
  89. }
  90. else if( $_GET[ 'thing' ] == "app" )
  91. {
  92. getApps();
  93. }
  94. else if( $_GET[ 'thing' ] == "update" )
  95. {
  96. updateServerStats();
  97. }
  98. else if( $_GET[ 'thing' ] == "hostname" )
  99. {
  100. $x = rcon( "sv_hostname", 1 );
  101. $x = explode('"', $x)[3];
  102. echo '<form id="edit" action="perform.php" method="post" style="background-color: #595959">
  103. <fieldset>
  104. ' . color( $x ) . '</font></font></font></font><br \>
  105. Hostname:<br \><input name="hostname" size="70" value="' . $x . '"><br \>
  106. <input type="hidden" name="id" value="hostname"><br \><br \>
  107. <input type="submit" name="submit" class="btn btn-primary" value="Send">
  108. </fieldset>
  109. </form>';
  110. }
  111. else if( $_GET[ 'thing' ] == "editrot" )
  112. {
  113. $x = rcon( "sv_maprotation", 1 );
  114. echo '<form id="edit" action="perform.php" method="post" >
  115. <fieldset>
  116. Text:<br \><textarea name="rotation" rows="30" cols="70">' . $x . '</textarea><br \>
  117. <input type="hidden" name="id" value="editrot"><br \><br \>
  118. <input type="submit" name="submit" class="btn btn-primary" value="Send">
  119. </fieldset>
  120. </form>';
  121. }
  122. else if( $_GET[ 'thing' ] == "start" )
  123. {
  124.  
  125. }
  126. else if( $_GET[ 'thing' ] == "shut" )
  127. {
  128. echo sendMessage( "shut" );
  129. }
  130. else if( $_GET[ 'thing' ] == "restart" )
  131. {
  132.  
  133.  
  134. }
  135. else
  136. {
  137. echo '<h1 style="color:red">Sorry, could not find your request, or it is currently under construction!</h1>';
  138. }
  139. echo '<a class="btn btn-primary" href="javascript:history.back()" style="text:white">Go back</a><br \><br \></center>';
  140. }
  141. else
  142. {
  143. $add = "";
  144. If( $headAdmin ) $add = '<a href="?thing=edit">Edit news</a><br \>';
  145.  
  146.  
  147. echo '<h2>' . $add . '
  148. <a href="?thing=make">Make news</a>
  149. <br \>
  150. <a href="?thing=app">Admin applications</a>
  151. <br \>
  152. <a href="?thing=control" color="blue">Server control</a>
  153. </h2></center>';
  154. }
  155.  
  156. function getString( $from, $to, $str, $flag=0 )
  157. {
  158. $rev = strRev( $str );
  159. $revTo = strRev( $to );
  160.  
  161. $str = strRev( strStr( $rev, $revTo ) );
  162. $str = str_replace( $to, "", $str );
  163.  
  164. $str = strStr( $str, $from );
  165. $str = str_replace( $from, "", $str );
  166.  
  167. $text = "</td>";
  168. if( $flag ) $text = "</tr>";
  169. echo '<td>' . $str . $text;
  170. }
  171. function updateServerStats()
  172. {
  173. Global $StatsFile;
  174.  
  175. $file = "../".$StatsFile;
  176.  
  177. $stats = explode( ":", "hunter_score:zombie_score:heads:bashes:kills" );
  178.  
  179. for( $i = 0;$i < count( $stats );$i++ )
  180. $stat[$i] = rcon( $stats[$i] );
  181.  
  182. $img[0] = "hunter_score.png";
  183. $img[1] = "zombie_score.png";
  184. $img[2] = "heads.png";
  185. $img[3] = "bashes.png";
  186. $img[4] = "kills.png";
  187.  
  188.  
  189. $re = '/is:"([0-9]*):(.*)" default/m';
  190.  
  191. for( $i = 0;$i < count( $stat );$i++ )
  192. {
  193. echo $stat[$i];
  194. preg_match_all($re, $stat[$i], $matches, PREG_SET_ORDER, 0);
  195.  
  196. $score[$i] = $matches[ 0 ][1];
  197. $name[$i] = $matches[ 0 ][2];
  198. }
  199.  
  200. $theret = "<table align=center class=style4><thead><th>#</th><th>Name</th><th>Score</th><tbody>";
  201.  
  202. for( $i = 0;$i < count($name);$i++ )
  203. $theret = $theret . '<tr><td><img src="images/' . $img[$i] . '" width=20 height=20></td><td>' . colorize($name[$i]) . '</td><td>' . $score[$i] . '</td></tr>';
  204.  
  205. $theret = $theret . '</tbody></table>';
  206. $fh = fopen($file, 'w') or die("can't open file");
  207. fwrite($fh, $theret);
  208. fclose($fh);
  209.  
  210. echo $theret;
  211. }
  212.  
  213. function color($text)
  214. {
  215. $text = str_replace('^0', '<font color="black">',$text);
  216. $text = str_replace('^1', '<font color="red">',$text);
  217. $text = str_replace('^2', '<font color="green">',$text);
  218. $text = str_replace('^3', '<font color="yellow">',$text);
  219. $text = str_replace('^4', '<font color="blue">',$text);
  220. $text = str_replace('^5', '<font color="aqua">',$text);
  221. $text = str_replace('^6', '<font color="hotpink">',$text);
  222. $text = str_replace('^7', '<font color="white">',$text);
  223. $text = str_replace('^8', '<font color="darkgreen">',$text);
  224. $text = str_replace('^9', '<font color="darkred">',$text);
  225. return $text;
  226. }
  227.  
  228. function getApps()
  229. {
  230. $file = '../apps737.db';
  231. $read = file_get_contents($file);
  232.  
  233. if( $read == "" ) exit( "Couldn't find any applications" . '<br \><a href="javascript:history.back()">Go back</a>' );
  234.  
  235. $apps = explode( "START OF APPLICATION|", $read );
  236.  
  237. echo '
  238. <table class="table table-dark">
  239. <thead>
  240. <tr>
  241. <th>#</th>
  242. <th>IP</th>
  243. <th>Name</th>
  244. <th>Steam</th>
  245. <th>Age</th>
  246. <th>English knowledge</th>
  247. <th>Command knowledge</th>
  248. <th>Experience as an Admin</th>
  249. <th>Experience in CoD</th>
  250. <th>Reason</th>
  251. </tr>
  252. </thead>
  253. <tbody>';
  254. for( $i = 1;$i < count( $apps );$i++ )
  255. {
  256. echo "<tr><th scope='row'>" . $i . "</th>";
  257. echo getString( "IP:", "NAME: ", $apps[ $i ] );
  258. echo getString( "NAME: ", "Steam: ", $apps[ $i ] );
  259. echo getString( "Age: ", "Knownledge of English: ", $apps[ $i ] );
  260. echo getString( "Knownledge of English: ", "Command Knownledge: ", $apps[ $i ] );
  261. echo getString( "Command Knownledge: ", "Experience as Admin: ", $apps[ $i ] );
  262. echo getString( "Experience as Admin: ", "Experience in CoD: ", $apps[ $i ] );
  263. echo getString( "Command Knownledge: ", "Experience as Admin: ", $apps[ $i ] );
  264. echo getString( "Experience in CoD: ", "Why wants to be an Admin: ", $apps[ $i ] );
  265. echo getString( "Why wants to be an Admin: ", "|END OF APPL", $apps[ $i ] );
  266. echo "</tr>";
  267. }
  268. echo '
  269. </tbody>
  270. </table>';
  271. }
  272.  
  273. function createNewsForm()
  274. {
  275. echo '<center><form id="edit" action="perform.php" method="post" >
  276. <fieldset>
  277. Title:<br \><input name="title" size="70"><br \>
  278. Text:<br \><textarea name="text" rows="30" cols="70"></textarea><br \>
  279. Date:<br \><input name="date"><br \>
  280. <input type="hidden" name="id" value="new"><br \><br \>
  281. <input class="btn btn-primary" type="submit" name="submit" value="Send">
  282. </fieldset>
  283. </form>';
  284.  
  285.  
  286. }
  287. function parseNews()
  288. {
  289. Global $array;
  290.  
  291. Global $newsTitle;
  292. Global $newsText;
  293. Global $newsDate;
  294. Global $newsApproval;
  295.  
  296. $newsTitle[0] = "";
  297. $newsText[0] = "";
  298. $newsDate[0] = "";
  299. $newsApproval[0] = "";
  300.  
  301. $lines = file( 'news.inc' );
  302. foreach ($lines as $line_num => $line)
  303. {
  304. $line = str_replace( "\r", "", $line );
  305. $line = str_replace( "\n", "", $line );
  306. $tmp = explode( "<", $line );
  307.  
  308. try {
  309. $newsTitle[ count( $newsTitle ) ] = $tmp[ 0 ];
  310. $newsText[ count( $newsText ) ] = $tmp[ 1 ];
  311. $newsDate[ count( $newsDate ) ] = $tmp[ 2 ];
  312. $newsApproval[ count( $newsApproval ) ] = $tmp[ 3 ];
  313. } catch(Exception $e){}
  314. }
  315. }
  316.  
  317.  
  318. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement