-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.cgi
More file actions
executable file
·77 lines (72 loc) · 1.5 KB
/
index.cgi
File metadata and controls
executable file
·77 lines (72 loc) · 1.5 KB
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
#!/usr/bin/perl -sw
use lib '/home/eaiibgrp/jbieron/perl_modules/lib';
use CGI;
sub root {
my$q = shift;
my$str = $q->url( -absolute => 1 );
return substr($str, 0, rindex($str, '/'));
}
sub include {
open my$fh, '<', shift;
while(<$fh>) {chomp; print}
close $fh;
}
sub anal {
my($cookie,$first) = @_;
open my$anal, '>>', 'anal.txt';
print $anal $cookie, '|';
if($first) {
print $anal 'first';
#print $anal $cookie->value. '|';
} else {
print $anal localtime();
}
print $anal '|', $ENV{HTTP_USER_AGENT}, "\n";
close $anal;
}
my$q = new CGI;
my$cookie = $q->cookie('welcome');
if($cookie) {
anal( $cookie, 0 );
print $q->header(-charset => 'utf-8');
include 'html/head.html';
include 'html/welcome.html';
#end
} else {
my$label = 'Powiedz przyjacielu i wejdź';
my$pass = $q->param('pass') || '';
open my$read, '<', 'aux/phrase' or die 'Nie mogę sprawdzić hasła';
my$phrase = <$read>;
close $read;
chomp $phrase;
if($pass eq $phrase) {
#my$time = localtime;
$cookie = $q->cookie(
-name=>'welcome',
-value=> time,
-expires=>'0',
# -path=>'/~jbieron/gorce.dev'
# -path=>'/'
-path=> root($q)
);
anal( $cookie, 1 );
print $q->header(
-cookie => $cookie,
-charset=>'utf-8',
-Location => $q->url()
);
#end
}
if(lc $pass eq 'mellon') {
$label = '...srsly?';
}
print $q->header(-charset => 'utf-8');
include 'html/head.html';
open $read, '<', 'html/form.html';
while(<$read>) {
chomp;
if($_ eq '=') {print $label}
else {print}
}
close $read;
}