admin.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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);
  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. print_r([$token,$action,$ip]);
  30. if (!(new token)->isAdmin($token)) {
  31. echo "admin access denied</div></body></html>";
  32. exit;
  33. }
  34. if($stats == true) {
  35. (new stats)->log($ip,$action,$token);
  36. }
  37. switch($action) {
  38. case 'blacklist':
  39. if((new action)->blackList($ip)){
  40. echo " blacklisted " . long2ip($ip) ."\n";
  41. } else {
  42. echo " fehler\n";
  43. };
  44. break;
  45. case 'deblacklist':
  46. if((new action)->deBlackList($ip)){
  47. echo " deblacklisted " . long2ip($ip) ."\n";
  48. } else {
  49. echo " fehler\n";
  50. };
  51. break;
  52. case 'whitelist':
  53. if((new action)->whiteList($ip)){
  54. echo " whitelisted " . long2ip($ip) ."\n";
  55. } else {
  56. echo " fehler\n";
  57. };
  58. break;
  59. case 'dewhitelist':
  60. if((new action)->deWhiteList($ip)){
  61. echo " dewhitelisted " . long2ip($ip) ."\n";
  62. } else {
  63. echo " fehler\n";
  64. };
  65. break;
  66. case 'list':
  67. if((new action)->list($ip)){
  68. echo " listed " . long2ip($ip) ."\n";
  69. } else {
  70. echo " fehler\n";
  71. };
  72. break;
  73. case 'delist':
  74. if((new action)->adminDeList($ip)){
  75. echo " delisted " . long2ip($ip) ."\n";
  76. } else {
  77. echo " fehler\n";
  78. };
  79. break;
  80. }
  81. ?>
  82. </div>
  83. <h3>Blacklist</h3>
  84. <table>
  85. <?php
  86. $blacklist = (new action)->getBlackList();
  87. foreach($blacklist as $blip) {
  88. echo "<tr><td>" . long2ip($blip) . "</td><td><a href=admin.php?token=" . $token . "&action=deblacklist&ip=" . long2ip($blip) . ">remove from blacklist</a></td></tr>";
  89. }
  90. ?>
  91. <tr>
  92. <form action="admin.php">
  93. <input type="hidden" id="token" name="token" value="<?php echo $token; ?>">
  94. <input type="hidden" id="action" name="action" value="blacklist">
  95. <td>
  96. <input type='text' id='ip' name='ip'>
  97. </td><td>
  98. <input type='submit' value='add to blacklist'>
  99. </form>
  100. </td></tr>
  101. </table>
  102. <h3>Whitelist</h3>
  103. <table border="0">
  104. <?php
  105. $whitelist = (new action)->getWhiteList();
  106. foreach($whitelist as $wlip) {
  107. echo "<tr><td>" . long2ip($wlip) . "</td><td><a href=admin.php?token=" . $token . "&action=dewhitelist&ip=" . long2ip($wlip) . ">remove from whitelist</a></td></tr>";
  108. }
  109. ?>
  110. </table>
  111. <h3>List</h3>
  112. <table border="0">
  113. <?php
  114. $list = (new action)->getList();
  115. foreach($list as $lip) {
  116. echo "<tr><td>" . long2ip($lip) . "</td><td><a href=admin.php?token=" . $token . "&action=delist&ip=" . long2ip($lip) . ">remove from list</a></td></tr>";
  117. }
  118. ?>
  119. </table>
  120. </body>
  121. </html>