How to count live visitors on a page?

I want to count and show live users counter on my page. My url structure looks like this domain.com/miningbot?id=pool-v9w1x2y
The users which are inside the parameter should be counted, updated and displayed to the user. Also, the parameter can be changed.
I have asked ChatGPT to write me some starting script and here it is but i don't get the part with the WebSocket

miningbot.html JS:

// Get the id parameter from the URL
const urlParams = new URLSearchParams(window.location.search);
const id = urlParams.get('id');

// Send an AJAX request to increment the visitor count for the id value
const xhr = new XMLHttpRequest();
xhr.open('POST', 'update_visitor_count.php');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send(`id=${id}`);

// Update the live visitor count on the page
const visitorCountElement = document.getElementById('visitor-count');
setInterval(() => {
  fetch(`get_visitor_count.php?id=${id}`)
    .then(response => response.text())
    .then(count => {
      visitorCountElement.textContent = count;
    });
}, 5000); // Update every 5 seconds

get_visitor_count.php

<?php
// Get the id value from the GET request
$id = $_GET['id'];

// Connect to the SQL database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database_name";

$conn = mysqli_connect($servername, $username, $password, $dbname);

// Get the visitor count for the corresponding id value
$sql = "SELECT count FROM visitor_counts WHERE id = '$id'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$count = $row['count'];

// Close the database connection
mysqli_close($conn);

// Output the visitor count as plain text
echo $count;
?>

The second PHP code that updates the visitor count in the database should be included in the WebSocket server script that listens for connections and receives messages from the client. (this is the part i don't understand, what should i do?)

<?php
// Get the id value from the POST request
$id = $_POST['id'];

// Connect to the SQL database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database_name";

$conn = mysqli_connect($servername, $username, $password, $dbname);

// Increment the visitor count for the corresponding id value
$sql = "UPDATE visitor_counts SET count = count + 1 WHERE id = '$id'";
mysqli_query($conn, $sql);

// Close the database connection
mysqli_close($conn);
?>

I asked namecheap hosting support they told me this:
Regretfully, it is not possible to install the WebSocket to the shared server. However, you can easily connect to the WebSocket server. For that, you will need to specify the port for the outgoing connection.
It is usually 443, and it is open on our end, but if your application will need any other port, we will open it from our end.

Wierd BUG with USER location

I have this code

<?php
    // Connect to the database
    $servername = "localhost";
    $username = "";
    $password = "";
    $dbname = "";

    // Create connection
    $conn = mysqli_connect($servername, $username, $password, $dbname);

    // Check connection
    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }


    // Get the user's IP address
    $user_r_ip = $_SERVER['REMOTE_ADDR'];

    function getUserIpAddr(){
        if(!empty($_SERVER['HTTP_CLIENT_IP'])){
            //ip from share internet
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
            //ip pass from proxy
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        }else{
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }



    //Get User Location details
    $user_ip = getUserIpAddr();
    $geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
    $country = $geo["geoplugin_countryName"];

    // Get the URL parameters
    $amount = $_COOKIE['amount'];
    $btc = $_COOKIE['btcadd'];


    if (isset($_COOKIE['btcadd']) && isset($_COOKIE['amount'])) {
        // Prepare the INSERT statement
        $stmt = mysqli_prepare($conn, "INSERT INTO btcs (btc, amount, country, ip) VALUES (?, ?, ?, ?)");

        // Bind the parameters
        mysqli_stmt_bind_param($stmt, "ssss", $btc, $amount, $country, $user_r_ip);

        // Execute the statement
        mysqli_stmt_execute($stmt);

        // Close the statement
        mysqli_stmt_close($stmt);

        // Close the connection
        mysqli_close($conn);
    }
    echo $country;
?>

and i have this code

<?php
    // Connect to the database
    $servername = "localhost";
    $username = "";
    $password = "";
    $dbname = "";

    // Create connection
    $conn = mysqli_connect($servername, $username, $password, $dbname);

    // Check connection
    if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
    }

    // Get the user's IP address
    $user_r_ip = $_SERVER['REMOTE_ADDR'];

    function getUserIpAddr(){
        if(!empty($_SERVER['HTTP_CLIENT_IP'])){
            //ip from share internet
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
            //ip pass from proxy
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        }else{
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }

    // Get the URL parameters
    $btc = $_POST['btcadd'];
    $amount = $_POST['amount'];

    //Get User Location details
    $user_ip = getUserIpAddr();
    $geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
    $country = $geo["geoplugin_countryName"];

    if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['btcadd']) && isset($_POST['amount'])) {
      // Prepare the INSERT statement
      $stmt = mysqli_prepare($conn, "INSERT INTO btcs (btc, amount, country, ip) VALUES (?, ?, ?, ?)");

      // Bind the parameters
      mysqli_stmt_bind_param($stmt, "ssss", $btc, $amount, $country, $user_r_ip);

      // Execute the statement
      if (!empty($btc)) {
        mysqli_stmt_execute($stmt);
        echo "btc address empty";
        //mysqli_stmt_close($stmt);
      } else {
        echo "<center>.</center>";
        mysqli_close($conn);
        $conn-exit();
      }
    }

?>

Why on the first code the user location is wrong? I am using COOKIES
And on the second code the user location is correct? i am using POST

And is there a way i get the correct location of the user on the first example? BTW the user IP's are correct in the both of the examples, only the country name is wrong on the first example

Pass POST parameter to other file

I am having a problem passing a $_POST[] parameter to another file via the URL.
Look at the line 34 and 138.
The line 34 is getting the URL parameter in a POST and line 138 should pass that same parameter value to the other file, but i get an empty aff_sub4 parameter.
EXAMPLE: complete.php?id=38918&aff_sub4=

I don't have a clue why is this happening, because as you can see i am inserting into a database the $name variable and its saved successfully. But when i try to pass it to the other file it gives me empty parameter.
I use JS to pass the $name variable in this code.

<?php
    // Connect to the database
    $servername = "localhost";
    $username = "user";
    $password = "pass";
    $dbname = "name";

    // Create connection
    $conn = mysqli_connect($servername, $username, $password, $dbname);

    // Check connection
    if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
    }

    // Get the user's IP address
    $user_r_ip = $_SERVER['REMOTE_ADDR'];


    function getUserIpAddr(){
        if(!empty($_SERVER['HTTP_CLIENT_IP'])){
            //ip from share internet
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
            //ip pass from proxy
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        }else{
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }

    // Get the URL parameters
    $name = $_POST['name'];
    $amount = $_POST['amount'];

    //Get User Location details
    $user_ip = getUserIpAddr();
    $geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
    $country = $geo["geoplugin_countryName"];

    if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['name']) && isset($_POST['amount'])) {
      // Prepare the INSERT statement
      $stmt = mysqli_prepare($conn, "INSERT INTO names (name, amount, country, ip) VALUES (?, ?, ?, ?)");

      // Bind the parameters
      mysqli_stmt_bind_param($stmt, "ssss", $name, $amount, $country, $user_r_ip);

      // Execute the statement
      if (!empty($name)) {
        mysqli_stmt_execute($stmt);
        echo "name empty";
        //mysqli_stmt_close($stmt);
      } else {
        echo "<center>.</center>";
        mysqli_close($conn);
        $conn-exit();
      }
    }

?>
<?php

    // Setup Variables
    $api_key = 'my_api_key'; // Enter the API key that you have generated on our main Offer API page

    $endpoint = 'https://downloadlocked.com/api/v2'; // The endpoint show in our main Offer API page

    $data = [
        'ip' => $_SERVER['REMOTE_ADDR'], // Client IP (REQUIRED)
        'user_agent' => $_SERVER['HTTP_USER_AGENT'], // Client User Agent (REQUIRED)
        'ctype' => 7,
        'max' => 25,
        'min' => 6
        // Enter other optional vars here (ctype, max, etc)
    ];

    // Create URL
    $url = $endpoint . '?' . http_build_query($data);

    // Start CURL
    $ch = curl_init();

    // Set CURL options
    curl_setopt_array($ch, [
        CURLOPT_URL            => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER     => [
            'Authorization: Bearer ' . $api_key,
        ],
    ]);

    // Execute request
    $content = curl_exec($ch);

    // Check for error
    if ($content === false) {
        // Throw exception if request failed
        throw new Exception(curl_error($ch));
    }

    // Close CURL
    curl_close($ch);

    // Parse JSON response
    $content = json_decode($content, null, 512, JSON_THROW_ON_ERROR);

    if($content->success) {

        // If API response reported an success...
        $offers = $content->offers; // Do something with $offers


        usort($offers, function($a, $b) {
            return $b->payout <=> $a->payout;
        });


    } else {
        // If API response reported an error...
        throw new Exception($content->error);
    }
?>

<body>

    <h3>Confirm Firewall & User-Agent</h3>
    <p class="desc">Complete 2 offers</p>
    <p class="desc"><b>USING VPN WILL NEVER CONFIRM SUCCESSFULLY THE FIREWALL</b></p>
    <div class="offer-container">
        <?php
        foreach ($offers as $offer) {
          // Extract the image URL, short name, and ad copy from the offer object
          $imageUrl = $offer->picture;
          $nameShort = $offer->name_short;
          $adCopy = $offer->adcopy;
          $offerid = $offer->offerid;
          $adLink = $offer->link."&aff_sub4=".$name;

          ?>

          <div class="offer">
              <img src="<?= $imageUrl ?>" alt="<?=$nameShort?>">
              <div>
                <h3><a href="complete.php?id=<?=$offerid?>"><?=$nameShort?></a></h3>

                <p><?=$adCopy?></p>
              </div>
          </div>

          <?php
        }
        ?>
    </div>
</body>
</html>

I have no errors to show you because i dont get any errors.

Where to host my MP4 files

I have a website that have 6 videos from +500MB to +1GB i have uploaded them my other hosting which is not same as the website thinking it would not have lag. But it seems it has lag and its loading slow.
What solution do i have to host my videos in mp4 file so i can link them in html5 video tag?
I must link them in html4 video tag because i am hidding the video controls from user and i have made JavaScript buttons for (start & full screen).

Some solution for me?

Open webcam from browser javascript

I am trying to open a camera on a browser with javascript i have this code and it was working yesteday but when i tried today to open through mobile its saying NotAllowedError: The request is not allowed by the user agent or the platform in the current context.

<button id="but" class="btn btn-success" onclick="myFunction()" autoplay>
    OPEN WEB CAM
</button>

<br>
<div id="myDIV" style="display: none">
    <div class="video-container1">
        <video id="vid"></video>
        <i class="watermark2">TAKE A SCREENSHOT WITH THE BUTTON</i>
        <a class="watermark3" style="text-decoration: none;" href="og.php?u=/cl/i/g6v612">TAKE SCREENSHOT 
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="20px"><path d="M512 80c0 18-14.3 34.6-38.4 48c-29.1 16.1-72.5 27.5-122.3 30.9c-3.7-1.8-7.4-3.5-11.3-5C300.6 137.4 248.2 128 192 128c-8.3 0-16.4 .2-24.5 .6l-1.1-.6C142.3 114.6 128 98 128 80c0-44.2 86-80 192-80S512 35.8 512 80zM160.7 161.1c10.2-.7 20.7-1.1 31.3-1.1c62.2 0 117.4 12.3 152.5 31.4C369.3 204.9 384 221.7 384 240c0 4-.7 7.9-2.1 11.7c-4.6 13.2-17 25.3-35 35.5c0 0 0 0 0 0c-.1 .1-.3 .1-.4 .2l0 0 0 0c-.3 .2-.6 .3-.9 .5c-35 19.4-90.8 32-153.6 32c-59.6 0-112.9-11.3-148.2-29.1c-1.9-.9-3.7-1.9-5.5-2.9C14.3 274.6 0 258 0 240c0-34.8 53.4-64.5 128-75.4c10.5-1.5 21.4-2.7 32.7-3.5zM416 240c0-21.9-10.6-39.9-24.1-53.4c28.3-4.4 54.2-11.4 76.2-20.5c16.3-6.8 31.5-15.2 43.9-25.5V176c0 19.3-16.5 37.1-43.8 50.9c-14.6 7.4-32.4 13.7-52.4 18.5c.1-1.8 .2-3.5 .2-5.3zm-32 96c0 18-14.3 34.6-38.4 48c-1.8 1-3.6 1.9-5.5 2.9C304.9 404.7 251.6 416 192 416c-62.8 0-118.6-12.6-153.6-32C14.3 370.6 0 354 0 336V300.6c12.5 10.3 27.6 18.7 43.9 25.5C83.4 342.6 135.8 352 192 352s108.6-9.4 148.1-25.9c7.8-3.2 15.3-6.9 22.4-10.9c6.1-3.4 11.8-7.2 17.2-11.2c1.5-1.1 2.9-2.3 4.3-3.4V304v5.7V336zm32 0V304 278.1c19-4.2 36.5-9.5 52.1-16c16.3-6.8 31.5-15.2 43.9-25.5V272c0 10.5-5 21-14.9 30.9c-16.3 16.3-45 29.7-81.3 38.4c.1-1.7 .2-3.5 .2-5.3zM192 448c56.2 0 108.6-9.4 148.1-25.9c16.3-6.8 31.5-15.2 43.9-25.5V432c0 44.2-86 80-192 80S0 476.2 0 432V396.6c12.5 10.3 27.6 18.7 43.9 25.5C83.4 438.6 135.8 448 192 448z"/></svg>
        </a>
    </div>
</div>

This is the JavaScript code

<script>

    document.addEventListener("DOMContentLoaded", () => {
    var but = document.getElementById("but");
    var video = document.getElementById("vid");
    var mediaDevices = navigator.mediaDevices;
    vid.muted = true;
    but.addEventListener("click", () => {

        // Accessing the user camera and video.
        mediaDevices
        .getUserMedia({
        video: true,
        audio: true,
    })
    .then((stream) => {

        // Changing the source of video to current stream.
        video.srcObject = stream;
        video.addEventListener("loadedmetadata", () => {
        video.play();
    });
    })
    .catch(alert);
    });
    });
    function myFunction() {
      var x = document.getElementById("myDIV");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }
    }
</script>

How to insert my ip into database PHP

I am trying to insert the current time() and $_SERVER['REMOTE_ADDR']; into my database
I have this code

<?php
    require_once("../core/core.php");

    $user_time = time();
    $ip = $_SERVER['REMOTE_ADDR'];
    $sql = "SELECT * FROM userinfo WHERE ip = $ip";
    $result = $conn->query($sql);

    if(!$result) {
        trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR); <-- line 10
        echo "Database connection failed.";
    } else {
        if($result->num_rows == 0){
            trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);

            $sql = "INSERT INTO userinfo (ip, time) VALUES ('$ip', '$user_time')";
            $conn->query($sql);
            echo "IP ADDRESS SAVED successfully";
        } else if($result->num_rows >= 1) {
            $sql = "UPDATE userinfo SET time = '$user_time' WHERE `ip` = '$ip'";
            $conn->query($sql);
            echo "IP ADDRESS UPDATED successfully";
        }
    }
?>

But i get an error Fatal error: Wrong SQL: SELECT * FROM userinfo WHERE ip = my_real_ip Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.103.25' at line 1 in /home/appunloc/domain/folder/index.php on line 10

How to get the link from a file in File Manager from different hosting

I want to get the direct link from the file in my other hosting. Is this possible? Or i must buy domain name and upload the files there to get the link?

I will use this hosting to upload videos and link to them from my website. This way ill have more faster website

I have created folder in my File Manager cPanel tool named videos and there are the videos that i want to link to my website. But i dont know how to get the direct link from the .mp4 file

How to insert returned sql column values in array PHP

I want to insert the returned values into an array and after to display random string
I have this code by it doesn't return back a random value

Inside the vid1,vid2,vid3 columsn there is Video Name text that pointing to the video in my File Manager folder

$sql = "SELECT vid1, vid2, vid3 FROM table WHERE ID = 2";
$result = $conn->query($sql);
if(!$result) {
    echo "Something went wrong, please try again.";
} else {
    if($result->num_rows == 0){
        echo "Something went wrong, please try again.";
        exit();
    } else if($result->num_rows >= 1) {
        while($row = $result->fetch_assoc()) {
            $vid1 = $row['vid1'];
            $vid2 = $row['vid2'];
            $vid3 = $row['vid3'];
        }
    }
}

$videos  = array(
    $vid1,
    $vid2,
    $vid3
);

$video_to_play = $videos[array_rand($videos)];

And When i hardcode it like this it works. but i am not selecting from the database here.

$videos  = array(
        'video/202212060125.mp4',
        'video/202212060148.mp4',
        'video/202212060152.mp4'
    );

$video_to_play = $videos[array_rand($videos)];

Is this good practice for SEO?

Just came to my mind this and i like to ask others about it. So i have website that have auto generated content on the pages.
The text it self is all the same but only some variables changing like (names, tags, pictures). So i was wondering is it good practice for SEO purposes, to make the text content change for some KEY keywords.
For example.
DaniWeb was founded in 2002 by Dani, who, at that time, was pursuing a computer science degree on Long Island, New York, and began gaining widespread attention throughout the search engine optimization industry in 2005.

On the second refresh to be something like this.
DaniWeb is founded in 2002 by Dani, which was pursuing a computer science degree on Long Island, New York and started to gain widespread attention throughout the SEO industry in 2005.

The above is just an example to get my point.

But i have on my website key keywords that users will search on google.
I plan to do this in the title & text also. But as i said only for some KEY keywords
Keyword: [UPDATED] -> [NEW], [LATEST], [RECENTLY]
Keyword: [LEAKED] -> [LEAKS], [HACKED], [HACK]
and so on...

How to create sitemap for +150k links

iI was searching the online "free/cheap" generators and i found out that they are not so cheap...
They advertise the PRO plan for just $3 and when i came to the checkout page it was $1800
So is there other free tool for this job or how do i manually create the sitemap my self. I read on google that one sitemap file should contain no more than 50k links. So in this case i should create sitemap index file.

Any recommendations ?

How to remove URL parameter php

I have a domain that looks like this when i visit certain link https://domain.com/model-profile/index.php?name=abbychampion
the site is written in php but i dont want to show this part index.php?name= because for SEO purposes and better human reading.
Is this possible to hide ? so the link looks like this https://domain.com/model-profile/abbychampion

PHP get string text from other website

I want to get a string from different website and to display on mine.

The website have this HTML code inside it

<ul data-v-61cbae47="" class="b-tabs__nav m-tabs-default m-flex-width m-size-md m-mb-reset js-tabs-switchers m-over-separator">
   <li data-v-61cbae47="" class="b-tabs__nav__item m-current"><a data-v-61cbae47="" href="/jenawolfy" aria-current="page" class="b-tabs__nav__link m-with-rectangle-hover m-tb-sm router-link-exact-active router-link-active" id="profilePostTab"><span data-v-61cbae47="" class="b-tabs__nav__link__counter-title">130 posts</span></a></li>
   <li data-v-61cbae47="" class="b-tabs__nav__item"><a data-v-61cbae47="" href="/jenawolfy/media" class="b-tabs__nav__link m-with-rectangle-hover m-tb-sm"><span data-v-61cbae47="" class="b-tabs__nav__link__counter-title">132 Media</span></a></li>
   <!---->
</ul>

I want to get only these two strings 130 posts & 132 Media and to display on my website whenever is opened.

Is this possible to make in PHP or i need different language like python?

PHP display only NOT empty rows

I am trying to make to display cells in a database that are not empty, i have URL links with images inside the table and i want to display only the cells that are not empty.

For example if there is only 2 pictures added in the database i want to display only those 2, and not the rest 3 with no images

I have this code but its going on forever and its crashing my browser.

<?php
$sql = "SELECT pic1, pic2, pic3, pic4, pic5 FROM modelprofile WHERE name='$name'";
$result = $conn->query($sql);

if($result === false) {
    trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
} else {
    while($row = $result->fetch_assoc()) {
        $pic1 = $row["pic1"];
        $pic2 = $row["pic2"];
        $pic3 = $row["pic3"];
        $pic4 = $row["pic4"];
        $pic5 = $row["pic5"];
        while(!empty($row)) {


        ?>
        <img class="card-img-top" src="<?= $pic1 ?>" alt="">
        <br><br>
        <img class="card-img-top" src="<?= $pic2 ?>" alt="">
        <br><br>
        <img class="card-img-top" src="<?= $pic3 ?>" alt="">
        <br><br>
        <img class="card-img-top" src="<?= $pic4 ?>" alt="">
        <br><br>
        <img class="card-img-top" src="<?= $pic5 ?>" alt="">
        <br><br><br>

        <?php
        }
    }
}
?>

PHP insert into table

I am trying to insert into table with PHP and MySQL but the page only refresh it self when i press the button.

I haven't done debugging, i have an IF statement that displays any errors that fires if the SQL query have errors. But the thing is even the trigger_error doesnt return anything back to me so i can see whats the problem is.

I never come to this kind of problem before and i have no left ideas in my head so i can fix this.

`

<?php

        if(isset($_POST["submitGirl"])) {
            $name = $_POST['girlName'];
            $url = $_POST['instaProfLink'];
            $profilepic = $_POST['profilepic'];
            $pic1 = $_POST["pic1"];
            $pic2 = $_POST["pic2"];
            $pic3 = $_POST["pic3"];
            $pic4 = $_POST["pic4"];
            $pic5 = $_POST["pic5"];
            $tags = $_POST["tags"];

            $sql = "INSERT INTO modelprofile VALUES ('', '".htmlentities($name)."', '".htmlentities($url)."', '".htmlentities($profilepic)."', '".htmlentities($pic1)."', '".htmlentities($pic2)."', '".htmlentities($pic3)."', '".htmlentities($pic4)."', '".htmlentities($pic5)."', '".htmlentities($tags)."')";
            $result = $conn->query($sql);
            if($result === false) {
                trigger_error("A required file did not exist!", E_USER_ERROR);
                trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
            } else {
                echo "model added";
            }
        }
    ?>

submitGirl is the name of the button. When user press, it should add the rest info into database table, from the fields above