[PC-BSD Commits] r2174 - in websites: bsdstats.org bsdstats.org/bsdstats/bin bsdstats.org/bsdstats/lib bsdstats.org/bsdstats/sbin bsdstats.org/bsdstats/slib/db bsdstats.org/bsdstats/tpl/bsdstats bsdstats.org/bsdstats/tpl/css pbidir.com/bibivu/sbin pbidir.com/bibivu/slib/db

svn at pcbsd.org svn at pcbsd.org
Wed Jun 25 20:11:35 PDT 2008


Author: fabry
Date: 2008-06-25 20:11:34 -0700 (Wed, 25 Jun 2008)
New Revision: 2174

Added:
   websites/bsdstats.org/bsdstats/lib/bsdstats.php
   websites/bsdstats.org/bsdstats/tpl/bsdstats/country.php
   websites/bsdstats.org/index_pre_fp.php
Removed:
   websites/bsdstats.org/index_new.php
Modified:
   websites/bsdstats.org/.htaccess
   websites/bsdstats.org/bsdstats/bin/start.php
   websites/bsdstats.org/bsdstats/sbin/uri.php
   websites/bsdstats.org/bsdstats/slib/db/pgsql.php
   websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php
   websites/bsdstats.org/bsdstats/tpl/bsdstats/footer.php
   websites/bsdstats.org/bsdstats/tpl/bsdstats/home.php
   websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php
   websites/bsdstats.org/bsdstats/tpl/css/bsdstats.css
   websites/bsdstats.org/index.php
   websites/pbidir.com/bibivu/sbin/uri.php
   websites/pbidir.com/bibivu/slib/db/pgsql.php
Log:
new bsdstats is live. adding more pages.

Countries page is live.

Modified: websites/bsdstats.org/.htaccess
===================================================================
--- websites/bsdstats.org/.htaccess	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/bsdstats.org/.htaccess	2008-06-26 03:11:34 UTC (rev 2174)
@@ -1,7 +1,7 @@
 RewriteEngine On
 
 RewriteCond %{REQUEST_URI} !.php|.css|.js|.jpg|.jpeg|.gif|.png|.txt|.statistics|.sh$
-	RewriteRule ^(.*)$ /index_new.php/$1 [L]
+	RewriteRule ^(.*)$ /index.php/$1 [L]
 
 
 ###############################################

Modified: websites/bsdstats.org/bsdstats/bin/start.php
===================================================================
--- websites/bsdstats.org/bsdstats/bin/start.php	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/bsdstats.org/bsdstats/bin/start.php	2008-06-26 03:11:34 UTC (rev 2174)
@@ -14,6 +14,7 @@
 
 		//assigning common links
 		$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')));
 
 
 		$task = $this->uri->get(TASK_KEY, '');
@@ -31,40 +32,11 @@
 		$this->display->end($show_head_foot,'bsdstats');
 	}
 	
-	public function get_list_os(){
-		//maybe have a table with those information in it?
-		return array('FreeBSD',
-					  'DragonFly',
-					  'OpenBSD',
-					  'NetBSD',
-					  'PC-BSD',
-					  'DesktopBSD',
-					  'MidnightBSD',
-					  'MirBSD',
-					  'GNU/kFreeBSD',
-					  );
-	}
-
 	public function web_home(){
-		$tmps = $this->db->query('SELECT operating_system, 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 (\''.implode('\',\'',$this->get_list_os()).'\')
-									AND ls.report_month = ls2.max
-								GROUP BY operating_system
-								ORDER BY count DESC;');
-		
-		$top_os = array();
-		$total = 0;
-		while($tmp = $this->db->fetch_array($tmps)){
-			$total += $tmp['count'];
-			$tmp['image'] = strtolower(str_replace(array('-','/'),'',$tmp['operating_system']));
-			$top_os[] = $tmp;
-		}
+		$tmp = load_library('bsdstats')->os_summary();
 
-		$this->display->assign('top_os', $top_os);
-		$this->display->assign('total', $total);
+		$this->display->assign('top_os', $tmp['os_summary']);
+		$this->display->assign('total', $tmp['total']);
 		$this->display->assign('title', 'Home');
 		$this->display('home');
 	}
@@ -73,5 +45,16 @@
 		$this->display->assign('title', 'Instructions');
 		$this->display('instructions');
 	}
+
+	public function web_countries(){
+		$tmp = load_library('bsdstats')->countries();
+
+		$this->display->assign('countries', $tmp['countries']);
+		$this->display->assign('countries_stats', $tmp['countries_stats']);
+		$this->display->assign('total', $tmp['total']);
+		$this->display->assign('title', 'Country Stats');
+		$this->display('country');
+	}
+
 }
 ?>
\ No newline at end of file

Added: websites/bsdstats.org/bsdstats/lib/bsdstats.php

Modified: websites/bsdstats.org/bsdstats/sbin/uri.php
===================================================================
--- websites/bsdstats.org/bsdstats/sbin/uri.php	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/bsdstats.org/bsdstats/sbin/uri.php	2008-06-26 03:11:34 UTC (rev 2174)
@@ -243,6 +243,9 @@
 	 * @return	string
 	 */ 
 	public function create_uri($query=NULL, $page=NULL, $domain=NULL, $secure=NULL, $port=NULL ){
+		if(!isset($_SERVER['HTTP_HOST'])){
+			$_SERVER['HTTP_HOST'] = '';
+		}
 		if($domain	=== NULL)			$domain =  (strrpos($_SERVER['HTTP_HOST'], ':') > 0)?substr($_SERVER['HTTP_HOST'], 0, strrpos($_SERVER['HTTP_HOST'], ':')):$_SERVER['HTTP_HOST'];
 		if(!is_array($query))			$query = $this->GET;
 

Modified: websites/bsdstats.org/bsdstats/slib/db/pgsql.php
===================================================================
--- websites/bsdstats.org/bsdstats/slib/db/pgsql.php	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/bsdstats.org/bsdstats/slib/db/pgsql.php	2008-06-26 03:11:34 UTC (rev 2174)
@@ -378,7 +378,7 @@
 			$this->errno=0;
 		} else {
 			//no connection, just gettin the last error from Pgsql
-			$this->errdesc=pg_last_error();
+			$this->errdesc='no connection';
 			$this->errno=0;
 		}
 		if(!isset($_SESSION[$this->appname][$this->errno]) || ($_SESSION[$this->appname][$this->errno]+(60*15))>time()){

Added: websites/bsdstats.org/bsdstats/tpl/bsdstats/country.php

Modified: websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/foot_menu.php	2008-06-26 03:11:34 UTC (rev 2174)
@@ -4,7 +4,7 @@
     <li class="first"><a href="/">Home</a></li>
     <li><a href="<?php echo $instructions_uri?>">Instructions</a></li>
     <li><a href="#">Release Stats</a></li>
-    <li><a href="cc_test.php">Country 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="#">CPU Stats</a></li>
     <li><a href="#">Port Stats</a></li>

Modified: websites/bsdstats.org/bsdstats/tpl/bsdstats/footer.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/footer.php	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/footer.php	2008-06-26 03:11:34 UTC (rev 2174)
@@ -1,10 +1,8 @@
-</div>
 <div id="footer">
 	<div class="separ"><hr/></div>
   </div><?php
 	$this->show('bsdstats/foot_menu');
 	?>
 </div>
-</div>
 </body>
 </html>

Modified: websites/bsdstats.org/bsdstats/tpl/bsdstats/home.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/home.php	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/home.php	2008-06-26 03:11:34 UTC (rev 2174)
@@ -13,10 +13,11 @@
     to <a href="mailto:scrappy at freebsd.org">scrappy at freebsd.org</a>.</p>
   Project hosted by <a href="http://www.hub.org">Hub.Org Networking Services</a><br/>
   Web Design by Antony Mawer<br />
-  Web Programmed by Fabrizio Parrella</div>
+  Web Programmed by Fabrizio Parrella
+</div>
 
 <!-- Operating Systems Summary -->
-<div style="float: right;" id="os-summary">
+<div id="os-summary">
 <h3>Operating System Summary</h3>
 <table cellspacing="0" cellpadding="0" class="stats-simple stats-large">
   <tbody>
@@ -28,8 +29,8 @@
 foreach($top_os as $os){
 	?><tr>
       <td class="oslogo"><img border="0" alt="<?php echo $os['operating_system']?>" src="/images/<?php echo $os['image']?>_logo_sm.png"/></td>
-      <td><?php echo load_library('format')->number($os['count'])?></td>
-      <td><?php echo load_library('format')->percent(($os['count']/$total)*100,2,' %')?></td>
+      <td><?php echo load_library('format')->number($os['cnt'])?></td>
+      <td><?php echo load_library('format')->percent(($os['cnt']/$total)*100,2,' %')?></td>
     </tr><?php
 }
 ?><tr class="total">
@@ -39,3 +40,4 @@
     </tr>
   </tbody>
 </table>
+</div>

Modified: websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/bsdstats.org/bsdstats/tpl/bsdstats/menu.php	2008-06-26 03:11:34 UTC (rev 2174)
@@ -9,7 +9,7 @@
 -->
       <li class="first"><a href="/">Home</a></li>
       <li><a href="#">Release Stats</a></li>
-      <li><a href="cc_test.php">Country 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="#">CPU Stats</a></li>
       <li><a href="#">Port Stats</a></li>

Modified: websites/bsdstats.org/bsdstats/tpl/css/bsdstats.css
===================================================================
--- websites/bsdstats.org/bsdstats/tpl/css/bsdstats.css	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/bsdstats.org/bsdstats/tpl/css/bsdstats.css	2008-06-26 03:11:34 UTC (rev 2174)
@@ -106,8 +106,9 @@
 .stats-simple th {
     background-color: #999999;
     color: #efefef;
-
     padding: 4px 12px;
+	border-left:1px solid #666666;
+	border-bottom:1px solid #666666;
 }
 .stats-simple td {
     text-align: right;
@@ -126,7 +127,7 @@
 
 .stats-large td {
     padding: 8px;
-    font-size: 125%;
+    font-size: 14px;
     border-bottom: 1px solid #c0c0c0;
 }
 
@@ -143,6 +144,14 @@
     clear: both;
     padding-top: 1em;
 }
+.country th{
+	font-size: 10px;
+    padding: 4px;
+}
+.country td{
+	font-size: 10px;
+    padding: 4px;
+}
 #adsense { margin-top: 1.5em; }
 
 /*******************

Modified: websites/bsdstats.org/index.php
===================================================================
--- websites/bsdstats.org/index.php	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/bsdstats.org/index.php	2008-06-26 03:11:34 UTC (rev 2174)
@@ -1,33 +1,151 @@
 <?php
-require_once('BSDSmarty.class.php');
-require_once('Stats/BSDStatsSummary.class.php');
+/*
+  BIBIVU SYSTEM
+  Based on various other systems
+  picking and choosing what Fabrizio Parrella, the creator, likes
+*/
+if(!defined('DIRECTORY_SEPARATOR'))	define('DIRECTORY_SEPARATOR',strtoupper(substr(PHP_OS,0,3)=='WIN')?'\\':'/');
+define('APPNAME', 'bibivu');
+define('VERSION', '5.0.0');
 
-//
-// Retrieve statistics
-//
+/*
+|---------------------------------------------------------------
+| PHP ERROR REPORTING LEVEL
+|---------------------------------------------------------------
+|
+| By default BBV runs with error reporting set to ALL.  For security
+| reasons you are encouraged to change this when your site goes live.
+| For more info visit:  http://www.php.net/error_reporting
+|
+*/
+	error_reporting(E_STRICT+E_ALL);
 
+/*
+|---------------------------------------------------------------
+| SYSTEM FOLDER NAME
+|---------------------------------------------------------------
+|
+| This variable must contain the name of your "bibivu" folder.
+| This will be the path where the whole system will be located
+| Include the path if the folder is not in the same  directory
+| as this file.
+|
+| NO TRAILING SLASH!
+|
+*/
+	$bibivu_main_folder = 'bsdstats';
 
-//
-// Display the page
-//  
-$smarty = new BSDSmarty;
-// Create a new BSDStats summary object
-$stats = new BSDStatsSummary;
-$smarty->assign_by_ref('stats', $stats);
+/*
+|===============================================================
+| END OF USER CONFIGURABLE SETTINGS
+|===============================================================
+*/
 
-// Create instances for each OS
-$systems = array();
-foreach ($stats->GetSupportedSystems() as $system) {
-    $system = str_replace('/', '', $system);
-    $system = str_replace('-', '', $system);
-    if (file_exists("/usr/local/www/bsdstats.org/www/_includes/Stats/$system.class.php")) {
-        require_once("Stats/$system.class.php");
-        $class_name = "${system}Stats";
-        $systems[$system] = new $class_name;
-    }
+
+/*
+|---------------------------------------------------------------
+| SET THE SERVER PATH
+|---------------------------------------------------------------
+|
+| Let's attempt to determine the full-server path to the "system"
+| folder in order to reduce the possibility of path problems.
+| Note: We only attempt this if the user hasn't specified a 
+| full server path.
+|
+*/
+if (strpos($bibivu_main_folder, DIRECTORY_SEPARATOR) === false){
+	if (function_exists('realpath') && @realpath(dirname(__FILE__)) !== false){
+		$bibivu_folder = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR.$bibivu_main_folder;
+	}
+}else{
+	// Swap directory separators to "DIRECTORY_SEPARATOR" style for consistency
+	$bibivu_folder = str_replace(array('\\','/'), DIRECTORY_SEPARATOR, $bibivu_main_folder); 
 }
-$smarty->assign_by_ref('systems', $systems);
 
+/*
+|---------------------------------------------------------------
+| DEFINE APPLICATION CONSTANTS
+|---------------------------------------------------------------
+|
+| EXT		- The file extension.  Typically ".php"
+| SELF		- The name of THIS file (typically "index.php")
+| FULLPATH	- The full server path to THIS file
+| WEBPATH	- The relative path that will be used for direct access to internal weblinks (index.php level)
+| BASEPATH	- The full server path to the "system" folder
+| ETCPATH	- The full server path to the "configuration and more" folder
+| SBINPATH	- The full server path to the "system binary" folder
+| BINPATH	- The full server path to the "binary" folder - your programs
+| SLIBPATH	- The full server path to the "system library" folder
+| LIBPATH	- The full server path to the "library" folder
+| TPLPATH	- The full server path to the "templates" folder
+| TPLWEBPATH	- The full server path to the "templates" folder accessible from the WEB
+|
+|
+|   the following needs to be writable by the webserver user
+|
+| TMPPATH	- The full server path to the "temporary" folder	- set this as temporary folder
+| USRPATH	- The full server path to the "user" folder
+| HOMEPATH	- The full server path to the "home" folder			- this will contain the site folders
+|
+*/
+define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
+define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
+define('FULLPATH', pathinfo(__FILE__, PATHINFO_DIRNAME).DIRECTORY_SEPARATOR);
+define('BASEPATH', $bibivu_folder.DIRECTORY_SEPARATOR);
+define('WEBPATH', str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR,DIRECTORY_SEPARATOR,pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME).DIRECTORY_SEPARATOR));
+define('ETCPATH',	BASEPATH.'etc'.DIRECTORY_SEPARATOR);
+define('BINPATH',	BASEPATH.'bin'.DIRECTORY_SEPARATOR);
+define('SBINPATH',	BASEPATH.'sbin'.DIRECTORY_SEPARATOR);
+define('SLIBPATH',	BASEPATH.'slib'.DIRECTORY_SEPARATOR);
+define('LIBPATH',	BASEPATH.'lib'.DIRECTORY_SEPARATOR);
+define('TPLPATH',	BASEPATH.'tpl'.DIRECTORY_SEPARATOR);
+define('TPLWEBPATH', WEBPATH.$bibivu_main_folder.DIRECTORY_SEPARATOR.'tpl'.DIRECTORY_SEPARATOR);
+//define('TMPPATH',	ini_get('upload_tmp_dir'));		//this is the default temporary folder for php
+define('TMPPATH',	BASEPATH.'tmp'.DIRECTORY_SEPARATOR);				//or you can leave it empty to use a site_driven temporary folder
+define('USRPATH',	BASEPATH.'usr'.DIRECTORY_SEPARATOR);
+define('HOMEPATH',	USRPATH.'home'.DIRECTORY_SEPARATOR);
 
-$smarty->display('index.tpl');
-?>
+/*
+| This is the name that will be passed to the GET string to load the main class
+| if nothing is passed, a class called "default_bibivu" will be loaded
+*/
+define('CLASS_KEY','bm');
+
+/*
+| This is the name that will be passed to the GET string to load the function in the main class
+| if nothing is passed, a class called DEFAULT will be loaded
+*/
+define('TASK_KEY','bt');
+
+/*
+| This is the name for the default class that will be loaded
+*/
+//define('STARTUP','default_bibivu');
+//define('STARTUP','pbi');
+define('STARTUP','start');
+
+/*
+|---------------------------------------------------------------
+| AND HERE WE START....
+|---------------------------------------------------------------
+*/
+require_once BASEPATH.'include'.DIRECTORY_SEPARATOR.'_functions'.EXT;
+
+$config		= load_class('config', true);
+$uri		= load_class('uri', true, $config);
+$startup	= $uri->get(CLASS_KEY);
+if($startup==''){
+	load_class(STARTUP, true);
+} else {
+	//I should show an error if the class doesn't exists
+	load_class($startup, true);
+}
+/*
+if($bibivu	=& load_class('bibivu')){
+	return $bibivu->start();
+} else {
+	echo 'CANNOT START PROCESS!! bibivu Class Doesn\'t Exists !!!';
+	return 1;
+}
+*/
+?>
\ No newline at end of file

Deleted: websites/bsdstats.org/index_new.php

Added: websites/bsdstats.org/index_pre_fp.php

Modified: websites/pbidir.com/bibivu/sbin/uri.php
===================================================================
--- websites/pbidir.com/bibivu/sbin/uri.php	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/pbidir.com/bibivu/sbin/uri.php	2008-06-26 03:11:34 UTC (rev 2174)
@@ -243,6 +243,9 @@
 	 * @return	string
 	 */ 
 	public function create_uri($query=NULL, $page=NULL, $domain=NULL, $secure=NULL, $port=NULL ){
+		if(!isset($_SERVER['HTTP_HOST'])){
+			$_SERVER['HTTP_HOST'] = '';
+		}
 		if($domain	=== NULL)			$domain =  (strrpos($_SERVER['HTTP_HOST'], ':') > 0)?substr($_SERVER['HTTP_HOST'], 0, strrpos($_SERVER['HTTP_HOST'], ':')):$_SERVER['HTTP_HOST'];
 		if(!is_array($query))			$query = $this->GET;
 

Modified: websites/pbidir.com/bibivu/slib/db/pgsql.php
===================================================================
--- websites/pbidir.com/bibivu/slib/db/pgsql.php	2008-06-25 17:09:03 UTC (rev 2173)
+++ websites/pbidir.com/bibivu/slib/db/pgsql.php	2008-06-26 03:11:34 UTC (rev 2174)
@@ -374,11 +374,11 @@
 		// only once per session or every 15 minutes
 		
 		if($this->link_id){
-			$this->errdesc=pg_result_error($this->link_id);
+			$this->errdesc=pg_last_error($this->link_id);
 			$this->errno=0;
 		} else {
 			//no connection, just gettin the last error from Pgsql
-			$this->errdesc=pg_last_error();
+			$this->errdesc='no connection';
 			$this->errno=0;
 		}
 		if(!isset($_SESSION[$this->appname][$this->errno]) || ($_SESSION[$this->appname][$this->errno]+(60*15))>time()){



More information about the Commits mailing list