.
*/
// exit if add_action or plugins_url functions do not exist
!defined('ABSPATH') || !function_exists('add_action') || !function_exists('plugins_url') || !function_exists('add_management_page') || !function_exists('wp_die') && exit;
/********************************************************************************************************************************************************************************************************
FUNCTIONS
********************************************************************************************************************************************************************************************************/
if (!function_exists('wp_die')) : function wp_die ($message = 'wp_die') { die($message); } endif;
if (!function_exists('absint')): function absint( $maybeint ) { return abs( intval( $maybeint ) ); } endif;
if (!function_exists('is_a')) : function is_a($o, $c) { return (!is_object($o)) ? false : ((strtolower(get_class($o)) == strtolower($c)) ? true : is_subclass_of($o, $c)); } endif;
if (!function_exists('stripos')) : function stripos($haystack, $needle, $offset = 0) { return strpos(strtolower($haystack), strtolower($needle), $offset); } endif;
if (!function_exists('wp_die')): function wp_die($m = 'wp_die'){ die($m); } endif;
if(!class_exists('AA_DEBUG')):
/********************************************************************************************************************************************************************************************************
COMPAT
********************************************************************************************************************************************************************************************************/
/*
__LINE__ The current line number of the file.
__FILE__ The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path with symlinks resolved whereas in older versions it contained relative path under some circumstances.
__DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory. (Added in PHP 5.3.0.)
__FUNCTION__ The function name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__CLASS__ The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__METHOD__ The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive).
__NAMESPACE__ The name of the current namespace (case-sensitive). This constant is defined in compile-time (Added in PHP 5.3.0).
*/
// Version constants only available as of 5.2.8
if (!defined("PHP_VERSION_ID"))
{
list($major, $minor, $bug) = explode(".", phpversion(), 3);
$bug = ((int)$bug < 10) ? "0".(int)$bug : (int)$bug; // Many distros make up their own versions
define("PHP_VERSION_ID", "{$major}0{$minor}$bug");
!defined("PHP_MAJOR_VERSION") && define("PHP_MAJOR_VERSION", $major);
}
if (PHP_VERSION_ID < 50300 && !defined('__DIR__')) define('__DIR__', realpath(dirname(__FILE__)));
if (PHP_VERSION_ID < 50207 && !defined('FILE_BINARY')) define('FILE_BINARY', 0);
/********************************************************************************************************************************************************************************************************
DEFINES
********************************************************************************************************************************************************************************************************/
!defined('NET_SOCKET_READ') && define('NET_SOCKET_READ', 1);
!defined('NET_SOCKET_WRITE') && define('NET_SOCKET_WRITE', 2);
!defined('NET_SOCKET_ERROR') && define('NET_SOCKET_ERROR', 4);
!defined('STREAM_CRYPTO_METHOD_TLS_CLIENT') && define('STREAM_CRYPTO_METHOD_TLS_CLIENT', 3);
!defined('STREAM_CRYPTO_METHOD_SSLv3_CLIENT') && define('STREAM_CRYPTO_METHOD_SSLv3_CLIENT', 1);
!defined('STREAM_CRYPTO_METHOD_SSLv23_CLIENT') && define('STREAM_CRYPTO_METHOD_SSLv23_CLIENT', 2);
!defined('STREAM_CRYPTO_METHOD_SSLv2_CLIENT') && define('STREAM_CRYPTO_METHOD_SSLv2_CLIENT', 0);
!defined('ABSPATH') || !function_exists('add_management_page') || !function_exists('wp_die') && die('death by askapache firing squad');
!defined('WP_CONTENT_DIR') && define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
!defined('WP_PLUGIN_DIR') && define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins'); // full path, no trailing slash
!defined('WP_CONTENT_URL') && define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
!defined('WP_PLUGIN_URL') && define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins'); // full url, no trailing slash
/*
if ( WP_DEBUG_DISPLAY ) ini_set( 'display_errors', 1 );
if ( WP_DEBUG_LOG ) {
ini_set( 'log_errors', 1 );
ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
}
if ( WP_DEBUG ) error_reporting(-1);
*/
!defined('FS_CHMOD_DIR') && define('FS_CHMOD_DIR', (S_IRWUGO & ~ umask()));
!defined('FS_CHMOD_FILE') && define('FS_CHMOD_FILE', (S_IRWXUGO & ~ umask()));
/*
function moveTestFiles()
{
if (!$this->conf['TEST_BASE_PATH'] ||
$this->conf['TEST_BASE_PATH'] == $this->conf['TEST_PHP_SRCDIR']) return;
$this->writemsg("moving files from {$this->conf['TEST_PHP_SRCDIR']} to {$this->conf['TEST_BASE_PATH']}\n");
$l = strlen($this->conf['TEST_PHP_SRCDIR']);
$files = array();
$dirs = array();
foreach ($this->test_files as $file) {
if (strpos($file,$this->conf['TEST_PHP_SRCDIR'])==0) {
$newlocation = $this->conf['TEST_BASE_PATH'].substr($file,$l);
$files[] = $newlocation;
$dirs[dirname($file)] = dirname($newlocation);
} else {
// XXX what to do with test files outside the
// php source directory? Need to map them into
// the new directory somehow.
}
}
foreach ($dirs as $src=>$new) {
mkpath($new);
copyfiles($src,$new);
}
$this->test_files = $files;
}
function findFilesInDir($dir,$is_ext_dir=FALSE,$ignore=FALSE)
{
$skip = array('.', '..', 'CVS');
$o = opendir($dir) or $this->error("cannot open directory: $dir");
while (($name = readdir($o)) !== FALSE) {
if (in_array($name, $skip)) continue;
if (is_dir("$dir/$name")) {
$skip_ext = ($is_ext_dir && !in_array($name, $this->exts_to_test));
if ($skip_ext) {
$this->exts_skipped++;
}
$this->findFilesInDir("$dir/$name", FALSE, $ignore || $skip_ext);
}
// Cleanup any left-over tmp files from last run.
if (substr($name, -4) == '.tmp') {
@unlink("$dir/$name");
continue;
}
// Otherwise we're only interested in *.phpt files.
if (substr($name, -5) == '.phpt') {
if ($ignore) {
$this->ignored_by_ext++;
} else {
$testfile = realpath("$dir/$name");
$this->test_files[] = $testfile;
}
}
}
closedir($o);
}
$compression = 0;
$output_file = $CUR_DIR . '/php_test_results_' . date('Ymd_Hi') . '.txt';
if ($compression) {
$output_file = 'compress.zlib://' . $output_file . '.gz';
}
*/
/**
* AA_DEBUG
*
* @package
* @author life
* @copyright Copyright (c) 2010
* @version $Id$
* @access public
*/
class AA_DEBUG
{
var $options = array(); // an array of options and values
var $plugin = array(); // array to hold plugin information
var $debug = 0;
var $old_inis = array();
var $debug_mods = array(
1 => array('included', 'Files included by php'),
2 => array('functions', 'Function Information'),
4 => array('classes', 'Information about Loaded Classes'),
8 => array('globals', 'Global Server/Request Information'),
16 => array('extensions', 'Extensions Loaded by PHP'),
32 => array('defined', 'Defined Constants and variables'),
64 => array('inis', 'Your PHP.ini settings'),
128 => array('phpinfo', 'Information from phpinfo'),
256 => array('permissions','Information about Owner/User/File permissions'),
512 => array('interfaces', 'Declared interfaces in the current script'),
1024 => array('sockets', 'Socket and Stream Debugging'),
2048 => array('rewrites', 'WordPress Rewrites'),
4096 => array('queries', 'View DB Queries')
);
/** AA_DEBUG::AA_DEBUG()
*/
function AA_DEBUG(){}
/** AA_DEBUG::__construct()
*/
function __construct(){/*$this->l("PHP CLASS: AA_DEBUG started!\n\n\n\n\n");@ini_set('memory_limit', '64M');*/$this->t(__FILE__); }
function __destruct(){/*$this->l('PHP CLASS: AA_DEBUG destroyed!');*/$this->t(__FILE__);}
/** AA_DEBUG::LoadOptions()
*/
function LoadOptions()
{
//$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$this->plugin = get_option('askapache_debug_plugin');
$this->options=get_option('askapache_debug_options');
$this->options['rel_path']=$this->relPath(__FILE__);
$this->debug=$this->options['plugin_debug_level'];
//$this->t(__FUNCTION__);
}
/** AA_DEBUG::SaveOptions()
*/
function SaveOptions()
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
update_option('askapache_debug_options', $this->options);
update_option('askapache_debug_plugin', $this->plugin);
$this->t(__FUNCTION__);
}
/** AA_DEBUG::DefaultOptions()
*/
function DefaultOptions()
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
delete_option("askapache_debug_options");
delete_option("askapache_debug_plugin");
// get all the plugin array data
$this->plugin = $this->get_plugin_data('tools');
$this->options=array(
'logfile' => $this->get_error_log(),
'log_errors' => '0',
'debug_live' => '0',
'admin_footer' => '1',
'wp_footer' => '0',
'error_reporting' => 4983,
'error_level' => 4983,
'plugin_debug_level' => 0,
'debug_mods_verbose' => 0,
'debug_mods' => 0
);
//add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
add_option('askapache_debug_options', $this->options);
add_option('askapache_debug_plugin', $this->plugin);
// Save all these variables to database
$this->t(__FUNCTION__);
$this->SaveOptions();
}
/*
if (file_exists(ABSPATH . 'wp-config.php'))
!defined('SAVEQUERIES') && define('SAVEQUERIES', false);
$configFile=ABSPATH.'wp-config.php
foreach ($configFile as $line_num => $line) {
switch (substr($line,0,16)) {
case "define('DB_NAME'":
$configFile[$line_num] = str_replace("database_name_here", $dbname, $line);
break;
case "define('DB_USER'":
$configFile[$line_num] = str_replace("'username_here'", "'$uname'", $line);
break;
case "define('DB_PASSW":
$configFile[$line_num] = str_replace("'password_here'", "'$passwrd'", $line);
break;
case "define('DB_HOST'":
$configFile[$line_num] = str_replace("localhost", $dbhost, $line);
break;
case '$table_prefix =':
$configFile[$line_num] = str_replace('wp_', $prefix, $line);
break;
case "define('AUTH_KEY":
case "define('SECURE_A":
case "define('LOGGED_I":
case "define('NONCE_KE":
case "define('AUTH_SAL":
case "define('SECURE_A":
case "define('LOGGED_I":
case "define('NONCE_SA":
$configFile[$line_num] = str_replace('put your unique phrase here', $secret_keys[$key++], $line );
break;
}
}
if ( ! is_writable(ABSPATH) ) :
display_header();
$handle = fopen(ABSPATH . 'wp-config.php', 'w');
foreach( $configFile as $line ) {
fwrite($handle, $line);
}
fclose($handle);
chmod(ABSPATH . 'wp-config.php', 0666);
$result = array();
if ($lines = explode("\n", implode('', file($file))))
{
$state = false;
if (!$f = $this->_fopen($file, 'w')) return $this->to_log("$this->_deactivate_sid couldnt fopen {$file}");
foreach ($markerdata as $n => $line)
{
if (strpos($line, "# +{$mark}{$sid}") !== false) $state = true;
if (!$state) $this->_fwrite($f, "{$line}\n");
if (strpos($line, "# -{$mark}{$sid}") !== false) $state = false;
}
}
*/
/** AA_DEBUG::management_page()
*/
function management_page()
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
echo '
AskApache Debugging Options
';
printf( "UMASK: %04o | DIR: %04o | FILE: %04o ", umask(), (0755 & ~ umask()), (0644 & ~ umask()).'
');
echo '
';
if($this->d(3)) $this->pp(array('POST' => $_POST,'options' => $this->options));
echo '
';
$this->t(__FUNCTION__);
}
/** AA_DEBUG::admin_footer()
*/
function admin_footer()
{
if(!current_user_can('administrator'))return;
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$this->LoadOptions();
if($this->options['admin_footer']!='1') return;
ob_start();
echo "{$this->plugin['plugin-name']} {$this->plugin['version']} Debugging Information
";
$oa = array();
foreach ( array_keys($this->debug_mods) as $k=>$id )
{
if( ($this->options['debug_mods'] & $id) == $id ) $oa[strtoupper($this->debug_mods[$id][0])] = $this->{'get_debug_'.$this->debug_mods[$id][0]}( ($this->options['debug_mods_verbose'] & $id)==$id );
}
if($this->d(10))
{
$oa['Debug Mods']=$this->debug_mods;
$oa['Plugin Options'] = array( 'askapache_debug_options' => $this->options );
$oa['Plugin Information'] = array( 'askapache_debug_plugin' => $this->plugin );
}
foreach ( $oa as $ar => $val )
{
if ( !!!$val ) continue;
echo "\n\n
{$ar}
\n";
foreach ( (array)$val as $key => $va ) { if ( !!!$va ) continue; echo "\n\n{$key}
\n";$this->pp($va); }
}
echo ' ';
echo ob_get_clean();
$this->t(__FUNCTION__);
}
/** AA_DEBUG::wp_footer()
*/
function wp_footer()
{
if(!current_user_can('administrator'))return;
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$this->LoadOptions();
if($this->options['wp_footer']!='1') return;
ob_start();
echo "{$this->plugin['plugin-name']} {$this->plugin['version']} Debugging Information
";
$oa = array();
foreach ( array_keys($this->debug_mods) as $k=>$id )
{
if( ($this->options['debug_mods'] & $id) == $id ) $oa[strtoupper($this->debug_mods[$id][0])] = $this->{'get_debug_'.$this->debug_mods[$id][0]}( ($this->options['debug_mods_verbose'] & $id)==$id );
}
if($this->d(10))
{
$oa['Debug Mods']=$this->debug_mods;
$oa['Plugin Options'] = array( 'askapache_debug_options' => $this->options );
$oa['Plugin Information'] = array( 'askapache_debug_plugin' => $this->plugin );
}
foreach ( $oa as $ar => $val )
{
if ( !!!$val ) continue;
echo "\n\n
{$ar}
\n";
foreach ( (array)$val as $key => $va ) { if ( !!!$va ) continue; echo "\n\n{$key}
\n";$this->pp($va); }
}
echo ' ';
echo ob_get_clean();
$this->t(__FUNCTION__);
}
/** AA_DEBUG::live_debug()
*/
function live_debug()
{
$this->LoadOptions();
if ( $this->options['debug_live'] !== '1' ) return;
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
static $started = false;
if ( $started === true )
{
// using ini_restore for now until i figure out how to make it more secure (from malicious ini settings another plugin might try)
foreach ( (array )$this->old_inis as $key => $val ) ini_restore( $key );
return error_reporting( $this->old_inis['error_reporting'] );
}
$ini_overwrites = array(
//'output_handler' => '',
'open_basedir' => '',
//'session.auto_start' => '0',
'tidy.clean_output' => 'Off',
//'zlib.output_compression' => 'Off',
'xdebug.default_enable' => 'Off',
'mbstring.func_overload' => 'Off',
'error_prepend_string' => '',
'error_append_string' => '',
'auto_prepend_file' => '',
'auto_append_file' => '',
'disable_functions' => '',
'safe_mode' => 'Off',
//'output_buffering' => 'Off',
'error_reporting' => $this->options['error_level'],
'display_errors' => 'Off',
'display_startup_errors' => 'Off',
'log_errors' => $this->options['log_errors'],
'html_errors' => 'Off',
'track_errors' => 'On',
'report_memleaks' => 'On',
//'report_zend_debug' => 'Off',
//'magic_quotes_runtime' => 'Off',
'ignore_repeated_errors' => 'On',
'ignore_repeated_source' => 'On',
//'precision'=>'14',
'log_errors_max_len'=>'1000240'
);
foreach ( $ini_overwrites as $key => $newval )
{
$this->old_inis[$key] = ($key=='error_reporting' ? error_reporting() : strval( ini_get($key) ));
ini_set( $key, $newval );
}
if ( WP_DEBUG_DISPLAY ) ini_set( 'display_errors', 1 );
if ( WP_DEBUG_LOG ) ini_set( 'log_errors', 1 );
if ( WP_DEBUG_DISPLAY ) ini_set( 'display_errors', 1 );
$started = true;
//error_reporting( (version_compare(phpversion(), '5.0', '>=')) ? E_ALL | E_STRICT : E_ALL );
return true;
}
/** AA_DEBUG::handle_post()
*/
function handle_post()
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
if (isset($_POST['save_debug_options']))
{
if ( !wp_verify_nonce($_POST['_wpnonce'], 'aadebug_settings_form') ) wp_die( 'ERROR: Incorrect Form Submission, please try again.' );
foreach(array('log_errors','debug_live','admin_footer','wp_footer') as $k) $this->options["{$k}"] = (isset($_POST["{$k}"]) ? '1' : '0');
if( isset($_POST['log_errors']) || empty($this->options['logfile']) ) $this->options['logfile']=$this->get_error_log();
if (isset($_POST['logfile']) && !empty($_POST['logfile'])) $this->options['logfile'] = trim($_POST['logfile']);
if (isset($_POST['error_level'])){
$this->options['error_level'] = intval($_POST['error_level']);
if(strpos($_POST['error_level'],'E')!==FALSE) $this->options['error_level']=$this->string2error(trim($_POST['error_level'],'|'));
elseif(strpos($_POST['error_level'],'|')!==FALSE) $this->options['error_level']=$this->string2error($this->error2string(trim($_POST['error_level'],'|')));
}
if (isset($_POST['plugin_debug_level']))$this->options['plugin_debug_level'] = intval($_POST['plugin_debug_level']);
if (isset($_POST['error_reporting']) && ($this->options['error_reporting'] = 0)==0)
foreach( array_map( 'intval', (array) $_POST['error_reporting'] ) as $bit) $this->options['error_reporting'] |= $bit;
if (isset($_POST['debug_mods']) && ($this->options['debug_mods'] = 0)==0)
foreach(array_map( 'intval', (array) $_POST['debug_mods'] ) as $bit) $this->options['debug_mods'] |= $bit;
if (isset($_POST['debug_mods_verbose']) && ($this->options['debug_mods_verbose'] = 0)==0)
foreach(array_map( 'intval', (array) $_POST['debug_mods_verbose'] ) as $bit) $this->options['debug_mods_verbose'] |= $bit;
$this->SaveOptions();
}
$this->t(__FUNCTION__);
}
/** AA_DEBUG::get_plugin_data()
*
* @param string $type
*/
/*
[askapache_debug_plugin] => Array
[plugin-name] => AskApache Debug Viewer
[short-name] => AA Debug
[description] => Displays Advanced Debugging Output
[author] => AskApache
[version] => 1.1.1
[requires-at-least] => 2.7
[tested-up-to] => 3.0
[tags] => debug, debugging, error, errors, problems, support, admin, programmer, developer, plugin, development, information, stats, logs
[contributors] => AskApache
[wordpress-uri] => http://wordpress.org/extend/plugins/askapache-debug-viewer/
[author-uri] => http://www.askapache.com/
[donate-uri] => http://www.askapache.com/donate/
[plugin-uri] => http://www.askapache.com/wordpress/deb
[title] => AskApache Debug Viewer
[pb] => askapache-debug-viewer/askapache-debug-viewer.php
[page] => askapache-debug-viewer.php
[pagenice] => askapache-debug-viewer
[nonce] => form_askapache-debug-viewer
[hook] => tools_page_askapache-debug-viewer
[action] => tools.php?page=askapache-debug-viewer.php
[op] => adv_
*/
function get_plugin_data($type='settings')
{
$pp = get_option("askapache_debug_plugin");
if(is_array($pp) && sizeof($pp)>10) return $pp;
$data = $this->_readfile(__FILE__, 750);
$mtx = $plugin = array();
preg_match_all('/[^a-z0-9]+((?:[a-z0-9]{2,25})(?:\ ?[a-z0-9]{2,25})?(?:\ ?[a-z0-9]{2,25})?)\:[\s\t]*(.+)/i', $data, $mtx, PREG_SET_ORDER);
foreach ($mtx as $m) $plugin[trim(str_replace(' ', '-', strtolower($m[1])))] = str_replace(array("\r", "\n", "\t"), '', trim($m[2]));
$plugin['title'] = '' . $plugin['plugin-name'] . '';
$plugin['author'] = '' . $plugin['author'] . '';
$plugin['pb'] = preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__);
$plugin['page'] = basename(__FILE__);
$plugin['pagenice'] = rtrim($plugin['page'], '.php');
$plugin['nonce'] = 'form_' . $plugin['pagenice'];
$plugin['hook'] = $type.'_page_' . $plugin['pagenice'];
$type = ($type=='settings') ? 'options-general' : $type;
$plugin['action'] = $type.'.php?page=' . $plugin['page'];
if (preg_match_all('#(?:([^\W_]{1})(?:[^\W_]*?\W+)?)?#i', $plugin['pagenice'] . '.' . $plugin['version'], $m, PREG_SET_ORDER))$plugin['op'] = '';
foreach($m as $k) sizeof($k == 2) && $plugin['op'] .= $k[1];
$plugin['op'] = substr($plugin['op'], 0, 3) . '_';
return $plugin;
}
function settings2array($settings, &$ini_settings)
{
foreach($settings as $setting) {
if (strpos($setting, '=') !== false) {
$setting = explode("=", $setting, 2);
$name = trim(strtolower($setting[0]));
$value = trim($setting[1]);
if ($name == 'extension') {
if (!isset($ini_settings[$name])) $ini_settings[$name] = array();
$ini_settings[$name][] = $value;
} else $ini_settings[$name] = $value;
}
}
}
/** AA_DEBUG::_ls()
*
* @param string $folder
* @param integer $levels
*/
function _ls( $folder = '', $levels = 2 )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
if ( empty($folder) || ! $levels ) return false;
$files = array();
if ( ($dir = opendir($folder)) !== false )
{
while ( ($file = readdir($dir)) !== false )
{
if ( in_array($file, array('.', '..')) ) continue;
if ( is_dir($folder . '/' . $file) )
{
$files2 = $this->_ls( $folder . '/' . $file, ($levels - 1) );
if ( $files2 ) $files = array_merge( $files, $files2 );
else $files[] = $folder . '/' . $file . '/';
}
else $files[] = $folder . '/' . $file;
}
}
closedir( $dir );
return $files;
}
/** AA_DEBUG::_pls()
*
* @param string $folder
* @param integer $levels
* @param integer $format
*/
function _pls( $folder = '.', $levels = 2, $format = 1 )
{
// $folder = ($folder=='.') ? getcwd() : realpath(".");
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$list = $fls = array();
$fls = $this->_ls( $folder, $levels );
foreach ( $fls as $file )
{
$fs = $this->_stat( $file );
$list[] = sprintf( "%10s %04s %06s %' 8s %s %' 15s %s", $fs['human'], $fs['octal'], $fs['decimal'], $fs['owner_name'], $fs['group_name'], $fs['size'] . ' bytes', str_replace(dirname($folder), '/', realpath($file)) );
}
echo '';
echo join( "\n", array_merge(array($folder . " Listing"), $list) );
echo '
';
}
/** AA_DEBUG::_is_readable()
*
* @param mixed $fl
*/
function _is_readable( $fl )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
if ( is_dir($fl) && ob_start() ) {
$r=is_readable( $fl );
ob_get_clean();
return $r;
}
return ( $this->_file_exists($fl) && (is_readable($fl) || $this->_fclose($this->_fopen($fl, 'rb'))) ) ? true : false;
}
/** AA_DEBUG::_file_exists()
*
* @param mixed $fl
*/
function _file_exists( $fl )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
return ( ((file_exists($fl)) === false && (@realpath($fl)) === false) || ($s = @stat($fl)) === false ) ? false : true;
}
/** AA_DEBUG::_stat()
*
* @param mixed $fl
*/
function _stat( $fl )
{
static $ftypes = false;
if ( !$ftypes ){
!defined('S_IFMT') && define('S_IFMT', 0170000); // mask for all types
!defined('S_IFSOCK') && define('S_IFSOCK', 0140000); // type: socket
!defined('S_IFLNK') && define('S_IFLNK', 0120000); // type: symbolic link
!defined('S_IFREG') && define('S_IFREG', 0100000); // type: regular file
!defined('S_IFBLK') && define('S_IFBLK', 0060000); // type: block device
!defined('S_IFDIR') && define('S_IFDIR', 0040000); // type: directory
!defined('S_IFCHR') && define('S_IFCHR', 0020000); // type: character device
!defined('S_IFIFO') && define('S_IFIFO', 0010000); // type: fifo
!defined('S_ISUID') && define('S_ISUID', 0004000); // set-uid bit
!defined('S_ISGID') && define('S_ISGID', 0002000); // set-gid bit
!defined('S_ISVTX') && define('S_ISVTX', 0001000); // sticky bit
!defined('S_IRWXU') && define('S_IRWXU', 00700); // mask for owner permissions
!defined('S_IRUSR') && define('S_IRUSR', 00400); // owner: read permission
!defined('S_IWUSR') && define('S_IWUSR', 00200); // owner: write permission
!defined('S_IXUSR') && define('S_IXUSR', 00100); // owner: execute permission
!defined('S_IRWXG') && define('S_IRWXG', 00070); // mask for group permissions
!defined('S_IRGRP') && define('S_IRGRP', 00040); // group: read permission
!defined('S_IWGRP') && define('S_IWGRP', 00020); // group: write permission
!defined('S_IXGRP') && define('S_IXGRP', 00010); // group: execute permission
!defined('S_IRWXO') && define('S_IRWXO', 00007); // mask for others permissions
!defined('S_IROTH') && define('S_IROTH', 00004); // others: read permission
!defined('S_IWOTH') && define('S_IWOTH', 00002); // others: write permission
!defined('S_IXOTH') && define('S_IXOTH', 00001); // others: execute permission
!defined('S_IRWXUGO') && define('S_IRWXUGO', (S_IRWXU | S_IRWXG | S_IRWXO));
!defined('S_IALLUGO') && define('S_IALLUGO', (S_ISUID | S_ISGID | S_ISVTX | S_IRWXUGO));
!defined('S_IRUGO') && define('S_IRUGO', (S_IRUSR | S_IRGRP | S_IROTH));
!defined('S_IWUGO') && define('S_IWUGO', (S_IWUSR | S_IWGRP | S_IWOTH));
!defined('S_IXUGO') && define('S_IXUGO', (S_IXUSR | S_IXGRP | S_IXOTH));
!defined('S_IRWUGO') && define('S_IRWUGO', (S_IRUGO | S_IWUGO));
$ftypes = array(S_IFSOCK=>'ssocket',
S_IFLNK=>'llink',
S_IFREG=>'-file',
S_IFBLK=>'bblock',
S_IFDIR=>'ddir',
S_IFCHR=>'cchar',
S_IFIFO=>'pfifo');
}
$s = $ss = array();
if ( ($ss = stat($fl)) === false ) return $this->logg(__FILE__,__FUNCTION__,__LINE__, "Couldnt stat {$fl}");
$p = $ss['mode'];
$t = decoct($p & S_IFMT);
$q = octdec($t);
$type = (array_key_exists($q,$ftypes))?substr($ftypes[$q],1):'?';
$s = array(
'filename' => $fl,
'human' => ( substr($ftypes[$q],0,1)
.(($p & S_IRUSR)?'r':'-')
.(($p & S_IWUSR)?'w':'-')
.(($p & S_ISUID)?(($p & S_IXUSR)?'s':'S'):(($p & S_IXUSR)?'x':'-'))
.(($p & S_IRGRP)?'r':'-')
.(($p & S_IWGRP)?'w':'-')
.(($p & S_ISGID)?(($p & S_IXGRP)?'s':'S'):(($p & S_IXGRP)?'x':'-'))
.(($p & S_IROTH)?'r':'-')
.(($p & S_IWOTH)?'w':'-')
.(($p & S_ISVTX)?(($p & S_IXOTH)?'t':'T'):(($p & S_IXOTH)?'x':'-'))),
'octal' => sprintf("%o",($ss['mode'] & 007777)),
'hex' => sprintf("0x%x", $ss['mode']),
'decimal' => sprintf("%d", $ss['mode']),
'binary' => sprintf("%b", $ss['mode']),
'base_convert' => base_convert($ss['mode'], 10, 8),
'fileperms' => ($this->_cf('fileperms') ? fileperms($fl) : ''),
'mode' => $p,
'fileuid' => $ss['uid'],
'filegid' => $ss['gid'],
'owner_name' => $this->get_posix_info('user', $ss['uid'], 'name'),
'group_name' => $this->get_posix_info('group', $ss['gid'], 'name'),
'dirname' => dirname($fl),
'type_octal' => sprintf("%07o", $q),
'type' => $type,
'device' => $ss['dev'],
'device_number' => $ss['rdev'],
'inode' => $ss['ino'],
'is_file' => is_file($fl) ? 1 : 0,
'is_dir' => is_dir($fl) ? 1 : 0,
'is_link' => is_link($fl) ? 1 : 0,
'is_readable' => is_readable($fl) ? 1 : 0,
'is_writable' => is_writable($fl) ? 1 : 0,
'link_count' => $ss['nlink'],
'size' => $ss['size'],
'blocks' => $ss['blocks'],
'block_size' => $ss['blksize'],
'accessed' => date('Y M D H:i:s', $ss['atime']),
'modified' => date('Y M D H:i:s', $ss['mtime']),
'created' => date('Y M D H:i:s', $ss['ctime']),
'mtime' => $ss['mtime'],
'atime' => $ss['atime'],
'ctime' => $ss['ctime']
);
if ( is_link($fl) ) $s['link_to'] = readlink( $fl );
if ( realpath($fl) != $fl ) $s['real_filename'] = realpath( $fl );
return $s;
}
/** AA_DEBUG::_fclose()
*
* @param mixed $fh
*/
function _fclose( &$fh )
{
$this->t( __FUNCTION__ );
return ( ((@fclose($fh)) !== false && ($fh=null)!== false) || ! is_resource($fh) ) ? true : false;
}
/** AA_DEBUG::_fopen()
*
* @param mixed $file
* @param mixed $mode
*/
function _fopen( $file, $mode )
{
$this->t( __FUNCTION__ );
//$filemodes = array('r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'rb', 'rb+', 'wb', 'wb+', 'ab', 'ab+', 'xb', 'xb+', 'rt', 'rt+', 'wt', 'wt+', 'at', 'at+', 'xt', 'xt+');
// $out='';foreach((array)stream_get_meta_data($fh) as $k=>$v)$out.="$k => $v\n";$this->logg(__FILE__,__FUNCTION__,__LINE__, "$out");
return ( (strspn($mode, 'abrtwx+')==strlen($mode)) && ($fh = @fopen($file, $mode)) !== false ) ? $fh : false;
}
/** AA_DEBUG::_fread()
*
* @param mixed $fh
* @param mixed $ts
* @param integer $bs
*/
function _fread( &$fh, $ts = false, $bs = 2048 )
{
$this->t( __FUNCTION__ );
for ( $d = $b = '', $rt = $at = $r = 0; ($fh !== false && ! feof($fh) && $b !== false && $at < 50000000 && $rt < $ts); $r = $ts - $rt, $bs = (($bs > $r) ? $r : $bs),
$this->t("R: {$rt}"),
$b = fread($fh, $bs), $br = strlen($b), $d .= $b,
$this->t("R: {$rt}"),
$rt += $br, $at++
,$this->logg(__FILE__,__FUNCTION__,__LINE__, " [RT: {$rt}]\t[BR: {$br}" . (($ts != 50000000) ? "]\t\t [{$r} / {$ts}]" : " : {$bs}]\t[{$at}]"))
) ;
$this->t( __FUNCTION__ );
return ( (strlen($d) != 0) ) ? $d : false;
}
/** AA_DEBUG::_fwrite()
*
* @param mixed $fh
* @param mixed $d
* @param integer $bs
*/
function _fwrite( &$fh, $d, $bs = 512 )
{
for ( $bw = $wt = $at = 0, $ts = strlen($d), $this->logg(__FILE__,__FUNCTION__,__LINE__, " starting write.. {$ts} bytes total with blocksize {$bs}");
($fh !== false && $bw !== false && $at < 1000 && $wt < $ts);
$r = $ts - $wt, $bs = ($bs > $r) ? $r : $bs, $bw = fwrite($fh, substr($d, $wt), $bs), $wt += $bw, $at++ );
$this->logg(__FILE__,__FUNCTION__,__LINE__, " {$at}: {$bw} / {$wt} of {$ts}" );
return ( $wt == $ts ) ? true : false;
}
/** AA_DEBUG::_readfile()
*
* @param mixed $file
* @param mixed $len
*/
function _readfile( $file, $len = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
if ( ! $this->_file_exists($file) ) return $this->logg(__FILE__,__FUNCTION__,__LINE__, "no such file! {$file}");
if ( ! $len ) $len = filesize( $file );
if ( ($fh = $this->_fopen($file, 'rb')) === false ) return $this->logg(__FILE__,__FUNCTION__,__LINE__, "Error opening rb handle for {$file}");
$data = $this->_fread( $fh, $len );
return ( ! $this->_fclose($fh) ) ? $this->logg(__FILE__,__FUNCTION__,__LINE__, "Error closing rb handle on {$file}") : $data;
}
/** AA_DEBUG::_mkdir()
*
* @param mixed $dir
* @param integer $mode
*/
function _mkdir( $dir, $mode = 0755 )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
if ( ! wp_mkdir_p($dir) ) return $this->logg(__FILE__,__FUNCTION__,__LINE__, "Couldnt create directory! ${dir}" );
}
/** AA_DEBUG::_rmdir()
*
* @param mixed $dir
*/
function _rmdir( $dir )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$dir = rtrim( str_replace('//', '/', $dir), '/' );
if ( is_dir($dir) && ! is_link($dir) )
{
$d = dir( $dir );
while ( false !== ($r = $d->read()) )
{
if ( $r == "." || $r == ".." || (($f = $d->path . '/' . $r) && is_link($f)) ) continue;
if ( ! $this->_rmdir($f) ) return $this->logg(__FILE__,__FUNCTION__,__LINE__, "Error Deleting: " . $f);
}
$d->close();
return rmdir( $dir );
}
else return $this->_unlink( $dir );
}
/** AA_DEBUG::_unlink()
*
* @param mixed $f
*/
function _unlink( $f )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
if ( unlink($f) || ! $this->_file_exists($f) ) return true;
if ( ! $this->_file_exists($f) ) return true;
if ( is_dir($f) ) return $this->_rmdir( $f );
else chmod( $f, FS_CHMOD_DIR );
return ( unlink($f) || ! $this->_file_exists($f) );
}
/** AA_DEBUG::_is_writable()
*
* @param mixed $fl
*/
function _is_writable( $fl )
{
// if ( is_dir( $fl ) || $fl{strlen( $fl ) - 1} == '/' ) $fl = $this->tslashit($fl).microtime().'.tmp';
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
if ( is_writable($fl) || touch($fl) ) return true;
$exists = ( bool )$this->_file_exists( $fl );
$dir = ( bool )is_dir( $fl );
if ( $exists && ! @chmod($fl, FS_CHMOD_FILE) && ! @chmod(dirname($file), FS_CHMOD_DIR) && ! @chmod($file, FS_CHMOD_FILE) && ! @touch($fl) ) return false;
if ( $dir === true ) $tfl = $fl . '/' . $this->_get_rand_str( 8 ) . '.tmp';
$w = ( bool )( $this->_fclose($this->_fopen($fl, 'a')) || $this->_fclose($this->_fopen($fl, 'x')) || $this->_fclose($this->_fopen($fl, 'w')) ) ? true : false;
if ( $d === true || $e === false ) $this->_unlink( $fl );
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
return $w;
}
function relPath($dest)
{
$dest = realpath($dest);
$path_separator = (substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : $path_separator = '/';
$Ahere = explode($path_separator, realpath(dirname(__FILE__) . $path_separator . '..'));
$Adest = explode($path_separator, $dest);
$result = '.';
// && count ($Adest)>0 && count($Ahere)>0 )
while (implode($path_separator, $Adest) != implode($path_separator, $Ahere)) {
if (count($Ahere) > count($Adest)) {
array_pop($Ahere);
$result .= $path_separator . '..';
} else array_pop($Adest);
}
return str_replace($path_separator . $path_separator, $path_separator, $result . str_replace(implode($path_separator, $Adest), '', $dest));
}
/** AA_DEBUG::_get_rand_str()
*
* @param mixed $l
* @param mixed $c
*/
function _get_rand_str($l=null,$c=null)
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
static $chars;
!is_null($c) && $chars=$c;
is_null($chars) && $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
is_null($l) && $l = rand(4,8);
return substr(str_shuffle($chars . $chars . $chars), 0, $l);
$this->t(__FUNCTION__);
}
/** AA_DEBUG::_stripdeep()
*
* @param mixed $value
*/
function _stripdeep(&$value){ return(is_array($value) ? array_map(array($this,'_stripdeep'), $value) : stripslashes($value));}
/** AA_DEBUG::_parse_args()
*
* @param mixed $a
* @param string $d
* @param string $r
*/
function _parse_args($a,$d='',$r=''){ return(false!==($r=(is_object($a)?get_object_vars($a):((!is_array($a)&&false!==(parse_str($a,$r)))?$r:$a)))&&is_array($d)?array_merge($d,$r):$r); }
function wb($id)
{
//$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$id=intval($id);
$o=array();
if( ($id & 1) == 1 ) $o[]=1;
if( ($id & 2) == 2 ) $o[]=2;
if( ($id & 4) == 4 ) $o[]=4;
if( ($id & 8) == 8 ) $o[]=8;
if( ($id & 16) == 16 ) $o[]=16;
if( ($id & 32) == 32 ) $o[]=32;
if( ($id & 64) == 64 ) $o[]=64;
if( ($id & 128) == 128 ) $o[]=128;
if( ($id & 256) == 256 ) $o[]=256;
if( ($id & 512) == 512 ) $o[]=512;
if( ($id & 1024) == 1024 ) $o[]=1024;
if( ($id & 2048) == 2048 ) $o[]=2048;
if( ($id & 4096) == 4096 ) $o[]=4096;
if( ($id & 8192) == 8192 ) $o[]=8192;
if( ($id & 16384) == 16384 ) $o[]=16384;
if( ($id & 32768) == 32768 ) $o[]=32768;
return $o;
/*
$o='';
if( ($id & 1) == 1 ) $o.="|".$array[1][0];
if( ($id & 2) == 2 ) $o.="|".$array[2][0];
if( ($id & 4) == 4 ) $o.="|".$array[4][0];
if( ($id & 8) == 8 ) $o.="|".$array[8][0];
if( ($id & 16) == 16 ) $o.="|".$array[16][0];
if( ($id & 32) == 32 ) $o.="|".$array[32][0];
if( ($id & 64) == 64 ) $o.="|".$array[64][0];
if( ($id & 128) == 128 ) $o.="|".$array[128][0];
if( ($id & 256) == 256 ) $o.="|".$array[256][0];
echo $id." is ".trim($o,'|')."\n";
*/
}
function _checkedd($val, $d=false)
{
//$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$val=intval($val);
$er=intval($this->options['error_reporting']);
$str=(($val <= $er) && ($er & $val) === $val) ? ' checked="checked"' : '';
if(!$d)return $str;
else echo $str;
}
function _checked($checked, $var, $d=false)
{
$str = '';
if($_SERVER['REQUEST_METHOD']=='POST')if(!isset($_POST[$checked]))return $str;
elseif (!isset($_POST[$checked]) && !isset($this->options[$checked])) return $str;
if(in_array($checked,array('debug_mods','debug_mods_verbose','error_reporting'))) $str = ( in_array($var, $this->wb($this->options[$checked]) ) ? ' checked="checked"' : '' );
else {
$checked = (isset($_POST[$checked])) ? $_POST[$checked] : $this->options[$checked];
if (is_array($checked) && in_array($var, $checked)) $str = ' checked="checked"';
elseif ($checked == $var || $checked === true) $str = ' checked="checked"';
}
if(!$d)return $str;
else echo $str;
return;
}
/** AA_DEBUG::_cf()
*
* @param mixed $f
*/
function _cf($f)
{
static $b=NULL,$g = array();
if(is_null($b)) $b = ( function_exists('ini_get') ) ? explode(',',strtolower(ini_get('disable_functions'))) : array();
if ( false!==($f=strtolower($f)) && ( in_array($f, $g) || in_array($f, $b)) ) return (in_array($f, $g));
return (!function_exists($f)) ? !( $b[] = $f ) : !!( $g[] = $f );
}
/** AA_DEBUG::mem_usage()
*
* @param mixed $raw
*/
function mem_usage($raw = false)
{
static $v=NULL,$m=NULL;
if(is_null($m)) $m = $this->_cf('memory_get_usage');
if ($m === false) return 1;
if(is_null($v)) $v = version_compare(phpversion(), '5.2.0', '>=');
$mem = (($v === false) ? memory_get_usage(true) : memory_get_usage());
return(($raw !== false) ? $this->bytes($mem) : $mem);
}
/** AA_DEBUG::bytes()
*
* @param integer $b
*/
function bytes($b = 0)
{
static $s=NULL;
if(is_null($s)) $s = array('B', 'Kb', 'MB', 'GB', 'TB', 'PB');
$e = floor(log($b) / log(1024));
return sprintf('%.2f ' . $s[$e], (($b > 0) ? ($b / pow(1024, floor($e))) : 0));
}
/** AA_DEBUG::_do_update()
*
* @param mixed $check_time
* @param integer $newer_than
*/
function _do_update( $check_time, $newer_than = 300 )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$time = ( time() - $check_time );
return ( $newer_than < $time ) ? true : false;
}
/** AA_DEBUG::pp()
*
* @param mixed $text
* @param integer $format
*/
function pp( $obj, $format = 1 )
{
$out='';
if (is_array($obj) || is_object($obj)) $out.="\n".print_r($obj,1)."\n";
else {
if(is_string($obj))$out.=$obj;
else { ob_start(); var_dump($obj); $out.=ob_get_clean();}
}
printf( '%s
', htmlspecialchars($out) );
return true;
}
function tt($id = 'new', $d = false)
{
static $a = array();
$ct = array_sum(explode(chr(32), microtime()));
if (!isset($a[$id])) {
$a[$id] = $ct;
return '';
}
elseif ($d) return sprintf("%.4f", ($ct - $a[$id]));
else return;
}
function t($f = '')
{
if (($this->tt($f, 1)) == '') return;
elseif($this->d(5))$this->l('PHP AA DEBUG: TIME: [' . $this->tt($f, 1)."] [" . $this->tt(__FILE__, 1)."] [".$this->mem_usage(1)."] {$f}()", 0);
}
function d($level=0)
{
return (bool) ( isset($GLOBALS["aa_debug_object"]) && absint($GLOBALS["aa_debug_object"]->debug) >= absint($level) ) ? true : false;
}
function logg($f='', $fu='', $l='', $m='')
{
$this->t($fu);
$msg="PHP AA DEBUG Notice: ".$this->relPath(__FILE__)."::{$fu}() [$l] {$m}";
$this->l("$msg");
}
function l($msg)
{
if($this->options['log_errors']=='1')error_log($msg);
return;
}
/** AA_DEBUG::get_error_log()
$log_file
*/
function get_error_log()
{
// If this directive is not set, errors are sent to the SAPI error logger. For example, it is an error log in Apache or stderr in CLI.
$log_file_ini=strval(ini_get('error_log'));
$this->l("log_file_ini: $log_file_ini");
//(( defined('WP_DEBUG_LOG') && WP_DEBUG_LOG===TRUE ) ? WP_CONTENT_DIR . '/debug.log' : FALSE);
$log_file_wp=WP_CONTENT_DIR . '/debug.log';
$this->l("log_file_wp: $log_file_wp");
$log_file_opt = $this->options['logfile'];
$this->l("log_file_opt: $log_file_opt");
if(!empty($log_file_opt))$log_file=$log_file_opt;
elseif(!empty($log_file_ini))$log_file=$log_file_ini;
elseif(!empty($log_file_wp))$log_file=$log_file_wp;
//$log_file = ( is_array($this->options) && isset($this->options['logfile']) ) ? $this->options['logfile'] : @ini_get( 'error_log' );
return $log_file;
}
/** AA_DEBUG::get_error_levels()
*/
function get_error_levels()
{
/*
$err_type = array (
1 => "Error", // E_ERROR
2 => "Warning", // E_WARINING
4 => "Parsing Error", // E_PARSE
8 => "Notice", // E_NOTICE
16 => "Core Error", // E_CORE_ERROR
32 => "Core Warning", // E_CORE_WARNING
64 => "Compile Error", // E_COMPILE_ERROR
128 => "Compile Warning", // E_COMPILE_WARNING
256 => "User Error", // E_USER_ERROR
512 => "User Warning", // E_USER_WARMING
1024=> "User Notice", // E_USER_NOTICE
2048=> "Strict Notice", // E_STRICT
4096=> "Catchable fatal error", // E_RECOVERABLE_ERROR
);
*/
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$error_levels=array(
'E_ERROR',
'E_WARNING',
'E_PARSE',
'E_NOTICE',
'E_CORE_ERROR',
'E_CORE_WARNING',
'E_COMPILE_ERROR',
'E_COMPILE_WARNING',
'E_USER_ERROR',
'E_USER_WARNING',
'E_USER_NOTICE',
'E_STRICT',
'E_RECOVERABLE_ERROR',
'E_DEPRECATED',
'E_USER_DEPRECATED',
'E_ALL'
);
$eany=0;
foreach($error_levels as $k) {
if(defined($k))$eany |= $e[$k]=$ev=constant($k);
}
$e['E_ANY']=$eany;
return $e;
}
function error_level_setup()
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$error_levels=array(
1 => array('E_ERROR', 'Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted.'),
2 => array('E_WARNING', 'Run-time warnings Execution of the script is not halted.'),
4 => array('E_PARSE', 'Compile-time parse errors. Parse errors should only be generated by the parser.'),
8 => array('E_NOTICE', 'Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.'),
16 => array('E_CORE_ERROR', 'Fatal errors that occur during PHPs initial startup. This is like an E_ERROR, except it is generated by the core of PHP.'),
32 => array('E_CORE_WARNING', 'Warnings that occur during PHPs initial startup. This is like an E_WARNING, except it is generated by the core of PHP.'),
64 => array('E_COMPILE_ERROR', 'Fatal compile-time errors. This is like an E_ERROR, except it is generated by the Zend Scripting Engine.'),
128 => array('E_COMPILE_WARNING', 'Compile-time warnings This is like an E_WARNING, except it is generated by the Zend Scripting Engine.'),
256 => array('E_USER_ERROR', 'User-generated error message. This is like an E_ERROR, except it is generated in PHP code by using the PHP function trigger_error().'),
512 => array('E_USER_WARNING', 'User-generated warning message. This is like an E_WARNING, except it is generated in PHP code by using the PHP function trigger_error().'),
1024 => array('E_USER_NOTICE', 'User-generated notice message. This is like an E_NOTICE, except it is generated in PHP code by using the PHP function trigger_error().'),
2048 => array('E_STRICT', 'Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code.'),
4096 => array('E_RECOVERABLE_ERROR', 'Catchable fatal error. It indicates a probably dangerous error occured. If the error is not caught by a user defined handle, the application aborts E_ERROR.'),
8192 => array('E_DEPRECATED', 'Run-time notices. Enable this to receive warnings about code that will not work in future versions.'),
16384 => array('E_USER_DEPRECATED', 'User-generated warning message. This is like an E_DEPRECATED, except it is generated in PHP code by using the PHP function trigger_error().'),
30719 => array('E_ALL', 'All errors and warnings, as supported, except of level E_STRICT.')
);
echo '';
$res=$re=array();$bit = intval(error_reporting());
while ($bit > 0) {
for($i = 0, $n = 0; $i <= $bit; $i = 1 * pow(2, $n), $n++)$end = $i;
$res[] =array($end,$this->error2string($end),$error_levels[$end][1]);
$re[]=$this->error2string($end);
$bit -= $end;
}
echo '
error_reporting('.implode('|',$re).');
';
echo '
';
foreach($res as $k=>$v) echo "- {$v[1]} ({$v[0]}): {$v[2]}
";
echo '
';
$e=array();$eany=$kk=0;
foreach(array_keys($error_levels) as $k) {
$kk=$error_levels[$k][0];
if(defined($kk))$eany |= $e[$kk]=$ev=constant($kk);
}
$e['E_ANY']=$eany;
echo 'Old error_reporting: '.intval($this->old_inis['error_reporting']).'
';
echo 'Current error_reporting: '.intval(error_reporting()) . ' '. $eany.' '.$this->error2string($eany).'
';
echo 'Recommended wp-config.php Settings
';
echo '
This is just a recommendation, this is not editable. Add this to your wp-config.php at the bottom BEFORE the wp-settings is included. This is of course, unneccessary if you can modify your php.ini - See my wp-config.php tutorial.
';
echo '
';
echo 'PHP Error Handling Configuration Settings (current|original)
';
foreach ( array('error_reporting','display_errors','display_startup_errors','log_errors','log_errors_max_len','ignore_repeated_errors','ignore_repeated_source','report_memleaks','track_errors','html_errors','xmlrpc_errors','xmlrpc_error_number','docref_root','docref_ext','error_prepend_string','error_append_string','error_log') as $k)
printf('- %1$s: %2$s | %3$s
', $k, @ini_get($k), @get_cfg_var($k) );
echo '
';
$this->t(__FUNCTION__);
}
function string2error($string)
{
$l_ns = array( 'E_ERROR', 'E_WARNING', 'E_PARSE', 'E_NOTICE',
'E_CORE_ERROR', 'E_CORE_WARNING', 'E_COMPILE_ERROR', 'E_COMPILE_WARNING',
'E_USER_ERROR', 'E_USER_WARNING', 'E_USER_NOTICE', 'E_ALL' );
if(defined('E_USER_DEPRECATED')) $l_ns[]='E_USER_DEPRECATED';
if(defined('E_DEPRECATED')) $l_ns[]='E_DEPRECATED';
if(defined('E_STRICT')) $l_ns[]='E_STRICT';
if(defined('E_RECOVERABLE_ERROR')) $l_ns[]='E_RECOVERABLE_ERROR';
$value=0;
$ls=explode('|',$string);
foreach($ls as $l)
{
$l=trim($l);
if(defined($l)) $value|=(int)constant($l);
}
return $value;
}
function error2string($v)
{
$l_ns = array(
E_ERROR => 'E_ERROR',
E_WARNING => 'E_WARNING',
E_PARSE => 'E_PARSE',
E_NOTICE => 'E_NOTICE',
E_CORE_ERROR => 'E_CORE_ERROR',
E_CORE_WARNING => 'E_CORE_WARNING',
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
E_USER_ERROR => 'E_USER_ERROR',
E_USER_WARNING => 'E_USER_WARNING',
E_USER_NOTICE => 'E_USER_NOTICE'
);
if(defined('E_USER_DEPRECATED')) $l_ns[E_USER_DEPRECATED]='E_USER_DEPRECATED';
if(defined('E_DEPRECATED')) $l_ns[E_DEPRECATED]='E_DEPRECATED';
if(defined('E_STRICT')) $l_ns[E_STRICT]='E_STRICT';
if(defined('E_RECOVERABLE_ERROR')) $l_ns[E_RECOVERABLE_ERROR]='E_RECOVERABLE_ERROR';
$ls=array();
if(($v&E_ALL)==E_ALL)
{
$ls[]='E_ALL';
$v&=~E_ALL;
}
foreach($l_ns as $l=>$n) if(($v&$l)==$l) $ls[]=$n;
return implode(' | ',$ls);
}
/** AA_DEBUG::get_posix_info()
*
* @param string $type
* @param string $id
* @param mixed $item
*/
function get_posix_info( $type = 'all', $id = '', $item = false )
{
static $egid,$pwuid,$grgid,$euid;
if(!$egid && $this->_cf('posix_getegid')) $egid=posix_getegid();
if(!$euid && $this->_cf('posix_geteuid')) $euid=posix_geteuid();
if(!$pwuid && $this->_cf('posix_getpwuid')) $pwuid=posix_getpwuid($egid);
if(!$grgid && $this->_cf('posix_getgrgid')) $grgid=posix_getgrgid($euid);
// 'Group Info by Name' => array('posix_getgrnam', $group_info['name'] )
//$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
//$ownerIsMe = PHP_OS == 'WIN' ? fileowner(__FILE__) == getmyuid() : function_exists( 'posix_geteuid' ) && fileowner(__FILE__) == posix_geteuid();
/*
if( !(function_exists('posix_geteuid'))) {
function posix_geteuid() {
return false;
}
}
*/
/*
if ( function_exists('curl_init') ) {
return true;
} else {
return false;
}
return extension_loaded('curl');
*/
/*
strpos(php_sapi_name(), 'cgi') === 0
preg_match( "|uid=(\d+)\((\S+)\)\s+gid=(\d+)\((\S+)\)\s+groups=(.+)|i",
$id_raw,
$matches);
if ($matches[5]) {
$gs = $matches[5];
$gs = explode(',', $gs);
foreach ($gs as $groupstr) {
preg_match("/(\d+)\(([^\)]+)\)/", $groupstr, $subs);
$groups[$subs[1]] = $subs[2];
}
ksort($groups);
$id_data['groups'] = $groups;
}
if (!$success && function_exists("posix_getpwuid") && function_exists("posix_geteuid") && function_exists('posix_getgrgid') && function_exists('posix_getgroups') ) {
$data = posix_getpwuid( posix_getuid() );
$id_data['uid'] = $data['uid'];
$id_data['username'] = $data['name'];
$id_data['gid'] = $data['gid'];
//$group_data = posix_getgrgid( posix_getegid() );
//$id_data['group'] = $group_data['name'];
$groups = posix_getgroups();
foreach ( $groups as $gid ) {
//$group_data = posix_getgrgid(posix_getgid());
$id_data['groups'][$gid] = '';
}
$success = true;
}
*/
/*
$group_desc=array(
'name' => 'The name element contains the name of the group. This is a short, usually less than 16 character "handle" of the group, not the real, full name.',
'passwd' => 'The passwd element contains the group\'s password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead.',
'gid' => 'Group ID, should be the same as the gid parameter used when calling the function, and hence redundant.',
'members' => 'This consists of an array of string\'s for all the members in the group.'
);
$user_desc=array(
'name' => 'The name element contains the username of the user. This is a short, usually less than 16 character "handle" of the user, not the real, full name.',
'passwd' => 'The passwd element contains the user\'s password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead.',
'uid' => 'User ID, should be the same as the uid parameter used when calling the function, and hence redundant.',
'gid' => 'The group ID of the user.',
'gecos' => 'The field contains a comma separated list containing the user\'s full name, office phone, office number, and home phone number. On most systems, only the user\'s full name is available.',
'dir' => 'This element contains the absolute path to the home directory of the user.',
'shell' => 'The shell element contains the absolute path to the executable of the user\'s default shell.'
);
*/
$info = array();
switch ( $type ):
case 'group': $info = ($this->_cf('posix_getgrgid') ? posix_getgrgid( ( (! empty($id)) ? $id : $egid ) ):''); break;
case 'user': $info = ($this->_cf('posix_getpwuid') ? posix_getpwuid( ( (! empty($id)) ? $id : $euid ) ):''); break;
endswitch;
return (( $item !== false && isset($info[$item]) ) ? $info[$item] : $info);
}
/** AA_DEBUG::get_debug_queries()
*/
function get_debug_queries()
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
global $wpdb;
$out = '';
if ($wpdb->queries) {
$x = 0;
$total_time = timer_stop( false, 22 );
$total_query_time = 0;
$class = '';
$out .= '' . "\n";
foreach ($wpdb->queries as $q) {
if ( $x % 2 != 0 )
$class = '';
else
$class = ' class="alt"';
$q[0] = trim( ereg_replace('[[:space:]]+', ' ', $q[0]) );
$total_query_time += $q[1];
$out .= '- ' . __('Time:') . ' ' . $q[1];
if ( isset($q[1]) )
$out .= '
' . __('Query:') . ' ' . htmlentities( $q[0] );
if ( isset($q[2]) )
$out .= '
' . __('Call from:') . ' ' . htmlentities( $q[2] );
$out .= ' ' . "\n";
$x++;
}
$out .= '
' . "\n\n";
}
$php_time = $total_time - $total_query_time;
// Create the percentages
$mysqlper = number_format_i18n( $total_query_time / $total_time * 100, 2 );
$phpper = number_format_i18n( $php_time / $total_time * 100, 2 );
$out .= '' . "\n";
$out .= '- ' . __('Total query time:') . ' ' . number_format_i18n( $total_query_time, 5 ) . __('s for') . ' ' . count($wpdb->queries) . ' ' . __('queries.') . '
';
if ( count($wpdb->queries) != get_num_queries() ) {
$out .= '- ' . __('Total num_query time:') . ' ' . timer_stop() . ' ' . __('for') . ' ' . get_num_queries() . ' ' . __('num_queries.') . '
' . "\n";
$out .= '- ' . __('» Different values in num_query and query? - please set the constant') . '
define(\'SAVEQUERIES\', true);' . __('in your') . ' wp-config.php ' . "\n";
}
if ( $total_query_time == 0 )
$out .= '- ' . __('» Query time is null (0)? - please set the constant') . '
SAVEQUERIES' . ' ' . __('at') . ' TRUE ' . __('in your') . ' wp-config.php ' . "\n";
$out .= '- ' . __('Page generated in'). ' ' . number_format_i18n( $total_time, 5 ) . __('s, ') . $phpper . __('% PHP') . ', ' . $mysqlper . __('% MySQL') . '
' . "\n";
$out .= '
' . "\n";
$this->t(__FUNCTION__);
return array($out);
}
/** AA_DEBUG::get_debug_sockets()
*
*/
function get_debug_sockets($vb=false)
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa = array();
$oe = error_reporting(E_ALL & ~E_WARNING);
foreach(array(
'stream_get_filters',
'stream_get_wrappers',
'stream_get_transports',
'stream_get_filters'
) as $fn)if(($this->_cf($fn))&&ob_start()&&print_r($fn()))$oa[$fn]=ob_get_clean();
//'stream_socket_get_name'=>@stream_socket_get_name($fp),
//'stream_supports_lock'=>@stream_supports_lock($fp),
//))
$fp = fsockopen($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT'], $errno, $errstr);
ob_start();
echo "\n";
$e1=$e2=$e3=$e4=array();
$e1=socket_last_error();
if(is_resource($fp))$e2=socket_last_error($fp);
$e3=socket_strerror(null);
$e4=socket_strerror($e2);
$e5=socket_strerror($e1);
$e5 = ($e5 == $e4) ? '' : "socket_strerror(socket_last_error()) => {$e5}\n";
$e3=( $e3 == $e4 || empty($e3) ) ? '' : "socket_strerror() => {$e3}\n";
$e4="socket_strerror(socket_last_error(fp)) => {$e4}\n";
$e1=( $e1 == $e2 || empty($e1) ) ? '' : "socket_last_error() => {$e1}\n";
$e2=( !empty($e2) ) ? "socket_last_error(fp) => {$e2}\n" : '';
foreach(array($e1,$e2,$e3,$e4,$e5) as $e) if(!empty($e))echo $e;
$s1=$s2=$s3=array();
$s1=socket_get_status($fp);
$s2=stream_get_meta_data($fp);
$s3=stream_context_get_options($fp);
$s1=( is_array($s1) && sizeof($s1) > 0 ) ? print_r($s1,1) : '';
$s2=( is_array($s2) && sizeof($s2) > 0 ) ? print_r($s2,1) : '';
$s3=( is_array($s3) && sizeof($s3) > 0 ) ? print_r($s3,1) : '';
$s3=( empty($s3) ) ? '' : "stream_context_get_options => {$s3}";
$s2=( $s1 == $s2 || empty($s2) ) ? '' : "stream_get_meta_data(fp) => {$s2}";
$s1=( empty($s1) ) ? '' : "socket_get_status(fp) => {$s1}";
foreach(array($s1,$s2,$s3) as $s) if(!empty($s))echo $s;
error_reporting($oe);
$ret=(!is_resource($fp) || !(@fclose($fp) and $fp = null));
$oa['sock']=ob_get_clean();
$this->t(__FUNCTION__);
return $oa;
}
/** AA_DEBUG::get_debug_rewrites()
*
* @param mixed $vb
*/
function get_debug_rewrites( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
global $is_apache, $wp_rewrite, $wp_query;
$oa = array();
$vars=array(
'use_trailing_slashes'=>'Whether to add trailing slashes.',
'use_verbose_rules'=>'Whether to write every mod_rewrite rule for WP. This is off by default',
'use_verbose_page_rules'=>'Whether to write every mod_rewrite rule for WP pages.',
'permalink_structure'=>'Default permalink structure for WP.',
'category_base'=>'Customized or default category permalink base ( askapache.com/xx/tagname ).',
'tag_base'=>'Customized or default tag permalink base ( askapache.com/xx/tagname ).',
'category_structure'=>'Permalink request structure for categories.',
'tag_structure'=>'Permalink request structure for tags.',
'author_base'=>'Permalink author request base ( askapache.com/author/authorname ).',
'author_structure'=>'Permalink request structure for author pages.',
'date_structure'=>'Permalink request structure for dates.',
'page_structure'=>'Permalink request structure for pages.',
'search_base'=>'Search permalink base ( askapache.com/search/query ).',
'search_structure'=>'Permalink request structure for searches.',
'comments_base'=>'Comments permalink base.',
'feed_base'=>'Feed permalink base.',
'comments_feed_structure'=>'Comments feed request structure permalink.',
'feed_structure'=>'Feed request structure permalink.',
'front'=>'Front URL path. If permalinks are turned off. The WP/index.php will be the front portion. If permalinks are turned on',
'root'=>'Root URL path to WP (without domain). The difference between front property is that WP might be located at askapache.com/WP/. The root is the WP/ portion.',
'index'=>'Permalink to the home page.',
'matches'=>'Request match string.',
'rules'=>'Rewrite rules to match against the request to find the redirect or query.',
'extra_rules'=>'Additional rules added external to the rewrite class.',
'extra_rules_top'=>'Additional rules that belong at the beginning to match first.',
'non_wp_rules'=>'Rules that don\'t redirect to WP\'s index.php. These rules are written to the mod_rewrite portion of the .htaccess.',
'extra_permastructs'=>'Extra permalink structures.',
'endpoints'=>'Endpoints permalinks',
'rewritecode'=>'Permalink structure search for preg_replace.',
'rewritereplace'=>'Preg_replace values for the search.',
'queryreplace'=>'Search for the query to look for replacing.',
'feeds'=>'Supported default feeds.',
);
foreach($vars as $k=>$d){
if(!isset($wp_rewrite->$k))continue;
$v=$wp_rewrite->$k;
if(is_bool($v)) $oa[$k]=(($v===true) ? 'TRUE' : 'FALSE');
elseif(is_string($v))$oa[$k]=$v;
elseif(is_array($v) && sizeof($v)>0)
{
$vo='';
foreach($v as $vv) {
if(is_array($vv)) foreach($vv as $vvv) $vo.="{$vvv}\n";
else $vo.="{$vv}\n";
}
echo $oa[$k]=$vo;
}
}
// robots.txt
$robots_rewrite = array('robots\.txt$' => $wp_rewrite->index . '?robots=1');
//Default Feed rules - These are require to allow for the direct access files to work with permalink structure starting with %category%
$default_feeds = array( '.*wp-atom.php$' => $wp_rewrite->index . '?feed=atom',
'.*wp-rdf.php$' => $wp_rewrite->index . '?feed=rdf',
'.*wp-rss.php$' => $wp_rewrite->index . '?feed=rss',
'.*wp-rss2.php$' => $wp_rewrite->index . '?feed=rss2',
'.*wp-feed.php$' => $wp_rewrite->index . '?feed=feed',
'.*wp-commentsrss2.php$' => $wp_rewrite->index . '?feed=rss2&withcomments=1');
// Post
$post_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->permalink_structure, EP_PERMALINK);
$post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
// Date
$date_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_date_permastruct(), EP_DATE);
$date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
// Root
$root_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->root . '/', EP_ROOT);
$root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
// Comments
$comments_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->root . $wp_rewrite->comments_base, EP_COMMENTS, true, true, true, false);
$comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
// Search
$search_structure = $wp_rewrite->get_search_permastruct();
$search_rewrite = $wp_rewrite->generate_rewrite_rules($search_structure, EP_SEARCH);
$search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
// Categories
$category_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_category_permastruct(), EP_CATEGORIES);
$category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);
// Tags
$tag_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_tag_permastruct(), EP_TAGS);
$tag_rewrite = apply_filters('tag_rewrite_rules', $tag_rewrite);
// Authors
$author_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_author_permastruct(), EP_AUTHORS);
$author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
// Pages
$page_rewrite = $wp_rewrite->page_rewrite_rules();
$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
$oa['extra_rules_top']=$wp_rewrite->extra_rules_top;
$oa['robots_rewrite']=$robots_rewrite;
$oa['default_feeds']=$default_feeds;
$oa['page_rewrite']=$page_rewrite;
$oa['root_rewrite']=$root_rewrite;
$oa['comments_rewrite']=$comments_rewrite;
$oa['search_rewrite']=$search_rewrite;
$oa['category_rewrite']=$category_rewrite;
$oa['tag_rewrite']=$tag_rewrite;
$oa['author_rewrite']=$author_rewrite;
$oa['date_rewrite']=$date_rewrite;
$oa['post_rewrite']=$post_rewrite;
$oa['extra_rules']=$wp_rewrite->extra_rules;
$oa['Permastructs']=$this->handle_results(array('get_date_permastruct','get_year_permastruct','get_month_permastruct','get_day_permastruct','get_category_permastruct',
'get_tag_permastruct','get_author_permastruct','get_search_permastruct','get_page_permastruct','get_feed_permastruct','get_comment_feed_permastruct'));
$oa['page_generated']=$this->handle_results(array('page_uri_index','page_rewrite_rules'));
$oa['Rewrite Rules']=$this->handle_results(array('wp_rewrite_rules','mod_rewrite_rules'));
$this->t(__FUNCTION__);
return array($oa);
}
function handle_results($incoming)
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
global $wp_rewrite;
$oa=array();
static $rewrite_methods=false;
if(!$rewrite_methods) $rewrite_methods=get_class_methods( 'WP_Rewrite' );
foreach((array)$incoming as $k) :
if( in_array($k, $rewrite_methods) )$v=$wp_rewrite->{$k}();
elseif( function_exists($k) ) $v=$k();
else continue;
if($k=='mod_rewrite_rules')$v=explode("\n",$v);
if(is_bool($v)) echo $oa[$k]=(($v===true) ? 'TRUE' : 'FALSE');
elseif(is_string($v))$oa[$k]=$v;
elseif(is_array($v) && sizeof($v)>0)
{
$vo='';
foreach($v as $vv) {
if(is_array($vv)) foreach($vv as $vvv) $vo.="{$vvv}\n";
else $vo.="{$vv}\n";
}
$oa[$k]=$vo;
}
endforeach;
$this->t(__FUNCTION__);
return $oa;
}
/** AA_DEBUG::get_debug_interfaces()
*
* @param mixed $vb
*/
function get_debug_interfaces( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa=array();
foreach((array)@get_declared_interfaces() as $k=>$v) $oa[$v]='';
$this->t(__FUNCTION__);
return array($oa);
}
/** AA_DEBUG::get_debug_extensions()
*
* @param mixed $vb
*/
function get_debug_extensions( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa = array();
foreach ( (array )@get_loaded_extensions() as $k => $v ) $oa[$v] = ( $vb === false ) ? '' : ( array )@get_extension_funcs( $v );
$this->t(__FUNCTION__);
return $oa;
}
/** AA_DEBUG::get_debug_functions()
*
* @param mixed $vb
*/
function get_debug_functions( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa = array();
foreach ( array('PHP script Process ID' => 'getmypid',
'PHP script owners UID' => 'getmyuid',
'php_sapi_name' => 'php_sapi_name',
'PHP Uname' => 'php_uname',
'Zend Version' => 'zend_version',
'PHP INI Loaded' => 'php_ini_loaded_file',
'Current Working Directory' => 'getcwd',
'Last Mod' => 'getlastmod',
'Script Inode' => 'getmyinode',
'Script GID' => 'getmygid',
'Script Owner' => 'get_current_user',
'Get Rusage' => 'getrusage',
'Error Reporting' => 'error_reporting',
'Path name of controlling terminal' => 'posix_ctermid',
'Error number set by the last posix function that failed' => 'posix_get_last_error',
'Pathname of current directory' => 'posix_getcwd',
'posix_getpid' => 'posix_getpid',
'posix_uname' => 'posix_uname',
'posix_times' => 'posix_times',
'posix_errno' => 'posix_errno',
'Effective group ID of the current process' => 'posix_getegid',
'Effective user ID of the current process' => 'posix_geteuid',
'Real group ID of the current process' => 'posix_getgid',
'Group set of the current process' => 'posix_getgroups',
'Login name' => 'posix_getlogin',
'Current process group identifier' => 'posix_getpgrp',
'Current process identifier' => 'posix_getpid',
'Parent process identifier' => 'posix_getppid',
'System Resource limits' => 'posix_getrlimit',
'Return the real user ID of the current process' => 'posix_getuid',
'Magic Quotes GPC' => 'get_magic_quotes_gpc',
'Magic Quotes Runtime' => 'get_magic_quotes_runtime') as $t=>$fn) if($this->_cf($fn))$oa[$fn]=$fn();
$this->t(__FUNCTION__);
return array($oa);
}
/** AA_DEBUG::get_debug_included()
*
* @param mixed $vb
*/
function get_debug_included( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa = array();
foreach ( (array)(($this->_cf('get_included_files') ? get_included_files() : array())) as $k => $v )
$oa[$v] = ( $vb === false ) ? '' : $this->_stat( $v );
$this->t(__FUNCTION__);
return array($oa);
}
/** AA_DEBUG::get_debug_permissions()
*
* @param mixed $vb
*/
function get_debug_permissions( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa = array();
foreach ( array('Real Group ID' => ($this->_cf('posix_getgid')) ? posix_getgid() : '',
'Effective Group ID' => ($this->_cf('posix_getegid')) ? posix_getegid() : '',
'Parent Process ID' => ($this->_cf('posix_getppid')) ? posix_getppid() : '',
'Parent Process Group ID' => ($this->_cf('posix_getpgid') && $this->_cf('posix_getppid')) ? posix_getpgid(posix_getppid()) : '',
'Real Process ID' => ($this->_cf('posix_getpid')) ? posix_getpid() : '',
'Real Process Group ID' => ($this->_cf('posix_getpgid') && $this->_cf('posix_getpid')) ? posix_getpgid(posix_getpid()) : '',
'Process Effective User ID' => ($this->_cf('posix_geteuid')) ? posix_geteuid() : '',
'Process Owner Username' => $this->get_posix_info('user', '', 'name'),
'File Owner Username' => ($this->_cf('get_current_user')) ? get_current_user() : '',
'User Info' => print_r($this->get_posix_info('user'), 1),
'Group Info' => print_r($this->get_posix_info('group'), 1),
'RealPath' => realpath(__FILE__),
'SAPI Name' => ($this->_cf('php_sapi_name')) ? print_r(php_sapi_name(), 1) : '',
'Posix Process Owner' => ($this->_cf('posix_getpwuid') && $this->_cf('posix_geteuid')) ? print_r(posix_getpwuid(posix_geteuid()), 1) : '',
'Scanned Ini' => ($this->_cf('php_ini_scanned_files')) ? str_replace("\n", "", php_ini_scanned_files()) : '',
'PHP.ini Path' => ($this->_cf('get_cfg_var')) ? get_cfg_var('cfg_file_path') : '',
'Sendmail Path' => ($this->_cf('get_cfg_var')) ? get_cfg_var('sendmail_path') : '',
'Info about a group by group id' => ($this->_cf('posix_getgrgid') && $this->_cf('posix_getegid')) ? posix_getgrgid(posix_getegid()) : '',
'Process group id for Current process' => ($this->_cf('posix_getgrgid') && $this->_cf('posix_getpid')) ? posix_getpgid(posix_getpid()) : '',
'Process group id for Parent process' => ($this->_cf('posix_getpgid') && $this->_cf('posix_getppid')) ? posix_getpgid(posix_getppid()) : '',
'Process group id of the session leader.' => ($this->_cf('posix_getsid') && $this->_cf('posix_getpid')) ? posix_getsid(posix_getpid()) : '',
'Info about a user by username' => ($this->_cf('posix_getpwnam') && $this->_cf('get_current_user')) ? posix_getpwnam(get_current_user()) : '',
'Info about a user by user id' => ($this->_cf('posix_getpwuid') && $this->_cf('posix_geteuid')) ? posix_getpwuid(posix_geteuid()) : '',
'Apache Version' => ($this->_cf('apache_get_version')) ? print_r(apache_get_version(), 1) : '',
'Apache Modules' => ($this->_cf('apache_get_modules')) ? print_r(apache_get_modules(), 1) : '',
'PHP_LOGO_GUI' => ($this->_cf('php_logo_guid')) ? php_logo_guid() : '',
'ZEND_LOGO_GUI' => ($this->_cf('zend_logo_guid')) ? zend_logo_guid() : '') as $t=>$v ) $oa[$t]=$v;
$this->t(__FUNCTION__);
return array($oa);
}
/** AA_DEBUG::get_debug_classes()
*
* @param mixed $vb
*/
function get_debug_classes( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$classes = $oa = array();
foreach ((array)(($vb!==false)?($this->_cf('get_declared_classes')?get_declared_classes():array()):array('WP','WP_Error','Walker','WP_Ajax_Response','wpdb','WP_Object_Cache','WP_Query','WP_Rewrite','WP_Locale')) as $k )
$oa[$k] = ($this->_cf('get_class_methods')&&$this->_cf('get_class_vars')) ? array('methods'=>get_class_methods($k),'vars'=>get_class_vars("$k")) : '';
$this->t(__FUNCTION__);
return $oa;
}
/** AA_DEBUG::get_debug_globals()
*
* @param mixed $vb
*/
function get_debug_globals( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa = array();
global $_GET,$_POST,$_COOKIE,$_SESSION,$_ENV,$_FILES,$_SERVER,$_REQUEST,$HTTP_POST_FILES,$HTTP_POST_VARS,$HTTP_SERVER_VARS,$HTTP_RAW_POST_DATA,$HTTP_GET_VARS,$HTTP_COOKIE_VARS,$HTTP_ENV_VARS;
$gv=create_function('$n','global $$n; return ( (is_array($$n)&&sizeof($$n)>0)?$$n:"");');
foreach (array('_GET','_POST','_COOKIE','_SESSION','_ENV','_FILES','_SERVER','_REQUEST','HTTP_POST_FILES','HTTP_POST_VARS','HTTP_SERVER_VARS','HTTP_RAW_POST_DATA','HTTP_GET_VARS','HTTP_COOKIE_VARS','HTTP_ENV_VARS') as $k)
$oa[((substr($k,0,1))=='_'?substr($k,1):$k)] = $gv($k);
$oa['UPLOAD']=(($this->_cf('wp_upload_dir')) ? wp_upload_dir() : array());
foreach (array_keys($_SERVER) as $k) if ($v=strval($_SERVER[$k])&&!empty($v))$oa[(substr($k,0,5)=='HTTP_'?'HTTP':'SERVER')][$k]=$_SERVER[$k];
$this->t(__FUNCTION__);
return $oa;
}
/*
function get_debug_globals( $vb = false )
{
$oa = array();
global $_GET,$_POST,$_COOKIE,$_SESSION,$_ENV,$_FILES,$_SERVER,$_REQUEST,$HTTP_POST_FILES,$HTTP_POST_VARS,$HTTP_SERVER_VARS,$HTTP_RAW_POST_DATA,$HTTP_GET_VARS,$HTTP_COOKIE_VARS,$HTTP_ENV_VARS;
array_walk($g=array('_GET,','_POST,','_COOKIE,','_SESSION,','_ENV,','_FILES,','_SERVER,','_REQUEST,','HTTP_POST_FILES,','HTTP_POST_VARS,','HTTP_SERVER_VARS,','HTTP_RAW_POST_DATA,','HTTP_GET_VARS,','HTTP_COOKIE_VARS,','HTTP_ENV_VARS'),
create_function('$n','global $$n;if(!!$$n && ob_start() && (print "( $"."$n )\n") && array_walk($$n, create_function(\'&$v,$k\', \'echo "[$k] => $v\n";\')))
echo "".htmlspecialchars(ob_get_clean())."
";'));
}
*/
/** AA_DEBUG::get_debug_loaded_extensions()
*
* @param mixed $vb
*/
function get_debug_loaded_extensions( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa = array();
foreach ((array)(($this->_cf('get_loaded_extensions')?get_loaded_extensions():array())) as $k=>$v) $oa[$v]=(($vb===false)?'':(array)($this->_cf('get_extension_funcs')?get_extension_funcs($v):array()));
$this->t(__FUNCTION__);
return $oa;
}
/** AA_DEBUG::get_debug_defined()
*
* @param mixed $vb
*/
function get_debug_defined( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa = array();
foreach ((array)(($this->_cf('get_defined_constants')?get_defined_constants():array())) as $k=>$v) if(($vb===true)||(!$vb&&in_array($k,array('ABSPATH','WP_ADMIN'))&&$vb=true))$oa[$k]=$v;
foreach (array('WP_TEMP_DIR','WP_SITEURL','WP_HOME','ABSPATH','WP_CONTENT_URL','WP_CONTENT_DIR','WP_PLUGIN_DIR','WP_PLUGIN_URL','WP_LANG_DIR','TEMPLATEPATH','STYLESHEETPATH','WPINC','COOKIEPATH','SITECOOKIEPATH','ADMIN_COOKIE_PATH','PLUGINS_COOKIE_PATH','PHP_SAPI','PHP_OS','PHP_VERSION') as $d) if(defined($d)&&$v=constant($d)&&!empty($v)) $oa[$d]=$v;
$this->t(__FUNCTION__);
return array($oa);
}
/** AA_DEBUG::get_debug_inis()
*
* @param mixed $vb
*/
function get_debug_inis( $vb = false )
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa = array();
if($this->_cf('ini_get')) {
foreach ( array(
'Error Log' => 'error_log',
'Session Data Path' => 'session.save_path',
'Upload Tmp Dir' => 'upload_tmp_dir',
'Include Path' => 'include_path',
'Memory Limit' => 'memory_limit',
'Max Execution Time' => 'max_execution_time',
'Display Errors' => 'display_errors',
'Allow url fopen' => 'allow_url_fopen',
'Disabled Functions' => 'disable_functions',
'Safe Mode' => 'safe_mode',
'Open Basedir' => 'open_basedir',
'File Uploads' => 'file_uploads',
'Max Upload Filesize' => 'upload_max_filesize',
'Max POST Size' => 'post_max_size',
'Open Basedir' => 'open_basedir'
) as $t=>$n)$oa[$n]=strval(ini_get($n));
}
if ($vb!==false && $this->_cf('ini_get_all')) foreach ((array)@ini_get_all() as $k=>$v) $oa[$k]=(($v['global_value']==$v['local_value'])?$v['global_value']:$v);
$this->t(__FUNCTION__);
return array($oa);
}
/** AA_DEBUG::get_debug_phpinfo()
*/
function get_debug_phpinfo()
{
$this->logg(__FILE__,__FUNCTION__,__LINE__, "Starting..." );
$oa = array();
if($this->_cf('phpinfo'))
{
ob_start();
phpinfo( -1 );
$oa = preg_replace(array('#^.*(.*).*$#ms','#PHP License
.*$#ms','#Configuration
#',"#\r?\n#","#(h1|h2|h3|tr)>#",'# +<#',"#[ \t]+#",
'# #','# +#','# class=".*?"#','%'%','#(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" />' . 'PHP Version (.*?)
(?:\n+?)
#',
'##','#(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)
#',"# +#",'##','#
#'
),
array('$1','','','','$1>' . "\n",'<',' ',' ',' ','',' ','PHP Configuration
' . "\n" . '| PHP Version | $2 |
' . "\n" . '| PHP Egg | $1 |
',
'| PHP Credits Egg | $1 |
','| Zend Engine | $2 |
' . "\n" . '| Zend Egg | $1 |
',' ','%S%','%E%'
),
ob_get_clean());
$sections = explode( '', strip_tags($oa, ' | ') );
unset( $sections[0] );
$oa = array();
foreach ( $sections as $s )
{
preg_match_all( '#%S%(?: | (.*?) | )?(?:(.*?) | )?(?:(.*?) | )?%E%#', $s, $askapache, PREG_SET_ORDER );
foreach ($askapache as $m) $oa[(substr( $s, 0, strpos($s, '
') ))][$m[1]]=( !isset($m[3]) || $m[2]==$m[3] ) ? (isset($m[2]) ? $m[2] : '') : array_slice($m,2);
}
}
$this->t(__FUNCTION__);
return $oa;
}
}
endif;
function &_aa_debug_object()
{
static $aa_debug_object=NULL;
if ( null === $aa_debug_object ) {
$aa_debug_object=new AA_DEBUG();
$GLOBALS["aa_debug_object"]=&$aa_debug_object;
}
return $aa_debug_object;
}
$AA_DEBUG = _aa_debug_object();
$_aabf=basename(__FILE__);
$_aapb=preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__);
$_aahk=rtrim('tools_page_'.$_aabf, '.php');
if (is_admin()) :
/*
function is_uninstallable_plugin($plugin) {
$file = plugin_basename($plugin);
$uninstallable_plugins = (array) get_option('uninstall_plugins');
if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) )
return true;
return false;
}
function is_plugin_active( $plugin ) {
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin );
}
function uninstall_plugin($plugin) {
$file = plugin_basename($plugin);
$uninstallable_plugins = (array) get_option('uninstall_plugins');
if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) {
if ( isset( $uninstallable_plugins[$file] ) ) {
unset($uninstallable_plugins[$file]);
update_option('uninstall_plugins', $uninstallable_plugins);
}
unset($uninstallable_plugins);
define('WP_UNINSTALL_PLUGIN', $file);
include WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php';
return true;
}
if ( isset( $uninstallable_plugins[$file] ) ) {
$callable = $uninstallable_plugins[$file];
unset($uninstallable_plugins[$file]);
update_option('uninstall_plugins', $uninstallable_plugins);
unset($uninstallable_plugins);
include WP_PLUGIN_DIR . '/' . $file;
add_action( 'uninstall_' . $file, $callable );
do_action( 'uninstall_' . $file );
}
}
plugin_dir_url
plugin_dir_path
plugin_basename
get_plugin_page_hookname( $plugin_page, $parent_page )
get_plugin_page_hook( $plugin_page, $parent_page )
function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
* @uses do_action() Calls 'add_option' hook before adding the option.
* @uses do_action() Calls 'add_option_$option' and 'added_option' hooks on success.
add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
do_action( "delete_option_$option", $option );
do_action( 'deleted_option', $option );
delete_option
register_uninstall_hook
register_activation_hook(__FILE__, array(&$this, '_activate'));
register_deactivation_hook(__FILE__, array(&$this, '_deactivate'));
if(!is_object($AA_DEBUG))$AA_DEBUG=_aa_debug_object();$AA_DEBUG->logg(__FILE__,__FUNCTION__,__LINE__, "deactivating_aapb!");delete_option("askapache_debug_options");delete_option("askapache_debug_plugin"); create_function('', ''));
*/
register_activation_hook(__FILE__, array(&$AA_DEBUG,'DefaultOptions'));
register_deactivation_hook(__FILE__, create_function('', 'delete_option("askapache_debug_options");delete_option("askapache_debug_plugin");'));
add_filter("plugin_action_links_{$_aapb}",
create_function('$l', 'return array_merge(
array(
"Settings"
),
$l
);'));
add_action("admin_init",
create_function('','$AA_DEBUG=&_aa_debug_object();
$AA_DEBUG->l("admin_init AA_DEBUG");
$AA_DEBUG->LoadOptions();'));
add_action('admin_menu',
create_function('','$AA_DEBUG=&_aa_debug_object();
$AA_DEBUG->l("admin_menu AA_DEBUG");
$p=$AA_DEBUG->get_plugin_data("tools");
add_management_page(
$p["plugin-name"],
$p["short-name"],
10,
$p["page"],
array(&$AA_DEBUG,"management_page")
);
add_action( "admin_footer", array(&$AA_DEBUG,"admin_footer"));
'));
add_action("load-{$_aahk}",
create_function('', '$AA_DEBUG=&_aa_debug_object();$AA_DEBUG->l("load- AA_DEBUG");"POST"==$_SERVER["REQUEST_METHOD"] && $AA_DEBUG->handle_post();'));
endif;
unset($_aapb,$_aahk,$_aabf);
add_action( 'init', array(&$AA_DEBUG, 'live_debug') );
add_action( 'shutdown', array(&$AA_DEBUG, 'live_debug') );
add_action( "wp_footer", array(&$AA_DEBUG,'wp_footer'));
add_action( "admin_footer", array(&$AA_DEBUG,'admin_footer'));
?>