die("Parameter $paramName is '$userAddress' but should be a valid user address"); } return $userAddress; } if(count($_POST)) { $unhostedAccount = new UnhostedAccount(getUserAddress("user_address", $_POST), getString("pwd", $_POST)); $token = $unhostedAccount->addAPP(getDomain("scope", $_POST)); if($token) { header("Location:".getUri("redirect_uri", $_POST)."#access_token=".$token."&token_type=unhosted"); echo "redirecting you back to the application.\n"; } else { echo "Wrong password!"; } } else { $userAddress = getUserAddress('user_address', $_GET); $clientId = getDomain('client_id', $_GET); $dataScope = getDomain('scope', $_GET); $redirectUri = getUri('redirect_uri', $_GET); ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script src="/jQuery/jquery-1.6.1.min.js"></script> <script src="/css/html5.js"></script><!-- this is the javascript allowing html5 to run in older browsers --> <title>My Unhosted node</title> <link rel="stylesheet" href="/css/uncompressed/reset.css" /> <link rel="stylesheet" href="/css/uncompressed/text.css" />
{ $domain = strtolower(getString($paramName)); if (!preg_match('|^[a-z0-9-]+(\\.[a-z0-9-]+)*$|i', $domain)) { die("Parameter {$paramName} should be a valid domain"); } return $domain; } function getUserAddress($paramName) { $userAddress = strtolower(getString($paramName)); if (!preg_match('|^[a-z0-9-]+(\\.[a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*$|i', $userAddress)) { die("Parameter {$paramName} should be a valid user address"); } return $userAddress; } $unhostedAccount = new UnhostedAccount(getUserAddress("userAddress"), getString("pwd")); switch (getString("action")) { case "getWallet": $wallet = $unhostedAccount->getWallet(getDomain("dataScope"), getString("allowCreation") == "true"); if ($wallet === false) { header("HTTP/1.0 404 Not Found"); } else { echo $wallet; } break; case "registerLocal": echo $unhostedAccount->registerLocal(getDomain("dataScope")); break; case "addApp": echo $unhostedAccount->addApp(getDomain("dataScope")); break;