. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ // exit if add_action or plugins_url functions do not exist !function_exists('add_action') || !function_exists('plugins_url') && exit; !defined('ABSPATH') || !function_exists('add_management_page') || !function_exists('wp_die') && die('death by askapache firing squad'); /******************************************************************************************************************************************************************************************************** FUNCTIONS ********************************************************************************************************************************************************************************************************/ if (!function_exists('aa_debug_log')/* && $_SERVER['REMOTE_ADDR'] == '24.123.215.60'*/): function aa_debug_log($m = null){} else: function aa_debug_log($m = null){} endif; if (!function_exists('absint')): function absint( $maybeint ) { return abs( intval( $maybeint ) ); } endif; if (!function_exists('is_a')) : function is_a($o, $c) { return (!is_object($o)) ? false : ((strtolower(get_class($o)) == strtolower($c)) ? true : is_subclass_of($o, $c)); } endif; if (!function_exists('stripos')) : function stripos($haystack, $needle, $offset = 0) { return strpos(strtolower($haystack), strtolower($needle), $offset); } endif; if (!function_exists('wp_die')): function wp_die($m = 'wp_die'){ aa_debug_log($m); die($m); } endif; if(!class_exists('AA_DEBUG')): /******************************************************************************************************************************************************************************************************** DEFINES ********************************************************************************************************************************************************************************************************/ /* COMPAT DEFINES =========================================================================================================================================================================================*/ !defined('NET_SOCKET_READ') && define('NET_SOCKET_READ', 1); !defined('NET_SOCKET_WRITE') && define('NET_SOCKET_WRITE', 2); !defined('NET_SOCKET_ERROR') && define('NET_SOCKET_ERROR', 4); !defined('STREAM_CRYPTO_METHOD_TLS_CLIENT') && define('STREAM_CRYPTO_METHOD_TLS_CLIENT', 3); !defined('STREAM_CRYPTO_METHOD_SSLv3_CLIENT') && define('STREAM_CRYPTO_METHOD_SSLv3_CLIENT', 1); !defined('STREAM_CRYPTO_METHOD_SSLv23_CLIENT') && define('STREAM_CRYPTO_METHOD_SSLv23_CLIENT', 2); !defined('STREAM_CRYPTO_METHOD_SSLv2_CLIENT') && define('STREAM_CRYPTO_METHOD_SSLv2_CLIENT', 0); !defined('ABSPATH') || !function_exists('add_management_page') || !function_exists('wp_die') && die('death by askapache firing squad'); !defined('WP_CONTENT_DIR') && define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down !defined('WP_PLUGIN_DIR') && define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins'); // full path, no trailing slash !defined('WP_CONTENT_URL') && define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up !defined('WP_PLUGIN_URL') && define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins'); // full url, no trailing slash !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)); !defined('FS_CHMOD_DIR') && define('FS_CHMOD_DIR', (S_IRWUGO & ~ umask()));!defined('FS_CHMOD_FILE') && define('FS_CHMOD_FILE', (S_IRWXUGO & ~ umask())); /** * AA_DEBUG * * @package * @author webmaster@askapache.com * @copyright AskApache * @version 2009 * @access public */ class AA_DEBUG { var $options; var $plugin; var $old_inis; var $old_track_errors; var $old_error_reporting; var $debug_mods = array( 1 => array('included', 'Files included by php'), 2 => array('functions', 'Function Information'), 4 => array('classes', 'Information about Loaded Classes'), 8 => array('globals', 'Global Server/Request Information'), 16 => array('extensions', 'Extensions Loaded by PHP'), 32 => array('defined', 'Defined Constants and variables'), 64 => array('inis', 'Your PHP.ini settings'), 128 => array('phpinfo', 'Information from phpinfo'), 256 => array('permissions','Information about Owner/User/File permissions'), 512 => array('interfaces', 'Declared interfaces in the current script') ); function AA_DEBUG(){register_shutdown_function(array(&$this, '__destruct'));return $this->__construct();} function __construct(){/* error_log(__CLASS__.' created!');*/$this->timer('AA_DEBUG');} function __destruct(){ error_reporting($this->old_error_reporting); @ini_set('track_errors', $this->old_track_errors);/*error_log(__CLASS__.' destroyed!');*/} function LoadOptions() { $this->logg( __FUNCTION__ . ':' . __LINE__ ); $this->plugin = $this->get_plugin_data('tools'); $this->options=get_option('askapache_debug_options'); } function SaveOptions() { $this->logg( __FUNCTION__ . ':' . __LINE__ ); update_option('askapache_debug_options', $this->options); update_option('askapache_debug_plugin', $this->plugin); } /* AA_DEBUG::default_options() [askapache_debug_options] => Array [logfile] => /home/askapach/sites/askapache.com/logs/php_error.log [log_errors] => 0 [debug_live] => 0 [error_reporting] => 0 [debug_mods_verbose] => 0 [debug_mods] => 0 */ function default_options() { $this->logg( __FUNCTION__ . ':' . __LINE__ ); delete_option("askapache_debug_options"); delete_option("askapache_debug_plugin"); // get all the plugin array data $this->plugin = $this->get_plugin_data('tools'); $this->options=array( 'logfile' => $this->get_error_log(), 'log_errors' => 0, 'debug_live' => '0', 'error_reporting' => 0, 'debug_level' => 0, 'debug_mods_verbose' => 0, 'debug_mods' => 0, ); // Save all these variables to database $this->SaveOptions(); } /* AA_DEBUG::management_page() * * @return */ function management_page() { $this->logg( __FUNCTION__ . ':' . __LINE__ ); echo '

AskApache Debugging Options


'; $this->pp(array('POST' => $_POST,'options' => $this->options)); 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 '

'; echo '

'; echo '



'; echo '

'; //echo '



'; echo '
'; foreach ($this->debug_mods as $id => $info) { echo '

'; echo '

'; } echo '

'; /*echo '
'; foreach ($this->get_error_levels() as $n=>$v) echo '

'; echo '

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

'; echo '


'; } /* AA_DEBUG::in_admin_footer() * * @return */ function in_admin_footer() { $this->logg( __FUNCTION__ . ':' . __LINE__ ); ob_start(); echo '


'; echo "

{$this->plugin['plugin-name']} {$this->plugin['version']} Debugging Information

"; $oa = array(); foreach ( array( 1, 2, 4, 8, 16, 32, 64, 128, 256, 512) as $id ) if( ($this->options['debug_mods'] & $id) == $id ) $oa[strtoupper($this->debug_mods[$id][0])] = $this->{'get_debug_'.$this->debug_mods[$id][0]}( ($this->options['debug_mods_verbose'] & $id)==$id ); /* $oa['Plugin Options'] = array( 'askapache_debug_options' => $this->options ); $oa['Plugin Information'] = array( 'askapache_debug_plugin' => $this->plugin ); */ foreach ( $oa as $ar => $val ) { ob_start(); $out = ''; if ( ! is_array($val) || sizeof($val) < 1 ) continue; echo "\n\n

{$ar}

\n"; foreach ( (array )$val as $key => $va ) $out .= "[{$key}] => " . ( is_array($va) ? print_r($va, 1) : $va ) . "\n"; $this->pp( $out, 2 ); echo ob_get_clean(); flush();ob_flush(); } echo '

'; } /* AA_DEBUG::live_debug() * * @return */ function live_debug() { if ( $this->options['debug_live'] == '0' ) return; $this->logg( __FUNCTION__ . ':' . __LINE__ ); static $started = false; if ( $started === true ) { foreach ( (array )$this->old_inis as $key => $val ) if ( ! empty($val) ) ini_set( $key, $val ); return error_reporting( $this->old_inis['error_reporting'] ); } $this->old_inis['error_reporting'] = error_reporting(); $ini_overwrites = array( 'display_errors' => 'Off', 'display_startup_errors' => 'Off', 'ignore_repeated_errors' => 'Off', 'ignore_repeated_source' => 'Off', 'html_errors' => 'Off', 'report_memleaks' => 'On', 'track_errors' => 'On', 'log_errors' => 'On' ); foreach ( $ini_overwrites as $key => $newval ) { $oldval = ''; $oldval = strval( ini_get($key) ); if ( ! empty($oldval) && $oldval != $newval ) $this->old_inis[$key] = ( $oldval == '1' ? 'On' : $oldval ); ini_set( $key, $newval ); } $started = true; error_reporting( (version_compare(phpversion(), '5.0', '>=')) ? E_ALL | E_STRICT : E_ALL ); return true; } function handle_post() { $this->logg( __FUNCTION__ . ':' . __LINE__ ); if (isset($_POST['save_debug_options'])) { if ( !wp_verify_nonce($_POST['_wpnonce'], 'aadebug_settings_form') ) wp_die( 'ERROR: Incorrect Form Submission, please try again.' ); if ( isset($_POST['log_errors']) ) isset($_POST['log_errors']); $this->options['debug_live'] = isset($_POST['debug_live']); if( isset($_POST['log_errors'])) $this->options['logfile']=$this->get_error_log(); if (isset($_POST['logfile'])) $this->options['logfile'] = trim($_POST['logfile']); if (isset($_POST['debug_level'])) $this->options['debug_level'] = trim(intval($_POST['debug_level'])); if (isset($_POST['error_reporting']) && ($this->options['error_reporting'] = 0)!==false) foreach( array_map( 'intval', (array) $_POST['error_reporting'] ) as $bit) $this->options['error_reporting'] |= $bit; if (isset($_POST['debug_mods']) && ($this->options['debug_mods'] = 0)!==false) foreach(array_map( 'intval', (array) $_POST['debug_mods'] ) as $bit) $this->options['debug_mods'] |= $bit; if (isset($_POST['debug_mods_verbose']) && ($this->options['debug_mods_verbose'] = 0)!==false) foreach(array_map( 'intval', (array) $_POST['debug_mods_verbose'] ) as $bit) $this->options['debug_mods_verbose'] |= $bit; $this->SaveOptions(); } } /* AA_DEBUG::wb() * * @param mixed $id * @return */ function wb($id) { //$this->logg( __FUNCTION__ . ':' . __LINE__ ); $id=intval($id); $o=array(); if( ($id & 1) == 1 ) $o[]=1; if( ($id & 2) == 2 ) $o[]=2; if( ($id & 4) == 4 ) $o[]=4; if( ($id & 8) == 8 ) $o[]=8; if( ($id & 16) == 16 ) $o[]=16; if( ($id & 32) == 32 ) $o[]=32; if( ($id & 64) == 64 ) $o[]=64; if( ($id & 128) == 128 ) $o[]=128; if( ($id & 256) == 256 ) $o[]=256; if( ($id & 512) == 512 ) $o[]=512; if( ($id & 1024) == 1024 ) $o[]=1024; if( ($id & 2048) == 2048 ) $o[]=2048; if( ($id & 4096) == 4096 ) $o[]=4096; if( ($id & 8192) == 8192 ) $o[]=8192; if( ($id & 16384) == 16384 ) $o[]=16384; if( ($id & 32768) == 32768 ) $o[]=32768; return $o; /* $o=''; if( ($id & 1) == 1 ) $o.="|".$array[1][0]; if( ($id & 2) == 2 ) $o.="|".$array[2][0]; if( ($id & 4) == 4 ) $o.="|".$array[4][0]; if( ($id & 8) == 8 ) $o.="|".$array[8][0]; if( ($id & 16) == 16 ) $o.="|".$array[16][0]; if( ($id & 32) == 32 ) $o.="|".$array[32][0]; if( ($id & 64) == 64 ) $o.="|".$array[64][0]; if( ($id & 128) == 128 ) $o.="|".$array[128][0]; if( ($id & 256) == 256 ) $o.="|".$array[256][0]; echo $id." is ".trim($o,'|')."\n"; */ } /* AA_DEBUG::_checkedd() */ function _checkedd($val, $d=false) { //$this->logg( __FUNCTION__ . ':' . __LINE__ ); $val=intval($val); $er=intval($this->options['error_reporting']); $str=(($val <= $er) && ($er & $val) === $val) ? ' checked="checked"' : ''; if(!$d)return $str; else echo $str; } /* AA_DEBUG::_checked() */ function _checked($checked, $var, $d=false) { $str = ''; if($_SERVER['REQUEST_METHOD']=='POST')if(!isset($_POST[$checked]))return $str; elseif (!isset($_POST[$checked]) && !isset($this->options[$checked])) return $str; if(in_array($checked,array('debug_mods','debug_mods_verbose','error_reporting'))) $str = ( in_array($var, $this->wb($this->options[$checked]) ) ? ' checked="checked"' : '' ); else { $checked = (isset($_POST[$checked])) ? $_POST[$checked] : $this->options[$checked]; if (is_array($checked) && in_array($var, $checked)) $str = ' checked="checked"'; elseif ($checked == $var || $checked === true) $str = ' checked="checked"'; } if(!$d)return $str; else echo $str; return; } /* AA_DEBUG::get_plugin_data() * * @param mixed $find * @return [askapache_debug_plugin] => Array [plugin-name] => AskApache Debug Viewer [short-name] => AA Debug [description] => Displays Advanced Debugging Output [author] => AskApache [version] => 1.1.1 [requires-at-least] => 2.7 [tested-up-to] => 3.0 [tags] => debug, debugging, error, errors, problems, support, admin, programmer, developer, plugin, development, information, stats, logs [contributors] => AskApache [wordpress-uri] => http://wordpress.org/extend/plugins/askapache-debug-viewer/ [author-uri] => http://www.askapache.com/ [donate-uri] => http://www.askapache.com/donate/ [plugin-uri] => http://www.askapache.com/wordpress/deb [title] => AskApache Debug Viewer [pb] => askapache-debug-viewer/askapache-debug-viewer.php [page] => askapache-debug-viewer.php [pagenice] => askapache-debug-viewer [nonce] => form_askapache-debug-viewer [hook] => tools_page_askapache-debug-viewer [action] => tools.php?page=askapache-debug-viewer.php [op] => adv_ */ function get_plugin_data($type='settings') { $pp = get_option("askapache_debug_plugin"); if(is_array($pp) && sizeof($pp)>10) return $pp; $data = $this->_readfile(__FILE__, 750); $mtx = $plugin = array(); preg_match_all('/[^a-z0-9]+((?:[a-z0-9]{2,25})(?:\ ?[a-z0-9]{2,25})?(?:\ ?[a-z0-9]{2,25})?)\:[\s\t]*(.+)/i', $data, $mtx, PREG_SET_ORDER); foreach ($mtx as $m) $plugin[trim(str_replace(' ', '-', strtolower($m[1])))] = str_replace(array("\r", "\n", "\t"), '', trim($m[2])); $plugin['title'] = '' . $plugin['plugin-name'] . ''; $plugin['author'] = '' . $plugin['author'] . ''; $plugin['pb'] = preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__); $plugin['page'] = basename(__FILE__); $plugin['pagenice'] = rtrim($plugin['page'], '.php'); $plugin['nonce'] = 'form_' . $plugin['pagenice']; $plugin['hook'] = $type.'_page_' . $plugin['pagenice']; $type = ($type=='settings') ? 'options-general' : $type; $plugin['action'] = $type.'.php?page=' . $plugin['page']; if (preg_match_all('#(?:([^\W_]{1})(?:[^\W_]*?\W+)?)?#i', $plugin['pagenice'] . '.' . $plugin['version'], $m, PREG_SET_ORDER))$plugin['op'] = ''; foreach($m as $k) sizeof($k == 2) && $plugin['op'] .= $k[1]; $plugin['op'] = substr($plugin['op'], 0, 3) . '_'; return $plugin; } /* AA_DEBUG::_ls() * * @param string $folder * @param integer $levels * @return */ function _ls( $folder = '', $levels = 2 ) { $this->logg( __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 * @return */ function _pls( $folder = '.', $levels = 2, $format = 1 ) { // $folder = ($folder=='.') ? getcwd() : realpath("."); $this->logg( __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(dirname($folder), '/', realpath($file)) ); } echo '

';
		echo join( "\n", array_merge(array($folder . " Listing"), $list) );
		echo '
'; } /* AA_DEBUG::_is_readable() * * @param mixed $fl * @return */ function _is_readable( $fl ) { $this->logg( __FUNCTION__ . ':' . __LINE__ ); if ( is_dir($fl) ) return is_readable( $fl ); return ( $this->_file_exists($fl) && (is_readable($fl) || $this->_fclose($this->_fopen($fl, 'rb'))) ) ? true : false; } /* AA_DEBUG::_file_exists() * * @param mixed $fl * @return */ function _file_exists( $fl ) { $this->logg( __FUNCTION__ . ':' . __LINE__ ); return ( ((file_exists($fl)) === false && (@realpath($fl)) === false) || ($s = @stat($fl)) === false ) ? false : true; } /* AA_DEBUG::_stat() * * @param mixed $fl * @return */ function _stat( $fl ) { static $ftypes = false; if ( !$ftypes && false !==($this->logg( __FUNCTION__ . ':' . __LINE__ ))) $ftypes = array(S_IFSOCK=>'ssocket', S_IFLNK=>'llink', S_IFREG=>'-file', S_IFBLK=>'bblock', S_IFDIR=>'ddir', S_IFCHR=>'cchar', S_IFIFO=>'pfifo'); $s = $ss = array(); if ( ($ss = stat($fl)) === false ) return $this->logg( __FUNCTION__ . ':' . __LINE__ . " Couldnt stat {$fl}", 0 ); $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 * @return */ function _fclose( &$fh ) { $this->timer( __FUNCTION__ ); return ( ((@fclose($fh)) !== false && ($fh=null)!== false) || ! is_resource($fh) ) ? true : false; } /* AA_DEBUG::_fopen() * * @param mixed $file * @param mixed $mode * @return */ function _fopen( $file, $mode ) { $this->timer( __FUNCTION__ ); //$filemodes = array('r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'rb', 'rb+', 'wb', 'wb+', 'ab', 'ab+', 'xb', 'xb+', 'rt', 'rt+', 'wt', 'wt+', 'at', 'at+', 'xt', 'xt+'); // $out='';foreach((array)stream_get_meta_data($fh) as $k=>$v)$out.="$k => $v\n";$this->logg($out); return ( (strspn($mode, 'abrtwx+')==strlen($mode)) && ($fh = @fopen($file, $mode)) !== false ) ? $fh : false; } /* AA_DEBUG::_fread() * * @param mixed $fh * @param bool $ts * @param integer $bs * @return */ function _fread( &$fh, $ts = false, $bs = 2048 ) { $this->timer( __FUNCTION__ ); for ( $d = $b = '', $rt = $at = $r = 0; ($fh !== false && ! feof($fh) && $b !== false && $at < 50000000 && $rt < $ts); $r = $ts - $rt, $bs = (($bs > $r) ? $r : $bs), $this->timer("R: {$rt}"), $b = fread($fh, $bs), $br = strlen($b), $d .= $b, $this->timer("R: {$rt}"), $rt += $br, $at++ ,$this->logg(__FUNCTION__ . ':' . __LINE__ . " [RT: {$rt}]\t[BR: {$br}" . (($ts != 50000000) ? "]\t\t [{$r} / {$ts}]" : " : {$bs}]\t[{$at}]")) ) ; $this->timer( __FUNCTION__ ); return ( (strlen($d) != 0) ) ? $d : false; } /* AA_DEBUG::_fwrite() * * @param mixed $fh * @param mixed $d * @param integer $bs * @return */ function _fwrite( &$fh, $d, $bs = 512 ) { for ( $bw = $wt = $at = 0, $ts = strlen($d), $this->logg(__FUNCTION__ . ':' . __LINE__ . " starting write.. {$ts} bytes total with blocksize {$bs}"); ($fh !== false && $bw !== false && $at < 1000 && $wt < $ts); $r = $ts - $wt, $bs = ($bs > $r) ? $r : $bs, $bw = fwrite($fh, substr($d, $wt), $bs), $wt += $bw, $at++ ) ; $this->logg( __FUNCTION__ . ':' . __LINE__ . " {$at}: {$bw} / {$wt} of {$ts}" ); return ( $wt == $ts ) ? true : false; } /* AA_DEBUG::_readfile() * * @param mixed $file * @param bool $len * @return */ function _readfile( $file, $len = false ) { $this->logg( __FUNCTION__ . ':' . __LINE__ ); if ( ! $this->_file_exists($file) ) return $this->logg( __FUNCTION__ . ':' . __LINE__ . ' ' . "no such file! {$file}", 0 ); if ( ! $len ) $len = filesize( $file ); if ( ($fh = $this->_fopen($file, 'rb')) === false ) return $this->logg( __FUNCTION__ . ':' . __LINE__ . ' ' . "Error opening rb handle for {$file}", 0 ); $data = $this->_fread( $fh, $len ); return ( ! $this->_fclose($fh) ) ? $this->logg( __FUNCTION__ . ':' . __LINE__ . ' ' . "Error closing rb handle on {$file}", 0 ) : $data; } /* AA_DEBUG::_mkdir() * * @param mixed $dir * @param integer $mode * @return */ function _mkdir( $dir, $mode = 0755 ) { $this->logg( __FUNCTION__ . ':' . __LINE__ ); if ( ! wp_mkdir_p($dir) ) return $this->logg( __FUNCTION__ . ':' . __LINE__ . ' ' . "Couldnt create directory! ${dir}", 0 ); } /* AA_DEBUG::_rmdir() * * @param mixed $dir * @return */ function _rmdir( $dir ) { $this->logg( __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->logg( __FUNCTION__ . ':' . __LINE__ . ' ' . "Error Deleting: " . $f, 0 ); } $d->close(); return rmdir( $dir ); } else return $this->_unlink( $dir ); } /* AA_DEBUG::_unlink() * * @param mixed $f * @return */ function _unlink( $f ) { $this->logg( __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 * @return */ function _is_writable( $fl ) { // if ( is_dir( $fl ) || $fl{strlen( $fl ) - 1} == '/' ) $fl = $this->tslashit($fl).microtime().'.tmp'; $this->logg( __FUNCTION__ . ':' . __LINE__ ); if ( is_writable($fl) || touch($fl) ) return true; $exists = ( bool )$this->_file_exists( $fl ); $dir = ( bool )is_dir( $fl ); if ( $exists && ! @chmod($fl, FS_CHMOD_FILE) && ! @chmod(dirname($file), FS_CHMOD_DIR) && ! @chmod($file, FS_CHMOD_FILE) && ! @touch($fl) ) return false; if ( $dir === true ) $tfl = $fl . '/' . $this->_get_rand_str( 8 ) . '.tmp'; $w = ( bool )( $this->_fclose($this->_fopen($fl, 'a')) || $this->_fclose($this->_fopen($fl, 'x')) || $this->_fclose($this->_fopen($fl, 'w')) ) ? true : false; if ( $d === true || $e === false ) $this->_unlink( $fl ); return $w; } /* AA_DEBUG::_get_rand_str() */ function _get_rand_str($l=null,$c=null) { $this->to_log(__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); } /* AA_DEBUG::_stripdeep() * * @param mixed $value * @return */ 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 * @return */ 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::timer() * * @param string $id * @param bool $d * @return */ function timer($id = 'new', $d = false) { static $a; is_null($a) && $a = array(); $ct = array_sum(explode(chr(32), microtime())); if (!isset($a[$id])) { $a[$id] = $ct; return ''; } else return sprintf("%.4f", ($ct - $a[$id])); } /* AA_DEBUG::_cf() * * @param mixed $func * @return */ public static function _cf($f) { static $b,$g = array(); is_null($b) && $b = ( function_exists('ini_get') ) ? explode(',',strtolower(ini_get('disable_functions'))) : array(); //aa_debug_log(print_r(array('g'=>$g,'b'=>$b),1)); if ( false!==($f=strtolower($f)) && ( in_array($f, $g) || in_array($f, $b)) ) return (in_array($f, $g)); return (!function_exists($f)) ? !( $b[] = $f ) : !!( $g[] = $f ); } /* AA_DEBUG::mem_usage() * * @param bool $raw * @return */ function mem_usage($raw = false) { static $v, $m; is_null($m) && $m = $this->_cf('memory_get_usage'); if ($m === false) return 1; 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 * @return */ function bytes($b = 0) { static $s; 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 * @return */ function _do_update( $check_time, $newer_than = 300 ) { $this->logg( __FUNCTION__ . ':' . __LINE__ ); $time = ( time() - $check_time ); return ( $newer_than < $time ) ? true : false; } /* AA_DEBUG::pp() * * @param mixed $text * @param integer $format * @return */ function pp( $text, $format = 1 ) { //$this->logg(__FUNCTION__ . ':' . __LINE__, 2); if ( is_array($text) ) $text = print_r( $text, 1 ); $f = 'display:block;padding:5px;margin:10px;font-family: Consolas, Monaco, Courier, monospace; padding: 1px 3px; margin: 0 1px; font-size: 11px; font-weight:normal; font-style:normal; background-color:#FFF;color:#000;border:2px solid #F7F7F7;overflow-x:auto;'; printf( '
%s
', $f, htmlspecialchars($text) ); return true; } /* AA_DEBUG::get_error_log() * * @return */ function get_error_log() { $this->options['logfile']=$log_file=@ini_get( 'error_log' ); $log_file = ( is_array($this->options) && isset($this->options['logfile']) ) ? $this->options['logfile'] : @ini_get( 'error_log' ); $log_file = ($log_file !== false && ! empty($log_file) ) ? $log_file : false; return $log_file; } /* AA_DEBUG::logg() * * @param string $d * @param integer $level * @return * time(&error_time); * error_time_str = php_format_date("d-M-Y H:i:s", 11, error_time, 1 TSRMLS_CC); * spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno); * * Write CLI/CGI errors to stderr if display_errors = "stderr" * ------------------------------------------------------------ * if ((!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi")) && PG(display_errors) == PHP_DISPLAY_ERRORS_STDERR * fprintf(stderr, "%s: %s in %s on line %d\n", error_type_str, buffer, error_filename, error_lineno); * else * php_printf("%s\n%s: %s in %s on line %d\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); */ function logg( $d = '', $level = 3 ) { //static $offset;is_null($offset) && $offset = ( get_option('gmt_offset') * 3600 ); if($this->options['log_errors']=1) error_log(sprintf( 'PHP NOTE: [%1$s sec] [%2$s] %3$s' . "\n", //gmdate('h:i:s', (time() + $offset)), $this->timer('AA_DEBUG'), $this->mem_usage(1), trim($d) )); else return ($level != 0) ? true : false; } function get_error_levels() { /* $err_type = array ( 1 => "Error", // E_ERROR 2 => "Warning", // E_WARINING 4 => "Parsing Error", // E_PARSE 8 => "Notice", // E_NOTICE 16 => "Core Error", // E_CORE_ERROR 32 => "Core Warning", // E_CORE_WARNING 64 => "Compile Error", // E_COMPILE_ERROR 128 => "Compile Warning", // E_COMPILE_WARNING 256 => "User Error", // E_USER_ERROR 512 => "User Warning", // E_USER_WARMING 1024=> "User Notice", // E_USER_NOTICE 2048=> "Strict Notice", // E_STRICT 4096=> "Catchable fatal error", // E_RECOVERABLE_ERROR ); */ $this->logg( __FUNCTION__ . ':' . __LINE__ ); $error_levels=array( 'E_ERROR','E_WARNING','E_PARSE','E_NOTICE','E_CORE_ERROR','E_CORE_WARNING','E_COMPILE_ERROR','E_COMPILE_WARNING','E_USER_ERROR','E_USER_WARNING','E_USER_NOTICE','E_STRICT','E_RECOVERABLE_ERROR','E_DEPRECATED','E_USER_DEPRECATED','E_ALL' ); $eany=0; foreach($error_levels as $k) { if(defined($k)){ $ev=constant($k); $eany |= $ev; $e[$k]=$ev; } } $e['E_ANY']=$eany; return $e; } /* AA_DEBUG::get_debug_interfaces() * * @param bool $vb * @return */ function get_debug_interfaces( $vb = false ) { $this->logg( __FUNCTION__ . ':' . __LINE__ ); return ( array )@get_declared_interfaces(); } /* AA_DEBUG::get_posix_info() */ function get_posix_info( $type = 'all', $id = '', $item = false ) { static $egid,$pwuid,$grgid,$euid; if(!$egid && $this->_cf('posix_getegid')) $egid=posix_getegid(); if(!$euid && $this->_cf('posix_geteuid')) $euid=posix_geteuid(); if(!$pwuid && $this->_cf('posix_getpwuid')) $pwuid=posix_getpwuid($egid); if(!$grgid && $this->_cf('posix_getgrgid')) $grgid=posix_getgrgid($euid); // 'Group Info by Name' => array('posix_getgrnam', $group_info['name'] ) //$this->logg( __FUNCTION__ . ':' . __LINE__ ); //$ownerIsMe = PHP_OS == 'WIN' ? fileowner(__FILE__) == getmyuid() : function_exists( 'posix_geteuid' ) && fileowner(__FILE__) == posix_geteuid(); /* if( !(function_exists('posix_geteuid'))) { function posix_geteuid() { return false; } } */ /* if ( function_exists('curl_init') ) { return true; } else { return false; } return extension_loaded('curl'); */ /* strpos(php_sapi_name(), 'cgi') === 0 preg_match( "|uid=(\d+)\((\S+)\)\s+gid=(\d+)\((\S+)\)\s+groups=(.+)|i", $id_raw, $matches); if ($matches[5]) { $gs = $matches[5]; $gs = explode(',', $gs); foreach ($gs as $groupstr) { preg_match("/(\d+)\(([^\)]+)\)/", $groupstr, $subs); $groups[$subs[1]] = $subs[2]; } ksort($groups); $id_data['groups'] = $groups; } if (!$success && function_exists("posix_getpwuid") && function_exists("posix_geteuid") && function_exists('posix_getgrgid') && function_exists('posix_getgroups') ) { $data = posix_getpwuid( posix_getuid() ); $id_data['uid'] = $data['uid']; $id_data['username'] = $data['name']; $id_data['gid'] = $data['gid']; //$group_data = posix_getgrgid( posix_getegid() ); //$id_data['group'] = $group_data['name']; $groups = posix_getgroups(); foreach ( $groups as $gid ) { //$group_data = posix_getgrgid(posix_getgid()); $id_data['groups'][$gid] = ''; } $success = true; } */ /* $group_desc=array( 'name' => 'The name element contains the name of the group. This is a short, usually less than 16 character "handle" of the group, not the real, full name.', 'passwd' => 'The passwd element contains the group\'s password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead.', 'gid' => 'Group ID, should be the same as the gid parameter used when calling the function, and hence redundant.', 'members' => 'This consists of an array of string\'s for all the members in the group.' ); $user_desc=array( 'name' => 'The name element contains the username of the user. This is a short, usually less than 16 character "handle" of the user, not the real, full name.', 'passwd' => 'The passwd element contains the user\'s password in an encrypted format. Often, for example on a system employing "shadow" passwords, an asterisk is returned instead.', 'uid' => 'User ID, should be the same as the uid parameter used when calling the function, and hence redundant.', 'gid' => 'The group ID of the user.', 'gecos' => 'The field contains a comma separated list containing the user\'s full name, office phone, office number, and home phone number. On most systems, only the user\'s full name is available.', 'dir' => 'This element contains the absolute path to the home directory of the user.', 'shell' => 'The shell element contains the absolute path to the executable of the user\'s default shell.' ); */ $info = array(); switch ( $type ): case 'group': $info = ($this->_cf('posix_getgrgid') ? posix_getgrgid( ( (! empty($id)) ? $id : $egid ) ):''); break; case 'user': $info = ($this->_cf('posix_getpwuid') ? posix_getpwuid( ( (! empty($id)) ? $id : $euid ) ):''); break; endswitch; return (( $item !== false && isset($info[$item]) ) ? $info[$item] : $info); } /* AA_DEBUG::get_debug_extensions() * * @param bool $vb * @return */ function get_debug_extensions( $vb = false ) { $this->logg( __FUNCTION__ . ':' . __LINE__ ); $oa = array(); foreach ( (array )@get_loaded_extensions() as $k => $v ) $oa[$v] = ( $vb === false ) ? '' : ( array )@get_extension_funcs( $v ); return $oa; } /* AA_DEBUG::get_debug_functions() * * @param bool $vb * @return */ function get_debug_functions( $vb = false ) { $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($v=''&&($this->_cf($fn)&&($v=$fn())!==false))$oa[$t]=((empty($v))?$fn:$v); return $oa; } /* AA_DEBUG::get_debug_included() * * @param bool $vb * @return */ function get_debug_included( $vb = false ) { $oa = array(); foreach ( (array)(($this->_cf('get_included_files') ? get_included_files() : array())) as $k => $v ) $oa[$v] = ( $vb === false ) ? '' : $this->_stat( $v ); return $oa; } /* AA_DEBUG::get_debug_permissions() * * @param bool $vb * @return */ function get_debug_permissions( $vb = false ) { $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; return $oa; } /* AA_DEBUG::get_debug_classes() * * @param bool $vb * @return */ function get_debug_classes( $vb = false ) { $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')) ? get_class_methods($k) : array(); return $oa; } /* AA_DEBUG::get_debug_globals() * * @param bool $vb * @return */ function get_debug_globals( $vb = false ) { $oa = array(); global $_GET,$_POST,$_COOKIE,$_SESSION,$_ENV,$_FILES,$_SERVER,$_REQUEST,$HTTP_POST_FILES,$HTTP_POST_VARS,$HTTP_SERVER_VARS,$HTTP_RAW_POST_DATA,$HTTP_GET_VARS,$HTTP_COOKIE_VARS,$HTTP_ENV_VARS; $gv=create_function('$n','global $$n; return ( (is_array($$n)&&sizeof($$n)>0)?$$n:array());'); 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,1))] = $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]; return $oa; } /* AA_DEBUG::get_debug_loaded_extensions() * * @param bool $vb * @return */ function get_debug_loaded_extensions( $vb = false ) { $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())); return $oa; } /* AA_DEBUG::get_debug_defined() * * @param bool $vb * @return */ function get_debug_defined( $vb = false ) { $oa = array(); foreach ((array)(($this->_cf('get_defined_constants')?get_defined_constants():array())) as $k=>$v) if(($vb===true)||(!$vb&&in_array($k,array('ABSPATH','WP_ADMIN'))&&$vb=true))$oa[$k]=$v; foreach (array('WP_TEMP_DIR','WP_SITEURL','WP_HOME','ABSPATH','WP_CONTENT_URL','WP_CONTENT_DIR','WP_PLUGIN_DIR','WP_PLUGIN_URL','WP_LANG_DIR','TEMPLATEPATH','STYLESHEETPATH','WPINC','COOKIEPATH','SITECOOKIEPATH','ADMIN_COOKIE_PATH','PLUGINS_COOKIE_PATH','PHP_SAPI','PHP_OS','PHP_VERSION') as $d) if(defined($d)&&$v=constant($d)&&!empty($v)) $oa[$d]=$v; return $oa; } /* AA_DEBUG::get_debug_inis() * * @param bool $vb * @return */ function get_debug_inis( $vb = false ) { $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) if (($v=''&&$v=strval(ini_get($n)))!==false&&!empty($v))$oa[$t]=$v; } 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); return $oa; } /* AA_DEBUG::get_debug_phpinfo() * * @return */ function get_debug_phpinfo() { $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); } } return $oa; } } endif; $AA_DEBUG = new AA_DEBUG(); if (is_admin()) : $_aapb=preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__); $_aahk=rtrim('tools_page_'.basename(__FILE__), '.php'); add_action("deactivate_{$_aapb}", create_function('', 'aa_debug_log("deactivating_aapb!");delete_option("askapache_debug_options");delete_option("askapache_debug_plugin");')); add_action("activate_{$_aapb}", create_function('', 'aa_debug_log("activating_aapb!");global $AA_DEBUG;if(!is_object($AA_DEBUG))$AA_DEBUG=new AA_DEBUG();$AA_DEBUG->default_options();')); // plugin action links add_filter("plugin_action_links_{$_aapb}",create_function('$l', 'return array_merge(array("Settings"), $l);')); add_action("admin_init", create_function('',' aa_debug_log("admin_init"); global $AA_DEBUG;$AA_DEBUG->LoadOptions(); $AA_DEBUG->old_track_errors=@ini_set("track_errors",1);$AA_DEBUG->old_error_reporting=error_reporting(-1);')); add_action('admin_menu', create_function('',' aa_debug_log("admin_menu"); global $AA_DEBUG; $p=$AA_DEBUG->get_plugin_data("tools"); add_management_page($p["plugin-name"],$p["short-name"],10,$p["page"],array(&$AA_DEBUG,"management_page")); add_action( "in_admin_footer", array(&$AA_DEBUG, "in_admin_footer"), 50, 0 );')); add_action("load-{$_aahk}", create_function('', ' aa_debug_log("load-aahk"); global $AA_DEBUG;"POST"==$_SERVER["REQUEST_METHOD"] && $AA_DEBUG->handle_post();')); unset($_aapb,$_aahk); endif; ?>