HEX
Server: Apache
System: Linux 136-243-153-58.cprapid.com 4.18.0-553.81.1.el8_10.x86_64 #1 SMP Mon Oct 27 11:29:19 EDT 2025 x86_64
User: mytest (1001)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/mytest/.trash/check-cron-error.php.8
<?php
/**
 * Check why cron-update-availability.php isn't working
 */
header('Content-Type: text/plain; charset=utf-8');

echo "=== Checking Cron Setup ===\n\n";

// Check if cron file exists
echo "1. Checking if cron-update-availability.php exists...\n";
if (file_exists(__DIR__ . '/cron-update-availability.php')) {
    echo "   ✓ File exists\n\n";
} else {
    echo "   ✗ FILE NOT FOUND!\n";
    echo "   You need to upload: cron-update-availability.php\n\n";
    exit;
}

// Check if config.php exists
echo "2. Checking if config.php exists...\n";
if (file_exists(__DIR__ . '/config.php')) {
    echo "   ✓ config.php exists\n\n";
} else {
    echo "   ✗ config.php NOT FOUND!\n\n";
}

// Check if database/Database.php exists
echo "3. Checking if database/Database.php exists...\n";
if (file_exists(__DIR__ . '/database/Database.php')) {
    echo "   ✓ Database.php exists\n\n";
} else {
    echo "   ✗ database/Database.php NOT FOUND!\n\n";
}

// Check if api/services/BookingManagerService.php exists
echo "4. Checking if api/services/BookingManagerService.php exists...\n";
if (file_exists(__DIR__ . '/api/services/BookingManagerService.php')) {
    echo "   ✓ BookingManagerService.php exists\n\n";
} else {
    echo "   ✗ api/services/BookingManagerService.php NOT FOUND!\n\n";
}

// Try to include files
echo "5. Trying to load required files...\n";
try {
    require_once __DIR__ . '/config.php';
    echo "   ✓ config.php loaded\n";
} catch (Exception $e) {
    echo "   ✗ Error loading config.php: " . $e->getMessage() . "\n";
}

try {
    require_once __DIR__ . '/database/Database.php';
    echo "   ✓ Database.php loaded\n";
} catch (Exception $e) {
    echo "   ✗ Error loading Database.php: " . $e->getMessage() . "\n";
}

try {
    require_once __DIR__ . '/api/services/BookingManagerService.php';
    echo "   ✓ BookingManagerService.php loaded\n";
} catch (Exception $e) {
    echo "   ✗ Error loading BookingManagerService.php: " . $e->getMessage() . "\n";
}

echo "\n6. Trying to connect to database...\n";
try {
    $db = Database::getInstance();
    echo "   ✓ Database connection successful\n\n";
    
    // Check if table exists
    echo "7. Checking if yacht_weekly_availability table exists...\n";
    $result = $db->query("SHOW TABLES LIKE 'yacht_weekly_availability'");
    $row = $result->fetch();
    if ($row) {
        echo "   ✓ Table exists\n\n";
    } else {
        echo "   ✗ TABLE DOES NOT EXIST!\n";
        echo "   Run the CREATE TABLE SQL in phpMyAdmin!\n\n";
    }
    
    // Check if yachts exist
    echo "8. Checking if yachts exist in database...\n";
    $result = $db->query("SELECT COUNT(*) as count FROM yachts WHERE booking_manager_id IS NOT NULL AND booking_manager_id != ''");
    $row = $result->fetch();
    echo "   Found " . $row['count'] . " yachts with booking_manager_id\n\n";
    
    if ($row['count'] == 0) {
        echo "   ✗ NO YACHTS FOUND WITH BOOKING MANAGER ID!\n";
        echo "   The cron has nothing to sync!\n\n";
    }
    
} catch (Exception $e) {
    echo "   ✗ Database error: " . $e->getMessage() . "\n\n";
}

echo "=== Check Complete ===\n";
echo "\nIf all checks pass, the cron should work.\n";
echo "If you see errors above, fix them first!\n";
?>