| Current Path : /var/www/cesa.co.za/crons/ |
| Current File : /var/www/cesa.co.za/crons/wp-load-bypass.php |
<?php
// Start output buffering
ob_start();
// Basic error reporting
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Set required server variables
if (!isset($_SERVER['HTTP_HOST'])) {
$_SERVER['HTTP_HOST'] = 'localhost';
}
if (!isset($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = '/';
}
echo "=== WordPress Bypass Load Test ===\n";
echo "PHP Version: " . phpversion() . "\n";
echo "Current directory: " . getcwd() . "\n";
// Set document root
if (!isset($_SERVER['DOCUMENT_ROOT']) || strlen($_SERVER['DOCUMENT_ROOT']) <= 0) {
$_SERVER['DOCUMENT_ROOT'] = str_replace('/crons', '', getcwd());
}
echo "Document root: " . $_SERVER['DOCUMENT_ROOT'] . "\n";
// Check if we can access WordPress files directly
$wp_includes_path = $_SERVER['DOCUMENT_ROOT'] . '/wp-includes';
$wp_admin_path = $_SERVER['DOCUMENT_ROOT'] . '/wp-admin';
if (is_dir($wp_includes_path)) {
echo "✓ wp-includes directory found\n";
} else {
echo "✗ wp-includes directory not found\n";
}
if (is_dir($wp_admin_path)) {
echo "✓ wp-admin directory found\n";
} else {
echo "✗ wp-admin directory not found\n";
}
// Try to load WordPress core files directly
echo "\nAttempting to load WordPress core files...\n";
try {
// Load wp-config.php first to get database settings
$wp_config_path = $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php';
if (file_exists($wp_config_path)) {
require_once($wp_config_path);
echo "✓ wp-config.php loaded\n";
} else {
echo "✗ wp-config.php not found\n";
exit(1);
}
// Load wp-settings.php which is the core WordPress initialization
$wp_settings_path = $_SERVER['DOCUMENT_ROOT'] . '/wp-settings.php';
if (file_exists($wp_settings_path)) {
require_once($wp_settings_path);
echo "✓ wp-settings.php loaded\n";
} else {
echo "✗ wp-settings.php not found\n";
exit(1);
}
echo "✓ WordPress core loaded successfully\n";
// Test basic functions
if (function_exists('get_post_meta')) {
echo "✓ get_post_meta function available\n";
} else {
echo "✗ get_post_meta function not available\n";
}
if (defined('ABSPATH')) {
echo "✓ ABSPATH constant defined: " . ABSPATH . "\n";
} else {
echo "✗ ABSPATH constant not defined\n";
}
// Test database connection
if (defined('DB_HOST') && defined('DB_USER') && defined('DB_NAME')) {
echo "✓ Database constants defined\n";
echo " Host: " . DB_HOST . "\n";
echo " User: " . DB_USER . "\n";
echo " Database: " . DB_NAME . "\n";
} else {
echo "✗ Database constants not defined\n";
}
} catch (Exception $e) {
echo "✗ Exception loading WordPress: " . $e->getMessage() . "\n";
echo "Exception trace: " . $e->getTraceAsString() . "\n";
} catch (Error $e) {
echo "✗ Fatal error loading WordPress: " . $e->getMessage() . "\n";
echo "Error trace: " . $e->getTraceAsString() . "\n";
}
echo "\n=== Test completed ===\n";
// Flush output buffer
ob_end_flush();