HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/panomity.de/panomity.com/images/image_generator.php
<?php

// Check if the prompt is set in the POST request
if (isset($_POST['prompt'])) {
    // Define the URL of the image generation API
    $url = "http://plano.panomity.com:7878/sdapi/v1/txt2img";
    
    // Prepare the payload with the prompt received from the AJAX request
    $payload = array(
        "prompt" => $_POST['prompt'], // Use the user's prompt
        "steps" => 25 // Number of steps for image generation, adjust as necessary
    );

    // Initialize a cURL session
    $ch = curl_init($url);

    // Specify that we want to send a POST request
    curl_setopt($ch, CURLOPT_POST, true);

    // Attach our encoded JSON payload
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));

    // Return the transfer as a string of the return value of curl_exec() instead of outputting it directly
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Set the content type to application/json
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

    // Execute the POST request
    $response = curl_exec($ch);

    // Close the cURL session
    curl_close($ch);

    // Decode the JSON response
    $responseData = json_decode($response, true);

    // Check if 'images' key exists and has at least one image
    if(isset($responseData['images'][0])) {
    // Generate a unique filename for the image
    $uniqueFilename = 'image_' . time() . '_' . rand(1000, 9999) . '.png'; 
       // Decode the first image from base64 and save it
        $imageData = base64_decode($responseData['images'][0]);
        
        // Specify the path to save the image
        $imagePath = "generated_images/".$uniqueFilename; // Make sure this directory exists and is writable
        
        file_put_contents($imagePath, $imageData);

        // Return the path to the generated image
        echo $imagePath;
    } else {
        echo "No images returned in the response.";
    }
} else {
    // If no prompt is provided, return an error message
    echo "Error: No prompt provided.";
}
?>