mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-26 06:39:56 +09:00
17515512: JanRain php-openid library included, normalization fix
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5137 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
f541dd59b9
commit
658c0e6dbc
219 changed files with 41415 additions and 10 deletions
112
modules/member/php-openid-1.2.3/examples/server/lib/render.php
Normal file
112
modules/member/php-openid-1.2.3/examples/server/lib/render.php
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
define('page_template',
|
||||
'<html>
|
||||
<head>
|
||||
<title>%s</title>
|
||||
%s
|
||||
</head>
|
||||
<body>
|
||||
%s
|
||||
<div id="content">
|
||||
<h1>%s</h1>
|
||||
%s
|
||||
</div>
|
||||
</body>
|
||||
</html>');
|
||||
|
||||
define('logged_in_pat', 'You are logged in as %s.');
|
||||
|
||||
/**
|
||||
* HTTP response line contstants
|
||||
*/
|
||||
define('http_bad_request', 'HTTP/1.1 400 Bad Request');
|
||||
define('http_found', 'HTTP/1.1 302 Found');
|
||||
define('http_ok', 'HTTP/1.1 200 OK');
|
||||
define('http_internal_error', 'HTTP/1.1 500 Internal Error');
|
||||
|
||||
/**
|
||||
* HTTP header constants
|
||||
*/
|
||||
define('header_connection_close', 'Connection: close');
|
||||
define('header_content_text', 'Content-Type: text/plain; charset=us-ascii');
|
||||
|
||||
define('redirect_message',
|
||||
'Please wait; you are being redirected to <%s>');
|
||||
|
||||
|
||||
/**
|
||||
* Return a string containing an anchor tag containing the given URL
|
||||
*
|
||||
* The URL does not need to be quoted, but if text is passed in, then
|
||||
* it does.
|
||||
*/
|
||||
function link_render($url, $text=null) {
|
||||
$esc_url = htmlspecialchars($url, ENT_QUOTES);
|
||||
$text = ($text === null) ? $esc_url : $text;
|
||||
return sprintf('<a href="%s">%s</a>', $esc_url, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an HTTP redirect response
|
||||
*/
|
||||
function redirect_render($redir_url)
|
||||
{
|
||||
$headers = array(http_found,
|
||||
header_content_text,
|
||||
header_connection_close,
|
||||
'Location: ' . $redir_url,
|
||||
);
|
||||
$body = sprintf(redirect_message, $redir_url);
|
||||
return array($headers, $body);
|
||||
}
|
||||
|
||||
function navigation_render($msg, $items)
|
||||
{
|
||||
$what = link_render(buildURL(), 'PHP OpenID Server');
|
||||
if ($msg) {
|
||||
$what .= ' — ' . $msg;
|
||||
}
|
||||
if ($items) {
|
||||
$s = '<p>' . $what . '</p><ul class="bottom">';
|
||||
foreach ($items as $action => $text) {
|
||||
$url = buildURL($action);
|
||||
$s .= sprintf('<li>%s</li>', link_render($url, $text));
|
||||
}
|
||||
$s .= '</ul>';
|
||||
} else {
|
||||
$s = '<p class="bottom">' . $what . '</p>';
|
||||
}
|
||||
return sprintf('<div class="navigation">%s</div>', $s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an HTML page
|
||||
*/
|
||||
function page_render($body, $user, $title, $h1=null, $login=false)
|
||||
{
|
||||
$h1 = $h1 ? $h1 : $title;
|
||||
|
||||
if ($user) {
|
||||
$msg = sprintf(logged_in_pat, link_render($user));
|
||||
$nav = array('logout' => 'Log Out',
|
||||
'sites' => 'Remembered Sites',
|
||||
);
|
||||
$navigation = navigation_render($msg, $nav);
|
||||
} else {
|
||||
if (!$login) {
|
||||
$msg = link_render(buildURL('login'), 'Log In');
|
||||
$navigation = navigation_render($msg, array());
|
||||
} else {
|
||||
$navigation = '';
|
||||
}
|
||||
}
|
||||
|
||||
$style = getStyle();
|
||||
$text = sprintf(page_template, $title, $style, $navigation, $h1, $body);
|
||||
// No special headers here
|
||||
$headers = array();
|
||||
return array($headers, $text);
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue