.
*/
// function to replace wp_die if it doesn't exist
if (!function_exists('wp_die')) : function wp_die ($message = 'wp_die') { die($message); } endif;
// don't load directly - exit if add_action or plugins_url functions do not exist
if (!defined('ABSPATH') || !function_exists('add_action') || !function_exists('plugins_url')) die('death by askapache firing squad');
//if(ob_start() && (print(str_repeat("\n",5).str_repeat("=",235)."\n+-- ".__LINE__." ------------------------------[ ".__FILE__." ] [START]\n")) && !!error_log(ob_get_clean()))true;
if(!class_exists('AA_DEBUG')):
/******************************************************************************************************************************************************************
PHP DEFINES
******************************************************************************************************************************************************************/
/*
__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
__DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. Does not have a trailing slash unless it is the root directory.
__FUNCTION__ The function name. 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. 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. 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
*/
!defined('__DIR__') && define('__DIR__', realpath(dirname(__FILE__)));
!defined('FILE_BINARY') && define('FILE_BINARY', 0);
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 (!defined('PHP_EOL')) {
switch (strtoupper(substr(PHP_OS, 0, 3))) {
case 'WIN': define('PHP_EOL', "\r\n"); break;
case 'DAR': define('PHP_EOL', "\r"); break;
default:define('PHP_EOL', "\n"); break;
}
}
/******************************************************************************************************************************************************************
WORDPRESS DEFINES
******************************************************************************************************************************************************************/
!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
!defined('CRLF') && define('CRLF', chr(13).chr(10));
/******************************************************************************************************************************************************************
FUNCTION DEFINES
******************************************************************************************************************************************************************/
/** aadv_error_log($msg='')
* since 2.3.2
*/
function aadv_error_log($msg='')
{
return error_log("1".$msg);
}
/** aadv_DEFINE_function()
* since 2.3.3
*/
function aadv_DEFINE_function($f='')
{
$funcs=array('absint','array_walk_recursive','curl_setopt_array','get_include_path','inet_ntop','inet_pton','ini_get_all','is_a','is_callable','is_scalar','md5_file','mhash','microtime','mkdir','ob_clean','ob_flush','ob_get_clean','ob_get_flush','pathinfo','php_ini_loaded_file','restore_include_path','scandir','set_include_path','sys_get_temp_dir','time_sleep_until','var_export','wp_die');
if(empty($f)) return $funcs;
aadv_error_log("Defining function {$f}");
switch($f)
{
case 'absint':
function absint( $maybeint )
{
return abs( intval( $maybeint ) );
}
break;
case 'array_walk_recursive':
function array_walk_recursive(&$input, $funcname)
{
if (!is_callable($funcname))
{
if (is_array($funcname)) $funcname = $funcname[0] . '::' . $funcname[1];
user_error('array_walk_recursive() Not a valid callback ' . $funcname, E_USER_WARNING);
return;
}
if (!is_array($input))
{
user_error('array_walk_recursive() The argument should be an array', E_USER_WARNING);
return;
}
$args = func_get_args();
foreach ($input as $key => $item)
{
$callArgs = $args;
if (is_array($item)) {
$thisCall = 'array_walk_recursive';
$callArgs[1] = $funcname;
} else {
$thisCall = $funcname;
$callArgs[1] = $key;
}
$callArgs[0] = &$input[$key];
call_user_func_array($thisCall, $callArgs);
}
};
break;
case 'curl_setopt_array':
function curl_setopt_array(&$ch, $curl_options)
{
$curl_info=array(
'url'=>'Last effective URL',
'content_type'=>'Content-type of downloaded object',
'http_code'=>'Last received HTTP code',
'header_size'=>'Total size of all headers received',
'request_size'=>'Total size of issued requests, currently only for HTTP requests',
'filetime'=>'Remote time of the retrieved document',
'ssl_verify_result'=>'Result of SSL certification verification requested',
'redirect_count'=>'Total number of redirects',
'total_time'=>'Total transaction time in seconds for last transfer',
'namelookup_time'=>'Time in seconds until name resolving was complete',
'connect_time'=>'Time in seconds it took to establish the connection',
'pretransfer_time'=>'Time in seconds from start until just before file transfer begins',
'size_upload'=>'Total number of bytes uploaded',
'size_download'=>'Total number of bytes downloaded',
'speed_download'=>'Average download speed',
'speed_upload'=>'Average upload speed',
'download_content_length'=>'content-length of download, read from Content-Length: field',
'upload_content_length'=>'Specified size of upload',
'starttransfer_time'=>'Time in seconds until the first byte is about to be transferred',
'redirect_time'=>'Time in seconds of all redirection steps before final transaction was started');
foreach ($curl_options as $option => $value) {
if (!curl_setopt($ch, $option, $value)) return false;
}
return true;
}
break;
case 'get_include_path':
function get_include_path()
{
return ini_get('include_path');
};
break;
case 'inet_ntop':
function inet_ntop($in_addr)
{
switch (strlen($in_addr)) {
case 4:
list(,$r) = unpack('N', $in_addr);
return long2ip($r);
case 16:
$r = substr(chunk_split(bin2hex($in_addr), 4, ':'), 0, -1);
$r = preg_replace(
array('/(?::?\b0+\b:?){2,}/', '/\b0+([^0])/e'),
array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;
}
return false;
};
break;
case 'inet_pton':
function inet_pton($address)
{
$r = ip2long($address);
if ($r !== false && $r != -1) return pack('N', $r);
$delim_count = substr_count($address, ':');
if ($delim_count < 1 || $delim_count > 7) return false;
$r = explode(':', $address);
$rcount = count($r);
if (($doub = array_search('', $r, 1)) !== false) {
$length = (!$doub || $doub == $rcount - 1 ? 2 : 1);
array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0));
}
$r = array_map('hexdec', $r);
array_unshift($r, 'n*');
$r = call_user_func_array('pack', $r);
return $r;
};
break;
case 'ini_get_all':
function ini_get_all($extension=null)
{
// Sanity check
if ($extension !== null && !is_scalar($extension)) {
user_error('ini_get_all() expects parameter 1 to be string, ' . gettype($extension) . ' given', E_USER_WARNING);
return false;
}
// Get the location of php.ini
ob_start();
phpinfo(INFO_GENERAL);
$info = ob_get_contents();
ob_clean();
$info = explode("\n", $info);
$line = array_values(preg_grep('#php\.ini#', $info));
// Plain vs HTML output
if (substr($line[0], 0, 4) === '
') {
list (, $value) = explode('', $line[0], 2);
$inifile = trim(strip_tags($value));
} else {
list (, $value) = explode(' => ', $line[0], 2);
$inifile = trim($value);
}
// Check the file actually exists
if (!file_exists($inifile)) return false;
};
break;
case 'restore_include_path':
function restore_include_path()
{
return ini_restore('include_path');
};
break;
case 'scandir':
function scandir($directory, $sorting_order = 0)
{
if (!is_string($directory)) {
user_error('scandir() expects parameter 1 to be string, ' . gettype($directory) . ' given', E_USER_WARNING);
return;
}
if (!is_int($sorting_order) && !is_bool($sorting_order)) {
user_error('scandir() expects parameter 2 to be long, ' . gettype($sorting_order) . ' given', E_USER_WARNING);
return;
}
if (!is_dir($directory) || (false === $fh = @opendir($directory))) {
user_error('scandir() failed to open dir: Invalid argument', E_USER_WARNING);
return false;
}
$files = array ();
while (false !== ($filename = readdir($fh))) $files[] = $filename;
closedir($fh);
if ($sorting_order == 1) rsort($files);
else sort($files);
return $files;
};
break;
case 'set_include_path':
function set_include_path($new_include_path)
{
return ini_set('include_path', $new_include_path);
};
break;
case 'sys_get_temp_dir':
function sys_get_temp_dir()
{
if (!empty($_ENV['TMP'])) return realpath($_ENV['TMP']);
if (!empty($_ENV['TMPDIR'])) return realpath( $_ENV['TMPDIR']);
if (!empty($_ENV['TEMP'])) return realpath( $_ENV['TEMP']);
$tempfile = tempnam(uniqid(rand(),TRUE),'');
if (file_exists($tempfile)) {
unlink($tempfile);
return realpath(dirname($tempfile));
}
};
break;
case 'time_sleep_until':
function time_sleep_until($timestamp)
{
list($usec, $sec) = explode(' ', microtime());
$now = $sec + $usec;
if ($timestamp <= $now) {
user_error('Specified timestamp is in the past', E_USER_WARNING);
return false;
}
$diff = $timestamp - $now;
usleep($diff * 1000000);
return true;
};
break;
case 'var_export':
function var_export($var, $return = false, $level = 0, $inObject = false)
{
$indent = ' ';
$doublearrow = ' => ';
$lineend = ",\n";
$stringdelim = '\'';
$newline = "\n";
$find = array(null, '\\', '\'');
$replace = array('NULL', '\\\\', '\\\'');
$out = '';
// Indent
$level++;
for ($i = 1, $previndent = ''; $i < $level; $i++) $previndent .= $indent;
$varType = gettype($var);
// Handle object indentation oddity
if ($inObject && $varType != 'object') $previndent = substr($previndent, 0, -1);
// Handle each type
switch ($varType)
{
case 'array':
if ($inObject) $out .= $newline . $previndent;
$out .= 'array (' . $newline;
foreach ($var as $key => $value) {
if (is_string($key)) {
// Make key safe
$key = str_replace($find, $replace, $key);
$key = $stringdelim . $key . $stringdelim;
}
// Value
if (is_array($value)) {
$export = var_export($value, true, $level);
$value = $newline . $previndent . $indent . $export;
} else $value = var_export($value, true, $level);
// Piece line together
$out .= $previndent . $indent . $key . $doublearrow . $value . $lineend;
}
// End string
$out .= $previndent . ')';
break;
case 'string':
// Make the string safe
for ($i = 0, $c = count($find); $i < $c; $i++) $var = str_replace($find[$i], $replace[$i], $var);
$out = $stringdelim . $var . $stringdelim;
break;
case 'integer':
case 'double':
$out = (string) $var;
break;
case 'boolean':
$out = $var ? 'true' : 'false';
break;
case 'NULL':
case 'resource':
$out = 'NULL';
break;
case 'object':
// Start the object export
$out = $newline . $previndent;
$out .= get_class($var) . '::__set_state(array(' . $newline;
// Export the object vars
foreach(get_object_vars($var) as $key => $value) $out .= $previndent . $indent . ' ' . $stringdelim . $key . $stringdelim . $doublearrow . var_export($value, true, $level, true) . $lineend;
$out .= $previndent . '))';
break;
}
// Method of output
if ($return === true) return $out;
else echo $out;
};
break;
case 'wp_die':
function wp_die ($message = 'wp_die')
{
die($message);
}
break;
}
}
// This is a cool workaround to defining functions already defined but throwing errors
foreach(aadv_DEFINE_function() as $f) if(!function_exists($f)) aadv_DEFINE_function($f);
/**
* AA_DEBUG
*
* @package
* @author askapache
* @copyright Copyright (c) 2011
* @version $Id$
* @access public
*/
class AA_DEBUG
{
/*
* e
* -------------------------------
* @since 2.2.8
* @var string
*/
var $qn='askapache_debug';
/*
* e
* -------------------------------
* @since 2.2.8
* @var int
*/
var $debug=0;
/*
* Contains Plugin Name and Settings from parsing this file
* -------------------------------
*
* [plugin] => Array
* [plugin-name] => AskApache Debug Viewer
* [short-name] => AA Debug
* [description] => Displays Advanced Debugging Output
* [author] => askapache,cduke250
* [version] => 2.2.8
* [requires-at-least] => 2.9
* [tested-up-to] => 3.4-alpha-19719
* [tags] => debug, debugging, error, errors, problems, support, admin, programmer, developer, plugin, development, information, stats, logs, queries, htaccess, password, error, support, askapache
* [contributors] => askapache,cduke250
* [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/debug-viewer-plugin.html
* [role] => administrator
* [capability] => askapache_debug_viewer
* [qn] => askapache_debug
* [http] => //w
* [file] => /wp-content/plugins/askapache-debug-viewer/askapache-debug-viewer.php
* [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] => settings_page_askapache-debug-viewer
* [action] => options-general.php?page=askapache-debug-viewer.php
* [op] => adv7 *
* @since 2.2.8
* @var array
*/
var $plugin = array(); // array to hold plugin information
/*
* Options for this plugin
* -------------------------------
*
* [options] => Array
* [page] => home
* [logfile] => php_error.log
* [dirtoexplore] => /tmp
* [log_errors] => 1
* [debug_live] => 0
* [admin_footer] => 1
* [wp_footer] => 1
* [error_reporting] => 4983
* [plugin_debug_level] => 5
* [debug_mods_v] => 5
* [debug_mods] => 5
* [admin_bar] => 1
*
* @since 2.2.8
* @var array
*/
var $options = array(
'page'=> 'home',
'logfile' => '',
'dirtoexplore' => '',
'log_errors' => '0',
'debug_live' => '0',
'display_height' => 500,
'admin_footer' => '1',
'wp_footer' => '1',
'admin_bar' => '1',
'error_reporting' => 2147483647,
'plugin_debug_level' => 0,
'debug_mods_v' => 2048,
'debug_mods' => 106679
);
/*
* Pages for Navigating to
* -------------------------------
*
* [pages] => Array
* [home] => Array
* [name] => Settings
* [title] => Setup Debugging Options
* [nonce] =>
* [wpconfig] => Array
* [name] => wp-config File
* [title] => Current and recommended wp-config.php file
* [nonce] =>
* [phpinfo] => Array
* [name] => PHPINFO
* [title] => phpinfo
* [nonce] =>
* [server-status] => Array
* [name] => Server Status
* [title] => Server Status
* [nonce] =>
* [server-info] => Array
* [name] => Server Info
* [title] => Server Info
* [nonce] =>
* [server-env] => Array
* [name] => Server Env
* [title] => Printenv Output
* [nonce] =>
* [files] => Array
* [name] => Directory File Browser
* [title] => Browse files and directories
* [nonce] =>
*
* @since 2.2.8
* @var array
*/
var $pages = array(
'home' => array('name'=>'Settings', 'title'=>'Setup Debugging Options', 'nonce'=>''),
'wpconfig' => array('name'=>'wp-config File', 'title'=>'wp-config.php file', 'nonce'=>''),
'phpinfo' => array('name'=>'PHPINFO', 'title'=>'phpinfo', 'nonce'=>''),
'server-status' => array('name'=>'Server Status', 'title'=>'Server Status', 'nonce'=>''),
'server-info' => array('name'=>'Server Info', 'title'=>'Server Info', 'nonce'=>''),
'server-env' => array('name'=>'Server Env', 'title'=>'Printenv Output', 'nonce'=>''),
//'files' => array('name'=>'Directory File Browser', 'title'=>'Browse files and directories', 'nonce'=>'')
);
/*
* Actions for immediate effect
* -------------------------------
*
* [adminbaroff] => Array
* [title] => Disable Front Admin Bar
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_action=adminbaroff&_wpnonce=5b02532fda
* [disable] => Array
* [title] => Disable
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_action=disable&_wpnonce=1352fa97c2
* [enable] => Array
* [title] => Enable
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_action=enable&_wpnonce=e136051dee
*
* @since 2.2.8
* @var array
*/
var $actions = array(
'adminbaroff' =>array('title'=>'Disable Front Admin Bar', 'nonce'=>''),
'disable' =>array('title'=>'Disable', 'nonce'=>''),
'enable' =>array('title'=>'Enable', 'nonce'=>'')
);
/*
* $debug_mods
* -------------------------------
* @since 2.2.8
* @var array
*/
var $debug_mods = array();
/*
* $ini_overwrites
* -------------------------------
* @since 2.2.8
* @var array
*/
var $ini_overwrites=array(
//'output_handler' => '',
//'session.auto_start' => '0',
//'zlib.output_compression' => 0,
//'output_buffering' => 0,
//'precision'=>'14',
//'report_zend_debug' => 0,
'open_basedir' => '',
'tidy.clean_output' => 0,
'xdebug.default_enable' => 0,
'mbstring.func_overload' => 0,
'error_prepend_string' => '',
'error_append_string' => '',
'auto_prepend_file' => '',
'auto_append_file' => '',
'disable_functions' => '',
'safe_mode' => 0,
'request_order' => 'GPCES',
'register_globals' => 1,
'register_long_arrays' => 1,
'register_argc_argv' => 1,
'always_populate_raw_post_data' => 1,
'error_reporting' => 0,
'display_errors' => 0,
'display_startup_errors' => 0,
'log_errors' => 1,
'html_errors' => 0,
'track_errors' => 1,
'report_memleaks' => 1,
'magic_quotes_runtime' => 0,
'magic_quotes_gpc' => 0,
'ignore_repeated_errors' => 1,
'ignore_repeated_source' => 1,
'log_errors_max_len'=>'0'
);
/*
* Old Ini Settings for storage
* -------------------------------
*
* [old_inis] => Array
* [open_basedir] =>
* [tidy.clean_output] =>
* [xdebug.default_enable] =>
* [mbstring.func_overload] => 0
* [error_prepend_string] =>
* [error_append_string] =>
* [auto_prepend_file] =>
* [auto_append_file] =>
* [disable_functions] => exec,shell_exec,system,passthru,disk_total_space,diskfreespace,popen,proc_open,proc_nice,dl
* [safe_mode] =>
* [request_order] => GP
* [register_globals] =>
* [register_long_arrays] =>
* [register_argc_argv] =>
* [always_populate_raw_post_data] => 0
* [error_reporting] => 4983
* [display_errors] => Off
* [display_startup_errors] =>
* [log_errors] => On
* [html_errors] =>
* [track_errors] =>
* [report_memleaks] => 1
* [magic_quotes_runtime] => 0
* [magic_quotes_gpc] => 1
* [ignore_repeated_errors] => 1
* [ignore_repeated_source] => 1
* [log_errors_max_len] => 1000240
*
* @since 2.2.8
* @var array
*/
var $old_inis = array();
/** AA_DEBUG::AA_DEBUG()
*/
function AA_DEBUG()
{
//if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [START]\n")) && !!error_log(ob_get_clean())) true;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if(version_compare(PHP_VERSION, '5.0.0', 'lt')){
$this->__construct();
register_shutdown_function(array($this,"__destruct"));
}
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
//if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [END]\n")) && !!error_log(ob_get_clean())) true;
}
/** AA_DEBUG::__construct()
*/
function __construct()
{
//if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [START]\n")) && !!error_log(ob_get_clean())) true;
// PRINT ERROR_GET_LAST ON SHUTDOWN
/*
register_shutdown_function(
create_function('',
'error_log("print error_get_last '.error_log("print error_get_last").'");$l=error_get_last();if(isset($l["type"])&&$l["type"]===E_ERROR)echo "fatal error";echo (isset($php_errormsg)?PHP_EOL.$php_errormsg:"").PHP_EOL.print_r($l,1).PHP_EOL;'
)
);
*/
$this->options=get_option($this->qn.'_options');
$this->debug=$this->options['plugin_debug_level'];
if($this->debug > 0)error_log(str_repeat("\n",5).str_repeat("=",235));
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',50);
$this->plugin = $this->get_plugin_data();
//$this->LoadOptions();
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',50);
//if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [END]\n")) && !!error_log(ob_get_clean())) true;
}
/** AA_DEBUG::__destruct()
function __destruct()
{
if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [START]\n")) && !!error_log(ob_get_clean())) true;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5);
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5);
if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [END]\n")) && !!error_log(ob_get_clean())) true;
return true;
}
*/
/** AA_DEBUG::LoadOptions()
*/
function LoadOptions()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
$this->options=get_option($this->qn.'_options');
$this->plugin = $this->get_plugin_data();
$this->debug=absint($this->options['plugin_debug_level']);
$D = array();
$D[(1 << sizeof($D))]=array('get_debug_footerhelper', 'Footer Helper');
$D[(1 << sizeof($D))]=array('get_debug_templates', 'Templates');
$D[(1 << sizeof($D))]=array('get_debug_options', 'WP Options');
$D[(1 << sizeof($D))]=array('get_debug_aa_plugin', 'Debug Plugin');
$D[(1 << sizeof($D))]=array('get_debug_request', 'Request');
$D[(1 << sizeof($D))]=array('get_debug_wordpress', 'WordPress Globals');
$D[(1 << sizeof($D))]=array('get_debug_globalprint', 'Global Print');
$D[(1 << sizeof($D))]=array('get_debug_globalvars', 'Global Variables');
$D[(1 << sizeof($D))]=array('get_debug_rewrites', 'Rewrites');
$D[(1 << sizeof($D))]=array('get_debug_included', 'Included Files');
$D[(1 << sizeof($D))]=array('get_debug_extensions', 'Extensions');
$D[(1 << sizeof($D))]=array('get_debug_classes', 'Classes');
$D[(1 << sizeof($D))]=array('get_debug_functions', 'Functions');
$D[(1 << sizeof($D))]=array('get_debug_defined', 'Constants');
$D[(1 << sizeof($D))]=array('get_debug_posix', 'Posix Info');
$D[(1 << sizeof($D))]=array('get_debug_inis', 'PHP ini settings');
//$D[(1 << sizeof($D))]=array('get_debug_phpinfo', 'PHPINFO');
$D[(1 << sizeof($D))]=array('get_debug_permissions', 'User/File/Process permissions');
$D[(1 << sizeof($D))]=array('get_debug_interfaces', 'Interfaces');
$D[(1 << sizeof($D))]=array('get_debug_sockets', 'Sockets');
$D[(1 << sizeof($D))]=array('get_debug_queries', 'DataBase Queries');
$D[(1 << sizeof($D))]=array('get_debug_crons', 'WordPress Crons');
$this->debug_mods=$D;
unset($D);
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::SaveOptions()
*/
function SaveOptions()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if( function_exists('current_user_can') && !current_user_can('administrator') ) wp_die(__FUNCTION__.':'.__LINE__);
update_option($this->qn.'_options', $this->options);
update_option($this->qn.'_plugin', $this->plugin);
$this->LoadOptions();
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::DefaultOptions()
*/
function DefaultOptions($save=false)
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
// get all the plugin array data
$this->plugin = $this->get_plugin_data(true);
// save the $this->plugin to $this->qn_plugin
$this->SaveOptions();
// default array of options
$ret=array(
'page'=> 'home',
'logfile' => $this->get_error_log(),
'dirtoexplore' => __DIR__,
'log_errors' => '1',
'debug_live' => '0',
'admin_footer' => '1',
'wp_footer' => '1',
'admin_bar' => '1',
'error_reporting' => 4983,
'plugin_debug_level' => 0,
'display_height' => 500,
'debug_mods_v' =>2048,
'debug_mods' => 106679
);
// if $save is true
if($save===true) {
//save $ret to $this->options
$this->options=$ret;
// save both $this->options and $this->plugin
$this->SaveOptions();
// reset $ret to equal true for return;
$ret=true;
}
// Save all these variables to database
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
return $ret;
}
/** AA_DEBUG::Activate()
*/
function Activate()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
$old_options=$old_plugin=$default_options=false;
// load the default options without saving ::options
$new_options=$this->DefaultOptions(false);
// get old options
$old_options=get_option($this->qn.'_options');
// if old_options exist, merge the old settings into the new
if ($old_options !==false && is_array($old_options) && array_key_exists('plugin_debug_level', $old_options) && !array_key_exists('admin_bar_fix', $old_options) ) {
aadv_error_log(print_r(array_diff($old_options, $new_options),1));
$this->options = wp_parse_args($old_options, $new_options);
}
// delete the existing options
delete_option($this->qn.'_options');
delete_option($this->qn.'_plugin');
// add the new options
//add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
add_option($this->qn.'_options', $this->options, '', 'yes');
add_option($this->qn.'_plugin', $this->plugin, '', 'yes');
$this->SaveOptions();
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::DeActivate()
*/
function DeActivate()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if( function_exists('current_user_can') && !current_user_can('administrator') ) wp_die(__FUNCTION__.':'.__LINE__);
delete_option($this->qn.'_plugin');
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::Uninstall()
*/
function Uninstall()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
//if( function_exists('current_user_can') && !current_user_can('administrator') ) wp_die(__FUNCTION__.':'.__LINE__);
delete_option($this->qn.'_options');
delete_option($this->qn.'_plugin');
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::Init()
*/
function Init()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if ( !$user = wp_get_current_user() ) return aadv_error_log(__FUNCTION__.':'.__LINE__.' user not = wp_get_current_user');
// return if user not an administrator
if(!current_user_can('administrator')) return;
// Load options
$this->LoadOptions();
// adminbar
add_action( 'admin_bar_menu', array(&$this, 'AdminBar'), 9983 );
// add admin-specific stuff
if(is_admin()):
add_action("admin_head-{$this->plugin['hook']}", array(&$this, 'AddHelp') );
add_filter("plugin_action_links_{$this->plugin['pb']}", create_function('$l', 'return array_merge(array("plugin['action']).'\">Settings"), $l);'));
add_action("load-{$this->plugin['hook']}", array(&$this, 'Load'));
add_action('admin_menu', create_function('','$AA_DEBUG=&_aa_debug_object(); $p=$AA_DEBUG->plugin; add_options_page( $p["plugin-name"], $p["short-name"], $p["role"], $p["page"], array(&$AA_DEBUG,"AdminPage") );'));
register_uninstall_hook(__FILE__, array(&$this,'Uninstall'));
register_activation_hook(__FILE__, array(&$this,'Activate'));
register_deactivation_hook(__FILE__, array(&$this,'DeActivate'));
endif;
// enqueue styles
wp_enqueue_style($this->plugin['pagenice'], plugins_url('/f/admin.css',__FILE__), false, $this->plugin['version'], "all");
wp_enqueue_style($this->plugin['pagenice'].'1', 'http'. (is_ssl() ? 's' : '' ).'://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css', false, $this->plugin['version'], "all");
// enqueue script
wp_enqueue_script($this->plugin['pagenice'], plugins_url('/f/admin.js',__FILE__), array('jquery','jquery-ui-core','jquery-ui-resizable', 'jquery-ui-tabs', 'jquery-ui-draggable'), $this->plugin['version']);
// add old inis to class var and create shutdown function to reset
foreach($this->ini_overwrites as $k=>$v)$this->old_inis[$k]=@ini_get($k);
$this->old_inis['error_reporting']=error_reporting();
register_shutdown_function(create_function('','$oe='.$this->old_inis['error_reporting'].';$ne='.error_reporting($this->options['error_reporting']).';error_reporting($oe);'));
foreach ($this->pages as $id => $idv) {
$this->pages[$id]['nonce']=wp_nonce_url(admin_url("{$this->plugin['action']}&{$this->plugin['op']}_page={$id}"), "{$this->plugin['op']}_page_{$id}");
}
foreach ($this->actions as $id=>$idv) {
$this->actions[$id]['nonce']=wp_nonce_url(admin_url("{$this->plugin['action']}&{$this->plugin['op']}_action={$id}"), "{$this->plugin['op']}_action_{$id}");
}
/*
foreach ($this->debug_mods as $id => $info) {
$this->actions[]=array('title'=>'Enable '.$info[1], 'nonce'=>wp_nonce_url(admin_url("{$this->plugin['action']}&{$this->plugin['op']}_action={$id}"), "{$this->plugin['op']}_action_{$id}"));
}
*/
// if output in the footer is enabled
if($this->options['wp_footer']=='1' || $this->options['admin_footer']=='1') {
// add to admin/wp footer
if($this->options['admin_footer']=='1') add_action( "admin_footer", array(&$this,'footer_output'));
if($this->options['wp_footer']=='1') add_action( "wp_footer", array(&$this,'footer_output'));
}
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::AddHelp($text, $screen)
*/
function AddHelp()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',20);
$current_screen=get_current_screen();
add_contextual_help( $current_screen,
'Fixing Status Headers'
.'For super-advanced users, or those with access and knowledge of Apache .htaccess/httpd.conf files'
.' you should check that your error pages are correctly returning a 404 Not Found'
.' HTTP Header and not a 200 OK Header which appears to be the default for many WP installs, this plugin attempts to fix this using PHP, but the best way I have found'
.' is to add the following to your .htaccess file. '
. 'ErrorDocument 404 /index.php?error=404'."\n".'Redirect 404 /index.php?error=404 '
.'Comments/QuestionsPlease visit AskApache.com or send me an email at webmaster@askapache.com '
);
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',20);
}
/** AA_DEBUG::AdminBar()
*/
function AdminBar($wp_admin_bar)
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if(!is_object($wp_admin_bar))return aadv_error_log(__FUNCTION__.':'.__LINE__.' wp_admin_bar is not an object');
//if($this->options['wp_footer']=='1' && $this->options['admin_bar']=='1' ) {
//$pref = get_user_option( "show_admin_bar_front", $user->ID );
//update_user_option($user->ID, "show_admin_bar_front", '');
//}
//isset( $_POST['admin_bar_front'] ) ? 'true' : 'false'
//
$wp_admin_bar->add_menu(array(
'id' => $this->plugin['op'].'menu',
'title' => $this->plugin["short-name"],
'href' => admin_url($this->plugin["action"])
) );
foreach ($this->pages as $id => $idv) {
$wp_admin_bar->add_menu(array(
'parent'=> $this->plugin['op'].'menu',
'id' => $this->plugin['op'].$id,
'title' => $idv['title'],
'href' => $idv['nonce']
) );
}
foreach ($this->actions as $id => $idv) {
$wp_admin_bar->add_menu(array(
'parent'=> $this->plugin['op'].'menu',
'id' => $this->plugin['op'].$id,
'title' => $idv['title'],
'href' => $idv['nonce']
) );
}
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::Load()
*/
function Load()
{
global $show_admin_bar;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
// Handle page
foreach (array_keys($this->pages) as $w) {
if (isset($_GET["{$this->plugin['op']}_page"]) && $_GET["{$this->plugin['op']}_page"] == $w) {
check_admin_referer("{$this->plugin['op']}_page_" . $w);
$this->options['page'] = $w;
break;
}
}
// Handle actions
foreach (array_keys($this->actions) as $w) {
if (isset($_GET["{$this->plugin['op']}_action"]) && $_GET["{$this->plugin['op']}_action"] == $w) {
check_admin_referer("{$this->plugin['op']}_action_" . $w);
if($w=='disable') {
$this->options["admin_footer"]=$this->options["wp_footer"]=$this->options["log_errors"]='0';
}
elseif($w=='enable') $this->options["admin_footer"]=$this->options["wp_footer"]='1';
elseif($w=='adminbaroff') {
//show_admin_bar(false);
//$this->options["admin_bar_fix"]='1';
$this->options["admin_bar"]='0';
}
wp_redirect($_SERVER['HTTP_REFERER']);
break;
}
}
// parse and handle post requests to plugin
if('POST' === $_SERVER['REQUEST_METHOD']) $this->HandlePost();
$this->SaveOptions();
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::HandlePost()
*/
function HandlePost()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if ( !current_user_can('administrator') ) wp_die( 'ERROR: User does not have permission to manage options. '.__FUNCTION__.':'.__LINE__ );
$op = $this->plugin['op'];
// verify nonce, if not verified, then DIE
if(isset($_POST["_{$this->plugin['nonce']}"])) wp_verify_nonce($_POST["_{$this->plugin['nonce']}"], $this->plugin['nonce']) || wp_die('ERROR: Incorrect Form Submission, please try again.');
elseif(isset($_POST["_{$this->plugin['nonce']}_reset"])) wp_verify_nonce($_POST["_{$this->plugin['nonce']}_reset"], $_POST["_{$this->plugin['nonce']}_reset"]) || wp_die('ERROR: Incorrect Form Submission, please try again.');
// resets options to default values
if(isset($_POST["{$op}_action_reset"])) return $this->DefaultOptions(true);
if (isset($_POST["{$op}_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', 'admin_bar') as $k) $this->options["{$k}"] = (isset($_POST["{$op}_{$k}"]) ? '1' : '0');
if( isset($_POST["{$op}_log_errors"]) || empty($this->options['logfile']) ) $this->options['logfile']=$this->get_error_log();
if (isset($_POST["{$op}_logfile"]) && !empty($_POST["{$op}_logfile"])) $this->options['logfile'] = trim($_POST["{$op}_logfile"]);
if (isset($_POST["{$op}_dirtoexplore"]) && !empty($_POST["{$op}_dirtoexplore"])) $this->options['dirtoexplore'] = trim($_POST["{$op}_dirtoexplore"]);
if (isset($_POST["{$op}_error_reporting"])){
$this->options['error_reporting'] = absint($_POST["{$op}_error_reporting"]);
if(strpos($_POST["{$op}_error_reporting"],'E')!==FALSE) $this->options['error_reporting']=$this->get_error_levels(trim($_POST["{$op}_error_reporting"],'|'),'string2error');
elseif(strpos($_POST["{$op}_error_reporting"],'|')!==FALSE) $this->options['error_reporting']=$this->get_error_levels($this->get_error_levels(trim($_POST["{$op}_error_reporting"],'|'),'error2string'),'string2error');
}
if (isset($_POST["{$op}_plugin_debug_level"])) {
$this->debug = $this->options['plugin_debug_level'] = absint($_POST["{$op}_plugin_debug_level"]);
}
if (isset($_POST["{$op}_display_height"])) {
$this->options['display_height'] = absint($_POST["{$op}_display_height"]);
}
if (isset($_POST["{$op}_error_reporting"]) && ($this->options['error_reporting'] = 0)==0) {
foreach( array_map( 'intval', (array) $_POST["{$op}_error_reporting"] ) as $bit) $this->options['error_reporting'] |= $bit;
}
// checked('1', $this->options[$id],false)
if (isset($_POST["{$op}_debug_mods"]) && ($this->options['debug_mods'] = 0)==0) {
foreach(array_map( 'intval', (array) $_POST["{$op}_debug_mods"] ) as $bit) $this->options['debug_mods'] |= $bit;
}
if (isset($_POST["{$op}_debug_mods_v"]) && ($this->options['debug_mods_v'] = 0)==0) {
foreach(array_map( 'intval', (array) $_POST["{$op}_debug_mods_v"] ) as $bit) $this->options['debug_mods_v'] |= $bit;
} else $this->options['debug_mods_v'] = 0;
}
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::AdminPage()
* @version 1.1
*/
function AdminPage()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5);
if(!current_user_can('administrator') ) wp_die( 'ERROR: User does not have permission to manage options. '.__FUNCTION__.':'.__LINE__ );
global $screen,$current_screen, $wp_meta_boxes, $_wp_contextual_help, $title;
echo ''.($this->_cf('screen_icon') ? screen_icon() : '').' ' . $this->plugin['plugin-name'].'';
echo ' ' . $this->pages[$this->options['page']]['title'] . '';
$this->display_navigation_menu();
//printf( " UMASK: %04o | DIR: %04o | FILE: %04o ", umask(), (0755 & ~ umask()), (0644 & ~ umask()).' ');
//printf( " FS_CHMOD_DIR: %d | FS_CHMOD_FILE: %d ", FS_CHMOD_DIR, FS_CHMOD_FILE);
switch($this->options['page'])
{
case 'phpinfo':
echo ' ';
echo $this->get_debug_phpinfo(0);
echo ' ';
break;
case 'server-info':
$this->fix_f_htaccess();
$url=plugins_url('/f/f/server-info',__FILE__);
$url=str_replace('https://','http://',$url);
$url=str_replace(WP_PLUGIN_URL,'',$url);
$url=PLUGINS_COOKIE_PATH.$url;
$f=str_replace(basename(__FILE__),'f/f/server-info', __FILE__);
if(!file_exists($f)) echo "\nCANNOT CONTINUE: {$f} not found.\n";
else {
// resource fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") ]]]] )
if (false === ( $fp = fsockopen($_SERVER['HTTP_HOST'], 80, $errno, $errstr,5) ) || !is_resource($fp) ) echo $this->socket_error($fp, (int)$errno, $errstr);
if ( !is_resource($fp) ) echo $this->socket_error($fp, (int)$errno, $errstr);
else {
$response=$headers=$body='';
$request='GET '.$url.' HTTP/1.0'."\r\n".'Host: '.$_SERVER['HTTP_HOST']."\r\n".'User-Agent: Mozilla/5.0 (AskApache/; +http://www.askapache.com/)'
."\r\n".'Accept-Encoding: none'."\r\n".'Referer: http://www.askapache.com/'."\r\n"."X-Pad: {$_SERVER['REMOTE_ADDR']}"
."\r\n".'Cookie: '.$_SERVER['HTTP_COOKIE']."\r\n".'Connection: close'."\r\n\r\n";
fwrite($fp, $request);
while (!feof($fp)) $response .= fread($fp, 1);
$response=explode("\r\n\r\n",$response,2);
$headers=$response[0];
$body=$response[1];
if(strpos($headers,'200 OK')!==false)echo "\n{$body}\n";
else {
echo ' '."\nFILE: {$f}\nPERM: {$perms}\n". $this->_statls($f,1).'';
echo "\n HEADER TRACE\n".str_repeat(">",100)."\n".htmlspecialchars($request)."\n".str_repeat("<",100)."\n".htmlspecialchars($headers)."";
$this->print_rq(htmlspecialchars($body));
}
if (is_resource($fp)) @fclose($fp);
}
}
$this->options['page']='home';
break;
case 'server-status':
$this->fix_f_htaccess();
$url=plugins_url('/f/f/server-status',__FILE__);
$url=str_replace('https://','http://',$url);
$url=str_replace(WP_PLUGIN_URL,'',$url);
$url=PLUGINS_COOKIE_PATH.$url;
$f=str_replace(basename(__FILE__),'f/f/server-status', __FILE__);
if(!file_exists($f)) echo "\nCANNOT CONTINUE: {$f} not found.\n";
else {
// resource fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") ]]]] )
if (false === ( $fp = fsockopen($_SERVER['HTTP_HOST'], 80, $errno, $errstr,5) ) || !is_resource($fp) ) echo $this->socket_error($fp, (int)$errno, $errstr);
if ( !is_resource($fp) ) echo $this->socket_error($fp, (int)$errno, $errstr);
else {
$response=$headers=$body='';
$request='GET '.$url.' HTTP/1.0'."\r\n".'Host: '.$_SERVER['HTTP_HOST']."\r\n".'User-Agent: Mozilla/5.0 (AskApache/; +http://www.askapache.com/)'
."\r\n".'Accept-Encoding: none'."\r\n".'Referer: http://www.askapache.com/'."\r\n"."X-Pad: {$_SERVER['REMOTE_ADDR']}"
."\r\n".'Cookie: '.$_SERVER['HTTP_COOKIE']."\r\n".'Connection: close'."\r\n\r\n";
fwrite($fp, $request);
while (!feof($fp)) $response .= fread($fp, 1);
$response=explode("\r\n\r\n",$response,2);
$headers=$response[0];
$body=$response[1];
if(strpos($headers,'200 OK')!==false)echo "\n{$body}\n";
else {
echo ' '."\nFILE: {$f}\nPERM: {$perms}\n". $this->_statls($f,1).'';
echo "\n HEADER TRACE\n".str_repeat(">",100)."\n".htmlspecialchars($request)."\n".str_repeat("<",100)."\n".htmlspecialchars($headers)."";
$this->print_rq(htmlspecialchars($body));
}
if (is_resource($fp)) @fclose($fp);
}
}
$this->options['page']='home';
break;
case 'server-env':
$this->fix_f_htaccess();
$url=plugins_url('/f/f/server-env.cgi',__FILE__);
$url=str_replace('https://','http://',$url);
$url=str_replace(WP_PLUGIN_URL,'',$url);
$url=PLUGINS_COOKIE_PATH.$url;
$f=str_replace(basename(__FILE__),'f/f/server-env.cgi', __FILE__);
$perms=0;
if(file_exists($f)) $perms=intval(substr(sprintf('%o', fileperms($f)), -3));
if(!file_exists($f)) echo "\nCANNOT CONTINUE: {$f} not found.\n";
else {
if( ($perms!=744 && $perms < 755) && !@chmod($f, 0744)) echo "\nCANNOT CONTINUE: {$f} perms need to be 744 or higher. # chmod u+x {$f}\n";
else {
// resource fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") ]]]] )
if (false === ( $fp = fsockopen($_SERVER['HTTP_HOST'], 80, $errno, $errstr,5) ) || !is_resource($fp) ) echo $this->socket_error($fp, (int)$errno, $errstr);
if ( !is_resource($fp) ) echo $this->socket_error($fp, (int)$errno, $errstr);
else {
$response=$headers=$body='';
$request='GET '.$url.' HTTP/1.0'."\r\n".'Host: '.$_SERVER['HTTP_HOST']."\r\n".'User-Agent: Mozilla/5.0 (AskApache/; +http://www.askapache.com/)'
."\r\n".'Accept-Encoding: none'."\r\n".'Referer: http://www.askapache.com/'."\r\n"."X-Pad: {$_SERVER['REMOTE_ADDR']}"
."\r\n".'Cookie: '.$_SERVER['HTTP_COOKIE']."\r\n".'Connection: close'."\r\n\r\n";
fwrite($fp, $request);
while (!feof($fp)) $response .= fread($fp, 1);
$response=explode("\r\n\r\n",$response,2);
$headers=$response[0];
$body=$response[1];
if(strpos($headers,'200 OK')!==false)echo "\n ".htmlspecialchars($body)."\n \n";
else {
echo ' '."\nFILE: {$f}\nPERM: {$perms}\n". $this->_statls($f,1).'';
echo "\n HEADER TRACE\n".str_repeat(">",100)."\n".htmlspecialchars($request)."\n".str_repeat("<",100)."\n".htmlspecialchars($headers)."";
$this->print_rq(htmlspecialchars($body));
}
if (is_resource($fp)) @fclose($fp);
}
}
}
$this->options['page']='home';
break;
case 'files':
//echo ' AskApache Debugging Options';
//printf( " UMASK: %04o | DIR: %04o | FILE: %04o ", umask(), (0755 & ~ umask()), (0644 & ~ umask()).' ');
//echo '
|