# jabber-lib.pl # Common functions for editing the jabber config files # # XXX - http://prdownloads.sourceforge.net/expat/expat-1.95.2-1.i686.rpm # - XML::Parser XML::Generator # XXX - admin <read> and <write> - what do they mean? BEGIN { push(@INC, ".."); }; use WebminCore; &init_config(); if ($config{'jabber_lib'}) { $ENV{$gconfig{'ld_env'}} .= ':' if ($ENV{$gconfig{'ld_env'}}); $ENV{$gconfig{'ld_env'}} .= $config{'jabber_lib'}; } eval "use XML::Parser; \$got_xml_parser++"; eval "use XML::Generator; \$got_xml_generator++"; # get_jabber_config() # Parse the jabber XML config file sub get_jabber_config { return $get_jabber_config_cache if (defined($get_jabber_config_cache)); local $xml = new XML::Parser('Style' => 'Tree'); eval { $get_jabber_config_cache = $xml->parsefile($config{'jabber_config'}); }; if ($@) { return $@; } return $get_jabber_config_cache; } # find(name, &config) sub find { local (@rv, $i); local $list = $_[1]->[1]; for($i=1; $i<@$list; $i+=2) { if (lc($list->[$i]) eq lc($_[0])) { push(@rv, [ $list->[$i], $list->[$i+1], $i ]); } } return wantarray ? @rv : $rv[0]; } # find_value(name, &config) sub find_value { local @rv = map { &value_in($_) } &find($_[0], $_[1]); return wantarray ? @rv : $rv[0]; } # jabber_pid_file() # Returns the PID file used by jabber sub jabber_pid_file { local $conf = &get_jabber_config(); local $pidfile = &find_value("pidfile", $conf); if ($pidfile =~ /^\//) { return $pidfile; } elsif ($pidfile) { return "$config{'jabber_dir'}/$pidfile"; } else { return "$config{'jabber_dir'}/jabber.pid"; } } # value_in(&tag) sub value_in { return undef if (!$_[0]); local $zero = &find("0", $_[0]); return $zero ? $zero->[1] : undef; } # generate_config(&tree, &gen) # Returns an XML::Generator object created from a config tree structure sub generate_config { local $gen = $_[1] ? $_[1] : XML::Generator->new(escape => 'always'); local $list = $_[0]->[1]; local (@mems, $i); for($i=1; $i<@$list-1; $i+=2) { if ($list->[$i] eq '0') { push(@mems, $list->[$i+1]); } else { push(@mems, &generate_config( [ $list->[$i], $list->[$i+1] ], $gen)); } } local $name = $_[0]->[0]; return $gen->$name($list->[0], @mems); } # save_jabber_config(&config) sub save_jabber_config { &open_tempfile(CONFIG, ">$config{'jabber_config'}"); local $xml = &generate_config($_[0]); &print_tempfile(CONFIG, $xml); &print_tempfile(CONFIG, "\n"); &close_tempfile(CONFIG); } # save_directive(&config, name|&old, &new) # Replaces all directives of some name with new values sub save_directive { local @ov = ref($_[1]) ? @{$_[1]} : &find($_[1], $_[0]); local @nv = @{$_[2]}; local ($i, $j); for($i=0; $i<@ov || $i<@nv; $i++) { local $idx = $ov[$i]->[2] if ($ov[$i]); if ($ov[$i] && $nv[$i]) { # Updating an existing value $_[0]->[1]->[$idx] = $nv[$i]->[0]; $_[0]->[1]->[$idx+1] = $nv[$i]->[1]; } elsif ($ov[$i]) { # Deleting an old value splice(@{$_[0]->[1]}, $idx, 2); map { $_->[2] -= 2 if ($_->[2] >= $idx) } @ov; } else { # Adding a new value after the last non-text one local $nt = -1; for($j=1; $j<@{$_[0]->[1]}; $j+=2) { $nt = $j if ($_[0]->[1]->[$j] ne '0'); } splice(@{$_[0]->[1]}, $nt+2, 0, $nv[$i]->[0], $nv[$i]->[1]); } } } # find_by_tag(name, tag, value, &config) sub find_by_tag { local @m = &find($_[0], $_[3]); @m = grep { lc($_->[1]->[0]->{lc($_[1])}) eq lc($_[2]) } @m; return wantarray ? @m : $m[0]; } # xml_string(name, &tree, ...) # Converts a list of XML structures into text sub xml_string { local $rv = ""; for($i=0; $i<@_; $i+=2) { local $xml = &generate_config([ $_[$i], $_[$i+1] ]); if ($xml =~ /\S/) { $rv .= $xml."\n"; } } return $rv; } # get_jabberd_version(&out) sub get_jabberd_version { local $jabberd = $config{'jabber_daemon'} ? $config{'jabber_daemon'} : "$config{'jabber_dir'}/bin/jabberd"; local $out = `$jabberd -v 2>&1`; ${$_[0]} = $out; return $out =~ /\s(1\.4\S*)/ ? $1 : undef; } # stop_jabber() # Stops jabber, and returns undef on success or an error message on failure sub stop_jabber { if ($config{'stop_cmd'}) { &system_logged("$config{'stop_cmd'} </dev/null >/dev/null 2>&1"); } else { local $pid = &check_pid_file(&jabber_pid_file()); if ($pid) { &kill_logged('TERM', $pid) || return $!; } else { return $text{'stop_epid'}; } } unlink(&jabber_pid_file()); return undef; } # start_jabber() # Starts jabber, and returns undef on success or an error message on failure sub start_jabber { &system_logged("$config{'start_cmd'} </dev/null >/tmp/err 2>&1"); return undef; } @register_fields = ( 'name', 'email' ); @karma_presets = ( { 'heartbeat' => 2, 'init' => 10, 'max' => 10, 'inc' => 1, 'dec' => 1, 'penalty' => -6, 'restore' => 10 }, { 'heartbeat' => 2, 'init' => 50, 'max' => 50, 'inc' => 4, 'dec' => 1, 'penalty' => -5, 'restore' => 50 }, { 'heartbeat' => 2, 'init' => 64, 'max' => 64, 'inc' => 6, 'dec' => 1, 'penalty' => -3, 'restore' => 64 } ); @filter_conds = ( "ns", "unavailable", "from", "resource", "subject", "body", "show", "type", "roster", "group" ); @filter_acts = ( "error", "offline", "forward", "reply", "continue", "settype" ); 1;
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
help | Folder | 0755 |
|
|
images | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
backup_config.pl | File | 770 B | 0755 |
|
config | File | 152 B | 0644 |
|
config-cobalt-linux | File | 190 B | 0644 |
|
config-coherent-linux | File | 190 B | 0644 |
|
config-debian-linux | File | 166 B | 0644 |
|
config-gentoo-linux | File | 195 B | 0644 |
|
config-mandrake-linux | File | 185 B | 0644 |
|
config-msc-linux | File | 190 B | 0644 |
|
config-openSUSE-Linux-15.0-ALL | File | 186 B | 0644 |
|
config-openmamba-linux | File | 190 B | 0644 |
|
config-redhat-linux | File | 190 B | 0644 |
|
config-suse-linux | File | 190 B | 0644 |
|
config-syno-linux | File | 152 B | 0644 |
|
config-trustix-linux | File | 190 B | 0644 |
|
config-turbo-linux | File | 190 B | 0644 |
|
config-united-linux | File | 202 B | 0644 |
|
config.info | File | 365 B | 0644 |
|
config.info.ca | File | 415 B | 0644 |
|
config.info.cs | File | 344 B | 0644 |
|
config.info.de | File | 413 B | 0644 |
|
config.info.es | File | 340 B | 0644 |
|
config.info.nl | File | 397 B | 0644 |
|
config.info.no | File | 373 B | 0644 |
|
config.info.pl | File | 394 B | 0644 |
|
config.info.ru | File | 580 B | 0644 |
|
config.info.uk | File | 592 B | 0644 |
|
cpan_modules.pl | File | 97 B | 0755 |
|
edit_admin.cgi | File | 1.66 KB | 0755 |
|
edit_file.cgi | File | 699 B | 0755 |
|
edit_filter.cgi | File | 1.37 KB | 0755 |
|
edit_general.cgi | File | 1.7 KB | 0755 |
|
edit_ips.cgi | File | 1.59 KB | 0755 |
|
edit_karma.cgi | File | 2.83 KB | 0755 |
|
edit_messages.cgi | File | 2.46 KB | 0755 |
|
edit_modules.cgi | File | 1.35 KB | 0755 |
|
index.cgi | File | 4.11 KB | 0755 |
|
install_check.pl | File | 609 B | 0755 |
|
jabber-lib.pl | File | 5.13 KB | 0755 |
|
module.info | File | 169 B | 0644 |
|
module.info.af | File | 0 B | 0644 |
|
module.info.af.auto | File | 106 B | 0644 |
|
module.info.ar | File | 0 B | 0644 |
|
module.info.ar.auto | File | 169 B | 0644 |
|
module.info.be | File | 0 B | 0644 |
|
module.info.be.auto | File | 189 B | 0644 |
|
module.info.bg | File | 0 B | 0644 |
|
module.info.bg.auto | File | 173 B | 0644 |
|
module.info.ca | File | 98 B | 0644 |
|
module.info.ca.auto | File | 15 B | 0644 |
|
module.info.cs | File | 25 B | 0644 |
|
module.info.cs.auto | File | 85 B | 0644 |
|
module.info.da | File | 0 B | 0644 |
|
module.info.da.auto | File | 106 B | 0644 |
|
module.info.de | File | 95 B | 0644 |
|
module.info.de.auto | File | 17 B | 0644 |
|
module.info.el | File | 0 B | 0644 |
|
module.info.el.auto | File | 201 B | 0644 |
|
module.info.es | File | 42 B | 0644 |
|
module.info.es.auto | File | 90 B | 0644 |
|
module.info.eu | File | 0 B | 0644 |
|
module.info.eu.auto | File | 120 B | 0644 |
|
module.info.fa | File | 0 B | 0644 |
|
module.info.fa.auto | File | 142 B | 0644 |
|
module.info.fi | File | 0 B | 0644 |
|
module.info.fi.auto | File | 115 B | 0644 |
|
module.info.fr | File | 0 B | 0644 |
|
module.info.fr.auto | File | 113 B | 0644 |
|
module.info.he | File | 0 B | 0644 |
|
module.info.he.auto | File | 153 B | 0644 |
|
module.info.hr | File | 0 B | 0644 |
|
module.info.hr.auto | File | 132 B | 0644 |
|
module.info.hu | File | 0 B | 0644 |
|
module.info.hu.auto | File | 119 B | 0644 |
|
module.info.it | File | 0 B | 0644 |
|
module.info.it.auto | File | 118 B | 0644 |
|
module.info.ja | File | 0 B | 0644 |
|
module.info.ja.auto | File | 148 B | 0644 |
|
module.info.ko | File | 0 B | 0644 |
|
module.info.ko.auto | File | 126 B | 0644 |
|
module.info.lt | File | 0 B | 0644 |
|
module.info.lt.auto | File | 130 B | 0644 |
|
module.info.lv | File | 0 B | 0644 |
|
module.info.lv.auto | File | 118 B | 0644 |
|
module.info.ms | File | 94 B | 0644 |
|
module.info.ms.auto | File | 15 B | 0644 |
|
module.info.mt | File | 0 B | 0644 |
|
module.info.mt.auto | File | 116 B | 0644 |
|
module.info.nl | File | 25 B | 0644 |
|
module.info.nl.auto | File | 93 B | 0644 |
|
module.info.no | File | 25 B | 0644 |
|
module.info.no.auto | File | 85 B | 0644 |
|
module.info.pl | File | 95 B | 0644 |
|
module.info.pl.auto | File | 17 B | 0644 |
|
module.info.pt | File | 0 B | 0644 |
|
module.info.pt.auto | File | 109 B | 0644 |
|
module.info.pt_BR | File | 0 B | 0644 |
|
module.info.pt_BR.auto | File | 118 B | 0644 |
|
module.info.ro | File | 0 B | 0644 |
|
module.info.ro.auto | File | 125 B | 0644 |
|
module.info.ru | File | 47 B | 0644 |
|
module.info.ru.auto | File | 150 B | 0644 |
|
module.info.sk | File | 0 B | 0644 |
|
module.info.sk.auto | File | 120 B | 0644 |
|
module.info.sl | File | 0 B | 0644 |
|
module.info.sl.auto | File | 120 B | 0644 |
|
module.info.sv | File | 0 B | 0644 |
|
module.info.sv.auto | File | 112 B | 0644 |
|
module.info.th | File | 0 B | 0644 |
|
module.info.th.auto | File | 250 B | 0644 |
|
module.info.tr | File | 0 B | 0644 |
|
module.info.tr.auto | File | 129 B | 0644 |
|
module.info.uk | File | 0 B | 0644 |
|
module.info.uk.auto | File | 191 B | 0644 |
|
module.info.ur | File | 0 B | 0644 |
|
module.info.ur.auto | File | 146 B | 0644 |
|
module.info.vi | File | 0 B | 0644 |
|
module.info.vi.auto | File | 114 B | 0644 |
|
module.info.zh | File | 0 B | 0644 |
|
module.info.zh.auto | File | 94 B | 0644 |
|
module.info.zh_TW | File | 0 B | 0644 |
|
module.info.zh_TW.auto | File | 103 B | 0644 |
|
restart.cgi | File | 274 B | 0755 |
|
save_admin.cgi | File | 1.16 KB | 0755 |
|
save_file.cgi | File | 636 B | 0755 |
|
save_filter.cgi | File | 920 B | 0755 |
|
save_general.cgi | File | 1.75 KB | 0755 |
|
save_ips.cgi | File | 979 B | 0755 |
|
save_karma.cgi | File | 1.26 KB | 0755 |
|
save_messages.cgi | File | 1.29 KB | 0755 |
|
save_modules.cgi | File | 748 B | 0755 |
|
start.cgi | File | 168 B | 0755 |
|
stop.cgi | File | 197 B | 0755 |
|