From 13f42715e7998dcd941a79547fed203131ba6f9c Mon Sep 17 00:00:00 2001
From: josch
Date: Wed, 10 Oct 2007 18:36:12 +0000
Subject: [PATCH] initial uploading capabilities
git-svn-id: http://yolanda.mister-muffin.de/svn@16 7eef14d0-6ed0-489d-bf55-20463b2d70db
---
trunk/include.pl | 2 +-
trunk/login.pl | 3 +--
trunk/register.pl | 2 +-
trunk/upload.pl | 22 ++++++++++++++++++++++
trunk/uploader.pl | 30 ++++++++++++++++++++++++++++++
trunk/xsl/xhtml.xsl | 2 +-
6 files changed, 56 insertions(+), 5 deletions(-)
create mode 100644 trunk/upload.pl
create mode 100644 trunk/uploader.pl
diff --git a/trunk/include.pl b/trunk/include.pl
index f0e9739..b19d114 100644
--- a/trunk/include.pl
+++ b/trunk/include.pl
@@ -1,5 +1,5 @@
+use CGI qw(:standard);
use CGI::Session;
-use CGI;
use DBI;
use XML::Simple qw(:strict);
diff --git a/trunk/login.pl b/trunk/login.pl
index 38710f0..32a1330 100644
--- a/trunk/login.pl
+++ b/trunk/login.pl
@@ -1,8 +1,8 @@
require "/var/www/perl/include.pl";
CGI::Session->name($session_name);
-$session = new CGI::Session;
$query = new CGI;
+$session = new CGI::Session;
if($query->param('action')) {
$dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass);
@@ -49,5 +49,4 @@ if($query->param('action')) {
';
- print STDIN;
}
diff --git a/trunk/register.pl b/trunk/register.pl
index 4194b81..31df645 100644
--- a/trunk/register.pl
+++ b/trunk/register.pl
@@ -1,8 +1,8 @@
require "/var/www/perl/include.pl";
CGI::Session->name($session_name);
-$session = new CGI::Session;
$query = new CGI;
+$session = new CGI::Session;
if($query->param('user') and $query->param('pass')) {
$dbh = DBI->connect("DBI:mysql:$database:$host", $dbuser, $dbpass);
diff --git a/trunk/upload.pl b/trunk/upload.pl
new file mode 100644
index 0000000..41d53f0
--- /dev/null
+++ b/trunk/upload.pl
@@ -0,0 +1,22 @@
+require "/var/www/perl/include.pl";
+require "/var/www/perl/functions.pl";
+
+#create or resume session
+CGI::Session->name($session_name);
+my $session = new CGI::Session;
+
+my $username = get_username_from_sid($session->id);
+
+if($username) {
+ print $session->header();
+ print '';
+} else {
+ print $session->header();
+ print "nope...";
+}
diff --git a/trunk/uploader.pl b/trunk/uploader.pl
new file mode 100644
index 0000000..b2a6a02
--- /dev/null
+++ b/trunk/uploader.pl
@@ -0,0 +1,30 @@
+require "/var/www/perl/include.pl";
+require "/var/www/perl/functions.pl";
+
+CGI::Session->name($session_name);
+$query = CGI->new(\&hook);
+$session = new CGI::Session;
+#$query = new CGI;
+
+sub hook {
+ my ($filename, $buffer, $bytes_read, $data) = @_;
+ open(TEMP, ">/var/www/perl/temp.temp") or die "cannot open";
+ print TEMP "Read $bytes_read bytes of $filename\n";
+ close TEMP;
+}
+
+my $username = get_username_from_sid($session->id);
+
+if($username) {
+ my $filename = $query->param("file");
+ my $title = $query->param("title");
+ $upload_filehandle = $query->upload("file");
+ print $session->header();
+ while ( <$upload_filehandle> )
+ {
+ print;
+ }
+} else {
+ print $session->header();
+ print "nope...";
+}
diff --git a/trunk/xsl/xhtml.xsl b/trunk/xsl/xhtml.xsl
index cca8cf9..d6bf83a 100755
--- a/trunk/xsl/xhtml.xsl
+++ b/trunk/xsl/xhtml.xsl
@@ -73,7 +73,7 @@