session_name('BLAM'); session_start(); if (get_magic_quotes_gpc()) { // If magic quotes is enabled, strip the extra slashes array_walk_recursive($_GET, create_function('&$v,$k', '$v = stripslashes($v);')); array_walk_recursive($_POST, create_function('&$v,$k', '$v = stripslashes($v);')); } try { // Connecting to the database DB::init($dbOptions); //response is an empty array $response = array(); // Handling the supported actions: switch ($_GET['action']) { case 'login': $response = BLAM::login($_POST['username'], $_POST['password']); // returns int Id, string Username, string Avatar, String Role or exception break; case 'checkLogged': $response = BLAM::checkLogged(); // returns int Id, string Username, string Avatar, String Role or exception break; case 'logout': $response = BLAM::logout(); // return null or exception break; case 'addMessage': BLAM::checkLogged(); $response = BLAM::addMessage($_POST['text'], $_POST['ticket'], $_POST['ticket_id']); // returns MessageId or exception break;