Readers: 17
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
#!/usr/bin/perl use strict; use CGI; use CGI qw(:standart); use CGI::Carp qw(fatalsToBrowser); use HTML::Template; use Digest::MD5 qw(md5_hex); require("config.pl"); my $cgi = CGI->new(); my $template = HTML::Template->new(filename => "template/check.tmpl"); my $user_input = CGI::param(); my $pass_input = CGI::param(); if((!defined($user_input)) || (!defined($pass_input))) { $template->param( weiterleitung => "index.pl", farbe => "red", checkausgabe => "Please insert your Username and Password" ); } elsif((defined($user_input)) && (defined($pass_input))) { my $user = md5_hex($user_input); my $pass = md5_hex($pass_input); if(($user eq $config{'login_user'}) && ($pass eq $config{'login_pass'})) { $template->param( weiterleitung => "online.pl", farbe => "green", checkausgabe => "Welcome <b>admin</b>" ); } else { $template->param( weiterleitung => "index.pl", farbe => "red", checkausgabe => "Wrong Username or Password! Please try again ..." ); } } else { $template->param( weiterleitung => "index.pl", farbe => "red", checkausgabe => "OH MY GOD «ERROR» " ); } print $cgi->header(); print $template->output();
1
2
3
4
5
6
7
8
9
10
11
<html>
<head>
<title>Login</title>
<link rel="stylesheet" type="text/css" href="template/style.css"/>
<link rel="shortcut icon" type="image/x-icon" href="template/ico.png"/>
<meta http-equiv="refresh" content="5; URL=<TMPL_VAR NAME="weiterleitung">">
</head>
<body bgcolor="#000000">
<font color="<TMPL_VAR NAME="farbe">"><center> >> <TMPL_VAR NAME="checkausgabe"> << </center></font>
</body>
</html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# ----------------------------------- # # Here you have to make your Settings # # ----------------------------------- # %config = ( # ------ MySql Settings ------ # mysql_host => 'localhost', mysql_user => 'testuser', mysql_pass => 'testpw', mysql_db => 'test_db', # ------ Login Settings [ only as MD5 ] ------ # login_user => '5d9c68c6c50ed3d02a2fcf54f63993b6', login_pass => '8eee3efdde1eb6cf6639a58848362bf4', ); return %config;
Quote[error] Attempt to reload HTML/Template.pm aborted.\nCompilation failed in require at /opt/lampp/htdocs/webpanel/index.pl line 7.\nBEGIN failed--compilation aborted at /opt/lampp/htdocs/webpanel/index.pl line 7.\n
1 2 3 4 5
$template->param( weiterleitung => "index.pl", farbe => "red", checkausgabe => "Wrong Username $config{'login_user'} or Password $config{'login_pass'}! Please try again ..." );
2009-04-02T14:07:34 Monk21Code (perl): (dl )1 2 3 4[...] my $user_input = CGI::param(); my $pass_input = CGI::param(); [...]
Quote[...]
Manchmal schreibt er mir folgende Error Meldung in die Log.
Quote[error] Attempt to reload HTML/Template.pm aborted.\nCompilation failed in require at /opt/lampp/htdocs/webpanel/index.pl line 7.\nBEGIN failed--compilation aborted at /opt/lampp/htdocs/webpanel/index.pl line 7.\n
[...]
Quote[...]
Wenn ich die richtigen Logindaten eingebe, dann springt er trotzdem zur Anweisung "Wrong Username ..."
Wenn ich nun die Ausgabe verändere in
Code (perl): (dl )1 2 3 4 5$template->param( weiterleitung => "index.pl", farbe => "red", checkausgabe => "Wrong Username $config{'login_user'} or Password $config{'login_pass'}! Please try again ..." );
Zeigt er mir aber die richtigen MD5 Hashes an.
Wieso klappt der Vergleich denn nicht ?
[...]
QuoteWie führst Du das Skript denn aus? Solche Fehlermeldungen kommen manchmal vor, wenn man Apache und mod_perl verwendet und der Server das Skript aufruft, nachdem es verändert wurde...
2009-04-02T15:47:16 nepos[...]
Bei zweiterem wird für jeden Aufruf des Scripts extra ein Perl-Interpreter gestartet.
my $template = HTML::Template->new(filename => "template/check.tmpl");
my $template = HTML::Template->new(filename => "../htdocs/webpanel/template/login.tmpl");
2009-04-02T16:10:53 Monk21Nö, das Skript kann auch .pl sein.Wenn ich das Script nun als .cgi in den cgi-bin Ordner lege, muss ich doch dann den Path zum Template anpassen.
QuoteKorrekt.Ich müsste also in diesen Skripten + allen html dateien den pfad auf "../htdocs/webpanel/template/" setzen.
QuoteSinnvoll ist, immer den kompletten Pfad zu Dateien anzugeben, also auch bei den Templates.Was ist den eigentlich Sinnvoller, und warum ?
Werden von Webhostern beide Arten unterstützt, oder nur cgi-bin ?
Quote[error] Attempt to reload HTML/Template.pm aborted.\nCompilation failed in require at /opt/lampp/htdocs/webpanel/index.pl line 7.\nBEGIN failed--compilation aborted at /opt/lampp/htdocs/webpanel/index.pl line 7.\n
QuoteSoftware error:
Can't call method "prepare" on an undefined value at /opt/lampp/htdocs/webpanel/check.cgi line 61.
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 106 107 108 109 110
#!/usr/bin/perl use strict; use warnings; use CGI; use CGI qw(:standart); use CGI::Carp qw(fatalsToBrowser); use HTML::Template; use Digest::MD5 qw(md5_hex); use DBI; require("config.cgi"); our %config; my $cgi = CGI->new(); my $template = HTML::Template->new(filename => "$config{'path'}/check.tmpl"); my $user_input = CGI::param('user'); my $pass_input = CGI::param('pass'); if(($user_input eq "") || ($pass_input eq "")) { $template->param( path => $config{'htmlpath'}, weiterleitung => "index.cgi", farbe => "red", checkausgabe => "Please insert your Username and Password" ); } elsif((defined($user_input)) && (defined($pass_input))) { my $user = md5_hex($user_input); my $pass = md5_hex($pass_input); if(($user eq $config{'login_user'}) && ($pass eq $config{'login_pass'})) { my $session_id = int(rand(9999999999)); my $sid = md5_hex($session_id); $template->param( path => $config{'htmlpath'}, weiterleitung => "online.cgi?id=$sid", farbe => "green", checkausgabe => "Welcome <b>Master</b>" ); my $dbh = DBI->connect("dbi:mysql:$config{'mysql_db'}", "$config{'mysql_user'}", "$config{'mysql_pass'}"); my $sth = $dbh->prepare("SELECT SessionID FROM session_id") || die "$DBI::errstr<br>"; $sth->execute() || die "$DBI::errstr<br>"; my $ausgabe = $sth->fetchrow_array(); if($ausgabe eq "") { $sth = $dbh->prepare("INSERT INTO session_id SET SessionID=MD5('$session_id')") || die "$DBI::errstr<br>"; $sth->execute() || die "$DBI::errstr<br>"; $sth->finish(); } else { $sth = $dbh->prepare("UPDATE session_id SET SessionID=MD5('$session_id')") || die "$DBI::errstr<br>"; $sth->execute() || die "$DBI::errstr<br>"; $sth->finish(); } } else { $template->param( path => $config{'htmlpath'}, weiterleitung => "index.cgi", farbe => "red", checkausgabe => "Wrong Username or Password! Please try again ..." ); } } else { $template->param( path => $config{'htmlpath'}, weiterleitung => "index.cgi", farbe => "red", checkausgabe => "OH MY GOD <b> «ERROR» </b>" ); } print $cgi->header(); print $template->output();
my $dbh = DBI->connect("dbi:mysql:$config{'mysql_db'}", "$config{'mysql_user'}", "$config{'mysql_pass'}");
1
2
my $dbh = DBI->connect("dbi:mysql:$config{'mysql_db'}", "$config{'mysql_user'}", "$config{'mysql_pass'}")
or die $DBI::errstr;
2009-04-03T11:12:15 Monk21[...]
Beim aufruf des check.cgi Scriptes erhalte ich folgende Error Message :
Code: (dl )1
2
3Software error:
Can't call method "prepare" on an undefined value at /opt/lampp/htdocs/webpanel/check.cgi line 61.
[...]
QuoteKeine MySql verbindung : Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)<br> at /opt/lampp/htdocs/webpanel/check.cgi line 59.
Quotecpan[8]> install DBD::mysql
Running install for module 'DBD::mysql'
Running make for C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
Has already been unwrapped into directory /root/.cpan/build/DBD-mysql-4.010-CGqKiL
'/usr/bin/perl Makefile.PL INSTALLDIRS=site' returned status 512, won't make
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
cpan[9]>
2009-04-03T11:47:26 Monk21Quotecpan[8]> install DBD::mysql
Running install for module 'DBD::mysql'
Running make for C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
Has already been unwrapped into directory /root/.cpan/build/DBD-mysql-4.010-CGqKiL
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
cpan[1]> install DBD::mysql
CPAN: Storable loaded ok (v2.18)
Going to read /root/.cpan/Metadata
Database was generated on Mon, 30 Mar 2009 22:27:06 GMT
CPAN: YAML loaded ok (v0.68)
Going to read 1 yaml file from /root/.cpan/build/
CPAN: Time::HiRes loaded ok (v1.9711)
............................................................................DONE
Restored the state of 1 (in 0.0453 secs)
Running install for module 'DBD::mysql'
Running make for C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
CPAN: Digest::SHA loaded ok (v5.45)
CPAN: Compress::Zlib loaded ok (v2.011)
Checksum for /root/.cpan/sources/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz ok
Scanning cache /root/.cpan/build for sizes
............................................................................DONE
DBD-mysql-4.010/
DBD-mysql-4.010/ChangeLog
DBD-mysql-4.010/constants.h
DBD-mysql-4.010/dbdimp.c
DBD-mysql-4.010/dbdimp.h
DBD-mysql-4.010/eg/
DBD-mysql-4.010/eg/._bug14979.pl
DBD-mysql-4.010/eg/bug14979.pl
DBD-mysql-4.010/eg/._bug21028.pl
DBD-mysql-4.010/eg/bug21028.pl
DBD-mysql-4.010/eg/bug30033.pl
DBD-mysql-4.010/eg/bug30033pg.pl
DBD-mysql-4.010/eg/decimal_test.pl
DBD-mysql-4.010/eg/issue21946.pl
DBD-mysql-4.010/eg/prepare_memory_usage.pl
DBD-mysql-4.010/eg/proc_example1.pl
DBD-mysql-4.010/eg/proc_example2.pl
DBD-mysql-4.010/eg/proc_example2a.pl
DBD-mysql-4.010/eg/proc_example2b.pl
DBD-mysql-4.010/eg/proc_example3.pl
DBD-mysql-4.010/eg/proc_example4.pl
DBD-mysql-4.010/INSTALL.html
DBD-mysql-4.010/lib/
DBD-mysql-4.010/lib/Bundle/
DBD-mysql-4.010/lib/Bundle/DBD/
DBD-mysql-4.010/lib/Bundle/DBD/mysql.pm
DBD-mysql-4.010/lib/DBD/
DBD-mysql-4.010/lib/DBD/mysql/
DBD-mysql-4.010/lib/DBD/mysql/GetInfo.pm
DBD-mysql-4.010/lib/DBD/mysql/INSTALL.pod
DBD-mysql-4.010/lib/DBD/mysql.pm
DBD-mysql-4.010/Makefile.PL
DBD-mysql-4.010/Makefile.PL.embedded
DBD-mysql-4.010/MANIFEST
DBD-mysql-4.010/MANIFEST.SKIP
DBD-mysql-4.010/META.yml
DBD-mysql-4.010/myld
DBD-mysql-4.010/mysql.xs
DBD-mysql-4.010/README
DBD-mysql-4.010/t/
DBD-mysql-4.010/t/00base.t
DBD-mysql-4.010/t/10connect.t
DBD-mysql-4.010/t/20createdrop.t
DBD-mysql-4.010/t/25lockunlock.t
DBD-mysql-4.010/t/29warnings.t
DBD-mysql-4.010/t/30insertfetch.t
DBD-mysql-4.010/t/31insertid.t
DBD-mysql-4.010/t/32insert_error.t
DBD-mysql-4.010/t/35limit.t
DBD-mysql-4.010/t/35prepare.t
DBD-mysql-4.010/t/40bindparam.t
DBD-mysql-4.010/t/40bindparam2.t
DBD-mysql-4.010/t/40blobs.t
DBD-mysql-4.010/t/40catalog.t
DBD-mysql-4.010/t/40keyinfo.t
DBD-mysql-4.010/t/40listfields.t
DBD-mysql-4.010/t/40nulls.t
DBD-mysql-4.010/t/40numrows.t
DBD-mysql-4.010/t/40server_prepare.t
DBD-mysql-4.010/t/40server_prepare_error.t
DBD-mysql-4.010/t/40types.t
DBD-mysql-4.010/t/41bindparam.t
DBD-mysql-4.010/t/41blobs_prepare.t
DBD-mysql-4.010/t/42bindparam.t
DBD-mysql-4.010/t/50chopblanks.t
DBD-mysql-4.010/t/50commit.t
DBD-mysql-4.010/t/55utf8.t
DBD-mysql-4.010/t/60leaks.t
DBD-mysql-4.010/t/65types.t
DBD-mysql-4.010/t/70takeimp.t
DBD-mysql-4.010/t/71impdata.t
DBD-mysql-4.010/t/75supported_sql.t
DBD-mysql-4.010/t/76multi_statement.t
DBD-mysql-4.010/t/80procs.t
DBD-mysql-4.010/t/lib.pl
DBD-mysql-4.010/t/mysql.dbtest
DBD-mysql-4.010/t/mysql.mtest
DBD-mysql-4.010/TODO
CPAN: File::Temp loaded ok (v0.18)
CPAN.pm: Going to build C/CA/CAPTTOFU/DBD-mysql-4.010.tar.gz
Can't exec "mysql_config": No such file or directory at Makefile.PL line 76.
Cannot find the file 'mysql_config'! Your execution PATH doesn't seem
not contain the path to mysql_config. Resorting to guessed values!
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
PLEASE NOTE:
For 'make test' to run properly, you must ensure that the
database user 'root' can connect to your MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.
mysql> grant all privileges on test.* to 'root'@'localhost' identified by 's3kr1t';
You can also optionally set the user to run 'make test' with:
perl Makefile.pl --testuser=username
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Can't exec "mysql_config": No such file or directory at Makefile.PL line 454.
Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
Failed to determine directory of mysql.h. Use
perl Makefile.PL --cflags=-I<dir>
to set this directory. For details see the INSTALL.html file,
section "C Compiler flags" or type
perl Makefile.PL --help
Warning: No success on command[/usr/bin/perl Makefile.PL INSTALLDIRS=site]
CAPTTOFU/DBD-mysql-4.010.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
Failed during this command:
CAPTTOFU/DBD-mysql-4.010.tar.gz : writemakefile NO '/usr/bin/perl Makefile.PL INSTALLDIRS=site' returned status 512
cpan[2]>