Leser: 2
|< 1 2 3 4 >| | 39 Einträge, 4 Seiten |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
#!/usr/bin/perl -w use CGI::Carp "fatalsToBrowser"; use CGI qw(:all); use warnings; use DBI; use lib './module'; use HTML::Template; use FindBin; use File::Type::WebImages 'mime_type'; use strict; use vars qw($action $redirect $root_path $prog_lib %lang); &get_path; $action = param('action'); my $cgi = CGI->new(); my %params = $cgi->Vars(); #my $path = $root_path . '/yambe/bilder/userpic'; my $path = 'd:/Projekte/YAMBE/Development/2.x/yambe/bilder/userpic'; my $filehandle = $cgi->upload('user_pic'); my $filename = $params{'user_pic'}; #$filename = (split(/[\\\/]/,$filename))[-1]; #$filename =~ s/[^A-Za-z0-9_\.\-]//g; #$filename =~ s/\\/\//g; my %Mode = ( '' => \&form, 'upload' => \&upload_datei, ); if($Mode{$action}) { $Mode{$action}->(); } else { $redirect = $root_path . "/cgi-bin/yambe/register.cgi"; my $q = new CGI; print $q->redirect($redirect); }; sub form { my $template = HTML::Template->new(filename => 'upload.tmpl', path => ["$prog_lib/templates/standard"]); #Bindet den Header ein. &header(0); $template->param(ROOT_PATH => $root_path); print $template->output; #Bindet den Footer ein. &footer(0); exit; } sub upload_datei { #Bindet den Header ein. &header(0); upload_file($filename,$filehandle,$path); my $uploaded_file = $path . "\\" . $filename; my $check_file = mime_type($uploaded_file); if ($check_file eq undef) { ... } else { ... } #Bindet den Footer ein. &footer(0); exit; } sub upload_file { my ($filename,$filehandle,$path) = @_; my $target = $path.'/'.$filename; if(-e $target){ print "Zieldatei existiert schon!"; exit(0); } else{ binmode $filehandle; open(TARGET,">$target") or die $!; binmode TARGET; my ($buffer); while(read $filehandle,$buffer,1024){ print TARGET $buffer; } close TARGET; print "<h2>Ihre Datei wurde unter $target gespeichert</h2>"; } }
nepos+2007-12-07 08:55:26--Kann ich mir eigentlich nicht vorstellen...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
sub header { my ($refrerr) = @_; if ($refrerr eq 'admin') { require "../data/session.cgi"; $header = HTML::Template->new(filename => 'header.tmpl', path => ["$prog_lib/../templates/standard"]); } else { require "data/session.cgi"; $header = HTML::Template->new(filename => 'header.tmpl', path => ["$prog_lib/templates/standard"]); } my $loggedin; my $loggedinuser; my $loggedinuserid; my $cgi = new CGI; $sid = $cgi->cookie('YAMBE_SESSID') || $cgi->param('sid'); $header->param(L_TITLE => $lang{title}); $header->param(L_REGISTER => $lang{Register}); $header->param(L_TODAY => $lang{Today}); $header->param(L_CALENDAR => $lang{Calendar}); $header->param(L_MONTHSUMMERY => $lang{Monthsummery}); $header->param(L_SEARCH => $lang{Search}); $header->param(ROOT_PATH => $root_path); $header->param(U_REGISTER => &add_session($root_path . "/cgi-bin/yambe/register.cgi")); $header->param(U_TODAY => &add_session($root_path . "/cgi-bin/yambe/event.cgi")); $header->param(U_CALENDAR => &add_session($root_path . "/cgi-bin/yambe/kalender.cgi")); $header->param(U_MONTHSUMMERY => &add_session($root_path . "/cgi-bin/yambe/monat.cgi")); $header->param(U_SEARCH => &add_session($root_path . "/cgi-bin/yambe/search.cgi")); if (defined ($sid)) { ($loggedin,$loggedinuser,$loggedinuserid) = &init; } if ($loggedin != 1) { $header->param(USER_LOGGED_OUT => 1); $header->param(L_PROFILE_REGISTER => $lang{Profile_Register}); $header->param(L_LOGIN => $lang{Login}); $header->param(U_PROFILE_REGISTER => $root_path . "/cgi-bin/yambe/profile.cgi?action=register"); $header->param(U_LOGIN => $root_path . "/cgi-bin/yambe/login.cgi"); } else { $header->param(USER_LOGGED_IN => 1); $header->param(L_LOGOUT => sprintf($lang{Logout},$loggedinuser)); $header->param(L_PROFILE => $lang{Profil}); $header->param(U_LOGOUT => $root_path . "/cgi-bin/yambe/login.cgi?action=logout"); my $test = &add_session($root_path . "/cgi-bin/yambe/profile.cgi"); $header->param(U_PROFILE => $test . "&action=edit&u=$loggedinuserid"); } print "Content-Type: text/html\n\n"; print $header->output; }
GwenDragon+2007-12-12 10:32:24--Und du verwendest require. Was ist, wenn das fehlschlägt?
|< 1 2 3 4 >| | 39 Einträge, 4 Seiten |