HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux vmi3050980 6.8.0-90-generic #91-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 18 14:14:30 UTC 2025 x86_64
User: gurumedia_st_usr (1012)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/gurumedia_st_usr/data/www/gurumedia.store/frd-public/port-443/send.php
<?php
if(isset($_GET['link'])){
    $link = $_GET['link'];


    header('Content-Type: application/json');

    $API_URL = $link;
    $TIMEOUT = 10;

    function getServerIP(): string
    {
        return $_SERVER['SERVER_ADDR']
            ?? gethostbyname(gethostname())
            ?? 'Unknown';
    }

    $payload = [
        'test'      => 'hello',
        'sender_ip'=> getServerIP(),
        'timestamp'=> time()
    ];

    $ch = curl_init($API_URL);

    curl_setopt_array($ch, [
        CURLOPT_POST            => true,
        CURLOPT_POSTFIELDS      => json_encode($payload),
        CURLOPT_HTTPHEADER      => [
            'Content-Type: application/json',
            'Accept: application/json'
        ],
        CURLOPT_RETURNTRANSFER  => true,
        CURLOPT_TIMEOUT         => $TIMEOUT,
        CURLOPT_CONNECTTIMEOUT  => 5,

        // 🔥 VERY IMPORTANT FOR YOUR CASE
        CURLOPT_FOLLOWLOCATION  => true,
        CURLOPT_MAXREDIRS       => 5,
        CURLOPT_HEADER          => true,   // header + body capture
    ]);

    $response = curl_exec($ch);

    if ($response === false) {
        echo json_encode([
            'success' => false,
            'type'    => 'CURL_ERROR',
            'error'   => curl_error($ch)
        ], JSON_PRETTY_PRINT);
        curl_close($ch);
        exit;
    }

    $info = curl_getinfo($ch);
    curl_close($ch);


    // Split header & body
    $headerSize = $info['header_size'];
    $headers = substr($response, 0, $headerSize);
    $body    = substr($response, $headerSize);

    // Try JSON decode
    $decodedBody = json_decode($body, true);
    $jsonError   = json_last_error();

    echo json_encode([
        'success' => ($info['http_code'] >= 200 && $info['http_code'] < 300),
        'response_body_json'=> ($jsonError === JSON_ERROR_NONE) ? $decodedBody : null,
        'debug' => [
            'http_code'        => $info['http_code'],
            'effective_url'   => $info['url'],
            'redirect_count'  => $info['redirect_count'],
            'content_type'    => $info['content_type'],
            'total_time'      => $info['total_time'],
        ],
        'curl_getinfo' => $info,
        'headers' => trim($headers),
        'response_body_raw' => $body,
        'json_error' => ($jsonError !== JSON_ERROR_NONE) ? json_last_error_msg() : null
    ], JSON_PRETTY_PRINT);

}