File size: 6,004 Bytes
efc9636
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1fb22f2
 
 
 
 
 
 
 
 
 
 
5ed2b6d
1fb22f2
 
 
 
 
 
 
 
 
5f45304
1fb22f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f45304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ed2b6d
5f45304
 
 
 
 
 
 
 
5ed2b6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f45304
 
 
 
efc9636
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?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', 'get_col', 'prepare', 'insert', 'update', 'delete', 'suppress_errors', 'show_errors', 'hide_errors', 'bail', 'timer_start', 'timer_stop', 'get_blog_prefix', '_escape', '_real_escape', '_weak_escape', 'escape', 'add_placeholder_escape', 'placeholder_escape'];
        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', '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>";
}

// Test database connection
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>";
    
    // Test if WordPress tables were created
    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>";
        }
    }
    
    // Test default options
    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', 'blogdescription', 'users_can_register', '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>";
        }
    }
    
    echo "<h3>Escape Methods Test</h3>";
    // Test escape methods
    $test_string = "Test's \"quoted\" string with % symbols";
    $test_array = array('key1' => "value's", 'key2' => 'value"with"quotes');
    
    echo "<p><strong>Original string:</strong> " . htmlspecialchars($test_string) . "</p>";
    echo "<p><strong>_escape():</strong> " . htmlspecialchars($db->_escape($test_string)) . "</p>";
    echo "<p><strong>_real_escape():</strong> " . htmlspecialchars($db->_real_escape($test_string)) . "</p>";
    echo "<p><strong>_weak_escape():</strong> " . htmlspecialchars($db->_weak_escape($test_string)) . "</p>";
    
    echo "<p><strong>Array escape test:</strong></p>";
    $escaped_array = $db->_escape($test_array);
    foreach ($escaped_array as $key => $value) {
        echo "<p style='margin-left: 20px;'>$key: " . htmlspecialchars($value) . "</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>";
?>