#!/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::Config; our ($script, $images, $myv, %FORM, %in); my $config = ConfigServer::Config->loadconfig(); my %config = $config->config; open (my $IN, "<", "/etc/csf/version.txt"); $myv = <$IN>; close ($IN); chomp $myv; $script = "/configservercsf/iframe/"; $images = "/static/configservercsf"; my $file = $ARGV[0]; unless (-e $file) {die "Cannot find tempfile [$file]"} my (undef,undef,$uuid,$ugid) = getpwnam("cyberpanel"); my $uid = (stat($file))[4]; my $gid = (stat($file))[5]; if ($uid != $uuid or $gid != $ugid) {die "Invalid tempfile ownership [$file]"} open (my $DATA, "<", $file); my $buffer = <$DATA>; close ($DATA); 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; } #print "
$ARGV[0]:$ARGV[1]:[[$buffer]]
\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::DisplayUI::main(\%FORM, $script, $script, $images, $myv); #close ($SCRIPTOUT); #select STDOUT; #open (OUT, ">/tmp/out.html"); #print OUT $templatehtml; #close (OUT); #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;