<?php
// create-avatar.php - Generate default avatar image
// Run once, then delete

$dir = 'uploads/avatars';
if(!is_dir($dir)) {
    mkdir($dir, 0777, true);
}

// Create a 200x200 image
$img = imagecreatetruecolor(200, 200);

// Purple background
$purple = imagecolorallocate($img, 108, 92, 231);
imagefill($img, 0, 0, $purple);

// White text
$white = imagecolorallocate($img, 255, 255, 255);

// Draw a simple person icon using circles
// Head
imagefilledellipse($img, 100, 70, 60, 60, $white);
// Body
imagefilledellipse($img, 100, 170, 100, 90, $white);

// Save the image
$saved = imagepng($img, $dir . '/default-avatar.png');
imagedestroy($img);

if($saved && file_exists($dir . '/default-avatar.png')) {
    echo "<h2 style='color:green;'>✅ Default avatar created!</h2>";
    echo "<p>File: uploads/avatars/default-avatar.png</p>";
    echo "<img src='uploads/avatars/default-avatar.png' width='100'>";
} else {
    echo "<h2 style='color:red;'>❌ Failed to create avatar</h2>";
    echo "<p>Check folder permissions</p>";
}

echo "<p style='color:red;'>Delete this file now!</p>";
?>