WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wpsc_create_debug_log() WPSCache 1.0

Хуков нет.

Возвращает

Null. Ничего.

Использование

wpsc_create_debug_log( $filename, $username );

Код wpsc_create_debug_log() WPSCache 1.7.1

<?php
function wpsc_create_debug_log( $filename = '', $username = '' ) {
	global $cache_path, $wp_cache_debug_username, $wp_cache_debug_log;
	if ( $filename != '' ) {
		$wp_cache_debug_log = $filename;
	} else {
		$wp_cache_debug_log = md5( time() + mt_rand() ) . ".php";
	}
	if ( $username != '' ) {
		$wp_cache_debug_username = $username;
	} else {
		$wp_cache_debug_username = wpsc_debug_username();
	}

	$msg = 'die( "Please use the viewer" );' . PHP_EOL;
	$fp = fopen( $cache_path . $wp_cache_debug_log, 'w' );
	if ( $fp ) {
		fwrite( $fp, '<' . "?php\n" );
		fwrite( $fp, $msg );
		fwrite( $fp, '?' . "><pre>" . PHP_EOL );
		fwrite( $fp, '<' . '?php // END HEADER ?' . '>' . PHP_EOL );
		fclose( $fp );
		wp_cache_setting( 'wp_cache_debug_log', $wp_cache_debug_log );
		wp_cache_setting( 'wp_cache_debug_username', $wp_cache_debug_username );
	}

	$msg = '
if ( !isset( $_SERVER[ "PHP_AUTH_USER" ] ) || ( $_SERVER[ "PHP_AUTH_USER" ] != "' . $wp_cache_debug_username . '" && $_SERVER[ "PHP_AUTH_PW" ] != "' . $wp_cache_debug_username . '" ) ) {
	header( "WWW-Authenticate: Basic realm=\"WP-Super-Cache Debug Log\"" );
	header( $_SERVER[ "SERVER_PROTOCOL" ] . " 401 Unauthorized" );
	echo "You must login to view the debug log";
	exit;
}' . PHP_EOL;

	$fp = fopen( $cache_path . 'view_' . $wp_cache_debug_log, 'w' );
	if ( $fp ) {
		fwrite( $fp, '<' . "?php" . PHP_EOL );
		$msg .= '$debug_log = file( "./' . $wp_cache_debug_log . '" );
$start_log = 1 + array_search( "<" . "?php // END HEADER ?" . ">" . PHP_EOL, $debug_log );
if ( $start_log > 1 ) {
	$debug_log = array_slice( $debug_log, $start_log );
}
?' . '><form action="" method="GET"><' . '?php

$checks = array( "wp-admin", "exclude_filter", "wp-content", "wp-json" );
foreach( $checks as $check ) {
	if ( isset( $_GET[ $check ] ) ) {
		$$check = 1;
	} else {
		$$check = 0;
	}
}

if ( isset( $_GET[ "filter" ] ) ) {
	$filter = htmlspecialchars( $_GET[ "filter" ] );
} else {
	$filter = "";
}

unset( $checks[1] ); // exclude_filter
?' . '>
<h2>WP Super Cache Log Viewer</h2>
<h3>Warning! Do not copy and paste this log file to a public website!</h3>
<p>This log file contains sensitive information about your website such as cookies and directories.</p>
<p>If you must share it please remove any cookies and remove any directories such as ' . ABSPATH . '.</p>
Exclude requests: <br />
<' . '?php foreach ( $checks as $check ) { ?>
	<label><input type="checkbox" name="<' . '?php echo $check; ?' . '>" value="1" <' . '?php if ( $$check ) { echo "checked"; } ?' . '> /> <' . '?php echo $check; ?' . '></label><br />
<' . '?php } ?' . '>
<br />
Text to filter by:

<input type="text" name="filter" value="<' . '?php echo $filter; ?' . '>" /><br />
<input type="checkbox" name="exclude_filter" value="1" <' . '?php if ( $exclude_filter ) { echo "checked"; } ?' . '> /> Exclude by filter instead of include.<br />
<input type="submit" value="Submit" />
</form>
<' . '?php
$path_to_site = "' . ABSPATH . '";
foreach ( $debug_log as $t => $line ) {
	$line = str_replace( $path_to_site, "ABSPATH/", $line );
	$debug_log[ $t ] = $line;
	foreach( $checks as $check ) {
		if ( $$check && false !== strpos( $line, " /$check/" ) ) {
			unset( $debug_log[ $t ] );
		}
	}
	if ( $filter ) {
		if ( false !== strpos( $line, $filter ) && $exclude_filter ) {
			unset( $debug_log[ $t ] );
		} elseif ( false === strpos( $line, $filter ) && ! $exclude_filter ) {
			unset( $debug_log[ $t ] );
		}
	}
}
foreach( $debug_log as $line ) {
	echo htmlspecialchars( $line ) . "<br />";
}';
		fwrite( $fp, $msg );
		fclose( $fp );
	}

	return array( 'wp_cache_debug_log' => $wp_cache_debug_log, 'wp_cache_debug_username' => $wp_cache_debug_username );
}