line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
72
|
|
2
|
|
|
|
|
|
|
package NetServer::Portal::Login; |
3
|
1
|
|
|
1
|
|
8
|
use NetServer::Portal qw($Host %PortInfo term); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1661
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
NetServer::Portal->register(cmd => "menu", |
6
|
|
|
|
|
|
|
title => "Main Menu", |
7
|
|
|
|
|
|
|
package => __PACKAGE__); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
0
|
|
|
0
|
0
|
|
bless { error => '' } |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub update { |
14
|
0
|
|
|
0
|
0
|
|
my ($o, $c) = @_; |
15
|
0
|
0
|
|
|
|
|
if (!$o->{user}) { |
16
|
0
|
|
|
|
|
|
my $s = "$o->{error}\n\n\n[$Host] $0 #$$\n\nlogin: "; |
17
|
0
|
|
|
|
|
|
$o->{error} = ''; |
18
|
0
|
|
|
|
|
|
$s; |
19
|
|
|
|
|
|
|
} else { |
20
|
0
|
|
|
|
|
|
my $conf = $c->conf; |
21
|
0
|
|
|
|
|
|
my $l = $c->format_line; |
22
|
0
|
|
|
|
|
|
my $s = NetServer::Portal::term->Tputs('cl',1,$c->{io}->fd); |
23
|
0
|
|
|
|
|
|
$s .= $l->("NetServer::Portal v$NetServer::Portal::VERSION"); |
24
|
0
|
|
|
|
|
|
$s .= "\n"; |
25
|
0
|
|
|
|
|
|
$s .= $l->("HOST: $Host"); |
26
|
0
|
|
|
|
|
|
$s .= $l->("PID: $$"); |
27
|
0
|
|
|
|
|
|
$s .= $l->("USER: $o->{user}"); |
28
|
0
|
|
|
|
|
|
$s .= "\n\n"; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my @p = values %PortInfo; |
31
|
0
|
|
|
|
|
|
@p = sort { $a->{title} cmp $b->{title} } @p; |
|
0
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $fmt = " %-10s %-40s"; |
33
|
0
|
|
|
|
|
|
for my $p (@p) { |
34
|
0
|
|
|
|
|
|
$s .= $l->($fmt, '!'.$p->{cmd}, $p->{title}); |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
|
$s .= $l->($fmt, '!exit', 'End Session'); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$s .= "\n"; |
39
|
0
|
|
|
|
|
|
$s .= $l->($fmt, "dim r,c", "Change screen dimensions from [$conf->{rows},$conf->{cols}]"); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$s .= "\n" x ($conf->{rows} - 13 - @p); |
42
|
0
|
|
|
|
|
|
$s .= $l->($o->{error}); |
43
|
0
|
|
|
|
|
|
$s .= "% "; |
44
|
0
|
|
|
|
|
|
$s; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub init_user { |
49
|
0
|
|
|
0
|
0
|
|
my ($o, $cl, $id) = @_; |
50
|
0
|
|
|
|
|
|
$o->{user} = $id; |
51
|
0
|
|
|
|
|
|
my $t = $NetServer::Portal::StoreTop; |
52
|
0
|
0
|
|
|
|
|
if (! exists $t->{$id}) { |
53
|
0
|
|
|
|
|
|
my $u = $t->{$id} = {}; |
54
|
0
|
|
|
|
|
|
$u->{rows} = 24; |
55
|
0
|
|
|
|
|
|
$u->{cols} = 80; |
56
|
0
|
|
|
|
|
|
$u->{screen} = __PACKAGE__; |
57
|
|
|
|
|
|
|
} else { |
58
|
0
|
|
|
|
|
|
eval { $cl->set_screen($t->{$id}{screen}) }; # failure OK |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub cmd { |
63
|
0
|
|
|
0
|
0
|
|
my ($o, $cl, $in) = @_; |
64
|
0
|
0
|
|
|
|
|
if (!$o->{user}) { |
65
|
0
|
0
|
|
|
|
|
if ($in) { |
66
|
0
|
0
|
|
|
|
|
if ($in =~ m/^[a-zA-Z\d]+$/) { |
67
|
|
|
|
|
|
|
# optional password protection XXX |
68
|
0
|
|
|
|
|
|
$o->init_user($cl, $in); |
69
|
|
|
|
|
|
|
} else { |
70
|
0
|
|
|
|
|
|
$o->{error} = "'$in' is not a valid login"; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} else { |
74
|
0
|
0
|
|
|
|
|
if (!$in) { |
75
|
0
|
|
|
|
|
|
$o->{error} = ''; |
76
|
0
|
|
|
|
|
|
return; |
77
|
|
|
|
|
|
|
} |
78
|
0
|
0
|
|
|
|
|
if ($in =~ m/^dim \s* (\d+) (\s*,\s*|\s+) (\d+)$/x) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my ($r,$c) = ($1,$3); |
80
|
0
|
0
|
|
|
|
|
$r = 12 if $r < 12; |
81
|
0
|
0
|
|
|
|
|
$c = 70 if $c < 70; |
82
|
0
|
|
|
|
|
|
my $conf = $cl->conf; |
83
|
0
|
|
|
|
|
|
$conf->{rows} = $r; |
84
|
0
|
|
|
|
|
|
$conf->{cols} = $c; |
85
|
|
|
|
|
|
|
} elsif ($in eq '!exit') { |
86
|
0
|
|
|
|
|
|
$cl->cancel; |
87
|
|
|
|
|
|
|
} elsif ($in eq '!back') { |
88
|
0
|
|
|
|
|
|
$cl->set_screen('back'); |
89
|
|
|
|
|
|
|
} else { |
90
|
0
|
|
|
|
|
|
for my $p (values %PortInfo) { |
91
|
0
|
0
|
|
|
|
|
if ($in eq '!'.$p->{cmd}) { |
92
|
0
|
|
|
|
|
|
$cl->set_screen($p->{package}); |
93
|
0
|
|
|
|
|
|
return; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
0
|
|
|
|
|
|
$o->{error} = "What is '$in'?"; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
package NetServer::Portal::About; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
NetServer::Portal->register(cmd => "about", |
104
|
|
|
|
|
|
|
title => "About This Extension", |
105
|
|
|
|
|
|
|
package => __PACKAGE__); |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
0
|
|
|
sub new { bless {}, shift } |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub cmd { |
110
|
0
|
|
|
0
|
|
|
my ($o, $cl) = @_; |
111
|
0
|
|
|
|
|
|
$cl->set_screen('back'); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub update { |
115
|
0
|
|
|
0
|
|
|
my ($o, $c) = @_; |
116
|
0
|
|
|
|
|
|
my $ln = $c->format_line; |
117
|
0
|
|
|
|
|
|
my $s = "NetServer::Portal v$NetServer::Portal::VERSION\n\n"; |
118
|
0
|
|
|
|
|
|
$s .= 'Copyright © 2000 Joshua Nathaniel Pritikin. All rights reserved. |
119
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
120
|
|
|
|
|
|
|
it under the same terms as Perl itself.'; |
121
|
0
|
|
|
|
|
|
$s .= "\n" x 3; |
122
|
0
|
|
|
|
|
|
$s .= q[Send questions about this extension to perl-loop@perl.org. |
123
|
|
|
|
|
|
|
If you wish to subscribe to this mailing list, send email to: |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
majordomo@perl.org |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
The body of your message should read: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
subscribe perl-loop |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
If you are curious about the author's motivation, see: |
133
|
|
|
|
|
|
|
http://why-compete.org |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Enjoy! ]; |
137
|
0
|
|
|
|
|
|
$s; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; |