line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Device::Audiotron;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.6.0;
|
4
|
|
|
|
|
|
|
require Exporter;
|
5
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '1.02';
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
11700
|
use strict;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
80
|
|
10
|
1
|
|
|
1
|
|
9
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
104
|
|
11
|
1
|
|
|
1
|
|
7
|
use vars qw($VERSION @ISA);
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
79
|
|
12
|
1
|
|
|
1
|
|
3126
|
use LWP 5.64 qw(UserAgent);
|
|
1
|
|
|
|
|
103666
|
|
|
1
|
|
|
|
|
1032
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#Copyright (c) 2002 Dave Crawford. All rights reserved.
|
16
|
|
|
|
|
|
|
#This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new
|
19
|
|
|
|
|
|
|
{
|
20
|
1
|
|
|
1
|
0
|
480
|
my $class = shift;
|
21
|
1
|
|
|
|
|
3
|
my $self = {};
|
22
|
1
|
|
|
|
|
18
|
($self->{ip},$self->{user},$self->{pass}) = @_;
|
23
|
1
|
|
|
|
|
3
|
bless $self,$class;
|
24
|
1
|
|
|
|
|
3
|
return($self);
|
25
|
|
|
|
|
|
|
}
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub GetInfo
|
28
|
|
|
|
|
|
|
{
|
29
|
0
|
|
|
0
|
0
|
0
|
my ($self,$type, $count, $criteria) = @_;
|
30
|
0
|
|
|
|
|
0
|
my ($url, $fetched, @array);
|
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
$url = "http://$self->{ip}/apigetinfo.asp?type=$type";
|
33
|
0
|
0
|
|
|
|
0
|
if($count){$url .= "&count=$count";}
|
|
0
|
|
|
|
|
0
|
|
34
|
0
|
0
|
|
|
|
0
|
if($criteria){$url .= "&this=" . $criteria;}
|
|
0
|
|
|
|
|
0
|
|
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
$fetched = $self->_FetchURL($url);
|
37
|
0
|
|
|
|
|
0
|
return($fetched);
|
38
|
|
|
|
|
|
|
}
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub Qfile
|
41
|
|
|
|
|
|
|
{
|
42
|
0
|
|
|
0
|
0
|
0
|
my ($self, $type, $criteria) = @_;
|
43
|
0
|
|
|
|
|
0
|
my ($url, $fetched);
|
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
0
|
$url = "http://$self->{ip}/apiqfile.asp?type=$type&file=$criteria";
|
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
$fetched = $self->_FetchURL($url);
|
48
|
0
|
|
|
|
|
0
|
return($fetched);
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub AddFile
|
52
|
|
|
|
|
|
|
{
|
53
|
0
|
|
|
0
|
0
|
0
|
my ($self, $file) = @_;
|
54
|
0
|
|
|
|
|
0
|
my ($url, $fetched);
|
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
$url = "http://$self->{ip}/apiaddfile.asp?type=file&file=$file";
|
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
$fetched = $self->_FetchURL($url);
|
59
|
0
|
|
|
|
|
0
|
return($fetched);
|
60
|
|
|
|
|
|
|
}
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub Cmd
|
63
|
|
|
|
|
|
|
{
|
64
|
0
|
|
|
0
|
0
|
0
|
my ($self, $cmd, $arg) = @_;
|
65
|
0
|
|
|
|
|
0
|
my ($url, $fetched);
|
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
$url = "http://$self->{ip}/apicmd.asp?cmd=$cmd";
|
68
|
0
|
0
|
|
|
|
0
|
if($arg){$url .= "&arg=$arg";}
|
|
0
|
|
|
|
|
0
|
|
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
$fetched = $self->_FetchURL($url);
|
71
|
0
|
|
|
|
|
0
|
return($fetched);
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub GetStatus
|
75
|
|
|
|
|
|
|
{
|
76
|
0
|
|
|
0
|
0
|
0
|
my $self = shift;
|
77
|
0
|
|
|
|
|
0
|
my ($url, $fetched, $h_name, $h_value, %status);
|
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
$url = "http://$self->{ip}/apigetstatus.asp";
|
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
0
|
$fetched = $self->_FetchURL($url);
|
82
|
0
|
|
|
|
|
0
|
my @array = split /\n/,$fetched;
|
83
|
0
|
|
|
|
|
0
|
foreach(@array)
|
84
|
|
|
|
|
|
|
{
|
85
|
0
|
0
|
0
|
|
|
0
|
if((/^\[(End )?Status\]/) || !(/=/)){next;}
|
|
0
|
|
|
|
|
0
|
|
86
|
0
|
|
|
|
|
0
|
chomp();
|
87
|
0
|
|
|
|
|
0
|
($h_name, $h_value) = split(/\s*=\s*/,$_,2);
|
88
|
0
|
|
|
|
|
0
|
$status{$h_name} = $h_value;
|
89
|
|
|
|
|
|
|
}
|
90
|
0
|
|
|
|
|
0
|
return(%status);
|
91
|
|
|
|
|
|
|
}
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub GlobalInfo
|
94
|
|
|
|
|
|
|
{
|
95
|
1
|
|
|
1
|
0
|
16
|
my $self = shift;
|
96
|
1
|
|
|
|
|
2
|
my ($url, $fetched, $h_name, $h_value, %tmp_hst, %status, @shares, @hosts);
|
97
|
1
|
|
|
|
|
3
|
my ($hst_cnt, $shr_flag, $hst_flag) = 0;
|
98
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
4
|
$url = "http://$self->{ip}/apigetinfo.asp?type=global";
|
100
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
129
|
$fetched = $self->_FetchURL($url);
|
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
my @array = split /\n/,$fetched;
|
104
|
0
|
|
|
|
|
0
|
foreach(@array)
|
105
|
|
|
|
|
|
|
{
|
106
|
0
|
0
|
|
|
|
0
|
if(/^\[(End )?Global\]/){next;}
|
|
0
|
|
|
|
|
0
|
|
107
|
0
|
0
|
|
|
|
0
|
if(/^\[Share List\]/){$shr_flag=1;next;}
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
108
|
0
|
0
|
|
|
|
0
|
if(/^\[End Share List\]/){$shr_flag=0;next;}
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
109
|
0
|
0
|
|
|
|
0
|
if(/^\[Host List\]/){$hst_flag=1;next;}
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
110
|
0
|
0
|
|
|
|
0
|
if(/^\[End Host List\]/){$hst_flag=0;next;}
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
111
|
0
|
0
|
|
|
|
0
|
if(/^\[End Host\]/){push(@hosts,{%tmp_hst});next;}
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
112
|
0
|
0
|
|
|
|
0
|
if(!(/=/)){next;}
|
|
0
|
|
|
|
|
0
|
|
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
0
|
chomp();
|
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
0
|
($h_name, $h_value) = split(/\s*=\s*/,$_,2);
|
117
|
|
|
|
|
|
|
|
118
|
0
|
0
|
|
|
|
0
|
if($shr_flag)
|
|
|
0
|
|
|
|
|
|
119
|
|
|
|
|
|
|
{
|
120
|
0
|
|
|
|
|
0
|
push(@shares, $h_value);
|
121
|
|
|
|
|
|
|
}
|
122
|
|
|
|
|
|
|
elsif($hst_flag)
|
123
|
|
|
|
|
|
|
{
|
124
|
0
|
|
|
|
|
0
|
$tmp_hst{$h_name} = $h_value;
|
125
|
|
|
|
|
|
|
}
|
126
|
|
|
|
|
|
|
else
|
127
|
|
|
|
|
|
|
{
|
128
|
0
|
|
|
|
|
0
|
$status{$h_name} = $h_value;
|
129
|
|
|
|
|
|
|
}
|
130
|
|
|
|
|
|
|
}
|
131
|
0
|
|
|
|
|
0
|
return(\%status, \@shares, \@hosts);
|
132
|
|
|
|
|
|
|
}
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub Msg
|
135
|
|
|
|
|
|
|
{
|
136
|
0
|
|
|
0
|
0
|
0
|
my ($self, $line1, $line2, $tmout) = @_;
|
137
|
0
|
|
|
|
|
0
|
my ($url, $fetched);
|
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
0
|
$url = "http://$self->{ip}/apimsg.asp?line1=$line1&line2=$line2";
|
140
|
0
|
0
|
|
|
|
0
|
if($tmout){$url .= "&timeout=$tmout";}
|
|
0
|
|
|
|
|
0
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
0
|
$fetched = $self->_FetchURL($url);
|
144
|
0
|
|
|
|
|
0
|
return($fetched);
|
145
|
|
|
|
|
|
|
}
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub DumpToc
|
148
|
|
|
|
|
|
|
{
|
149
|
0
|
|
|
0
|
0
|
0
|
my ($self, $share) = @_;
|
150
|
0
|
|
|
|
|
0
|
my ($url, $fetched);
|
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
0
|
$url = "http://$self->{ip}/apidumptoc.asp?share=$share";
|
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
0
|
$fetched = $self->_FetchURL($url);
|
155
|
0
|
|
|
|
|
0
|
return($fetched);
|
156
|
|
|
|
|
|
|
}
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
## internal "helper" routines ##
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub _FetchURL
|
163
|
|
|
|
|
|
|
{
|
164
|
1
|
|
|
1
|
|
4
|
my ($self, $url) = @_;
|
165
|
1
|
|
|
|
|
2
|
my ($ua, $request, $response);
|
166
|
|
|
|
|
|
|
|
167
|
1
|
|
|
|
|
10
|
$ua = LWP::UserAgent->new();
|
168
|
1
|
|
|
|
|
6970
|
$ua->agent("Device::Audiotron 1.01");
|
169
|
1
|
|
|
|
|
165
|
$request = HTTP::Request->new('GET', $url);
|
170
|
1
|
|
|
|
|
13756
|
$request->authorization_basic($self->{user}, $self->{pass});
|
171
|
|
|
|
|
|
|
|
172
|
1
|
|
|
|
|
2231
|
$response = $ua->request($request);
|
173
|
|
|
|
|
|
|
|
174
|
1
|
50
|
|
|
|
94442
|
if($response->is_success)
|
175
|
|
|
|
|
|
|
{
|
176
|
0
|
|
|
|
|
0
|
return($response->content());
|
177
|
|
|
|
|
|
|
}
|
178
|
|
|
|
|
|
|
else
|
179
|
|
|
|
|
|
|
{
|
180
|
1
|
|
|
|
|
99
|
croak("[HTTP " . $response->code() . " Error] ");
|
181
|
|
|
|
|
|
|
}
|
182
|
|
|
|
|
|
|
}
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
1;
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
__END__
|