• 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!

[Znote AAC] Front page Server Info box

OcOlrk.png

Originally coded by @Raggaer Demo: http://www.qumora.com/index.php
Improoved by me, adding cache system and Znote SQL functions.

Add to index.php after:
Code:
include 'layout/overall/header.php';
add:
PHP:
// Front page server information box by Raggaer. Improved by Znote. (Using cache system and Znote SQL functions)
// Create a cache system
$infoCache = new Cache('engine/cache/serverInfo');
$infoCache->setExpiration(60); // This will be a short cache (60 seconds)
if ($infoCache->hasExpired()) {

    // Fetch data from database
    $data = array(
        'newPlayer' => mysql_select_single("SELECT `name` FROM `players` ORDER BY `id` DESC LIMIT 1"),
        'bestPlayer' => mysql_select_single("SELECT `name`, `level` FROM `players` ORDER BY `experience` DESC LIMIT 1"),
        'playerCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `players`"),
        'accountCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `accounts`"),
        'guildCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `guilds`")
    );

    // Initiate default values where needed
    if ($data['playerCount'] !== false && $data['playerCount']['count'] > 0) $data['playerCount'] = $data['playerCount']['count'];
    else $data['playerCount'] = 0;
    if ($data['accountCount'] !== false && $data['accountCount']['count'] > 0) $data['accountCount'] = $data['accountCount']['count'];
    else $data['accountCount'] = 0;
    if ($data['guildCount'] !== false && $data['guildCount']['count'] > 0) $data['guildCount'] = $data['guildCount']['count'];
    else $data['guildCount'] = 0;

    // Store data to cache
    $infoCache->setContent($data);
    $infoCache->save();
} else {
    // Load data from cache
    $data = $infoCache->load();
}
?>

<!-- Render HTML for server information -->
<table border="0" cellspacing="0">
    <tr class="yellow">
        <td><center>Server Information</center></td>
    </tr>
    <tr>
        <td>
            <center>Welcome to our newest player:
                <a href="characterprofile.php?name=<?php echo $data['newPlayer']['name']; ?>">
                    <?php echo $data['newPlayer']['name']; ?>
                </a>
            </center>
        </td>
    </tr>
    <tr>
        <td>
            <center>The best player is:
                <a href="characterprofile.php?name=<?php echo $data['bestPlayer']['name']; ?>">
                    <?php echo $data['bestPlayer']['name']; ?>
                </a> level: <?php echo $data['bestPlayer']['level']; ?> congratulations!
            </center>
        </td>
    </tr>
    <tr>
        <td>
            <center>We have <b><?php echo $data['accountCount']; ?></b> accounts in our database, <b><?php echo $data['playerCount']; ?></b> players, and <b><?php echo $data['guildCount']; ?></b> guilds </center>
        </td>
    </tr>
</table>

Enjoy.
I made everything as you said and it doesn't work after then i tried to put <?php before
<?php

if (!isset($_GET['page'])) {
And its appeared on website but i got 2 problems now
Website doesn't load highest level from database and when i tried to up level or down level of this character nothing changed on it, I think i can't explain what is the problem but i will show you it by photos
jg72go.jpg

Only account What ever appear on site and when i tried to up level for another character it doesn't changed too
4t0htx.jpg

Index.php
https://gist.github.com/Sasooo/3a8b5cf71b31980bb2af
TFS 0.3.6
 
I made everything as you said and it doesn't work after then i tried to put <?php before
<?php

if (!isset($_GET['page'])) {
And its appeared on website but i got 2 problems now
Website doesn't load highest level from database and when i tried to up level or down level of this character nothing changed on it, I think i can't explain what is the problem but i will show you it by photos
jg72go.jpg

Only account What ever appear on site and when i tried to up level for another character it doesn't changed too
4t0htx.jpg

Index.php
https://gist.github.com/Sasooo/3a8b5cf71b31980bb2af
TFS 0.3.6
lvl is high but the experience?
ORDER BY `experience`
 
Hmm how do I make this only for the Homepage? Cuz now I have it on highscores etc and It would be really nice only on the Homepage :) And how can I add topFragger?
 
Last edited:
Back
Top