|
<?php |
|
|
|
|
|
|
|
|
|
echo "<h1>PHP Test Page</h1>"; |
|
echo "<p>PHP Version: " . phpversion() . "</p>"; |
|
echo "<p>Current Time: " . date('Y-m-d H:i:s') . "</p>"; |
|
|
|
|
|
if (extension_loaded('pdo_sqlite')) { |
|
echo "<p style='color: green;'>β SQLite PDO extension is available</p>"; |
|
|
|
try { |
|
$db_file = '/var/www/html/wp-content/database/wordpress.db'; |
|
$pdo = new PDO('sqlite:' . $db_file); |
|
echo "<p style='color: green;'>β SQLite connection successful</p>"; |
|
|
|
|
|
$result = $pdo->query("SELECT name FROM sqlite_master WHERE type='table'"); |
|
$tables = $result->fetchAll(PDO::FETCH_COLUMN); |
|
|
|
if (count($tables) > 0) { |
|
echo "<p>Database tables found: " . implode(', ', $tables) . "</p>"; |
|
} else { |
|
echo "<p>No tables found in database (this is normal for a fresh install)</p>"; |
|
} |
|
|
|
} catch (Exception $e) { |
|
echo "<p style='color: red;'>β SQLite connection failed: " . $e->getMessage() . "</p>"; |
|
} |
|
} else { |
|
echo "<p style='color: red;'>β SQLite PDO extension is NOT available</p>"; |
|
} |
|
|
|
|
|
echo "<h2>File Permissions</h2>"; |
|
$files = [ |
|
'/var/www/html/wp-config.php', |
|
'/var/www/html/wp-content/db.php', |
|
'/var/www/html/wp-content/database' |
|
]; |
|
|
|
foreach ($files as $file) { |
|
if (file_exists($file)) { |
|
$perms = substr(sprintf('%o', fileperms($file)), -4); |
|
echo "<p>$file: $perms</p>"; |
|
} else { |
|
echo "<p style='color: red;'>$file: NOT FOUND</p>"; |
|
} |
|
} |
|
|
|
|
|
echo "<h2>WordPress Database Methods Test</h2>"; |
|
if (file_exists('/var/www/html/wp-content/db.php')) { |
|
require_once('/var/www/html/wp-content/db.php'); |
|
|
|
if (class_exists('SQLite_DB')) { |
|
$test_db = new SQLite_DB(); |
|
|
|
echo "<p>β SQLite_DB class loaded successfully</p>"; |
|
|
|
|
|
$methods = ['set_prefix', 'get_results', 'get_row', 'get_var', 'get_col', 'prepare', 'insert', 'update', 'delete', 'suppress_errors', 'show_errors', 'hide_errors', 'bail', 'timer_start', 'timer_stop', 'get_blog_prefix']; |
|
foreach ($methods as $method) { |
|
if (method_exists($test_db, $method)) { |
|
echo "<p style='color: green;'>β Method $method exists</p>"; |
|
} else { |
|
echo "<p style='color: red;'>β Method $method missing</p>"; |
|
} |
|
} |
|
|
|
|
|
$properties = ['prefix', 'posts', 'users', 'options', 'ready', 'field_types', 'suppress_errors', 'show_errors', 'time_start', 'blogid', 'base_prefix', 'charset', 'collate', 'dbname']; |
|
foreach ($properties as $prop) { |
|
if (property_exists($test_db, $prop)) { |
|
echo "<p style='color: green;'>β Property $prop exists</p>"; |
|
} else { |
|
echo "<p style='color: red;'>β Property $prop missing</p>"; |
|
} |
|
} |
|
|
|
} else { |
|
echo "<p style='color: red;'>β SQLite_DB class not found</p>"; |
|
} |
|
} else { |
|
echo "<p style='color: red;'>β wp-content/db.php not found</p>"; |
|
} |
|
|
|
|
|
echo "<h3>Database Connection Test</h3>"; |
|
if ($db->ready) { |
|
echo "<p style='color: green;'>β Database connection successful</p>"; |
|
echo "<p>Database type: SQLite (in-memory)</p>"; |
|
echo "<p>Database prefix: " . $db->prefix . "</p>"; |
|
|
|
|
|
echo "<h4>WordPress Tables Test</h4>"; |
|
$tables_to_check = array('posts', 'users', 'options', 'comments', 'terms', 'term_taxonomy', 'term_relationships'); |
|
foreach ($tables_to_check as $table) { |
|
$table_name = $db->prefix . $table; |
|
$result = $db->get_results("SELECT name FROM sqlite_master WHERE type='table' AND name='$table_name'"); |
|
if (!empty($result)) { |
|
echo "<p style='color: green;'>β Table '$table_name' exists</p>"; |
|
} else { |
|
echo "<p style='color: red;'>β Table '$table_name' missing</p>"; |
|
} |
|
} |
|
|
|
|
|
echo "<h4>Default Options Test</h4>"; |
|
$option_count = $db->get_var("SELECT COUNT(*) FROM {$db->prefix}options"); |
|
echo "<p>Total options in database: $option_count</p>"; |
|
|
|
$test_options = array('siteurl', 'home', 'blogname', 'admin_email'); |
|
foreach ($test_options as $option) { |
|
$value = $db->get_var($db->prepare("SELECT option_value FROM {$db->prefix}options WHERE option_name = %s", $option)); |
|
if ($value !== null) { |
|
echo "<p style='color: green;'>β Option '$option': $value</p>"; |
|
} else { |
|
echo "<p style='color: red;'>β Option '$option' not found</p>"; |
|
} |
|
} |
|
} else { |
|
echo "<p style='color: red;'>β Database connection failed</p>"; |
|
} |
|
|
|
echo "<hr>"; |
|
echo "<p><a href='/'>Try WordPress</a> | <a href='/debug.php'>Debug Info</a></p>"; |
|
?> |