/** * Ajax Callback * * @access public * @return void */ function sc_chat_ajax_callback() { $response = array(); try { // Handling the supported actions: switch ($_GET['mode']) { case 'login': $response = Chat::login(@$_POST['f_chat_user_name'], @$_POST['f_chat_user_email'], $_POST['f_chat_is_admin']); break; case 'send_contact_from': $response = Chat::send_contact_from($_POST); break; case 'is_user_logged_in': $response = Chat::is_user_logged_in(); break; case 'logout': $response = Chat::logout(); break; case 'online': $response = Chat::online(); break; case 'offline': $response = Chat::offline(); break; case 'send_chat_msg': $response = Chat::send_chat_msg($_POST); break; case 'get_online_users': $response = Chat::get_online_users(); break; case 'get_chat_lines': $response = Chat::get_chat_lines($_GET['last_log_ID'], $_GET['sender']); break; case 'user_info': $response = Chat::user_info($_GET['ID']); break; default: throw new Exception('Wrong action'); } } catch (Exception $e) { $response['error'] = $e->getMessage(); } // Response output header("Content-Type: application/json"); echo json_encode($response); exit; }