[Znote AAC] Staff support list

Discussion in 'Website Applications' started by cbrm, Oct 8, 2012.

  1. cbrm

    cbrm Just another mod Staff Member Global Moderator

    Joined:
    Jan 6, 2009
    Messages:
    6,537
    Likes Received:
    828
    Best Answers:
    0
    Preview:
    [​IMG]

    support.php
    If you use a TFS 0.2 distribution, use:
    PHP:
    1. <?php
    2. #    TFS 0.2 Support List for ZnoteAAC
    3. #    By cbrm @ otland.net
    4. #    Credits to: AchTung, Zonet
    5.  
    6. require_once 'engine/init.php'; include 'layout/overall/header.php';
    7. $groups = array(2 => 'Gamemaster', 3 => 'God');
    8. echo'<h1>Support in game</h1>';
    9. $list = mysql_query('SELECT `name`, `online`, `group_id` FROM `players` WHERE `group_id` > 1 ORDER BY `group_id` DESC');
    10. while ($row = mysql_fetch_assoc($list)) {$data[] = $row;}
    11. if (empty($data)) {echo 'This server is ruled by the players.'; return include 'layout/overall/footer.php';}
    12. $headline = '<table>
    13.            <tr class="yellow"><td width="30%"><strong>Group</strong></td>
    14.            <td width="40%"><strong>Name</strong></td>
    15.            <td width="30%"><strong>Status</strong></td>';        
    16. $group_id = 0;
    17. foreach($data as $staff)
    18. {
    19.     if($group_id != (int)$staff['group_id'])
    20.     {
    21.         if($group_id != 0) echo '</table>'; echo $headline; $group_id = (int)$staff['group_id'];
    22.     }
    23.     echo '<tr><td>'.$groups[(int)$staff['group_id']].'</td>';
    24.     echo '<td><a href="characterprofile.php?name='.$staff['name'].'">'.$staff['name'].'</a></td>';
    25.     echo '<td><span style="color:'.($staff['online'] == 0 ?  'red;">Offline':'green;">Online').'</span></td></tr>';
    26. }
    27. echo'</table>'; include 'layout/overall/footer.php'; ?>
    If you use a TFS 0.3 distribution, use:
    PHP:
    1. <?php
    2. #    TFS 0.3 Support List for ZnoteAAC
    3. #    By cbrm @ otland.net
    4. #    Credits to: AchTung, Zonet
    5.  
    6. require_once 'engine/init.php'; include 'layout/overall/header.php';
    7. $groups = array(2 => 'Tutor', 3 => 'Senior Tutor', 4 => 'Gamemaster', 5 => 'Community Manager', 6 => 'God');
    8. $worlds = array(0 => 'Server1', 1 => 'Server2');
    9. echo'<h1>Support in game</h1>';
    10. $list = mysql_query('SELECT `name`, `online`, `group_id`, `world_id`  FROM `players` WHERE `group_id` > 1 ORDER BY `group_id` DESC');
    11. while ($row = mysql_fetch_assoc($list)) {$data[] = $row;}
    12. if (empty($data)) {echo 'This server is ruled by the players.'; return include 'layout/overall/footer.php';}
    13. $headline = '<table>
    14.            <tr class="yellow"><td width="30%"><strong>Group</strong></td>
    15.            <td width="30%"><strong>Name</strong></td>
    16.            <td width="20%"><strong>Status</strong></td>
    17.            <td width="20%"><strong>World</strong></td>';        
    18. $group_id = 0;
    19. foreach($data as $staff)
    20. {
    21.     if($group_id != (int)$staff['group_id'])
    22.     {
    23.         if($group_id != 0) echo '</table>'; echo $headline; $group_id = (int)$staff['group_id'];
    24.     }
    25.     echo '<tr><td>'.$groups[(int)$staff['group_id']].'</td>';
    26.     echo '<td><a href="characterprofile.php?name='.$staff['name'].'">'.$staff['name'].'</a></td>';
    27.     echo '<td><span style="color:'.($staff['online'] == 0 ?  'red;">Offline':'green;">Online').'</span></td>';
    28.     echo '<td>'.$worlds[(int)$staff['world_id']].'</td></tr>';
    29. }
    30. echo'</table>'; include 'layout/overall/footer.php'; ?>
    Configure your groups' names based on group id at:
    PHP:
    1. $groups = array(2 => 'Gamemaster', 3 => 'God');
    PHP:
    1. $groups = array(2 => 'Tutor', 3 => 'Senior Tutor', 4 =>  'Gamemaster', 5 => 'Community Manager', 6 => 'God');

    For TFS 0.3 configure worlds' names at:
    PHP:
    1. $worlds = array(0 => 'Server1', 1 => 'Server2');

     
    Last edited: Oct 9, 2012
    gerard95 and 4Muki4 like this.
  2. Collz

    Collz Pandas Go RAWR!!!

    Joined:
    Oct 10, 2008
    Messages:
    2,091
    Likes Received:
    57
    Best Answers:
    0
    Good to see some more features for Znote AAC! Now people have options to choose from.
     
  3. 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 script works for both TFS 0.2 and 0.3, using only values from config.php

    /engine/function/users.php
    add:
    PHP:
    1. // Support list
    2. function support_list() {
    3.     $TFS = Config('TFSVersion');
    4.     $query = mysql_query("SELECT `group_id`, `name`, `online`, `account_id` FROM `players` WHERE `group_id` > 1 ORDER BY `group_id` ASC;");
    5.     while ($row = mysql_fetch_assoc($query)) {
    6.         if ($TFS == 'TFS_02') {
    7.             $ACCquery = mysql_query("SELECT `type` FROM `accounts` WHERE `id` ='". $row['account_id'] ."';") or die(mysql_error());
    8.             $ACCrow = mysql_fetch_assoc($ACCquery);
    9.             $row['group_id'] = $ACCrow['type'];
    10.             unset($ACCrow);
    11.         }
    12.         unset($row['account_id']);
    13.         $array[] = $row;
    14.     }
    15.     if (isset($array)) {return $array; } else {return false;}
    16. }
    Then add page support.php in root directory:
    PHP:
    1. <?php require_once 'engine/init.php'; include 'layout/overall/header.php';
    2. ?><h1>Support in-game</h1><?php
    3. $cache = new Cache('engine/cache/support');
    4. if ($cache->hasExpired()) {
    5.     // Fetch all staffs in-game.
    6.     $staffs = support_list();
    7.     // Fetch group ids and names from config.php
    8.     $groups = $config['ingame_positions'];
    9.     // Loops through groups, separating each group element into an ID variable and name variable
    10.     foreach ($groups as $group_id => $group_name) {
    11.         // Loops through list of staffs
    12.         foreach ($staffs as $staff) {
    13.             if ($staff['group_id'] == $group_id) $srtGrp[$group_name][] = $staff;
    14.         }
    15.     }
    16.     if (!empty($srtGrp)) {
    17.         $cache->setContent($srtGrp);
    18.         $cache->save();
    19.     }
    20. } else {
    21.     $srtGrp = $cache->load();
    22. }
    23. $writeHeader = true;
    24. if (!empty($srtGrp)) {
    25.     foreach (array_reverse($srtGrp) as $grpName => $grpList) {
    26.         ?>
    27.         <table>
    28.             <?php if ($writeHeader) {
    29.             $writeHeader = false; ?>
    30.             <tr class="yellow">
    31.                 <td width="30%">Group</td>
    32.                 <td width="40%">Name</td>
    33.                 <td width="30%">Status</td>
    34.             </tr>
    35.             <?php
    36.             }
    37.             foreach ($grpList as $char) {
    38.                 if ($char['name'] != $config['website_char']) {
    39.                     echo '<tr>';
    40.                     echo "<td width='30%'>". $grpName ."</td>";
    41.                     echo '<td width="40%"><a href="characterprofile.php?name='. $char['name'] .'">'. $char['name'] .'</a></td>';
    42.                     echo "<td width='30%'>". online_id_to_name($char['online']) ."</td>";
    43.                     echo '</tr>';
    44.                 }
    45.             }
    46.             ?>
    47.         </table>
    48.         <?php
    49.     }
    50. }
    51. echo'</table>'; include 'layout/overall/footer.php'; ?>
    This system is cached, so it only does queries toward the database very rarely.

    Configure group names in config.php:
    PHP:
    1. $config['ingame_positions'] = array(
    2.         1 => 'Player',
    3.         2 => 'Tutor',
    4.         3 => 'Gamemaster',
    5.         4 => 'Community Manager',
    6.         5 => 'God',
    7.     );
    [​IMG]
     
    Last edited: Nov 10, 2012
    simson361 likes this.
  4. Clorens

    Clorens Member

    Joined:
    Oct 5, 2011
    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Nvm... Fixed it
     
    Last edited: Apr 7, 2013
  5. Tarek1337

    Tarek1337 Well-Known Member

    Joined:
    Jun 9, 2012
    Messages:
    3,556
    Likes Received:
    1,129
    Best Answers:
    3
    Have time to update it to TFS 1.2? :p
     
  6. HalfAway

    HalfAway Well-Known Member

    Joined:
    Sep 3, 2011
    Messages:
    3,581
    Likes Received:
    2,309
    Best Answers:
    15
  7. pierroth

    pierroth Mar Co.

    Joined:
    Sep 11, 2008
    Messages:
    344
    Likes Received:
    9
    Best Answers:
    0
    @Znote,

    Is it suppose to show GM/Gods that are offline as well? (Your image is broken, so I cant see). Anyways, in my page, it doesn't show offline.
     
  8. HalfAway

    HalfAway Well-Known Member

    Joined:
    Sep 3, 2011
    Messages:
    3,581
    Likes Received:
    2,309
    Best Answers:
    15
    Use the one that comes with ZnoteAAC by default, shows both offline and online support members.
     
    pierroth likes this.
  9. Jfrye

    Jfrye Mapper, trying to learn scripting Premium User

    Joined:
    Jan 8, 2009
    Messages:
    348
    Likes Received:
    78
    Best Answers:
    6
    I cant get this to say anything other than Community Manager. I have a God char, yet it only shows online as Community manager. I have tried making different changes in the current scripts, and tried changing scripts around, but I cannot get this changed. Any ideas of where I can look?
     
  10. Peonso

    Peonso 1337

    Joined:
    Jan 14, 2008
    Messages:
    1,281
    Likes Received:
    765
    Best Answers:
    16
    config.php
     
  11. Jfrye

    Jfrye Mapper, trying to learn scripting Premium User

    Joined:
    Jan 8, 2009
    Messages:
    348
    Likes Received:
    78
    Best Answers:
    6
    Wow. I see the error. I guess everyone was set as groupID 5, when it should have been 6. Thank you for pointing me to the file. I looked through it and found my error.
     
  12. Peonso

    Peonso 1337

    Joined:
    Jan 14, 2008
    Messages:
    1,281
    Likes Received:
    765
    Best Answers:
    16
    It depends on server.
     
  13. Jfrye

    Jfrye Mapper, trying to learn scripting Premium User

    Joined:
    Jan 8, 2009
    Messages:
    348
    Likes Received:
    78
    Best Answers:
    6
    Im using TFS 1.1. Once I changed the IDs to 6, it is working just as it should.
     
  14. Bica

    Bica Member

    Joined:
    Jul 22, 2009
    Messages:
    559
    Likes Received:
    20
    Best Answers:
    0
    Hey @Znote i'm using tfs 1.2, this script will work ?
     

Share This Page

Loading...