[Znote AAC] Front page Server Info box

Discussion in 'Website Applications' started by Znote, Mar 5, 2014.

  1. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,361
    Likes Received:
    1,058
    Best Answers:
    148
    [​IMG]
    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 (Text):
    1. include 'layout/overall/header.php';
    add:
    PHP:
    1.  
    2. // Front page server information box by Raggaer. Improved by Znote. (Using cache system and Znote SQL functions)
    3. // Create a cache system
    4. $infoCache = new Cache('engine/cache/serverInfo');
    5. $infoCache->setExpiration(60); // This will be a short cache (60 seconds)
    6. if ($infoCache->hasExpired()) {
    7.  
    8.     // Fetch data from database
    9.     $data = array(
    10.         'newPlayer' => mysql_select_single("SELECT `name` FROM `players` ORDER BY `id` DESC LIMIT 1"),
    11.         'bestPlayer' => mysql_select_single("SELECT `name`, `level` FROM `players` ORDER BY `experience` DESC LIMIT 1"),
    12.         'playerCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `players`"),
    13.         'accountCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `accounts`"),
    14.         'guildCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `guilds`")
    15.     );
    16.  
    17.     // Initiate default values where needed
    18.     if ($data['playerCount'] !== false && $data['playerCount']['count'] > 0) $data['playerCount'] = $data['playerCount']['count'];
    19.     else $data['playerCount'] = 0;
    20.     if ($data['accountCount'] !== false && $data['accountCount']['count'] > 0) $data['accountCount'] = $data['accountCount']['count'];
    21.     else $data['accountCount'] = 0;
    22.     if ($data['guildCount'] !== false && $data['guildCount']['count'] > 0) $data['guildCount'] = $data['guildCount']['count'];
    23.     else $data['guildCount'] = 0;
    24.  
    25.     // Store data to cache
    26.     $infoCache->setContent($data);
    27.     $infoCache->save();
    28. } else {
    29.     // Load data from cache
    30.     $data = $infoCache->load();
    31. }
    32. ?>
    33.  
    34. <!-- Render HTML for server information -->
    35. <table border="0" cellspacing="0">
    36.     <tr class="yellow">
    37.         <td><center>Server Information</center></td>
    38.     </tr>
    39.     <tr>
    40.         <td>
    41.             <center>Welcome to our newest player:
    42.                 <a href="characterprofile.php?name=<?php echo $data['newPlayer']['name']; ?>">
    43.                     <?php echo $data['newPlayer']['name']; ?>
    44.                 </a>
    45.             </center>
    46.         </td>
    47.     </tr>
    48.     <tr>
    49.         <td>
    50.             <center>The best player is:
    51.                 <a href="characterprofile.php?name=<?php echo $data['bestPlayer']['name']; ?>">
    52.                     <?php echo $data['bestPlayer']['name']; ?>
    53.                 </a> level: <?php echo $data['bestPlayer']['level']; ?> congratulations!
    54.             </center>
    55.         </td>
    56.     </tr>
    57.     <tr>
    58.         <td>
    59.             <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>
    60.         </td>
    61.     </tr>
    62. </table>
    63.  
    Enjoy.
     
    Last edited: Mar 6, 2014
    Purple Cow, MartyX and Printer like this.
  2. Raggaer

    Raggaer Godly Member

    Joined:
    Jul 25, 2012
    Messages:
    1,521
    Likes Received:
    865
    Best Answers:
    8
  3. gremlee

    gremlee Qumora.com

    Joined:
    Jul 15, 2008
    Messages:
    512
    Likes Received:
    16
    Best Answers:
    0
  4. Cornex

    Cornex Web Developer Staff Member Global Moderator

    Joined:
    Jun 15, 2008
    Messages:
    3,443
    Likes Received:
    1,157
    Best Answers:
    4
  5. Raggaer

    Raggaer Godly Member

    Joined:
    Jul 25, 2012
    Messages:
    1,521
    Likes Received:
    865
    Best Answers:
    8
    Its quite old, didnt even know znote had custom mysql functions, I even think it doesnt
     
  6. Olddies

    Olddies Tibiana 7.1 Owner

    Joined:
    Nov 21, 2009
    Messages:
    551
    Likes Received:
    71
    Best Answers:
    0
    this not working for znote TFS 1.0?
     
  7. HalfAway

    HalfAway #1

    Joined:
    Sep 3, 2011
    Messages:
    3,604
    Likes Received:
    2,330
    Best Answers:
    15
    Thanks, good job.
     
  8. Raggaer

    Raggaer Godly Member

    Joined:
    Jul 25, 2012
    Messages:
    1,521
    Likes Received:
    865
    Best Answers:
    8
    Use the one znote posted :3
     
  9. Olddies

    Olddies Tibiana 7.1 Owner

    Joined:
    Nov 21, 2009
    Messages:
    551
    Likes Received:
    71
    Best Answers:
    0
    i need use the znote 1.5 for tfs 1.0 if it possible to use or what i need to edit?
     
  10. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,361
    Likes Received:
    1,058
    Best Answers:
    148
    This should work on all versions.
     
  11. Olddies

    Olddies Tibiana 7.1 Owner

    Joined:
    Nov 21, 2009
    Messages:
    551
    Likes Received:
    71
    Best Answers:
    0
    it dont work when i click on reload news its become a blank page
     
  12. lopez65

    lopez65 Member

    Joined:
    May 10, 2012
    Messages:
    231
    Likes Received:
    10
    Best Answers:
    0
    Hello Znote
    I wanted to ask if Znote 1.5 svn version is the latest, stable or is there any better, because I try to do almost all always gives me some kind of error, perhaps not be the damn windows 7 pro 64bit the cause of it all?
    Greetings friend
     
  13. HalfAway

    HalfAway #1

    Joined:
    Sep 3, 2011
    Messages:
    3,604
    Likes Received:
    2,330
    Best Answers:
    15
    1.5 is mostly for TFS 1.0
    1.4 works for everything else expect TFS 1.0

    And whats the error?
     
  14. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,361
    Likes Received:
    1,058
    Best Answers:
    148
    Znote AAC 1.5 is not officially released(but available at github) because Mark have not released an official TFS 1.0 distribution, when he does you can expect Znote AAC 1.5 to come shortly after with full TFS 1.0 support. (As well as normal support for previous versions).

    Znote AAC 1.5 should also be compatible with PHP 5.5, 1.4 supports 5.4 as highest version.

    1.5 pretty much works on all versions, while 1.4 works for 0.2 and 0.3/4
     
  15. lopez65

    lopez65 Member

    Joined:
    May 10, 2012
    Messages:
    231
    Likes Received:
    10
    Best Answers:
    0
    and Halfaway:

    this clear, I'm using a 1.0 rl map 10.30 tfs client 64 bits, and I'm trying to see if it's worth it online
    but the issue is quesi works, it's just that when I put some scripts, not installed well and if I use the version 1.4 gives me error with tfs 1.0, this is a crossroads xDD.

    Anyway I ye clarified my doubts and I thank consumption especially your Znote Thanks for answering both companions and greetings, I will try to test another tfs. Greetings friends and thanks again
     
  16. Ray Rewind

    Ray Rewind Doctor

    Joined:
    Jun 6, 2009
    Messages:
    1,349
    Likes Received:
    74
    Best Answers:
    0

    I have the same problem you fixed it ?


    the code gets white

    @Znote
    if I do the steps you say I whiten the part of the isset! [​IMG]
     
  17. Fanges

    Fanges New Member

    Joined:
    Jul 5, 2014
    Messages:
    27
    Likes Received:
    4
    Best Answers:
    0
    I got the problem solved:
    PHP:
    1. // Front page server information box by Raggaer. Improved by Znote. (Using cache system and Znote SQL functions)
    2. // Create a cache system
    3. $infoCache = new Cache('engine/cache/serverInfo');
    4. $infoCache->setExpiration(60); // This will be a short cache (60 seconds)
    5. if ($infoCache->hasExpired()) {
    6.  
    7.     // Fetch data from database
    8.     $data = array(
    9.         'newPlayer' => mysql_select_single("SELECT `name` FROM `players` ORDER BY `id` DESC LIMIT 1"),
    10.         'bestPlayer' => mysql_select_single("SELECT `name`, `level` FROM `players` ORDER BY `experience` DESC LIMIT 1"),
    11.         'playerCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `players`"),
    12.         'accountCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `accounts`"),
    13.         'guildCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `guilds`")
    14.     );
    15.  
    16.     // Initiate default values where needed
    17.     if ($data['playerCount'] !== false && $data['playerCount']['count'] > 0) $data['playerCount'] = $data['playerCount']['count'];
    18.     else $data['playerCount'] = 0;
    19.     if ($data['accountCount'] !== false && $data['accountCount']['count'] > 0) $data['accountCount'] = $data['accountCount']['count'];
    20.     else $data['accountCount'] = 0;
    21.     if ($data['guildCount'] !== false && $data['guildCount']['count'] > 0) $data['guildCount'] = $data['guildCount']['count'];
    22.     else $data['guildCount'] = 0;
    23.  
    24.     // Store data to cache
    25.     $infoCache->setContent($data);
    26.     $infoCache->save();
    27. } else {
    28.     // Load data from cache
    29.     $data = $infoCache->load();
    30. }
    31. ?>
    32.  
    33. <!-- Render HTML for server information -->
    34. <table border="0" cellspacing="0">
    35.     <tr class="yellow">
    36.         <td><center>Server Information</center></td>
    37.     </tr>
    38.     <tr>
    39.         <td>
    40.             <center>Welcome to our newest player:
    41.                 <a href="characterprofile.php?name=<?php echo $data['newPlayer']['name']; ?>">
    42.                     <?php echo $data['newPlayer']['name']; ?>
    43.                 </a>
    44.             </center>
    45.         </td>
    46.     </tr>
    47.     <tr>
    48.         <td>
    49.             <center>The best player is:
    50.                 <a href="characterprofile.php?name=<?php echo $data['bestPlayer']['name']; ?>">
    51.                     <?php echo $data['bestPlayer']['name']; ?>
    52.                 </a> level: <?php echo $data['bestPlayer']['level']; ?> congratulations!
    53.             </center>
    54.         </td>
    55.     </tr>
    56.     <tr>
    57.         <td>
    58.             <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>
    59.         </td>
    60.     </tr>
    61. </table>
    62. <?php
    If you look on the last line in the php script, it didn't reopen the php line, now it does.
     
    Amiroslo and lopez65 like this.
  18. Fanges

    Fanges New Member

    Joined:
    Jul 5, 2014
    Messages:
    27
    Likes Received:
    4
    Best Answers:
    0
    And i've also made another edit in the script:

    PHP:
    1.         'bestPlayer' => mysql_select_single("SELECT `name`, `level` FROM `players` ORDER BY `experience` DESC LIMIT 1"),
    to:
    PHP:
    1.  'bestPlayer' => mysql_select_single('SELECT `name`, `level`, `experience` FROM `players` WHERE `group_id` < ' . $config['highscore']['ignoreGroupId'] . ' ORDER BY `experience` DESC LIMIT 1;'),
    This is because the "god/admin" with a high lvl also gets count in the exp.

    PHP:
    1. <?php require_once 'engine/init.php'; include 'layout/overall/header.php'; // Front page server information box by Raggaer. Improved by Znote. (Using cache system and Znote SQL functions)
    2. // Create a cache system
    3. $infoCache = new Cache('engine/cache/serverInfo');
    4. $infoCache->setExpiration(60); // This will be a short cache (60 seconds)
    5. if ($infoCache->hasExpired()) {
    6.  
    7.     // Fetch data from database
    8.     $data = array(
    9.         'newPlayer' => mysql_select_single("SELECT `name` FROM `players` ORDER BY `id` DESC LIMIT 1"),
    10.         'bestPlayer' => mysql_select_single('SELECT `name`, `level`, `experience` FROM `players` WHERE `group_id` < ' . $config['highscore']['ignoreGroupId'] . ' ORDER BY `experience` DESC LIMIT 1;'),
    11.         'playerCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `players`"),
    12.         'accountCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `accounts`"),
    13.         'guildCount' => mysql_select_single("SELECT COUNT(`id`) as `count` FROM `guilds`")
    14.     );
    15.  
    16.     // Initiate default values where needed
    17.     if ($data['playerCount'] !== false && $data['playerCount']['count'] > 0) $data['playerCount'] = $data['playerCount']['count'];
    18.     else $data['playerCount'] = 0;
    19.     if ($data['accountCount'] !== false && $data['accountCount']['count'] > 0) $data['accountCount'] = $data['accountCount']['count'];
    20.     else $data['accountCount'] = 0;
    21.     if ($data['guildCount'] !== false && $data['guildCount']['count'] > 0) $data['guildCount'] = $data['guildCount']['count'];
    22.     else $data['guildCount'] = 0;
    23.  
    24.     // Store data to cache
    25.     $infoCache->setContent($data);
    26.     $infoCache->save();
    27. } else {
    28.     // Load data from cache
    29.     $data = $infoCache->load();
    30. }
    31. ?>
     
    Purple Cow likes this.
  19. simson361

    simson361 The Grim Reaper

    Joined:
    Aug 4, 2010
    Messages:
    627
    Likes Received:
    27
    Best Answers:
    0
    update link please! <3
     
  20. Ray Rewind

    Ray Rewind Doctor

    Joined:
    Jun 6, 2009
    Messages:
    1,349
    Likes Received:
    74
    Best Answers:
    0

    thanks works :)!
     

Share This Page

Loading...