. */ include_once __DIR__ . '/../database/database.php'; include_once __DIR__ . '/../misc/utilities.php'; include_once __DIR__ . '/authentication.php'; include_once __DIR__ . '/accounts.php'; include_once __DIR__ . '/aliases.php'; include_once __DIR__ . '/devices.php'; include_once __DIR__ . '/passwords.php'; include_once __DIR__ . '/user_info.php'; $request = file_get_contents("php://input"); if (empty($request)) Logger::getInstance()->error("Request is empty"); $server = xmlrpc_server_create(); if (!$server) die("Couldn't create server"); if (USE_DIGEST_AUTH) { $headers = getallheaders(); $xml = simplexml_load_string($request); $request_type = $xml->methodName; $unauthenticated_requests = array( // email accounts 0 => 'create_email_account', 1 => 'create_email_md5_sha256_account', 2 => 'activate_email_account', 3 => 'recover_email_account', // phone accounts 4 => 'create_phone_account', 5 => 'activate_phone_account', 6 => 'recover_phone_account', 7 => 'is_phone_number_used', 8 => 'get_phone_number_for_account', // accounts 9 => 'get_confirmation_key', 10 => 'is_account_used', 11 => 'is_account_activated', 12 => 'recover_account_from_confirmation_key', 13 => 'get_accounts_count', // aliases 14 => 'is_alias_used', 15 => 'link_phone_number_with_account', 16 => 'get_alias', // devices 17 => 'add_ec_calibration_result', ); // Get authentication header if there is one if (!empty($headers['Auth-Digest'])) { Logger::getInstance()->debug("Auth-Digest = " . $headers['Auth-Digest']); $authorization = $headers['Auth-Digest']; } elseif (!empty($headers['Authorization'])) { Logger::getInstance()->debug("Authorization = " . $headers['Authorization']); $authorization = $headers['Authorization']; } // Authentication if (in_array($request_type, $unauthenticated_requests) == FALSE) { if (!empty($authorization)) { $authentication_status = authenticate(AUTH_REALM); if ($authentication_status == TRUE) { Logger::getInstance()->debug("Authentication successful for " . $headers['From']); } else { Logger::getInstance()->debug("Authentication failed for " . $headers['From']); request_authentication(AUTH_REALM); } } else { Logger::getInstance()->debug("No authentication header for " . $headers['From']); request_authentication(AUTH_REALM); } } } xmlrpc_accounts_register_methods($server); xmlrpc_aliases_register_methods($server); xmlrpc_devices_register_methods($server); xmlrpc_passwords_register_methods($server); xmlrpc_user_info_register_methods($server); if (USE_IN_APP_PURCHASES) { include_once __DIR__ . '/inapp.php'; xmlrpc_inapp_register_methods($server); } if (ALLOW_TEST_ACCOUNTS) { include_once __DIR__ . '/liblinphone_tester.php'; xmlrpc_liblinphone_tester_register_methods($server); } if ($request) { $options = array('output_type' => 'xml', 'version' => 'auto'); echo xmlrpc_server_call_method($server, $request, null, $options); } ?>