.
*/
// exit if add_action or plugins_url functions do not exist
!defined('ABSPATH') || !function_exists('add_action') || !function_exists('plugins_url') || !function_exists('add_management_page') || !function_exists('wp_die') && exit;
if(!class_exists('AA_DEBUG')):
/********************************************************************************************************************************************************************************************************
PHP COMPAT FUNCTIONS
********************************************************************************************************************************************************************************************************/
if (!function_exists('is_a')) : function is_a($o, $c) { return (!is_object($o)) ? false : ((strtolower(get_class($o)) == strtolower($c)) ? true : is_subclass_of($o, $c)); } endif;
if (!function_exists('stripos')) : function stripos($haystack, $needle, $offset = 0) { return strpos(strtolower($haystack), strtolower($needle), $offset); } endif;
/********************************************************************************************************************************************************************************************************
WORDPRESS COMPAT FUNCTIONS
********************************************************************************************************************************************************************************************************/
if (!function_exists('wp_die')) : function wp_die ($message = 'wp_die') { die($message); } endif;
if (!function_exists('absint')): function absint( $maybeint ) { return abs( intval( $maybeint ) ); } endif;
/********************************************************************************************************************************************************************************************************
PHP DEFINES
********************************************************************************************************************************************************************************************************/
/*
__LINE__ The current line number of the file.
__FILE__ The full path and filename of the file. If used inside an include, the name of the included file is returned
__DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. Does not have a trailing slash unless it is the root directory.
__FUNCTION__ The function name. As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__CLASS__ The class name. As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__METHOD__ The class method name. The method name is returned as it was declared (case-sensitive).
__NAMESPACE__ The name of the current namespace (case-sensitive). This constant is defined in compile-time
*/
// Version constants only available as of 5.2.8
if (!defined("PHP_VERSION_ID"))
{
list($major, $minor, $bug) = explode(".", phpversion(), 3);
$bug = ((int)$bug < 10) ? "0".(int)$bug : (int)$bug; // Many distros make up their own versions
define("PHP_VERSION_ID", "{$major}0{$minor}$bug");
!defined("PHP_MAJOR_VERSION") && define("PHP_MAJOR_VERSION", $major);
}
!defined('__DIR__') && define('__DIR__', realpath(dirname(__FILE__)));
!defined('FILE_BINARY') && define('FILE_BINARY', 0);
/********************************************************************************************************************************************************************************************************
WORDPRESS DEFINES
********************************************************************************************************************************************************************************************************/
!defined('ABSPATH') || !function_exists('add_management_page') || !function_exists('wp_die') && die('death by askapache firing squad');
!defined('WP_CONTENT_DIR') && define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
!defined('WP_PLUGIN_DIR') && define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins'); // full path, no trailing slash
!defined('WP_CONTENT_URL') && define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
!defined('WP_PLUGIN_URL') && define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins'); // full url, no trailing slash
!defined('FS_CHMOD_DIR') && define('FS_CHMOD_DIR', (S_IRWUGO & ~ umask()));
!defined('FS_CHMOD_FILE') && define('FS_CHMOD_FILE', (S_IRWXUGO & ~ umask()));
/* This is a cool workaround to defining functions already defined but throwing errors */
function aadv_DEFINE_function($f='')
{
switch($f)
{
case 'get_include_path': function get_include_path(){ return ini_get('include_path'); }; break;
case 'set_include_path': function set_include_path($new_include_path){ return ini_set('include_path', $new_include_path); }; break;
case 'restore_include_path': function restore_include_path(){ return ini_restore('include_path'); }; break;
case 'inet_ntop': function inet_ntop($in_addr)
{
switch (strlen($in_addr)) {
case 4:
list(,$r) = unpack('N', $in_addr);
return long2ip($r);
case 16:
$r = substr(chunk_split(bin2hex($in_addr), 4, ':'), 0, -1);
$r = preg_replace(
array('/(?::?\b0+\b:?){2,}/', '/\b0+([^0])/e'),
array('::', '(int)"$1"?"$1":"0$1"'),
$r);
return $r;
}
return false;
}
break;
case 'inet_pton': function inet_pton($address)
{
$r = ip2long($address);
if ($r !== false && $r != -1) return pack('N', $r);
$delim_count = substr_count($address, ':');
if ($delim_count < 1 || $delim_count > 7) return false;
$r = explode(':', $address);
$rcount = count($r);
if (($doub = array_search('', $r, 1)) !== false) {
$length = (!$doub || $doub == $rcount - 1 ? 2 : 1);
array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0));
}
$r = array_map('hexdec', $r);
array_unshift($r, 'n*');
$r = call_user_func_array('pack', $r);
return $r;
}
break;
case 'php_ini_loaded_file': function php_ini_loaded_file()
{
// Get the location of php.ini
ob_start();
phpinfo(INFO_GENERAL);
$info = ob_get_contents();
ob_clean();
$info = explode("\n", $info);
$line = array_values(preg_grep('#php\.ini#', $info));
// Plain vs HTML output
if (substr($line[0], 0, 4) === '
') {
list (, $value) = explode('', $line[0], 2);
$inifile = trim(strip_tags($value));
} else {
list (, $value) = explode(' => ', $line[0], 2);
$inifile = trim($value);
}
// Check the file actually exists
if (!file_exists($inifile)) {
user_error('ini_get_all() Unable to find php.ini', E_USER_WARNING);
return false;
}
// Check the file is readable
if (!is_readable($inifile)) {
user_error('ini_get_all() Unable to open php.ini', E_USER_WARNING);
return false;
}
// Parse the ini
if ($extension !== null)
{
$ini_all = parse_ini_file($inifile, true);
// Lowercase extension keys
foreach ($ini_all as $key => $value) $ini_arr[strtolower($key)] = $value;
// Check the extension exists
if (isset($ini_arr[$extension])) $ini = $ini_arr[$extension];
else {
user_error("ini_get_all() Unable to find extension '$extension'",E_USER_WARNING);
return false;
}
} else {
$ini = parse_ini_file($inifile);
}
// Order
$ini_lc = array_map('strtolower', array_keys($ini));
array_multisort($ini_lc, SORT_ASC, SORT_STRING, $ini);
// Format
$info = array();
foreach ($ini as $key => $value) $info[$key] = array( 'global_value' => $value, 'local_value' => ini_get($key), 'access' => -1);
return $info;
}
break;
case 'is_a': function is_a($object, $class)
{
if (!is_object($object)) return false;
if (strtolower(get_class($object)) == strtolower($class)) return true;
else return is_subclass_of($object, $class);
}
break;
case 'is_callable': function is_callable($var, $syntax_only = false)
{
if (!is_string($var) && !(is_array($var) && count($var) == 2 && isset($var[0], $var[1]) && is_string($var[1]) && (is_string($var[0]) || is_object($var[0])))) return false;
if ($syntax_only) return true;
if (is_string($var)) return function_exists($var);
else if (is_array($var))
{
if (is_string($var[0])) {
$methods = get_class_methods($var[0]);
$method = strtolower($var[1]);
if ($methods) {
foreach ($methods as $classMethod) {
if (strtolower($classMethod) == $method) return true;
}
}
} else return method_exists($var[0], $var[1]);
}
return false;
}
break;
case 'mhash':
if (!defined('MHASH_CRC32')) {
define('MHASH_CRC32', 0);
}
if (!defined('MHASH_MD5')) {
define('MHASH_MD5', 1);
}
if (!defined('MHASH_SHA1')) {
define('MHASH_SHA1', 2);
}
if (!defined('MHASH_HAVAL256')) {
define('MHASH_HAVAL256', 3);
}
if (!defined('MHASH_RIPEMD160')) {
define('MHASH_RIPEMD160', 5);
}
if (!defined('MHASH_TIGER')) {
define('MHASH_TIGER', 7);
}
if (!defined('MHASH_GOST')) {
define('MHASH_GOST', 8);
}
if (!defined('MHASH_CRC32B')) {
define('MHASH_CRC32B', 9);
}
if (!defined('MHASH_HAVAL192')) {
define('MHASH_HAVAL192', 11);
}
if (!defined('MHASH_HAVAL160')) {
define('MHASH_HAVAL160', 12);
}
if (!defined('MHASH_HAVAL128')) {
define('MHASH_HAVAL128', 13);
}
if (!defined('MHASH_TIGER128')) {
define('MHASH_TIGER128', 14);
}
if (!defined('MHASH_TIGER160')) {
define('MHASH_TIGER160', 15);
}
if (!defined('MHASH_MD4')) {
define('MHASH_MD4', 16);
}
if (!defined('MHASH_SHA256')) {
define('MHASH_SHA256', 17);
}
if (!defined('MHASH_ADLER32')) {
define('MHASH_ADLER32', 18);
}
function mhash($hashtype, $data, $key = '')
{
switch ($hashtype) {
case MHASH_MD5:
$key = str_pad((strlen($key) > 64 ? pack("H*", md5($key)) : $key), 64, chr(0x00));
$k_opad = $key ^ (str_pad('', 64, chr(0x5c)));
$k_ipad = $key ^ (str_pad('', 64, chr(0x36)));
return pack("H*", md5($k_opad . pack("H*", md5($k_ipad . $data))));
default:
return false;
break;
}
}break;
case 'get_current_screen': function get_current_screen() { global $current_screen; return (( !isset($current_screen) ) ? null : $current_screen); }; break;
case 'sys_get_temp_dir': function sys_get_temp_dir()
{
if (!empty($_ENV['TMP'])) return realpath($_ENV['TMP']);
if (!empty($_ENV['TMPDIR'])) return realpath( $_ENV['TMPDIR']);
if (!empty($_ENV['TEMP'])) return realpath( $_ENV['TEMP']);
$tempfile = tempnam(uniqid(rand(),TRUE),'');
if (file_exists($tempfile)) {
unlink($tempfile);
return realpath(dirname($tempfile));
}
}
break;
case 'time_sleep_until': function time_sleep_until($timestamp)
{
list($usec, $sec) = explode(' ', microtime());
$now = $sec + $usec;
if ($timestamp <= $now) {
user_error('Specified timestamp is in the past', E_USER_WARNING);
return false;
}
$diff = $timestamp - $now;
usleep($diff * 1000000);
return true;
}
break;
case 'is_scalar': function is_scalar($val){ return (is_bool($val) || is_int($val) || is_float($val) || is_string($val)); }; break;
case 'md5_file': function md5_file($filename, $raw_output = false)
{
// Sanity check
if (!is_scalar($filename)) {
user_error('md5_file() expects parameter 1 to be string, ' .
gettype($filename) . ' given', E_USER_WARNING);
return;
}
if (!is_scalar($raw_output)) {
user_error('md5_file() expects parameter 2 to be bool, ' .
gettype($raw_output) . ' given', E_USER_WARNING);
return;
}
if (!file_exists($filename)) {
user_error('md5_file() Unable to open file', E_USER_WARNING);
return false;
}
// Read the file
if (false === $fh = fopen($filename, 'rb')) {
user_error('md5_file() failed to open stream: No such file or directory',
E_USER_WARNING);
return false;
}
clearstatcache();
if ($fsize = @filesize($filename)) {
$data = fread($fh, $fsize);
} else {
$data = '';
while (!feof($fh)) {
$data .= fread($fh, 8192);
}
}
fclose($fh);
// Return
$data = md5($data);
if ($raw_output === true) {
$data = pack('H*', $data);
}
return $data;
}
break;
case 'microtime': function microtime($get_as_float = false)
{
if (!function_exists('gettimeofday')) {
$time = time();
return $get_as_float ? ($time * 1000000.0) : '0.00000000 ' . $time;
}
$gtod = gettimeofday();
$usec = $gtod['usec'] / 1000000.0;
return $get_as_float
? (float) ($gtod['sec'] + $usec)
: (sprintf('%.8f ', $usec) . $gtod['sec']);
}
break;
case 'mkdir': function mkdir($pathname, $mode = 0777, $recursive = true, $context = null)
{
if (version_compare(PHP_VERSION, '5.0.0', 'gte')) {
// revert to native function
return (func_num_args() > 3)
? mkdir($pathname, $mode, $recursive, $context)
: mkdir($pathname, $mode, $recursive);
}
if (!strlen($pathname)) {
user_error('No such file or directory', E_USER_WARNING);
return false;
}
if (is_dir($pathname)) {
if (func_num_args() == 5) {
// recursive call
return true;
}
user_error('File exists', E_USER_WARNING);
return false;
}
$parent_is_dir = php_compat_mkdir(dirname($pathname), $mode, $recursive, null, 0);
if ($parent_is_dir) {
return mkdir($pathname, $mode);
}
user_error('No such file or directory', E_USER_WARNING);
return false;
}
break;
case 'ob_clean': function ob_clean()
{
if (@ob_end_clean()) {
return ob_start();
}
user_error("ob_clean() failed to delete buffer. No buffer to delete.", E_USER_NOTICE);
return false;
}
break;
case 'ob_flush': function ob_flush()
{
if (@ob_end_flush()) {
return ob_start();
}
user_error("ob_flush() Failed to flush buffer. No buffer to flush.", E_USER_NOTICE);
return false;
}
break;
case 'ob_get_clean': function ob_get_clean()
{
$contents = ob_get_contents();
if ($contents !== false) {
ob_end_clean();
}
return $contents;
}
break;
case 'ob_get_flush': function ob_get_flush()
{
$contents = ob_get_contents();
if ($contents !== false) {
ob_end_flush();
}
return $contents;
}
break;
case 'pathinfo': if (!defined('PATHINFO_FILENAME')) {
define('PATHINFO_FILENAME', 8);
}function pathinfo($path = false, $options = false)
{
// Sanity check
if (!is_scalar($path)) {
user_error('pathinfo() expects parameter 1 to be string, '
. gettype($path) . ' given', E_USER_WARNING);
return;
}
if (version_compare(PHP_VERSION, '5.2.0', 'ge')) {
return pathinfo($path, $options);
}
if ($options & PATHINFO_FILENAME) {
//bug #15688
if (strpos($path, '.') !== false) {
$filename = substr($path, 0, strrpos($path, '.'));
}
if ($options === PATHINFO_FILENAME) {
return $filename;
}
$pathinfo = pathinfo($path, $options);
$pathinfo['filename'] = $filename;
return $pathinfo;
}
return pathinfo($path, $options);
}
break;
case 'scandir': function scandir($directory, $sorting_order = 0)
{
if (!is_string($directory)) {
user_error('scandir() expects parameter 1 to be string, ' .
gettype($directory) . ' given', E_USER_WARNING);
return;
}
if (!is_int($sorting_order) && !is_bool($sorting_order)) {
user_error('scandir() expects parameter 2 to be long, ' .
gettype($sorting_order) . ' given', E_USER_WARNING);
return;
}
if (!is_dir($directory) || (false === $fh = @opendir($directory))) {
user_error('scandir() failed to open dir: Invalid argument', E_USER_WARNING);
return false;
}
$files = array ();
while (false !== ($filename = readdir($fh))) {
$files[] = $filename;
}
closedir($fh);
if ($sorting_order == 1) {
rsort($files);
} else {
sort($files);
}
return $files;
}
break;
case 'var_export': function var_export($var, $return = false, $level = 0, $inObject = false)
{
// Init
$indent = ' ';
$doublearrow = ' => ';
$lineend = ",\n";
$stringdelim = '\'';
$newline = "\n";
$find = array(null, '\\', '\'');
$replace = array('NULL', '\\\\', '\\\'');
$out = '';
// Indent
$level++;
for ($i = 1, $previndent = ''; $i < $level; $i++) {
$previndent .= $indent;
}
$varType = gettype($var);
// Handle object indentation oddity
if ($inObject && $varType != 'object') {
$previndent = substr($previndent, 0, -1);
}
// Handle each type
switch ($varType) {
// Array
case 'array':
if ($inObject) {
$out .= $newline . $previndent;
}
$out .= 'array (' . $newline;
foreach ($var as $key => $value) {
// Key
if (is_string($key)) {
// Make key safe
$key = str_replace($find, $replace, $key);
$key = $stringdelim . $key . $stringdelim;
}
// Value
if (is_array($value)) {
$export = php_compat_var_export($value, true, $level);
$value = $newline . $previndent . $indent . $export;
} else {
$value = php_compat_var_export($value, true, $level);
}
// Piece line together
$out .= $previndent . $indent . $key . $doublearrow . $value . $lineend;
}
// End string
$out .= $previndent . ')';
break;
// String
case 'string':
// Make the string safe
for ($i = 0, $c = count($find); $i < $c; $i++) {
$var = str_replace($find[$i], $replace[$i], $var);
}
$out = $stringdelim . $var . $stringdelim;
break;
// Number
case 'integer':
case 'double':
$out = (string) $var;
break;
// Boolean
case 'boolean':
$out = $var ? 'true' : 'false';
break;
// NULLs
case 'NULL':
case 'resource':
$out = 'NULL';
break;
// Objects
case 'object':
// Start the object export
$out = $newline . $previndent;
$out .= get_class($var) . '::__set_state(array(' . $newline;
// Export the object vars
foreach(get_object_vars($var) as $key => $value) {
$out .= $previndent . $indent . ' ' . $stringdelim . $key . $stringdelim . $doublearrow;
$out .= php_compat_var_export($value, true, $level, true) . $lineend;
}
$out .= $previndent . '))';
break;
}
// Method of output
if ($return === true) {
return $out;
} else {
echo $out;
}
}
break;
case 'array_walk_recursive': function array_walk_recursive(&$input, $funcname)
{
if (!is_callable($funcname)) {
if (is_array($funcname)) {
$funcname = $funcname[0] . '::' . $funcname[1];
}
user_error('array_walk_recursive() Not a valid callback ' . $funcname,
E_USER_WARNING);
return;
}
if (!is_array($input)) {
user_error('array_walk_recursive() The argument should be an array',
E_USER_WARNING);
return;
}
$args = func_get_args();
foreach ($input as $key => $item) {
$callArgs = $args;
if (is_array($item)) {
$thisCall = 'array_walk_recursive';
$callArgs[1] = $funcname;
} else {
$thisCall = $funcname;
$callArgs[1] = $key;
}
$callArgs[0] = &$input[$key];
call_user_func_array($thisCall, $callArgs);
}
}
break;
case 'set_current_screen':
function set_current_screen( $id = '' )
{
global $current_screen, $hook_suffix, $typenow, $taxnow;
$action = '';
if ( empty($id) ) {
$current_screen = str_replace('.php', '', $hook_suffix);
if ( preg_match('/-add|-new$/', $current_screen) ) $action = 'add';
$current_screen = str_replace('-add', '', str_replace('-new', '', $current_screen));
$current_screen = array('id' => $current_screen, 'base' => $current_screen);
} else {
$id = sanitize_key($id);
if ( false !== strpos($id, '-') ) {
list( $id, $typenow ) = explode('-', $id, 2);
if ( taxonomy_exists( $typenow ) ) {$id = 'edit-tags';$taxnow = $typenow;$typenow = '';}
}
$current_screen = array('id' => $id, 'base' => $id);
}
$current_screen = (object) $current_screen;
$current_screen->action = $action;
if ( 'index' == $current_screen->base ) $current_screen->base = 'dashboard';
if ( 'index' == $current_screen->id ) $current_screen->id = 'dashboard';
if ( 'edit' == $current_screen->id ) {
if ( empty($typenow) )$typenow = 'post';
$current_screen->id .= '-' . $typenow;
$current_screen->post_type = $typenow;
} elseif ( 'post' == $current_screen->id ) {
if ( empty($typenow) ) $typenow = 'post';
$current_screen->id = $typenow;
$current_screen->post_type = $typenow;
} elseif ( 'edit-tags' == $current_screen->id ) {
if ( empty($taxnow) ) $taxnow = 'post_tag';
$current_screen->id = 'edit-' . $taxnow;
$current_screen->taxonomy = $taxnow;
}
$current_screen->is_network = is_network_admin();
$current_screen->is_user = is_user_admin();
if ( $current_screen->is_network ) {$current_screen->base .= '-network';$current_screen->id .= '-network';}
elseif ( $current_screen->is_user ) {$current_screen->base .= '-user';$current_screen->id .= '-user';}
$current_screen = apply_filters('current_screen', $current_screen);
}
break;
}
}
/**
* AA_DEBUG
*
* @package
* @author life
* @copyright Copyright (c) 2011
* @version $Id$
* @access public
*/
class AA_DEBUG
{
var $options = array(); // an array of options and values
var $plugin = array(); // array to hold plugin information
var $debug = 0;
var $op='adv7';
var $old_inis = array();
var $ini_overwrites=array(
//'output_handler' => '',
'open_basedir' => '',
//'session.auto_start' => '0',
'tidy.clean_output' => 'Off',
//'zlib.output_compression' => 'Off',
'xdebug.default_enable' => 'Off',
'mbstring.func_overload' => 'Off',
'error_prepend_string' => '',
'error_append_string' => '',
'auto_prepend_file' => '',
'auto_append_file' => '',
'disable_functions' => '',
'safe_mode' => 'Off',
'request_order' => 'GPCES',
'register_globals' => 'On',
'register_long_arrays' => 'On',
'register_argc_argv' => 'On',
'always_populate_raw_post_data' => 'On',
//'output_buffering' => 'Off',
'error_reporting' => 0,
'display_errors' => 'Off',
'display_startup_errors' => 'Off',
'log_errors' => 'On',
'html_errors' => 'Off',
'track_errors' => 'On',
'report_memleaks' => 'On',
//'report_zend_debug' => 'Off',
'magic_quotes_runtime' => 'Off',
'magic_quotes_gpc' => 'Off',
'ignore_repeated_errors' => 'On',
'ignore_repeated_source' => 'On',
//'precision'=>'14',
'log_errors_max_len'=>'1000240'
);
var $sections = array(
'config' => 'Main Config',
/*
'logging' => 'Log Settings',
'files' => 'File Browser',
'phpini' => 'php.ini Setup',
*/
'wpconfig' => 'wp-config.php Settings'
);
var $debug_mods = array(
0x0000001 => array('included', 'Files included by php'),
0x0000002 => array('functions', 'Function Information'),
0x0000004 => array('classes', 'Information about Loaded Classes'),
0x0000008 => array('globals', 'Global Server/Request Information'),
0x0000010 => array('extensions', 'Extensions Loaded by PHP'),
0x0000020 => array('defined', 'Defined Constants and variables'),
0x0000040 => array('inis', 'Your PHP.ini settings'),
0x0000080 => array('phpinfo', 'Information from phpinfo'),
0x0000100 => array('permissions', 'Information about Owner/User/File permissions'),
0x0000200 => array('interfaces', 'Declared interfaces in the current script'),
0x0000400 => array('sockets', 'Socket and Stream Debugging'),
0x0001000 => array('rewrites', 'WordPress Rewrites'),
0x0002000 => array('queries', 'View DataBase Queries'),
0x0004000 => array('wordpress', 'Debug WordPress Globals'),
0x0008000 => array('globalprint', 'Show All GLOBALS')
);
/** AA_DEBUG::AA_DEBUG()
*/
function AA_DEBUG() { return $this->__construct(); }
/** AA_DEBUG::__construct()
*/
function __construct()
{
//error_log(str_repeat("\n",75)."\033[2;2H".str_repeat("=",235));
$this->l(str_repeat("\n",5).str_repeat("=",235),5);
$this->tt(__FILE__);
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
$this->LoadOptions();
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
}
/** AA_DEBUG::__destruct()
*/
function __destruct()
{
//$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
//$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
return true;
}
/** AA_DEBUG::LoadOptions()
*/
function LoadOptions()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
$this->plugin = $this->get_plugin_data();
$this->options=get_option('askapache_debug_options');
$this->debug=$this->options['plugin_debug_level'];
foreach($this->ini_overwrites as $k=>$v)$this->old_inis[$k]=@ini_get($k);
$this->old_inis['error_reporting']=error_reporting();
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
}
/** AA_DEBUG::SaveOptions()
*/
function SaveOptions()
{
if( function_exists('current_user_can') && !current_user_can('manage_options') ) wp_die(__FUNCTION__.':'.__LINE__);
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
update_option('askapache_debug_options', $this->options);
update_option('askapache_debug_plugin', $this->plugin);
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
}
/** AA_DEBUG::DefaultOptions()
*/
function DefaultOptions()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
delete_option("askapache_debug_options");
delete_option("askapache_debug_plugin");
// get all the plugin array data
$this->plugin = $this->get_plugin_data();
$this->options=array(
'logfile' => $this->get_error_log(),
'dirtoexplore' => dirname($this->get_error_log()),
'log_errors' => '0',
'debug_live' => '0',
'admin_footer' => '1',
'wp_footer' => '0',
'error_reporting' => 4983,
'error_level' => 4983,
'plugin_debug_level' => 0,
'debug_mods_verbose' => 0,
'debug_mods' => 0
);
//add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )
add_option('askapache_debug_options', $this->options, '', 'yes');
add_option('askapache_debug_plugin', $this->plugin, '', 'yes');
// Save all these variables to database
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
$this->SaveOptions();
}
/** AA_DEBUG::Activate()
*/
function Activate()
{
global $wp_roles;
$wp_roles->add_cap("administrator", "askapache_debug_viewer");
$this->DefaultOptions();
}
/** AA_DEBUG::DeActivate()
*/
function DeActivate()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
global $wp_roles;
$wp_roles->remove_cap("administrator", "askapache_debug_viewer");
delete_option("askapache_debug_options");
delete_option("askapache_debug_plugin");
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
}
/** AA_DEBUG::Uninstall()
*/
function Uninstall()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
global $wp_roles;
$wp_roles->remove_cap("administrator", "askapache_debug_viewer");
delete_option("askapache_debug_options");
delete_option("askapache_debug_plugin");
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
}
/** AA_DEBUG::Init()
*/
function Init()
{
if ( !$user = wp_get_current_user() ) return;
//stripslashes($_GET['page'])
add_action("load-{$this->plugin['hook']}", array(&$this, 'Load'));
add_action("admin_print_styles-{$this->plugin['hook']}", create_function('', 'echo "";'));
add_action("admin_print_scripts-{$this->plugin['hook']}",create_function('','
wp_register_script("'.$this->plugin['pagenice'].'",
"'.plugins_url('/f/admin.js',__FILE__).'",
array("jquery","common","wp-lists","postbox","jquery-ui-core","jquery-ui-dialog","jquery-ui-tabs"),
"'.$this->plugin['version'].'",
true);
wp_enqueue_script("'.$this->plugin['pagenice'].'",
"'.plugins_url('/f/admin.js',__FILE__).'",
array("jquery","common","wp-lists","postbox","jquery-ui-core","jquery-ui-dialog","jquery-ui-tabs"),
"'.$this->plugin['version'].'",
true);
'
));
/*add_action("admin_print_scripts-{$this->plugin['hook']}", create_function('', 'echo "";'));*/
//add_action("admin_print_scripts",create_function('','wp_enqueue_script("jquery");'));
}
/** AA_DEBUG::Load()
*/
function Load()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
global $screen,$current_screen, $wp_meta_boxes, $_wp_contextual_help, $title;
set_screen_options();
if(!function_exists('get_current_screen')) aadv_DEFINE_function('get_current_screen');
if(!function_exists('set_current_screen')) aadv_DEFINE_function('set_current_screen');
if(function_exists('set_current_screen')) set_current_screen($current_screen->id);
// parse and handle post requests to plugin
if('POST' === $_SERVER['REQUEST_METHOD']) $this->HandlePost();
// add contextual help
$help = 'Fixing Status Headers';
$help .= 'For super-advanced users, or those with access and knowledge of Apache .htaccess/httpd.conf files';
$help .=' you should check that your error pages are correctly returning a 404 Not Found';
$help .=' HTTP Header and not a 200 OK Header which appears to be the default for many WP installs, this plugin attempts to fix this using PHP, but the best way I have found';
$help .=' is to add the following to your .htaccess file. ';
$help .= 'ErrorDocument 404 /index.php?error=404'."\n".'Redirect 404 /index.php?error=404 ';
$help .= 'Comments/QuestionsPlease visit AskApache.com or send me an email at webmaster@askapache.com ';
add_contextual_help($this->plugin['hook'], $help);
// enqueue css
wp_enqueue_style($this->plugin['pagenice'], plugins_url('/f/admin.css',__FILE__), array('dashboard','wp-admin'), $this->plugin['version'], 'all');
//wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false )
//wp_register_script($this->plugin['pagenice'], plugins_url('/f/admin.js',__FILE__), array("jquery","common","wp-lists","postbox","thickbox","jquery-ui-core","jquery-ui-dialog","jquery-ui-tabs"), $this->plugin['version'], true);
// enqueue js
//foreach(array('jquery-ui-core','jquery-ui-dialog','jquery-ui-tabs', 'thickbox') as $js) wp_enqueue_script("$js");
//wp_enqueue_script('jquery-ui-tabs');
//wp_register_script($this->plugin['pagenice'], plugins_url('/f/admin.js',__FILE__), false, false, false);
//wp_enqueue_script($this->plugin['pagenice'], plugins_url('/f/admin.js',__FILE__), false, false, false);
//wp_enqueue_script('jquery-cookie', plugins_url('f/jquery.cookie.js', __FILE__));
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
}
/** AA_DEBUG::HandlePost()
*/
function HandlePost()
{
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
if ( !current_user_can('manage_options') ) wp_die( 'ERROR: User does not have permission to manage options.' );
// if current user does not have administrator rights, then DIE
if(!current_user_can('administrator')) wp_die('ERROR: Not an Admin!');
// verify nonce, if not verified, then DIE
if(isset($_POST["_{$this->plugin['nonce']}"])) wp_verify_nonce($_POST["_{$this->plugin['nonce']}"], $this->plugin['nonce']) || wp_die('ERROR: Incorrect Form Submission, please try again.');
elseif(isset($_POST["_{$this->plugin['nonce']}_reset"])) wp_verify_nonce($_POST["_{$this->plugin['nonce']}_reset"], $_POST["_{$this->plugin['nonce']}_reset"]) || wp_die('ERROR: Incorrect Form Submission, please try again.');
// resets options to default values
if(isset($_POST["{$this->op}_action_reset"])) return $this->DefaultOptions();
if (isset($_POST["save_debug_options"]))
{
//if ( !wp_verify_nonce($_POST['_wpnonce'], 'aadebug_settings_form') ) wp_die( 'ERROR: Incorrect Form Submission, please try again.' );
foreach(array('log_errors','debug_live','admin_footer','wp_footer') as $k) $this->options["{$k}"] = (isset($_POST["{$this->op}_{$k}"]) ? '1' : '0');
if( isset($_POST["{$this->op}_log_errors"]) || empty($this->options['logfile']) ) $this->options['logfile']=$this->get_error_log();
if (isset($_POST["{$this->op}_logfile"]) && !empty($_POST["{$this->op}_logfile"])) $this->options['logfile'] = trim($_POST["{$this->op}_logfile"]);
if (isset($_POST["{$this->op}_dirtoexplore"]) && !empty($_POST["{$this->op}_dirtoexplore"])) $this->options['dirtoexplore'] = trim($_POST["{$this->op}_dirtoexplore"]);
if (isset($_POST["{$this->op}_error_level"])){
$this->options['error_level'] = intval($_POST["{$this->op}_error_level"]);
if(strpos($_POST["{$this->op}_error_level"],'E')!==FALSE) $this->options['error_level']=$this->get_error_levels(trim($_POST["{$this->op}_error_level"],'|'),'string2error');
elseif(strpos($_POST["{$this->op}_error_level"],'|')!==FALSE) $this->options['error_level']=$this->get_error_levels($this->get_error_levels(trim($_POST["{$this->op}_error_level"],'|'),'error2string'),'string2error');
}
if (isset($_POST["{$this->op}_plugin_debug_level"])) {
$this->debug = $this->options['plugin_debug_level'] = intval($_POST["{$this->op}_plugin_debug_level"]);
}
if (isset($_POST["{$this->op}_error_reporting"]) && ($this->options['error_reporting'] = 0)==0) {
foreach( array_map( 'intval', (array) $_POST["{$this->op}_error_reporting"] ) as $bit) $this->options['error_reporting'] |= $bit;
}
// checked('1', $this->options[$id],false)
if (isset($_POST["{$this->op}_debug_mods"]) && ($this->options['debug_mods'] = 0)==0) {
foreach(array_map( 'intval', (array) $_POST["{$this->op}_debug_mods"] ) as $bit) $this->options['debug_mods'] |= $bit;
}
if (isset($_POST["{$this->op}_debug_mods_verbose"]) && ($this->options['debug_mods_verbose'] = 0)==0) {
foreach(array_map( 'intval', (array) $_POST["{$this->op}_debug_mods_verbose"] ) as $bit) $this->options['debug_mods_verbose'] |= $bit;
}
$this->SaveOptions();
}
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
}
/** AA_DEBUG::AdminPage()
*/
function AdminPage()
{
if(!current_user_can('manage_options') ) wp_die( 'ERROR: User does not have permission to manage options.' );
if(!current_user_can('administrator')) wp_die('ERROR: Not an Admin!');
global $screen,$current_screen, $wp_meta_boxes, $_wp_contextual_help, $title;
$this->t(__FILE__,__CLASS__,__FUNCTION__,__LINE__);
echo '';
if(function_exists('screen_icon')) screen_icon();
echo ' ' . $this->plugin['plugin-name'].'';
if($this->d(5)) {
$this->p($_POST);
$this->p($this->options);
}
echo ' |