Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need php coding help!

    Im adding tons of new features to my site http://www.allgamesallfree.com and I have just finished making a succesful registration and login feature on my testing server. I want to be able to count the number of members that have registered in my list of stats
    here:

    <?php

    /**
    * Class file to get different statistics
    *
    */
    class RSTATS extends RCORE
    {
    /**
    * Function to display different all in one statistics
    *
    */
    function DisplayStats()
    {
    echo
    "
    <table width='100%' cellspacing='6' cellpadding='5'>
    <tr>
    <td colspan='2'><strong>RGameScript Pro Statistics</strong></td>
    </tr>
    <tr>
    <td>Total Diskspace Usage: </td>
    <td><div align='right'>".$this->RDiskSpaceUsage("./../")."</div></td>
    </tr>
    <tr>
    <td>Total Diskspace Used by Games: </td>
    <td><div align='right'>".$this->RDiskSpaceUsage("./..********")."</div></td>
    </tr>
    <tr>
    <td>Total Diskspace Used by Game Icons: </td>
    <td><div align='right'>".$this->RDiskSpaceUsage("./../rgames/game_icons/")."</div></td>
    </tr>
    <tr>
    <td>Total Diskspace Used by Category Icons: </td>
    <td><div align='right'>".$this->RDiskSpaceUsage("./..*******")."</div></td>
    </tr>
    <tr>
    <td>Total Active Games: </td>
    <td><div align='right'>".$this->GetActiveGames()."</div></td>
    </tr>
    <tr>
    <td>Total Game Files: </td>
    <td><div align='right'>".$this->num_files("./..***********")."</div></td>
    </tr>
    <tr>
    <td>Total Members: </td>
    <td><div align='right'>".$this->num_links("./..*************")."</div></td>
    </tr>
    <tr>
    <td>Total Game Icons: </td>
    <td><div align='right'>".$this->num_files("./..************")."</div></td>
    </tr>
    </table>
    ";
    }

    /**
    * Function to count number of files in a directory
    *
    * @param string $directory The directory from which files will be counted
    * @return integer The total amount of files
    */
    function num_files($directory='.') {
    return count(glob($directory."/*.*"));
    }
    /**
    * Function to count number of links in a directory
    *
    * @param string $directory2 The directory from which links will be counted
    * @return integer The total amount of links
    */
    function num_links($directory2='.') {
    return count(glob($directory2."/*.*"));
    }

    /**
    * Function to active games
    *
    * @return integer The total amount of active games
    */
    function GetActiveGames()
    {
    $amount = $this->RNumRows("SELECT * FROM rgames_flash WHERE GameAlive = 1");
    return $amount;
    }

    /**
    * Function to count total diskspace usage in a directory
    *
    * @param string $dir The directory to find the diskusage of
    * @return string The amount of diskspace used
    */
    function RDiskSpaceUsage($dir)
    {
    $usage = $this->disk_usage($dir);
    $format = $this->format_filesize($usage);
    return $format;
    }

    /**
    * Function to find the actual diskspace and its sub-directories
    *
    * @param string $d The directory
    * @param string $depth Depth level of the directory
    * @return integer The amount of diskspace used
    */
    function disk_usage($d, $depth = NULL)
    {
    if(is_file($d))
    return filesize($d);

    if(isset($depth) && $depth < 0)
    return 0;

    if($d[strlen($d)-1] != '\\' || $d[strlen($d)-1] != '/')
    $d .= '/';

    $dh=@opendir($d);
    if(!$dh)
    return 0;

    while($e = readdir($dh))
    if($e != '.' && $e != '..')
    $usage += $this->disk_usage($d.$e, isset($depth) ? $depth - 1 : NULL);

    closedir($dh);

    return $usage;
    }

    /**
    * Function format any filesize and return as bytes, MB or GB
    *
    * @param integer $int The amount
    * @param string $bytesstyle Options style (leave false)
    * @return string The file size
    */
    function format_filesize($int,$bytesstyle = false)
    {
    if ($bytesstyle != false){$bytes = $int;}
    $str = " bytes";
    if ($int > 1024+256){$int /= 1024; $str = " KB";}
    if ($int > 1024+256){$int /= 1024; $str = " MB";}
    if ($int > 1024+256){$int /= 1024; $str = " GB";}
    if ($int > 1024+256){$int /= 1024; $str = " TB";}
    $int2 = round(number_format($int,2),2);
    if ($str != " bytes" AND $bytesstyle == 1){$str .= " (".$bytes." bytes)";}
    return $int2.$str;
    }

    }

    ?>
    I have a page in my admin panel that has every member as a different link, with the option to delete, promote, demote them etc so perhaps a crude way to do this would be to make a function that counts the number of links on that page, I say crude because there are a few other links on that page as well. If you know how to do that, it would help extremely.

    Also I have plans to add a rating system to every game, since every game is
    coded into a php file, and the information is grabbed from my admin panel
    when ever I upload it, I need to figure out a function that would allow
    a different rating system to display on each 1 of those games, calculate the rating and only allow the person to vote on that specific game once. Every
    rating system I tried makes only 1 rating system for every game, which doesnt work to well.
    Last edited by ab9003; 11-10-2006 at 04:46 PM.


 

Posting Permissions

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