. */ // 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; if(!class_exists('AA_DEBUG')): /******************************************************************************************************************************************************************************************************** PHP COMPAT FUNCTIONS ********************************************************************************************************************************************************************************************************/ 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; /******************************************************************************************************************************************************************************************************** WORDPRESS COMPAT 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; /******************************************************************************************************************************************************************************************************** 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 */ // 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); } !defined('__DIR__') && define('__DIR__', realpath(dirname(__FILE__))); !defined('FILE_BINARY') && define('FILE_BINARY', 0); /******************************************************************************************************************************************************************************************************** WORDPRESS DEFINES ********************************************************************************************************************************************************************************************************/ !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 !defined('FS_CHMOD_DIR') && define('FS_CHMOD_DIR', (S_IRWUGO & ~ umask())); !defined('FS_CHMOD_FILE') && define('FS_CHMOD_FILE', (S_IRWXUGO & ~ umask())); /* This is a cool workaround to defining functions already defined but throwing errors */ function aadv_DEFINE_function($f='') { switch($f) { case 'get_include_path': function get_include_path(){ return ini_get('include_path'); }; break; case 'set_include_path': function set_include_path($new_include_path){ return ini_set('include_path', $new_include_path); }; break; case 'restore_include_path': function restore_include_path(){ return ini_restore('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 'php_ini_loaded_file': function php_ini_loaded_file() { // 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 '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)) { user_error('ini_get_all() Unable to find php.ini', E_USER_WARNING); return false; } // Check the file is readable if (!is_readable($inifile)) { user_error('ini_get_all() Unable to open php.ini', E_USER_WARNING); return false; } // Parse the ini if ($extension !== null) { $ini_all = parse_ini_file($inifile, true); // Lowercase extension keys foreach ($ini_all as $key => $value) $ini_arr[strtolower($key)] = $value; // Check the extension exists if (isset($ini_arr[$extension])) $ini = $ini_arr[$extension]; else { user_error("ini_get_all() Unable to find extension '$extension'",E_USER_WARNING); return false; } } else { $ini = parse_ini_file($inifile); } // Order $ini_lc = array_map('strtolower', array_keys($ini)); array_multisort($ini_lc, SORT_ASC, SORT_STRING, $ini); // Format $info = array(); foreach ($ini as $key => $value) $info[$key] = array( 'global_value' => $value, 'local_value' => ini_get($key), 'access' => -1); return $info; } break; case 'is_a': function is_a($object, $class) { if (!is_object($object)) return false; if (strtolower(get_class($object)) == strtolower($class)) return true; else return is_subclass_of($object, $class); } break; case 'is_callable': function is_callable($var, $syntax_only = false) { if (!is_string($var) && !(is_array($var) && count($var) == 2 && isset($var[0], $var[1]) && is_string($var[1]) && (is_string($var[0]) || is_object($var[0])))) return false; if ($syntax_only) return true; if (is_string($var)) return function_exists($var); else if (is_array($var)) { if (is_string($var[0])) { $methods = get_class_methods($var[0]); $method = strtolower($var[1]); if ($methods) { foreach ($methods as $classMethod) { if (strtolower($classMethod) == $method) return true; } } } else return method_exists($var[0], $var[1]); } return false; } break; case 'mhash': if (!defined('MHASH_CRC32')) { define('MHASH_CRC32', 0); } if (!defined('MHASH_MD5')) { define('MHASH_MD5', 1); } if (!defined('MHASH_SHA1')) { define('MHASH_SHA1', 2); } if (!defined('MHASH_HAVAL256')) { define('MHASH_HAVAL256', 3); } if (!defined('MHASH_RIPEMD160')) { define('MHASH_RIPEMD160', 5); } if (!defined('MHASH_TIGER')) { define('MHASH_TIGER', 7); } if (!defined('MHASH_GOST')) { define('MHASH_GOST', 8); } if (!defined('MHASH_CRC32B')) { define('MHASH_CRC32B', 9); } if (!defined('MHASH_HAVAL192')) { define('MHASH_HAVAL192', 11); } if (!defined('MHASH_HAVAL160')) { define('MHASH_HAVAL160', 12); } if (!defined('MHASH_HAVAL128')) { define('MHASH_HAVAL128', 13); } if (!defined('MHASH_TIGER128')) { define('MHASH_TIGER128', 14); } if (!defined('MHASH_TIGER160')) { define('MHASH_TIGER160', 15); } if (!defined('MHASH_MD4')) { define('MHASH_MD4', 16); } if (!defined('MHASH_SHA256')) { define('MHASH_SHA256', 17); } if (!defined('MHASH_ADLER32')) { define('MHASH_ADLER32', 18); } function mhash($hashtype, $data, $key = '') { switch ($hashtype) { case MHASH_MD5: $key = str_pad((strlen($key) > 64 ? pack("H*", md5($key)) : $key), 64, chr(0x00)); $k_opad = $key ^ (str_pad('', 64, chr(0x5c))); $k_ipad = $key ^ (str_pad('', 64, chr(0x36))); return pack("H*", md5($k_opad . pack("H*", md5($k_ipad . $data)))); default: return false; break; } }break; case 'get_current_screen': function get_current_screen() { global $current_screen; return (( !isset($current_screen) ) ? null : $current_screen); }; 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 'is_scalar': function is_scalar($val){ return (is_bool($val) || is_int($val) || is_float($val) || is_string($val)); }; break; case 'md5_file': function md5_file($filename, $raw_output = false) { // Sanity check if (!is_scalar($filename)) { user_error('md5_file() expects parameter 1 to be string, ' . gettype($filename) . ' given', E_USER_WARNING); return; } if (!is_scalar($raw_output)) { user_error('md5_file() expects parameter 2 to be bool, ' . gettype($raw_output) . ' given', E_USER_WARNING); return; } if (!file_exists($filename)) { user_error('md5_file() Unable to open file', E_USER_WARNING); return false; } // Read the file if (false === $fh = fopen($filename, 'rb')) { user_error('md5_file() failed to open stream: No such file or directory', E_USER_WARNING); return false; } clearstatcache(); if ($fsize = @filesize($filename)) { $data = fread($fh, $fsize); } else { $data = ''; while (!feof($fh)) { $data .= fread($fh, 8192); } } fclose($fh); // Return $data = md5($data); if ($raw_output === true) { $data = pack('H*', $data); } return $data; } break; case 'microtime': function microtime($get_as_float = false) { if (!function_exists('gettimeofday')) { $time = time(); return $get_as_float ? ($time * 1000000.0) : '0.00000000 ' . $time; } $gtod = gettimeofday(); $usec = $gtod['usec'] / 1000000.0; return $get_as_float ? (float) ($gtod['sec'] + $usec) : (sprintf('%.8f ', $usec) . $gtod['sec']); } break; case 'mkdir': function mkdir($pathname, $mode = 0777, $recursive = true, $context = null) { if (version_compare(PHP_VERSION, '5.0.0', 'gte')) { // revert to native function return (func_num_args() > 3) ? mkdir($pathname, $mode, $recursive, $context) : mkdir($pathname, $mode, $recursive); } if (!strlen($pathname)) { user_error('No such file or directory', E_USER_WARNING); return false; } if (is_dir($pathname)) { if (func_num_args() == 5) { // recursive call return true; } user_error('File exists', E_USER_WARNING); return false; } $parent_is_dir = php_compat_mkdir(dirname($pathname), $mode, $recursive, null, 0); if ($parent_is_dir) { return mkdir($pathname, $mode); } user_error('No such file or directory', E_USER_WARNING); return false; } break; case 'ob_clean': function ob_clean() { if (@ob_end_clean()) { return ob_start(); } user_error("ob_clean() failed to delete buffer. No buffer to delete.", E_USER_NOTICE); return false; } break; case 'ob_flush': function ob_flush() { if (@ob_end_flush()) { return ob_start(); } user_error("ob_flush() Failed to flush buffer. No buffer to flush.", E_USER_NOTICE); return false; } break; case 'ob_get_clean': function ob_get_clean() { $contents = ob_get_contents(); if ($contents !== false) { ob_end_clean(); } return $contents; } break; case 'ob_get_flush': function ob_get_flush() { $contents = ob_get_contents(); if ($contents !== false) { ob_end_flush(); } return $contents; } break; case 'pathinfo': if (!defined('PATHINFO_FILENAME')) { define('PATHINFO_FILENAME', 8); }function pathinfo($path = false, $options = false) { // Sanity check if (!is_scalar($path)) { user_error('pathinfo() expects parameter 1 to be string, ' . gettype($path) . ' given', E_USER_WARNING); return; } if (version_compare(PHP_VERSION, '5.2.0', 'ge')) { return pathinfo($path, $options); } if ($options & PATHINFO_FILENAME) { //bug #15688 if (strpos($path, '.') !== false) { $filename = substr($path, 0, strrpos($path, '.')); } if ($options === PATHINFO_FILENAME) { return $filename; } $pathinfo = pathinfo($path, $options); $pathinfo['filename'] = $filename; return $pathinfo; } return pathinfo($path, $options); } 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 'var_export': function var_export($var, $return = false, $level = 0, $inObject = false) { // Init $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) { // Array case 'array': if ($inObject) { $out .= $newline . $previndent; } $out .= 'array (' . $newline; foreach ($var as $key => $value) { // Key if (is_string($key)) { // Make key safe $key = str_replace($find, $replace, $key); $key = $stringdelim . $key . $stringdelim; } // Value if (is_array($value)) { $export = php_compat_var_export($value, true, $level); $value = $newline . $previndent . $indent . $export; } else { $value = php_compat_var_export($value, true, $level); } // Piece line together $out .= $previndent . $indent . $key . $doublearrow . $value . $lineend; } // End string $out .= $previndent . ')'; break; // String 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; // Number case 'integer': case 'double': $out = (string) $var; break; // Boolean case 'boolean': $out = $var ? 'true' : 'false'; break; // NULLs case 'NULL': case 'resource': $out = 'NULL'; break; // Objects 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; $out .= php_compat_var_export($value, true, $level, true) . $lineend; } $out .= $previndent . '))'; break; } // Method of output if ($return === true) { return $out; } else { echo $out; } } 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 'set_current_screen': function set_current_screen( $id = '' ) { global $current_screen, $hook_suffix, $typenow, $taxnow; $action = ''; if ( empty($id) ) { $current_screen = str_replace('.php', '', $hook_suffix); if ( preg_match('/-add|-new$/', $current_screen) ) $action = 'add'; $current_screen = str_replace('-add', '', str_replace('-new', '', $current_screen)); $current_screen = array('id' => $current_screen, 'base' => $current_screen); } else { $id = sanitize_key($id); if ( false !== strpos($id, '-') ) { list( $id, $typenow ) = explode('-', $id, 2); if ( taxonomy_exists( $typenow ) ) {$id = 'edit-tags';$taxnow = $typenow;$typenow = '';} } $current_screen = array('id' => $id, 'base' => $id); } $current_screen = (object) $current_screen; $current_screen->action = $action; if ( 'index' == $current_screen->base ) $current_screen->base = 'dashboard'; if ( 'index' == $current_screen->id ) $current_screen->id = 'dashboard'; if ( 'edit' == $current_screen->id ) { if ( empty($typenow) )$typenow = 'post'; $current_screen->id .= '-' . $typenow; $current_screen->post_type = $typenow; } elseif ( 'post' == $current_screen->id ) { if ( empty($typenow) ) $typenow = 'post'; $current_screen->id = $typenow; $current_screen->post_type = $typenow; } elseif ( 'edit-tags' == $current_screen->id ) { if ( empty($taxnow) ) $taxnow = 'post_tag'; $current_screen->id = 'edit-' . $taxnow; $current_screen->taxonomy = $taxnow; } $current_screen->is_network = is_network_admin(); $current_screen->is_user = is_user_admin(); if ( $current_screen->is_network ) {$current_screen->base .= '-network';$current_screen->id .= '-network';} elseif ( $current_screen->is_user ) {$current_screen->base .= '-user';$current_screen->id .= '-user';} $current_screen = apply_filters('current_screen', $current_screen); } break; } } /** * AA_DEBUG * * @package * @author life * @copyright Copyright (c) 2011 * @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 $op='adv7'; var $old_inis = array(); var $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', 'request_order' => 'GPCES', 'register_globals' => 'On', 'register_long_arrays' => 'On', 'register_argc_argv' => 'On', 'always_populate_raw_post_data' => 'On', //'output_buffering' => 'Off', 'error_reporting' => 0, 'display_errors' => 'Off', 'display_startup_errors' => 'Off', 'log_errors' => 'On', 'html_errors' => 'Off', 'track_errors' => 'On', 'report_memleaks' => 'On', //'report_zend_debug' => 'Off', 'magic_quotes_runtime' => 'Off', 'magic_quotes_gpc' => 'Off', 'ignore_repeated_errors' => 'On', 'ignore_repeated_source' => 'On', //'precision'=>'14', 'log_errors_max_len'=>'1000240' ); var $sections = array( 'config' => 'Main Config', /* 'logging' => 'Log Settings', 'files' => 'File Browser', 'phpini' => 'php.ini Setup', */ 'wpconfig' => 'wp-config.php Settings' ); var $debug_mods = array( 0x0000001 => array('included', 'Files included by php'), 0x0000002 => array('functions', 'Function Information'), 0x0000004 => array('classes', 'Information about Loaded Classes'), 0x0000008 => array('globals', 'Global Server/Request Information'), 0x0000010 => array('extensions', 'Extensions Loaded by PHP'), 0x0000020 => array('defined', 'Defined Constants and variables'), 0x0000040 => array('inis', 'Your PHP.ini settings'), 0x0000080 => array('phpinfo', 'Information from phpinfo'), 0x0000100 => array('permissions', 'Information about Owner/User/File permissions'), 0x0000200 => array('interfaces', 'Declared interfaces in the current script'), 0x0000400 => array('sockets', 'Socket and Stream Debugging'), 0x0001000 => array('rewrites', 'WordPress Rewrites'), 0x0002000 => array('queries', 'View DataBase Queries'), 0x0004000 => array('wordpress', 'Debug WordPress Globals'), 0x0008000 => array('globalprint', 'Show All GLOBALS') ); /** AA_DEBUG::AA_DEBUG() */ function AA_DEBUG() { return $this->__construct(); } /** AA_DEBUG::__construct() */ function __construct() { //error_log(str_repeat("\n",75)."\033[2;2H".str_repeat("=",235)); $this->l(str_repeat("\n",5).str_repeat("=",235),5); $this->tt(__FILE__); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $this->LoadOptions(); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::__destruct() */ function __destruct() { //$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); //$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return true; } /** AA_DEBUG::LoadOptions() */ function LoadOptions() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $this->plugin = $this->get_plugin_data(); $this->options=get_option('askapache_debug_options'); $this->debug=$this->options['plugin_debug_level']; foreach($this->ini_overwrites as $k=>$v)$this->old_inis[$k]=@ini_get($k); $this->old_inis['error_reporting']=error_reporting(); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::SaveOptions() */ function SaveOptions() { if( function_exists('current_user_can') && !current_user_can('manage_options') ) wp_die(__FUNCTION__.':'.__LINE__); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); update_option('askapache_debug_options', $this->options); update_option('askapache_debug_plugin', $this->plugin); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::DefaultOptions() */ function DefaultOptions() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); delete_option("askapache_debug_options"); delete_option("askapache_debug_plugin"); // get all the plugin array data $this->plugin = $this->get_plugin_data(); $this->options=array( 'logfile' => $this->get_error_log(), 'dirtoexplore' => dirname($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, '', 'yes'); add_option('askapache_debug_plugin', $this->plugin, '', 'yes'); // Save all these variables to database $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $this->SaveOptions(); } /** AA_DEBUG::Activate() */ function Activate() { global $wp_roles; $wp_roles->add_cap("administrator", "askapache_debug_viewer"); $this->DefaultOptions(); } /** AA_DEBUG::DeActivate() */ function DeActivate() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); global $wp_roles; $wp_roles->remove_cap("administrator", "askapache_debug_viewer"); delete_option("askapache_debug_options"); delete_option("askapache_debug_plugin"); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::Uninstall() */ function Uninstall() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); global $wp_roles; $wp_roles->remove_cap("administrator", "askapache_debug_viewer"); delete_option("askapache_debug_options"); delete_option("askapache_debug_plugin"); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::Init() */ function Init() { if ( !$user = wp_get_current_user() ) return; //stripslashes($_GET['page']) add_action("load-{$this->plugin['hook']}", array(&$this, 'Load')); add_action("admin_print_styles-{$this->plugin['hook']}", create_function('', 'echo "";')); add_action("admin_print_scripts-{$this->plugin['hook']}",create_function('',' wp_register_script("'.$this->plugin['pagenice'].'", "'.plugins_url('/f/admin.js',__FILE__).'", array("jquery","common","wp-lists","postbox","jquery-ui-core","jquery-ui-dialog","jquery-ui-tabs"), "'.$this->plugin['version'].'", true); wp_enqueue_script("'.$this->plugin['pagenice'].'", "'.plugins_url('/f/admin.js',__FILE__).'", array("jquery","common","wp-lists","postbox","jquery-ui-core","jquery-ui-dialog","jquery-ui-tabs"), "'.$this->plugin['version'].'", true); ' )); /*add_action("admin_print_scripts-{$this->plugin['hook']}", create_function('', 'echo "";'));*/ //add_action("admin_print_scripts",create_function('','wp_enqueue_script("jquery");')); } /** AA_DEBUG::Load() */ function Load() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); global $screen,$current_screen, $wp_meta_boxes, $_wp_contextual_help, $title; set_screen_options(); if(!function_exists('get_current_screen')) aadv_DEFINE_function('get_current_screen'); if(!function_exists('set_current_screen')) aadv_DEFINE_function('set_current_screen'); if(function_exists('set_current_screen')) set_current_screen($current_screen->id); // parse and handle post requests to plugin if('POST' === $_SERVER['REQUEST_METHOD']) $this->HandlePost(); // add contextual help $help = '

Fixing Status Headers

'; $help .= '

For super-advanced users, or those with access and knowledge of Apache .htaccess/httpd.conf files'; $help .=' you should check that your error pages are correctly returning a 404 Not Found'; $help .=' 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'; $help .=' is to add the following to your .htaccess file.

'; $help .= '
ErrorDocument 404 /index.php?error=404'."\n".'Redirect 404 /index.php?error=404
'; $help .= '
Comments/Questions

Please visit AskApache.com or send me an email at webmaster@askapache.com

'; add_contextual_help($this->plugin['hook'], $help); // enqueue css wp_enqueue_style($this->plugin['pagenice'], plugins_url('/f/admin.css',__FILE__), array('dashboard','wp-admin'), $this->plugin['version'], 'all'); //wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) //wp_register_script($this->plugin['pagenice'], plugins_url('/f/admin.js',__FILE__), array("jquery","common","wp-lists","postbox","thickbox","jquery-ui-core","jquery-ui-dialog","jquery-ui-tabs"), $this->plugin['version'], true); // enqueue js //foreach(array('jquery-ui-core','jquery-ui-dialog','jquery-ui-tabs', 'thickbox') as $js) wp_enqueue_script("$js"); //wp_enqueue_script('jquery-ui-tabs'); //wp_register_script($this->plugin['pagenice'], plugins_url('/f/admin.js',__FILE__), false, false, false); //wp_enqueue_script($this->plugin['pagenice'], plugins_url('/f/admin.js',__FILE__), false, false, false); //wp_enqueue_script('jquery-cookie', plugins_url('f/jquery.cookie.js', __FILE__)); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::HandlePost() */ function HandlePost() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); if ( !current_user_can('manage_options') ) wp_die( 'ERROR: User does not have permission to manage options.' ); // if current user does not have administrator rights, then DIE if(!current_user_can('administrator')) wp_die('ERROR: Not an Admin!'); // 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["{$this->op}_action_reset"])) return $this->DefaultOptions(); 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["{$this->op}_{$k}"]) ? '1' : '0'); if( isset($_POST["{$this->op}_log_errors"]) || empty($this->options['logfile']) ) $this->options['logfile']=$this->get_error_log(); if (isset($_POST["{$this->op}_logfile"]) && !empty($_POST["{$this->op}_logfile"])) $this->options['logfile'] = trim($_POST["{$this->op}_logfile"]); if (isset($_POST["{$this->op}_dirtoexplore"]) && !empty($_POST["{$this->op}_dirtoexplore"])) $this->options['dirtoexplore'] = trim($_POST["{$this->op}_dirtoexplore"]); if (isset($_POST["{$this->op}_error_level"])){ $this->options['error_level'] = intval($_POST["{$this->op}_error_level"]); if(strpos($_POST["{$this->op}_error_level"],'E')!==FALSE) $this->options['error_level']=$this->get_error_levels(trim($_POST["{$this->op}_error_level"],'|'),'string2error'); elseif(strpos($_POST["{$this->op}_error_level"],'|')!==FALSE) $this->options['error_level']=$this->get_error_levels($this->get_error_levels(trim($_POST["{$this->op}_error_level"],'|'),'error2string'),'string2error'); } if (isset($_POST["{$this->op}_plugin_debug_level"])) { $this->debug = $this->options['plugin_debug_level'] = intval($_POST["{$this->op}_plugin_debug_level"]); } if (isset($_POST["{$this->op}_error_reporting"]) && ($this->options['error_reporting'] = 0)==0) { foreach( array_map( 'intval', (array) $_POST["{$this->op}_error_reporting"] ) as $bit) $this->options['error_reporting'] |= $bit; } // checked('1', $this->options[$id],false) if (isset($_POST["{$this->op}_debug_mods"]) && ($this->options['debug_mods'] = 0)==0) { foreach(array_map( 'intval', (array) $_POST["{$this->op}_debug_mods"] ) as $bit) $this->options['debug_mods'] |= $bit; } if (isset($_POST["{$this->op}_debug_mods_verbose"]) && ($this->options['debug_mods_verbose'] = 0)==0) { foreach(array_map( 'intval', (array) $_POST["{$this->op}_debug_mods_verbose"] ) as $bit) $this->options['debug_mods_verbose'] |= $bit; } $this->SaveOptions(); } $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::AdminPage() */ function AdminPage() { if(!current_user_can('manage_options') ) wp_die( 'ERROR: User does not have permission to manage options.' ); if(!current_user_can('administrator')) wp_die('ERROR: Not an Admin!'); global $screen,$current_screen, $wp_meta_boxes, $_wp_contextual_help, $title; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); echo '
'; if(function_exists('screen_icon')) screen_icon(); echo '

' . $this->plugin['plugin-name'].'

'; if($this->d(5)) { $this->p($_POST); $this->p($this->options); } echo '
'; echo '

'; echo '

'; echo '
'; echo '
    '; foreach($this->sections as $section_id => $section_name)printf('
  • %s
  • ', esc_attr($section_id), $section_name); echo '
'; foreach($this->sections as $section_id => $section_name){ echo "\n".'

'.$section_name.'

'; $this->{"TAB_$section_id"}(); echo '
'."\n"; } echo '
'; //echo '

AskApache Debugging Options

'; //printf( "

UMASK: %04o | DIR: %04o | FILE: %04o ", umask(), (0755 & ~ umask()), (0644 & ~ umask()).'

'); //echo '


'; //echo '
'; //echo '

Debug Options

'; //foreach ( $this->wb($this->options['debug_mods']) as $id ) $oa[strtoupper($this->debug_mods[$id][0])] = $this->{'get_debug_'.$this->debug_mods[$id][0]}( in_array($id, $this->wb($this->options['debug_mods_verbose']) ) ? 1 : 0 ); /*echo '
'; foreach ($this->get_error_levels() as $n=>$v) echo '

'; echo '

'; */ //wp_nonce_field( 'aadebug_settings_form' ); echo '

'; //echo "

Save Changes »

"; echo '

    '; 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','error_log') as $k) { $v1=@ini_get($k); $v2=@get_cfg_var($k); if(empty($v1) && empty($v2))continue; if($v1 != $v2 && ! empty($v2) ) $v2=' | '.$v2.''; else $v2=''; printf('
  • %1$s: %2$s%3$s
  • ', $k, $v1, $v2 ); } echo '

'; $e=array();$eany=0; foreach($this->get_error_levels(0,'defined') as $k=>$v) $eany |= $e["$k"]=constant($k); printf('

Previous error_reporting: %1$s - %2$s

', intval($this->old_inis['error_reporting']), $this->get_error_levels($this->old_inis['error_reporting'],'error2string')); printf('

Current error_reporting: %1$s - %2$s

', $eany, $this->get_error_levels($eany,'error2string')); echo '
    '; foreach($this->get_error_levels(error_reporting(),'enabled') as $k=>$v) echo "
  • {$v[1]} ({$v[0]}): {$v[2]}
  • "; echo '
'; echo '

To duplicate the current error_reporting setting in a script:
'.$this->get_error_levels(error_reporting(),'enabled_php_code').'

'; echo '
  ; Common Values:
  ;   E_ALL & ~E_NOTICE  (Show all errors, except for notices and coding standards warnings.)
  ;   E_ALL & ~E_NOTICE | E_STRICT  (Show all errors, except for notices)
  ;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
  ;   E_ALL | E_STRICT  (Show all errors, warnings and notices including coding standards.)
  ; Default Value: E_ALL & ~E_NOTICE
  ; Development Value: E_ALL | E_STRICT
  ; Production Value: E_ALL & ~E_DEPRECATED
  ; http://php.net/error-reporting

'; $this->_pls($this->options['dirtoexplore'],1); echo ''; // just a temp solution.. will be cleaned for next release echo ""; if($this->d(55)) $this->pp(array('plugin' => $this->plugin, 'old_inis' => $this->old_inis)); echo '
'; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::TAB_config() */ function TAB_config() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $this->form_field( 2, 'PHP Error Reporting Level', 'error_level', 'PHP Error Reporting Level.' ); $this->form_field( 2, 'Plugin Debug Level (0-100)', 'plugin_debug_level', 'Plugin Debug Level.' ); $this->form_field( 2, 'Error Log File: ', 'logfile', 'Error Log File: ' ); $this->form_field( 2, 'Dir to Explore: ', 'dirtoexplore', 'Dir to Explore: ' ); $this->form_field( 1, 'Log Errors to File', 'log_errors', 'Log Errors to File' ); $this->form_field( 1, 'Enable Live Debugging', 'debug_live', 'Enable Live Debugging' ); $this->form_field( 1, 'View in admin_footer', 'admin_footer', 'View in admin_footer' ); $this->form_field( 1, 'View in wp_footer', 'wp_footer', 'View in wp_footer' ); echo '
'; echo '
'; echo ''; echo ''; foreach ($this->debug_mods as $id => $info) { echo '

'; echo '

'; } echo '
'; echo '

'; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::TAB_logging() */ function TAB_logging() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); //echo '

'; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::TAB_files() */ function TAB_files() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); //$this->form_field( 2, 'Dir to Explore: ', 'dirtoexplore', 'Dir to Explore: ' ); //$this->_pls($this->options['dirtoexplore'],1); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::TAB_phpini() */ function TAB_phpini() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::TAB_wpconfig() */ function TAB_wpconfig() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); echo '

wp-config.php Settings

'; /* 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; } } */ $wp_config=(file_exists(ABSPATH.'wp-config.php')) ? ABSPATH.'wp-config.php' : ( file_exists(dirname(ABSPATH).'/wp-config.php') ? dirname(ABSPATH).'/wp-config.php' : ''); //rtrim($line, "\r\n") . PHP_EOL echo "

Current Contents of {$wp_config}

"; echo preg_replace('#color="(.*?)"#', 'style="color:\\1"', str_replace(array(''), array(''), highlight_string(stripslashes(file_get_contents($wp_config)), true))); /* 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 unneccessary if you can modify your php.ini - See my wp-config.php tutorial.

'; echo ''; echo preg_replace('#color="(.*?)"#', 'style="color:\\1"', str_replace(array(''), array(''), highlight_string(stripslashes($rec), true))); */ $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** 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') { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $plugin = get_option("askapache_debug_plugin"); if(!is_array($plugin) || !!!$plugin || !array_key_exists('file',$plugin) || "{$plugin['file']}"!=__FILE__) { $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['file'] = __FILE__; $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']; $plugin['action'] = (($type=='settings') ? 'options-general' : $type).'.php?page=' . $plugin['page']; $plugin['op'] = 'adv7'; } $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $plugin; } /** AA_DEBUG::form_field() */ function form_field($w = 1, $title = '', $id = '', $desc = '') { echo '
'; switch ($w) : case 1: echo "

options[$id],false)." />"; echo "

"; break; case 2: echo "


"; echo "

"; break; case '2j': echo "


"; echo "

"; break; case '2h': echo "


"; echo "

"; break; case 3: echo "


"; break; case 5: echo "

{$title}
"; echo "
"; break; endswitch; echo '
'; } /** AA_DEBUG::_cf() */ function _cf($f) { static $b=NULL,$g = array(); if(is_null($b)) $b = ( function_exists('ini_get') ) ? array_map('trim', (array)explode(',',strtolower(ini_get('disable_functions')." ".ini_get('suhosin.executor.func.blacklist')." "))) : array(); $f=strtolower($f); //error_log(print_r(array('good'=>$g,'bad'=>$b),1)); if ( ( 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->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $time = ( time() - $check_time ); return ( $newer_than < $time ) ? true : false; } /** AA_DEBUG::_get_rand_str() * * @param mixed $l * @param mixed $c */ function _get_rand_str($l=null,$c=null) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** 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); } /** AA_DEBUG::print_ra() */ function print_ra(&$varInput, $var_name='', $reference='', $method = '=', $sub = false) { static $output=''; static $depth=0; if ( $sub == false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $output = ''; $depth = 0; $reference = $var_name; $var = unserialize( serialize( $varInput ) ); } else { ++$depth; $var =& $varInput; } // constants $nl = "\n"; $block = 'a_big_recursion_protection_block'; $c = $depth; $indent = ''; while( $c -- > 0 ) $indent .= '| '; // if this has been parsed before if ( is_array($var) && isset($var[$block])) { $real =& $var[ $block ]; $name =& $var[ 'name' ]; $type = gettype( $real ); $output .= $indent.$var_name.' '.$method.'& '.($type=='array'?'Array':(($type!='string'&&!is_bool($real)&&!is_int($real))?get_class($real):$real)).' '.$name.$nl; // havent parsed this before } else { // insert recursion blocker $var = array( $block => $var, 'name' => $reference ); $theVar =& $var[ $block ]; // print it out $type = gettype($theVar); switch( $type ) { case 'array' : $output .= $indent . $var_name . ' '.$method.' Array ('.$nl; foreach(array_keys($theVar) as $name) $this->print_ra($value=&$theVar[$name], $name, $reference.'["'.$name.'"]', '=', true); $output .= $indent.')'.$nl; break; case 'object' : $output .= $indent.$var_name.' = '.get_class($theVar).' {'.$nl; foreach($theVar as $name=>$value)$this->print_ra($value, $name, $reference.'->'.$name, '->', true); $output .= $indent.'}'.$nl; break; case 'string' : $output .= "{$indent}{$var_name}{$method}\"{$theVar}\"{$nl}"; break; default:$output .= "{$indent}{$var_name} {$method} ({$type}) {$theVar}{$nl}"; break; } // $var=$var[$block]; } -- $depth; if( $sub == false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $output; } } /** AA_DEBUG::p() */ function p($o) { //$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); if(!!$o && ob_start() && (print $$o) ) array_walk_recursive($o, create_function('&$v,$k', 'echo "[$k] => $v\n";')); echo "
".htmlspecialchars(ob_get_clean())."
"; //$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::pp() * * @param mixed $text * @param integer $format */ function pp( $obj, $format = 1 ) { echo '
';
		if (is_array($obj) || is_object($obj)) echo htmlspecialchars(print_r($obj,1));
		else {
			if(is_string($obj))echo htmlspecialchars($obj)."\n";
			else { ob_start(); var_dump($obj); echo htmlspecialchars(ob_get_clean()); }
		}
		echo '
'; return true; } /** AA_DEBUG::tt() */ function tt($id = 'new', $d = false) { static $a = FALSE; static $b = FALSE; if(!!!$a)$a=$b=array(); $ct = array_sum(explode(chr(32), microtime())); //$this->l("id: $id | ". ($d?'1':'0')." | ".$ct); if(!isset($a[$id])){ $a[$id] = $ct; $b[$id] = 0; //$this->l("id: $id | ". ($d?'1':'0') ." | ".$a[$id]." | ".$b[$id],100); //if($d) return '0.0000'; return array($b[$id], '0.0000'); }else { $b[$id]+=1; //$this->l("id: $id | ". ($d?'1':'0') ." | ".$a[$id]." | ".$b[$id],100); return array($b[$id], sprintf("%.4f", ($ct - $a[$id]))); } } /** AA_DEBUG::t() */ function t($f='', $c='AA_DEBUG', $fu='', $l='0', $m='') { $f=str_replace(dirname($f).'/','',$f); $t1=$this->tt("{$f}{$c}{$fu}",1); if($m=='')$m=(($t1[0] % 2) == 0) ? "[{$t1[0]}] Start..." : "[{$t1[0]}] End..."; $t2=$this->tt($f,1); $this->l("PHP Notice: ".$f." [".$t1[1]."] [".$t2[1]."] [".$this->mem_usage(1)."] {$c}::{$fu}() {$m} on line $l"); return; } /** AA_DEBUG::d() */ function d($level=0) { return (bool) ( intval($this->debug) >= intval($level) ) ? true : false; } /** AA_DEBUG::l() */ function l($msg,$pl=5,$b=false) { if( $this->options && $this->options['log_errors']=='1' && $this->d($pl) ){ if($b){ $f=str_replace(dirname(__FILE__).'/','',__FILE__); $t2=$this->tt($f); error_log("PHP Notice: ".$f." [ ] [".$t2[1]."] [".$this->mem_usage(1)."] ".__CLASS__."::l()"." {$msg}"); } else error_log($msg); } return; } /** AA_DEBUG::get_error_log() */ 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($v='',$type='defined') { /* $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 ); */ static $error_levels=false; static $els=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.') ); if(false===$error_levels) { //$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $error_levels=array(); foreach(array('ERROR','WARNING','PARSE','NOTICE','CORE_ERROR','CORE_WARNING','COMPILE_ERROR','COMPILE_WARNING','USER_ERROR','USER_WARNING','USER_NOTICE','STRICT','RECOVERABLE_ERROR','DEPRECATED','USER_DEPRECATED','ALL') as $k) if(defined("E_{$k}")) $error_levels["E_{$k}"]=constant("E_{$k}"); /* Array ( [E_ERROR] => 1 [E_WARNING] => 2 [E_PARSE] => 4 [E_NOTICE] => 8 [E_CORE_ERROR] => 16 [E_CORE_WARNING] => 32 [E_COMPILE_ERROR] => 64 [E_COMPILE_WARNING] => 128 [E_USER_ERROR] => 256 [E_USER_WARNING] => 512 [E_USER_NOTICE] => 1024 [E_STRICT] => 2048 [E_RECOVERABLE_ERROR] => 4096 [E_DEPRECATED] => 8192 [E_USER_DEPRECATED] => 16384 [E_ALL] => 30719 ) */ $this->l(print_r($error_levels,1),99); } switch($type) { case 'defined': $ret=$error_levels; break; case 'string2error': $e=0; foreach((array)array_map('trim',(array)explode('|',"{$v}")) as $l) if(defined($k)) $e|=(int)constant($k); $ret=$k; break; case 'error2string': $ls=array();if( ( $v & E_ALL ) == E_ALL ){ $ls[]='E_ALL';$v &= ~E_ALL; } foreach($error_levels as $l=>$n) if(($v&$n)==$n) $ls[]="$l"; $ret=implode('|',$ls); break; case 'enabled': $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,$re[]=$this->get_error_levels($end,'error2string'),$els[$end][1]); $bit -= $end; } $ret=array_reverse($res); break; case 'enabled_php_code': $res=$this->get_error_levels($v,'enabled'); $re=array(); foreach($res as $k=>$v) $re[]=$v[1]; $ret='error_reporting('.implode('|',$re).');'; break; } //$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $ret; } /** AA_DEBUG::get_posix_info() * * @param string $type * @param string $id * @param mixed $item */ function get_posix_info( $type = 'all', $id = '', $item = false ) { //$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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); $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; //$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return (( $item !== false && isset($info[$item]) ) ? $info[$item] : $info); } /** AA_DEBUG::_ls() * * @param string $folder * @param integer $levels */ function _ls( $folder = '', $levels = 2 ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $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($folder.'/', '', realpath($file)) ); } echo '
';
		echo join( "\n", array_merge(array($folder), $list) );
		//echo join( "\n", array_merge(array($folder . " Listing"), $list) );
		echo '
'; } /** AA_DEBUG::_is_readable() * * @param mixed $fl */ function _is_readable( $fl ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); if ( is_dir($fl) && ob_start() ) { $return=is_readable( $fl ); ob_get_clean(); } if(!$return) $return=( $this->_file_exists($fl) && (is_readable($fl) || $this->_fclose($this->_fopen($fl, 'rb'))) ) ? true : false; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $return; } /** AA_DEBUG::_file_exists() * * @param mixed $fl */ function _file_exists( $fl ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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->l(__FILE__,__CLASS__,__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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $return=( ((@fclose($fh)) !== false && ($fh=null)!== false) || ! is_resource($fh) ) ? true : false; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $return; } /** AA_DEBUG::_fopen() * * @param mixed $file * @param mixed $mode */ function _fopen( $file, $mode ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $this->l($file,$mode); //$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; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $return; } /** AA_DEBUG::_fread() * * @param mixed $fh * @param mixed $ts * @param integer $bs */ function _fread( &$fh, $ts = false, $bs = 2048 ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__, " [RT: {$rt}]\t[BR: {$br}" . (($ts != 50000000) ? "]\t\t [{$r} / {$ts}]" : " : {$bs}]\t[{$at}]")) ); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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->t(__FILE__,__CLASS__,__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->t(__FILE__,__CLASS__,__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->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); if ( ! $this->_file_exists($file) ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,"no such file! {$file}"); $return=false; } else { if ( ! $len ) $len = filesize( $file ); if ( ($fh = $this->_fopen($file, 'rb')) === false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,"Error opening rb handle for {$file}"); $return=false; } $data = $this->_fread( $fh, $len ); } if( ! $this->_fclose($fh) ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,"Error closing rb handle on {$file}"); $return=false; } else $return=$data; return $return; } /** AA_DEBUG::_mkdir() * * @param mixed $dir * @param integer $mode */ function _mkdir( $dir, $mode = 0755 ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); if ( ! wp_mkdir_p($dir) ) return $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,"Couldnt create directory! ${dir}" ); } /** AA_DEBUG::_rmdir() * * @param mixed $dir */ function _rmdir( $dir ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $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->t(__FILE__,__CLASS__,__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->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); if ( is_writable($fl) || touch($fl) ) $return=true; else { $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; else { 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 ); $return=$w; } } $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $return; } /** AA_DEBUG::relPath() */ 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_debug_wordpress() */ function get_debug_wordpress($vb=false) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); global $wp_query,$wp,$wpdb,$wp_rewrites,$wp_object_cache; $return= ( $vb===false ? array('wp_query'=>print_r($wp_query,1)) : array( 'wp'=>$this->print_ra($wp), 'wpdb'=>$this->print_ra($wpdb), 'wp_query'=>$this->print_ra($wp_query), 'wp_rewrites'=>$this->print_ra($wp_rewrites) )); //$debugs = array(); //if ( defined('SAVEQUERIES') && SAVEQUERIES )$debugs['wpdb'] = array( __('Queries'), 'wp_admin_bar_debug_queries' ); //if ( is_object($wp_object_cache) && method_exists($wp_object_cache, 'stats') )$debugs['object-cache'] = array( __('Object Cache'), 'wp_admin_bar_debug_object_cache' ); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $return; } /* function wp_admin_bar_debug_object_cache() { global $wp_object_cache; ob_start(); echo "
"; $wp_object_cache->stats(); echo "
"; $out = ob_get_contents(); ob_end_clean(); return $out; } function wp_admin_bar_debug_queries() { global $wpdb; $queries = array(); $out = ''; $total_time = 0; if ( !empty($wpdb->queries) ) { $show_many = isset($_GET['debug_queries']); if ( $wpdb->num_queries > 500 && !$show_many ) $out .= "

There are too many queries to show easily! Show them anyway.

"; $out .= '
    '; $first_query = 0; $counter = 0; foreach ( $wpdb->queries as $q ) { list($query, $elapsed, $debug) = $q; $total_time += $elapsed; if ( !$show_many && ++$counter > 500 ) continue; $query = nl2br(esc_html($query)); // $dbhname, $host, $port, $name, $tcp, $elapsed $out .= "
  1. $query
    $debug #{$counter} (" . number_format(sprintf('%0.1f', $elapsed * 1000), 1, '.', ',') . "ms)
  2. \n"; } $out .= '
'; } else { $out .= "

There are no queries on this page, you won the prize!!! :)

"; } $query_count = '

Total Queries:' . number_format( $wpdb->num_queries ) . "

\n"; $query_time = '

Total query time:' . number_format(sprintf('%0.1f', $total_time * 1000), 1) . "ms

\n"; $memory_usage = '

Peak Memory Used:' . number_format( memory_get_peak_usage( ) ) . " bytes

\n"; $out = $query_count . $query_time . $memory_usage . $out; return $out; } */ /** AA_DEBUG::get_debug_globalprint() */ function get_debug_globalprint($vb=false) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); //global $wp_query; //if($vb==false)return var_export(array_diff(get_defined_vars(), array(array()))); $return=$this->print_ra($GLOBALS); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $return; } /** AA_DEBUG::get_debug_queries() */ function get_debug_queries($vb=false) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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) { $class = ( $x % 2 != 0 ) ? '' : ' class="alt"'; $q[0] = trim( ereg_replace('[[:space:]]+', ' ', $q[0]) ); $total_query_time += $q[1]; $out .= "
  1. "; if ( isset($q[1]) ) $out .= '' . __('Query:') . ' ' . htmlentities( $q[0] ); if ( isset($q[2]) ) $out .= '
    ' . __('Call from:') . ' ' . htmlentities( $q[2] ); $out .= '
  2. ' . "\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 ); $out1=$out; $out=''; $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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $out.$out1; } /** AA_DEBUG::get_debug_sockets() */ function get_debug_sockets($vb=false) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $oa; } /** AA_DEBUG::get_debug_rewrites() * * @param mixed $vb */ function get_debug_rewrites( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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"; } $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['Rewrite Rules']=$this->handle_results(array('wp_rewrite_rules','mod_rewrite_rules')); $oa['page_generated']=$this->handle_results(array('page_uri_index','page_rewrite_rules')); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return array($oa); } /** AA_DEBUG::handle_results() */ function handle_results($incoming) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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)) $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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $oa; } /** AA_DEBUG::get_debug_interfaces() * * @param mixed $vb */ function get_debug_interfaces( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $oa=array(); foreach((array)@get_declared_interfaces() as $k=>$v) $oa[$v]=''; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return array($oa); } /** AA_DEBUG::get_debug_extensions() * * @param mixed $vb */ function get_debug_extensions( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $oa = $oi=array(); foreach ( (array )@get_loaded_extensions() as $k => $v ) $oa[$v] = ( $vb === false ) ? '' : ( array )@get_extension_funcs( $v ); ob_start(); foreach ( (array )@get_loaded_extensions() as $v ) { $ext = new ReflectionExtension($v); echo "\n\n[ $v ]\n"; foreach((array)$ext->getINIEntries() as $kk=>$vv)echo "$kk=$vv\n"; #print_r($ext->getFunctions()); #print_r($ext->info()); } $oi=array("INI Entries by Extension"=>ob_get_clean()); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return array($oa,$oi); } /** AA_DEBUG::get_debug_functions() * * @param mixed $vb */ function get_debug_functions( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return array($oa); } /** AA_DEBUG::get_debug_included() * * @param mixed $vb */ function get_debug_included( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return array($oa); } /** AA_DEBUG::get_debug_permissions() * * @param mixed $vb */ function get_debug_permissions( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return array($oa); } /** AA_DEBUG::get_debug_classes() * * @param mixed $vb */ function get_debug_classes( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $oa; } /** AA_DEBUG::get_debug_globals() * * @param mixed $vb */ function get_debug_globals( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $oa; } /** AA_DEBUG::get_debug_loaded_extensions() * * @param mixed $vb */ function get_debug_loaded_extensions( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $oa; } /** AA_DEBUG::get_debug_defined() * * @param mixed $vb */ function get_debug_defined( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $oa = array(); /* 'Date'=>'DATE', 'libxml'=>'LIBXML', 'OPENSSL'=>'OPENSSL', 'pcre'=>'PREG', 'sqlite3'=>'SQLITE3', 'zlib'=>'FORCE', 'curl'=>'CURL', 'dom'=>'XML', 'hash'=>'HASH', 'fileinfo'=>'FILEINFO', 'filter'=>'INPUT', 'ftp'=>'FTP', 'gd'=>'IMG', 'gmp'=>'GMP', 'iconv'=>'ICONV', 'json'=>'JSON', 'mbstring'=>'MB_', 'mcrypt'=>'MCRY', 'mysql'=>'MYSQL_', 'pcntl'=>array('WNOHANG','SIG'), 'posix'=>'POSIX', 'standard'=>'CONNECT', 'soap'=>'SOAP', 'sockets'=>'AF_', 'SQLite'=>'SQPLITE_', 'EXIF'=>'EXIF_', 'sysvmsg'=>'MSG_IPC', 'tokenizer'=>'T_REQUIRE', 'xml'=>'XML_ERROR_', 'user'=>'', */ 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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return array($oa); } /** AA_DEBUG::get_debug_inis() * * @param mixed $vb */ function get_debug_inis( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $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); /* On, Off, True, False, Yes, No and None ${foo} ; Expressions in the INI file are limited to bitwise operators and parentheses: ; | bitwise OR ; ^ bitwise XOR ; & bitwise AND ; ~ bitwise NOT ; ! boolean NOT ; error_reporting ; Default Value: E_ALL & ~E_NOTICE ; Development Value: E_ALL | E_STRICT ; Production Value: E_ALL & ~E_DEPRECATED ; Boolean flags can be turned on using the values 1, On, True or Yes. ; They can be turned off using the values 0, Off, False or No. ; An empty string can be denoted by simply not writing anything after the equal ; sign, or by using the None keyword: */ $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return array($oa); } /** AA_DEBUG::get_debug_phpinfo() */ function get_debug_phpinfo() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); $oa = array(); if($this->_cf('phpinfo')) { ob_start(); phpinfo( -1 ); $oa = preg_replace(array('#^.*(.*).*$#ms','#

PHP License

.*$#ms','#

Configuration

#',"#\r?\n#","##",'# +<#',"#[ \t]+#", '# #','# +#','# class=".*?"#','%'%','#(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" />' . '

PHP Version (.*?)

(?:\n+?)#', '#

PHP Credits

#','#(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)#',"# +#",'##','##' ), array('$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(__FILE__,__CLASS__,__FUNCTION__,__LINE__); return $oa; } /** AA_DEBUG::admin_footer() */ function admin_footer() { if(!current_user_can('administrator'))return; if(!current_user_can('level_10'))return; if($this->options['admin_footer']!='1') return; if($this->options['wp_footer']!='1') return; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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 ) { if($this->debug_mods[$id][0] == 'queries') { echo "\n\n

QUERIES

\n"; echo '
'; echo $this->{'get_debug_'.$this->debug_mods[$id][0]}( ($this->options['debug_mods_verbose'] & $id)==$id ); echo '
'; continue; } $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 "

GLOBAL VARS: ".implode(", ", array_keys($GLOBALS))."

"; echo '
'; echo ob_get_clean(); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::wp_footer() */ function wp_footer() { if(!current_user_can('administrator'))return; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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 ) { if($this->debug_mods[$id][0] == 'queries') { echo "\n\n

QUERIES

\n"; echo $this->{'get_debug_'.$this->debug_mods[$id][0]}( ($this->options['debug_mods_verbose'] & $id)==$id ); continue; } $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 "

GLOBAL VARS: ".implode(", ", array_keys($GLOBALS))."

"; echo '
'; echo ob_get_clean(); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); } /** AA_DEBUG::live_debug() */ function live_debug() { //error_log($this->options['debug_mods']); if ( $this->options['debug_live'] !== '1' ) return; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__); 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', 'request_order' => 'GPCES', 'register_globals' => 'On', 'register_long_arrays' => 'On', 'register_argc_argv' => 'On', 'always_populate_raw_post_data' => 'On', //'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', 'magic_quotes_gpc' => '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 ); } //$this->SaveOptions(); 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; } } endif; function &_aa_debug_object() { static $aa_debug_object=NULL; if ( null === $aa_debug_object ) { $aa_debug_object=new AA_DEBUG(); $aa_debug_object->t(__FILE__,"AA_DEBUG",__FUNCTION__,__LINE__); $GLOBALS["aa_debug_object"]=&$aa_debug_object; $aa_debug_object->t(__FILE__,"AA_DEBUG",__FUNCTION__,__LINE__); } return $aa_debug_object; } $AA_DEBUG=&_aa_debug_object(); $_aabf=basename(__FILE__); $_aapb=preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__); $_aahk=rtrim('settings_page_'.$_aabf, '.php'); add_action('init', array(&$AA_DEBUG, 'Init')); if (is_admin()) : register_activation_hook(__FILE__, array(&$AA_DEBUG,'Activate')); register_deactivation_hook(__FILE__, array(&$AA_DEBUG,'DeActivate')); //register_uninstall_hook(__FILE__, array(&$AA_DEBUG,'Uninstall')); add_filter("plugin_action_links_{$_aapb}", create_function('$l', 'return array_merge(array("Settings"), $l);')); 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["access"], $p["page"], array(&$AA_DEBUG,"AdminPage") );')); add_action("admin_init", create_function('','$AA_DEBUG=&_aa_debug_object();$AA_DEBUG->l("admin_init",5,1);')); add_action("admin_head-{$_aahk}", create_function('','$AA_DEBUG=&_aa_debug_object();$AA_DEBUG->l("admin_head-'.$_aahk.'",5,1);')); add_action("load-{$_aahk}", create_function('','$AA_DEBUG=&_aa_debug_object();$AA_DEBUG->l("load-'.$_aahk.'",5,1);')); endif; add_action( 'init', array(&$AA_DEBUG, 'live_debug') ); add_action( 'shutdown', array(&$AA_DEBUG, 'live_debug') ); add_action( "admin_footer", array(&$AA_DEBUG,'admin_footer')); add_action('wp_footer', create_function('','echo "
".print_r(array_keys($GLOBALS),1)."
";')); add_action( "wp_footer", array(&$AA_DEBUG,'admin_footer')); unset($_aapb,$_aahk,$_aabf); ?>