HEX
Server: LiteSpeed
System: Linux premium127.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User: luxbsolr (925)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/luxbsolr/cardsord.store/wp-content/plugins/Csv_Uploader/debug.php
<?php
/**
 * Debug script to check plugin tables and functionality
 * Remove this file after debugging
 */

// Add this to your WordPress admin area temporarily for debugging
function fcpi_debug_info() {
    if (!current_user_can('manage_options')) {
        return;
    }
    
    global $wpdb;
    
    echo '<div class="wrap"><h1>FCPI Debug Info</h1>';
    
    // Check if table exists
    $table_name = $wpdb->prefix . 'fcpi_import_logs';
    $table_exists = $wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") == $table_name;
    
    echo '<h2>Database Table Status</h2>';
    echo '<p>Table name: ' . $table_name . '</p>';
    echo '<p>Table exists: ' . ($table_exists ? 'YES' : 'NO') . '</p>';
    
    if ($table_exists) {
        $columns = $wpdb->get_results("DESCRIBE {$table_name}");
        echo '<h3>Table Structure:</h3>';
        echo '<table class="wp-list-table widefat"><thead><tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th></tr></thead><tbody>';
        foreach ($columns as $column) {
            echo '<tr>';
            echo '<td>' . $column->Field . '</td>';
            echo '<td>' . $column->Type . '</td>';
            echo '<td>' . $column->Null . '</td>';
            echo '<td>' . $column->Key . '</td>';
            echo '</tr>';
        }
        echo '</tbody></table>';
        
        // Check records
        $count = $wpdb->get_var("SELECT COUNT(*) FROM {$table_name}");
        echo '<p>Records in table: ' . $count . '</p>';
        
        if ($count > 0) {
            $records = $wpdb->get_results("SELECT * FROM {$table_name} ORDER BY id DESC LIMIT 5");
            echo '<h3>Latest Records:</h3>';
            echo '<pre>' . print_r($records, true) . '</pre>';
        }
    }
    
    // Check transients
    echo '<h2>Transients Check</h2>';
    $transients = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE '_transient_fcpi_file_%' ORDER BY option_id DESC LIMIT 5");
    echo '<p>Active file transients: ' . count($transients) . '</p>';
    if (!empty($transients)) {
        echo '<pre>' . print_r($transients, true) . '</pre>';
    }
    
    // Check WooCommerce
    echo '<h2>Dependencies</h2>';
    echo '<p>WooCommerce active: ' . (class_exists('WooCommerce') ? 'YES' : 'NO') . '</p>';
    
    // Test table creation
    if (!$table_exists) {
        echo '<h2>Table Creation Test</h2>';
        echo '<form method="post">';
        echo '<input type="hidden" name="fcpi_create_table" value="1">';
        echo '<button type="submit" class="button">Create Table</button>';
        echo '</form>';
        
        if (isset($_POST['fcpi_create_table'])) {
            $charset_collate = $wpdb->get_charset_collate();
            
            $sql = "CREATE TABLE {$table_name} (
                id mediumint(9) NOT NULL AUTO_INCREMENT,
                import_id varchar(32) NOT NULL,
                status varchar(20) NOT NULL DEFAULT 'pending',
                total_rows int(11) NOT NULL DEFAULT 0,
                processed_rows int(11) NOT NULL DEFAULT 0,
                successful_rows int(11) NOT NULL DEFAULT 0,
                failed_rows int(11) NOT NULL DEFAULT 0,
                error_log longtext,
                file_path longtext,
                mapping_data longtext,
                started_at datetime DEFAULT CURRENT_TIMESTAMP,
                completed_at datetime NULL,
                PRIMARY KEY (id),
                KEY import_id (import_id),
                KEY status (status)
            ) {$charset_collate};";
            
            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
            $result = dbDelta($sql);
            
            echo '<div class="notice notice-info"><p>Table creation result:</p><pre>' . print_r($result, true) . '</pre></div>';
        }
    }
    
    echo '</div>';
}

// Add to admin menu temporarily
add_action('admin_menu', function() {
    add_submenu_page(
        'tools.php',
        'FCPI Debug',
        'FCPI Debug',
        'manage_options',
        'fcpi-debug',
        'fcpi_debug_info'
    );
});
?>