|
Server IP : 10.131.40.8 / Your IP : 216.73.216.37 Web Server : Apache System : Linux webd008.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : ludmqhh ( 137773) PHP Version : 8.4.10 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/ludmqhh/www/hotel-forum/wp-content/plugins/wp-hotelier/includes/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
/**
* Allows log files to be written to for debugging purposes.
*
* @author Benito Lopez <hello@lopezb.com>
* @category Class
* @package Hotelier/Classes
* @version 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'HTL_Log' ) ) :
/**
* HTL_Log Class
*/
class HTL_Log {
/**
* @var array Stores open file _handles.
* @access private
*/
private $_handles;
/**
* Constructor for the logger.
*/
public function __construct() {
$this->_handles = array();
}
/**
* Destructor.
*/
public function __destruct() {
foreach ( $this->_handles as $handle ) {
@fclose( $handle );
}
}
/**
* Open log file for writing.
*
* @access private
* @param mixed $handle
* @return bool success
*/
private function open( $handle ) {
if ( isset( $this->_handles[ $handle ] ) ) {
return true;
}
if ( $this->_handles[ $handle ] = @fopen( htl_get_log_file_path( $handle ), 'a' ) ) {
return true;
}
return false;
}
/**
* Add a log entry to chosen file.
*
* @param string $handle
* @param string $message
*/
public function add( $handle, $message ) {
if ( $this->open( $handle ) && is_resource( $this->_handles[ $handle ] ) ) {
$time = date_i18n( 'm-d-Y @ H:i:s -' ); // Grab Time
@fwrite( $this->_handles[ $handle ], $time . " " . $message . "\n" );
}
do_action( 'hotelier_log_add', $handle, $message );
}
/**
* Clear entries from chosen file.
*
* @param mixed $handle
*/
public function clear( $handle ) {
if ( $this->open( $handle ) && is_resource( $this->_handles[ $handle ] ) ) {
@ftruncate( $this->_handles[ $handle ], 0 );
}
do_action( 'hotelier_log_clear', $handle );
}
}
endif;
