View file FFDB/stats.php

File size: 2.67Kb
<?php
// +----------------------------------------------------------------------+
// |                      Fantastic File Database                         |
// +----------------------------------------------------------------------+
// |                          By Tony Baird                               |
// |                  Copyright (c) 2003 Fantastic Scripts                |
// |                          http://fscripts.com                         |
// +----------------------------------------------------------------------+
// | Fantastic File Database Can be modified freely as long as copyright  | 
// | is intact and this is left at the top of every source file           |
// +----------------------------------------------------------------------+
// | stats.php                                                            |
// | Date Started: March 8, 2003                                          |
// | Last Modified: March 8, 2003                                         |
// +----------------------------------------------------------------------+
Class Stats {
	//*************************************************/
    // Just seing what we are doing
    //*************************************************/
    function Stats() {
        global $tpl,$mysql,$online,$ffdb;
		if ($_REQUEST['action']=="stats") {
			$this->DisplayStats();
		}

	}
	//*************************************************/
    // Displays our wonderful stats!
    //*************************************************/
	function DisplayStats() {
		global $tpl,$mysql,$online,$ffdb;
		$mysql->Query("SELECT * FROM ffdb_stats");
		$show_stats=mysql_fetch_array($mysql->result_id);
		$tpl->LoadTemplate("stats","templates/$online->skin/stats.tpl");
		$mysql->Query("SELECT * FROM ffdb_files");
		while ($show_file=mysql_fetch_array($mysql->result_id)) {
			$total_downloads+=$show_file[downloads];
			$newest_file=$show_file[file_name];
			$newest_file_id=$show_file[file_id];
		}
		if ($total_downloads>0 && $show_stats[num_files]>0) {
			$average_num_downloads=round($total_downloads/$show_stats[num_files],2);
		} else {
			$average_num_downloads=0;
		}
		$stats_array = array(
			'total_categorys'=> $show_stats[num_categorys],
			'total_sub_categorys'=> $show_stats[num_sub_categorys],
			'total_members'=>$show_stats[num_users],
			'total_files'=>$show_stats[num_files],
			'total_ratings'=>$show_stats[num_ratings],
			'total_downloads'=>$total_downloads,
			'newest_file'=>$newest_file,
			'newest_file_id'=>$newest_file_id,
			'average_num_downloads'=>$average_num_downloads
		);
		$tpl->ParseTemplate("stats",$stats_array,"No");
		$tpl->PrintTemplate("stats");

	}
	
}
?>