[Znote AAC] Account VIP list (TFS 0.3)

cbrm

Just another mod
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,550
Best answers
1
Likes
802
Location
Caribbean Sea
#1
Preview:



Edit /layout/widgets/loggedin.php

Below:

PHP:
            <li>
                <a href='myaccount.php'>My Account</a>
            </li>

Add:

PHP:
            <li>
                <a href='friends.php'>My Friends</a>
            </li>
friends.php
PHP:
<?php 
#    TFS 0.3 VIP Friends for ZnoteAAC
#    By cbrm @ otland.net

require_once 'engine/init.php';
protect_page();
include 'layout/overall/header.php';

echo'<h1>VIP Friends</h1>';
$vip = mysql_query('SELECT 
                        p.name AS name, p.id AS id, p.online AS online, player_id 
                    FROM 
                        account_viplist
                    LEFT JOIN 
                        players p ON account_viplist.player_id = p.id
                    WHERE
                        account_viplist.account_id = '.$user_data['id'].'
                    ORDER BY
                        name, online ASC LIMIT 0,100');
while ($row = mysql_fetch_assoc($vip)) {$data[] = $row;}
if (empty($data)) {echo 'You VIP list is empty.'; return include 'layout/overall/footer.php';}
?>

<table><tr class="yellow"><td width="60%"><strong>Name</strong></td><td width="40%"><strong>Status</strong></td></tr>

<?php
foreach($data as $friend)
{
    echo '<tr><td><a href="characterprofile.php?name='.$friend['name'].'">'.$friend['name'].'</a></td>';
    echo '<td><span style="color:'.($friend['online'] == 0 ?  'red;">Offline':'green;">Online').'</span></td></tr>';
} 
echo'</table>'; include 'layout/overall/footer.php'; ?>
 
Last edited:

vipershot

New Member
Joined
Dec 30, 2007
Messages
14
Best answers
0
Likes
0
#5
nice piece of code but including a sql statement to a variable is rather insecure and easy for hackers to distroy your database, id surgest you doing it another way.
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,367
Best answers
150
Likes
1,060
Location
Norway, Oslo
#10
Improved script a bit, giving it TFS 1.0 support and Znote AAC 1.5 support. (you must use mysqli or Znote SQL functions to make it work in Znote AAC 1.5).
PHP:
<?php
#    TFS 0.2, 0.3/4, 1.0 VIP Friends for ZnoteAAC
#    By cbrm @ otland.net
#    Improved by Znote. (This requires Znote AAC 1.4+, and is compatible with Znote AAC 1.5)

require_once 'engine/init.php';
protect_page();
include 'layout/overall/header.php';

?>
<h1>VIP Friends</h1>
<?php

if ($config['TFSVersion'] !== 'TFS_10') $viplist = mysql_select_multi('SELECT `p`.`name` AS `name`, `p`.`id` AS `id`, `p`.`online` AS `online`, `v`.`player_id` FROM `account_viplist` AS `v` LEFT JOIN `players` AS `p` ON `v`.`player_id` = `p`.`id` WHERE `v`.`account_id` = '.$user_data['id'].' ORDER BY `p`.`name`, `p`.`online` ASC LIMIT 0,100');
else {
    // Lets attempt this at TFS 1.0
    $viplist = mysql_select_multi('SELECT `p`.`name` AS `name`, `p`.`id` AS `id`, `v`.`player_id` FROM `account_viplist` AS `v` LEFT JOIN `players` AS `p` ON `v`.`player_id` = `p`.`id` WHERE `v`.`account_id` = '.$user_data['id'].' ORDER BY `p`.`name` ASC LIMIT 0,100');
    if (!empty($viplist) || $viplist) {
        // Lets find out who are online with just one additional query (not quite sure how to do this with joins)
     
        // Fill up an array that only contains player ids
        $pids = array();
        foreach ($viplist as $p) $pids[] = $p['id'];
     
        // Do a query that returns the online players from that array.
        $onlineData = mysql_select_multi("SELECT `player_id` FROM `players_online` WHERE `player_id` IN (". implode(',', array_map('intval', $pids)) .")");

        // Based on onlineData, fill up an array with only ids of players who are logged in.
        $oids = array();
        foreach ($onlineData as $o) $oids[] = $o['player_id'];
     
        // Now lets modify $viplist with online status, we need to use for loop
        // instead of foreach loop to manipulate original array.
        for ($i = 0; $i < count($viplist); $i++) {
            if (in_array($viplist[$i]['id'], $oids)) $viplist[$i]['online'] = 1;
            else $viplist[$i]['online'] = 0;
        }
    }
}

if (empty($viplist) || !$viplist) echo 'You VIP list is empty.';
else {
    ?>
    <table>
        <tr class="yellow">
            <td width="60%">
                <strong>Name</strong>
            </td>
            <td width="40%">
                <strong>Status</strong>
            </td>
        </tr>
        <?php
        foreach ($viplist as $friend) {
            ?>
            <tr>
                <td>
                    <a href="characterprofile.php?name=<?php echo $friend['name']; ?>">
                        <?php echo $friend['name']; ?>
                    </a>
                </td>
                <td>
                    <?php
                    if ($friend['online'] == 0) echo '<span style="color: red;">Offline</span>';
                    else echo '<span style="color: green;">Online</span>';
                    ?>
                </td>
            </tr>
            <?php
            }
            ?>
    </table>
    <?php
}

include 'layout/overall/footer.php'; ?>
I havent tested it yet so somebody please test it and give feedback. :)
 
Last edited:

imback1

Unknown member
Joined
Jul 11, 2013
Messages
776
Best answers
1
Likes
43
#12
Preview:


Edit /layout/widgets/loggedin.php


Below:
PHP:
            <li>
                <a href='myaccount.php'>My Account</a>
            </li>

Add:
PHP:
            <li>
                <a href='friends.php'>My Friends</a>
            </li>
friends.php
PHP:
<?php
#    TFS 0.3 VIP Friends for ZnoteAAC
#    By cbrm @ otland.net

require_once 'engine/init.php';
protect_page();
include 'layout/overall/header.php';

echo'<h1>VIP Friends</h1>';
$vip = mysql_query('SELECT
                        p.name AS name, p.id AS id, p.online AS online, player_id
                    FROM
                        account_viplist
                    LEFT JOIN
                        players p ON account_viplist.player_id = p.id
                    WHERE
                        account_viplist.account_id = '.$user_data['id'].'
                    ORDER BY
                        name, online ASC LIMIT 0,100');
while ($row = mysql_fetch_assoc($vip)) {$data[] = $row;}
if (empty($data)) {echo 'You VIP list is empty.'; return include 'layout/overall/footer.php';}
?>

<table><tr class="yellow"><td width="60%"><strong>Name</strong></td><td width="40%"><strong>Status</strong></td></tr>

<?php
foreach($data as $friend)
{
    echo '<tr><td><a href="characterprofile.php?name='.$friend['name'].'">'.$friend['name'].'</a></td>';
    echo '<td><span style="color:'.($friend['online'] == 0 ?  'red;">Offline':'green;">Online').'</span></td></tr>';
}
echo'</table>'; include 'layout/overall/footer.php'; ?>
Hmm It's not working with me :S i Don't know the reason i made everything like you said
 

God Mythera

Well-Known Member
Joined
Aug 11, 2012
Messages
2,041
Best answers
2
Likes
211
Location
United States
#17
Ye, NOOBS use Gesior ;*
nah gesior is just easier, since !shop is gay and you need to pay someon to fix ;d gesior is awesome cause its automatic shop system, im also using gesior 2012 for uniserver, its pretty nice.

also NOOBS use znote cause its fast & easy to setup and they can get there money making ots online......
 
Last edited by a moderator:

Tarek1337

Well-Known Member
Joined
Jun 9, 2012
Messages
3,559
Best answers
3
Likes
995
Location
Sweden
#19
2015 and yet people are running 8.6 server because they didn't learn how to move forward :)
Evil, i wan't to cry. :((, Znote is a great AAC, i am very happy that theres many scripts that doesn't exist to Gesior or 0.x. LOVE TO ZNOTE AND TFS 1.X <33
 
Joined
Sep 3, 2011
Messages
3,636
Best answers
16
Likes
2,263
Location
Sweden
#20
also NOOBS use znote cause its fast & easy to setup and they can get there money making ots online......
Why wouldn't someone use something that's still being developed and works perfect?

nah gesior is just easier, since !shop is gay and you need to pay someon to fix ;d gesior is awesome cause its automatic shop system, im also using gesior 2012 for uniserver, its pretty nice.
If you search you'll find an automatic shop, for TFS 1.? but we are moving forward so leave the old client versions.
https://otland.net/threads/automatic-znote-aac-shop-tfs-1-0.224483/

Explain whats makes GesiorAAC easier than ZnoteAAC?.
 
Top