. */ // exit if add_action or plugins_url functions do not exist !defined('ABSPATH') || !function_exists('add_action') || !function_exists('plugins_url') || !function_exists('add_management_page') || !function_exists('wp_die') && exit; /******************************************************************************************************************************************************************************************************** FUNCTIONS ********************************************************************************************************************************************************************************************************/ if (!function_exists('wp_die')) : function wp_die ($message = 'wp_die') { die($message); } endif; if (!function_exists('absint')): function absint( $maybeint ) { return abs( intval( $maybeint ) ); } endif; if (!function_exists('is_a')) : function is_a($o, $c) { return (!is_object($o)) ? false : ((strtolower(get_class($o)) == strtolower($c)) ? true : is_subclass_of($o, $c)); } endif; if (!function_exists('stripos')) : function stripos($haystack, $needle, $offset = 0) { return strpos(strtolower($haystack), strtolower($needle), $offset); } endif; if (!function_exists('wp_die')): function wp_die($m = 'wp_die'){ die($m); } endif; if(!class_exists('AA_DEBUG')): /******************************************************************************************************************************************************************************************************** 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 life * @copyright Copyright (c) 2010 * @version $Id$ * @access public */ class AA_DEBUG { var $options = array(); // an array of options and values var $plugin = array(); // array to hold plugin information var $debug = 0; var $old_inis; 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'), 1024 => array('sockets', 'Socket and Stream Debugging'), 2048 => array('rewrites', 'WordPress Rewrites'), 4096 => array('queries', 'View DB Queries') ); /** AA_DEBUG::AA_DEBUG() * */ function AA_DEBUG(){register_shutdown_function(array(&$this, '__destruct'));return $this->__construct();} /** AA_DEBUG::__construct() * */ function __construct(){/*error_log( 'PHP CLASS: AA_DEBUG started!');*/$this->t(__FILE__);} function __destruct(){error_reporting($this->old_error_reporting); @ini_set('track_errors', $this->old_track_errors);$this->t(__FILE__);/*error_log('PHP CLASS: AA_DEBUG destroyed!');*/} /** AA_DEBUG::LoadOptions() * * @return */ function LoadOptions() { $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "" ); $this->plugin = $this->get_plugin_data('tools'); $this->options=get_option('askapache_debug_options'); } /** AA_DEBUG::SaveOptions() * * @return */ function SaveOptions() { $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "" ); update_option('askapache_debug_options', $this->options); update_option('askapache_debug_plugin', $this->plugin); } /** AA_DEBUG::default_options() * * @return */ /* 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->aadv_logg(__FILE__,__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' => '1', 'admin_footer' => '1', 'wp_footer' => '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->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "" ); echo '

AskApache Debugging Options

'; printf( "\tUMASK: %04o | DIR: %04o | FILE: %04o | $ chown " . posix_geteuid() . ':' . posix_getegid(), umask(), (0755 & ~ umask()), (0644 & ~ umask()) ); echo '


'; if($this->d(3)) $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 '

'; //echo '



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

'; echo '

'; } echo '

'; echo '
    '; foreach (array('error_reporting','display_errors','display_startup_errors','log_errors','log_errors_max_len','ignore_repeated_errors','ignore_repeated_source','report_memleaks','track_errors','html_errors','xmlrpc_errors','xmlrpc_error_number','docref_root','docref_ext','error_prepend_string','error_append_string','error_log') as $k) { echo '
  • '.$k.': '.(($v=''&&$v=strval(ini_get($k)))!==false&&!empty($v))?$v:''.'
  • '; } echo '
'; /*echo '
'; foreach ($this->get_error_levels() as $n=>$v) echo '

'; echo '

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

'; echo '


'; } /** AA_DEBUG::admin_footer() * * @return */ function admin_footer() { $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "" ); if(!current_user_can('administrator'))return; $this->LoadOptions(); if($this->options['admin_footer']!=='1') return; 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, 1024, 2048,4096) 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 ); if($this->d(3)) { $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( $ar='QUERIES' && !!!$val) echo $val; if ( !!!$val || $ar='QUERIES') continue; ob_start(); echo "\n\n

{$ar}

\n"; foreach ( (array )$val as $key => $va ) { echo "\n\n

{$key}

\n";$this->pp($va); } echo ob_get_clean(); flush();ob_flush(); } echo '

'; } /** AA_DEBUG::wp_footer() * * @return */ function wp_footer() { $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "" ); if(!current_user_can('administrator'))return; $this->LoadOptions(); if($this->options['wp_footer']!=='1') return; 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, 1024, 2048, 4096) 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 ); if($this->d(3)) { $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( $ar='QUERIES' && !!!$val ) echo $val; if ( !!!$val || $ar='QUERIES') continue; ob_start(); echo "\n\n

{$ar}

\n"; foreach ( (array )$val as $key => $va ) { echo "\n\n

{$key}

\n";$this->pp($va); } echo ob_get_clean(); flush();ob_flush(); } echo '

'; } /** AA_DEBUG::live_debug() * * @return */ function live_debug() { if ( $this->options['debug_live'] == '0' ) return; $this->aadv_logg(__FILE__,__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; } /** AA_DEBUG::handle_post() * * @return */ function handle_post() { $this->aadv_logg(__FILE__,__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']); $this->options['admin_footer'] = (isset($_POST['admin_footer']) ? '1' : '0'); $this->options['wp_footer'] = (isset($_POST['wp_footer']) ? '1' : '0'); 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['plugin_debug_level'])) $this->options['plugin_debug_level'] = trim(intval($_POST['debug_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(); } } function wb($id) { //$this->aadv_logg(__FILE__,__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"; */ } function _checkedd($val, $d=false) { //$this->aadv_logg(__FILE__,__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; } 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 string $type * @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->aadv_logg(__FILE__,__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->aadv_logg(__FILE__,__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->aadv_logg(__FILE__,__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->aadv_logg(__FILE__,__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->aadv_logg(__FILE__,__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->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "Couldnt stat {$fl}"); $p = $ss['mode']; $t = decoct($p & S_IFMT); $q = octdec($t); $type = (array_key_exists($q,$ftypes))?substr($ftypes[$q],1):'?'; $s = array( 'filename' => $fl, 'human' => ( substr($ftypes[$q],0,1) .(($p & S_IRUSR)?'r':'-') .(($p & S_IWUSR)?'w':'-') .(($p & S_ISUID)?(($p & S_IXUSR)?'s':'S'):(($p & S_IXUSR)?'x':'-')) .(($p & S_IRGRP)?'r':'-') .(($p & S_IWGRP)?'w':'-') .(($p & S_ISGID)?(($p & S_IXGRP)?'s':'S'):(($p & S_IXGRP)?'x':'-')) .(($p & S_IROTH)?'r':'-') .(($p & S_IWOTH)?'w':'-') .(($p & S_ISVTX)?(($p & S_IXOTH)?'t':'T'):(($p & S_IXOTH)?'x':'-'))), 'octal' => sprintf("%o",($ss['mode'] & 007777)), 'hex' => sprintf("0x%x", $ss['mode']), 'decimal' => sprintf("%d", $ss['mode']), 'binary' => sprintf("%b", $ss['mode']), 'base_convert' => base_convert($ss['mode'], 10, 8), 'fileperms' => ($this->_cf('fileperms') ? fileperms($fl) : ''), 'mode' => $p, 'fileuid' => $ss['uid'], 'filegid' => $ss['gid'], 'owner_name' => $this->get_posix_info('user', $ss['uid'], 'name'), 'group_name' => $this->get_posix_info('group', $ss['gid'], 'name'), 'dirname' => dirname($fl), 'type_octal' => sprintf("%07o", $q), 'type' => $type, 'device' => $ss['dev'], 'device_number' => $ss['rdev'], 'inode' => $ss['ino'], 'is_file' => is_file($fl) ? 1 : 0, 'is_dir' => is_dir($fl) ? 1 : 0, 'is_link' => is_link($fl) ? 1 : 0, 'is_readable' => is_readable($fl) ? 1 : 0, 'is_writable' => is_writable($fl) ? 1 : 0, 'link_count' => $ss['nlink'], 'size' => $ss['size'], 'blocks' => $ss['blocks'], 'block_size' => $ss['blksize'], 'accessed' => date('Y M D H:i:s', $ss['atime']), 'modified' => date('Y M D H:i:s', $ss['mtime']), 'created' => date('Y M D H:i:s', $ss['ctime']), 'mtime' => $ss['mtime'], 'atime' => $ss['atime'], 'ctime' => $ss['ctime'] ); if ( is_link($fl) ) $s['link_to'] = readlink( $fl ); if ( realpath($fl) != $fl ) $s['real_filename'] = realpath( $fl ); return $s; } /** AA_DEBUG::_fclose() * * @param mixed $fh * @return */ function _fclose( &$fh ) { $this->t( __FUNCTION__ ); return ( ((@fclose($fh)) !== false && ($fh=null)!== false) || ! is_resource($fh) ) ? true : false; } /** AA_DEBUG::_fopen() * * @param mixed $file * @param mixed $mode * @return */ function _fopen( $file, $mode ) { $this->t( __FUNCTION__ ); //$filemodes = array('r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'rb', 'rb+', 'wb', 'wb+', 'ab', 'ab+', 'xb', 'xb+', 'rt', 'rt+', 'wt', 'wt+', 'at', 'at+', 'xt', 'xt+'); // $out='';foreach((array)stream_get_meta_data($fh) as $k=>$v)$out.="$k => $v\n";$this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "$out"); return ( (strspn($mode, 'abrtwx+')==strlen($mode)) && ($fh = @fopen($file, $mode)) !== false ) ? $fh : false; } /** AA_DEBUG::_fread() * * @param mixed $fh * @param mixed $ts * @param integer $bs * @return */ function _fread( &$fh, $ts = false, $bs = 2048 ) { $this->t( __FUNCTION__ ); for ( $d = $b = '', $rt = $at = $r = 0; ($fh !== false && ! feof($fh) && $b !== false && $at < 50000000 && $rt < $ts); $r = $ts - $rt, $bs = (($bs > $r) ? $r : $bs), $this->t("R: {$rt}"), $b = fread($fh, $bs), $br = strlen($b), $d .= $b, $this->t("R: {$rt}"), $rt += $br, $at++ ,$this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, " [RT: {$rt}]\t[BR: {$br}" . (($ts != 50000000) ? "]\t\t [{$r} / {$ts}]" : " : {$bs}]\t[{$at}]")) ) ; $this->t( __FUNCTION__ ); return ( (strlen($d) != 0) ) ? $d : false; } /** AA_DEBUG::_fwrite() * * @param mixed $fh * @param mixed $d * @param integer $bs * @return */ function _fwrite( &$fh, $d, $bs = 512 ) { for ( $bw = $wt = $at = 0, $ts = strlen($d), $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, " starting write.. {$ts} bytes total with blocksize {$bs}"); ($fh !== false && $bw !== false && $at < 1000 && $wt < $ts); $r = $ts - $wt, $bs = ($bs > $r) ? $r : $bs, $bw = fwrite($fh, substr($d, $wt), $bs), $wt += $bw, $at++ ); $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, " {$at}: {$bw} / {$wt} of {$ts}" ); return ( $wt == $ts ) ? true : false; } /** AA_DEBUG::_readfile() * * @param mixed $file * @param mixed $len * @return */ function _readfile( $file, $len = false ) { $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "" ); if ( ! $this->_file_exists($file) ) return $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "no such file! {$file}"); if ( ! $len ) $len = filesize( $file ); if ( ($fh = $this->_fopen($file, 'rb')) === false ) return $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "Error opening rb handle for {$file}"); $data = $this->_fread( $fh, $len ); return ( ! $this->_fclose($fh) ) ? $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "Error closing rb handle on {$file}") : $data; } /** AA_DEBUG::_mkdir() * * @param mixed $dir * @param integer $mode * @return */ function _mkdir( $dir, $mode = 0755 ) { $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "" ); if ( ! wp_mkdir_p($dir) ) return $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "Couldnt create directory! ${dir}" ); } /** AA_DEBUG::_rmdir() * * @param mixed $dir * @return */ function _rmdir( $dir ) { $this->aadv_logg(__FILE__,__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->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "Error Deleting: " . $f); } $d->close(); return rmdir( $dir ); } else return $this->_unlink( $dir ); } /** AA_DEBUG::_unlink() * * @param mixed $f * @return */ function _unlink( $f ) { $this->aadv_logg(__FILE__,__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->aadv_logg(__FILE__,__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() * * @param mixed $l * @param mixed $c * @return */ 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); } function tt($id = 'new', $d = false) { static $a = array(); $ct = array_sum(explode(chr(32), microtime())); if (!isset($a[$id])) return $a[$id] = $ct; elseif ($d) return sprintf("%.4f", ($ct - $a[$id])); } function t($f = '') { if (($this->tt($f, 1)) == '') return; //error_log('PHP AA DEBUG: TIME: [' . $this->tt($f, 1) . '] [' . $this->tt(__FILE__, 1)."] [{".$this->mem_usage(1)."}] {$f}", 0); } /** AA_DEBUG::_cf() * * @param mixed $f * @return */ function _cf($f) { static $b=NULL,$g = array(); if(is_null($b)) $b = ( function_exists('ini_get') ) ? explode(',',strtolower(ini_get('disable_functions'))) : array(); if ( false!==($f=strtolower($f)) && ( in_array($f, $g) || in_array($f, $b)) ) return (in_array($f, $g)); return (!function_exists($f)) ? !( $b[] = $f ) : !!( $g[] = $f ); } /** AA_DEBUG::mem_usage() * * @param mixed $raw * @return */ 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 * @return */ 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 * @return */ function _do_update( $check_time, $newer_than = 300 ) { $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "" ); $time = ( time() - $check_time ); return ( $newer_than < $time ) ? true : false; } /** AA_DEBUG::pp() * * @param mixed $text * @param integer $format * @return */ function pp( $obj, $format = 1 ) { $out=''; if (is_array($obj) || is_object($obj)) $out.="\n".print_r($obj,1)."\n"; else { if(is_string($obj))$out.=$obj; else { ob_start(); var_dump($obj); $out.=ob_get_clean();} } printf( '
%s
', htmlspecialchars($out) ); return true; } function d($level=0) { return (bool) ( isset($GLOBALS["aa_debug_object"]) && absint($GLOBALS["aa_debug_object"]->debug) > absint($level) ) ? true : false; } function aadv_logg($f='', $fu='', $l='', $m='') { $this->t($f.'::'.$fu); $msg="PHP AA_DEBUG Notice: {$fu}() {$m}"; if($this->options['log_errors']=1) if($this->d(20))echo($this->debug . ' ' . $msg."\n"); elseif($this->d(4)) error_log($msg); } /** AA_DEBUG::get_error_log()ions['logfile']=$log_file=@ini_get( 'error_log' ); $log_file * * @return */ function get_error_log() { $this->opt = ( 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::get_error_levels() * * @return */ 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->aadv_logg(__FILE__,__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_posix_info() * * @param string $type * @param string $id * @param mixed $item * @return */ 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->aadv_logg(__FILE__,__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_queries() */ function get_debug_queries() { global $wpdb; $out = ''; if ($wpdb->queries) { $x = 0; $total_time = timer_stop( false, 22 ); $total_query_time = 0; $class = ''; $out .= '
    ' . "\n"; foreach ($wpdb->queries as $q) { if ( $x % 2 != 0 ) $class = ''; else $class = ' class="alt"'; $q[0] = trim( ereg_replace('[[:space:]]+', ' ', $q[0]) ); $total_query_time += $q[1]; $out .= '' . __('Time:') . ' ' . $q[1]; if ( isset($q[1]) ) $out .= '
    ' . __('Query:') . ' ' . htmlentities( $q[0] ); if ( isset($q[2]) ) $out .= '
    ' . __('Call from:') . ' ' . htmlentities( $q[2] ); $out .= '' . "\n"; $x++; } $out .= '
' . "\n\n"; } $php_time = $total_time - $total_query_time; // Create the percentages $mysqlper = number_format_i18n( $total_query_time / $total_time * 100, 2 ); $phpper = number_format_i18n( $php_time / $total_time * 100, 2 ); $out .= '' . "\n"; return $out; } /** AA_DEBUG::get_debug_sockets() * * @return */ function get_debug_sockets($vb=false) { $this->aadv_logg(__FILE__,__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(); return $oa; } /** AA_DEBUG::get_debug_rewrites() * * @param mixed $vb * @return */ function get_debug_rewrites( $vb = false ) { global $is_apache, $wp_rewrite, $wp_query; $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "" ); $oa = array(); $vars=array( 'use_trailing_slashes'=>'Whether to add trailing slashes.', 'use_verbose_rules'=>'Whether to write every mod_rewrite rule for WP. This is off by default', 'use_verbose_page_rules'=>'Whether to write every mod_rewrite rule for WP pages.', 'permalink_structure'=>'Default permalink structure for WP.', 'category_base'=>'Customized or default category permalink base ( askapache.com/xx/tagname ).', 'tag_base'=>'Customized or default tag permalink base ( askapache.com/xx/tagname ).', 'category_structure'=>'Permalink request structure for categories.', 'tag_structure'=>'Permalink request structure for tags.', 'author_base'=>'Permalink author request base ( askapache.com/author/authorname ).', 'author_structure'=>'Permalink request structure for author pages.', 'date_structure'=>'Permalink request structure for dates.', 'page_structure'=>'Permalink request structure for pages.', 'search_base'=>'Search permalink base ( askapache.com/search/query ).', 'search_structure'=>'Permalink request structure for searches.', 'comments_base'=>'Comments permalink base.', 'feed_base'=>'Feed permalink base.', 'comments_feed_structure'=>'Comments feed request structure permalink.', 'feed_structure'=>'Feed request structure permalink.', 'front'=>'Front URL path. If permalinks are turned off. The WP/index.php will be the front portion. If permalinks are turned on', 'root'=>'Root URL path to WP (without domain). The difference between front property is that WP might be located at askapache.com/WP/. The root is the WP/ portion.', 'index'=>'Permalink to the home page.', 'matches'=>'Request match string.', 'rules'=>'Rewrite rules to match against the request to find the redirect or query.', 'extra_rules'=>'Additional rules added external to the rewrite class.', 'extra_rules_top'=>'Additional rules that belong at the beginning to match first.', 'non_wp_rules'=>'Rules that don\'t redirect to WP\'s index.php. These rules are written to the mod_rewrite portion of the .htaccess.', 'extra_permastructs'=>'Extra permalink structures.', 'endpoints'=>'Endpoints permalinks', 'rewritecode'=>'Permalink structure search for preg_replace.', 'rewritereplace'=>'Preg_replace values for the search.', 'queryreplace'=>'Search for the query to look for replacing.', 'feeds'=>'Supported default feeds.', ); foreach($vars as $k=>$d){ if(!isset($wp_rewrite->$k))continue; $v=$wp_rewrite->$k; if(is_bool($v)) $oa[$k]=(($v===true) ? 'TRUE' : 'FALSE'); elseif(is_string($v))$oa[$k]=$v; elseif(is_array($v) && sizeof($v)>0) { $vo=''; foreach($v as $vv) { if(is_array($vv)) foreach($vv as $vvv) $vo.="{$vvv}\n"; else $vo.="{$vv}\n"; } echo $oa[$k]=$vo; } } // robots.txt $robots_rewrite = array('robots\.txt$' => $wp_rewrite->index . '?robots=1'); //Default Feed rules - These are require to allow for the direct access files to work with permalink structure starting with %category% $default_feeds = array( '.*wp-atom.php$' => $wp_rewrite->index . '?feed=atom', '.*wp-rdf.php$' => $wp_rewrite->index . '?feed=rdf', '.*wp-rss.php$' => $wp_rewrite->index . '?feed=rss', '.*wp-rss2.php$' => $wp_rewrite->index . '?feed=rss2', '.*wp-feed.php$' => $wp_rewrite->index . '?feed=feed', '.*wp-commentsrss2.php$' => $wp_rewrite->index . '?feed=rss2&withcomments=1'); // Post $post_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->permalink_structure, EP_PERMALINK); $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite); // Date $date_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_date_permastruct(), EP_DATE); $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite); // Root $root_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->root . '/', EP_ROOT); $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite); // Comments $comments_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->root . $wp_rewrite->comments_base, EP_COMMENTS, true, true, true, false); $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite); // Search $search_structure = $wp_rewrite->get_search_permastruct(); $search_rewrite = $wp_rewrite->generate_rewrite_rules($search_structure, EP_SEARCH); $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite); // Categories $category_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_category_permastruct(), EP_CATEGORIES); $category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite); // Tags $tag_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_tag_permastruct(), EP_TAGS); $tag_rewrite = apply_filters('tag_rewrite_rules', $tag_rewrite); // Authors $author_rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_author_permastruct(), EP_AUTHORS); $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite); // Pages $page_rewrite = $wp_rewrite->page_rewrite_rules(); $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite); $oa['extra_rules_top']=$wp_rewrite->extra_rules_top; $oa['robots_rewrite']=$robots_rewrite; $oa['default_feeds']=$default_feeds; $oa['page_rewrite']=$page_rewrite; $oa['root_rewrite']=$root_rewrite; $oa['comments_rewrite']=$comments_rewrite; $oa['search_rewrite']=$search_rewrite; $oa['category_rewrite']=$category_rewrite; $oa['tag_rewrite']=$tag_rewrite; $oa['author_rewrite']=$author_rewrite; $oa['date_rewrite']=$date_rewrite; $oa['post_rewrite']=$post_rewrite; $oa['extra_rules']=$wp_rewrite->extra_rules; $oa['Permastructs']=$this->handle_results(array('get_date_permastruct','get_year_permastruct','get_month_permastruct','get_day_permastruct','get_category_permastruct', 'get_tag_permastruct','get_author_permastruct','get_search_permastruct','get_page_permastruct','get_feed_permastruct','get_comment_feed_permastruct')); $oa['page_generated']=$this->handle_results(array('page_uri_index','page_rewrite_rules')); $oa['Rewrite Rules']=$this->handle_results(array('wp_rewrite_rules','mod_rewrite_rules')); return array($oa); } function handle_results($incoming) { global $wp_rewrite; $oa=array(); static $rewrite_methods=false; if(!$rewrite_methods) $rewrite_methods=get_class_methods( 'WP_Rewrite' ); foreach((array)$incoming as $k) : if( in_array($k, $rewrite_methods) )$v=$wp_rewrite->{$k}(); elseif( function_exists($k) ) $v=$k(); else continue; if($k=='mod_rewrite_rules')$v=explode("\n",$v); if(is_bool($v)) echo $oa[$k]=(($v===true) ? 'TRUE' : 'FALSE'); elseif(is_string($v))$oa[$k]=$v; elseif(is_array($v) && sizeof($v)>0) { $vo=''; foreach($v as $vv) { if(is_array($vv)) foreach($vv as $vvv) $vo.="{$vvv}\n"; else $vo.="{$vv}\n"; } $oa[$k]=$vo; } endforeach; return $oa; } /** AA_DEBUG::get_debug_interfaces() * * @param mixed $vb * @return */ function get_debug_interfaces( $vb = false ) { $this->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "" ); $oa=array(); foreach((array)@get_declared_interfaces() as $k=>$v) $oa[$v]=''; return array($oa); } /** AA_DEBUG::get_debug_extensions() * * @param mixed $vb * @return */ function get_debug_extensions( $vb = false ) { $this->aadv_logg(__FILE__,__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 mixed $vb * @return */ function get_debug_functions( $vb = false ) { $this->aadv_logg(__FILE__,__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(); return array($oa); } /** AA_DEBUG::get_debug_included() * * @param mixed $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 array($oa); } /** AA_DEBUG::get_debug_permissions() * * @param mixed $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 array($oa); } /** AA_DEBUG::get_debug_classes() * * @param mixed $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')&&$this->_cf('get_class_vars')) ? array('methods'=>get_class_methods($k),'vars'=>get_class_vars("$k")) : ''; return $oa; } /** AA_DEBUG::get_debug_globals() * * @param mixed $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:"");'); 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]; return $oa; } /* function get_debug_globals( $vb = false ) { $oa = array(); global $_GET,$_POST,$_COOKIE,$_SESSION,$_ENV,$_FILES,$_SERVER,$_REQUEST,$HTTP_POST_FILES,$HTTP_POST_VARS,$HTTP_SERVER_VARS,$HTTP_RAW_POST_DATA,$HTTP_GET_VARS,$HTTP_COOKIE_VARS,$HTTP_ENV_VARS; array_walk($g=array('_GET,','_POST,','_COOKIE,','_SESSION,','_ENV,','_FILES,','_SERVER,','_REQUEST,','HTTP_POST_FILES,','HTTP_POST_VARS,','HTTP_SERVER_VARS,','HTTP_RAW_POST_DATA,','HTTP_GET_VARS,','HTTP_COOKIE_VARS,','HTTP_ENV_VARS'), create_function('$n','global $$n;if(!!$$n && ob_start() && (print "( $"."$n )\n") && array_walk($$n, create_function(\'&$v,$k\', \'echo "[$k] => $v\n";\'))) echo "
".htmlspecialchars(ob_get_clean())."
";')); } */ /** AA_DEBUG::get_debug_loaded_extensions() * * @param mixed $vb * @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 mixed $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 array($oa); } /** AA_DEBUG::get_debug_inis() * * @param mixed $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)$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); return array($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; function &_aa_debug_object() { static $aa_debug_object=NULL; if ( null === $aa_debug_object ) { $aa_debug_object=new AA_DEBUG(); $GLOBALS["aa_debug_object"]=&$aa_debug_object; } return $aa_debug_object; } $AA_DEBUG = _aa_debug_object(); $_aapb=preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__); $_aahk=rtrim('tools_page_'.basename(__FILE__), '.php'); if (is_admin()) : add_action("deactivate_{$_aapb}", create_function('', 'if(!is_object($AA_DEBUG))$AA_DEBUG=_aa_debug_object();$AA_DEBUG->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "deactivating_aapb!");delete_option("askapache_debug_options");delete_option("askapache_debug_plugin");')); add_action("activate_{$_aapb}", create_function('', 'if(!is_object($AA_DEBUG))$AA_DEBUG=_aa_debug_object();$AA_DEBUG->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "activating_aapb!");$AA_DEBUG->default_options();')); add_filter("plugin_action_links_{$_aapb}", create_function('$l', 'return array_merge(array("Settings"), $l);')); add_action("admin_init", create_function('','if(!is_object($AA_DEBUG))$AA_DEBUG=_aa_debug_object();$AA_DEBUG->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "admin_init");$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('','if(!is_object($AA_DEBUG))$AA_DEBUG=_aa_debug_object();$AA_DEBUG->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "admin_menu");$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("load-{$_aahk}", create_function('', 'if(!is_object($AA_DEBUG))$AA_DEBUG=_aa_debug_object();$AA_DEBUG->aadv_logg(__FILE__,__FUNCTION__,__LINE__, "load-aahk");"POST"==$_SERVER["REQUEST_METHOD"] && $AA_DEBUG->handle_post();')); unset($_aapb,$_aahk); endif; add_action( "admin_footer", array(&$AA_DEBUG,'admin_footer')); add_action( "wp_footer", array(&$AA_DEBUG,'wp_footer')); ?>