Oyunda Gönderilen Bağırmaları Sitede Göster

Exatluen

Level 1
Katılım
29 Eyl 2024
Konular
78
Mesajlar
242
Beğeniler
273
GG Coin
6,426
Ticaret Değeri - 0%
0   0   0
Sitenizin herhangi bir alanında oyun içi sohbetleri (bağırmaları) gösterebilirsiniz. Ancak, anlık sorguların veritabanını aşırı yükleyeceği için bu işlemi bir cache sistemi ile optimize ettim. Bu sistem, 5 dakikada bir yeni kayıt alacak şekilde çalışır. Kullanıcılar, ana dizinde bir cache klasörü oluşturmalı ve buna uygun bir cron job eklemelidir.

Bu sistem, son 10 konuşmayı gösterecek şekilde yapılandırılmıştır ve her bir konuşma, krallık bayrağı ve karakter detayları ile birlikte görüntülenecektir.

1738077252539.png


Kod:
<?php
$filenamesohbet = "anasayfa-sohbet.html";
$cachefilesohbet = "cache/".$filenamesohbet;
$cachetimesohbet = 5 * 5; // Cache Süresi
if (!(file_exists($cachefilesohbet)) || time() - $cachetimesohbet > filemtime($cachefilesohbet))
{
ob_start();
mysql_select_db("log");
?>

<?php

        mysql_select_db('log'); //  DB seçimi 'player'
        mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_turkish_ci'");
    $test = "SELECT * from shout_log";
        $testquery = mysql_query($test);
            $num2 = mysql_num_rows($testquery);

        if($_GET['max']) {
            $get = $_GET['max'];
        } else {
        $get = '0';
?>

<?php
        mysql_select_db('log'); // Select DB 'player'
        mysql_query("SET NAMES 'utf8'");
        mysql_query("SET CHARACTER SET utf8");
        mysql_query("SET COLLATION_CONNECTION = 'utf8_turkish_ci'");
// Select player etc from db //
    $rank = "SELECT * from shout_log WHERE channel NOT LIKE '[%]%' order by time desc limit $get,10";
        $query = mysql_query($rank);
    echo "<ul>"; // Table başı
    $i = 0;
 
            while($array = mysql_fetch_array($query)) {
                $i = $i + 1;
              
                echo "<tr>";
                echo "<td>CH " . $array["channel"] . "</td>";
                echo "<td>" . $array["time"] . "</td>";
                echo "<td><img src='images/empire" . $array["empire"] . ".png'></td>";
                echo "<td>" . $array["shout"] . "</td>";
                echo "</tr>";
                }
    echo "</ul>"; // table sonu
 
}
?>
<?php
$fp = fopen($cachefilesohbet, 'w+');
fwrite($fp, ob_get_contents());
fclose($fp);
ob_end_flush();
}
else
{
readfile($cachefilesohbet);
}
?>
 
Geri
Üst Alt