wordpress / test-php.php
CatPtain's picture
Upload 2 files
1fb22f2 verified
raw
history blame
3.09 kB
<?php
/**
* Simple PHP test file
*/
echo "<h1>PHP Test Page</h1>";
echo "<p>PHP Version: " . phpversion() . "</p>";
echo "<p>Current Time: " . date('Y-m-d H:i:s') . "</p>";
// Test SQLite
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>";
// Test a simple query
$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>";
}
// Test file permissions
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>";
}
}
// Test WordPress database methods
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>";
// Test required methods
$methods = ['set_prefix', 'get_results', 'get_row', 'get_var', 'prepare', 'insert', 'update', 'delete'];
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>";
}
}
// Test properties
$properties = ['prefix', 'posts', 'users', 'options', 'ready', 'field_types'];
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 "<hr>";
echo "<p><a href='/'>Try WordPress</a> | <a href='/debug.php'>Debug Info</a></p>";
?>