PK Default page
One Hat Cyber Team
  • Dir : ~/usr/local/src/csf/ConfigServer/
  • Edit File: DisplayUI.pm

    \n"; print "
    \n"; print "\n"; print < var myFont = 14; var textarea = \$('#formdata'); var editordiv = \$('#editor'); var editor = ace.edit("editor"); editor.setTheme("ace/theme/tomorrow"); editor.setShowPrintMargin(false); editor.setOptions({ fontFamily: "Courier New, Courier", fontSize: "14px" }); editor.getSession().setMode("ace/mode/space"); editor.getSession().on('change', function () { textarea.val(editor.getSession().getValue()); }); textarea.on('change', function () { editor.getSession().setValue(textarea.val()); }); editor.getSession().setValue(textarea.val()); \$('#textarea').hide(); editordiv.show(); \$("#toggletextarea-btn").on('click', function () { \$('#textarea').toggle(); editordiv.toggle(); }); \$("#fontplus-btn").on('click', function () { myFont++; if (myFont > 20) {myFont = 20} editor.setFontSize(myFont) textarea.css("font-size",myFont+"px"); }); \$("#fontminus-btn").on('click', function () { myFont--; if (myFont < 12) {myFont = 12} editor.setFontSize(myFont) textarea.css("font-size",myFont+"px"); }); EOF } else { if ($config{DIRECTADMIN}) { print "
    \n
    \n"; } else { print "\n
    \n"; } print "
    Edit $file
    \n"; print "
    \n"; print "\n"; if ($extra) {print "\n";} print "
    \n"; print "\n"; print "
    \n"; } return; } # end editfile ############################################################################### # start savefile sub savefile { my $file = shift; my $restart = shift; $FORM{formdata} =~ s/\r//g; if ($FORM{ace} == "1") { if ($FORM{formdata} !~ /^# Do not remove or change this line as it is a safeguard for the UI editor\n/) { print "
    UI editor safeguard missing, changes have not been saved.
    \n"; return; } $FORM{formdata} =~ s/^# Do not remove or change this line as it is a safeguard for the UI editor\n//g; } sysopen (my $OUT, $file, O_WRONLY | O_CREAT) or die "Unable to open file: $!"; flock ($OUT, LOCK_EX); seek ($OUT, 0, 0); truncate ($OUT, 0); if ($FORM{formdata} !~ /\n$/) {$FORM{formdata} .= "\n"} print $OUT $FORM{formdata}; close ($OUT); if ($restart eq "csf") { print "
    Changes saved. You should restart csf.
    \n"; print "
    \n"; } elsif ($restart eq "lfd") { print "
    Changes saved. You should restart lfd.
    \n"; print "
    \n"; } elsif ($restart eq "both") { print "
    Changes saved. You should restart csf and lfd.

    \n"; print "
    \n"; } else { print "
    Changes saved.
    \n"; } return; } # end cloudflare ############################################################################### # start cloudflare sub cloudflare { my $scope = &ConfigServer::CloudFlare::getscope(); print "\n"; print "\n"; print "\n"; print "\n"; print ""; print "\n"; # } else { # print "\n"; # } print ""; print "\n"; print "\n"; print ""; print "
    csf - CloudFlare
    Select the user(s), then select the action below
    Select the domain(s), then select the action below
    List rules in CloudFlare ONLY for the chosen accounts
    Add rule for target in CloudFlare ONLY for the chosen accounts
    Delete rule for target in CloudFlare ONLY
    Temporarily IP address for $config{CF_TEMP} secs in CloudFlare AND csf for the chosen accounts and those with to \"any\"
    \n"; print "
    Output will appear here
    \n"; print "
    Note:\n
      \n"; print "
    • target can be one of:
      • An IP address
      • \n
      • 2 letter Country Code
      • \n
      • IP range CIDR
      \n
    • \n"; print "
    • Only Enterprise customers can block a Country Code, but all can allow and challenge\n"; print "
    • \nIP range CIDR is limited to /16 and /24
    \n"; print "\n"; &printreturn; return; } # end cloudflare ############################################################################### # start resize sub resize { my $part = shift; my $scroll = shift; if ($part eq "top") { print "
    \n"; print "
    \n"; } else { print " EOF } return; } # end resize ############################################################################### # start printreturn sub printreturn { print "
    \n"; return; } # end printreturn ############################################################################### # start confirmmodal # print "\n"; # &confirmmodal; sub confirmmodal { print "\n"; print "\n"; return; } # end confirmmodal ############################################################################### # start csgetversion sub csgetversion { my $product = shift; my $current = shift; my $upgrade = 0; my $newversion; if (-e "/var/lib/configserver/".$product.".txt.error") { open (my $VERSION, "<", "/var/lib/configserver/".$product.".txt.error"); flock ($VERSION, LOCK_SH); $newversion = <$VERSION>; close ($VERSION); chomp $newversion; if ($newversion eq "") { $newversion = "Failed to retrieve latest version from ConfigServer"; } else { $newversion = "Failed to retrieve latest version from ConfigServer: $newversion"; } } elsif (-e "/var/lib/configserver/".$product.".txt") { open (my $VERSION, "<", "/var/lib/configserver/".$product.".txt"); flock ($VERSION, LOCK_SH); $newversion = <$VERSION>; close ($VERSION); chomp $newversion; if ($newversion eq "") { $newversion = "Failed to retrieve latest version from ConfigServer"; } else { if ($newversion =~ /^[\d\.]*$/) { if ($newversion > $current) {$upgrade = 1} else {$newversion = ""} } else {$newversion = ""} } } elsif (-e "/var/lib/configserver/error") { open (my $VERSION, "<", "/var/lib/configserver/error"); flock ($VERSION, LOCK_SH); $newversion = <$VERSION>; close ($VERSION); chomp $newversion; if ($newversion eq "") { $newversion = "Failed to retrieve latest version from ConfigServer"; } else { $newversion = "Failed to retrieve latest version from ConfigServer: $newversion"; } } else { $newversion = "Failed to retrieve latest version from ConfigServer"; } return ($upgrade, $newversion); } # end csgetversion ############################################################################### # start manualversion sub manualversion { my $current = shift; my $upgrade = 0; my $url = "https://$config{DOWNLOADSERVER}/csf/version.txt"; if ($config{URLGET} == 1) {$url = "http://$config{DOWNLOADSERVER}/csf/version.txt";} my ($status, $newversion) = $urlget->urlget($url); if (!$status and $newversion ne "" and $newversion =~ /^[\d\.]*$/ and $newversion > $current) {$upgrade = 1} else {$newversion = ""} return ($upgrade, $newversion); } # end manualversion ############################################################################### 1;