Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.38 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_GET['ping']) || isset($_POST['ping'])) {
  4.  
  5. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  6. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
  7. header("Cache-Control: no-cache, must-revalidate");
  8. header("Pragma: no-cache");
  9. header("Content-Type: text/xml; charset=utf-8");
  10.  
  11. require('chat.php');
  12.  
  13. // definitions of random variables
  14. $ip = $_SERVER['REMOTE_ADDR'];
  15. $output = '<?xml version="1.0" ?><root>';
  16.  
  17. if (isset($_POST['query'])) {
  18. $query = $_POST['query'];
  19. } else if (isset($_GET['query'])) {
  20. $query = $_GET['query'];
  21. }
  22.  
  23. $sign_on = false;
  24. $query = strip_tags($query);
  25. $command_regex = ("/^\//");
  26.  
  27. // setup a new user object (add refresh when done)
  28. $user = new user;
  29. $user->_connect();
  30. //$user->_refresh();
  31. $user->_get_info($ip, 2);
  32.  
  33. if (preg_match($command_regex, $query)) {
  34. $query_array = preg_split('/\s/', $query, 2);
  35. $command = preg_replace($command_regex, null, $query_array[0]);
  36. $variables = $query_array[1];
  37. }
  38.  
  39. if (($user->_status == "offline" || $user->_status == null) && isset($command)) {
  40.  
  41. //offline commands
  42. if (preg_match('/login/i', $command)) {
  43. list($name, $pass) = explode(' ', $variables);
  44.  
  45. if (isset($name) && isset($pass)) {
  46. $output .= "<command>" . $user->_login($name, $pass, $ip) . '</command>';
  47. if ($user->_status == "online") {
  48. $sign_on = true;
  49. }
  50. }
  51. }
  52.  
  53. if (preg_match('/register/i', $command)) {
  54. list($name, $pass) = explode(' ', $variables);
  55.  
  56. if (isset($name) && isset($pass)) {
  57. $output .= "<command>" . $user->_add_user($name, $pass, $ip) . "</command>";
  58. }
  59. }
  60. }
  61.  
  62. if ($user->_status == "online") {
  63. //online commands
  64. if (isset($command)) {
  65. if (preg_match('/logout/i', $command)) {
  66. if (isset($variables)) {
  67. $output .= "<command>" . $user->_logout($user->_name, $variables) . "</command>";
  68. } else {
  69. $output .= "<command>" . $user->_logout($user->_name) . "</command>";
  70. }
  71. goto end;
  72. }
  73.  
  74. if (preg_match('/\binfo\b/i', $command) || $sign_on == true) {
  75. $output .= "<chat_info>";
  76. $_info = $user->_get_chat_info();
  77. if (preg_match('/t/', $variables) || ($variables == "-all" || $variables == "-a" || $variables == null) || $sign_on = true) {
  78. $output .= "<title editor='" . $_info['title_editor'] . "'>" . $_info['title'] . "</title>";
  79. }
  80. if (preg_match('/m/', $variables) || ($variables == "-all" || $variables == "-a" || $variables == null) || $sign_on = true) {
  81. $output .= "<motd editor='" . $_info['motd_editor'] . "'>" . $_info['motd'] . "</motd>";
  82. }
  83. if (preg_match('/u/', $variables) || ($variables == "-all" || $variables == "-a" || $variables == null) || $sign_on = true) {
  84. $output .= "<users>";
  85. foreach ($user->_users_online() as $_user) {
  86. $output .= "<user name='" . $_user['name'] . "' level='" . $_user['level'] . "'></user>";
  87. }
  88. $output .= "</users>";
  89. }
  90. $output .= "</chat_info>";
  91. }
  92.  
  93. if ($user->_level >= 0) {
  94. if (preg_match('/pm/i', $command)) {
  95. $query_array = preg_split('/\s/', $variables, 2);
  96. $output .= "<command>" . $user->_pm($query_array[0], $query_array[1]) . "</command>";
  97. }
  98.  
  99. if (preg_match('/set/i', $command)) {
  100. $query_array = preg_split('/\s/', $variables, 3);
  101. if (($query_array[0] == "-p" || $query_array[0] == "-pw" || $query_array[0] == "-pass" || $query_array[0] == "-password") && strlen($query_array[1]) > 3 && !isset($query_array[2])) {
  102. $output .= "<command>" . $user->_change_pass($query_array[1]) . "</command>";
  103. }
  104. }
  105. }
  106.  
  107. if ($user->_level >= 2) {
  108. if (preg_match('/set/i', $command)) {
  109. $query_array = preg_split('/\s/', $variables, 2);
  110. if (($query_array[0] == "-t" || $query_array[0] == "-title" || $query_array[0] == "-topic") && strlen($query_array[1]) > 0) {
  111. $output .= "<command>" . $user->_set_title($query_array[1]) . "</command>";
  112. }
  113. if (($query_array[0] == "-l" || $query_array[0] == "-lvl" || $query_array[0] == "-level") && strlen($query_array[1]) > 0) {
  114. $output .= "<command>" . $user->_set_title($query_array[1]) . "</command>";
  115. }
  116. }
  117.  
  118. if (preg_match('/kick/i', $command)) {
  119. $query_array = preg_split('/\s/', $variables, 2);
  120. if (isset($query_array[0])) {
  121. if (strlen($query_array[1]) > 0) {
  122. $output .= "<command>" . $user->_kick($query_array[0], $query_array[1]) . "</command>";
  123. } else {
  124. $output .= "<command>" . $user->_kick($query_array[0]) . "</command>";
  125. }
  126. }
  127. }
  128. }
  129.  
  130. if ($user->_level >= 3) {
  131. if (preg_match('/dump/i', $command)) {
  132. if (isset($variables) && is_numberic($variables)) {
  133. $output .= "<command>" . $user->_dump($variables) . "</command>";
  134. } else {
  135. $output .= "<command>" . $user->_dump() . "</command>";
  136. }
  137. }
  138.  
  139. if (preg_match('/set/i', $command)) {
  140. $query_array = preg_split('/\s/', $variables, 3);
  141. if (($query_array[0] == "-p" || $query_array[0] == "-pw" || $query_array[0] == "-pass" || $query_array[0] == "-password") && isset($query_array[1]) && isset($query_array[2])) {
  142. $output .= "<command>" . $user->_change_pass($query_array[2], $query_array[1]) . "</command>";
  143. }
  144. }
  145.  
  146. if (preg_match('/users/i', $command)) {
  147. if (!isset($variables)) {
  148. $variables = false;
  149. }
  150. $output .= "<command>";
  151. foreach ($user->_get_users($variables) as $_user) {
  152. $output .= "<user name='" . $_user['name'] . "' pass='" . $_user['pass'] . "' level='" . $_user['level'] . "' host='" . $_user['host'] . "' exception='" . $_user['excep'] . "'></user>";
  153. }
  154. $output .= "</command>";
  155. }
  156. }
  157.  
  158. if ($user->_level >= 4) {
  159. if (preg_match('/dump/i', $command)) {
  160. if (isset($variables) && is_numberic($variables)) {
  161. $output .= "<command>" . $user->_dump($variables) . "</command>";
  162. } else {
  163. $output .= "<command>" . $user->_dump() . "</command>";
  164. }
  165. }
  166.  
  167. if (preg_match('/set/i', $command)) {
  168. $query_array = preg_split('/\s/', $variables, 3);
  169. if (($query_array[0] == "-p" || $query_array[0] == "-pw" || $query_array[0] == "-pass" || $query_array[0] == "-password") && isset($query_array[1]) && isset($query_array[2])) {
  170. $output .= "<command>" . $user->_change_pass($query_array[2], $query_array[1]) . "</command>";
  171. }
  172. }
  173. }
  174. }
  175.  
  176. $output .= "<user_info><name>" . $user->_name . "</name><status>" . $user->_status . "</status></user_info>";
  177.  
  178. if (isset($_GET['chat']) || isset($_POST['chat'])) {
  179. $chat = new chat;
  180. $chat->_connect();
  181. $chat->_get_info($ip);
  182.  
  183. if (isset($query) && strlen($query) > 0 && !preg_match($command_regex, $query)) {
  184. $chat->_send($user->_name, $query);
  185. }
  186. $output .= "<chat id='" . $chat->_last_id() . "'>";
  187.  
  188. if (isset($_GET['id']) && $_GET['id'] != -1) {
  189. $id = $_GET['id'];
  190. } else {
  191. $id = $chat->_last_id() - 10;
  192. }
  193.  
  194. foreach ($chat->_get($user->_name, $id) as $_row) {
  195. switch ($_row['type']) {
  196. case 'chat':
  197. $output .= "<message id='" . $_row['id'] . "' type='" . $_row['type'] . "' name='" . $_row['name'] . "'>" . $_row['message'] . "</message>";
  198. break 1;
  199. case 'pm':
  200. if ($_row['recipient'] == $user->_name || $_row['name'] == $user->_name) {
  201. $output .= "<message id='" . $_row['id'] . "' type='" . $_row['type'] . "' name='" . $_row['name'] . "' recipient='" . $_row['recipient'] . "'>" . $_row['message'] . "</message>";
  202. }
  203. break 1;
  204. case 'title':
  205. $output .= "<message id='" . $_row['id'] . "' type='" . $_row['type'] . "' name='" . $_row['name'] . "'>" . $_row['message'] . "</message>";
  206. break 1;
  207. //case 'game':
  208. //$_output .= "\n[" . $_row['type'] . "]" . $_row['name'] . " is now playing " . $_row['message'];
  209. //break 1;
  210. case 'kick':
  211. case 'kicked':
  212. $output .= "<message id='" . $_row['id'] . "' type='" . $_row['type'] . "' name='" . $_row['name'] . "' recipient='" . $_row['recipient'] . "'>" . $_row['message'] . "</message>";
  213. break 1;
  214. case 'log in':
  215. case 'log out':
  216. $output .= "<message id='" . $_row['id'] . "' type='" . $_row['type'] . "' name='" . $_row['name'] . "'>" . $_row['message'] . "</message>";
  217. break 1;
  218. }
  219. }
  220.  
  221. $output .= "</chat>";
  222. }
  223. $user->_action($user->_name);
  224. }
  225. }
  226.  
  227. end:
  228. $output .= '</root>';
  229. echo $output;
  230.  
  231. function get_info($mode=null) {
  232. $_output .= "<chat_info>";
  233. //$_info = $user->_get_chat_info();
  234. if (preg_match('/t/', $mode) || ($mode == "-all" || $mode == "-a" || $mode == null)) {
  235. $_output .= "<title editor='" . $_info['title_editor'] . "'>" . $_info['title'] . "</title>";
  236. }
  237. if (preg_match('/m/', $mode) || ($mode == "-all" || $mode == "-a" || $mode == null)) {
  238. $_output .= "<motd editor='" . $_info['motd_editor'] . "'>" . $_info['motd'] . "</motd>";
  239. }
  240. if (preg_match('/u/', $mode) || ($mode == "-all" || $mode == "-a" || $mode == null)) {
  241. $_output .= "<users>";
  242. //foreach ($user->_users_online() as $_user) {
  243. // $_output .= "<user name='" . $_user['name'] . "' level='" . $_user['level'] . "'></user>";
  244. //}
  245. $_output .= "</users></chat_info>";
  246. }
  247. return $_output;
  248. }
  249.  
  250. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement