Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_GET['ping']) || isset($_POST['ping'])) {
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
- header("Cache-Control: no-cache, must-revalidate");
- header("Pragma: no-cache");
- header("Content-Type: text/xml; charset=utf-8");
- require('chat.php');
- // definitions of random variables
- $ip = $_SERVER['REMOTE_ADDR'];
- $output = '<?xml version="1.0" ?><root>';
- if (isset($_POST['query'])) {
- $query = $_POST['query'];
- } else if (isset($_GET['query'])) {
- $query = $_GET['query'];
- }
- $sign_on = false;
- $query = strip_tags($query);
- $command_regex = ("/^\//");
- // setup a new user object (add refresh when done)
- $user = new user;
- $user->_connect();
- //$user->_refresh();
- $user->_get_info($ip, 2);
- if (preg_match($command_regex, $query)) {
- $query_array = preg_split('/\s/', $query, 2);
- $command = preg_replace($command_regex, null, $query_array[0]);
- $variables = $query_array[1];
- }
- if (($user->_status == "offline" || $user->_status == null) && isset($command)) {
- //offline commands
- if (preg_match('/login/i', $command)) {
- list($name, $pass) = explode(' ', $variables);
- if (isset($name) && isset($pass)) {
- $output .= "<command>" . $user->_login($name, $pass, $ip) . '</command>';
- if ($user->_status == "online") {
- $sign_on = true;
- }
- }
- }
- if (preg_match('/register/i', $command)) {
- list($name, $pass) = explode(' ', $variables);
- if (isset($name) && isset($pass)) {
- $output .= "<command>" . $user->_add_user($name, $pass, $ip) . "</command>";
- }
- }
- }
- if ($user->_status == "online") {
- //online commands
- if (isset($command)) {
- if (preg_match('/logout/i', $command)) {
- if (isset($variables)) {
- $output .= "<command>" . $user->_logout($user->_name, $variables) . "</command>";
- } else {
- $output .= "<command>" . $user->_logout($user->_name) . "</command>";
- }
- goto end;
- }
- if (preg_match('/\binfo\b/i', $command) || $sign_on == true) {
- $output .= "<chat_info>";
- $_info = $user->_get_chat_info();
- if (preg_match('/t/', $variables) || ($variables == "-all" || $variables == "-a" || $variables == null) || $sign_on = true) {
- $output .= "<title editor='" . $_info['title_editor'] . "'>" . $_info['title'] . "</title>";
- }
- if (preg_match('/m/', $variables) || ($variables == "-all" || $variables == "-a" || $variables == null) || $sign_on = true) {
- $output .= "<motd editor='" . $_info['motd_editor'] . "'>" . $_info['motd'] . "</motd>";
- }
- if (preg_match('/u/', $variables) || ($variables == "-all" || $variables == "-a" || $variables == null) || $sign_on = true) {
- $output .= "<users>";
- foreach ($user->_users_online() as $_user) {
- $output .= "<user name='" . $_user['name'] . "' level='" . $_user['level'] . "'></user>";
- }
- $output .= "</users>";
- }
- $output .= "</chat_info>";
- }
- if ($user->_level >= 0) {
- if (preg_match('/pm/i', $command)) {
- $query_array = preg_split('/\s/', $variables, 2);
- $output .= "<command>" . $user->_pm($query_array[0], $query_array[1]) . "</command>";
- }
- if (preg_match('/set/i', $command)) {
- $query_array = preg_split('/\s/', $variables, 3);
- 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])) {
- $output .= "<command>" . $user->_change_pass($query_array[1]) . "</command>";
- }
- }
- }
- if ($user->_level >= 2) {
- if (preg_match('/set/i', $command)) {
- $query_array = preg_split('/\s/', $variables, 2);
- if (($query_array[0] == "-t" || $query_array[0] == "-title" || $query_array[0] == "-topic") && strlen($query_array[1]) > 0) {
- $output .= "<command>" . $user->_set_title($query_array[1]) . "</command>";
- }
- if (($query_array[0] == "-l" || $query_array[0] == "-lvl" || $query_array[0] == "-level") && strlen($query_array[1]) > 0) {
- $output .= "<command>" . $user->_set_title($query_array[1]) . "</command>";
- }
- }
- if (preg_match('/kick/i', $command)) {
- $query_array = preg_split('/\s/', $variables, 2);
- if (isset($query_array[0])) {
- if (strlen($query_array[1]) > 0) {
- $output .= "<command>" . $user->_kick($query_array[0], $query_array[1]) . "</command>";
- } else {
- $output .= "<command>" . $user->_kick($query_array[0]) . "</command>";
- }
- }
- }
- }
- if ($user->_level >= 3) {
- if (preg_match('/dump/i', $command)) {
- if (isset($variables) && is_numberic($variables)) {
- $output .= "<command>" . $user->_dump($variables) . "</command>";
- } else {
- $output .= "<command>" . $user->_dump() . "</command>";
- }
- }
- if (preg_match('/set/i', $command)) {
- $query_array = preg_split('/\s/', $variables, 3);
- 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])) {
- $output .= "<command>" . $user->_change_pass($query_array[2], $query_array[1]) . "</command>";
- }
- }
- if (preg_match('/users/i', $command)) {
- if (!isset($variables)) {
- $variables = false;
- }
- $output .= "<command>";
- foreach ($user->_get_users($variables) as $_user) {
- $output .= "<user name='" . $_user['name'] . "' pass='" . $_user['pass'] . "' level='" . $_user['level'] . "' host='" . $_user['host'] . "' exception='" . $_user['excep'] . "'></user>";
- }
- $output .= "</command>";
- }
- }
- if ($user->_level >= 4) {
- if (preg_match('/dump/i', $command)) {
- if (isset($variables) && is_numberic($variables)) {
- $output .= "<command>" . $user->_dump($variables) . "</command>";
- } else {
- $output .= "<command>" . $user->_dump() . "</command>";
- }
- }
- if (preg_match('/set/i', $command)) {
- $query_array = preg_split('/\s/', $variables, 3);
- 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])) {
- $output .= "<command>" . $user->_change_pass($query_array[2], $query_array[1]) . "</command>";
- }
- }
- }
- }
- $output .= "<user_info><name>" . $user->_name . "</name><status>" . $user->_status . "</status></user_info>";
- if (isset($_GET['chat']) || isset($_POST['chat'])) {
- $chat = new chat;
- $chat->_connect();
- $chat->_get_info($ip);
- if (isset($query) && strlen($query) > 0 && !preg_match($command_regex, $query)) {
- $chat->_send($user->_name, $query);
- }
- $output .= "<chat id='" . $chat->_last_id() . "'>";
- if (isset($_GET['id']) && $_GET['id'] != -1) {
- $id = $_GET['id'];
- } else {
- $id = $chat->_last_id() - 10;
- }
- foreach ($chat->_get($user->_name, $id) as $_row) {
- switch ($_row['type']) {
- case 'chat':
- $output .= "<message id='" . $_row['id'] . "' type='" . $_row['type'] . "' name='" . $_row['name'] . "'>" . $_row['message'] . "</message>";
- break 1;
- case 'pm':
- if ($_row['recipient'] == $user->_name || $_row['name'] == $user->_name) {
- $output .= "<message id='" . $_row['id'] . "' type='" . $_row['type'] . "' name='" . $_row['name'] . "' recipient='" . $_row['recipient'] . "'>" . $_row['message'] . "</message>";
- }
- break 1;
- case 'title':
- $output .= "<message id='" . $_row['id'] . "' type='" . $_row['type'] . "' name='" . $_row['name'] . "'>" . $_row['message'] . "</message>";
- break 1;
- //case 'game':
- //$_output .= "\n[" . $_row['type'] . "]" . $_row['name'] . " is now playing " . $_row['message'];
- //break 1;
- case 'kick':
- case 'kicked':
- $output .= "<message id='" . $_row['id'] . "' type='" . $_row['type'] . "' name='" . $_row['name'] . "' recipient='" . $_row['recipient'] . "'>" . $_row['message'] . "</message>";
- break 1;
- case 'log in':
- case 'log out':
- $output .= "<message id='" . $_row['id'] . "' type='" . $_row['type'] . "' name='" . $_row['name'] . "'>" . $_row['message'] . "</message>";
- break 1;
- }
- }
- $output .= "</chat>";
- }
- $user->_action($user->_name);
- }
- }
- end:
- $output .= '</root>';
- echo $output;
- function get_info($mode=null) {
- $_output .= "<chat_info>";
- //$_info = $user->_get_chat_info();
- if (preg_match('/t/', $mode) || ($mode == "-all" || $mode == "-a" || $mode == null)) {
- $_output .= "<title editor='" . $_info['title_editor'] . "'>" . $_info['title'] . "</title>";
- }
- if (preg_match('/m/', $mode) || ($mode == "-all" || $mode == "-a" || $mode == null)) {
- $_output .= "<motd editor='" . $_info['motd_editor'] . "'>" . $_info['motd'] . "</motd>";
- }
- if (preg_match('/u/', $mode) || ($mode == "-all" || $mode == "-a" || $mode == null)) {
- $_output .= "<users>";
- //foreach ($user->_users_online() as $_user) {
- // $_output .= "<user name='" . $_user['name'] . "' level='" . $_user['level'] . "'></user>";
- //}
- $_output .= "</users></chat_info>";
- }
- return $_output;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement