. */ include_once __DIR__ . '/../database/database.php'; include_once __DIR__ . '/../objects/account.php'; include_once __DIR__ . '/../objects/password.php'; include_once __DIR__ . '/../objects/alias.php'; include_once __DIR__ . '/../objects/user_info.php'; include_once __DIR__ . '/../misc/utilities.php'; include_once __DIR__ . '/results_values.php'; // args = [username, ha1, [domain], [algo]] function xmlrpc_get_email_account($method, $args) { $username = $args[0]; $ha1 = $args[1]; $domain = get_domain($args[2]); $algo = get_algo($args[3]); Logger::getInstance()->message("[XMLRPC] xmlrpc_get_email_account(" . $username . ")"); $database = new Database(); $db = $database->getConnection(); $account = new Account($db); $account->username = $username; $account->domain = $domain; if (!$account->getOne()) { return ACCOUNT_NOT_FOUND; } $password = new Password($db); $password->account_id = $account->id; $password->algorithm = $algo; if (!$password->getOne()) { return PASSWORD_NOT_FOUND; } if (!password_match($ha1, $password->password)) { return PASSWORD_DOESNT_MATCH; } $user_info = new UserInfo($db); $user_info->account_id = $account->id; $result = array( "id" => $account->id, "username" => $account->username, "domain" => $account->domain, "email" => $account->email, "alias" => $account->alias, "activated" => $account->activated, "firstname" => $user_info->firstname, "lastname" => $user_info->lastname, "gender" => $user_info->gender, "subscribe" => $user_info->subscribe ); return $result; } // args = [tel, ha1, [domain], [algo]] function xmlrpc_get_phone_account($method, $args) { $phone = $args[0]; $ha1 = $args[1]; $domain = get_domain($args[2]); $algo = get_algo($args[3]); Logger::getInstance()->message("[XMLRPC] xmlrpc_get_phone_account(" . $phone . ")"); $database = new Database(); $db = $database->getConnection(); $alias = new Alias($db); $alias->alias = $phone; $alias->domain = $domain; $account = new Account($db); if (!$alias->getOne()) { $account->username = $phone; $account->domain = $domain; } else { $account->id = $alias->account_id; } if (!$account->getOne()) { return ACCOUNT_NOT_FOUND; } $password = new Password($db); $password->account_id = $account->id; $password->algorithm = $algo; if (!$password->getOne()) { return PASSWORD_NOT_FOUND; } if (!password_match($ha1, $password->password)) { return PASSWORD_DOESNT_MATCH; } $user_info = new UserInfo($db); $user_info->account_id = $account->id; $result = array( "id" => $account->id, "username" => $account->username, "domain" => $account->domain, "email" => $account->email, "alias" => $account->alias, "activated" => $account->activated, "firstname" => $user_info->firstname, "lastname" => $user_info->lastname, "gender" => $user_info->gender, "subscribe" => $user_info->subscribe ); return $result; } // args = [confirmation_key, [algo]] function xmlrpc_get_account_by_confirmation_key($method, $args) { $confirmation_key = $args[0]; $algo = get_algo($args[1]); Logger::getInstance()->message("[XMLRPC] xmlrpc_get_account_by_confirmation_key(" . $confirmation_key . ")"); $database = new Database(); $db = $database->getConnection(); $account = new Account($db); $account->confirmation_key = $confirmation_key; if (!$account->getOne()) { return ACCOUNT_NOT_FOUND; } $user_info = new UserInfo($db); $user_info->account_id = $account->id; $result = array( "id" => $account->id, "username" => $account->username, "domain" => $account->domain, "email" => $account->email, "alias" => $account->alias, "activated" => $account->activated, "firstname" => $user_info->firstname, "lastname" => $user_info->lastname, "gender" => $user_info->gender, "subscribe" => $user_info->subscribe ); return $result; } function xmlrpc_user_info_register_methods($server) { xmlrpc_server_register_method($server, 'get_email_account', 'xmlrpc_get_email_account'); // args = [username, ha1, [domain], [algo]] xmlrpc_server_register_method($server, 'get_phone_account', 'xmlrpc_get_phone_account'); // args = [tel, ha1, [domain], [algo]] xmlrpc_server_register_method($server, 'get_account_by_confirmation_key', 'xmlrpc_get_account_by_confirmation_key'); // args = [confirmation_key, [algo]] } ?>