/[gentoo-src]/gentoo-stats/stats.inc.php
Gentoo

Diff of /gentoo-stats/stats.inc.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.2
1<?php 1<?php
2/** 2/**
3 * Gentoo stats 3 * Gentoo stats
4 * Written by Meir Kriheli <mksoft.gentoo.org> 4 * Written by Meir Kriheli <mksoft@gentoo.org>
5 * Based on gentoo-stats by Maik Schreiber <blizzy@gentoo.org> 5 * Based on gentoo-stats by Maik Schreiber <blizzy@gentoo.org>
6 * 6 *
7 * $Id: stats.inc.php,v 1.1 2003/04/29 13:13:00 mksoft Exp $ 7 * $Id: stats.inc.php,v 1.2 2003/04/29 14:30:55 mksoft Exp $
8 * 8 *
9 * vim: set tabstop=4 shiftwidth=4: 9 * vim: set tabstop=4 shiftwidth=4:
10 */ 10 */
11 11
12/********** Config section *****************/ 12/********** Config section *****************/
14$db_server = 'localhost'; 14$db_server = 'localhost';
15$db_name = 'gentoo'; 15$db_name = 'gentoo';
16$db_user = 'genstats'; 16$db_user = 'genstats';
17$db_pass = 'a45fgt34'; 17$db_pass = 'a45fgt34';
18 18
19$menu = array(
20 'index.php' => 'Home' ,
21 'general.php' => 'General',
22 'profiles.php' => 'Profiles',
23 'cpus.php' => 'CPUs',
24 'cards.php' => 'Expansion Cards',
25 'package_hi.php' => 'Package Highlights',
26 'package_cat.php' => 'Package Categories'
27);
28
29// numbers of days considering the user is active 19// numbers of days considering the user is active
30$active_days = 14; 20$active_days = 14;
31$max_accepted_cpu_mhz = 4000; 21$max_accepted_cpu_mhz = 4000;
32
33define('GRID_STR',"\t<tr><td class=\"%s\" style=\"text-align:right;\">%s</td><td class=\"%s\">%s</td></tr>\n");
34define('GRID_SPACER',"<tr><td clospan=\"2\"></td></tr>\n");
35define('TOTAL_SYSTEMS','Total # of monitored systems');
36define('UPDATED_SYSTEMS',"Systems updated during last $active_days days");
37define('LAST_UPDATED','Last update from a system');
38define('TOTAL_CPUS','Total # of monitored CPUs');
39define('AVG_CPUS','Average # of CPUs per system');
40define('AVG_MHZ','Average speed of CPUs');
41define('MIN_MHZ','Minimum speed of CPU');
42define('MAX_MHZ','Maximum speed of CPU');
43 22
44/********** End of config section **********/ 23/********** End of config section **********/
45 24
46require_once('DB.php'); 25require_once('DB.php');
47require_once('Smarty.class.php'); 26require_once('Smarty.class.php');
48 27
49// get the db connection 28// get the db connection
50$db = & DB::connect("mysql://$db_user:$db_pass@$db_server/$db_name"); 29$db = & DB::connect("mysql://$db_user:$db_pass@$db_server/$db_name");
30
51$smarty = & new Smarty; 31$smarty = & new Smarty;
32$smarty->assign('active_days',$active_days);
52 33
53function showHeader() {
54?>
55<html>
56<head>
57 <title>Gentoo stats</title>
58 <link rel="stylesheet" href="stats.css" type="text/css">
59</head>
60<body>
61 <table width="100%" cellspacing="0" cellspacing="3">
62 <tr><td class="header">Gentoo stats</td></tr>
63 <tr>
64 <td class="menu">
65<?php
66 reset($GLOBALS['menu']);
67 $first = true;
68 while ( list($url,$caption) = each($GLOBALS['menu']) ) {
69 if ($first) $first=false;
70 else echo " | ";
71 echo "<a href=\"$url\" class=\"menulink\">$caption</a>";
72 }
73?>
74 </td>
75 </tr>
76 </table>
77 <div class="content">
78<?php
79}
80
81function showFooter() {
82?>
83 </div>
84</body></html>
85<?php
86}
87 34
88function getTotalUsers() { 35function getTotalUsers() {
89 global $db; 36 global $db;
90 37
91 $sql = "SELECT COUNT(*) FROM t_users WHERE (u_last_update IS NOT NULL) " . 38 $sql = "SELECT COUNT(*) FROM t_users WHERE (u_last_update IS NOT NULL) " .

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.20