コード例 #1
0
ファイル: index.php プロジェクト: nethad/experiments
        $uri = getString($paramName, $from);
        if(!preg_match('|^[a-z0-9-]+\:\/\/[a-z0-9-]+(\.[a-z0-9-\/]+)*$|i', $uri)) {
                die("Parameter $paramName should be a valid uri");
        }
	return $uri;
}
function getUserAddress($paramName, $from) {
        $userAddress = strtolower(getString($paramName, $from));
        if(!preg_match('|^[a-z0-9-]+(\.[a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$|i', $userAddress)) {
                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">
コード例 #2
0
ファイル: do.php プロジェクト: nethad/experiments
{
    $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;