line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MySQL::Admin::Config; |
2
|
5
|
|
|
5
|
|
18
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
112
|
|
3
|
5
|
|
|
5
|
|
14
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
110
|
|
4
|
|
|
|
|
|
|
require Exporter; |
5
|
5
|
|
|
5
|
|
14
|
use utf8; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
12
|
|
6
|
5
|
|
|
5
|
|
101
|
use vars qw($config $DefaultClass @EXPORT @ISA $defaultconfig); |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
1136
|
|
7
|
|
|
|
|
|
|
@MySQL::Admin::Config::EXPORT = qw(loadConfig saveConfig $config); |
8
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
$MySQL::Admin::Config::VERSION = '1.12'; |
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
|
32
|
my ($self, @p) = getSelf(@_); |
54
|
4
|
50
|
|
|
|
11
|
my $saveAs = defined $p[0] ? $p[0] : $defaultconfig; |
55
|
4
|
50
|
|
|
|
10
|
$config = defined $p[1] ? $p[1] : $config; |
56
|
4
|
50
|
|
|
|
10
|
my $var = defined $p[2] ? $p[2] : 'config'; |
57
|
5
|
|
|
5
|
|
2671
|
use Data::Dumper; |
|
5
|
|
|
|
|
34434
|
|
|
5
|
|
|
|
|
401
|
|
58
|
4
|
|
|
|
|
22
|
my $content = Dumper($config); |
59
|
4
|
|
|
|
|
345
|
$content .= "\$$var =\$VAR1;"; |
60
|
5
|
|
|
5
|
|
26
|
use Fcntl qw(:flock); |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
526
|
|
61
|
5
|
|
|
5
|
|
1967
|
use Symbol; |
|
5
|
|
|
|
|
3183
|
|
|
5
|
|
|
|
|
1386
|
|
62
|
4
|
|
|
|
|
17
|
my $fh = gensym(); |
63
|
4
|
50
|
|
|
|
89
|
my $rsas = $saveAs =~ /^(\S+)$/ ? $1 : 0; |
64
|
|
|
|
|
|
|
|
65
|
4
|
50
|
|
|
|
12
|
if ($rsas) { |
66
|
4
|
50
|
|
|
|
434
|
open $fh, ">$rsas.bak" |
67
|
|
|
|
|
|
|
or warn "$/MySQL::Admin::Config::saveConfig$/ $! $/ File: $rsas $/Caller: " |
68
|
|
|
|
|
|
|
. caller() |
69
|
|
|
|
|
|
|
. $/; |
70
|
4
|
|
|
|
|
20
|
flock $fh, 2; |
71
|
4
|
|
|
|
|
23
|
seek $fh, 0, 0; |
72
|
4
|
|
|
|
|
120
|
truncate $fh, 0; |
73
|
4
|
|
|
|
|
34
|
print $fh $content; |
74
|
4
|
|
|
|
|
21819
|
close $fh; |
75
|
|
|
|
|
|
|
} |
76
|
4
|
50
|
|
|
|
93
|
if (-e "$rsas.bak") { |
77
|
4
|
50
|
|
|
|
210
|
rename "$rsas.bak", $rsas |
78
|
|
|
|
|
|
|
or warn "$/MySQL::Admin::Config::saveConfig$/ $! $/ File: $rsas $/Caller: " |
79
|
|
|
|
|
|
|
. caller() |
80
|
|
|
|
|
|
|
. $/; |
81
|
4
|
|
|
|
|
1095
|
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
|
|
|
42
|
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; |