• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Error in OTCV8 status.php (Player Online)

Odisk

New Member
Joined
Apr 6, 2010
Messages
27
Reaction score
1
Hello everyone <3

I am trying to add the status.php to my client and I can not always get this error but I have even tried with status.php from other servers taking it from their direct domain and if the users see it online. from my OTCV8 client.

Error client
error client.PNG

here I am opening the status.php from my browser and this is the result, I even tried entering the status.php from other servers and it looks exactly the same as mine.
Screenshot 2024-03-05 at 01-25-25 Screenshot.png

this is the code I am using status.php

PHP:
<?php
$online_otservlist = 0;
try {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://otarchive.com/server/6452daeb8fe898282d5263a7");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return data inplace of echoing on screen
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); // Skip SSL Verification
    curl_setopt($ch, CURLOPT_ENCODING , "");
    $site = curl_exec($ch);
    curl_close($ch);
    preg_match('/Informed Players (\d+) \(\d+\)/', $site, $matches);
    // preg_match('/There are: <strong>([0-9]*)<\/strong>/', $site, $matches);
    $doc = new DOMDocument();
    @$doc->loadHTML($site);

    $xpath = new DOMXPath($doc);

    // Find the <th> element with the text "Informed Players"
    $thElement = $xpath->query('//th[contains(text(), "Informed Players")]')->item(0);
    if ($thElement) {
        // Find the element <td> sibling of <th> that contains the number of online players
        $tdElement = $thElement->nextSibling;
        if ($tdElement && $tdElement->nodeName === 'td') {
            $playersOnlineText = $tdElement->nodeValue;
            // Use a regular expression to extract just the number
            if (preg_match('/(\d+)/', $playersOnlineText, $matches)) {
                $playersOnline = $matches[1];
            }
        }
    }
    $online_otservlist = $matches[1];
} catch(Exception $e) {}
$online_discord = 0;
try {
    $online_discord = json_decode(file_get_contents("https://discord.com/api/guilds/1136264192232525964/widget.json "))->presence_count;
} catch(Exception $e) {}

$response = array(
    "online" => "$online_otservlist Players online",
    "discord_online" => $online_discord,
    "discord_link" => "https://discord.gg/t4ntS5p"
);
echo json_encode($response);
?>

thank you for your help. !
 
Back
Top