[PC-BSD Commits] r2285 - in websites/bsdstats.org: _includes bsdstats/bin bsdstats/lib bsdstats/slib/db bsdstats/tpl/bsdstats bsdstats/tpl/css
svn at pcbsd.org
svn at pcbsd.org
Sun Jul 6 13:10:23 PDT 2008
Author: fabry
Date: 2008-07-06 13:10:23 -0700 (Sun, 06 Jul 2008)
New Revision: 2285
Added:
websites/bsdstats.org/bsdstats/tpl/bsdstats/device.php
Modified:
websites/bsdstats.org/_includes/BSDStats.class.php
websites/bsdstats.org/bsdstats/bin/start.php
websites/bsdstats.org/bsdstats/lib/bsdstats.php
websites/bsdstats.org/bsdstats/slib/db/pgsql.php
websites/bsdstats.org/bsdstats/tpl/bsdstats/country.php
websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php
websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php
websites/bsdstats.org/bsdstats/tpl/css/bsdstats.css
Log:
more on the "device stats" has been done for each OS.
Modified: websites/bsdstats.org/_includes/BSDStats.class.php
===================================================================
--- websites/bsdstats.org/_includes/BSDStats.class.php 2008-07-06 20:08:37 UTC (rev 2284)
+++ websites/bsdstats.org/_includes/BSDStats.class.php 2008-07-06 20:10:23 UTC (rev 2285)
@@ -1,303 +1,303 @@
-<?php
-
-class BSDStats {
- // Variables
- var $_dbsys;
- var $_name;
- var $_name_styled;
- var $_website;
- var $_short;
- var $_platforms;
- var $_style;
- var $_blurb;
-
- // Database connection
- var $_conn = false;
-
- // Constructor
- function BSDStats() {
- }
-
- // Connect to the database
- function _connectDB() {
- if ($this->_conn == false)
- $this->_conn = pg_pconnect("host=bsdstats.org dbname=bsdstats_new user=pgsql");
- }
-
- // General helper functions
- function GetID() { return $this->_dbsys; }
- function GetName() { return $this->_name; }
- function GetNameStyled() { return isset($this->_name_styled) ? $this->_name_styled : $this->_name; }
- function GetWebsite() { return $this->_website; }
- function GetPlatforms() { return $this->_platforms; }
- function GetStyle() { return $this->_style; }
- function GetShortName() { return $this->_short; }
- function GetBlurb() { return $this->_blurb; }
- function GetLowerName() { return strtolower(str_replace("-", "", $this->_name)); }
-
- // Returns a list of "authorative" systems
- function GetSupportedSystems() {
- return array(
- 'FreeBSD',
- 'DragonFly',
- 'OpenBSD',
- 'NetBSD',
- 'PC-BSD',
- 'DesktopBSD',
- 'MidnightBSD',
- 'MirBSD',
- 'GNU/kFreeBSD',
- );
- }
-
- function _sqlGetNumberOfSystems() {
-// $sql = "SELECT count(1)
-// FROM systems
-// WHERE DATE_TRUNC('month', report_month) = DATE_TRUNC('month', now())
-// AND os_id IN ( SELECT id
-// FROM operating_systems
-// WHERE operating_system IN ('" . ($this->_dbsys ? $this->_dbsys : implode("', '", $this->GetSupportedSystems())) . "')
-// )
-// ORDER BY count DESC ";
-// $sql = "SELECT count(1)
-// FROM systems s, operating_systems os
-// WHERE DATE_TRUNC('month', report_month) = date_trunc('month', now())
-// AND os_id = os.id
-// AND operating_system IN ( '" . ($this->_dbsys ? $this->_dbsys : implode("', '", $this->GetSupportedSystems())) . "')
-// ORDER BY count DESC;";
- $sql = "SELECT count(1)
- FROM list_systems ls, ( SELECT id, MAX(report_month)
- FROM list_systems
- GROUP BY id ) AS ls2
- WHERE ls.id = ls2.id
- AND operating_system IN ( '" . ($this->_dbsys ? $this->_dbsys : implode("', '", $this->GetSupportedSystems())) . "')
- AND ls.report_month = ls2.max
- ORDER BY count DESC;";
-
- return $sql;
- }
-
- // Get the number of systems
- function GetNumberOfSystems() {
- // Create a database connection
- $this->_connectDB();
-
- // Return the number of systems
- $res = pg_query($this->_conn, $this->_sqlGetNumberOfSystems());
- return pg_fetch_result($res, 0, 'count');
- }
-
- // Get the number of systems by country
- function GetSystemsByCountry($limit = false) {
- // Create a database connection
- $this->_connectDB();
-
- // Get the total number of systems
- $total_systems = $this->GetNumberOfSystems();
-
- // Build the query string
-// $sql = "SELECT long AS country,
-// short AS country_code,
-// count(1)" . ($this->_dbsys ? '' : ",
-// (count(1) / $total_systems)::float4 AS percent " ) . "
-// FROM systems s, system_ids si
-// LEFT JOIN country_codes ON ( country_code = short )
-// WHERE DATE_TRUNC('month', s.report_month) = date_trunc('month', now())
-// AND s.id = si.id ";
- $sql = "SELECT long AS country,
- short AS country_code,
- count(1)" . ($this->_dbsys ? '' : ",
- (count(1) / $total_systems)::float4 AS percent " ) . "
- FROM list_countries lc, ( SELECT id, MAX(report_month)
- FROM list_countries
- GROUP BY id ) AS lc2
- LEFT JOIN country_codes ON ( country_code = short )
- WHERE lc.report_month = lc2.max
- AND lc.id = lc2.id ";
- if ($this->_dbsys)
- $sql .= "AND s.os_id= ( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
- $sql .= "GROUP BY long, short
- ORDER BY count DESC ";
- if ($limit)
- $sql .= "LIMIT $limit ";
-
- // Query the database
- print $sql;
- // Build the query string
- }
-
- // Get the release systems
- function GetReleases($precision, $sort_by = 'count') {
- // Create the database connection
- $this->_connectDB();
-
- // Get the total number of systems
- $total_systems = $this->GetNumberOfSystems();
-
- // Build the query string
- switch($precision) {
- case 'series':
- case 'major':
- $release = "substring(release from 1 for 1) || '.x'";
- break;
-
- case 'minor':
- $release = "split_part(release, '-', 1)";
- break;
-
- case 'version':
- case 'branches':
- default:
- $release = "release";
- break;
- }
- $sql = "SELECT $release AS release,
- count(1),
- count(1)::float4 / $total_systems * 100 AS percent
- FROM systems
- WHERE DATE_TRUNC('month', report_month) = date_trunc('month', now()) ";
- if ($this->_dbsys)
- $sql .= "AND os_id=( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
- $sql .= "GROUP BY $release ";
-
- // Add the sort statement
- if ($sort_by == 'count') {
- $sql .= "ORDER BY count DESC ";
- } else {
- $sql .= "ORDER BY release DESC ";
- }
-
- // Retrieve the result
- $res = pg_query($this->_conn, $sql);
- $rv = pg_fetch_all($res);
-
- // Return the results
- return $rv ? $rv : array();
- }
-
- // Get the countries
- function GetCountries($sort_by = 'count') {
- // Create the database connection
- $this->_connectDB();
-
- // Get the total number of systems
- $total_systems = $this->GetNumberOfSystems();
-
- // Build the query string
- $sql = "SELECT long AS country,
- short AS country_code,
- count(1),
- count(1)::float4 / $total_systems * 100 AS percent
- FROM systems s, system_ids si
- LEFT JOIN country_codes ON ( country_code = short )
- WHERE DATE_TRUNC('month', s.report_month) = date_trunc('month', now())
- AND s.id = si.id ";
- if ($this->_dbsys)
- $sql .= "AND os_id=( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
- $sql .= "GROUP BY long, short ";
-
- // Add the sort statement
- if ($sort_by == 'count') {
- $sql .= "ORDER BY count DESC ";
- } else {
- $sql .= "ORDER BY country ";
- }
-
- // Retrieve the result
- $res = pg_query($this->_conn, $sql);
- $rv = pg_fetch_all($res);
-
- // Return the results
- return $rv ? $rv : array();
- }
-
- //
- // DEVICE RELATED INFORMATION
- //
- function GetDeviceClasses() {
- // Create the database connection
- $this->_connectDB();
-
- $sql = "SELECT d.class, class_name, count(1)
- FROM systems s, system_ids si, devices d
- LEFT JOIN device_classes USING (class)
- WHERE DATE_TRUNC('month', s.report_month) = date_trunc('month', now())
- AND DATE_TRUNC('month', d.report_month) = date_trunc('month', now())
- AND s.id = si.id
- AND si.id = d.id ";
- if ($this->_dbsys)
- $sql .= "AND os_id=( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
- $sql .= "GROUP BY d.class, class_name
- ORDER BY class";
-
- // Retrieve the result
- $res = pg_query($this->_conn, $sql);
- $rv = pg_fetch_all($res);
-
- // Return the results
- return $rv ? $rv : array();
- }
-
- function GetDeviceSubclasses($class) {
- // Create the database connection
- $this->_connectDB();
-
- $sql = "SELECT
- d.class,
- substring(d.subclass for 2) AS dev_subclass,
- subclass_name,
- count(1)
- FROM systems s, system_ids si, devices d
- LEFT JOIN device_subclasses dsc ON (d.class=dsc.class AND substring(d.subclass for 2)=dsc.subclass)
- WHERE DATE_TRUNC('month', s.report_month) = date_trunc('month', now())
- AND DATE_TRUNC('month', d.report_month) = date_trunc('month', now())
- AND s.id = si.id
- AND si.id = d.id
- AND d.class = '" . pg_escape_string($class) . "' ";
- if ($this->_dbsys)
- $sql .= "AND os_id=( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
- $sql .= "GROUP BY d.class, dev_subclass, subclass_name
- ORDER BY dev_subclass";
-
- // Retrieve the result
- $res = pg_query($this->_conn, $sql);
- $rv = pg_fetch_all($res);
-
- // Return the results
- return $rv ? $rv : array();
- }
-
- // Retrieve a list of devices in a given class/subclass
- function GetDevicesByClass($class, $subclass) {
- // Create the database connection
- $this->_connectDB();
-
- $sql = "SELECT
- TRIM(driver, '[0123456789]*') AS driver,
- dm_v.description AS vendor,
- dm_d.description AS device,
- count(1)
- FROM systems s, system_ids si, devices d
- LEFT JOIN device_map dm_v ON (upper(d.device) = dm_v.device_id AND dm_v.vendor_id = 'NULL')
- LEFT JOIN device_map dm_d ON (upper(d.vendor) = dm_d.device_id AND upper(d.device) = dm_d.vendor_id )
- WHERE DATE_TRUNC('month', d.report_month) = date_trunc('month', now())
- AND DATE_TRUNC('month', s.report_month) = date_trunc('month', now())
- AND s.id = si.id
- AND si.id = d.id
- AND d.class = '" . pg_escape_string($class) . "'
- AND substring(d.subclass for 2) = '" . pg_escape_string($subclass) . "' ";
- if ($this->_dbsys)
- $sql .= "AND os_id=( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
- $sql .= "GROUP BY TRIM(driver, '[0123456789]*'), dm_v.description, dm_d.description
- ORDER BY TRIM(driver, '[0123456789]*'), dm_v.description, dm_d.description ";
-
- // Retrieve the result
- $res = pg_query($this->_conn, $sql);
- $rv = pg_fetch_all($res);
-
- // Return the results
- return $rv ? $rv : array();
- }
-}
-
-?>
+<?php
+
+class BSDStats {
+ // Variables
+ var $_dbsys;
+ var $_name;
+ var $_name_styled;
+ var $_website;
+ var $_short;
+ var $_platforms;
+ var $_style;
+ var $_blurb;
+
+ // Database connection
+ var $_conn = false;
+
+ // Constructor
+ function BSDStats() {
+ }
+
+ // Connect to the database
+ function _connectDB() {
+ if ($this->_conn == false)
+ $this->_conn = pg_pconnect("host=bsdstats.org dbname=bsdstats_new user=pgsql");
+ }
+
+ // General helper functions
+ function GetID() { return $this->_dbsys; }
+ function GetName() { return $this->_name; }
+ function GetNameStyled() { return isset($this->_name_styled) ? $this->_name_styled : $this->_name; }
+ function GetWebsite() { return $this->_website; }
+ function GetPlatforms() { return $this->_platforms; }
+ function GetStyle() { return $this->_style; }
+ function GetShortName() { return $this->_short; }
+ function GetBlurb() { return $this->_blurb; }
+ function GetLowerName() { return strtolower(str_replace("-", "", $this->_name)); }
+
+ // Returns a list of "authorative" systems
+ function GetSupportedSystems() {
+ return array(
+ 'FreeBSD',
+ 'DragonFly',
+ 'OpenBSD',
+ 'NetBSD',
+ 'PC-BSD',
+ 'DesktopBSD',
+ 'MidnightBSD',
+ 'MirBSD',
+ 'GNU/kFreeBSD',
+ );
+ }
+
+ function _sqlGetNumberOfSystems() {
+// $sql = "SELECT count(1)
+// FROM systems
+// WHERE DATE_TRUNC('month', report_month) = DATE_TRUNC('month', now())
+// AND os_id IN ( SELECT id
+// FROM operating_systems
+// WHERE operating_system IN ('" . ($this->_dbsys ? $this->_dbsys : implode("', '", $this->GetSupportedSystems())) . "')
+// )
+// ORDER BY count DESC ";
+// $sql = "SELECT count(1)
+// FROM systems s, operating_systems os
+// WHERE DATE_TRUNC('month', report_month) = date_trunc('month', now())
+// AND os_id = os.id
+// AND operating_system IN ( '" . ($this->_dbsys ? $this->_dbsys : implode("', '", $this->GetSupportedSystems())) . "')
+// ORDER BY count DESC;";
+ $sql = "SELECT count(1)
+ FROM list_systems ls, ( SELECT id, MAX(report_month)
+ FROM list_systems
+ GROUP BY id ) AS ls2
+ WHERE ls.id = ls2.id
+ AND operating_system IN ( '" . ($this->_dbsys ? $this->_dbsys : implode("', '", $this->GetSupportedSystems())) . "')
+ AND ls.report_month = ls2.max
+ ORDER BY count DESC;";
+
+ return $sql;
+ }
+
+ // Get the number of systems
+ function GetNumberOfSystems() {
+ // Create a database connection
+ $this->_connectDB();
+
+ // Return the number of systems
+ $res = pg_query($this->_conn, $this->_sqlGetNumberOfSystems());
+ return pg_fetch_result($res, 0, 'count');
+ }
+
+ // Get the number of systems by country
+ function GetSystemsByCountry($limit = false) {
+ // Create a database connection
+ $this->_connectDB();
+
+ // Get the total number of systems
+ $total_systems = $this->GetNumberOfSystems();
+
+ // Build the query string
+// $sql = "SELECT long AS country,
+// short AS country_code,
+// count(1)" . ($this->_dbsys ? '' : ",
+// (count(1) / $total_systems)::float4 AS percent " ) . "
+// FROM systems s, system_ids si
+// LEFT JOIN country_codes ON ( country_code = short )
+// WHERE DATE_TRUNC('month', s.report_month) = date_trunc('month', now())
+// AND s.id = si.id ";
+ $sql = "SELECT long AS country,
+ short AS country_code,
+ count(1)" . ($this->_dbsys ? '' : ",
+ (count(1) / $total_systems)::float4 AS percent " ) . "
+ FROM list_countries lc, ( SELECT id, MAX(report_month)
+ FROM list_countries
+ GROUP BY id ) AS lc2
+ LEFT JOIN country_codes ON ( country_code = short )
+ WHERE lc.report_month = lc2.max
+ AND lc.id = lc2.id ";
+ if ($this->_dbsys)
+ $sql .= "AND s.os_id= ( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
+ $sql .= "GROUP BY long, short
+ ORDER BY count DESC ";
+ if ($limit)
+ $sql .= "LIMIT $limit ";
+
+ // Query the database
+ print $sql;
+ // Build the query string
+ }
+
+ // Get the release systems
+ function GetReleases($precision, $sort_by = 'count') {
+ // Create the database connection
+ $this->_connectDB();
+
+ // Get the total number of systems
+ $total_systems = $this->GetNumberOfSystems();
+
+ // Build the query string
+ switch($precision) {
+ case 'series':
+ case 'major':
+ $release = "substring(release from 1 for 1) || '.x'";
+ break;
+
+ case 'minor':
+ $release = "split_part(release, '-', 1)";
+ break;
+
+ case 'version':
+ case 'branches':
+ default:
+ $release = "release";
+ break;
+ }
+ $sql = "SELECT $release AS release,
+ count(1),
+ count(1)::float4 / $total_systems * 100 AS percent
+ FROM systems
+ WHERE DATE_TRUNC('month', report_month) = date_trunc('month', now()) ";
+ if ($this->_dbsys)
+ $sql .= "AND os_id=( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
+ $sql .= "GROUP BY $release ";
+
+ // Add the sort statement
+ if ($sort_by == 'count') {
+ $sql .= "ORDER BY count DESC ";
+ } else {
+ $sql .= "ORDER BY release DESC ";
+ }
+
+ // Retrieve the result
+ $res = pg_query($this->_conn, $sql);
+ $rv = pg_fetch_all($res);
+
+ // Return the results
+ return $rv ? $rv : array();
+ }
+
+ // Get the countries
+ function GetCountries($sort_by = 'count') {
+ // Create the database connection
+ $this->_connectDB();
+
+ // Get the total number of systems
+ $total_systems = $this->GetNumberOfSystems();
+
+ // Build the query string
+ $sql = "SELECT long AS country,
+ short AS country_code,
+ count(1),
+ count(1)::float4 / $total_systems * 100 AS percent
+ FROM systems s, system_ids si
+ LEFT JOIN country_codes ON ( country_code = short )
+ WHERE DATE_TRUNC('month', s.report_month) = date_trunc('month', now())
+ AND s.id = si.id ";
+ if ($this->_dbsys)
+ $sql .= "AND os_id=( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
+ $sql .= "GROUP BY long, short ";
+
+ // Add the sort statement
+ if ($sort_by == 'count') {
+ $sql .= "ORDER BY count DESC ";
+ } else {
+ $sql .= "ORDER BY country ";
+ }
+
+ // Retrieve the result
+ $res = pg_query($this->_conn, $sql);
+ $rv = pg_fetch_all($res);
+
+ // Return the results
+ return $rv ? $rv : array();
+ }
+
+ //
+ // DEVICE RELATED INFORMATION
+ //
+ function GetDeviceClasses() {
+ // Create the database connection
+ $this->_connectDB();
+
+ $sql = "SELECT d.class, class_name, count(1)
+ FROM systems s, system_ids si, devices d
+ LEFT JOIN device_classes USING (class)
+ WHERE DATE_TRUNC('month', s.report_month) = date_trunc('month', now())
+ AND DATE_TRUNC('month', d.report_month) = date_trunc('month', now())
+ AND s.id = si.id
+ AND si.id = d.id ";
+ if ($this->_dbsys)
+ $sql .= "AND os_id=( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
+ $sql .= "GROUP BY d.class, class_name
+ ORDER BY class";
+
+ // Retrieve the result
+ $res = pg_query($this->_conn, $sql);
+ $rv = pg_fetch_all($res);
+
+ // Return the results
+ return $rv ? $rv : array();
+ }
+
+ function GetDeviceSubclasses($class) {
+ // Create the database connection
+ $this->_connectDB();
+
+ $sql = "SELECT
+ d.class,
+ substring(d.subclass for 2) AS dev_subclass,
+ subclass_name,
+ count(1)
+ FROM systems s, system_ids si, devices d
+ LEFT JOIN device_subclasses dsc ON (d.class=dsc.class AND substring(d.subclass for 2)=dsc.subclass)
+ WHERE DATE_TRUNC('month', s.report_month) = date_trunc('month', now())
+ AND DATE_TRUNC('month', d.report_month) = date_trunc('month', now())
+ AND s.id = si.id
+ AND si.id = d.id
+ AND d.class = '" . pg_escape_string($class) . "' ";
+ if ($this->_dbsys)
+ $sql .= "AND os_id=( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
+ $sql .= "GROUP BY d.class, dev_subclass, subclass_name
+ ORDER BY dev_subclass";
+
+ // Retrieve the result
+ $res = pg_query($this->_conn, $sql);
+ $rv = pg_fetch_all($res);
+
+ // Return the results
+ return $rv ? $rv : array();
+ }
+
+ // Retrieve a list of devices in a given class/subclass
+ function GetDevicesByClass($class, $subclass) {
+ // Create the database connection
+ $this->_connectDB();
+
+ $sql = "SELECT
+ TRIM(driver, '[0123456789]*') AS driver,
+ dm_v.description AS vendor,
+ dm_d.description AS device,
+ count(1)
+ FROM systems s, system_ids si, devices d
+ LEFT JOIN device_map dm_v ON (upper(d.device) = dm_v.device_id AND dm_v.vendor_id = 'NULL')
+ LEFT JOIN device_map dm_d ON (upper(d.vendor) = dm_d.device_id AND upper(d.device) = dm_d.vendor_id )
+ WHERE DATE_TRUNC('month', d.report_month) = date_trunc('month', now())
+ AND DATE_TRUNC('month', s.report_month) = date_trunc('month', now())
+ AND s.id = si.id
+ AND si.id = d.id
+ AND d.class = '" . pg_escape_string($class) . "'
+ AND substring(d.subclass for 2) = '" . pg_escape_string($subclass) . "' ";
+ if ($this->_dbsys)
+ $sql .= "AND os_id=( SELECT id FROM operating_systems WHERE operating_system = '$this->_dbsys' ) ";
+ $sql .= "GROUP BY TRIM(driver, '[0123456789]*'), dm_v.description, dm_d.description
+ ORDER BY TRIM(driver, '[0123456789]*'), dm_v.description, dm_d.description ";
+
+ // Retrieve the result
+ $res = pg_query($this->_conn, $sql);
+ $rv = pg_fetch_all($res);
+
+ // Return the results
+ return $rv ? $rv : array();
+ }
+}
+
+?>
Modified: websites/bsdstats.org/bsdstats/bin/start.php
===================================================================
--- websites/bsdstats.org/bsdstats/bin/start.php 2008-07-06 20:08:37 UTC (rev 2284)
+++ websites/bsdstats.org/bsdstats/bin/start.php 2008-07-06 20:10:23 UTC (rev 2285)
@@ -23,7 +23,7 @@
$this->display->assign('instructions_uri',$this->uri->create_uri(array_merge(array(TASK_KEY=>'instructions'),$url)));
$this->display->assign('countries_uri',$this->uri->create_uri(array_merge(array(TASK_KEY=>'countries'),$url)));
$this->display->assign('cpus_uri',$this->uri->create_uri(array_merge(array(TASK_KEY=>'cpus'),$url)));
- $this->display->assign('drivers_uri',$this->uri->create_uri(array_merge(array(TASK_KEY=>'drivers'),$url)));
+ $this->display->assign('devices_uri',$this->uri->create_uri(array_merge(array(TASK_KEY=>'devices'),$url)));
$task = $this->uri->get(TASK_KEY, '');
@@ -76,13 +76,14 @@
$this->display('cpu');
}
- public function web_drivers(){
- $tmp = load_library('bsdstats')->drivers();
+ public function web_devices(){
+ $tmp = load_library('bsdstats')->devices($this->uri->get('class',''));
- $this->display->assign('drivers_stats', $tmp['drivers_stats']);
- $this->display->assign('drivers_tot', $tmp['drivers_tot']);
- $this->display->assign('title', 'Drivers Stats');
- $this->display('driver');
+ $this->display->assign('devices_stats', $tmp['devices_stats']);
+ $this->display->assign('devices_class_stats', isset($tmp['devices_class_stats'])?$tmp['devices_class_stats']:array());
+
+ $this->display->assign('title', 'Devices Stats');
+ $this->display('device');
}
}
Modified: websites/bsdstats.org/bsdstats/lib/bsdstats.php
===================================================================
--- websites/bsdstats.org/bsdstats/lib/bsdstats.php 2008-07-06 20:08:37 UTC (rev 2284)
+++ websites/bsdstats.org/bsdstats/lib/bsdstats.php 2008-07-06 20:10:23 UTC (rev 2285)
@@ -108,7 +108,75 @@
}
return $return;
}
+
+ public function devices($class=''){
+ $return1 = load_class('cache')->get('devices'.$this->current_os);
+ if($return1==false){
+ $sql = 'SELECT d.class,
+ class_name,
+ count(1) AS cnt
+ FROM systems s
+ LEFT JOIN system_ids si ON s.id = si.id
+ LEFT JOIN devices d ON si.id = d.id
+ LEFT JOIN device_classes USING (class)
+ WHERE DATE_TRUNC(\'month\', s.report_month) = date_trunc(\'month\', now())
+ AND DATE_TRUNC(\'month\', d.report_month) = date_trunc(\'month\', now())';
+ if($this->current_os!=''){
+ $sql .= 'AND os_id=( SELECT id FROM operating_systems WHERE operating_system = \''.$this->current_os.'\' )';
+ }
+ $sql .= 'GROUP BY d.class, class_name
+ ORDER BY class;';
+ $tmps = $this->db->query($sql);
+ $devices_stats = array();
+ $i=0;
+ while($tmp = $this->db->fetch_array($tmps)){
+ $devices_stats[$i]['class'] = $tmp['class'];
+ $devices_stats[$i]['name'] = $tmp['class_name']==''?'unknown':$tmp['class_name'];
+ $devices_stats[$i]['total'] = $tmp['cnt'];
+ $i++;
+ }
+ $return1 = array('devices_stats'=>$devices_stats);
+ load_class('cache')->set('devices'.$this->current_os, $return1);
+ }
+ if($class!=''){
+ $return2 = load_class('cache')->get('devices_class'.$class.$this->current_os);
+ if($return2==false){
+ $sql = 'SELECT d.class,
+ substring(d.subclass for 2) AS dev_subclass,
+ subclass_name,
+ count(1) AS cnt
+ FROM systems s
+ LEFT JOIN system_ids si ON s.id = si.id
+ LEFT JOIN devices d ON si.id = d.id
+ LEFT JOIN device_subclasses dsc ON (d.class=dsc.class AND substring(d.subclass for 2)=dsc.subclass)
+ WHERE DATE_TRUNC(\'month\', s.report_month) = date_trunc(\'month\', now())
+ AND DATE_TRUNC(\'month\', d.report_month) = date_trunc(\'month\', now())
+ AND d.class = \''.$this->db->escape_string($class).'\'';
+ if($this->current_os!=''){
+ $sql .= 'AND os_id=( SELECT id FROM operating_systems WHERE operating_system = \''.$this->current_os.'\' )';
+ }
+ $sql .= 'GROUP BY d.class, dev_subclass, subclass_name
+ ORDER BY dev_subclass;';
+ $tmps = $this->db->query($sql);
+ $devices_class_stats = array();
+ $i=0;
+ while($tmp = $this->db->fetch_array($tmps)){
+ $devices_class_stats[$i]['class'] = $tmp['class'];
+ $devices_class_stats[$i]['subclass'] = $tmp['dev_subclass']==''?'':$tmp['dev_subclass'];
+ $devices_class_stats[$i]['name'] = $tmp['subclass_name']==''?'unknown':$tmp['subclass_name'];
+ $devices_class_stats[$i]['total'] = $tmp['cnt'];
+ $i++;
+ }
+ $return2 = array('devices_class_stats'=>$devices_class_stats);
+ load_class('cache')->set('devices_class'.$class.$this->current_os, $return2);
+ }
+ } else {
+ $return2 = array();
+ }
+ return array_merge($return1,$return2);
+ }
+
public function drivers(){
$return = load_class('cache')->get('drivers'.$this->current_os);
if($return==false){
Modified: websites/bsdstats.org/bsdstats/slib/db/pgsql.php
===================================================================
--- websites/bsdstats.org/bsdstats/slib/db/pgsql.php 2008-07-06 20:08:37 UTC (rev 2284)
+++ websites/bsdstats.org/bsdstats/slib/db/pgsql.php 2008-07-06 20:10:23 UTC (rev 2285)
@@ -355,7 +355,7 @@
$this->connect($this->persistant,true);
}
if($string!='' && $this->link_id){
- $return = pg_escape_string($string,$this->link_id);
+ $return = pg_escape_string($this->link_id,$string);
} else {
$return =$string;
}
Modified: websites/bsdstats.org/bsdstats/tpl/bsdstats/country.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/country.php 2008-07-06 20:08:37 UTC (rev 2284)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/country.php 2008-07-06 20:10:23 UTC (rev 2285)
@@ -38,7 +38,7 @@
<td class="country"><img border="0" alt="<?php echo $country?>" src="/images/countries/<?php echo $flag?>.png"/> <?php echo $country_name!=''?$country_name:'(unknown)'?></td><?php
$tt = 0;
foreach($oss as $os){
- ?><td><?php
+ ?><td class="number"><?php
if(isset($countries_stats[$country][$os])){
$tt +=$countries_stats[$country][$os];
echo $format->number($countries_stats[$country][$os]);
Modified: websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php 2008-07-06 20:08:37 UTC (rev 2284)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php 2008-07-06 20:10:23 UTC (rev 2285)
@@ -5,7 +5,7 @@
<li><a href="<?php echo $instructions_uri?>">Instructions</a></li>
<li><a href="#">Release Stats</a></li>
<li><a href="<?php echo $countries_uri?>">Country Stats</a></li>
- <li><a href="<?php echo $drivers_uri?>">Drivers/HW Stats</a></li>
+ <li><a href="<?php echo $devices_uri?>">Device Stats</a></li>
<li><a href="<?php echo $cpus_uri?>">CPU Stats</a></li>
<li><a href="#">Port Stats</a></li>
</ul>
Modified: websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php 2008-07-06 20:08:37 UTC (rev 2284)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php 2008-07-06 20:10:23 UTC (rev 2285)
@@ -19,7 +19,7 @@
?>
<li><a href="#">Release Stats</a></li>
<li><a href="<?php echo $countries_uri?>">Country Stats</a></li>
- <li><a href="<?php echo $drivers_uri?>">Device Stats</a></li>
+ <li><a href="<?php echo $devices_uri?>">Device Stats</a></li>
<li><a href="<?php echo $cpus_uri?>">CPU Stats</a></li>
<li><a href="#">Ports Stats</a></li>
</ul>
Modified: websites/bsdstats.org/bsdstats/tpl/css/bsdstats.css
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/css/bsdstats.css 2008-07-06 20:08:37 UTC (rev 2284)
+++ websites/bsdstats.org/bsdstats/tpl/css/bsdstats.css 2008-07-06 20:10:23 UTC (rev 2285)
@@ -103,8 +103,8 @@
text-align:left;
}
-.total{
- text-align:right;
+.total, .number{
+ text-align:right !important;
}
.stats-simple {
@@ -119,7 +119,7 @@
border-bottom:1px solid #666666;
}
.stats-simple td {
- text-align: right;
+ text-align: left;
padding: 1px 4px 1px 4px;
border-bottom: 1px solid #e0e0e0;
border-left: 1px dotted #e0e0e0;
More information about the Commits
mailing list