| Server IP : 89.39.208.18 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : User : ( ) PHP Version : 7.4.33 Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home3/./mahyarcake/././www/wp-content/plugins/mailchimp-for-wp/includes/ |
Upload File : |
<?php
/**
* Class MC4WP_Debug_Log_Reader
*/
class MC4WP_Debug_Log_Reader {
/**
* @var resource|null
*/
private $handle;
/**
* @var string
*/
private static $regex = '/^(\[[\d \-\:]+\]) (\w+\:) (.*)$/S';
/**
* @var string
*/
private static $html_template = '<span class="time">$1</span> <span class="level">$2</span> <span class="message">$3</span>';
/**
* @var string The log file location.
*/
private $file;
/**
* MC4WP_Debug_Log_Reader constructor.
*
* @param $file
*/
public function __construct( $file ) {
$this->file = $file;
}
/**
* @return string
*/
public function all() {
return file_get_contents( $this->file );
}
/**
* Sets file pointer to $n of lines from the end of file.
*
* @param int $n
*/
private function seek_line_from_end( $n ) {
$line_count = 0;
// get line count
while ( ! feof( $this->handle ) ) {
fgets( $this->handle );
++$line_count;
}
// rewind to beginning
rewind( $this->handle );
// calculate target
$target = $line_count - $n;
$target = $target > 1 ? $target : 1; // always skip first line because oh PHP header
$current = 0;
// keep reading until we're at target
while ( $current < $target ) {
fgets( $this->handle );
++$current;
}
}
/**
* @return string|null
*/
public function read() {
// open file if not yet opened
if ( ! is_resource( $this->handle ) ) {
// doesn't exist?
if ( ! file_exists( $this->file ) ) {
return null;
}
$this->handle = @fopen( $this->file, 'r' );
// unable to read?
if ( ! is_resource( $this->handle ) ) {
return null;
}
// set pointer to 1000 files from EOF
$this->seek_line_from_end( 1000 );
}
// stop reading once we're at the end
if ( feof( $this->handle ) ) {
fclose( $this->handle );
$this->handle = null;
return null;
}
// read line, up to 8kb
$text = fgets( $this->handle );
// strip tags & trim
$text = strip_tags( $text );
$text = trim( $text );
return $text;
}
/**
* @return string
*/
public function read_as_html() {
$line = $this->read();
// null means end of file
if ( is_null( $line ) ) {
return null;
}
// empty string means empty line, but not yet eof
if ( empty( $line ) ) {
return '';
}
$line = preg_replace( self::$regex, self::$html_template, $line );
return $line;
}
/**
* Reads X number of lines.
*
* If $start is negative, reads from end of log file.
*
* @param int $start
* @param int $number
* @return string
*/
public function lines( $start, $number ) {
$handle = fopen( $start, 'r' );
$lines = '';
$current_line = 0;
while ( $current_line < $number ) {
$lines .= fgets( $handle );
}
fclose( $handle );
return $lines;
}
}