#!/usr/bin/perl ############################################################################### # Copyright (C) 2006-2025 Jonathan Michaelson # # https://github.com/waytotheweb/scripts # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 3 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, see . ############################################################################### # start main use strict; use File::Find; use Fcntl qw(:DEFAULT :flock); use Sys::Hostname qw(hostname); use IPC::Open3; use lib '/usr/local/csf/lib'; use ConfigServer::DisplayUI; use ConfigServer::DisplayResellerUI; use ConfigServer::Config; use ConfigServer::Slurp qw(slurp); our ($reseller, %rprivs, $script, $images, $myv, %FORM, %in); my $config = ConfigServer::Config->loadconfig(); my %config = $config->config; my $slurpreg = ConfigServer::Slurp->slurpreg; my $cleanreg = ConfigServer::Slurp->cleanreg; foreach my $line (slurp("/etc/csf/csf.resellers")) { $line =~ s/$cleanreg//g; my ($user,$alert,$privs) = split(/\:/,$line); $privs =~ s/\s//g; foreach my $priv (split(/\,/,$privs)) { $rprivs{$user}{$priv} = 1; } $rprivs{$user}{ALERT} = $alert; } #print "content-type: text/html\n\n"; #foreach my $key (keys %ENV) { # print "ENV $key = [$ENV{$key}]
\n"; #} $reseller = 0; if ($ENV{REMOTE_USER} ne "" and $rprivs{$ENV{REMOTE_USER}}{USE}) { $reseller = 1; } else { print "content-type: text/html\n\n"; print "You do not have access to this feature\n"; exit(); } open (my $IN, "<", "/etc/csf/version.txt") or die $!; $myv = <$IN>; close ($IN); chomp $myv; $script = "/nodeworx/configservercsf"; $images = "/configserver/csf"; my $buffer = $ENV{'QUERY_STRING'}; if ($buffer eq "") {$buffer = $ENV{POST}} my @pairs = split(/&/, $buffer); foreach my $pair (@pairs) { my ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } $FORM{action} = $FORM{iworxme}; delete $FORM{iworxme}; print "content-type: text/html\n\n"; #foreach my $key (keys %ENV) { # print "$key = [$ENV{$key}]
\n"; #} my $bootstrapcss = ""; my $jqueryjs = ""; my $bootstrapjs = ""; unless ($FORM{action} eq "tailcmd" or $FORM{action} =~ /^cf/ or $FORM{action} eq "logtailcmd" or $FORM{action} eq "loggrepcmd") { print < ConfigServer Security & Firewall $bootstrapcss $jqueryjs $bootstrapjs \n"; print <

ConfigServer Security & Firewall - csf v$myv

EOF } my $templatehtml; open (my $SCRIPTOUT, '>', \$templatehtml); select $SCRIPTOUT; ConfigServer::DisplayResellerUI::main(\%FORM, $script, 0, $images, $myv); close ($SCRIPTOUT); select STDOUT; $templatehtml =~ s/\?action\=/?iworxme=/g; $templatehtml =~ s/\&action\=/&iworxme=/g; $templatehtml =~ s/\{action\}/{iworxme}/g; $templatehtml =~ s/\'action'/'iworxme'/g; $templatehtml =~ s/\"action"/"iworxme"/g; print $templatehtml; unless ($FORM{action} eq "tailcmd" or $FORM{action} =~ /^cf/ or $FORM{action} eq "logtailcmd" or $FORM{action} eq "loggrepcmd") { print < \n"; print "\n"; print "\n"; } 1;