Ejemplo n.º 1
0
    // Connecting to the database
    DB::init($dbOptions);
    $response = array();
    // Handling the supported actions:
    switch ($_GET['action']) {
        case 'login':
            $response = Chat::login($_POST['name'], $_POST['email']);
            break;
        case 'checkLogged':
            $response = Chat::checkLogged();
            break;
        case 'logout':
            $response = Chat::logout();
            break;
        case 'submitChat':
            $response = Chat::submitChat($_POST['chatText']);
            break;
        case 'getUsers':
            $response = Chat::getUsers();
            break;
        case 'getChats':
            $response = Chat::getChats($_GET['lastID']);
            break;
        default:
            throw new Exception('Wrong action');
    }
    echo json_encode($response);
} catch (Exception $e) {
    die(json_encode(array('error' => $e->getMessage())));
}
?>
Ejemplo n.º 2
0
Archivo: ajax.php Proyecto: kardi31/ogl
 // Connecting to the database
 DB::init($dbOptions);
 $response = array();
 // Handling the supported actions:
 switch ($_GET['action']) {
     case 'login':
         $response = Chat::login($_POST['name'], $_POST['email'], $_POST['user']);
         break;
     case 'checkLogged':
         $response = Chat::checkLogged();
         break;
     case 'logout':
         $response = Chat::logout();
         break;
     case 'submitChat':
         $response = Chat::submitChat($_POST['chatText'], $_POST['room'], $_POST['room_od']);
         break;
     case 'getUsers':
         $response = Chat::getUsers();
         break;
     case 'getChats':
         $response = Chat::getChats($_GET['lastID'], $_GET['room'], $_GET['room_od']);
         break;
     default:
         throw new Exception('Error');
 }
 if ($_GET['action'] == "getChats") {
     echo emot(json_encode($response));
 } else {
     echo json_encode($response);
 }