syntax cleaenup
git-svn-id: http://yolanda.mister-muffin.de/svn@29 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
ba33884b1a
commit
14b3f68a73
6 changed files with 53 additions and 26 deletions
|
@ -2,7 +2,8 @@
|
||||||
require "include.pl";
|
require "include.pl";
|
||||||
|
|
||||||
#get tags from database and fill $page with xml
|
#get tags from database and fill $page with xml
|
||||||
sub fill_tagcloud {
|
sub fill_tagcloud
|
||||||
|
{
|
||||||
#connect to db
|
#connect to db
|
||||||
my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr;
|
my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr;
|
||||||
|
|
||||||
|
@ -27,7 +28,8 @@ sub fill_tagcloud {
|
||||||
}
|
}
|
||||||
|
|
||||||
#return a username from passed session id
|
#return a username from passed session id
|
||||||
sub get_username_from_sid {
|
sub get_username_from_sid
|
||||||
|
{
|
||||||
#get parameters
|
#get parameters
|
||||||
my ($sid) = @_;
|
my ($sid) = @_;
|
||||||
|
|
||||||
|
@ -54,7 +56,8 @@ sub get_username_from_sid {
|
||||||
}
|
}
|
||||||
|
|
||||||
#return a username from passed session id
|
#return a username from passed session id
|
||||||
sub get_userid_from_sid {
|
sub get_userid_from_sid
|
||||||
|
{
|
||||||
#get parameters
|
#get parameters
|
||||||
my ($sid) = @_;
|
my ($sid) = @_;
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,14 @@ $query = new CGI;
|
||||||
$session = new CGI::Session;
|
$session = new CGI::Session;
|
||||||
|
|
||||||
#check if action is set
|
#check if action is set
|
||||||
if($query->param('action')) {
|
if($query->param('action'))
|
||||||
|
{
|
||||||
#connect to db
|
#connect to db
|
||||||
$dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass);
|
$dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass);
|
||||||
|
|
||||||
#if login is requested
|
#if login is requested
|
||||||
if($query->param('action') eq "login") {
|
if($query->param('action') eq "login")
|
||||||
|
{
|
||||||
#save POST data in local variables
|
#save POST data in local variables
|
||||||
my $user = $query->param('user');
|
my $user = $query->param('user');
|
||||||
my $pass = $query->param('pass');
|
my $pass = $query->param('pass');
|
||||||
|
@ -27,7 +29,8 @@ if($query->param('action')) {
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
|
|
||||||
#if something was returned username and password match
|
#if something was returned username and password match
|
||||||
if($sth->fetchrow_array()) {
|
if($sth->fetchrow_array())
|
||||||
|
{
|
||||||
#store session id in local variable
|
#store session id in local variable
|
||||||
my $sid = $session->id;
|
my $sid = $session->id;
|
||||||
|
|
||||||
|
@ -37,13 +40,17 @@ if($query->param('action')) {
|
||||||
$sth->finish();
|
$sth->finish();
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print "logged in";
|
print "logged in";
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#if not, print error
|
#if not, print error
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print "could not log you in";
|
print "could not log you in";
|
||||||
}
|
}
|
||||||
|
|
||||||
} elsif($query->param('action') eq "logout") {
|
}
|
||||||
|
elsif($query->param('action') eq "logout")
|
||||||
|
{
|
||||||
#if logout is requested
|
#if logout is requested
|
||||||
#remove sid from database
|
#remove sid from database
|
||||||
$sth = $dbh->prepare(qq{update users set sid = '' where username = '$user'});
|
$sth = $dbh->prepare(qq{update users set sid = '' where username = '$user'});
|
||||||
|
@ -52,7 +59,9 @@ if($query->param('action')) {
|
||||||
$session->delete();
|
$session->delete();
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print "logged out";
|
print "logged out";
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#something ugly was passed
|
#something ugly was passed
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print "wtf?";
|
print "wtf?";
|
||||||
|
@ -60,7 +69,9 @@ if($query->param('action')) {
|
||||||
|
|
||||||
#disconnect db
|
#disconnect db
|
||||||
$dbh->disconnect();
|
$dbh->disconnect();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#print login form
|
#print login form
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print '<form action="" method="POST"><p>
|
print '<form action="" method="POST"><p>
|
||||||
|
|
|
@ -7,7 +7,8 @@ $query = new CGI;
|
||||||
$session = new CGI::Session;
|
$session = new CGI::Session;
|
||||||
|
|
||||||
#if username and password are passed put them into the database
|
#if username and password are passed put them into the database
|
||||||
if($query->param('user') and $query->param('pass')) {
|
if($query->param('user') and $query->param('pass'))
|
||||||
|
{
|
||||||
#connect to db
|
#connect to db
|
||||||
my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr;
|
my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr;
|
||||||
|
|
||||||
|
@ -24,7 +25,9 @@ if($query->param('user') and $query->param('pass')) {
|
||||||
#print a little confirmation
|
#print a little confirmation
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print "done";
|
print "done";
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#if not, print register form
|
#if not, print register form
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print '<form action="" method="POST"><p>
|
print '<form action="" method="POST"><p>
|
||||||
|
|
|
@ -7,7 +7,8 @@ $query = new CGI;
|
||||||
$session = new CGI::Session;
|
$session = new CGI::Session;
|
||||||
|
|
||||||
#check if query is set
|
#check if query is set
|
||||||
if($query->param('query')) {
|
if($query->param('query'))
|
||||||
|
{
|
||||||
my $search_query = $query->param('query');
|
my $search_query = $query->param('query');
|
||||||
|
|
||||||
$page = XMLin('$gnutube_root/search.xml', ForceArray => 1, KeyAttr => {} );
|
$page = XMLin('$gnutube_root/search.xml', ForceArray => 1, KeyAttr => {} );
|
||||||
|
@ -32,17 +33,17 @@ if($query->param('query')) {
|
||||||
#really obfuscated array/hash creation
|
#really obfuscated array/hash creation
|
||||||
push @{ $page->{'results'}->{'result'} },
|
push @{ $page->{'results'}->{'result'} },
|
||||||
{
|
{
|
||||||
'thumbnail' => ['./video-stills/225x150/4chan_city_mashup.png'],
|
'thumbnail' => ['./video-stills/225x150/4chan_city_mashup.png'],
|
||||||
'rdf:RDF' =>
|
'rdf:RDF' =>
|
||||||
{
|
{
|
||||||
'cc:Work' =>
|
'cc:Work' =>
|
||||||
{
|
{
|
||||||
'rdf:about' => './videos/1050x700/4chan_city_mashup.ogg',
|
'rdf:about' => './videos/1050x700/4chan_city_mashup.ogg',
|
||||||
'dc:title' => [$title]
|
'dc:title' => [$title]
|
||||||
},
|
},
|
||||||
'cc:License' =>
|
'cc:License' =>
|
||||||
{
|
{
|
||||||
'rdf:about' => 'http://creativecommons.org/licenses/GPL/2.0/'
|
'rdf:about' => 'http://creativecommons.org/licenses/GPL/2.0/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -59,7 +60,9 @@ if($query->param('query')) {
|
||||||
|
|
||||||
#print xml
|
#print xml
|
||||||
print XMLout($page, KeyAttr => {}, XMLDecl => '<?xml version="1.0" encoding="ISO-8859-1" ?><?xml-stylesheet type="text/xsl" href="./xsl/xhtml.xsl" ?>', RootName => 'page');
|
print XMLout($page, KeyAttr => {}, XMLDecl => '<?xml version="1.0" encoding="ISO-8859-1" ?><?xml-stylesheet type="text/xsl" href="./xsl/xhtml.xsl" ?>', RootName => 'page');
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print "no query passed";
|
print "no query passed";
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@ my $session = new CGI::Session;
|
||||||
|
|
||||||
my $username = get_username_from_sid($session->id);
|
my $username = get_username_from_sid($session->id);
|
||||||
|
|
||||||
if($username) {
|
if($username)
|
||||||
|
{
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print '<form action="uploader.pl" method="post" enctype="multipart/form-data">
|
print '<form action="uploader.pl" method="post" enctype="multipart/form-data">
|
||||||
Upload: <input type="file" name="file">
|
Upload: <input type="file" name="file">
|
||||||
|
@ -17,7 +18,9 @@ Title: <input type="text" name="title">
|
||||||
<br><br>
|
<br><br>
|
||||||
<input type="submit" name="submit" value=" upload ">
|
<input type="submit" name="submit" value=" upload ">
|
||||||
</form>';
|
</form>';
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print "nope...";
|
print "nope...";
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ CGI::Session->name($session_name);
|
||||||
$query = CGI->new(\&hook);
|
$query = CGI->new(\&hook);
|
||||||
$session = new CGI::Session;
|
$session = new CGI::Session;
|
||||||
|
|
||||||
sub hook {
|
sub hook
|
||||||
|
{
|
||||||
#this is going to become an ajax progress bar
|
#this is going to become an ajax progress bar
|
||||||
my ($filename, $buffer, $bytes_read, $data) = @_;
|
my ($filename, $buffer, $bytes_read, $data) = @_;
|
||||||
#print $ENV{'CONTENT_LENGTH'};
|
#print $ENV{'CONTENT_LENGTH'};
|
||||||
|
@ -18,7 +19,8 @@ sub hook {
|
||||||
|
|
||||||
my $userid = get_userid_from_sid($session->id);
|
my $userid = get_userid_from_sid($session->id);
|
||||||
|
|
||||||
if($userid) {
|
if($userid)
|
||||||
|
{
|
||||||
#connect to db
|
#connect to db
|
||||||
my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr;
|
my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr;
|
||||||
|
|
||||||
|
@ -62,7 +64,9 @@ if($userid) {
|
||||||
|
|
||||||
#disconnect db
|
#disconnect db
|
||||||
$dbh->disconnect() or die $dbh->errstr;
|
$dbh->disconnect() or die $dbh->errstr;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print $session->header();
|
print $session->header();
|
||||||
print "nope...";
|
print "nope...";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue