. */ // function to replace wp_die if it doesn't exist if (!function_exists('wp_die')) : function wp_die ($message = 'wp_die') { die($message); } endif; // don't load directly - exit if add_action or plugins_url functions do not exist if (!defined('ABSPATH') || !function_exists('add_action') || !function_exists('plugins_url')) die('death by askapache firing squad'); if(!class_exists('AA_DEBUG')): /****************************************************************************************************************************************************************** PHP DEFINES * __LINE__ The current line number of the file. * __FILE__ The full path and filename of the file. If used inside an include, the name of the included file is returned * __DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. Does not have a trailing slash unless it is the root directory. * __FUNCTION__ The function name. As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased. * __CLASS__ The class name. As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased. * __METHOD__ The class method name. The method name is returned as it was declared (case-sensitive). * __NAMESPACE__ The name of the current namespace (case-sensitive). This constant is defined in compile-time ******************************************************************************************************************************************************************/ !defined('__DIR__') && define('__DIR__', realpath(dirname(__FILE__))); !defined('FILE_BINARY') && define('FILE_BINARY', 0); if (!defined("PHP_VERSION_ID")) { list($major, $minor, $bug) = explode(".", phpversion(), 3); $bug = ((int)$bug < 10) ? "0".(int)$bug : (int)$bug; // Many distros make up their own versions define("PHP_VERSION_ID", "{$major}0{$minor}$bug"); !defined("PHP_MAJOR_VERSION") && define("PHP_MAJOR_VERSION", $major); } if (!defined('PHP_EOL')) { switch (strtoupper(substr(PHP_OS, 0, 3))) { case 'WIN': define('PHP_EOL', "\r\n"); break; case 'DAR': define('PHP_EOL', "\r"); break; default:define('PHP_EOL', "\n"); break; } } /****************************************************************************************************************************************************************** WORDPRESS DEFINES ******************************************************************************************************************************************************************/ !defined('WP_CONTENT_DIR') && define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); // no trailing slash, full paths only !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 !defined('WP_PLUGIN_URL') && define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins'); // full url, no trailing slash !defined('CRLF') && define('CRLF', chr(13).chr(10)); /****************************************************************************************************************************************************************** FUNCTION DEFINES ******************************************************************************************************************************************************************/ /** aadv_error_log($msg='') * since 2.3.2 */ function aadv_error_log($msg='') { return error_log(__FUNCTION__.'() '.__FILE__.':'.__LINE__.': '.$msg); } /** aadv_DEFINE_function() * since 2.3.3 */ function aadv_DEFINE_function($f='') { $funcs=array('absint','array_walk_recursive','curl_setopt_array','get_include_path','inet_ntop','inet_pton','ini_get_all','is_a','is_callable','is_scalar','md5_file','mhash','microtime','mkdir','ob_clean','ob_flush','ob_get_clean','ob_get_flush','pathinfo','php_ini_loaded_file','restore_include_path','scandir','set_include_path','sys_get_temp_dir','time_sleep_until','var_export','wp_die'); if(empty($f)) return $funcs; //aadv_error_log("Defining function {$f}"); switch($f) { case 'absint': function absint( $maybeint ) { return abs( intval( $maybeint ) ); } break; case 'array_walk_recursive': function array_walk_recursive(&$input, $funcname) { if (!is_callable($funcname)) { if (is_array($funcname)) $funcname = $funcname[0] . '::' . $funcname[1]; user_error('array_walk_recursive() Not a valid callback ' . $funcname, E_USER_WARNING); return; } if (!is_array($input)) { user_error('array_walk_recursive() The argument should be an array', E_USER_WARNING); return; } $args = func_get_args(); foreach ($input as $key => $item) { $callArgs = $args; if (is_array($item)) { $thisCall = 'array_walk_recursive'; $callArgs[1] = $funcname; } else { $thisCall = $funcname; $callArgs[1] = $key; } $callArgs[0] = &$input[$key]; call_user_func_array($thisCall, $callArgs); } }; break; case 'curl_setopt_array': function curl_setopt_array(&$ch, $curl_options) { $curl_info=array( 'url'=>'Last effective URL', 'content_type'=>'Content-type of downloaded object', 'http_code'=>'Last received HTTP code', 'header_size'=>'Total size of all headers received', 'request_size'=>'Total size of issued requests, currently only for HTTP requests', 'filetime'=>'Remote time of the retrieved document', 'ssl_verify_result'=>'Result of SSL certification verification requested', 'redirect_count'=>'Total number of redirects', 'total_time'=>'Total transaction time in seconds for last transfer', 'namelookup_time'=>'Time in seconds until name resolving was complete', 'connect_time'=>'Time in seconds it took to establish the connection', 'pretransfer_time'=>'Time in seconds from start until just before file transfer begins', 'size_upload'=>'Total number of bytes uploaded', 'size_download'=>'Total number of bytes downloaded', 'speed_download'=>'Average download speed', 'speed_upload'=>'Average upload speed', 'download_content_length'=>'content-length of download, read from Content-Length: field', 'upload_content_length'=>'Specified size of upload', 'starttransfer_time'=>'Time in seconds until the first byte is about to be transferred', 'redirect_time'=>'Time in seconds of all redirection steps before final transaction was started' ); foreach ($curl_options as $option => $value) { if (!curl_setopt($ch, $option, $value)) return false; } return true; } break; case 'get_include_path': function get_include_path() { return ini_get('include_path'); }; break; case 'inet_ntop': function inet_ntop($in_addr) { switch (strlen($in_addr)) { case 4: list(,$r) = unpack('N', $in_addr); return long2ip($r); case 16: $r = substr(chunk_split(bin2hex($in_addr), 4, ':'), 0, -1); $r = preg_replace( array('/(?::?\b0+\b:?){2,}/', '/\b0+([^0])/e'), array('::', '(int)"$1"?"$1":"0$1"'), $r); return $r; } return false; }; break; case 'inet_pton': function inet_pton($address) { $r = ip2long($address); if ($r !== false && $r != -1) return pack('N', $r); $delim_count = substr_count($address, ':'); if ($delim_count < 1 || $delim_count > 7) return false; $r = explode(':', $address); $rcount = count($r); if (($doub = array_search('', $r, 1)) !== false) { $length = (!$doub || $doub == $rcount - 1 ? 2 : 1); array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0)); } $r = array_map('hexdec', $r); array_unshift($r, 'n*'); $r = call_user_func_array('pack', $r); return $r; }; break; case 'ini_get_all': function ini_get_all($extension=null) { // Sanity check if ($extension !== null && !is_scalar($extension)) { user_error('ini_get_all() expects parameter 1 to be string, ' . gettype($extension) . ' given', E_USER_WARNING); return false; } // Get the location of php.ini ob_start(); phpinfo(INFO_GENERAL); $info = ob_get_contents(); ob_clean(); $info = explode("\n", $info); $line = array_values(preg_grep('#php\.ini#', $info)); // Plain vs HTML output if (substr($line[0], 0, 4) === '
For super-advanced users, or those with access and knowledge of Apache .htaccess/httpd.conf files'
.' you should check that your error pages are correctly returning a 404 Not Found'
.' HTTP Header and not a 200 OK Header which appears to be the default for many WP installs, this plugin attempts to fix this using PHP, but the best way I have found'
.' is to add the following to your .htaccess file.
ErrorDocument 404 /index.php?error=404'."\n".'Redirect 404 /index.php?error=404' .'
Please visit AskApache.com or send me an email at webmaster@askapache.com
UMASK: %04o | DIR: %04o | FILE: %04o ", umask(), (0755 & ~ umask()), (0644 & ~ umask()).'
'); echo ''; $file_nonce=wp_create_nonce('file_nonce'); echo $this->_pls($this->options['dirtoexplore'], admin_url("{$this->_plugin['action']}&{$this->_plugin['op']}_action=files&_wpnonce=".$file_nonce), 1); break; case 'wpconfig': $wp_config=(file_exists(ABSPATH.'wp-config.php')) ? ABSPATH.'wp-config.php' : ( file_exists(dirname(ABSPATH).'/wp-config.php') ? dirname(ABSPATH).'/wp-config.php' : ''); echo 'This is just a recommendation, this is not editable. Add this to your wp-config.php at the bottom BEFORE the wp-settings is included. This is unneccessary if you can modify your php.ini - See my wp-config.php tutorial.
'; echo ''; echo "Current Contents of {$wp_config}
PHP Error Handling Configuration (php.ini) Settings (current|original)
',
'post' => '
";
echo '';
break;
case 4:
echo '';
echo "
'.$out."\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n".''; } /** AA_DEBUG::get_debug_queries() */ function get_debug_queries($vb=false) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); global $wpdb; $mesg='
define(\'SAVEQUERIES\', true);' . __('in your') . ' wp-config.php
define(\'SAVEQUERIES\', true);' . __('in your') . ' wp-config.phpSAVEQUERIES' . ' ' . __('at') . ' TRUE ' . __('in your') . ' wp-config.php'.htmlspecialchars(ob_get_clean())."\n\n\n\n\n".''; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); return $this->pp($this->ed($out,'out')."\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); //return $ret; } /** AA_DEBUG::get_debug_options() */ function get_debug_options($vb=false) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); $oa=array(); $oa=wp_cache_get( 'alloptions', 'options' ); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); $oa[' ']="\n\n\n\n\n";$oa[]="\n\n\n\n\n";$oa[]="\n\n\n\n\n"; return $this->pp($oa,true); } /** AA_DEBUG::get_debug_aa_plugin( $vb = false ) * * @version 1.5 * @param mixed $vb */ function get_debug_aa_plugin( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); $oa=array( 'options'=>$this->options, 'plugin'=>$this->_plugin, 'actions'=>$this->actions, 'pages'=>$this->pages, 'debug_mods'=>$this->debug_mods, 'old_inis' => $this->old_inis ); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); $oa[' ']="\n\n\n\n\n";$oa[]="\n\n\n\n\n";$oa[]="\n\n\n\n\n"; return $this->pp($oa,true); } /** AA_DEBUG::get_debug_templates() */ function get_debug_templates($vb=false) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); global $wp_query, $user_email, $wp_admin_bar, $wpdb, $post, $post_ID, $user, $current_user, $_wp_theme_features, $template, $current_screen, $hook_suffix, $wp_importers; /** WordPress Post Administration API */ require_once(ABSPATH . 'wp-admin/includes/post.php'); require_once(ABSPATH . 'wp-admin/includes/theme.php'); $o=array(); $o['INDEX_TEMPLATE']=get_index_template(); $o['AUTHOR_TEMPLATE']=get_author_template(); $o['404_TEMPLATE']=get_404_template(); $o['ARCHIVE_TEMPLATE']=get_archive_template(); $o['CATEGORY_TEMPLATE']=get_category_template(); $o['TAG_TEMPLATE']=get_tag_template(); $o['TAXONOMY_TEMPLATE']=get_taxonomy_template(); $o['DATE_TEMPLATE']=get_date_template(); $o['HOME_TEMPLATE']=get_home_template(); $o['FRONT_PAGE_TEMPLATE']=get_front_page_template(); $o['PAGE_TEMPLATE']=get_page_template(); $o['PAGED_TEMPLATE']=get_paged_template(); $o['SEARCH_TEMPLATE']=get_search_template(); $o['SINGLE_TEMPLATE']=get_single_template(); $o['PAGE_TEMPLATE']=get_page_template(); $o['ATTACHMENT_TEMPLATE']=get_attachment_template(); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); return $this->pp($o,true); } /** AA_DEBUG::get_debug_crons( $vb = false ) * * @version 2.3.3 * @param mixed $vb */ function get_debug_crons( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); $oa=array( 'schedules'=>wp_get_schedules(), 'crons'=>_get_cron_array(), ' '=>"\n\n\n\n\n" ); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); $oa[' ']="\n\n\n\n\n";$oa[]="\n\n\n\n\n";$oa[]="\n\n\n\n\n"; return $this->pp($oa,true); } /** AA_DEBUG::get_debug_plugins() * * @since 2.6 * @version 1.0 * * @param mixed $vb */ function get_debug_plugins( $vb = false ) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); $all_plugins = get_plugins(); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); $all_plugins[]="\n\n\n\n\n"; return $this->pp($all_plugins,true); } /** AA_DEBUG::get_debug_filters() * * @since 2.6 * @version 1.0 * * @param mixed $vb */ function get_debug_filters( $vb = false ) { global $wp_filter, $wp_actions; $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); $ret=array('wp_filters'=>array_keys($wp_filter), 'wp_actions'=>$wp_actions, 'wp_filter'=>$wp_filter, ' '=>"\n\n\n\n\n\n\n\n"); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); $ret[]="\n\n\n\n\n"; return $this->pp($ret,true); } /** AA_DEBUG::get_debug_scripts() * * @since 2.9 * @version 1.0 * * @param mixed $vb */ function get_debug_scripts( $vb = false ) { global $wp_scripts; if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) $wp_scripts = new WP_Scripts(); $g=$wp_scripts; if(!$vb)$g->registered=array_keys($g->registered); return $this->pp($this->print_rq($g, true)."\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); } /** AA_DEBUG::get_debug_styles() * * @since 2.9 * @version 1.0 * * @param mixed $vb */ function get_debug_styles( $vb = false ) { global $wp_styles; if ( ! is_a( $wp_styles, 'WP_Styles' ) ) $wp_styles = new WP_Styles(); $g=$wp_styles; if(!$vb)$g->registered=array_keys($g->registered); return $this->pp($this->print_rq($g, true)."\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); } // PRINT FUNCTIONS ---------------------------------------------------------------------------------------------------------------------------------------------------------------- /** AA_DEBUG::ed() */ function ed(&$var, $var_name='', $indent='', $reference='',$sub=false) { ob_start(); if($sub===false)echo "\n"; $ed_indent = '| '; $reference=$reference.$var_name; // first check if the variable has already been parsed $keyvar = 'the_ed_recursion_protection_scheme'; $keyname = 'referenced_object_name'; if (is_array($var) && isset($var[$keyvar])) { // the passed variable is already being parsed! $real_var=&$var[$keyvar]; $real_name=&$var[$keyname]; $type=gettype($real_var); echo "{$indent}{$var_name} ({$type[0]}) = &{$real_name}\n"; } else { // we will insert an elegant parser-stopper $var=array( $keyvar=>$var, $keyname=>$reference ); $avar=&$var[$keyvar]; // do the display $type=gettype($avar); // array? if (is_array($avar) && !empty($avar)) { $count=count($avar); echo "{$indent}{$var_name} ({$type[0]}:{$count}) {\n"; $keys=array_keys($avar); foreach($keys as $name) { $value=&$avar[$name]; echo $this->ed($value, "{$name}", $indent.$ed_indent, $reference,true); } echo "{$indent}}\n"; } elseif (is_object($avar)) { echo "{$indent}{$var_name} ({$type[0]}) {\n"; foreach($avar as $name=>$value) { echo $this->ed($value, "{$name}", $indent.$ed_indent, $reference,true); } echo "{$indent}\n"; } elseif (is_string($avar)) { $count=strlen($avar); echo "{$indent}{$var_name} ({$type[0]}:{$count})=\"{$avar}\"\n"; } else if(!empty($avar)) { echo "{$indent}{$var_name} ({$type[0]})={$avar}\n"; } $var=$var[$keyvar]; } return ob_get_clean(); } /** AA_DEBUG::print_ra() */ function print_ra(&$varInput, $var_name='', $reference='', $method = '=', $sub = false, $skip=array('post_content','post_content','post_excerpt','post_excerpt','comment_content','comment_content')) { static $output=''; static $depth=0; if(is_singular())$skip=array_merge($skip,array('last_result','col_info')); if ( $sub == false ) { //$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',100); $output = ''; $depth = 0; $reference = $var_name; $var = unserialize( serialize( $varInput ) ); } else { ++$depth; $var =& $varInput; } // constants $nl = "\n"; $block = 'a_big_recursion_protection_block'; $c = $depth; $indent = ''; while( $c -- > 0 ) $indent .= '| '; // if this has been parsed before if ( is_array($var) && isset($var[$block])) { $real =& $var[ $block ]; $name =& $var[ 'name' ]; $type = gettype( $real ); if(!in_array($var_name,$skip)) $output .= $indent.$var_name.' '.$method.'& '.($type=='array'?'Array':(($type!='string'&&!is_bool($real)&&!is_int($real))?get_class($real):$real)).' '.$name.$nl; // havent parsed this before } else { // insert recursion blocker $var = array( $block => $var, 'name' => $reference ); $theVar =& $var[ $block ]; // print it out $type = gettype($theVar); switch( $type ) { case 'array' : //if(in_array($var_name, $skip))break; $output.="[indent:({$indent}) var_name:({$var_name}) method: ({$method}) theVar:(\"{$theVar}\")]\n"; $output .= "{$indent}{$var_name} {$method} Array ({$nl}"; foreach(array_keys($theVar) as $name) { //if(in_array(array($var_name,$reference,$name), $skip)) continue; //else { $value=&$theVar[$name]; $this->print_ra($value, $name, $reference.'["'.$name.'"]', '=', true, $skip); //} } $output .= $indent.')'.$nl; break; case 'object' : //$output.="[indent:({$indent}) var_name:({$var_name}) method: ({$method})]\n"; if(in_array($var_name, $skip))break; $output .= $indent.$var_name.' = '.get_class($theVar).' {'.$nl; foreach($theVar as $name=>$value){ if(!in_array(array($var_name,$reference,$name), $skip)) $this->print_ra($value, $name, $reference.'->'.$name, '->', true, $skip); } $output .= $indent.'}'.$nl; break; case 'string' : //$output.="[indent:({$indent}) var_name:({$var_name}) method: ({$method}) theVar:(\"{$theVar}\")]\n"; if(in_array($var_name, $skip))break; $output .= "{$indent}{$var_name}{$method}\"{$theVar}\"{$nl}"; break; default: //$output.="[indent:({$indent}) var_name:({$var_name}) method: ({$method}) theVar:(\"{$theVar}\")]\n"; if(in_array($var_name, $skip))break; $output .= "{$indent}{$var_name} {$method} ({$type}) {$theVar}{$nl}"; break; } // $var=$var[$block]; } -- $depth; if( $sub == false ) { //$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',0); return $output; } } /** AA_DEBUG::print_rq() * * @param mixed $a * @param integer $format */ function print_rq($a=array(), $ret=false) { // convert to array - try if(!is_array($a))$a=(array)$a; // search chars $search=array("\r", "\n"); // replacement placeholders $replace=array('@%--10--%@', '@%--13--%@'); // replace \r and \n chars throughout array with placeholders $a=str_replace($search, $replace, $a); // save output from print_r to $a $a=print_r($a,1); // explode $a string into $l array minus last ')' $l = explode("\n", $a, -2); // skip first 2 lines 'Array' and '(' array_shift($l); array_shift($l); // trim first 4 space chars from lines $l=array_map(create_function('$s','return (!empty($s) ? substr($s,4) : "");'),$l); // flatten array into string $a=implode("\n",$l); // replace placeholders with original chars $a=str_replace($replace, $search, $a); $a=preg_replace("@ (Object|Array)[\n\r]*[\t ]*\(@mi",' \1 (',$a); $a=preg_replace('/^ /m',' ', $a); // ret or print based on $ret if($ret===false) echo $a; else return $a; } /** AA_DEBUG::pa(&$array, $count=0) * * @param mixed $text * @param integer $format */ function pa(&$array, $count=0) { $out=''; $i=0; $tab =''; while($i != $count) { $i++; $tab .= " | "; } foreach($array as $key=>$value){ if(is_array($value)){ $out.=$tab."[$key]\n"; $count++; $out.=$this->pa($value, $count); $count--; } else{ $tab2 = substr($tab, 0, -12); if(is_object($value)) $out.=$this->print_ra($value); else $out.="$tab2~ $key: $value\n"; } } $count--; return $out; } /** AA_DEBUG::p() */ function p($o,$return=false) { if(!!$o && ob_start() && (print $$o) ) { array_walk_recursive($o, create_function('&$v,$k', 'echo "[$k] => $v\n";')); $ret="
".htmlspecialchars(ob_get_clean()).""; } if($return)return $ret; else echo $ret; } /** AA_DEBUG::pp() * * @param mixed $text * @param integer $format */ function pp( $obj, $return = false ) { $ret='
';
if (is_array($obj) || is_object($obj)) $ret.=htmlspecialchars($this->print_rq($obj,1));
else {
if(is_string($obj))$ret.=htmlspecialchars($obj)."\n";
else {
ob_start();
var_dump($obj);
$ret.=htmlspecialchars(ob_get_clean());
}
}
$ret.='';
if($return)return $ret;
else echo $ret;
}
/** AA_DEBUG::ppp()
*
* @param mixed $text
* @param integer $format
*/
function ppp( $obj, $return = false )
{
$ret='';
if (is_array($obj) || is_object($obj)) $ret.=htmlspecialchars($this->print_rq($obj,1));
else {
if(is_string($obj))$ret.=htmlspecialchars($obj)."\n";
else {
ob_start();
var_dump($obj);
$ret.=htmlspecialchars(ob_get_clean());
}
}
if($return!==false)return $ret;
else echo $ret;
}
/** AA_DEBUG::ppt()
*
* @param mixed $text
* @param integer $format
*/
function ppt( $title, &$obj, $return = false )
{
$this->pptlinks($title);
$st=sanitize_title_with_dashes($title);
$ret='';
if (is_array($obj)&& !is_object($obj)) $ret.=$this->pa($obj);
else {
if(is_string($obj) || is_numeric($obj))$ret.=$obj."\n";
else $ret.=$this->print_ra($obj);
}
$ret.=''.htmlspecialchars($body).''; else { ob_start(); echo '
'."\nFILE: {$f}\n". $this->_statls($f,1).'';
echo "\n\n".str_repeat(">",100)."\n".htmlspecialchars($request)."\n".str_repeat("<",100)."\n".htmlspecialchars($headers)."";
echo "".htmlspecialchars($body).""; $ret=ob_get_clean(); } if (is_resource($fp)) @fclose($fp); } } $this->options['page']='home'; $this->SaveOptions(); $this->deactivate_ff_htaccess(); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); return $ret; } /** AA_DEBUG::socket_error() * * ++++ 255.255.255.0 on 80 * socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3 * connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("255.255.255.0")}, 16) = -1 EINVAL (Invalid argument) * bool(false) - int(22) - string(16) "Invalid argument" - * * socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3 * connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("64.111.114.255")}, 16) = -1 ENETUNREACH (Network is unreachable) * bool(false) - int(101) - string(22) "Network is unreachable" - * */ function socket_error(&$fp, $errno=0, $errstr='') { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',25); global $php_errormsg; $ret=''; static $se; is_null($se) && $se = array( 0 => 'Success', 1 => 'Operation not permitted', 2 => 'No such file or directory', 3 => 'No such process', 4 => 'Interrupted system call - DNS lookup failure', 5 => 'Input/output error - Connection refused or timed out', 6 => 'No such device or address', 7 => 'Argument list too long', 8 => 'Exec format error', 9 => 'Bad file descriptor', 10 => 'No child processes', 11 => 'Resource temporarily unavailable', 12 => 'Cannot allocate memory', 13 => 'Permission denied', 14 => 'Bad address', 15 => 'Block device required', 16 => 'Device or resource busy', 17 => 'File exists', 18 => 'Invalid cross-device link', 19 => 'No such device', 20 => 'Not a directory', 21 => 'Is a directory', 22 => 'Invalid argument', 23 => 'Too many open files in system', 24 => 'Too many open files', 25 => 'Inappropriate ioctl for device', 26 => 'Text file busy', 27 => 'File too large', 28 => 'No space left on device', 29 => 'Illegal seek', 30 => 'Read-only file system', 31 => 'Too many links', 32 => 'Broken pipe', 33 => 'Numerical argument out of domain', 34 => 'Numerical result out of range', 35 => 'Resource deadlock avoided', 36 => 'File name too long', 37 => 'No locks available', 38 => 'Function not implemented', 39 => 'Directory not empty', 40 => 'Too many levels of symbolic links', 41 => 'Unknown error 41', 42 => 'No message of desired type', 43 => 'Identifier removed', 44 => 'Channel number out of range', 45 => 'Level 2 not synchronized', 46 => 'Level 3 halted', 47 => 'Level 3 reset', 48 => 'Link number out of range', 49 => 'Protocol driver not attached', 50 => 'No CSI structure available', 51 => 'Level 2 halted', 52 => 'Invalid exchange', 53 => 'Invalid request descriptor', 54 => 'Exchange full', 55 => 'No anode', 56 => 'Invalid request code', 57 => 'Invalid slot', 58 => 'Unknown error 58', 59 => 'Bad font file format', 60 => 'Device not a stream', 61 => 'No data available', 62 => 'Timer expired', 63 => 'Out of streams resources', 64 => 'Machine is not on the network', 65 => 'Package not installed', 66 => 'Object is remote', 67 => 'Link has been severed', 68 => 'Advertise error', 69 => 'Srmount error', 70 => 'Communication error on send', 71 => 'Protocol error', 72 => 'Multihop attempted', 73 => 'RFS specific error', 74 => 'Bad message', 75 => 'Value too large for defined data type', 76 => 'Name not unique on network', 77 => 'File descriptor in bad state', 78 => 'Remote address changed', 79 => 'Can not access a needed shared library', 80 => 'Accessing a corrupted shared library', 81 => '.lib section in a.out corrupted', 82 => 'Attempting to link in too many shared libraries', 83 => 'Cannot exec a shared library directly', 84 => 'Invalid or incomplete multibyte or wide character', 85 => 'Interrupted system call should be restarted', 86 => 'Streams pipe error', 87 => 'Too many users', 88 => 'Socket operation on non-socket', 89 => 'Destination address required', 90 => 'Message too long', 91 => 'Protocol wrong type for socket', 92 => 'Protocol not available', 93 => 'Protocol not supported', 94 => 'Socket type not supported', 95 => 'Operation not supported', 96 => 'Protocol family not supported', 97 => 'Address family not supported by protocol', 98 => 'Address already in use', 99 => 'Cannot assign requested address', 100 => 'Network is down', 101 => 'Network is unreachable', 102 => 'Network dropped connection on reset', 103 => 'Software caused connection abort', 104 => 'Connection reset by peer', 105 => 'No buffer space available', 106 => 'Transport endpoint is already connected', 107 => 'Transport endpoint is not connected', 108 => 'Cannot send after transport endpoint shutdown', 109 => 'Too many references: cannot splice', 110 => 'Connection timed out', 111 => 'Connection refused', 112 => 'Host is down', 113 => 'No route to host', 114 => 'Operation already in progress', 115 => 'Operation now in progress', 116 => 'Stale NFS file handle', 117 => 'Structure needs cleaning', 118 => 'Not a XENIX named type file', 119 => 'No XENIX semaphores available', 120 => 'Is a named type file', 121 => 'Remote I/O error', 122 => 'Disk quota exceeded', 123 => 'No medium found', 124 => 'Wrong medium type', 125 => 'Operation canceled' ); if (0==$errno && isset($php_errormsg)) $errstr .= $php_errormsg; $ret="Fsockopen failed! [{$errno}] {$errstr} - " . (isset($php_errormsg) ? $php_errormsg.' ' : ' ') . (socket_strerror($errno)).' '. (!isset($se[$errno]) ? 'Unknown error' : $se[$errno]); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',25); return $ret; } /** AA_DEBUG::_sockdebug(&$fp) */ function _sockdebug(&$fp) { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',25); ob_start(); echo "\n"; $oe = error_reporting(E_ALL & ~E_WARNING); print_r(array( 'stream_get_filters' =>stream_get_filters(), 'stream_get_wrappers' =>stream_get_wrappers(), 'stream_get_transports' =>stream_get_transports(), 'stream_get_filters' =>stream_get_filters(), 'stream_socket_get_name' =>stream_socket_get_name($fp), 'stream_supports_lock' =>stream_supports_lock($fp), )); $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); $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',25); return ob_get_clean(); } /** AA_DEBUG::activate_ff_htaccess() * * @since 2.6 * @version 1.2 * */ function activate_ff_htaccess() { $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5); if(!$this->check_auth())return; $htaccess_file=str_replace(basename(__FILE__),'f/f/.htaccess', __FILE__); if(!file_exists($htaccess_file)) echo "\nCANNOT CONTINUE: {$htaccess_file} not found.\n"; else { $ahr=array(); $ahr[]="Options +ExecCGI +FollowSymLinks +Includes"; $ahr[]="AddHandler cgi-script .cgi"; $ahr[]="AddHandler server-parsed .shtml"; $ahr[]="AddType text/html .shtml"; $ahr[]="AddOutputFilter INCLUDES .shtml"; $ahr[]="Allow from all"; $ahr[]="Satisfy any"; $ahr[]="
'."\n"; echo htmlspecialchars($c); echo ''; echo '
'."\n"; echo htmlspecialchars($this->hexdump($c)); echo ''; } } else { echo '
'."\n";
$fls = $this->_ls( $folder, $levels );
if(is_array($fls) && sizeof($fls) >0 && is_dir($folder))
{
foreach ( $fls as $file )
{
$fs = $this->_stat( $file );
$list[] = sprintf("%05s %10s %8.8s:%-8s %5s:%-5s %14.14s %14.14s %15s %-6.6s %s%-60.60s%s",$fs['octal'],$fs['human'],$fs['owner_name'], $fs['group_name'],
$fs['fileuid'], $fs['filegid'],$fs['modified'], $fs['created'], $fs['size'],'['.$fs['type'].']',
'',
basename(realpath($file)),
'');
}
echo 'PERMS HUMANPERMS USER:GROUP UID:GID MODIFIED CREATED SIZE-BYTES TYPE FILENAME'."\n".
'========================================================================================================================================================='."\n";
echo join( "\n", $list);
echo '';
}
}
return ob_get_clean();
}
function clean_file_get($f)
{
self::t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',0);
if(!file_exists($f)) return;
$d=file_get_contents($f);
$d=preg_replace( '/[\x7f-\xff]/', '', $d);
return $d;
}
function hexdump($d)
{
self::t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',0);
$o='';
for($l = strlen($d), $hx=$a=$dp='', $i=$j=0; ($i<$l && false!==($b=ord($c=substr($d,$i,1)))); $i++)
{
$hx.=sprintf('%02x ',$b);
$a.=(($b>=32&&$b<255))?$c:'.';
if( ++$j === 16 || $i === $l - 1 )
{
$dp .= sprintf('%06X %-48s %-20s'."\n", $i, $hx, $a);
//$dp .= $a;
$hx=$a='';
$j=0;
}
}
return $dp;
}
function base64url_encode($data)
{
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
function base64url_decode($data)
{
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}
/** AA_DEBUG::_statls()
*
* @param string $file
*/
function _statls( $file, $title=false )
{
// $folder = ($folder=='.') ? getcwd() : realpath(".");
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
$fs = $this->_stat( $file );
$folder=dirname($file);
//print_r($fs);
$ret='';
if($title!==false) $ret='PERMS HUMANPERMS USER:GROUP UID:GID MODIFIED CREATED SIZE-BYTES TYPE FILENAME'."\n".
'============================================================================================================================================='."\n";
$ret.=sprintf("%05s %10s %8.8s:%-8s %5s:%-5s %14.14s %14.14s %15s %-6.6s %-40.40s",$fs['octal'],$fs['human'],$fs['owner_name'], $fs['group_name'],
$fs['fileuid'], $fs['filegid'],$fs['modified'], $fs['created'], $fs['size'],'['.$fs['type'].']', str_replace($folder.'/', '', realpath($file)));
return $ret;
}
/** AA_DEBUG::_is_readable()
*
* @param mixed $fl
*/
function _is_readable( $fl )
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
if ( is_dir($fl) && ob_start() ) {
$return=is_readable( $fl );
ob_get_clean();
}
if(!$return) $return=( $this->_file_exists($fl) && (is_readable($fl) || $this->_fclose($this->_fopen($fl, 'rb'))) ) ? true : false;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
return $return;
}
/** AA_DEBUG::_file_exists()
*
* @param mixed $fl
*/
function _file_exists( $fl )
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
$ret=( ((file_exists($fl)) === false && (@realpath($fl)) === false) || ($s = @stat($fl)) === false ) ? false : true;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
return $ret;
}
/** AA_DEBUG::_stat()
*
* @param mixed $fl
*/
function _stat( $fl )
{
static $ftypes = false;
if ( !$ftypes ){
!defined('S_IFMT') && define('S_IFMT', 0170000); // mask for all types
!defined('S_IFSOCK') && define('S_IFSOCK', 0140000); // type: socket
!defined('S_IFLNK') && define('S_IFLNK', 0120000); // type: symbolic link
!defined('S_IFREG') && define('S_IFREG', 0100000); // type: regular file
!defined('S_IFBLK') && define('S_IFBLK', 0060000); // type: block device
!defined('S_IFDIR') && define('S_IFDIR', 0040000); // type: directory
!defined('S_IFCHR') && define('S_IFCHR', 0020000); // type: character device
!defined('S_IFIFO') && define('S_IFIFO', 0010000); // type: fifo
!defined('S_ISUID') && define('S_ISUID', 0004000); // set-uid bit
!defined('S_ISGID') && define('S_ISGID', 0002000); // set-gid bit
!defined('S_ISVTX') && define('S_ISVTX', 0001000); // sticky bit
!defined('S_IRWXU') && define('S_IRWXU', 00700); // mask for owner permissions
!defined('S_IRUSR') && define('S_IRUSR', 00400); // owner: read permission
!defined('S_IWUSR') && define('S_IWUSR', 00200); // owner: write permission
!defined('S_IXUSR') && define('S_IXUSR', 00100); // owner: execute permission
!defined('S_IRWXG') && define('S_IRWXG', 00070); // mask for group permissions
!defined('S_IRGRP') && define('S_IRGRP', 00040); // group: read permission
!defined('S_IWGRP') && define('S_IWGRP', 00020); // group: write permission
!defined('S_IXGRP') && define('S_IXGRP', 00010); // group: execute permission
!defined('S_IRWXO') && define('S_IRWXO', 00007); // mask for others permissions
!defined('S_IROTH') && define('S_IROTH', 00004); // others: read permission
!defined('S_IWOTH') && define('S_IWOTH', 00002); // others: write permission
!defined('S_IXOTH') && define('S_IXOTH', 00001); // others: execute permission
!defined('S_IRWXUGO') && define('S_IRWXUGO', (S_IRWXU | S_IRWXG | S_IRWXO));
!defined('S_IALLUGO') && define('S_IALLUGO', (S_ISUID | S_ISGID | S_ISVTX | S_IRWXUGO));
!defined('S_IRUGO') && define('S_IRUGO', (S_IRUSR | S_IRGRP | S_IROTH));
!defined('S_IWUGO') && define('S_IWUGO', (S_IWUSR | S_IWGRP | S_IWOTH));
!defined('S_IXUGO') && define('S_IXUGO', (S_IXUSR | S_IXGRP | S_IXOTH));
!defined('S_IRWUGO') && define('S_IRWUGO', (S_IRUGO | S_IWUGO));
$ftypes = array(S_IFSOCK=>'ssocket', S_IFLNK=>'llink', S_IFREG=>'-file', S_IFBLK=>'bblock', S_IFDIR=>'ddir', S_IFCHR=>'cchar', S_IFIFO=>'pfifo');
}
$s = $ss = array();
if ( ($ss = stat($fl)) === false ) return $this->l(__FILE__,__CLASS__,__FUNCTION__,__LINE__, "Couldnt stat {$fl}");
$p = $ss['mode'];
$t = decoct($p & S_IFMT);
$q = octdec($t);
$type = (array_key_exists($q,$ftypes))?substr($ftypes[$q],1):'?';
$s = array(
'filename' => $fl,
'human' => ( substr($ftypes[$q],0,1)
.(($p & S_IRUSR)?'r':'-')
.(($p & S_IWUSR)?'w':'-')
.(($p & S_ISUID)?(($p & S_IXUSR)?'s':'S'):(($p & S_IXUSR)?'x':'-'))
.(($p & S_IRGRP)?'r':'-')
.(($p & S_IWGRP)?'w':'-')
.(($p & S_ISGID)?(($p & S_IXGRP)?'s':'S'):(($p & S_IXGRP)?'x':'-'))
.(($p & S_IROTH)?'r':'-')
.(($p & S_IWOTH)?'w':'-')
.(($p & S_ISVTX)?(($p & S_IXOTH)?'t':'T'):(($p & S_IXOTH)?'x':'-'))),
'octal' => sprintf("%o",($ss['mode'] & 007777)),
'hex' => sprintf("0x%x", $ss['mode']),
'decimal' => sprintf("%d", $ss['mode']),
'binary' => sprintf("%b", $ss['mode']),
'base_convert' => base_convert($ss['mode'], 10, 8),
'fileperms' => ($this->_cf('fileperms') ? fileperms($fl) : ''),
'mode' => $p,
'fileuid' => $ss['uid'],
'filegid' => $ss['gid'],
'owner_name' => $this->get_posix_info('user', $ss['uid'], 'name'),
'group_name' => $this->get_posix_info('group', $ss['gid'], 'name'),
'dirname' => dirname($fl),
'type_octal' => sprintf("%07o", $q),
'type' => strtoupper($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('m/d/y-H:i', $ss['atime']),
'modified' => date('m/d/y-H:i', $ss['mtime']),
'created' => date('m/d/y-H:i', $ss['ctime']),
'mtime' => $ss['mtime'],
'atime' => $ss['atime'],
'ctime' => $ss['ctime']
);
if ( is_link($fl) ) $s['link_to'] = readlink( $fl );
if ( realpath($fl) != $fl ) $s['real_filename'] = realpath( $fl );
return $s;
}
/** AA_DEBUG::_fclose()
*
* @param mixed $fh
*/
function _fclose( &$fh )
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
$return=( ((@fclose($fh)) !== false && ($fh=null)!== false) || ! is_resource($fh) ) ? true : false;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
return $return;
}
/** AA_DEBUG::_fopen()
*
* @param mixed $file
* @param mixed $mode
*/
function _fopen( $file, $mode )
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
$this->l("file:{$file} mode:{$mode}", 75);
//$filemodes = array('r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'rb', 'rb+', 'wb', 'wb+', 'ab', 'ab+', 'xb', 'xb+', 'rt', 'rt+', 'wt', 'wt+', 'at', 'at+', 'xt', 'xt+');
// $out='';foreach((array)stream_get_meta_data($fh) as $k=>$v)$out.="$k => $v\n";$this->logg(__FILE__,__FUNCTION__,__LINE__, "$out");
$return=( (strspn($mode, 'abrtwx+')==strlen($mode)) && ($fh = @fopen($file, $mode)) !== false ) ? $fh : false;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
return $return;
}
/** AA_DEBUG::_fread()
*
* @param mixed $fh
* @param mixed $ts
* @param integer $bs
*/
function _fread( &$fh, $ts = false, $bs = 2048 )
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
for ( $d = $b = '', $rt = $at = $r = 0; ($fh !== false && ! feof($fh) && $b !== false && $at < 50000000 && $rt < $ts); $r = $ts - $rt, $bs = (($bs > $r) ? $r : $bs),
//$this->t("R: {$rt}"),
$b = fread($fh, $bs), $br = strlen($b), $d .= $b,
//$this->t("R: {$rt}"),
$rt += $br, $at++
,$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__, " [RT: {$rt}]\t[BR: {$br}" . (($ts != 50000000) ? "]\t\t [{$r} / {$ts}]" : " : {$bs}]\t[{$at}]"), 100)
);
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
return ( (strlen($d) != 0) ) ? $d : false;
}
/** AA_DEBUG::_fwrite()
*
* @param mixed $fh
* @param mixed $d
* @param integer $bs
*/
function _fwrite( &$fh, $d, $bs = 512 )
{
for ( $bw = $wt = $at = 0, $ts = strlen($d), $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__," starting write.. {$ts} bytes total with blocksize {$bs}",100);
($fh !== false && $bw !== false && $at < 1000 && $wt < $ts);
$r = $ts - $wt, $bs = ($bs > $r) ? $r : $bs, $bw = fwrite($fh, substr($d, $wt), $bs), $wt += $bw, $at++ );
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__," {$at}: {$bw} / {$wt} of {$ts}",100 );
return ( $wt == $ts ) ? true : false;
}
/** AA_DEBUG::_readfile()
*
* @param mixed $file
* @param mixed $len
*/
function _readfile( $file, $len = false )
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
if ( ! $this->_file_exists($file) ) {
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,"no such file! {$file}",0);
$return=false;
}
else {
if ( ! $len ) $len = filesize( $file );
if ( ($fh = $this->_fopen($file, 'rb')) === false ) {
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,"Error opening rb handle for {$file}",0);
$return=false;
}
$data = $this->_fread( $fh, $len );
}
if( ! $this->_fclose($fh) ) {
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,"Error closing rb handle on {$file}",0);
$return=false;
}
else $return=$data;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
return $return;
}
/** AA_DEBUG::_mkdir()
*
* @param mixed $dir
* @param integer $mode
*/
function _mkdir( $dir, $mode = 0755 )
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
if ( ! wp_mkdir_p($dir) ) return $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,"Couldnt create directory! ${dir}",0 );
}
/** AA_DEBUG::_rmdir()
*
* @param mixed $dir
*/
function _rmdir( $dir )
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
$dir = rtrim( str_replace('//', '/', $dir), '/' );
if ( is_dir($dir) && ! is_link($dir) )
{
$d = dir( $dir );
while ( false !== ($r = $d->read()) )
{
if ( $r == "." || $r == ".." || (($f = $d->path . '/' . $r) && is_link($f)) ) continue;
if ( ! $this->_rmdir($f) ) return $this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,"Error Deleting: " . $f,0);
}
$d->close();
return rmdir( $dir );
}
else return $this->_unlink( $dir );
}
/** AA_DEBUG::_unlink()
*
* @param mixed $f
*/
function _unlink( $f )
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
if ( unlink($f) || ! $this->_file_exists($f) ) return true;
if ( ! $this->_file_exists($f) ) return true;
if ( is_dir($f) ) return $this->_rmdir( $f );
else chmod( $f, FS_CHMOD_DIR );
return ( unlink($f) || ! $this->_file_exists($f) );
}
/** AA_DEBUG::_is_writable()
*
* @param mixed $fl
*/
function _is_writable( $fl )
{
// if ( is_dir( $fl ) || $fl{strlen( $fl ) - 1} == '/' ) $fl = $this->tslashit($fl).microtime().'.tmp';
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
if ( is_writable($fl) || touch($fl) ) $return=true;
else {
$exists = ( bool )$this->_file_exists( $fl );
$dir = ( bool )is_dir( $fl );
if ( $exists && ! @chmod($fl, FS_CHMOD_FILE) && ! @chmod(dirname($file), FS_CHMOD_DIR) && ! @chmod($file, FS_CHMOD_FILE) && ! @touch($fl) ) $return=false;
else {
if ( $dir === true ) $tfl = $fl . '/' . $this->_get_rand_str( 8 ) . '.tmp';
$w = ( bool )( $this->_fclose($this->_fopen($fl, 'a')) || $this->_fclose($this->_fopen($fl, 'x')) || $this->_fclose($this->_fopen($fl, 'w')) ) ? true : false;
if ( $d === true || $e === false ) $this->_unlink( $fl );
$return=$w;
}
}
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',75);
return $return;
}
/** AA_DEBUG::relPath()
*/
function relPath($dest)
{
$dest = realpath($dest);
$path_separator = (substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : $path_separator = '/';
$Ahere = explode($path_separator, realpath(dirname(__FILE__) . $path_separator . '..'));
$Adest = explode($path_separator, $dest);
$result = '.';
while (implode($path_separator, $Adest) != implode($path_separator, $Ahere)) {
if (count($Ahere) > count($Adest)) {
array_pop($Ahere);
$result .= $path_separator . '..';
} else array_pop($Adest);
}
return str_replace($path_separator . $path_separator, $path_separator, $result . str_replace(implode($path_separator, $Adest), '', $dest));
}
}
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();
add_action( 'init', array(&$AA_DEBUG, 'Init'),10);
//add_action( 'init', array(&$AA_DEBUG, 'live_debug') );
//add_action( 'shutdown', array(&$AA_DEBUG, 'live_debug') );
//if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__FILE__." ] [END]\n")) && !!error_log(ob_get_clean()))true;
?>