Server IP : 103.119.228.120 / Your IP : 216.73.216.201 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els17.x86_64 #1 SMP Mon Feb 24 04:58:14 UTC 2025 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/local/ssl/src/csf/ConfigServer/ |
Upload File : |
############################################################################### # Copyright 2006-2023, Way to the Web Limited # URL: http://www.configserver.com # Email: sales@waytotheweb.com ############################################################################### ## no critic (RequireUseWarnings, ProhibitExplicitReturnUndef, ProhibitMixedBooleanOperators, RequireBriefOpen) # start main package ConfigServer::Sendmail; use strict; use lib '/usr/local/csf/lib'; use Carp; use POSIX qw(strftime); use Fcntl qw(:DEFAULT :flock); use ConfigServer::Config; use ConfigServer::CheckIP qw(checkip); use Exporter qw(import); our $VERSION = 1.02; our @ISA = qw(Exporter); our @EXPORT_OK = qw(); my $config = ConfigServer::Config->loadconfig(); my %config = $config->config(); my $tz = strftime("%z", localtime); my $hostname; if (-e "/proc/sys/kernel/hostname") { open (my $IN, "<", "/proc/sys/kernel/hostname"); flock ($IN, LOCK_SH); $hostname = <$IN>; chomp $hostname; close ($IN); } else { $hostname = "unknown"; } if ($config{LF_ALERT_SMTP}) { require Net::SMTP; import Net::SMTP; } # end main ############################################################################### # start sendmail sub relay { my ($to, $from, @message) = @_; my $time = localtime(time); if ($to eq "") {$to = $config{LF_ALERT_TO}} else {$config{LF_ALERT_TO} = $to} if ($from eq "") {$from = $config{LF_ALERT_FROM}} else {$config{LF_ALERT_FROM} = $from} my $data; if ($from =~ /([\w\.\=\-\_]+\@[\w\.\-\_]+)/) {$from = $1} if ($from eq "") {$from = "root"} if ($to =~ /([\w\.\=\-\_]+\@[\w\.\-\_]+)/) {$to = $1} if ($to eq "") {$to = "root"} my $header = 1; foreach my $line (@message) { $line =~ s/\r//; if ($line eq "") {$header = 0} $line =~ s/\[time\]/$time $tz/ig; $line =~ s/\[hostname\]/$hostname/ig; if ($header) { if ($line =~ /^To:\s*(.*)\s*$/i) { my $totxt = $1; if ($config{LF_ALERT_TO} ne "") { $line =~ s/^To:.*$/To: $config{LF_ALERT_TO}/i; } else { $to = $totxt; } } if ($line =~ /^From:\s*(.*)\s*$/i) { my $fromtxt = $1; if ($config{LF_ALERT_FROM} ne "") { $line =~ s/^From:.*$/From: $config{LF_ALERT_FROM}/i; } else { $from = $1; } } } $data .= $line."\n"; } $data = &wraptext($data, 990); if ($config{LF_ALERT_SMTP}) { if ($from !~ /\@/) {$from .= '@'.$hostname} if ($to !~ /\@/) {$to .= '@'.$hostname} my $smtp = Net::SMTP->new($config{LF_ALERT_SMTP}, Timeout => 10) or carp("Unable to send SMTP alert via [$config{LF_ALERT_SMTP}]: $!"); if (defined $smtp) { $smtp->mail($from); $smtp->to($to); $smtp->data(); $smtp->datasend($data); $smtp->dataend(); $smtp->quit(); } } else { local $SIG{CHLD} = 'DEFAULT'; my $error = 0; open (my $MAIL, "|-", "$config{SENDMAIL} -f $from -t") or carp("Unable to send SENDMAIL alert via [$config{SENDMAIL}]: $!"); print $MAIL $data; close ($MAIL) or $error = 1; if ($error and $config{DEBUG}) { logfile("Failed to send message via sendmail binary: $?"); logfile("Failed message: [$data]"); } } return; } # end sendmail ############################################################################### # start wraptext sub wraptext { my $text = shift; my $column = shift; my $original = $text; my $return = ""; my $hit = 1; my $loop = 0; while ($hit) { $hit = 0; $return = ""; foreach my $line (split(/\n/, $text)) { if (length($line) > $column) { foreach ($line =~ /(.{1,$column})/g) { my $chunk = $_; my $newchunk = ""; my $thishit = 0; my @chars = split(//,$chunk); for (my $x = length($chunk)-1;$x >= 0; $x--) { if ($chars[$x] =~ /\s/) { for (0..$x) {$newchunk .= $chars[$_]} $newchunk .= "\n"; for ($x+1..length($chunk)-1) {$newchunk .= $chars[$_]} $thishit = 1; last; } } if ($thishit) { $hit = 1; $thishit = 0; $return .= $newchunk; } else { $return .= $chunk."\n"; } } } else { $return .= $line."\n"; } } $text = $return; $loop++; if ($loop > 1000) { return $original; last; } } if (length($return) < length($original)) {$return = $original} return $return; } # end wraptext ############################################################################### 1;