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
|
package ASM::XML;
no autovivification;
use warnings;
use strict;
use XML::Simple qw(:strict);
use IO::All;
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
$::xs1 = XML::Simple->new( KeyAttr => ['id'], Cache => [ qw/memcopy/ ]);
sub readXML {
my ( $p ) = $::cset;
my @fchan = ( 'event', keys %::RISKS );
$::settings = $::xs1->XMLin( "$p/settings.xml", ForceArray => ['host'],
'GroupTags' => { altnicks => 'altnick', server => 'host',
autojoins => 'autojoin' });
$::channels = $::xs1->XMLin( "$p/channels.xml", ForceArray => \@fchan );
$::users = $::xs1->XMLin( "$p/users.xml", ForceArray => 'person');
$::commands = $::xs1->XMLin( "$p/commands.xml", ForceArray => [qw/command/]);
$::mysql = $::xs1->XMLin( "$p/mysql.xml", ForceArray => ['ident', 'geco'],
'GroupTags' => { ignoredidents => 'ident', ignoredgecos => 'geco' });
$::dnsbl = $::xs1->XMLin( "$p/dnsbl.xml", ForceArray => []);
$::rules = $::xs1->XMLin( "$p/rules.xml", ForceArray => []);
$::restrictions = $::xs1->XMLin( "$p/restrictions.xml", ForceArray => ['host', 'nick', 'account']);
$::blacklist = $::xs1->XMLin( "$p/blacklist.xml", ForceArray => 'string');
}
sub writeXML {
writeSettings();
writeChannels();
writeUsers();
writeRestrictions();
writeBlacklist();
writeMysql();
# $::xs1->XMLout($::commands, RootName => 'commands', KeyAttr => ['id']) > io("$::cset/commands.xml");
}
sub writeMysql {
$::settingschanged=1;
$::xs1->XMLout($::mysql, RootName => 'mysql', KeyAttr => ['id']) > io("$::cset/mysql.xml");
}
sub writeChannels {
$::settingschanged=1;
$::xs1->XMLout($::channels, RootName => 'channels', KeyAttr => ['id'], NumericEscape => 2) > io("$::cset/channels.xml");
}
sub writeUsers {
$::settingschanged=1;
$::xs1->XMLout($::users, RootName => 'people', KeyAttr => ['id']) > io("$::cset/users.xml");
}
sub writeSettings {
$::settingschanged=1;
$::xs1->XMLout($::settings, RootName => 'settings',
GroupTags => { altnicks => 'altnick', server => 'host', autojoins => 'autojoin' }, NoAttr => 1) > io("$::cset/settings.xml");
}
sub writeRestrictions {
$::settingschanged=1;
$::xs1->XMLout($::restrictions, RootName => 'restrictions', KeyAttr => ['id'],
GroupTags => { hosts => "host", nicks => "nick", accounts => "account"}) > io("$::cset/restrictions.xml");
}
sub writeBlacklist {
$::settingschanged=1;
$::xs1->XMLout($::blacklist, RootName => 'blacklist', KeyAttr => ['id'], NumericEscape => 2) > io("$::cset/blacklist.xml");
}
return 1;
|