syntax cleaenup

git-svn-id: http://yolanda.mister-muffin.de/svn@29 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2007-10-11 17:26:39 +00:00
parent ba33884b1a
commit 14b3f68a73
6 changed files with 53 additions and 26 deletions

View file

@ -2,7 +2,8 @@
require "include.pl";
#get tags from database and fill $page with xml
sub fill_tagcloud {
sub fill_tagcloud
{
#connect to db
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
sub get_username_from_sid {
sub get_username_from_sid
{
#get parameters
my ($sid) = @_;
@ -54,7 +56,8 @@ sub get_username_from_sid {
}
#return a username from passed session id
sub get_userid_from_sid {
sub get_userid_from_sid
{
#get parameters
my ($sid) = @_;

View file

@ -7,12 +7,14 @@ $query = new CGI;
$session = new CGI::Session;
#check if action is set
if($query->param('action')) {
if($query->param('action'))
{
#connect to db
$dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass);
#if login is requested
if($query->param('action') eq "login") {
if($query->param('action') eq "login")
{
#save POST data in local variables
my $user = $query->param('user');
my $pass = $query->param('pass');
@ -27,7 +29,8 @@ if($query->param('action')) {
$sth->execute();
#if something was returned username and password match
if($sth->fetchrow_array()) {
if($sth->fetchrow_array())
{
#store session id in local variable
my $sid = $session->id;
@ -37,13 +40,17 @@ if($query->param('action')) {
$sth->finish();
print $session->header();
print "logged in";
} else {
}
else
{
#if not, print error
print $session->header();
print "could not log you in";
}
} elsif($query->param('action') eq "logout") {
}
elsif($query->param('action') eq "logout")
{
#if logout is requested
#remove sid from database
$sth = $dbh->prepare(qq{update users set sid = '' where username = '$user'});
@ -52,7 +59,9 @@ if($query->param('action')) {
$session->delete();
print $session->header();
print "logged out";
} else {
}
else
{
#something ugly was passed
print $session->header();
print "wtf?";
@ -60,7 +69,9 @@ if($query->param('action')) {
#disconnect db
$dbh->disconnect();
} else {
}
else
{
#print login form
print $session->header();
print '<form action="" method="POST"><p>

View file

@ -7,7 +7,8 @@ $query = new CGI;
$session = new CGI::Session;
#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
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 $session->header();
print "done";
} else {
}
else
{
#if not, print register form
print $session->header();
print '<form action="" method="POST"><p>

View file

@ -7,7 +7,8 @@ $query = new CGI;
$session = new CGI::Session;
#check if query is set
if($query->param('query')) {
if($query->param('query'))
{
my $search_query = $query->param('query');
$page = XMLin('$gnutube_root/search.xml', ForceArray => 1, KeyAttr => {} );
@ -32,17 +33,17 @@ if($query->param('query')) {
#really obfuscated array/hash creation
push @{ $page->{'results'}->{'result'} },
{
'thumbnail' => ['./video-stills/225x150/4chan_city_mashup.png'],
'rdf:RDF' =>
'thumbnail' => ['./video-stills/225x150/4chan_city_mashup.png'],
'rdf:RDF' =>
{
'cc:Work' =>
'cc:Work' =>
{
'rdf:about' => './videos/1050x700/4chan_city_mashup.ogg',
'dc:title' => [$title]
'rdf:about' => './videos/1050x700/4chan_city_mashup.ogg',
'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 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 "no query passed";
}

View file

@ -8,7 +8,8 @@ my $session = new CGI::Session;
my $username = get_username_from_sid($session->id);
if($username) {
if($username)
{
print $session->header();
print '<form action="uploader.pl" method="post" enctype="multipart/form-data">
Upload: <input type="file" name="file">
@ -17,7 +18,9 @@ Title: <input type="text" name="title">
<br><br>
<input type="submit" name="submit" value=" upload ">
</form>';
} else {
}
else
{
print $session->header();
print "nope...";
}

View file

@ -6,7 +6,8 @@ CGI::Session->name($session_name);
$query = CGI->new(\&hook);
$session = new CGI::Session;
sub hook {
sub hook
{
#this is going to become an ajax progress bar
my ($filename, $buffer, $bytes_read, $data) = @_;
#print $ENV{'CONTENT_LENGTH'};
@ -18,7 +19,8 @@ sub hook {
my $userid = get_userid_from_sid($session->id);
if($userid) {
if($userid)
{
#connect to db
my $dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass) or die $dbh->errstr;
@ -62,7 +64,9 @@ if($userid) {
#disconnect db
$dbh->disconnect() or die $dbh->errstr;
} else {
}
else
{
print $session->header();
print "nope...";
}