Results 1 to 2 of 2

Thread: Statistics

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    1
    Rep Power
    0

    Default Statistics

    Hello, can I ask how you made those cool icons that show whether the user is online (on irc) or not?

  2. #2

    Default Re: Statistics

    Sorry it's taken so long to reply, hadn't noticed your message.

    The images go into a little more detail then online/offline, they also cover authenticated to services, IRCops, services, bots, away and SSL too.

    Oh those are quite simple, its just a simple PHP script (mod_rewrite to give the .png extension) that reads from Denora's (IRC Statistics service) MySQL database.

    As for the images they're just loaded by PHP's GD library. And in the case of the key (SSL) and clock (away) overlays, they're just images with a transparent background loaded and merged using PHP's GD library.

    The images I use can be found in famfamfam.com's silk icon set (or in the attached zip.file)

    The code I use (bear in mind this code is tuned for using Denora's MySQL DB with Denora connected to a network running Nefarious which has slightly different user modes to some IRCds):
    PHP Code:
    <?php
    $sqldetails
    ['server'] = "<mysqlserver>";
    $sqldetails['user'] = "<mysqluser>";
    $sqldetails['password'] = "<mysqlpasswd>";
    $sqldetails['database'] = "<mysqldenoradb>";

    $nickin "";
    if ( isset(
    $_GET['user']) ) {
        
    $nickin $_GET['user'];
    }
    if ( isset(
    $_POST['user']) ) {
        
    $nickin $_POST['user'];
    }

    $nickin str_replace("/""\\"$nickin);

    $status 0;

    $conn mysql_connect($sqldetails['server'], $sqldetails['user'], $sqldetails['password']);
    mysql_select_db($sqldetails['database'], $conn);

    $sqlu "SELECT * FROM user WHERE nick = '".mysql_real_escape_string($nickin)."'";
    $resultu mysql_query($sqlu$conn) or die(mysql_error());

    if ( 
    mysql_num_rows($resultu) > ) {
        
    $userrow mysql_fetch_array($resultu);
        if ( 
    $userrow['online'] == "Y" ) {
            
    $status 2;
            if ( ( 
    $userrow['account'] != "" ) or ( $userrow['mode_lr'] == "Y" ) ) {
                
    $status 1;
            }
            if ( 
    $userrow['mode_lo'] == "Y" ) {
                
    $status 3;
            }
            if ( 
    $userrow['mode_ub'] == "Y" ) {
                
    $status 5;
            }
            if ( 
    $userrow['mode_lk'] == "Y" ) {
                
    $status 4;
            }
            if ( 
    $userrow['mode_lz'] == "Y" ) {
                
    $ssl 1;
            }
            if ( 
    $userrow['away'] == "Y" ) {
                
    $away 1;
            }
        } else {
            
    $status 0;
        }
    } else {
        
    $status 0;
    }

    if ( 
    $status == ) {
        
    $img ImageCreateFromPng("images/status-onlinereg.png");
    } else if ( 
    $status == ) {
        
    $img ImageCreateFromPng("images/status-online.png");
    } else if ( 
    $status == ) {
        
    $img ImageCreateFromPng("images/status-oper.png");
    } else if ( 
    $status == ) {
        
    $img ImageCreateFromPng("images/status-service.png");
    } else if ( 
    $status == ) {
        
    $img ImageCreateFromPng("images/status-bot.png");
    } else {
        
    $img ImageCreateFromPng("images/status-offline.png");
    }

    if ( 
    $ssl == ) {
        
    $imgssl ImageCreateFromPng("images/status-ssl.png");
        
    ImageCopyMerge($img$imgssl00001616100);
        
    ImageDestroy($imgssl);
    }

    if ( 
    $away == ) {
        
    $imgaway ImageCreateFromPng("images/status-away.png");
        
    ImageCopyMerge($img$imgaway00001616100);
        
    ImageDestroy($imgaway);
    }

    header ("Content-type: image/png");
    ImagePNG($img);

    ImageDestroy($img);

    mysql_close($conn);
    ?>
    Attached Files Attached Files
    Last edited by Jobe; February 20th, 2011 at 16:06:13.
    Your IP:
    My IRC Status: Status: Jobe
    My Server Status: Status: alpha.invictachat.net Status: bravo.invictachat.net

    My user profile

    Warning: If the help desk thinks your question is stupid, we will set you on fire.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •