line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MySQL::Admin::Config; |
2
|
5
|
|
|
5
|
|
16
|
use strict; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
104
|
|
3
|
5
|
|
|
5
|
|
13
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
108
|
|
4
|
|
|
|
|
|
|
require Exporter; |
5
|
5
|
|
|
5
|
|
13
|
use utf8; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
14
|
|
6
|
5
|
|
|
5
|
|
93
|
use vars qw($config $DefaultClass @EXPORT @ISA $defaultconfig); |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
1115
|
|
7
|
|
|
|
|
|
|
@MySQL::Admin::Config::EXPORT = qw(loadConfig saveConfig $config); |
8
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
$MySQL::Admin::Config::VERSION = '1.1'; |
10
|
|
|
|
|
|
|
$DefaultClass = 'MySQL::Admin::Config' unless defined $MySQL::Admin::Config::DefaultClass; |
11
|
|
|
|
|
|
|
$defaultconfig = '/var/www/cgi-bin/config/config.pl'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
MySQL::Admin::Config - config for MySQL::Admin |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
see L |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 EXPORT |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
loadConfig() saveConfig() $config |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 Public |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 new() |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
0
|
|
|
0
|
1
|
0
|
my ($class, @initializer) = @_; |
33
|
0
|
|
|
|
|
0
|
my $self = {}; |
34
|
0
|
|
0
|
|
|
0
|
bless $self, ref $class || $class || $DefaultClass; |
35
|
0
|
|
|
|
|
0
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 loadConfig() |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub loadConfig { |
43
|
0
|
|
|
0
|
1
|
0
|
my ($self, @p) = getSelf(@_); |
44
|
0
|
0
|
|
|
|
0
|
my $do = (defined $p[0]) ? $p[0] : $defaultconfig; |
45
|
0
|
0
|
|
|
|
0
|
if (-e $do) { do $do; } |
|
0
|
|
|
|
|
0
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 saveConfig() |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub saveConfig { |
53
|
4
|
|
|
4
|
1
|
31
|
my ($self, @p) = getSelf(@_); |
54
|
4
|
50
|
|
|
|
9
|
my $saveAs = defined $p[0] ? $p[0] : $defaultconfig; |
55
|
4
|
50
|
|
|
|
10
|
$config = defined $p[1] ? $p[1] : $config; |
56
|
4
|
50
|
|
|
|
9
|
my $var = defined $p[2] ? $p[2] : 'config'; |
57
|
5
|
|
|
5
|
|
2820
|
use Data::Dumper; |
|
5
|
|
|
|
|
33731
|
|
|
5
|
|
|
|
|
425
|
|
58
|
4
|
|
|
|
|
19
|
my $content = Dumper($config); |
59
|
4
|
|
|
|
|
319
|
$content .= "\$$var =\$VAR1;"; |
60
|
5
|
|
|
5
|
|
25
|
use Fcntl qw(:flock); |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
511
|
|
61
|
5
|
|
|
5
|
|
2288
|
use Symbol; |
|
5
|
|
|
|
|
3112
|
|
|
5
|
|
|
|
|
1392
|
|
62
|
4
|
|
|
|
|
14
|
my $fh = gensym(); |
63
|
4
|
50
|
|
|
|
83
|
my $rsas = $saveAs =~ /^(\S+)$/ ? $1 : 0; |
64
|
|
|
|
|
|
|
|
65
|
4
|
50
|
|
|
|
12
|
if ($rsas) { |
66
|
4
|
50
|
|
|
|
391
|
open $fh, ">$rsas.bak" |
67
|
|
|
|
|
|
|
or warn "$/MySQL::Admin::Config::saveConfig$/ $! $/ File: $rsas $/Caller: " |
68
|
|
|
|
|
|
|
. caller() |
69
|
|
|
|
|
|
|
. $/; |
70
|
4
|
|
|
|
|
21
|
flock $fh, 2; |
71
|
4
|
|
|
|
|
20
|
seek $fh, 0, 0; |
72
|
4
|
|
|
|
|
111
|
truncate $fh, 0; |
73
|
4
|
|
|
|
|
34
|
print $fh $content; |
74
|
4
|
|
|
|
|
138
|
close $fh; |
75
|
|
|
|
|
|
|
} |
76
|
4
|
50
|
|
|
|
46
|
if (-e "$rsas.bak") { |
77
|
4
|
50
|
|
|
|
194
|
rename "$rsas.bak", $rsas |
78
|
|
|
|
|
|
|
or warn "$/MySQL::Admin::Config::saveConfig$/ $! $/ File: $rsas $/Caller: " |
79
|
|
|
|
|
|
|
. caller() |
80
|
|
|
|
|
|
|
. $/; |
81
|
4
|
|
|
|
|
955
|
do $rsas; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 Private |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 getSelf() |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
see L |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub getSelf { |
94
|
4
|
50
|
33
|
4
|
1
|
27
|
return @_ if defined($_[0]) && (!ref($_[0])) && ($_[0] eq 'MySQL::Admin::Config'); |
|
|
|
33
|
|
|
|
|
95
|
4
|
50
|
33
|
|
|
38
|
return (defined($_[0]) |
96
|
|
|
|
|
|
|
&& (ref($_[0]) eq 'MySQL::Admin::Config' || UNIVERSAL::isa($_[0], 'MySQL::Admin::Config')) |
97
|
|
|
|
|
|
|
) |
98
|
|
|
|
|
|
|
? @_ |
99
|
|
|
|
|
|
|
: ($MySQL::Admin::Config::DefaultClass->new, @_); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 see Also |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
L L L L L L |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Dirk Lindner |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Copyright (C) 2005-2015 by Hr. Dirk Lindner |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
115
|
|
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public License |
116
|
|
|
|
|
|
|
as published by the Free Software Foundation; |
117
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
118
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
119
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
120
|
|
|
|
|
|
|
GNU Lesser General Public License for more details. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |