本文整理汇总了PHP中pb_backupbuddy::_skiplog方法的典型用法代码示例。如果您正苦于以下问题:PHP pb_backupbuddy::_skiplog方法的具体用法?PHP pb_backupbuddy::_skiplog怎么用?PHP pb_backupbuddy::_skiplog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pb_backupbuddy
的用法示例。
在下文中一共展示了pb_backupbuddy::_skiplog方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: status
/**
* self::status()
*
* Logs data to a CSV file. Optional unique serial identifier.
* If a serial is passed then EVERYTHING will be logged to the specified serial file in addition to whatever (if anything) is logged to main status file.
* Always logs to main status file based on logging settings whether serial is passed or not.
*
* @see self::get_status().
*
* @param string $type Valid types: error, warning, details, message
* @param string $text Text message to log.
* @param string|array $serial Optional. Optional unique identifier for this plugin's message. Status messages are unique per plugin so this adds an additional unique layer for retrieval.
* If self::$_status_serial has been set by set_status_serial() then it will override if $serial is blank.
* @return null
*/
public static function status($type, $message, $serials = '', $js_mode = false)
{
if (!class_exists('backupbuddy_core')) {
require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
}
if (self::$_status_serial != '' && $serials == '') {
$serials = self::$_status_serial;
}
if (!is_array($serials)) {
$serials = array($serials);
}
global $pb_backupbuddy_js_status;
if (defined('PB_IMPORTBUDDY') || isset($pb_backupbuddy_js_status) && $pb_backupbuddy_js_status === true) {
$status = pb_backupbuddy::$format->date(time()) . "\t" . sprintf("%01.2f", round(microtime(true) - pb_backupbuddy::$start_time, 2)) . "\t" . sprintf("%01.2f", round(memory_get_peak_usage() / 1048576, 2)) . "\t" . $type . "\t" . str_replace(chr(9), ' ', $message);
$status = str_replace('\\', '/', $status);
echo '<script type="text/javascript">pb_status_append("' . str_replace("\n", '\\n', str_replace('"', '"', $status)) . '");</script>';
pb_backupbuddy::flush();
}
if (defined('BACKUPBUDDY_WP_CLI') && true === BACKUPBUDDY_WP_CLI) {
if (class_exists('WP_CLI')) {
WP_CLI::line($type . ' - ' . $message);
}
}
$delimiter = '|~|';
// Make sure we have a unique log serial for all logs for security.
if (!isset(self::$options['log_serial']) || self::$options['log_serial'] == '') {
self::$options['log_serial'] = self::random_string(15);
self::save();
}
foreach ($serials as $serial) {
// Determine whether writing to main file.
$write_main = false;
if (self::$options['log_level'] == 0) {
// No logging.
$write_main = false;
} elseif (self::$options['log_level'] == 1) {
// Errors only.
if ($type == 'error') {
$write_main = true;
self::log('[' . $serial . '] ' . $message, 'error');
}
} else {
// Everything else.
$write_main = true;
self::log('[' . $serial . '] ' . $message, $type);
}
// Determine whether writing to serial file. Ignores log level.
if ($serial != '') {
$write_serial = true;
} else {
$write_serial = false;
}
// Return if not writing to any file.
if ($write_main !== true && $write_serial !== true) {
return;
}
// Calculate log directory.
$log_directory = backupbuddy_core::getLogDirectory();
// Also handles when within importbuddy.
// Prepare directory for log files. Return if unable to do so.
if (true === self::$_skiplog) {
// bool true so skip.
return;
} elseif (false !== self::$_skiplog) {
// something other than bool false so check directory before proceeding.
if (true !== self::anti_directory_browsing($log_directory, $die_on_fail = false, $deny_all = false, $suppress_alert = true)) {
// Unable to secure directory. Fail.
self::$_skiplog = true;
return;
} else {
self::$_skiplog = false;
}
}
// Function for writing actual log CSV data. Used later.
if (!function_exists('write_status_line')) {
function write_status_line($file, $content_array, $delimiter)
{
$delimiter = '|~|';
if (false !== ($file_handle = @fopen($file, 'a'))) {
// Append mode.
//fputcsv ( $file_handle , $content_array );
@fwrite($file_handle, trim(implode($delimiter, $content_array)) . PHP_EOL);
@fclose($file_handle);
} else {
//pb_backupbuddy::alert( 'Unable to open file handler for status file `' . $file . '`. Unable to write status log.' );
//.........这里部分代码省略.........
示例2: status
/**
* self::status()
*
* Logs data to a CSV file. Optional unique serial identifier.
* If a serial is passed then EVERYTHING will be logged to the specified serial file in addition to whatever (if anything) is logged to main status file.
* Always logs to main status file based on logging settings whether serial is passed or not.
* NOTE: When full logging is on AND a serial is passed, it will be written to a _sum_ text file instead of the main log file.
*
* @see self::get_status().
*
* @param string $type Valid types: error, warning, details, message
* @param string $text Text message to log.
* @param string $serial Optional. Optional unique identifier for this plugin's message. Status messages are unique per plugin so this adds an additional unique layer for retrieval.
* If self::$_status_serial has been set by set_status_serial() then it will override if $serial is blank.
* @return null
*/
public static function status($type, $message, $serials = '', $js_mode = false, $echoNotWrite = false)
{
if (!class_exists('backupbuddy_core')) {
require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
}
if (self::$_status_serial != '' && $serials == '') {
$serials = self::$_status_serial;
}
if (defined('BACKUPBUDDY_WP_CLI') && true === BACKUPBUDDY_WP_CLI) {
if (class_exists('WP_CLI')) {
WP_CLI::line($type . ' - ' . $message);
}
}
// Make sure we have a unique log serial for all logs for security.
if (!isset(self::$options['log_serial']) || self::$options['log_serial'] == '') {
self::$options['log_serial'] = self::random_string(15);
self::save();
}
if (!is_array($serials)) {
$serials = array($serials);
}
// Calculate log directory.
$log_directory = backupbuddy_core::getLogDirectory();
// Also handles when within importbuddy.
// Prepare directory for log files. Return if unable to do so.
if (true === self::$_skiplog) {
// bool true so skip.
return;
} elseif (false !== self::$_skiplog) {
// something other than bool false so check directory before proceeding.
if (true !== self::anti_directory_browsing($log_directory, $die_on_fail = false, $deny_all = false, $suppress_alert = true)) {
// Unable to secure directory. Fail.
self::$_skiplog = true;
return;
} else {
self::$_skiplog = false;
}
}
foreach ($serials as $serial) {
// ImportBuddy always write to main status log.
if (defined('PB_IMPORTBUDDY') && PB_IMPORTBUDDY === true) {
// IMPORTBUDDY
$write_serial = false;
$write_main = true;
$main_file = $log_directory . 'status-' . self::$options['log_serial'] . '.txt';
} else {
// STANDALONE.
// Determine whether writing to main extraneous log file.
$write_main = false;
if (self::$options['log_level'] == 0) {
// No logging.
$write_main = false;
} elseif (self::$options['log_level'] == 1) {
// Errors only.
if ($type == 'error') {
$write_main = true;
self::log('[' . $serial . '] ' . $message, 'error');
}
} else {
// Everything else.
$write_main = true;
self::log('[' . $serial . '] ' . $message, $type);
}
// Determine which normal status log files to write.
if ($serial != '') {
$write_serial = true;
$write_main = true;
$main_file = $log_directory . 'status-' . $serial . '_sum_' . self::$options['log_serial'] . '.txt';
} else {
$write_serial = false;
$write_main = false;
}
}
// Function for writing actual log CSV data. Used later.
if (!function_exists('write_status_line')) {
function write_status_line($file, $content_array, $echoNotWrite)
{
$writeData = json_encode($content_array) . PHP_EOL;
if (true === $echoNotWrite) {
// echo data instead of writing to file. used by ajax when checking status log and needing to prepend before log.
echo $writeData;
} else {
//$delimiter = '|~|';
if (false !== ($file_handle = @fopen($file, 'a'))) {
//.........这里部分代码省略.........
示例3: status
/**
* self::status()
*
* Logs data to a CSV file. Optional unique serial identifier.
* If a serial is passed then EVERYTHING will be logged to the specified serial file in addition to whatever (if anything) is logged to main status file.
* Always logs to main status file based on logging settings whether serial is passed or not.
*
* @see self::get_status().
*
* @param string $type Valid types: error, warning, details, message
* @param string $text Text message to log.
* @param string $serial Optional. Optional unique identifier for this plugin's message. Status messages are unique per plugin so this adds an additional unique layer for retrieval.
* If self::$_status_serial has been set by set_status_serial() then it will override if $serial is blank.
* @return null
*/
public static function status($type, $message, $serial = '', $js_mode = false)
{
global $pb_backupbuddy_js_status;
if (defined('PB_IMPORTBUDDY') || isset($pb_backupbuddy_js_status) && $pb_backupbuddy_js_status === true) {
$status = pb_backupbuddy::$format->date(time()) . "\t" . sprintf("%01.2f", round(microtime(true) - pb_backupbuddy::$start_time, 2)) . "\t" . sprintf("%01.2f", round(memory_get_peak_usage() / 1048576, 2)) . "\t" . $type . "\t" . str_replace(chr(9), ' ', $message);
$status = str_replace('\\', '/', $status);
echo '<script type="text/javascript">pb_status_append("' . str_replace("\n", '\\n', str_replace('"', '"', $status)) . '");</script>';
//echo '<script type="text/javascript">pb_status_append(\'' . str_replace( '\'', ''', $status ) . '\');</script>';
/*
USE WITH JAVASCRIPT IN PAGE:
<script type="text/javascript">
function pb_status_append( status_string ) {
target_id = 'importbuddy_status'; // importbuddy_status or pb_backupbuddy_status
jQuery( '#' + target_id ).append( "\n" + status_string );
textareaelem = document.getElementById( target_id );
textareaelem.scrollTop = textareaelem.scrollHeight;
}
</script>
*/
pb_backupbuddy::flush();
//return;
}
$delimiter = '|~|';
if (self::$_status_serial != '' && $serial == '') {
$serial = self::$_status_serial;
}
// Make sure we have a unique log serial for all logs for security.
if (!isset(self::$options['log_serial']) || self::$options['log_serial'] == '') {
self::$options['log_serial'] = self::random_string(15);
self::save();
}
// Determine whether writing to main file.
$write_main = false;
if (self::$options['log_level'] == 0) {
// No logging.
$write_main = false;
} elseif (self::$options['log_level'] == 1) {
// Errors only.
if ($type == 'error') {
$write_main = true;
self::log('[' . $serial . '] ' . $message, 'error');
}
} else {
// Everything else.
$write_main = true;
self::log('[' . $serial . '] ' . $message, $type);
}
// Determine whether writing to serial file. Ignores log level.
if ($serial != '') {
$write_serial = true;
} else {
$write_serial = false;
}
// Return if not writing to any file.
if ($write_main !== true && $write_serial !== true) {
return;
}
// Calculate log directory.
if (defined('PB_STANDALONE') && PB_STANDALONE === true) {
$log_directory = ABSPATH . 'importbuddy/';
} else {
$log_directory = WP_CONTENT_DIR . '/uploads/pb_' . self::settings('slug') . '/';
}
// Prepare directory for log files. Return if unable to do so.
if (true === self::$_skiplog) {
// bool true so skip.
return;
} elseif (false !== self::$_skiplog) {
// something other than bool false so check directory before proceeding.
if (true !== self::anti_directory_browsing($log_directory, $die_on_fail = false, $deny_all = false, $suppress_alert = true)) {
// Unable to secure directory. Fail.
self::$_skiplog = true;
return;
} else {
self::$_skiplog = false;
}
}
// Function for writing actual log CSV data. Used later.
if (!function_exists('write_status_line')) {
function write_status_line($file, $content_array, $delimiter)
{
$delimiter = '|~|';
if (false !== ($file_handle = fopen($file, 'a'))) {
// Append mode.
//fputcsv ( $file_handle , $content_array );
//.........这里部分代码省略.........