[PC-BSD Commits] r2199 - in websites: bsdstats.org/bsdstats/bin bsdstats.org/bsdstats/etc bsdstats.org/bsdstats/lib bsdstats.org/bsdstats/sbin bsdstats.org/bsdstats/sbin/cache bsdstats.org/bsdstats/slib bsdstats.org/bsdstats/tpl/bsdstats bsdstats.org/bsdstats/tpl/js pbidir.com/bibivu/etc pbidir.com/bibivu/sbin pbidir.com/bibivu/sbin/cache pbidir.com/bibivu/slib
svn at pcbsd.org
svn at pcbsd.org
Sun Jun 29 07:32:24 PDT 2008
Author: fabry
Date: 2008-06-29 07:32:23 -0700 (Sun, 29 Jun 2008)
New Revision: 2199
Added:
websites/bsdstats.org/bsdstats/tpl/bsdstats/driver.php
Modified:
websites/bsdstats.org/bsdstats/bin/start.php
websites/bsdstats.org/bsdstats/etc/autoload.conf.php
websites/bsdstats.org/bsdstats/etc/cache.conf.php
websites/bsdstats.org/bsdstats/lib/bsdstats.php
websites/bsdstats.org/bsdstats/sbin/cache.php
websites/bsdstats.org/bsdstats/sbin/cache/memcached.php
websites/bsdstats.org/bsdstats/slib/format.php
websites/bsdstats.org/bsdstats/tpl/bsdstats/cpu.php
websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php
websites/bsdstats.org/bsdstats/tpl/bsdstats/header.php
websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php
websites/bsdstats.org/bsdstats/tpl/js/functions.js
websites/pbidir.com/bibivu/etc/autoload.conf.php
websites/pbidir.com/bibivu/etc/cache.conf.php
websites/pbidir.com/bibivu/sbin/cache.php
websites/pbidir.com/bibivu/sbin/cache/memcached.php
websites/pbidir.com/bibivu/slib/format.php
Log:
driver page created.
added some extra functionality to the format class:
- format text
Modified: websites/bsdstats.org/bsdstats/bin/start.php
===================================================================
--- websites/bsdstats.org/bsdstats/bin/start.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/bin/start.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -16,6 +16,7 @@
$this->display->assign('instructions_uri',$this->uri->create_uri(array(TASK_KEY=>'instructions')));
$this->display->assign('countries_uri',$this->uri->create_uri(array(TASK_KEY=>'countries')));
$this->display->assign('cpus_uri',$this->uri->create_uri(array(TASK_KEY=>'cpus')));
+ $this->display->assign('drivers_uri',$this->uri->create_uri(array(TASK_KEY=>'drivers')));
$task = $this->uri->get(TASK_KEY, '');
@@ -66,5 +67,14 @@
$this->display('cpu');
}
+ public function web_drivers(){
+ $tmp = load_library('bsdstats')->drivers();
+
+ $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');
+ }
+
}
?>
\ No newline at end of file
Modified: websites/bsdstats.org/bsdstats/etc/autoload.conf.php
===================================================================
--- websites/bsdstats.org/bsdstats/etc/autoload.conf.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/etc/autoload.conf.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -16,5 +16,5 @@
$autoload['lib']['display'] = true;
//$autoload['lib']['db'.DIRECTORY_SEPARATOR.'mysql'] = true;
$autoload['lib']['db'] = true;
-$autoload['lib']['format'] = true;
+$autoload['lib']['format'] = false;
?>
\ No newline at end of file
Modified: websites/bsdstats.org/bsdstats/etc/cache.conf.php
===================================================================
--- websites/bsdstats.org/bsdstats/etc/cache.conf.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/etc/cache.conf.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -5,7 +5,37 @@
| -------------------------------------------------------------------------
*/
$cache['driver'] = 'memcached';
+
+/*
+memcached settings
+*/
$cache['memcached_server'] = 'localhost';
$cache['memcached_port'] = '11211';
$cache['memcached_timeout'] = '1';
+
+/*
+those are the default settings for the function :
+ - set
+ - add
+ - replace
+
+They can be also manually set when calling the functions.
+
+if set to NULL, the default values will be:
+ - compress: false
+ - expire: 0 (never expire)
+*/
+$cache['compress'] = true;
+$cache['expire'] = 3600;
+
+/*
+in case we use a type of cache that can be shae between multiple sites (I.E.: memcached)
+we can set the "site_id" to different values for each site,
+this will allow you to use the same variable names between different sites
+but the people on the same site will see the shared variable
+
+default = ''
+
+*/
+$cache['site_id'] = '';
?>
\ No newline at end of file
Modified: websites/bsdstats.org/bsdstats/lib/bsdstats.php
===================================================================
--- websites/bsdstats.org/bsdstats/lib/bsdstats.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/lib/bsdstats.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -7,85 +7,124 @@
public function get_list_os(){
//maybe have a table with those information in it?
- $tmps = $this->db->query("SELECT DISTINCT operating_system FROM list_systems ORDER BY operating_system;");
- $return = array();
- while($tmp = $this->db->fetch_array($tmps)){
- $return[] = $tmp['operating_system'];
+ $return = load_class('cache')->get('list_os');
+ if($return==false){
+ $tmps = $this->db->query("SELECT DISTINCT operating_system FROM list_systems ORDER BY operating_system;");
+ $return = array();
+ while($tmp = $this->db->fetch_array($tmps)){
+ $return[] = $tmp['operating_system'];
+ }
+ load_class('cache')->set('list_os', $return);
}
return $return;
-/*
- return array('FreeBSD',
- 'DragonFly',
- 'OpenBSD',
- 'NetBSD',
- 'PC-BSD',
- 'DesktopBSD',
- 'MidnightBSD',
- 'MirBSD',
- 'GNU/kFreeBSD',
- );
-*/
}
public function os_summary(){
- $tmps = $this->db->query('SELECT operating_system, count(1) as cnt
- 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 (\''.implode('\',\'',$this->get_list_os()).'\')
- AND ls.report_month = ls2.max
- GROUP BY operating_system
- ORDER BY cnt DESC;');
-
- $return = array('os_summary'=>array(),'total'=>0);
- while($tmp = $this->db->fetch_array($tmps)){
- $return['total'] += $tmp['cnt'];
- $tmp['image'] = strtolower(str_replace(array('-','/'),'',$tmp['operating_system']));
- $return['os_summary'][] = $tmp;
+ $return = load_class('cache')->get('os_summary');
+ if($return==false){
+ $tmps = $this->db->query('SELECT operating_system, count(1) as cnt
+ 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 (\''.implode('\',\'',$this->get_list_os()).'\')
+ AND ls.report_month = ls2.max
+ GROUP BY operating_system
+ ORDER BY cnt DESC;');
+
+ $return = array('os_summary'=>array(),'total'=>0);
+ while($tmp = $this->db->fetch_array($tmps)){
+ $return['total'] += $tmp['cnt'];
+ $tmp['image'] = strtolower(str_replace(array('-','/'),'',$tmp['operating_system']));
+ $return['os_summary'][] = $tmp;
+ }
+ load_class('cache')->set('os_summary', $return);
}
return $return;
}
public function countries(){
- $tmps = $this->db->query('SELECT operating_system, country_code, count(1) as cnt
- FROM ( SELECT DISTINCT ls.id, ls.operating_system, country_code FROM list_systems ls LEFT JOIN system_ids si ON ls.id = si.id ) AS os_list
- GROUP BY operating_system, country_code;');
- $total = 0;
- $countries_stats = array();
- while($tmp = $this->db->fetch_array($tmps)){
- $total += $tmp['cnt'];
- $countries_stats[$tmp['country_code']][$tmp['operating_system']] = $tmp['cnt'];
+ $return = load_class('cache')->get('countries');
+ if($return==false){
+ $tmps = $this->db->query('SELECT operating_system, country_code, count(1) as cnt
+ FROM ( SELECT DISTINCT ls.id, ls.operating_system, country_code FROM list_systems ls LEFT JOIN system_ids si ON ls.id = si.id ) AS os_list
+ GROUP BY operating_system, country_code;');
+ $total = 0;
+ $countries_stats = array();
+ while($tmp = $this->db->fetch_array($tmps)){
+ $total += $tmp['cnt'];
+ $countries_stats[$tmp['country_code']][$tmp['operating_system']] = $tmp['cnt'];
+ }
+
+ $tmps = $this->db->query('SELECT country_code, count(1) AS cnt
+ FROM ( SELECT DISTINCT ls.id, ls.operating_system, country_code FROM list_systems ls LEFT JOIN system_ids si ON ls.id = si.id ) AS os_list
+ GROUP BY country_code
+ ORDER BY cnt DESC;');
+ $countries = array();
+ while($tmp = $this->db->fetch_array($tmps)){
+ $countries[] = $tmp['country_code'];
+ }
+ $return = array('countries'=>$countries,'countries_stats'=>$countries_stats, 'total'=>$total);
+ load_class('cache')->set('countries', $return);
}
-
- $tmps = $this->db->query('SELECT country_code, count(1) AS cnt
- FROM ( SELECT DISTINCT ls.id, ls.operating_system, country_code FROM list_systems ls LEFT JOIN system_ids si ON ls.id = si.id ) AS os_list
- GROUP BY country_code
- ORDER BY cnt DESC;');
- $countries = array();
- while($tmp = $this->db->fetch_array($tmps)){
- $countries[] = $tmp['country_code'];
- }
-
- return array('countries'=>$countries,'countries_stats'=>$countries_stats, 'total'=>$total);
+ return $return;
}
public function cpus(){
- $tmps = $this->db->query('SELECT cpus, count(1) AS cnt FROM cpus GROUP BY cpus ORDER BY cpus;');
- $cpu_stats = array();
- while($tmp = $this->db->fetch_array($tmps)){
- $cpu_stats[$tmp['cpus']] = $tmp['cnt'];
+ $return = load_class('cache')->get('cpus');
+ if($return==false){
+ $tmps = $this->db->query('SELECT cpus, count(1) AS cnt FROM cpus GROUP BY cpus ORDER BY cpus;');
+ $cpu_stats = array();
+ while($tmp = $this->db->fetch_array($tmps)){
+ $cpu_stats[$tmp['cpus']] = $tmp['cnt'];
+ }
+
+ $tmps = $this->db->query('SELECT vendor, cpu_type, count(1) AS cnt FROM cpus GROUP BY vendor, cpu_type ORDER BY vendor, cnt DESC;');
+ $vendor_stats = array();
+ $i=0;
+ while($tmp = $this->db->fetch_array($tmps)){
+ $vendor_stats[$i]['vendor'] = $tmp['vendor'];
+ $vendor_stats[$i]['cpu_type'] = $tmp['cpu_type'];
+ $vendor_stats[$i]['total'] = $tmp['cnt'];
+ $i++;
+ }
+ $return = array('cpu_stats'=>$cpu_stats,'vendor_stats'=>$vendor_stats);
+ load_class('cache')->set('cpus', $return);
}
-
- $tmps = $this->db->query('SELECT vendor, cpu_type, count(1) AS cnt FROM cpus GROUP BY vendor, cpu_type ORDER BY vendor, cnt DESC;');
- $vendor_stats = array();
- $i=0;
- while($tmp = $this->db->fetch_array($tmps)){
- $vendor_stats[$i]['vendor'] = $tmp['vendor'];
- $vendor_stats[$i]['cpu_type'] = $tmp['cpu_type'];
- $vendor_stats[$i]['total'] = $tmp['cnt'];
- $i++;
+ return $return;
+ }
+
+ public function drivers(){
+ $return = load_class('cache')->get('drivers');
+ if($return==false){
+ $tmps = $this->db->query('SELECT trim(driver, \'[0123456789]*\') AS driver, count(1) AS cnt
+ FROM devices d
+ WHERE date_trunc(\'month\', report_month) = date_trunc(\'month\', now())
+ GROUP BY trim(driver, \'[0123456789]*\')
+ ORDER BY driver;');
+ $drivers_tot = array();
+ while($tmp = $this->db->fetch_array($tmps)){
+ $drivers_tot[$tmp['driver']] = $tmp['cnt'];
+ }
+
+ $tmps = $this->db->query('SELECT TRIM(driver, \'[0123456789]*\') AS driver, dm_v.description AS vendor, dm_d.description AS device, count(1) AS cnt
+ FROM 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())
+ GROUP BY TRIM(driver, \'[0123456789]*\'), dm_v.description, dm_d.description
+ ORDER BY driver, vendor, cnt DESC;');
+ $drivers_stats = array();
+ $i=0;
+ while($tmp = $this->db->fetch_array($tmps)){
+ $drivers_stats[$i]['driver'] = $tmp['driver'];
+ $drivers_stats[$i]['vendor'] = $tmp['vendor'];
+ $drivers_stats[$i]['device'] = $tmp['device'];
+ $drivers_stats[$i]['total'] = $tmp['cnt'];
+ $i++;
+ }
+ $return = array('drivers_tot'=>$drivers_tot,'drivers_stats'=>$drivers_stats);
+ load_class('cache')->set('drivers', $return);
}
-
- return array('cpu_stats'=>$cpu_stats,'vendor_stats'=>$vendor_stats);
+ return $return;
}
}
?>
\ No newline at end of file
Modified: websites/bsdstats.org/bsdstats/sbin/cache/memcached.php
===================================================================
--- websites/bsdstats.org/bsdstats/sbin/cache/memcached.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/sbin/cache/memcached.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -11,6 +11,10 @@
public $numIncrement = 0;
public $numDecrement = 0;
public $total_time = 0;
+
+ public $compress = false;
+ public $expire = 0;
+
public function __construct() {
parent::$instance =&$this;
@@ -20,10 +24,30 @@
$this->connections = array();
}
- public function set_site_id($site_id){
- $this->site_id = $site_id;
+ //set or return default site_id values
+ public function set_site_id($site_id=NULL){
+ if($site_id!=NULL){
+ $this->site_id = $site_id;
+ }
+ return $this->site_id;
}
+ //set or return default compress values
+ public function default_compress($compress=NULL){
+ if($compress!=NULL){
+ $this->compress = (bool)$compress;
+ }
+ return $this->compress;
+ }
+
+ //set or return default expire values
+ public function default_expire($expire=NULL){
+ if($expire!=NULL){
+ $this->expire = $expire+0;
+ }
+ return $this->expire;
+ }
+
public function close(){
$result = false;
for ($i = 0; $i < count($this->connections); $i++) {
@@ -106,23 +130,24 @@
}
}
- public function set($key, $var, $compress=0, $expire=0) {
-// echo 'setting here: '.$key.':<br />'; var_dump($var);
-// mail('fabrizio at bibivu.com',$key,var_export($var,true));
+ public function set($key, $var, $compress=NULL, $expire=NULL) {
$time1=$this->getmicrotime();
+ if($compress==NULL) $compres = $this->default_compress();
+ if($expire==NULL) $expire = $this->default_expire();
$key = $this->site_id.trim($key);
$con = $this->_getConForKey($key);
if ($con === false) return false;
$this->numSet++;
-// mail('fabrizio at bibivu.com','[bibivu]->memcached->set->'.$key,'setting up key '.$key);
$return = $con->set($key, $var, $compress, $expire);
$time2=$this->getmicrotime();
$this->total_time += $time2-$time1;
return $return;
}
- public function add($key, $var, $compress=0, $expire=0) {
+ public function add($key, $var, $compress=NULL, $expire=NULL) {
$time1=$this->getmicrotime();
+ if($compress==NULL) $compres = $this->default_compress();
+ if($expire==NULL) $expire = $this->default_expire();
$key = $this->site_id.trim($key);
$con = $this->_getConForKey($key);
if ($con === false) return false;
@@ -133,8 +158,10 @@
return $return;
}
- public function replace($key, $var, $compress=0, $expire=0) {
+ public function replace($key, $var, $compress=NULL, $expire=NULL) {
$time1=$this->getmicrotime();
+ if($compress==NULL) $compres = $this->default_compress();
+ if($expire==NULL) $expire = $this->default_expire();
$key = $this->site_id.trim($key);
$con = $this->_getConForKey($key);
if ($con === false) return false;
Modified: websites/bsdstats.org/bsdstats/sbin/cache.php
===================================================================
--- websites/bsdstats.org/bsdstats/sbin/cache.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/sbin/cache.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -11,6 +11,9 @@
$driver = $config->get('cache_driver','');
$tmp =& load_class('cache'.DIRECTORY_SEPARATOR.$driver);
if($driver!='' && $tmp!==false){
+ $tmp->set_site_id($config->get('cache_site_id',''));
+ $tmp->default_compress($config->get('cache_compress',''));
+ $tmp->default_expire($config->get('cache_expire',''));
switch($driver){
case 'memcached':
$tmp->connect($config->get('cache_memcached_server', 'localhost'),
Modified: websites/bsdstats.org/bsdstats/slib/format.php
===================================================================
--- websites/bsdstats.org/bsdstats/slib/format.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/slib/format.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -41,7 +41,7 @@
return $this->number_format($number,$decimal).$percent_sign;
}
- function bytes($bytes){
+ public function bytes($bytes){
if($bytes==0) return '0 b';
if($bytes/1024<1){
return $this->number_format($bytes).' b';
@@ -56,7 +56,7 @@
}
}
- function secs($secs){
+ public function secs($secs){
if($secs==0) return '0';
$d = (int)($secs/(24*3600)); $secs -= $d*24*3600;
$h = (int)($secs/3600); $secs -= $h*3600;
@@ -73,5 +73,17 @@
return $return;
}
+
+ public function text($text, $width, $cont_char='...', $if_empty='', $htmlchar=false){
+ if($text=='') $text = $if_empty;
+ if(strlen($text)>$width){
+ if($width>strlen(trim($cont_char))) $width -= strlen(trim($cont_char));
+ $tmp = wordwrap($text, $width, $cont_char."\n", true);
+ $tmps = explode($cont_char."\n",$tmp,2);
+ $text = $tmps[0];
+ }
+ if($htmlchar) $text = htmlentities($text);
+ return $text;
+ }
}
?>
\ No newline at end of file
Modified: websites/bsdstats.org/bsdstats/tpl/bsdstats/cpu.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/cpu.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/cpu.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -30,12 +30,12 @@
if($old_vendor!=''){
?></tbody><?php
}
- ?><thead class="ven_head" id="ven_head_<?php echo $i?>"><tr><th colspan="2"><?php echo $vendor['vendor']?></th></tr></thead><tbody id='ven_<?php echo $i?>'><?php
+ ?><thead class="tab_head" id="tab_head_<?php echo $i?>"><tr><th colspan="2"><?php echo $vendor['vendor']?></th></tr></thead><tbody id='tab_body_<?php echo $i?>'><?php
$old_vendor = $vendor['vendor'];
$i++;
}
?><tr>
- <td style="text-align:left;"><?php echo $vendor['cpu_type']?></td>
+ <td style="text-align:left;"><?php echo $format->text($vendor['cpu_type'],50,'...','-',true)?></td>
<td><?php echo $format->number($vendor['total'])?></td>
</tr><?php
}
Added: websites/bsdstats.org/bsdstats/tpl/bsdstats/driver.php
Modified: websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -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="#">Drivers/HW Stats</a></li>
+ <li><a href="<?php echo $drivers_uri?>">Drivers/HW 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/header.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/header.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/header.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" dir="ltr" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
-<title><?php echo htmlentities($title!=''?$title.': ':'')?>*BSD Usage Statistics</title><?php
+<title>*BSD Usage Statistics<?php echo htmlentities($title!=''?': '.$title:'')?></title><?php
foreach($link as $key=>$v1){
?><link <?php
foreach($v1 as $name=>$value){
Modified: websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -10,7 +10,7 @@
<li class="first"><a href="/">Home</a></li>
<li><a href="#">Release Stats</a></li>
<li><a href="<?php echo $countries_uri?>">Country Stats</a></li>
- <li><a href="#">Drivers/HW Stats</a></li>
+ <li><a href="<?php echo $drivers_uri?>">Drivers/HW 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/js/functions.js
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/js/functions.js 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/bsdstats.org/bsdstats/tpl/js/functions.js 2008-06-29 14:32:23 UTC (rev 2199)
@@ -1,7 +1,10 @@
// JavaScript Document
$(function(){
// Document is ready
- $('.ven_head').click(function() {
- $('#ven_' + $(this).attr('id').substring(9)).toggle();
- });
+ $('.tab_head').click(function() {
+ $('#tab_body_' + $(this).attr('id').substring(9)).toggle();
+ }).dblclick(function() {
+ $('#tab_body_' + $(this).attr('id').substring(9)).siblings("tbody").hide();
+ $('#tab_body_' + $(this).attr('id').substring(9)).show();
+ });
});
Modified: websites/pbidir.com/bibivu/etc/autoload.conf.php
===================================================================
--- websites/pbidir.com/bibivu/etc/autoload.conf.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/pbidir.com/bibivu/etc/autoload.conf.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -11,7 +11,7 @@
|
| when it is true, it will load the configuration in [key].conf.php, and it will load the correspondingclass
*/
-$autoload['class']['cache'] = true;
+$autoload['class']['cache'] = false;
$autoload['lib']['display'] = true;
//$autoload['lib']['db'.DIRECTORY_SEPARATOR.'mysql'] = true;
Modified: websites/pbidir.com/bibivu/etc/cache.conf.php
===================================================================
--- websites/pbidir.com/bibivu/etc/cache.conf.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/pbidir.com/bibivu/etc/cache.conf.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -5,7 +5,37 @@
| -------------------------------------------------------------------------
*/
$cache['driver'] = 'memcached';
+
+/*
+memcached settings
+*/
$cache['memcached_server'] = 'localhost';
$cache['memcached_port'] = '11211';
$cache['memcached_timeout'] = '1';
+
+/*
+those are the default settings for the function :
+ - set
+ - add
+ - replace
+
+They can be also manually set when calling the functions.
+
+if set to NULL, the default values will be:
+ - compress: false
+ - expire: 0 (never expire)
+*/
+$cache['compress'] = true;
+$cache['expire'] = 3600;
+
+/*
+in case we use a type of cache that can be shae between multiple sites (I.E.: memcached)
+we can set the "site_id" to different values for each site,
+this will allow you to use the same variable names between different sites
+but the people on the same site will see the shared variable
+
+default = ''
+
+*/
+$cache['site_id'] = '';
?>
\ No newline at end of file
Modified: websites/pbidir.com/bibivu/sbin/cache/memcached.php
===================================================================
--- websites/pbidir.com/bibivu/sbin/cache/memcached.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/pbidir.com/bibivu/sbin/cache/memcached.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -11,6 +11,10 @@
public $numIncrement = 0;
public $numDecrement = 0;
public $total_time = 0;
+
+ public $compress = false;
+ public $expire = 0;
+
public function __construct() {
parent::$instance =&$this;
@@ -20,10 +24,30 @@
$this->connections = array();
}
- public function set_site_id($site_id){
- $this->site_id = $site_id;
+ //set or return default site_id values
+ public function set_site_id($site_id=NULL){
+ if($site_id!=NULL){
+ $this->site_id = $site_id;
+ }
+ return $this->site_id;
}
+ //set or return default compress values
+ public function default_compress($compress=NULL){
+ if($compress!=NULL){
+ $this->compress = (bool)$compress;
+ }
+ return $this->compress;
+ }
+
+ //set or return default expire values
+ public function default_expire($expire=NULL){
+ if($expire!=NULL){
+ $this->expire = $expire+0;
+ }
+ return $this->expire;
+ }
+
public function close(){
$result = false;
for ($i = 0; $i < count($this->connections); $i++) {
@@ -106,23 +130,24 @@
}
}
- public function set($key, $var, $compress=0, $expire=0) {
-// echo 'setting here: '.$key.':<br />'; var_dump($var);
-// mail('fabrizio at bibivu.com',$key,var_export($var,true));
+ public function set($key, $var, $compress=NULL, $expire=NULL) {
$time1=$this->getmicrotime();
+ if($compress==NULL) $compres = $this->default_compress();
+ if($expire==NULL) $expire = $this->default_expire();
$key = $this->site_id.trim($key);
$con = $this->_getConForKey($key);
if ($con === false) return false;
$this->numSet++;
-// mail('fabrizio at bibivu.com','[bibivu]->memcached->set->'.$key,'setting up key '.$key);
$return = $con->set($key, $var, $compress, $expire);
$time2=$this->getmicrotime();
$this->total_time += $time2-$time1;
return $return;
}
- public function add($key, $var, $compress=0, $expire=0) {
+ public function add($key, $var, $compress=NULL, $expire=NULL) {
$time1=$this->getmicrotime();
+ if($compress==NULL) $compres = $this->default_compress();
+ if($expire==NULL) $expire = $this->default_expire();
$key = $this->site_id.trim($key);
$con = $this->_getConForKey($key);
if ($con === false) return false;
@@ -133,8 +158,10 @@
return $return;
}
- public function replace($key, $var, $compress=0, $expire=0) {
+ public function replace($key, $var, $compress=NULL, $expire=NULL) {
$time1=$this->getmicrotime();
+ if($compress==NULL) $compres = $this->default_compress();
+ if($expire==NULL) $expire = $this->default_expire();
$key = $this->site_id.trim($key);
$con = $this->_getConForKey($key);
if ($con === false) return false;
Modified: websites/pbidir.com/bibivu/sbin/cache.php
===================================================================
--- websites/pbidir.com/bibivu/sbin/cache.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/pbidir.com/bibivu/sbin/cache.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -11,6 +11,9 @@
$driver = $config->get('cache_driver','');
$tmp =& load_class('cache'.DIRECTORY_SEPARATOR.$driver);
if($driver!='' && $tmp!==false){
+ $tmp->set_site_id($config->get('cache_site_id',''));
+ $tmp->default_compress($config->get('cache_compress',''));
+ $tmp->default_expire($config->get('cache_expire',''));
switch($driver){
case 'memcached':
$tmp->connect($config->get('cache_memcached_server', 'localhost'),
Modified: websites/pbidir.com/bibivu/slib/format.php
===================================================================
--- websites/pbidir.com/bibivu/slib/format.php 2008-06-28 21:42:03 UTC (rev 2198)
+++ websites/pbidir.com/bibivu/slib/format.php 2008-06-29 14:32:23 UTC (rev 2199)
@@ -41,7 +41,7 @@
return $this->number_format($number,$decimal).$percent_sign;
}
- function bytes($bytes){
+ public function bytes($bytes){
if($bytes==0) return '0 b';
if($bytes/1024<1){
return $this->number_format($bytes).' b';
@@ -56,7 +56,7 @@
}
}
- function secs($secs){
+ public function secs($secs){
if($secs==0) return '0';
$d = (int)($secs/(24*3600)); $secs -= $d*24*3600;
$h = (int)($secs/3600); $secs -= $h*3600;
@@ -73,5 +73,17 @@
return $return;
}
+
+ public function text($text, $width, $cont_char='...', $if_empty='', $htmlchar=false){
+ if($text=='') $text = $if_empty;
+ if(strlen($text)>$width){
+ if($width>strlen(trim($cont_char))) $width -= strlen(trim($cont_char));
+ $tmp = wordwrap($text, $width, $cont_char."\n", true);
+ $tmps = explode($cont_char."\n",$tmp,2);
+ $text = $tmps[0];
+ }
+ if($htmlchar) $text = htmlentities($text);
+ return $text;
+ }
}
?>
\ No newline at end of file
More information about the Commits
mailing list