admin.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Blacklister Admin</title>
  5. </head>
  6. <body>
  7. <div>
  8. <?php
  9. error_reporting(E_ALL);
  10. require_once 'action.php';
  11. require_once 'db.php';
  12. require_once 'token.php';
  13. require_once 'stats.php';
  14. print_r($_GET['token']);
  15. if(!isset($_GET['token'])){
  16. echo "<form action='admin.php'><input type='text' id='token' name='token'><input type='submit' valeu='send token'></form></div></body></html>";
  17. exit;
  18. }
  19. if(isset($_GET['ip'])) {
  20. $ip = ip2long(substr(trim($_GET['ip']),0,15));
  21. }
  22. if(isset($_GET['token'])) {
  23. $token = substr(trim($_GET['token']),0,25);
  24. }
  25. if(isset($_GET['action'])) {
  26. $action = substr(trim($_GET['action']),0,9);
  27. }
  28. $stats = true;
  29. if (!(new token)->isAdmin($token)) {
  30. echo "admin access denied</div></body></html>";
  31. exit;
  32. }
  33. if($stats == true) {
  34. (new stats)->log($ip,$action,$token);
  35. }
  36. switch($action) {
  37. case 'blacklist':
  38. if((new action)->blackList($ip)){
  39. echo " blacklisted " . long2ip($ip) ."\n";
  40. } else {
  41. echo " fehler\n";
  42. };
  43. break;
  44. case 'deblacklist':
  45. if((new action)->deBlackList($ip)){
  46. echo " deblacklisted " . long2ip($ip) ."\n";
  47. } else {
  48. echo " fehler\n";
  49. };
  50. break;
  51. case 'whitelist':
  52. if((new action)->whiteList($ip)){
  53. echo " whitelisted " . long2ip($ip) ."\n";
  54. } else {
  55. echo " fehler\n";
  56. };
  57. break;
  58. case 'dewhitelist':
  59. if((new action)->deWhiteList($ip)){
  60. echo " dewhitelisted " . long2ip($ip) ."\n";
  61. } else {
  62. echo " fehler\n";
  63. };
  64. break;
  65. case 'list':
  66. if((new action)->list($ip)){
  67. echo " listed " . long2ip($ip) ."\n";
  68. } else {
  69. echo " fehler\n";
  70. };
  71. break;
  72. case 'delist':
  73. if((new action)->adminDeList($ip)){
  74. echo " delisted " . long2ip($ip) ."\n";
  75. } else {
  76. echo " fehler\n";
  77. };
  78. break;
  79. }
  80. ?>
  81. </div>
  82. <h3>Blacklist</h3>
  83. <table>
  84. <?php
  85. $blacklist = (new action)->getBlackList();
  86. foreach($blacklist as $blip) {
  87. echo "<tr><td>" . long2ip($blip) . "</td><td><a href=admin.php?token=" . $token . "&action=deblacklist&ip=" . long2ip($blip) . ">remove from blacklist</a></td></tr>";
  88. }
  89. ?>
  90. <tr>
  91. <form action="admin.php">
  92. <input type="hidden" id="token" name="token" value="<?php echo $token; ?>">
  93. <input type="hidden" id="action" name="action" value="blacklist">
  94. <td>
  95. <input type='text' id='ip' name='ip'>
  96. </td><td>
  97. <input type='submit' value='add to blacklist'>
  98. </form>
  99. </td></tr>
  100. </table>
  101. <h3>Whitelist</h3>
  102. <table border="0">
  103. <?php
  104. $whitelist = (new action)->getWhiteList();
  105. foreach($whitelist as $wlip) {
  106. echo "<tr><td>" . long2ip($wlip) . "</td><td><a href=admin.php?token=" . $token . "&action=dewhitelist&ip=" . long2ip($wlip) . ">remove from whitelist</a></td></tr>";
  107. }
  108. ?>
  109. </table>
  110. <h3>List</h3>
  111. <table border="0">
  112. <?php
  113. $list = (new action)->getList();
  114. foreach($list as $lip) {
  115. echo "<tr><td>" . long2ip($lip) . "</td><td><a href=admin.php?token=" . $token . "&action=delist&ip=" . long2ip($lip) . ">remove from list</a></td></tr>";
  116. }
  117. ?>
  118. </table>
  119. </body>
  120. </html>