<?php
header('Content-Type: text/html; charset=UTF-8');
error_reporting(E_ALL);
ini_set('display_errors', '1');

if ($_SERVER["REQUEST_METHOD"] == "POST") {
// HTML form handling
if (isset($_POST['Content'])) {
$title = $_POST['title'];
$csrfKey = $_POST['csrfKey'];
$stringcookie = $_POST['stringcookie'];
$Content = $_POST['Content'];

    $url = 'https://forums.kentuckywrestling.com/index.php?/forum/50-events-marketplace/&do=add';
    $boundary = '----WebKitFormBoundaryAAeOFmlHzR34b9t3';

    // Data POST yang dikirim
    $data = [
        'form_submitted' => '1',
        'csrfKey' => $csrfKey,
        'MAX_FILE_SIZE' => '67108864',
        'plupload' => '1d1ec0d9d63cb872b1d52078da63b8cd',
        'topic_title' => $title,
        'topic_tags_original' => '',
        'topic_tags' => '',
        'topic_tags_prefix' => '',
        'topic_content' => $Content,
        'topic_content_upload' => 'cdf1bcd0fe0c5d834241342f8d0ee2c9',
        'topic_auto_follow' => '0',
        'topic_poll[title]' => '',
        'topic_poll[poll_close_date]' => '2026-08-27',
        'topic_poll[poll_close_time]' => '23:53',
        'topic_poll[questions][1][title]' => '',
        'topic_poll[questions][1][answers][1][value]' => '',
        'topic_poll[questions][1][answers][2][value]' => '',
    ];

    // Bangun data POST
    $postFields = '';
    foreach ($data as $key => $value) {
        $postFields .= "--$boundary\r\n";
        $postFields .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n";
        $postFields .= "$value\r\n";
    }
    $postFields .= "--$boundary--\r\n";

    // Inisialisasi sesi cURL
    $ch = curl_init($url);

    // Atur opsi cURL
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
        'Accept-Language: en-US,en;q=0.9',
        'Cache-Control: max-age=0',
        'Content-Type: multipart/form-data; boundary=' . $boundary,
        'Cookie: ' . $stringcookie,
        'Origin: https://forums.kentuckywrestling.com',
        'Referer: https://forums.kentuckywrestling.com',
        'Sec-CH-UA: "Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
        'Sec-CH-UA-Mobile: ?0',
        'Sec-CH-UA-Platform: "macOS"',
        'Sec-Fetch-Dest: document',
        'Sec-Fetch-Mode: navigate',
        'Sec-Fetch-Site: same-origin',
        'Sec-Fetch-User: ?1',
        'Upgrade-Insecure-Requests: 1',
        'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'
    ]);

    $headers = [];
    curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($ch, $header) use (&$headers) {
        $length = strlen($header);
        if (stripos($header, 'Location:') === 0) {
            $headers[] = trim(substr($header, 9));
        }
        return $length;
    });

    $retry = true;
    while ($retry) {
        // Eksekusi permintaan cURL
        $response = curl_exec($ch);
        if (curl_errno($ch)) {
            echo 'Error: ' . curl_error($ch);
            break;
        }

        // Cek apakah ada pesan tentang batas waktu
        if (preg_match('/<span class="ipsType_warning">New posts within a short time frame are limited. Please wait (\d+) seconds before submitting.<\/span>/', $response, $matches)) {
            // Ambil waktu tunggu dan tidurkan
            $waitTime = (int)$matches[1];
            echo "Please wait for $waitTime seconds before retrying.<br/>";
            sleep($waitTime);
        } else {
            // Menampilkan response
            echo "<textarea style='width:100%;height:300px;'>$response</textarea>";
            $retry = false; // Selesai jika tidak ada lagi batas waktu
        }
    }

    // Tutup sesi cURL
    curl_close($ch);

    // Tampilkan URL redirect jika ada
    if (!empty($headers)) {
        echo '<br/><div id="hasil">' . end($headers) . '</div>';
        echo 'Redirect URL: ' . end($headers);
    } else {
        echo '<br/><div id="hasil">failed</div>';
    }
}

}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML to JSON Converter</title>
</head>
<body>
<h2>HTML to JSON Converter</h2>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<label for="title">Title:</label><br>
<input id="title" name="title" /><br><br>
<input id="csrfKey" name="csrfKey" /><br><br>
<label for="Content">Masukkan Kode HTML:</label><br>
<textarea id="Content" name="Content" rows="10" cols="50"><?php if(isset($Content)) echo htmlspecialchars($Content); ?></textarea><br><br>
<label for="stringcookie">cookie:</label><br>
<textarea id="stringcookie" name="stringcookie" rows="10" cols="50"></textarea><br><br>
<input type="submit" value="Convert to JSON">
</form>
</body>
</html>

Edit Report
Pub: 08 Apr 2025 00:40 UTC
Views: 6