Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #21 from SyntaxC4/master

Updates to the PHP Sample
  • Loading branch information...
commit e5d2000f2c3d7d54257636e00a867b8b90408b1f 2 parents 3aa0472 + 4030581
@fmarier fmarier authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 php/persona.php
View
14 php/persona.php
@@ -14,26 +14,26 @@
print_header();
echo "<p>Logged in as: " . $result->email . "</p>";
echo '<p><a href="javascript:navigator.id.logout()">Logout</a></p>';
- echo "<p><a href=\"persona.php\">Back to login page</p>";
+ print_backLink();
print_footer($result->email);
} else {
// Login-attempt not successful
print_header();
echo "<p>Error: " . $result->reason . "</p>";
// Note that the explanation is technical and not user friendly
- echo "<p><a href=\"persona.php\">Back to login page</p>";
+ print_backLink();
print_footer();
}
} elseif (!empty($_GET['logout'])) {
// Logout request submitted
print_header();
echo "<p>You have logged out.</p>";
- echo "<p><a href=\"persona.php\">Back to login page</p>";
+ print_backLink();
print_footer();
} else {
// The state of the page
print_header();
- echo "<p><a href=\"javascript:navigator.id.request()\">Login</a>";
+ echo "<p><a href=\"javascript:navigator.id.request()\">Login</a></p>";
print_footer();
}
@@ -48,6 +48,10 @@ function print_header() {
EOF;
}
+function print_backLink() {
+ echo "<p><a href=\"persona.php\">Back to login page</a></p>";
+}
+
function print_footer($email = 'null') {
if ($email !== 'null') {
$email = "'$email'";
@@ -79,7 +83,7 @@ function print_footer($email = 'null') {
* @return object
*/
function verify_assertion($assertion) {
- $audience = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'];
+ $audience = ($_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'];
$postdata = 'assertion=' . urlencode($assertion) . '&audience=' . urlencode($audience);
$ch = curl_init();
Please sign in to comment.
Something went wrong with that request. Please try again.