From 1615c2888149b3cfb2da8a3c36246e9586d1ac83 Mon Sep 17 00:00:00 2001 From: josch Date: Wed, 10 Oct 2007 10:27:05 +0000 Subject: [PATCH] added basic login/logout git-svn-id: http://yolanda.mister-muffin.de/svn@10 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/include.pl | 2 ++ trunk/index.pl | 6 +----- trunk/login.pl | 26 ++++++++++++++++++++++++++ trunk/xsl/xhtml.xsl | 4 +++- 4 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 trunk/login.pl diff --git a/trunk/include.pl b/trunk/include.pl index 0e8bb5e..5418ed9 100644 --- a/trunk/include.pl +++ b/trunk/include.pl @@ -6,3 +6,5 @@ $database = 'gnutube'; $host = 'localhost'; $user = 'root'; $pass = ''; +$session_name = 'sid'; +1; diff --git a/trunk/index.pl b/trunk/index.pl index f0fb12e..8a061bf 100644 --- a/trunk/index.pl +++ b/trunk/index.pl @@ -1,14 +1,10 @@ -#!/usr/bin/perl require "/var/www/perl/include.pl"; require "/var/www/perl/functions.pl"; #create or resume session -CGI::Session->name("SID"); +CGI::Session->name($session_name); my $session = new CGI::Session; -#store session param -$session->param('auth', 'true'); - #read xml $page = XMLin('/var/www/perl/index.xml', ForceArray => 1, KeyAttr => {} ); diff --git a/trunk/login.pl b/trunk/login.pl new file mode 100644 index 0000000..7690174 --- /dev/null +++ b/trunk/login.pl @@ -0,0 +1,26 @@ +require "/var/www/perl/include.pl"; + +CGI::Session->name($session_name); +my $session = new CGI::Session; + +#fill %querystring with everything that was passed via GET +@parts = split( /\&/, $ENV{ "QUERY_STRING" } ); +foreach $part (@parts) { + ( $name, $value ) = split( /\=/, $part ); + $queryString{ $name } = $value; +} + +if($queryString{ "action" }) { + if($queryString{ "action" } eq "login") { + $session->param('auth', 'true'); + print $session->header(); + print "logged in"; + } elsif($queryString{ "action" } eq "logout") { + $session->param('auth', 'false'); + print $session->header(); + print "logged out"; + } +} else { + print $session->header(); + print "incorrect query string"; +} diff --git a/trunk/xsl/xhtml.xsl b/trunk/xsl/xhtml.xsl index 74956f4..5b261d8 100755 --- a/trunk/xsl/xhtml.xsl +++ b/trunk/xsl/xhtml.xsl @@ -65,7 +65,9 @@
- + + + open id logo