.
*/
/* IS? FUNCTINONS
* isset() - Determine if a variable is set and is not NULL (isset() will return FALSE if testing a variable that has been set to NULL)
* is_bool() - Finds out whether a variable is a boolean
* is_numeric() - Finds whether a variable is a number or a numeric string
* is_float() - Finds whether the type of a variable is float
* is_int() - Find whether the type of a variable is integer
* is_string() - Find whether the type of a variable is string
* is_object() - Finds whether a variable is an object
* is_array() - Finds whether a variable is an array
*/
/* SORTING
* array_multisort() value associative yes, numeric no first array or sort options array_walk()
* asort() value yes low to high arsort()
* arsort() value yes high to low asort()
* krsort() key yes high to low ksort()
* ksort() key yes low to high asort()
* natcasesort() value yes natural, case insensitive natsort()
* natsort() value yes natural natcasesort()
* rsort() value no high to low sort()
* shuffle() value no random array_rand()
* sort() value no low to high rsort()
* uasort() value yes user defined uksort()
* uksort() key yes user defined uasort()
* usort() value no user defined uasort()
*/
/* REGEXP
*
* $msg = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $msg);
*
* The following should be escaped if you are trying to match that character: * ^ . $ | ( ) [ ] * + ? { } ,
* Special Character Definitions
* Quote the next metacharacter
* ^ Match the beginning of the line
* . Match any character (except newline)
* $ Match the end of the line (or before newline at the end)
* | Alternation
* () Grouping
* [] Character class
* * Match 0 or more times
* + Match 1 or more times
* ? Match 1 or 0 times
* {n} Match exactly n times
* {n,} Match at least n times
* {n,m} Match at least n but not more than m times
* More Special Character Stuff
* t tab (HT, TAB)
* n newline (LF, NL)
* r return (CR)
* f form feed (FF)
* a alarm (bell) (BEL)
* e escape (think troff) (ESC)
* 033 octal char (think of a PDP-11)
* x1B hex char
* c[ control char
* l lowercase next char (think vi)
* u uppercase next char (think vi)
* L lowercase till \E (think vi)
* U uppercase till \E (think vi)
* E end case modification (think vi)
* Q quote (disable) pattern metacharacters till \E
* Even More Special Characters
* w Match a "word" character (alphanumeric plus "_")
* W Match a non-word character
* s Match a whitespace character
* S Match a non-whitespace character
* d Match a digit character
* D Match a non-digit character
* b Match a word boundary
* B Match a non-(word boundary)
* A Match only at beginning of string
* Z Match only at end of string, or before newline at the end
* z Match only at end of string
* G Match only where previous m//g left off (works only with /g)
*/
/*
///////////////////////////----------------------------------------------------------------------------------------------------- Meta-characters
\ general escape character with several uses
^ assert start of subject (or line, in multiline mode)
$ assert end of subject (or line, in multiline mode)
. match any character except newline (by default)
[ start character class definition
] end character class definition
| start of alternative branch
( start subpattern
) end subpattern
? extends the meaning of (, also 0 or 1 quantifier, also makes greedy quantifiers lazy (see repetition)
* 0 or more quantifier
+ 1 or more quantifier
{ start min/max quantifier
} end min/max quantifier
Part of a pattern that is in square brackets is called a "character class". In a character class the only meta-characters are:
\ general escape character
^ negate the class, but only if the first character
- indicates character range
] terminates the character class
///////////////////////////----------------------------------------------------------------------------------------------------- Escape sequences
\a alarm, that is, the BEL character (hex 07)
\cx "control-x", where x is any character
\e escape (hex 1B)
\f formfeed (hex 0C)
\n newline (hex 0A)
\p{xx} a character with the xx property, see unicode properties for more info
\P{xx} a character without the xx property, see unicode properties for more info
\r carriage return (hex 0D)
\t tab (hex 09)
\xhh character with hex code hh
\ddd character with octal code ddd, or backreference
\040 is another way of writing a space
\40 is the same, provided there are fewer than 40 previous capturing subpatterns
\7 is always a back reference
\11 might be a back reference, or another way of writing a tab
\011 is always a tab
\0113 is a tab followed by the character "3"
\113 is the character with octal code 113 (since there can be no more than 99 back references)
\377 is a byte consisting entirely of 1 bits
\81 is either a back reference, or a binary zero followed by the two characters "8" and "1"
\d any decimal digit
\D any character that is not a decimal digit
\h any horizontal whitespace character (since PHP 5.2.4)
\H any character that is not a horizontal whitespace character (since PHP 5.2.4)
\s any whitespace character
\S any character that is not a whitespace character
\v any vertical whitespace character (since PHP 5.2.4)
\V any character that is not a vertical whitespace character (since PHP 5.2.4)
\w any "word" character
\W any "non-word" character
\b word boundary
\B not a word boundary
\A start of subject (independent of multiline mode)
\Z end of subject or newline at end (independent of multiline mode)
\z end of subject (independent of multiline mode)
\G first matching position in subject
///////////////////////////----------------------------------------------------------------------------------------------------- Character classes
alnum letters and digits
alpha letters
ascii character codes 0 - 127
blank space or tab only
cntrl control characters
digit decimal digits (same as \d)
graph printing characters, excluding space
lower lower case letters
print printing characters, including space
punct printing characters, excluding letters and digits
space white space (not quite the same as \s)
upper upper case letters
word "word" characters (same as \w)
xdigit hexadecimal digits
///////////////////////////----------------------------------------------------------------------------------------------------- Internal option letters
i for PCRE_CASELESS
m for PCRE_MULTILINE
s for PCRE_DOTALL
x for PCRE_EXTENDED
U for PCRE_UNGREEDY
X for PCRE_EXTRA
J for PCRE_INFO_JCHANGED
///////////////////////////----------------------------------------------------------------------------------------------------- Single-character quantifiers
* equivalent to {0,}
+ equivalent to {1,}
? equivalent to {0,1}
///////////////////////////----------------------------------------------------------------------------------------------------- Pattern Modifiers
i (PCRE_CASELESS) If this modifier is set, letters in the pattern match both upper and lower case letters.
m (PCRE_MULTILINE) By default, PCRE treats the subject string as consisting of a single "line" of characters (even if it actually contains several newlines).
s (PCRE_DOTALL) If this modifier is set, a dot metacharacter in the pattern matches all characters, including newlines. Without it, newlines are excluded. This modifier is equivalent to Perl's /s modifier.
x (PCRE_EXTENDED) If this modifier is set, whitespace data characters in the pattern are totally ignored except when escaped or inside a character class, and characters between an unescaped # outside a character class
e (PREG_REPLACE_EVAL) If this modifier is set, preg_replace() does normal substitution of backreferences in the replacement string, evaluates it as PHP code, and uses the result for replacing the search string.
A (PCRE_ANCHORED) If this modifier is set, the pattern is forced to be "anchored", that is, it is constrained to match only at the start of the string which is being searched (the "subject string").
D (PCRE_DOLLAR_ENDONLY) If this modifier is set, a dollar metacharacter in the pattern matches only at the end of the subject string. Without this modifier, a dollar also matches immediately before the final character
S When a pattern is going to be used several times, it is worth spending more time analyzing it in order to speed up the time taken for matching. If this modifier is set, then this extra analysis is performed.
U (PCRE_UNGREEDY) This modifier inverts the "greediness" of the quantifiers so that they are not greedy by default, but become greedy if followed by ?. It is not compatible with Perl. It can also be set by a (?U) modifier
X (PCRE_EXTRA) This modifier turns on additional functionality of PCRE that is incompatible with Perl. Any backslash in a pattern that is followed by a letter that has no special meaning causes an error,
J (PCRE_INFO_JCHANGED) The (?J) internal option setting changes the local PCRE_DUPNAMES option. Allow duplicate names for subpatterns.
u (PCRE8) This modifier turns on additional functionality of PCRE that is incompatible with Perl. Pattern strings are treated as UTF-8. This modifier is available from PHP 4.1.0 or greater on Unix and from PHP 4.2.3 on win32.
///////////////////////////-----------------------------------------------------------------------------------------------------
///////////////////////////-----------------------------------------------------------------------------------------------------
///////////////////////////-----------------------------------------------------------------------------------------------------
///////////////////////////-----------------------------------------------------------------------------------------------------
///////////////////////////-----------------------------------------------------------------------------------------------------
*/
/* Logical Operators (http://www.php.net/manual/en/language.operators.logical.php),
*
* $a = ( false && foo() ) - $a = bool(false)
* $b = ( true || foo() ) - $b = bool(true)
* $c = ( false and foo() ) - $c = bool(false)
* $d = ( true or foo() ) - $d = bool(true)
*
* $a and $b - true if BOTH $a and $b are true.
* $a or $b - true if EITHER $a OR $b is true.
* $a xor $b - true if EITHER $a or $b is true, but not both.
* ! $a - true if $a is NOT true.
* $a && $b - true if BOTH $a and $b are true.
* $a || $b - true if EITHER $a or $b is true.
*
* $g = true && false - $g will be ASSIGNED to (true && false) which is FALSE
* $g = true and false - $g will be ASSIGNED to TRUE
* $g = false || true - $g will be ASSIGNED to (false || true) which is TRUE
* $g = false or true - $g will be ASSIGNED to FALSE
*
* (http://www.php.net/manual/en/language.operators.arithmetic.php)
* $a += $b $a = $a + $b //Addition
* $a -= $b $a = $a - $b //Subtraction
* $a *= $b $a = $a * $b //Multiplication
* $a /= $b $a = $a / $b //Division
* $a %= $b $a = $a % $b //Modulus
*/
/* and, or, execution
*
* if($something) do_this() and do_that(); = do_that() executed only if do_this() returns true
* if($something) do_this() or do_that(); = do_that() executed only if do_this() returns false
*
* // foo() will NEVER get called as those operators are short-circuit
* function foo(){var_dump(array());}
* function_exists('fread') and d();
* function_exists('fread') && d();
* !function_exists('fread') or d();
* !function_exists('fread') || d();
* !function_exists('freap') and d();
* !function_exists('freap') && d();
* function_exists('fredp') or d();
* function_exists('fredp') || d();
*/
/*
When converting to boolean, the following values are considered FALSE:
* the boolean FALSE itself
* the integer 0 (zero)
* the float 0.0 (zero)
* the empty string, and the string "0"
* an array with zero elements
* an object with zero member variables (PHP 4 only)
* the special type NULL (including unset variables)
* SimpleXML objects created from empty tags
Every other value is considered TRUE (including any resource).
-1 is considered TRUE, like any other non-zero (whether negative or positive) number!
var_dump((bool) ""); // bool(false)
var_dump((bool) 1); // bool(true)
var_dump((bool) -2); // bool(true)
var_dump((bool) "foo"); // bool(true)
var_dump((bool) 2.3e5); // bool(true)
var_dump((bool) array(12)); // bool(true)
var_dump((bool) array()); // bool(false)
var_dump((bool) "false"); // bool(true)
*/
/* BUILTIN FUNCTIONS
* static const zend_function_entry builtin_functions[] = {
* zend_version
* func_num_args
* func_get_arg
* func_get_args
* strlen
* strcmp
* strncmp
* strcasecmp
* strncasecmp
* each
* error_reporting
* define
* defined
* get_class
* get_called_class
* get_parent_class
* method_exists
* property_exists
* class_exists
* interface_exists
* function_exists
* class_alias
* get_included_files
* ZEND_FALIAS(get_required_files, get_included_files
* is_subclass_of
* is_a
* get_class_vars
* get_object_vars
* get_class_methods
* trigger_error
* ZEND_FALIAS(user_error, trigger_error
* set_error_handler
* restore_error_handler
* set_exception_handler
* restore_exception_handler
* get_declared_classes
* get_declared_interfaces
* get_defined_functions
* get_defined_vars
* create_function
* get_resource_type
* get_loaded_extensions
* extension_loaded
* get_extension_funcs
* get_defined_constants
* debug_backtrace
* debug_print_backtrace
* gc_collect_cycles
* gc_enabled
* gc_enable
* gc_disable
*/
//if(ob_start() && (print(str_repeat("\n",5).str_repeat("=",235)."\n+-- ".__LINE__." ------------------------------[ ".__FILE__." ] [START]\n")) && !!error_log(ob_get_clean()))true;
// exit if add_action or plugins_url functions do not exist
!defined('ABSPATH') || !function_exists('add_action') || !function_exists('plugins_url') || !function_exists('add_management_page') || !function_exists('wp_die') && exit;
if(!class_exists('AA_DEBUG')):
/******************************************************************************************************************************************************************
WORDPRESS COMPAT FUNCTIONS
******************************************************************************************************************************************************************/
if (!function_exists('wp_die')) : function wp_die ($message = 'wp_die') { die($message); } endif;
if (!function_exists('absint')): function absint( $maybeint ) { return abs( intval( $maybeint ) ); } endif;
/******************************************************************************************************************************************************************
PHP DEFINES
******************************************************************************************************************************************************************/
/*
__LINE__ The current line number of the file.
__FILE__ The full path and filename of the file. If used inside an include, the name of the included file is returned
__DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. Does not have a trailing slash unless it is the root directory.
__FUNCTION__ The function name. As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__CLASS__ The class name. As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__METHOD__ The class method name. The method name is returned as it was declared (case-sensitive).
__NAMESPACE__ The name of the current namespace (case-sensitive). This constant is defined in compile-time
*/
// Version constants only available as of 5.2.8
if (!defined("PHP_VERSION_ID"))
{
list($major, $minor, $bug) = explode(".", phpversion(), 3);
$bug = ((int)$bug < 10) ? "0".(int)$bug : (int)$bug; // Many distros make up their own versions
define("PHP_VERSION_ID", "{$major}0{$minor}$bug");
!defined("PHP_MAJOR_VERSION") && define("PHP_MAJOR_VERSION", $major);
}
!defined('__DIR__') && define('__DIR__', realpath(dirname(__FILE__)));
!defined('FILE_BINARY') && define('FILE_BINARY', 0);
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('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
//function isc_lock($ip=null){ return (bool)( ((null === $ip) ? $_SERVER['REMOTE_ADDR'] : $ip) === ISC_IP); }
function sqpt_error_log($msg=''){ error_log($msg); return; }
!defined('CRLF') && define('CRLF', chr(13).chr(10));
/** aadv_DEFINE_function() - This is a cool workaround to defining functions already defined but throwing errors
*/
function aadv_DEFINE_function($f='')
{
switch($f)
{
case 'get_include_path': function get_include_path(){ return ini_get('include_path'); }; break;
case 'set_include_path': function set_include_path($new_include_path){ return ini_set('include_path', $new_include_path); }; break;
case 'restore_include_path': function restore_include_path(){ return ini_restore('include_path'); }; break;
case 'inet_ntop': function inet_ntop($in_addr)
{
switch (strlen($in_addr)) {
case 4:
list(,$r) = unpack('N', $in_addr);
return long2ip($r);
case 16:
$r = substr(chunk_split(bin2hex($in_addr), 4, ':'), 0, -1);
$r = preg_replace(
array('/(?::?\b0+\b:?){2,}/', '/\b0+([^0])/e'),
array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;
}
return false;
}
break;
case 'inet_pton': function inet_pton($address)
{
$r = ip2long($address);
if ($r !== false && $r != -1) return pack('N', $r);
$delim_count = substr_count($address, ':');
if ($delim_count < 1 || $delim_count > 7) return false;
$r = explode(':', $address);
$rcount = count($r);
if (($doub = array_search('', $r, 1)) !== false) {
$length = (!$doub || $doub == $rcount - 1 ? 2 : 1);
array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0));
}
$r = array_map('hexdec', $r);
array_unshift($r, 'n*');
$r = call_user_func_array('pack', $r);
return $r;
}
break;
case 'php_ini_loaded_file': function php_ini_loaded_file()
{
// Get the location of php.ini
ob_start();
phpinfo(INFO_GENERAL);
$info = ob_get_contents();
ob_clean();
$info = explode("\n", $info);
$line = array_values(preg_grep('#php\.ini#', $info));
// Plain vs HTML output
if (substr($line[0], 0, 4) === '
') {
list (, $value) = explode('', $line[0], 2);
$inifile = trim(strip_tags($value));
} else {
list (, $value) = explode(' => ', $line[0], 2);
$inifile = trim($value);
}
// Check the file actually exists
if (!file_exists($inifile)) {
user_error('ini_get_all() Unable to find php.ini', E_USER_WARNING);
return false;
}
// Check the file is readable
if (!is_readable($inifile)) {
user_error('ini_get_all() Unable to open php.ini', E_USER_WARNING);
return false;
}
// Parse the ini
if ($extension !== null)
{
$ini_all = parse_ini_file($inifile, true);
// Lowercase extension keys
foreach ($ini_all as $key => $value) $ini_arr[strtolower($key)] = $value;
// Check the extension exists
if (isset($ini_arr[$extension])) $ini = $ini_arr[$extension];
else {
user_error("ini_get_all() Unable to find extension '$extension'",E_USER_WARNING);
return false;
}
} else {
$ini = parse_ini_file($inifile);
}
// Order
$ini_lc = array_map('strtolower', array_keys($ini));
array_multisort($ini_lc, SORT_ASC, SORT_STRING, $ini);
// Format
$info = array();
foreach ($ini as $key => $value) $info[$key] = array( 'global_value' => $value, 'local_value' => ini_get($key), 'access' => -1);
return $info;
}
break;
case 'is_a': function is_a($object, $class)
{
if (!is_object($object)) return false;
if (strtolower(get_class($object)) == strtolower($class)) return true;
else return is_subclass_of($object, $class);
}
break;
case 'is_callable': function is_callable($var, $syntax_only = false)
{
if (!is_string($var) && !(is_array($var) && count($var) == 2 && isset($var[0], $var[1]) && is_string($var[1]) && (is_string($var[0]) || is_object($var[0])))) return false;
if ($syntax_only) return true;
if (is_string($var)) return function_exists($var);
else if (is_array($var))
{
if (is_string($var[0])) {
$methods = get_class_methods($var[0]);
$method = strtolower($var[1]);
if ($methods) {
foreach ($methods as $classMethod) {
if (strtolower($classMethod) == $method) return true;
}
}
} else return method_exists($var[0], $var[1]);
}
return false;
}
break;
case 'mhash':
!defined('MHASH_CRC32') && define('MHASH_CRC32', 0);
!defined('MHASH_MD5') && define('MHASH_MD5', 1);
!defined('MHASH_SHA1') && define('MHASH_SHA1', 2);
!defined('MHASH_HAVAL256') && define('MHASH_HAVAL256', 3);
!defined('MHASH_RIPEMD160') && define('MHASH_RIPEMD160', 5);
!defined('MHASH_TIGER') && define('MHASH_TIGER', 7);
!defined('MHASH_GOST') && define('MHASH_GOST', 8);
!defined('MHASH_CRC32B') && define('MHASH_CRC32B', 9);
!defined('MHASH_HAVAL192') && define('MHASH_HAVAL192', 11);
!defined('MHASH_HAVAL160') && define('MHASH_HAVAL160', 12);
!defined('MHASH_HAVAL128') && define('MHASH_HAVAL128', 13);
!defined('MHASH_TIGER128') && define('MHASH_TIGER128', 14);
!defined('MHASH_TIGER160') && define('MHASH_TIGER160', 15);
!defined('MHASH_MD4') && define('MHASH_MD4', 16);
!defined('MHASH_SHA256') && define('MHASH_SHA256', 17);
!defined('MHASH_ADLER32') && define('MHASH_ADLER32', 18);
function mhash($hashtype, $data, $key = '')
{
switch ($hashtype) {
case MHASH_MD5:
$key = str_pad((strlen($key) > 64 ? pack("H*", md5($key)) : $key), 64, chr(0x00));
$k_opad = $key ^ (str_pad('', 64, chr(0x5c)));
$k_ipad = $key ^ (str_pad('', 64, chr(0x36)));
return pack("H*", md5($k_opad . pack("H*", md5($k_ipad . $data))));
default:
return false;
break;
}
}
break;
case 'get_current_screen': function get_current_screen() { global $current_screen; return (( !isset($current_screen) ) ? null : $current_screen); }; break;
case 'sys_get_temp_dir': function sys_get_temp_dir()
{
if (!empty($_ENV['TMP'])) return realpath($_ENV['TMP']);
if (!empty($_ENV['TMPDIR'])) return realpath( $_ENV['TMPDIR']);
if (!empty($_ENV['TEMP'])) return realpath( $_ENV['TEMP']);
$tempfile = tempnam(uniqid(rand(),TRUE),'');
if (file_exists($tempfile)) {
unlink($tempfile);
return realpath(dirname($tempfile));
}
}
break;
case 'time_sleep_until': function time_sleep_until($timestamp)
{
list($usec, $sec) = explode(' ', microtime());
$now = $sec + $usec;
if ($timestamp <= $now) {
user_error('Specified timestamp is in the past', E_USER_WARNING);
return false;
}
$diff = $timestamp - $now;
usleep($diff * 1000000);
return true;
}
break;
case 'is_scalar': function is_scalar($val){ return (is_bool($val) || is_int($val) || is_float($val) || is_string($val)); }; break;
case 'md5_file': function md5_file($filename, $raw_output = false)
{
// Sanity check
if (!is_scalar($filename)) {
user_error('md5_file() expects parameter 1 to be string, ' . gettype($filename) . ' given', E_USER_WARNING);
return;
}
if (!is_scalar($raw_output)) {
user_error('md5_file() expects parameter 2 to be bool, ' . gettype($raw_output) . ' given', E_USER_WARNING);
return;
}
if (!file_exists($filename)) {
user_error('md5_file() Unable to open file', E_USER_WARNING);
return false;
}
// Read the file
if (false === $fh = fopen($filename, 'rb')) {
user_error('md5_file() failed to open stream: No such file or directory', E_USER_WARNING);
return false;
}
clearstatcache();
if ($fsize = @filesize($filename)) {
$data = fread($fh, $fsize);
} else {
$data = '';
while (!feof($fh)) {
$data .= fread($fh, 8192);
}
}
fclose($fh);
// Return
$data = md5($data);
if ($raw_output === true) {
$data = pack('H*', $data);
}
return $data;
}
break;
case 'microtime': function microtime($get_as_float = false)
{
if (!function_exists('gettimeofday')) {
$time = time();
return $get_as_float ? ($time * 1000000.0) : '0.00000000 ' . $time;
}
$gtod = gettimeofday();
$usec = $gtod['usec'] / 1000000.0;
return $get_as_float
? (float) ($gtod['sec'] + $usec)
: (sprintf('%.8f ', $usec) . $gtod['sec']);
}
break;
case 'mkdir': function mkdir($pathname, $mode = 0777, $recursive = true, $context = null)
{
if (version_compare(PHP_VERSION, '5.0.0', 'gte')) {
// revert to native function
return (func_num_args() > 3)
? mkdir($pathname, $mode, $recursive, $context)
: mkdir($pathname, $mode, $recursive);
}
if (!strlen($pathname)) {
user_error('No such file or directory', E_USER_WARNING);
return false;
}
if (is_dir($pathname)) {
if (func_num_args() == 5) {
// recursive call
return true;
}
user_error('File exists', E_USER_WARNING);
return false;
}
$parent_is_dir = php_compat_mkdir(dirname($pathname), $mode, $recursive, null, 0);
if ($parent_is_dir) {
return mkdir($pathname, $mode);
}
user_error('No such file or directory', E_USER_WARNING);
return false;
}
break;
case 'ob_clean': function ob_clean()
{
if (@ob_end_clean()) {
return ob_start();
}
user_error("ob_clean() failed to delete buffer. No buffer to delete.", E_USER_NOTICE);
return false;
}
break;
case 'ob_flush': function ob_flush()
{
if (@ob_end_flush()) {
return ob_start();
}
user_error("ob_flush() Failed to flush buffer. No buffer to flush.", E_USER_NOTICE);
return false;
}
break;
case 'ob_get_clean': function ob_get_clean()
{
$contents = ob_get_contents();
if ($contents !== false) {
ob_end_clean();
}
return $contents;
}
break;
case 'ob_get_flush': function ob_get_flush()
{
$contents = ob_get_contents();
if ($contents !== false) {
ob_end_flush();
}
return $contents;
}
break;
case 'pathinfo':
!defined('PATHINFO_FILENAME') && define('PATHINFO_FILENAME', 8);
function pathinfo($path = false, $options = false)
{
// Sanity check
if (!is_scalar($path)) {
user_error('pathinfo() expects parameter 1 to be string, ' . gettype($path) . ' given', E_USER_WARNING);
return;
}
if (version_compare(PHP_VERSION, '5.2.0', 'ge')) {
return pathinfo($path, $options);
}
if ($options & PATHINFO_FILENAME) {
//bug #15688
if (strpos($path, '.') !== false) {
$filename = substr($path, 0, strrpos($path, '.'));
}
if ($options === PATHINFO_FILENAME) {
return $filename;
}
$pathinfo = pathinfo($path, $options);
$pathinfo['filename'] = $filename;
return $pathinfo;
}
return pathinfo($path, $options);
}
break;
case 'scandir': function scandir($directory, $sorting_order = 0)
{
if (!is_string($directory)) {
user_error('scandir() expects parameter 1 to be string, ' . gettype($directory) . ' given', E_USER_WARNING);
return;
}
if (!is_int($sorting_order) && !is_bool($sorting_order)) {
user_error('scandir() expects parameter 2 to be long, ' . gettype($sorting_order) . ' given', E_USER_WARNING);
return;
}
if (!is_dir($directory) || (false === $fh = @opendir($directory))) {
user_error('scandir() failed to open dir: Invalid argument', E_USER_WARNING);
return false;
}
$files = array ();
while (false !== ($filename = readdir($fh))) {
$files[] = $filename;
}
closedir($fh);
if ($sorting_order == 1) {
rsort($files);
} else {
sort($files);
}
return $files;
}
break;
case 'var_export': function var_export($var, $return = false, $level = 0, $inObject = false)
{
// Init
$indent = ' ';
$doublearrow = ' => ';
$lineend = ",\n";
$stringdelim = '\'';
$newline = "\n";
$find = array(null, '\\', '\'');
$replace = array('NULL', '\\\\', '\\\'');
$out = '';
// Indent
$level++;
for ($i = 1, $previndent = ''; $i < $level; $i++) {
$previndent .= $indent;
}
$varType = gettype($var);
// Handle object indentation oddity
if ($inObject && $varType != 'object') {
$previndent = substr($previndent, 0, -1);
}
// Handle each type
switch ($varType) {
// Array
case 'array':
if ($inObject) {
$out .= $newline . $previndent;
}
$out .= 'array (' . $newline;
foreach ($var as $key => $value) {
if (is_string($key)) {
// Make key safe
$key = str_replace($find, $replace, $key);
$key = $stringdelim . $key . $stringdelim;
}
// Value
if (is_array($value)) {
$export = php_compat_var_export($value, true, $level);
$value = $newline . $previndent . $indent . $export;
} else {
$value = php_compat_var_export($value, true, $level);
}
// Piece line together
$out .= $previndent . $indent . $key . $doublearrow . $value . $lineend;
}
// End string
$out .= $previndent . ')';
break;
// String
case 'string':
// Make the string safe
for ($i = 0, $c = count($find); $i < $c; $i++) {
$var = str_replace($find[$i], $replace[$i], $var);
}
$out = $stringdelim . $var . $stringdelim;
break;
// Number
case 'integer':
case 'double':
$out = (string) $var;
break;
// Boolean
case 'boolean':
$out = $var ? 'true' : 'false';
break;
// NULLs
case 'NULL':
case 'resource':
$out = 'NULL';
break;
// Objects
case 'object':
// Start the object export
$out = $newline . $previndent;
$out .= get_class($var) . '::__set_state(array(' . $newline;
// Export the object vars
foreach(get_object_vars($var) as $key => $value) {
$out .= $previndent . $indent . ' ' . $stringdelim . $key . $stringdelim . $doublearrow;
$out .= php_compat_var_export($value, true, $level, true) . $lineend;
}
$out .= $previndent . '))';
break;
}
// Method of output
if ($return === true) {
return $out;
} else {
echo $out;
}
}
break;
case 'array_walk_recursive': function array_walk_recursive(&$input, $funcname)
{
if (!is_callable($funcname)) {
if (is_array($funcname)) {
$funcname = $funcname[0] . '::' . $funcname[1];
}
user_error('array_walk_recursive() Not a valid callback ' . $funcname, E_USER_WARNING);
return;
}
if (!is_array($input)) {
user_error('array_walk_recursive() The argument should be an array', E_USER_WARNING);
return;
}
$args = func_get_args();
foreach ($input as $key => $item) {
$callArgs = $args;
if (is_array($item)) {
$thisCall = 'array_walk_recursive';
$callArgs[1] = $funcname;
} else {
$thisCall = $funcname;
$callArgs[1] = $key;
}
$callArgs[0] = &$input[$key];
call_user_func_array($thisCall, $callArgs);
}
}
break;
case 'set_current_screen': function set_current_screen( $id = '' )
{
global $current_screen, $hook_suffix, $typenow, $taxnow;
$action = '';
if ( empty($id) ) {
$current_screen = str_replace('.php', '', $hook_suffix);
if ( preg_match('/-add|-new$/', $current_screen) ) $action = 'add';
$current_screen = str_replace('-add', '', str_replace('-new', '', $current_screen));
$current_screen = array('id' => $current_screen, 'base' => $current_screen);
} else {
$id = sanitize_key($id);
if ( false !== strpos($id, '-') ) {
list( $id, $typenow ) = explode('-', $id, 2);
if ( taxonomy_exists( $typenow ) ) {$id = 'edit-tags';$taxnow = $typenow;$typenow = '';}
}
$current_screen = array('id' => $id, 'base' => $id);
}
$current_screen = (object) $current_screen;
$current_screen->action = $action;
if ( 'index' == $current_screen->base ) $current_screen->base = 'dashboard';
if ( 'index' == $current_screen->id ) $current_screen->id = 'dashboard';
if ( 'edit' == $current_screen->id ) {
if ( empty($typenow) )$typenow = 'post';
$current_screen->id .= '-' . $typenow;
$current_screen->post_type = $typenow;
} elseif ( 'post' == $current_screen->id ) {
if ( empty($typenow) ) $typenow = 'post';
$current_screen->id = $typenow;
$current_screen->post_type = $typenow;
} elseif ( 'edit-tags' == $current_screen->id ) {
if ( empty($taxnow) ) $taxnow = 'post_tag';
$current_screen->id = 'edit-' . $taxnow;
$current_screen->taxonomy = $taxnow;
}
$current_screen->is_network = is_network_admin();
$current_screen->is_user = is_user_admin();
if ( $current_screen->is_network ) {$current_screen->base .= '-network';$current_screen->id .= '-network';}
elseif ( $current_screen->is_user ) {$current_screen->base .= '-user';$current_screen->id .= '-user';}
$current_screen = apply_filters('current_screen', $current_screen);
}
break;
}
}
/**
* AA_DEBUG
*
* @package
* @author askapache
* @copyright Copyright (c) 2011
* @version $Id$
* @access public
*/
class AA_DEBUG
{
/*
* e
* -------------------------------
* @since 2.2.8
* @var string
*/
var $qn='askapache_debug';
/*
* e
* -------------------------------
* @since 2.2.8
* @var int
*/
var $debug=0;
/*
* Contains Plugin Name and Settings from parsing this file
* -------------------------------
*
* [plugin] => Array
* [plugin-name] => AskApache Debug Viewer
* [short-name] => AA Debug
* [description] => Displays Advanced Debugging Output
* [author] => askapache,cduke250
* [version] => 2.2.8
* [requires-at-least] => 2.9
* [tested-up-to] => 3.4-alpha-19719
* [tags] => debug, debugging, error, errors, problems, support, admin, programmer, developer, plugin, development, information, stats, logs, queries, htaccess, password, error, support, askapache
* [contributors] => askapache,cduke250
* [wordpress-uri] => http://wordpress.org/extend/plugins/askapache-debug-viewer/
* [author-uri] => http://www.askapache.com/
* [donate-uri] => http://www.askapache.com/donate/
* [plugin-uri] => http://www.askapache.com/wordpress/debug-viewer-plugin.html
* [role] => administrator
* [capability] => askapache_debug_viewer
* [qn] => askapache_debug
* [http] => //w
* [file] => /askapache.com/htdocs/wp-content/plugins/askapache-debug-viewer/askapache-debug-viewer.php
* [title] => AskApache Debug Viewer
* [pb] => askapache-debug-viewer/askapache-debug-viewer.php
* [page] => askapache-debug-viewer.php
* [pagenice] => askapache-debug-viewer
* [nonce] => form_askapache-debug-viewer
* [hook] => settings_page_askapache-debug-viewer
* [action] => options-general.php?page=askapache-debug-viewer.php
* [op] => adv7 *
* @since 2.2.8
* @var array
*/
var $plugin = array(); // array to hold plugin information
/*
* Options for this plugin
* -------------------------------
*
* [options] => Array
* [page] => home
* [logfile] => /opt/a22161/logs/vhost_custom/www.askapache.com/php_error.log
* [dirtoexplore] => /askapache.com/tmp
* [log_errors] => 1
* [debug_live] => 0
* [admin_footer] => 1
* [wp_footer] => 1
* [error_reporting] => 4983
* [plugin_debug_level] => 5
* [debug_mods_v] => 5
* [debug_mods] => 5
* [admin_bar] => 1
*
* @since 2.2.8
* @var array
*/
var $options = array(
'page'=> 'home',
'logfile' => '',
'dirtoexplore' => '',
'log_errors' => '0',
'debug_live' => '0',
'display_height' => 500,
'admin_footer' => '1',
'wp_footer' => '1',
'admin_bar' => '1',
'error_reporting' => 4983, //2147483647,
'plugin_debug_level' => 0,
'debug_mods_v' => 524294,
'debug_mods' => 531871
);
/*
* Pages for Navigating to
* -------------------------------
*
* [pages] => Array
* [home] => Array
* [name] => Settings
* [title] => Setup Debugging Options
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_page=home&_wpnonce=141fb3899c
* [wpconfig] => Array
* [name] => wp-config File
* [title] => Current and recommended wp-config.php file
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_page=wpconfig&_wpnonce=d0c89659a7
* [phpinfo] => Array
* [name] => PHPINFO
* [title] => phpinfo
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_page=phpinfo&_wpnonce=8c9331fe28
* [server-status] => Array
* [name] => Server Status
* [title] => Server Status
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_page=server-status&_wpnonce=a148d0af82
* [server-info] => Array
* [name] => Server Info
* [title] => Server Info
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_page=server-info&_wpnonce=ae9afd29a9
* [server-env] => Array
* [name] => Server Env
* [title] => Printenv Output
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_page=server-env&_wpnonce=9b8d9ab463
* [files] => Array
* [name] => Directory File Browser
* [title] => Browse files and directories
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_page=files&_wpnonce=0cf667012c
*
* @since 2.2.8
* @var array
*/
var $pages = array(
//'home' => array('name'=>'Settings', 'title'=>'Setup Debugging Options', 'nonce'=>''),
'wpconfig' => array('name'=>'wp-config File', 'title'=>'wp-config.php file', 'nonce'=>''),
'phpinfo' => array('name'=>'PHPINFO', 'title'=>'phpinfo', 'nonce'=>''),
'server-status' => array('name'=>'Server Status', 'title'=>'Server Status', 'nonce'=>''),
'server-info' => array('name'=>'Server Info', 'title'=>'Server Info', 'nonce'=>''),
'server-env' => array('name'=>'Server Env', 'title'=>'Printenv Output', 'nonce'=>''),
//'files' => array('name'=>'Directory File Browser', 'title'=>'Browse files and directories', 'nonce'=>'')
);
/*
* Actions for immediate effect
* -------------------------------
*
* [adminbaroff] => Array
* [title] => Disable Front Admin Bar
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_action=adminbaroff&_wpnonce=5b02532fda
* [disable] => Array
* [title] => Disable
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_action=disable&_wpnonce=1352fa97c2
* [enable] => Array
* [title] => Enable
* [nonce] => https://www.askapache.com/wp-admin/options-general.php?page=askapache-debug-viewer.php&adv7_action=enable&_wpnonce=e136051dee
*
* @since 2.2.8
* @var array
*/
var $actions = array(
'adminbaroff' =>array('title'=>'Disable Front Admin Bar', 'nonce'=>''),
'disable' =>array('title'=>'Disable', 'nonce'=>''),
'enable' =>array('title'=>'Enable', 'nonce'=>'')
);
/*
* $debug_mods
* -------------------------------
* @since 2.2.8
* @var array
*/
var $debug_mods = array();
/*
* $ini_overwrites
* -------------------------------
* @since 2.2.8
* @var array
*/
var $ini_overwrites=array(
//'output_handler' => '',
//'session.auto_start' => '0',
//'zlib.output_compression' => 0,
//'output_buffering' => 0,
//'precision'=>'14',
//'report_zend_debug' => 0,
'open_basedir' => '',
'tidy.clean_output' => 0,
'xdebug.default_enable' => 0,
'mbstring.func_overload' => 0,
'error_prepend_string' => '',
'error_append_string' => '',
'auto_prepend_file' => '',
'auto_append_file' => '',
'disable_functions' => '',
'safe_mode' => 0,
'request_order' => 'GPCES',
'register_globals' => 1,
'register_long_arrays' => 1,
'register_argc_argv' => 1,
'always_populate_raw_post_data' => 1,
'error_reporting' => 0,
'display_errors' => 0,
'display_startup_errors' => 0,
'log_errors' => 1,
'html_errors' => 0,
'track_errors' => 1,
'report_memleaks' => 1,
'magic_quotes_runtime' => 0,
'magic_quotes_gpc' => 0,
'ignore_repeated_errors' => 1,
'ignore_repeated_source' => 1,
'log_errors_max_len'=>'0'
);
/*
* Old Ini Settings for storage
* -------------------------------
*
* [old_inis] => Array
* [open_basedir] => /askapache.com/tmp/:/askapache.com/htdocs/
* [tidy.clean_output] =>
* [xdebug.default_enable] =>
* [mbstring.func_overload] => 0
* [error_prepend_string] =>
* [error_append_string] =>
* [auto_prepend_file] =>
* [auto_append_file] =>
* [disable_functions] => exec,shell_exec,system,passthru,disk_total_space,diskfreespace,popen,proc_open,proc_nice,dl
* [safe_mode] =>
* [request_order] => GP
* [register_globals] =>
* [register_long_arrays] =>
* [register_argc_argv] =>
* [always_populate_raw_post_data] => 0
* [error_reporting] => 4983
* [display_errors] => Off
* [display_startup_errors] =>
* [log_errors] => On
* [html_errors] =>
* [track_errors] =>
* [report_memleaks] => 1
* [magic_quotes_runtime] => 0
* [magic_quotes_gpc] => 1
* [ignore_repeated_errors] => 1
* [ignore_repeated_source] => 1
* [log_errors_max_len] => 1000240
*
* @since 2.2.8
* @var array
*/
var $old_inis = array();
/** AA_DEBUG::AA_DEBUG()
*/
function AA_DEBUG()
{
//if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [START]\n")) && !!error_log(ob_get_clean())) true;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if(version_compare(PHP_VERSION, '5.0.0', 'lt')){
$this->__construct();
register_shutdown_function(array($this,"__destruct"));
}
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
//if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [END]\n")) && !!error_log(ob_get_clean())) true;
}
/** AA_DEBUG::__construct()
*/
function __construct()
{
//if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [START]\n")) && !!error_log(ob_get_clean())) true;
// PRINT ERROR_GET_LAST ON SHUTDOWN
/*
register_shutdown_function(
create_function('',
'error_log("print error_get_last '.error_log("print error_get_last").'");$l=error_get_last();if(isset($l["type"])&&$l["type"]===E_ERROR)echo "fatal error";echo (isset($php_errormsg)?PHP_EOL.$php_errormsg:"").PHP_EOL.print_r($l,1).PHP_EOL;'
)
);
*/
$this->options=get_option($this->qn.'_options');
$this->debug=$this->options['plugin_debug_level'];
if($this->debug > 0)error_log(str_repeat("\n",5).str_repeat("=",235));
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',50);
$this->plugin = $this->get_plugin_data();
//$this->LoadOptions();
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',50);
//if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [END]\n")) && !!error_log(ob_get_clean())) true;
}
/** AA_DEBUG::__destruct()
function __destruct()
{
if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [START]\n")) && !!error_log(ob_get_clean())) true;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5);
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5);
if(ob_start() && (print("\n+-- ".__LINE__." ------------------------------[ ".__CLASS__.'->'.__FUNCTION__."() ".__METHOD__." ] [END]\n")) && !!error_log(ob_get_clean())) true;
return true;
}
*/
/** AA_DEBUG::LoadOptions()
*/
function LoadOptions()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
$this->options=get_option($this->qn.'_options');
$this->plugin = $this->get_plugin_data();
$this->debug=absint($this->options['plugin_debug_level']);
$D = array();
$D[(1 << sizeof($D))]=array('get_debug_footerhelper', 'Footer Helper');
$D[(1 << sizeof($D))]=array('get_debug_templates', 'Templates');
$D[(1 << sizeof($D))]=array('get_debug_options', 'WP Options');
$D[(1 << sizeof($D))]=array('get_debug_aa_plugin', 'Debug Plugin');
$D[(1 << sizeof($D))]=array('get_debug_request', 'Request');
$D[(1 << sizeof($D))]=array('get_debug_wordpress', 'WordPress Globals');
$D[(1 << sizeof($D))]=array('get_debug_globalprint', 'Global Print');
$D[(1 << sizeof($D))]=array('get_debug_rewrites', 'Rewrites');
$D[(1 << sizeof($D))]=array('get_debug_included', 'Included Files');
$D[(1 << sizeof($D))]=array('get_debug_extensions', 'Extensions');
$D[(1 << sizeof($D))]=array('get_debug_classes', 'Classes');
$D[(1 << sizeof($D))]=array('get_debug_functions', 'Functions');
$D[(1 << sizeof($D))]=array('get_debug_defined', 'Constants');
$D[(1 << sizeof($D))]=array('get_debug_posix', 'Posix Info');
$D[(1 << sizeof($D))]=array('get_debug_inis', 'PHP ini settings');
//$D[(1 << sizeof($D))]=array('get_debug_phpinfo', 'PHPINFO');
$D[(1 << sizeof($D))]=array('get_debug_permissions', 'User/File/Process permissions');
$D[(1 << sizeof($D))]=array('get_debug_interfaces', 'Interfaces');
$D[(1 << sizeof($D))]=array('get_debug_sockets', 'Sockets');
$D[(1 << sizeof($D))]=array('get_debug_queries', 'DataBase Queries');
$D[(1 << sizeof($D))]=array('get_debug_crons', 'WordPress Crons');
$this->debug_mods=$D;
unset($D);
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::SaveOptions()
*/
function SaveOptions()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if( function_exists('current_user_can') && !current_user_can('administrator') ) wp_die(__FUNCTION__.':'.__LINE__);
update_option($this->qn.'_options', $this->options);
update_option($this->qn.'_plugin', $this->plugin);
$this->LoadOptions();
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::DefaultOptions()
* @version 1.2
*/
function DefaultOptions($save=false)
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
// get all the plugin array data
$this->plugin = $this->get_plugin_data(true);
// save the $this->plugin to $this->qn_plugin
$this->SaveOptions();
// default array of options
$ret=array(
'page'=> 'home',
'logfile' => $this->get_error_log(),
'dirtoexplore' => __DIR__,
'log_errors' => '1',
'debug_live' => '0',
'admin_footer' => '1',
'wp_footer' => '1',
'admin_bar' => '1',
'error_reporting' => 4983,
'plugin_debug_level' => 0,
'display_height' => 500,
'debug_mods_v' => 524294,
'debug_mods' => 531871
);
// if $save is true
if($save===true) {
//save $ret to $this->options
$this->options=$ret;
// save both $this->options and $this->plugin
$this->SaveOptions();
// reset $ret to equal true for return;
$ret=true;
}
// Save all these variables to database
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
return $ret;
}
/** AA_DEBUG::Activate()
*/
function Activate()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
$old_options=$old_plugin=$default_options=false;
// load the default options without saving ::options
$new_options=$this->DefaultOptions(false);
// get old options
$old_options=get_option($this->qn.'_options');
// if old_options exist, merge the old settings into the new
if ($old_options !==false && is_array($old_options) && array_key_exists('plugin_debug_level', $old_options) && !array_key_exists('admin_bar_fix', $old_options) ) {
sqpt_error_log(print_r(array_diff($old_options, $new_options),1));
$this->options = wp_parse_args($old_options, $new_options);
}
// delete the existing options
delete_option($this->qn.'_options');
delete_option($this->qn.'_plugin');
// add the new options
//add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
add_option($this->qn.'_options', $this->options, '', 'yes');
add_option($this->qn.'_plugin', $this->plugin, '', 'yes');
$this->SaveOptions();
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::DeActivate()
*/
function DeActivate()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if( function_exists('current_user_can') && !current_user_can('administrator') ) wp_die(__FUNCTION__.':'.__LINE__);
delete_option($this->qn.'_plugin');
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::Uninstall()
*/
function Uninstall()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
//if( function_exists('current_user_can') && !current_user_can('administrator') ) wp_die(__FUNCTION__.':'.__LINE__);
delete_option($this->qn.'_options');
delete_option($this->qn.'_plugin');
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::Init()
*/
function Init()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if ( !$user = wp_get_current_user() ) return sqpt_error_log(__FUNCTION__.':'.__LINE__.' user not = wp_get_current_user');
// Load options
$this->LoadOptions();
add_action( 'admin_bar_menu', array(&$this, 'AdminBar'), 9983 );
// add admin-specific stuff
if(is_admin()):
add_action("admin_head-{$this->plugin['hook']}", array(&$this, 'AddHelp') );
add_filter("plugin_action_links_{$this->plugin['pb']}", create_function('$l', 'return array_merge(array("plugin['action']).'\">Settings"), $l);'));
add_action("load-{$this->plugin['hook']}", array(&$this, 'Load'));
add_action('admin_menu', create_function('','$AA_DEBUG=&_aa_debug_object(); $p=$AA_DEBUG->plugin; add_options_page( $p["plugin-name"], $p["short-name"], $p["role"], $p["page"], array(&$AA_DEBUG,"AdminPage") );'));
register_uninstall_hook(__FILE__, array(&$this,'Uninstall'));
register_activation_hook(__FILE__, array(&$this,'Activate'));
register_deactivation_hook(__FILE__, array(&$this,'DeActivate'));
endif;
// add old inis to class var and create shutdown function to reset
foreach($this->ini_overwrites as $k=>$v)$this->old_inis[$k]=@ini_get($k);
$this->old_inis['error_reporting']=error_reporting();
register_shutdown_function(create_function('','$oe='.$this->old_inis['error_reporting'].';$ne='.error_reporting($this->options['error_reporting']).';error_reporting($oe);'));
foreach ($this->pages as $id => $idv) {
$this->pages[$id]['nonce']=wp_nonce_url(admin_url("{$this->plugin['action']}&{$this->plugin['op']}_page={$id}"), "{$this->plugin['op']}_page_{$id}");
}
foreach ($this->actions as $id=>$idv) {
$this->actions[$id]['nonce']=wp_nonce_url(admin_url("{$this->plugin['action']}&{$this->plugin['op']}_action={$id}"), "{$this->plugin['op']}_action_{$id}");
}
/*
foreach ($this->debug_mods as $id => $info) {
$this->actions[]=array('title'=>'Enable '.$info[1], 'nonce'=>wp_nonce_url(admin_url("{$this->plugin['action']}&{$this->plugin['op']}_action={$id}"), "{$this->plugin['op']}_action_{$id}"));
}
*/
// if output in the footer is enabled
if($this->options['wp_footer']=='1' || $this->options['admin_footer']=='1') {
// enqueue styles
wp_enqueue_style($this->plugin['pagenice'], plugins_url('/f/admin.css',__FILE__), false, $this->plugin['version'], "all");
wp_enqueue_style($this->plugin['pagenice'].'1', 'http'. (is_ssl() ? 's' : '' ).'://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css', false, $this->plugin['version'], "all");
// enqueue script
wp_enqueue_script($this->plugin['pagenice'], plugins_url('/f/admin.js',__FILE__), array('jquery','jquery-ui-core','jquery-ui-resizable'), $this->plugin['version']);
// add to admin/wp footer
add_action( "admin_footer", array(&$this,'footer_output'));
add_action( "wp_footer", array(&$this,'footer_output'));
}
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::AddHelp($text, $screen)
*/
function AddHelp()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',20);
if(!function_exists('get_current_screen')) aadv_DEFINE_function('get_current_screen');
$current_screen=get_current_screen();
add_contextual_help( $current_screen,
'Fixing Status Headers'
.'For super-advanced users, or those with access and knowledge of Apache .htaccess/httpd.conf files'
.' you should check that your error pages are correctly returning a 404 Not Found'
.' HTTP Header and not a 200 OK Header which appears to be the default for many WP installs, this plugin attempts to fix this using PHP, but the best way I have found'
.' is to add the following to your .htaccess file. '
. 'ErrorDocument 404 /index.php?error=404'."\n".'Redirect 404 /index.php?error=404 '
.'Comments/QuestionsPlease visit AskApache.com or send me an email at webmaster@askapache.com '
);
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',20);
}
/** AA_DEBUG::AdminBar()
*/
function AdminBar($wp_admin_bar)
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if(!is_object($wp_admin_bar))return sqpt_error_log(__FUNCTION__.':'.__LINE__.' wp_admin_bar is not an object');
//if($this->options['wp_footer']=='1' && $this->options['admin_bar']=='1' ) {
//$pref = get_user_option( "show_admin_bar_front", $user->ID );
//update_user_option($user->ID, "show_admin_bar_front", '');
//}
//isset( $_POST['admin_bar_front'] ) ? 'true' : 'false'
//
$wp_admin_bar->add_menu(array(
'id' => $this->plugin['op'].'menu',
'title' => $this->plugin["short-name"],
'href' => add_query_arg( "{$this->plugin['op']}_page", 'home', admin_url($this->plugin["action"]) )
) );
foreach ($this->pages as $id => $idv) {
$wp_admin_bar->add_menu(array(
'parent'=> $this->plugin['op'].'menu',
'id' => $this->plugin['op'].$id,
'title' => $idv['title'],
'href' => $idv['nonce']
) );
}
foreach ($this->actions as $id => $idv) {
$wp_admin_bar->add_menu(array(
'parent'=> $this->plugin['op'].'menu',
'id' => $this->plugin['op'].$id,
'title' => $idv['title'],
'href' => $idv['nonce']
) );
}
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::Load()
*/
function Load()
{
global $show_admin_bar;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if (isset($_GET["{$this->plugin['op']}_page"])) $this->options['page']='home';
// Handle page
foreach (array_keys($this->pages) as $w) {
if (isset($_GET["{$this->plugin['op']}_page"]) && $_GET["{$this->plugin['op']}_page"] == $w) {
check_admin_referer("{$this->plugin['op']}_page_" . $w);
$this->options['page'] = $w;
break;
}
}
// Handle actions
foreach (array_keys($this->actions) as $w) {
if (isset($_GET["{$this->plugin['op']}_action"]) && $_GET["{$this->plugin['op']}_action"] == $w) {
check_admin_referer("{$this->plugin['op']}_action_" . $w);
if($w=='disable') {
$this->options["admin_footer"]=$this->options["wp_footer"]=$this->options["log_errors"]='0';
}
elseif($w=='enable') $this->options["admin_footer"]=$this->options["wp_footer"]='1';
elseif($w=='adminbaroff') {
//show_admin_bar(false);
//$this->options["admin_bar_fix"]='1';
$this->options["admin_bar"]='0';
}
wp_redirect($_SERVER['HTTP_REFERER']);
break;
}
}
// parse and handle post requests to plugin
if('POST' === $_SERVER['REQUEST_METHOD']) $this->HandlePost();
$this->SaveOptions();
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::HandlePost()
*/
function HandlePost()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
if ( !current_user_can('administrator') ) wp_die( 'ERROR: User does not have permission to manage options. '.__FUNCTION__.':'.__LINE__ );
$op = $this->plugin['op'];
// verify nonce, if not verified, then DIE
if(isset($_POST["_{$this->plugin['nonce']}"])) wp_verify_nonce($_POST["_{$this->plugin['nonce']}"], $this->plugin['nonce']) || wp_die('ERROR: Incorrect Form Submission, please try again.');
elseif(isset($_POST["_{$this->plugin['nonce']}_reset"])) wp_verify_nonce($_POST["_{$this->plugin['nonce']}_reset"], $_POST["_{$this->plugin['nonce']}_reset"]) || wp_die('ERROR: Incorrect Form Submission, please try again.');
// resets options to default values
if(isset($_POST["{$op}_action_reset"])) return $this->DefaultOptions(true);
if (isset($_POST["{$op}_save_debug_options"]))
{
//if ( !wp_verify_nonce($_POST['_wpnonce'], 'aadebug_settings_form') ) wp_die( 'ERROR: Incorrect Form Submission, please try again.' );
foreach(array('log_errors','debug_live','admin_footer','wp_footer', 'admin_bar') as $k) $this->options["{$k}"] = (isset($_POST["{$op}_{$k}"]) ? '1' : '0');
if( isset($_POST["{$op}_log_errors"]) || empty($this->options['logfile']) ) $this->options['logfile']=$this->get_error_log();
if (isset($_POST["{$op}_logfile"]) && !empty($_POST["{$op}_logfile"])) $this->options['logfile'] = trim($_POST["{$op}_logfile"]);
if (isset($_POST["{$op}_dirtoexplore"]) && !empty($_POST["{$op}_dirtoexplore"])) $this->options['dirtoexplore'] = trim($_POST["{$op}_dirtoexplore"]);
if (isset($_POST["{$op}_error_reporting"])){
$this->options['error_reporting'] = absint($_POST["{$op}_error_reporting"]);
if(strpos($_POST["{$op}_error_reporting"],'E')!==FALSE) $this->options['error_reporting']=$this->get_error_levels(trim($_POST["{$op}_error_reporting"],'|'),'string2error');
elseif(strpos($_POST["{$op}_error_reporting"],'|')!==FALSE) $this->options['error_reporting']=$this->get_error_levels($this->get_error_levels(trim($_POST["{$op}_error_reporting"],'|'),'error2string'),'string2error');
}
if (isset($_POST["{$op}_plugin_debug_level"])) {
$this->debug = $this->options['plugin_debug_level'] = absint($_POST["{$op}_plugin_debug_level"]);
}
if (isset($_POST["{$op}_display_height"])) {
$this->options['display_height'] = absint($_POST["{$op}_display_height"]);
}
if (isset($_POST["{$op}_error_reporting"]) && ($this->options['error_reporting'] = 0)==0) {
foreach( array_map( 'intval', (array) $_POST["{$op}_error_reporting"] ) as $bit) $this->options['error_reporting'] |= $bit;
}
// checked('1', $this->options[$id],false)
if (isset($_POST["{$op}_debug_mods"]) && ($this->options['debug_mods'] = 0)==0) {
foreach(array_map( 'intval', (array) $_POST["{$op}_debug_mods"] ) as $bit) $this->options['debug_mods'] |= $bit;
}
if (isset($_POST["{$op}_debug_mods_v"]) && ($this->options['debug_mods_v'] = 0)==0) {
foreach(array_map( 'intval', (array) $_POST["{$op}_debug_mods_v"] ) as $bit) $this->options['debug_mods_v'] |= $bit;
} else $this->options['debug_mods_v'] = 0;
}
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',10);
}
/** AA_DEBUG::AdminPage()
* @version 1.2
*/
function AdminPage()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__,'',5);
if(!current_user_can('administrator') ) wp_die( 'ERROR: User does not have permission to manage options. '.__FUNCTION__.':'.__LINE__ );
global $screen,$current_screen, $wp_meta_boxes, $_wp_contextual_help, $title;
echo ''.($this->_cf('screen_icon') ? screen_icon() : '').' ' . $this->plugin['plugin-name'].'';
echo ' ' . $this->pages[$this->options['page']]['title'] . '';
$this->display_navigation_menu();
printf( " UMASK: %04o | DIR: %04o | FILE: %04o ", umask(), (0755 & ~ umask()), (0644 & ~ umask()).' ');
printf( " FS_CHMOD_DIR: %d | FS_CHMOD_FILE: %d ", FS_CHMOD_DIR, FS_CHMOD_FILE);
switch($this->options['page'])
{
case 'phpinfo':
$message = "Your new WordPress site has been successfully set up at:
%1\$s
You can log in to the administrator account with the following information:
Username: %2\$s
Password: %3\$s
We hope you enjoy your new site. Thanks!
--The WordPress Team
http://wordpress.org/
";
echo ' ';
echo 'plugins_url(): '.plugins_url()."\n";
echo "pplugins_url('player_mp3.swf',__FILE__): ".plugins_url('player_mp3.swf',__FILE__)."\n";
echo '';
echo ' ';
echo $this->get_debug_phpinfo(0);
echo ' ';
break;
case 'server-info':
echo ' ';
// SOCKET TEST
$fp = null;
$errstr = '';
$errno = 0;
$LF = chr(13).chr(10);
$LF = "\r\n";
$url=plugins_url('/f/f/server-info',__FILE__);
$url=str_replace('https://','http://',$url);
$url=str_replace(WP_PLUGIN_URL,'',$url);
$url=PLUGINS_COOKIE_PATH.$url;
// resource fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") ]]]] )
if (false === ( $fp = fsockopen($_SERVER['HTTP_HOST'], 80, $errno, $errstr,5) ) || !is_resource($fp) ) echo $this->socket_error($fp, (int)$errno, $errstr);
else {
$response='';
$request='GET '.$url.' HTTP/1.0'
."\r\n".'Host: '.$_SERVER['HTTP_HOST']."\r\n".'User-Agent: Mozilla/5.0 (AskApache/; +http://www.askapache.com/)'."\r\n".'Accept-Encoding: none'."\r\n".'Referer: http://www.askapache.com/'."\r\n".'Cookie: '.$_SERVER['HTTP_COOKIE']."\r\n".'Connection: close'."\r\n\r\n";
fwrite($fp, $request);
while (!feof($fp)) $response .= fread($fp, 1);
$response=explode("\r\n\r\n",$response,2);
$response=$response[1];
echo "\n===================================================================\n".$response."\n===================================================================\n";
if (is_resource($fp)) @fclose($fp);
}
echo ' Server-Info';
echo ' ';
break;
case 'server-status':
echo ' ';
$fp = null;
$errstr = '';
$errno = 0;
$LF = chr(13).chr(10);
$LF = "\r\n";
$url=plugins_url('/f/f/server-status',__FILE__);
$url=str_replace('https://','http://',$url);
$url=str_replace(WP_PLUGIN_URL,'',$url);
$url=PLUGINS_COOKIE_PATH.$url;
// resource fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") ]]]] )
if (false === ( $fp = fsockopen($_SERVER['HTTP_HOST'], 80, $errno, $errstr,5) ) || !is_resource($fp) ) echo $this->socket_error($fp, (int)$errno, $errstr);
else {
$response='';
$request='GET '.$url.' HTTP/1.0'
."\r\n".'Host: '.$_SERVER['HTTP_HOST']."\r\n".'User-Agent: Mozilla/5.0 (AskApache/; +http://www.askapache.com/)'."\r\n".'Accept-Encoding: none'."\r\n".'Referer: http://www.askapache.com/'."\r\n".'Cookie: '.$_SERVER['HTTP_COOKIE']."\r\n".'Connection: close'."\r\n\r\n";
fwrite($fp, $request);
while (!feof($fp)) $response .= fread($fp, 1);
$response=explode("\r\n\r\n",$response,2);
$response=$response[1];
echo "\n===================================================================\n".$response."\n===================================================================\n";
if (is_resource($fp)) @fclose($fp);
}
echo ' Server-Status ';
echo ' ';
break;
case 'server-env':
echo ' ';
$url=plugins_url('/f/f/server-env.cgi',__FILE__);
$url=str_replace('https://','http://',$url);
$url=str_replace(WP_PLUGIN_URL,'',$url);
$url=PLUGINS_COOKIE_PATH.$url;
// resource fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") ]]]] )
if (false === ( $fp = fsockopen($_SERVER['HTTP_HOST'], 80, $errno, $errstr,5) ) || !is_resource($fp) ) echo $this->socket_error($fp, (int)$errno, $errstr);
else {
$response='';
$request='GET '.$url.' HTTP/1.0'
."\r\n".'Host: '.$_SERVER['HTTP_HOST']."\r\n".'User-Agent: Mozilla/5.0 (AskApache/; +http://www.askapache.com/)'."\r\n".'Accept-Encoding: none'."\r\n".'Referer: http://www.askapache.com/'."\r\n".'Cookie: '.$_SERVER['HTTP_COOKIE']."\r\n".'Connection: close'."\r\n\r\n";
fwrite($fp, $request);
while (!feof($fp)) $response .= fread($fp, 1);
$response=explode("\r\n\r\n",$response,2);
$response=$response[1];
echo "\n \n".$response."\n \n";
if (is_resource($fp)) @fclose($fp);
}
echo ' ';
break;
case 'files':
//echo ' AskApache Debugging Options';
//printf( " UMASK: %04o | DIR: %04o | FILE: %04o ", umask(), (0755 & ~ umask()), (0644 & ~ umask()).' ');
//echo '
|