initial commit of file from CVS for smeserver-userpanel on Sat Sep 7 21:12:39 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 21:12:39 +10:00
parent d369a6eb72
commit 537335bf32
24 changed files with 3616 additions and 2 deletions

View File

@@ -0,0 +1,128 @@
#!/usr/bin/perl -w
#
# mod_auth_tkt sample logout script
#
# Note that this needs script needs to be available locally on all domains
# if using multiple domains (unlike login.cgi, which only needs to exist
# on one domain).
#
use File::Basename;
use lib dirname($ENV{SCRIPT_FILENAME});
use Apache::AuthTkt 0.03;
use CGI qw(:standard);
use URI::Escape;
use URI;
use strict;
# ------------------------------------------------------------------------
# Configure this section to taste
# CSS stylesheet to use (optional)
my $STYLESHEET = '/server-common/css/tkt.css';
# Page title (optional)
my $TITLE = '';
# Boolean flag, whether to fallback to HTTP_REFERER for back link
my $BACK_REFERER = 1;
# Additional cookies to clear on logout e.g. PHPSESSID
my @NUKE_COOKIES = qw();
# ------------------------------------------------------------------------
# Main code begins
my $debug = 0;
my $at = Apache::AuthTkt->new(conf => "/etc/e-smith/web/common/cgi-bin/AuthTKT.cfg");
my $q = CGI->new;
my ($server_name, $server_port) = split /:/, $q->http('X-Forwarded-Host') || $ENV{HTTP_HOST};
#warn "servername is $server_name; HOST is $ENV{HTTP_HOST}\n";
$server_name ||= $ENV{SERVER_NAME};
$server_port ||= $ENV{SERVER_PORT};
$server_port = '443';
my $AUTH_DOMAIN = $server_name;
my $back = $q->cookie($at->back_cookie_name) if $at->back_cookie_name;
$back ||= $q->param($at->back_arg_name) if $at->back_arg_name;
$back ||= $ENV{HTTP_REFERER} if $BACK_REFERER;
$back = "/user-manager/";
if ($back && $back =~ m!^/!) {
my $hostname = $server_name;
my $port = $server_port;
$hostname .= ':' . $port if $port && $port != 80 && $port != 443;
$back = sprintf "http%s://%s%s", ($port == 443 ? 's' : ''), $hostname, $back;
} elsif ($back && $back !~ m/^http/i) {
$back = 'http://' . $back;
}
$back = uri_unescape($back) if $back =~ m/^https?%3A%2F%2F/;
my $back_html = escapeHTML($back) if $back;
# Logout by resetting the auth cookie
my @cookies = cookie(-name => $at->cookie_name, -value => '', -expires => '-1h',
($AUTH_DOMAIN && $AUTH_DOMAIN =~ /\./ ? (-domain => $AUTH_DOMAIN) : ()));
push @cookies, map { cookie(-name => $_, -value => '', -expires => '-1h') } @NUKE_COOKIES;
my $redirected = 0;
if ($back) {
my $b = URI->new($back);
# If $back domain doesn't match $AUTH_DOMAIN, add ticket reset to back
if ($b->host !~ m/\b$AUTH_DOMAIN$/i) {
$back .= $b->query ? '&' : '?';
$back .= $at->cookie_name . '=';
}
if ($debug) {
print $q->header(-cookie => \@cookies);
}
else {
# Set (local) cookie, and redirect to $back
print $q->header(
-cookie => \@cookies,
# -location => $back,
);
# For some reason, a Location: redirect doesn't seem to then see the cookie,
# but a meta refresh one does - weird
print $q->start_html(
-head => meta({
-http_equiv => 'refresh', -content => "0;URL=$back"
}));
$redirected = 1;
}
}
# If no $back, just set the auth cookie and hope for the best
else {
print $q->header(-cookie => \@cookies);
}
my @style = $STYLESHEET ? ('-style' => { src => $STYLESHEET }) : ();
$TITLE ||= 'Logout Page';
unless ($redirected) {
# If here, either some kind of error or no back ref found
print $q->start_html(
-title => $TITLE,
@style,
);
print <<EOD;
<div align="center">
<h1>$TITLE</h1>
EOD
if ($debug) {
print <<EOD;
<pre>
back: $back
back_html: $back_html
</pre>
EOD
}
print <<EOD;
<p>You are now logged out.</p>
EOD
print qq(<p><a href="$back_html">Return to server manager login</a></p>\n) if $back_html;
print <<EOD;
</div>
</body>
</html>
EOD
}
# arch-tag: 09c96fc6-5119-4c79-8086-6c6b24951f96
# vim:sw=2:sm:cin

View File

@@ -0,0 +1,310 @@
/*------------------------------------------------------------
* Default properties
*------------------------------------------------------------*/
body
{
background: #ffffff;
color: #000000;
font-family: verdana,arial,helvetica,sans-serif;
font-size: 10pt;
border-width: 0
}
/* Netscape 4 needs these basic settings in order to render default font properly */
p
{
color: #000000;
font-family: verdana,arial,helvetica,sans-serif;
}
table td
{
color: #000000;
font-family: verdana,arial,helvetica,sans-serif;
font-size: 10pt;
}
td {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 10pt;
}
table td div {
background: transparent;
font-size: 10pt;
}
p.notsmall {
font-size: 10pt;
}
/* End Netscape-isms (for the moment <sigh>) */
.centerit
{
text-align: center;
}
div
{
margin-top: 10px;
margin-bottom: 10px;
}
.highlight
{
background: #ffc61e;
}
.subheading
{
background: #ffffff;
color: #1e385b;
}
/*------------------------------------------------------------
* Properties for headings
*------------------------------------------------------------*/
h1
{
font-family: verdana,helvetica,arial,sans-serif;
color: #000099
}
h2
{
font-family: verdana,helvetica,arial,sans-serif;
color: #000099
}
h3
{
font-family: verdana,helvetica,arial,sans-serif;
color: #000099
}
h4
{
font-family: verdana,helvetica,arial,sans-serif;
font-style: italic
}
/*------------------------------------------------------------
* Properties for lists
*------------------------------------------------------------*/
ul
{
font-family: arial,helvetica,sans-serif;
list-style-type: square;
}
ol {
font-family: arial,helvetica,sans-serif;
font-size: 80%;
color: #1e385b;
}
/*------------------------------------------------------------
* Properties for list items
*------------------------------------------------------------*/
ol ul li
{
font-family: arial,helvetica,sans-serif;
font-size: 80%;
font-weight: normal;
color: #000000;
}
/*------------------------------------------------------------
* Properties for tables
*------------------------------------------------------------*/
/* Removed -- see default table font above... */
/* td
{
font-family: Times
}
*/
table
{
margin-top: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
}
/* left margin and center [sic] table classes */
.banner
{
background: #000000;
color: #ffffff;
}
.banner-right
{
font-family: arial,helvetica,sans-serif;
background: #e17200;
color: #ffffff;
}
.border
{
background: #000000;
color: #000000;
border-color: #000000;
}
.sidebar
{
width: 200px;
background: #ffffff;
font-size: smaller;
font: arial,helvetica,sans-serif;
font-weight: normal;
}
.sidebar-title
{
background: #1e385b;
color: #ffffff;
font: arial,helvetica,sans-serif;
font-weight: bold;
}
.newsitem
{
background: #ffffff;
font-color: #000000;
font: arial,helvetica,sans-serif;
margin-left: 5px;
margin-right: 5px;
margin-top: 5px;
margin-bottom: 5px;
}
.newsitem-title
{
background: #cccccc;
font-color: #ffffff;
font: arial,helvetica,sans-serif;
font-weight: bold;
}
.newsitem-footer
{
background: #cccccc;
color: #000000;
font: arial,helvetica,sans-serif;
font-size: smaller;
text-align: right;
}
.newsitem-detail
{
font-size: smaller;
font-weight: normal;
}
.formlabel
{
background: #c0c0c0;
color: #000000;
font: arial,helvetica,sans-serif;
font-size: small;
font-weight: bold;
text-align: right;
}
/*------------------------------------------------------------
* Properties for title tables
*------------------------------------------------------------*/
th
{
/* font-family: Helvetica,Arial; */
background: #F7E0B5;
color: #000000
}
/*------------------------------------------------------------
* Properties for the copyright notice on the bottom
*------------------------------------------------------------*/
.copyright
{
font-family: Times;
font-size: smaller
}
/*------------------------------------------------------------
* Properties for the clickable links
*------------------------------------------------------------*/
/* Netscape 4 can't use these. Default ANCHOR setting follows... */
a:link, A:visited, A:active
{
color: #00008b
}
a
{
color: #00008b;
}
/* link styles for index.php3 (i.e. welcome page) */
.welcome-link
{
background: #ffffff;
color: #1e385b;
}
/*------------------------------------------------------------
* Properties for the littlelinks
*------------------------------------------------------------*/
.littlelink
{
font-family: helvetica,arial,sans-serif;
}
/*------------------------------------------------------------
* Style for positioning text
*------------------------------------------------------------*/
#textlayer
{
position: absolute;
visibility: inherit;
top: 160px;
left: 50px;
z-index: 2
}
/*------------------------------------------------------------
* Style for bold paragraph text
*------------------------------------------------------------*/
#para
{
font-family: helvetica,arial,sans-serif;
font-weight: bold;
color: #000000
}
/*------------------------------------------------------------
*
*------------------------------------------------------------*/
#title
{
font-family: helvetica,arial,sans-serif;
font-weight: bold;
padding: 7px 7px 7px 7px;
color: #ffffff
}