[PC-BSD Commits] r2035 - in websites/pbidir.com/bibivu: bin lib sbin slib tpl/pbidir

svn at pcbsd.org svn at pcbsd.org
Sat Jun 7 05:58:02 PDT 2008


Author: fabry
Date: 2008-06-07 05:58:01 -0700 (Sat, 07 Jun 2008)
New Revision: 2035

Modified:
   websites/pbidir.com/bibivu/bin/start.php
   websites/pbidir.com/bibivu/lib/permissions.php
   websites/pbidir.com/bibivu/sbin/user_info.php
   websites/pbidir.com/bibivu/slib/lang.php
   websites/pbidir.com/bibivu/tpl/pbidir/download.php
Log:
fixed a warning message and starting to integrate the user_info class.

Modified: websites/pbidir.com/bibivu/bin/start.php
===================================================================
--- websites/pbidir.com/bibivu/bin/start.php	2008-06-07 10:10:24 UTC (rev 2034)
+++ websites/pbidir.com/bibivu/bin/start.php	2008-06-07 12:58:01 UTC (rev 2035)
@@ -632,7 +632,7 @@
 			$uri = $this->display->get('pbi_uri').'/'.$pbi['id'];
 		}
 		if($this->permissions->can('pbi_comment')){
-			if($comment!='' && $this->pbi->add_comment($pbi['id'], htmlentities($comment, ENT_COMPAT, 'UTF-8'), $this->permissions->get('id',''),$this->permissions->get('user',''), $this->permissions->IP())!==false){
+			if($comment!='' && $this->pbi->add_comment($pbi['id'], htmlentities($comment, ENT_COMPAT, 'UTF-8'), $this->permissions->get('id',''),$this->permissions->get('user',''), load_class('user_info')->IP())!==false){
 				if($this->ajax){
 					$xml = array('message'=>array(
 									'error'		=> '',

Modified: websites/pbidir.com/bibivu/lib/permissions.php
===================================================================
--- websites/pbidir.com/bibivu/lib/permissions.php	2008-06-07 10:10:24 UTC (rev 2034)
+++ websites/pbidir.com/bibivu/lib/permissions.php	2008-06-07 12:58:01 UTC (rev 2035)
@@ -246,21 +246,5 @@
 		$tmp = $this->select()->field('id')->where($filters)->do_db()->db->fetch_array($this->last_result());
 		return isset($tmp['id']);
 	}
-	
-	public function IP(){
-		if(!isset($this->IP) || $this->IP==''){
-			$tmp = array();
-			if  (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && strpos($_SERVER['HTTP_X_FORWARDED_FOR'],',')) {
-			   $tmp += explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
-			} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
-			   $tmp[] = trim($_SERVER['HTTP_X_FORWARDED_FOR']);
-			}elseif(isset($_SERVER['HTTP_CLIENT_IP'])) {
-			   $tmp[] = trim($_SERVER['HTTP_CLIENT_IP']);
-			}
-			$tmp[] = trim($_SERVER['REMOTE_ADDR']);
-			$this->IP = trim(str_replace('unknown','',strtolower(implode("\n",$tmp))));
-		}
-		return $this->IP;
-	}
 }
 ?>
\ No newline at end of file

Modified: websites/pbidir.com/bibivu/sbin/user_info.php
===================================================================
--- websites/pbidir.com/bibivu/sbin/user_info.php	2008-06-07 10:10:24 UTC (rev 2034)
+++ websites/pbidir.com/bibivu/sbin/user_info.php	2008-06-07 12:58:01 UTC (rev 2035)
@@ -6,7 +6,7 @@
  the function get() it will return the whole list of information
  
  TO-DO:
-  - break each info into different functions that the user can call separately
+  - allow plugins
 */
 class user_info {
 	private $info = array();
@@ -22,209 +22,238 @@
 			$return['URL']				= $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];
 			//return the request method (get,post ...)
 			$return['RequestMethod']	= $_SERVER['REQUEST_METHOD'];
-			//return the user agent
-			$UserAgent					= isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:'';
-			$return['UserAgent']		= $UserAgent;
-			//return the Browser
-			if(($pos = strpos($UserAgent,'MSIE')) !== false) {
-				$Browser='Internet Explorer';
-				$pos+=strlen('MSIE')+1;
-				$endPos=strpos($UserAgent,';',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Firefox')) !== false) {
-				$Browser='Mozilla Firefox';
-				$pos+=strlen('Firefox')+1;
-				$endPos=strpos($UserAgent,';',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Mozilla Firebird')) !== false) {
-				$Browser='Mozilla Firebird';
-				$pos+=strlen('Mozilla Firebird')+1;
-				$endPos=strpos($UserAgent,';',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Netscape')) !== false) {
-				$Browser='Netscape Navigator';
-				$pos+=strlen('Netscape')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Konqueror')) !== false) {
-				$Browser='Konqueror';
-				$pos+=strlen('Konqueror')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Mozilla')) !== false) {
-				$Browser='Mozilla';
-				$pos+=strlen('Mozilla')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Opera')) !== false) {
-				$Browser='Opera';
-				$pos+=strlen('Opera')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'msnbot')) !== false) {
-				$Browser='MSNBot';
-				$pos+=strlen('msnbot')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'HTMLParser')) !== false) {
-				$Browser='HTMLParser';
-				$pos+=strlen('HTMLParser')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'SurveyBot')) !== false) {
-				$Browser='SurveyBot - Whois Source';
-				$pos+=strlen('SurveyBot')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Googlebot-Image')) !== false) {
-				$Browser='Google Image';
-				$pos+=strlen('Googlebot')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Googlebot')) !== false) {
-				$Browser='Google';
-				$pos+=strlen('Googlebot')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Feedfetcher')) !== false) {
-				$Browser='Feedfetcher-Google';
-				$pos+=strlen('Feedfetcher')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Gigabot')) !== false) {
-				$Browser='Gigabot';
-				$pos+=strlen('Gigabot')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Slurp')) !== false) {
-				$Browser='Yahoo Slurp';
-				$pos+=strlen('Slurp')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else if(($pos = strpos($UserAgent,'Alexa')) !== false) {
-				$Browser='Alexa (IA Archive)';
-				$pos+=strlen('Alexa')+1;
-				$endPos=strpos($UserAgent,' ',$pos);
-				$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
-				$BrowserVersion = substr($UserAgent,$pos,$endPos);
-			} else {
-				$Browser='Not Detected';
-				$BrowserVersion='';
-			}
-			$return['BrowserName']		= $Browser;
-			$return['BrowserVersion']	= $BrowserVersion;
-			$return['Browser']			= $Browser.' v.'.$BrowserVersion;
-			//return the OS
-			if(eregi('Windows',$UserAgent)) {
-				$OS='Windows';
-			} else if(eregi('Linux',$UserAgent)) {
-				$OS='Linux';
-			} else if(eregi('Unix',$UserAgent)) {
-				$OS='Unix';
-			} else if(eregi('PC-BSD',$UserAgent)) {
-				$OS='PC-BSD';
-			} else if(eregi('FreeBSD',$UserAgent)) {
-				$OS='FreeBSD';
-			} else if(eregi('BSD',$UserAgent)) {
-				$OS='BSD';
-			} else if(eregi('Mac',$UserAgent)) {
-				$OS='Macintosh';
-			} else if(eregi('SunOS',$UserAgent)) {
-				$OS='SunOS';
-			} else if(eregi('HP-UX',$UserAgent)) {
-				$OS='Unix';
-			} else if(eregi('IRIX',$UserAgent)) {
-				$OS='Unix';
-			} else if(eregi('Netcraft',$UserAgent)) {
-				$OS='Netcraft';
-			} else if(eregi('Googlebot',$UserAgent)) {
-				$OS='Googlebot';
-			} else if(eregi('SurveyBot',$UserAgent)) {
-				$OS='Whois Source';
-			} else if(eregi('Yahoo! Slurp',$UserAgent)) {
-				$OS='Yahoo! Slurp';
-			} else if(eregi('Gigabot',$UserAgent)) {
-				$OS='Gigabot';
-			} else if(eregi('HTMLParser',$UserAgent)) {
-				$OS='HTMLParser';
-			} else if(eregi('robot',$UserAgent)) {
-				$OS='robot';
-			} else {
-				$OS='Not Detected';
-			}
-			$return['OS']	= $OS;
-			//return the Accepted Languages
-			if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
-				$lArr=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
-				foreach($lArr as $k => $v) {
-					$vArr=explode(';',$v);
-					$vArr[1]=(!empty($vArr[1])) ? str_replace('q=','',$vArr[1]) : '1.0';
-					$tmplCArr[$vArr[0]]=$vArr[1];
-				}
-				foreach($tmplCArr as $lC=>$qV) {
-					$lC = strtolower(trim($lC));
-					$langArr[]=array('langCode'=>$lC,'langName'=>$this->_lang_details($lC),'langQValue'=>$qV);
-				}
-			} else {
-				$langArr[]=array('langCode'=>'*','langName'=>'all languages are equally acceptable','langQValue'=>'1.0');
-			}
-			$return['AcceptedLanguage']=$langArr;
-			//return the Accepted Encoding
-			if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) && !empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
-				$eArr=explode(',',$_SERVER['HTTP_ACCEPT_ENCODING']);
-				foreach($eArr as $k => $v) {
-					$vArr=explode(';',$v);
-					$vArr[1]=(!empty($vArr[1])) ? str_replace('q=','',$vArr[1]) : 1.0;
-					$encArr[]=array('encoding'=>$vArr[0],'encodingQValue'=>$vArr[1]);
-				}
-			} else {
-				$encArr[]=array('encoding'=>'','encodingQValue'=>1.0);
-			}
-			$return['AcceptedEncoding']=$encArr;
-			//return the Accepted Charset
-			if(isset($_SERVER['HTTP_ACCEPT_CHARSET']) && !empty($_SERVER['HTTP_ACCEPT_CHARSET'])) {
-				$cArr=explode(',',$_SERVER['HTTP_ACCEPT_CHARSET']);
-				foreach($cArr as $k => $v) {
-					$vArr=explode(';',$v);
-					$vArr[1]=(!empty($vArr[1])) ? str_replace('q=','',$vArr[1]) : 1.0;
-					$charsetArr[]=array('charset'=>$vArr[0],'charsetQValue'=>$vArr[1]);
-				}
-			} else {
-				$charsetArr[]=array('charset'=>'','charsetQValue'=>1.0);
-			}
-			$return['AcceptedCharset']=$charsetArr;
-			//return the IP Address
-			if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
-			   $IP = getenv( 'HTTP_X_FORWARDED_FOR' );
-			}elseif( getenv( 'HTTP_CLIENT_IP' ) ) {
-			   $IP = getenv( 'HTTP_CLIENT_IP' );
-			}else{
-			   $IP = getenv( 'REMOTE_ADDR' );
-			}
-			$return['IP'] = $IP;
+			
+			$return['user_agent']		= $this->user_agent();
+			$return['browser']			= $this->broser();
+			$return['os']				= $this->os();
+			$return['language']			= $this->language();
+			$return['encoding']			= $this->encoding();
+			$return['charset']			= $this->charset();
+			$return['IP']				= $this->IP();
+			$return['is_crawler']		= $this->is_crawler();
 			//return the Country
 //			$return['country'] = phpAds_geoip_getGeo($IP, dirname(__FILE__).'/files_includes/geoip/GeoIP-106_20040501.dat');
 			//check if it is crawler
-			$return['is_crawler'] = $this->is_crawler();
 			$this->info = $return;
 		}
 		return $this->info;
 	}
+	
+	public function user_agent(){
+		//return the user agent
+		return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:'';
+	}
+	public function browser(){
+		//return the Browser
+		$UserAgent = $this->user_agent();
+		if(($pos = strpos($UserAgent,'MSIE')) !== false) {
+			$Browser='Internet Explorer';
+			$pos+=strlen('MSIE')+1;
+			$endPos=strpos($UserAgent,';',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Firefox')) !== false) {
+			$Browser='Mozilla Firefox';
+			$pos+=strlen('Firefox')+1;
+			$endPos=strpos($UserAgent,';',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Mozilla Firebird')) !== false) {
+			$Browser='Mozilla Firebird';
+			$pos+=strlen('Mozilla Firebird')+1;
+			$endPos=strpos($UserAgent,';',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Netscape')) !== false) {
+			$Browser='Netscape Navigator';
+			$pos+=strlen('Netscape')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Konqueror')) !== false) {
+			$Browser='Konqueror';
+			$pos+=strlen('Konqueror')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Mozilla')) !== false) {
+			$Browser='Mozilla';
+			$pos+=strlen('Mozilla')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Opera')) !== false) {
+			$Browser='Opera';
+			$pos+=strlen('Opera')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'msnbot')) !== false) {
+			$Browser='MSNBot';
+			$pos+=strlen('msnbot')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'HTMLParser')) !== false) {
+			$Browser='HTMLParser';
+			$pos+=strlen('HTMLParser')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'SurveyBot')) !== false) {
+			$Browser='SurveyBot - Whois Source';
+			$pos+=strlen('SurveyBot')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Googlebot-Image')) !== false) {
+			$Browser='Google Image';
+			$pos+=strlen('Googlebot')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Googlebot')) !== false) {
+			$Browser='Google';
+			$pos+=strlen('Googlebot')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Feedfetcher')) !== false) {
+			$Browser='Feedfetcher-Google';
+			$pos+=strlen('Feedfetcher')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Gigabot')) !== false) {
+			$Browser='Gigabot';
+			$pos+=strlen('Gigabot')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Slurp')) !== false) {
+			$Browser='Yahoo Slurp';
+			$pos+=strlen('Slurp')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else if(($pos = strpos($UserAgent,'Alexa')) !== false) {
+			$Browser='Alexa (IA Archive)';
+			$pos+=strlen('Alexa')+1;
+			$endPos=strpos($UserAgent,' ',$pos);
+			$endPos = ($endPos===false) ? strlen($UserAgent) : $endPos-$pos;
+			$BrowserVersion = substr($UserAgent,$pos,$endPos);
+		} else {
+			$Browser='Not Detected';
+			$BrowserVersion='';
+		}
+		$return['BrowserName']		= $Browser;
+		$return['BrowserVersion']	= $BrowserVersion;
+		$return['Browser']			= $Browser.' v.'.$BrowserVersion;
+		return $return;
+	}
+	
+	public function os(){
+		//return the OS
+		$UserAgent = $this->user_agent();
+		if(eregi('Windows',$UserAgent)) {
+			$OS='Windows';
+		} else if(eregi('Linux',$UserAgent)) {
+			$OS='Linux';
+		} else if(eregi('Unix',$UserAgent)) {
+			$OS='Unix';
+		} else if(eregi('PC-BSD',$UserAgent)) {
+			$OS='PC-BSD';
+		} else if(eregi('FreeBSD',$UserAgent)) {
+			$OS='FreeBSD';
+		} else if(eregi('BSD',$UserAgent)) {
+			$OS='BSD';
+		} else if(eregi('Mac',$UserAgent)) {
+			$OS='Macintosh';
+		} else if(eregi('SunOS',$UserAgent)) {
+			$OS='SunOS';
+		} else if(eregi('HP-UX',$UserAgent)) {
+			$OS='Unix';
+		} else if(eregi('IRIX',$UserAgent)) {
+			$OS='Unix';
+		} else if(eregi('Netcraft',$UserAgent)) {
+			$OS='Netcraft';
+		} else if(eregi('Googlebot',$UserAgent)) {
+			$OS='Googlebot';
+		} else if(eregi('SurveyBot',$UserAgent)) {
+			$OS='Whois Source';
+		} else if(eregi('Yahoo! Slurp',$UserAgent)) {
+			$OS='Yahoo! Slurp';
+		} else if(eregi('Gigabot',$UserAgent)) {
+			$OS='Gigabot';
+		} else if(eregi('HTMLParser',$UserAgent)) {
+			$OS='HTMLParser';
+		} else if(eregi('robot',$UserAgent)) {
+			$OS='robot';
+		} else {
+			$OS='Not Detected';
+		}
+		return $OS;
+	}
+	
+	public function language(){
+		//return the Accepted Languages
+		if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
+			$lArr=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
+			foreach($lArr as $k => $v) {
+				$vArr=explode(';',$v);
+				$vArr[1]=(!empty($vArr[1])) ? str_replace('q=','',$vArr[1]) : '1.0';
+				$tmplCArr[$vArr[0]]=$vArr[1];
+			}
+			foreach($tmplCArr as $lC=>$qV) {
+				$lC = strtolower(trim($lC));
+				$langArr[]=array('code'=>$lC,'name'=>$this->_lang_details($lC),'QValue'=>$qV);
+			}
+		} else {
+			$langArr[]=array('code'=>'*','name'=>'all languages are equally acceptable','QValue'=>'1.0');
+		}
+		return $langArr;
+	}
+	
+	public function encoding(){
+		//return the Accepted Encoding
+		if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) && !empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
+			$eArr=explode(',',$_SERVER['HTTP_ACCEPT_ENCODING']);
+			foreach($eArr as $k => $v) {
+				$vArr=explode(';',$v);
+				$vArr[1]=(!empty($vArr[1])) ? str_replace('q=','',$vArr[1]) : 1.0;
+				$encArr[]=array('encoding'=>$vArr[0],'encodingQValue'=>$vArr[1]);
+			}
+		} else {
+			$encArr[]=array('encoding'=>'','encodingQValue'=>1.0);
+		}
+		return $encArr;
+	}
+	public function charset(){
+		//return the Accepted Charset
+		if(isset($_SERVER['HTTP_ACCEPT_CHARSET']) && !empty($_SERVER['HTTP_ACCEPT_CHARSET'])) {
+			$cArr=explode(',',$_SERVER['HTTP_ACCEPT_CHARSET']);
+			foreach($cArr as $k => $v) {
+				$vArr=explode(';',$v);
+				$vArr[1]=(!empty($vArr[1])) ? str_replace('q=','',$vArr[1]) : 1.0;
+				$charsetArr[]=array('charset'=>$vArr[0],'charsetQValue'=>$vArr[1]);
+			}
+		} else {
+			$charsetArr[]=array('charset'=>'','charsetQValue'=>1.0);
+		}
+		return $charsetArr;
+	}
+	public function IP(){
+		$tmp = array();
+		if  (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && strpos($_SERVER['HTTP_X_FORWARDED_FOR'],',')) {
+		   $tmp += explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
+		} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+		   $tmp[] = trim($_SERVER['HTTP_X_FORWARDED_FOR']);
+		}elseif(isset($_SERVER['HTTP_CLIENT_IP'])) {
+		   $tmp[] = trim($_SERVER['HTTP_CLIENT_IP']);
+		}
+		$tmp[] = trim($_SERVER['REMOTE_ADDR']);
+		return trim(str_replace('unknown','',strtolower(implode("\n",$tmp))));
+	}
 	private function _lang_details($lang){
 		$langCode['af']		= 'Afrikaans';
 		$langCode['sq']		= 'Albanian';
@@ -389,64 +418,56 @@
 		}
 	}
 	public function is_crawler(){
-		if(!isset($_SESSION['is_crawler']) || $_SESSION['is_crawler']==true){
-			//I need to check if this is a crowdler
-			//if it is, I skip the hijack Check
-			$_SESSION['is_crawler'] = false;
-			$_crawlers = array();
-	
-			$_crawlers[] = 'alexa';
-			$_crawlers[] = 'archive';
-			$_crawlers[] = 'askjeeves';
-			$_crawlers[] = 'bot';
-			$_crawlers[] = 'crawl';
-			$_crawlers[] = 'echo!';
-			$_crawlers[] = 'edintorni';
-			$_crawlers[] = 'feedfetcher';
-			$_crawlers[] = 'findlinks';
-			//$_crawlers[] = 'funwebproducts';		//this is not a crawler, just junk installed in the browser
-			$_crawlers[] = 'gigabot';
-			$_crawlers[] = 'girafabot';
-			$_crawlers[] = 'google';
-			$_crawlers[] = 'holmes';
-			$_crawlers[] = 'maxthon';
-			$_crawlers[] = 'mediapartner';
-			$_crawlers[] = 'mj12bot';
-			$_crawlers[] = 'mirago';
-			$_crawlers[] = 'moget';
-			$_crawlers[] = 'msnbot';
-			$_crawlers[] = 'netcraft';
-			$_crawlers[] = 'newsgator';
-			$_crawlers[] = 'nomad';
-			$_crawlers[] = 'robot';
-			$_crawlers[] = 'sbider';
-			$_crawlers[] = 'spider';
-			$_crawlers[] = 'scooter';
-			$_crawlers[] = 'seekbot';
-			$_crawlers[] = 'seeker';
-			$_crawlers[] = 'spider';
-			$_crawlers[] = 'survey';
-			$_crawlers[] = 'T-H-U-N-D-E-R-S-T-O-N-E';
-			$_crawlers[] = 'validator';
-			$_crawlers[] = 'walhello';
-			$_crawlers[] = 'yahoo';
-			$_crawlers[] = 'zyborg';
-		//	$_crawlers[] = 'anonymouse.org';	//dangerous site
-		//this doesn't work for some reason:
-		//Mediapartners-Google/2.1
-			if(isset($_SERVER['HTTP_USER_AGENT']) && trim($_SERVER['HTTP_USER_AGENT'])!=''){
-				$_HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']);
-				foreach($_crawlers as $value){
-					if(strpos($_HTTP_USER_AGENT, $value)!==false){
-						$_SESSION['is_crawler'] = true;
-						break;
-					}
+		$_crawlers = array();
+
+		$_crawlers[] = 'alexa';
+		$_crawlers[] = 'archive';
+		$_crawlers[] = 'askjeeves';
+		$_crawlers[] = 'bot';
+		$_crawlers[] = 'crawl';
+		$_crawlers[] = 'echo!';
+		$_crawlers[] = 'edintorni';
+		$_crawlers[] = 'feedfetcher';
+		$_crawlers[] = 'findlinks';
+		//$_crawlers[] = 'funwebproducts';		//this is not a crawler, just junk installed in the browser
+		$_crawlers[] = 'gigabot';
+		$_crawlers[] = 'girafabot';
+		$_crawlers[] = 'google';
+		$_crawlers[] = 'holmes';
+		$_crawlers[] = 'maxthon';
+		$_crawlers[] = 'mediapartner';
+		$_crawlers[] = 'mj12bot';
+		$_crawlers[] = 'mirago';
+		$_crawlers[] = 'moget';
+		$_crawlers[] = 'msnbot';
+		$_crawlers[] = 'netcraft';
+		$_crawlers[] = 'newsgator';
+		$_crawlers[] = 'nomad';
+		$_crawlers[] = 'robot';
+		$_crawlers[] = 'sbider';
+		$_crawlers[] = 'spider';
+		$_crawlers[] = 'scooter';
+		$_crawlers[] = 'seekbot';
+		$_crawlers[] = 'seeker';
+		$_crawlers[] = 'spider';
+		$_crawlers[] = 'survey';
+		$_crawlers[] = 'T-H-U-N-D-E-R-S-T-O-N-E';
+		$_crawlers[] = 'validator';
+		$_crawlers[] = 'walhello';
+		$_crawlers[] = 'yahoo';
+		$_crawlers[] = 'zyborg';
+		if(isset($_SERVER['HTTP_USER_AGENT']) && trim($_SERVER['HTTP_USER_AGENT'])!=''){
+			$_HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']);
+			foreach($_crawlers as $value){
+				if(strpos($_HTTP_USER_AGENT, $value)!==false){
+					$is_crawler = true;
+					break;
 				}
-			} else {
-				$_SESSION['is_crawler'] = true;
 			}
+		} else {
+			$is_crawler = true;
 		}
-		return (bool)$_SESSION['is_crawler'];
+		return $is_crawler;
 	}
 }
 

Modified: websites/pbidir.com/bibivu/slib/lang.php
===================================================================
--- websites/pbidir.com/bibivu/slib/lang.php	2008-06-07 10:10:24 UTC (rev 2034)
+++ websites/pbidir.com/bibivu/slib/lang.php	2008-06-07 12:58:01 UTC (rev 2035)
@@ -60,119 +60,19 @@
 				$this->words[$language][($file!='common'?$file.'_':'').$key] = $value;
 			}
 		}
-		//maybe later on add it to the cache
+		//maybe later add it to the cache
 	}
 	
-	//PART OF THIS FUNCTION HAS BEEN GRABBED FROM PHPMYADMIN
-	//and changed by fabrizio parrella
-		/**
-		 * All the supported languages have to be listed in the array below.
-		 * 1. The key must be the "official" ISO 639 language code and, if required,
-		 *    the dialect code. It can also contain some informations about the
-		 *    charset (see the Russian case).
-		 * 2. The first of the values associated to the key is used in a regular
-		 *    expression to find some keywords corresponding to the language inside two
-		 *    environment variables.
-		 *    These values contains:
-		 *    - the "official" ISO language code and, if required, the dialect code
-		 *      also ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French
-		 *      dialects, 'zh[-_]tw' for Chinese traditional...);
-		 *    - the '|' character (it means 'OR');
-		 *    - the full language name.
-		 * 3. The last values associated to the key is the language code as defined by
-		 *    the RFC1766.  This will be used for the name of the folder for the language
-		 *
-		 * Beware that the sorting order (first values associated to keys by
-		 * alphabetical reverse order in the array) is important: 'zh-tw' (chinese
-		 * traditional) must be detected before 'zh' (chinese simplified) for
-		 * example.
-		 *
-		 * When there are more than one charset for a language, we put the 
-		 * first.
-		 *
-		 * For Russian, we put 1251 first, because MSIE does not accept 866
-		 * and users would not see anything.
-		 */
 	private function _detect_lang(){
 		$lang = '';
 		if($this->config['detect']){
 			if(isset($this->config['detected']) && $this->config['detected']!=''){
 				$lang = $this->config['detected'];
 			} else {
-				$array_languages = array(
-					'af'     => 'af|afrikaans', 
-					'ar'     => 'ar([-_][[:alpha:]]{2})?|arabic', 
-					'az'     => 'az|azerbaijani', 
-					'bg'     => 'bg|bulgarian', 
-					'bs'     => 'bs|bosnian', 
-					'ca'     => 'ca|catalan', 
-					'cs'     => 'cs|czech',
-					'da'     => 'da|danish', 
-					'de'     => 'de([-_][[:alpha:]]{2})?|german', 
-					'el'     => 'el|greek', 
-					'en'     => 'en([-_][[:alpha:]]{2})?|english', 
-					'es'     => 'es([-_][[:alpha:]]{2})?|spanish', 
-					'et'     => 'et|estonian',
-					'eu'     => 'eu|basque', 
-					'fa'     => 'fa|persian', 
-					'fi'     => 'fi|finnish', 
-					'fr'     => 'fr([-_][[:alpha:]]{2})?|french',
-					'gl'     => 'gl|galician', 
-					'he'     => 'he|hebrew', 
-					'hi'     => 'hi|hindi', 
-					'hr'     => 'hr|croatian', 
-					'hu'     => 'hu|hungarian', 
-					'id'     => 'id|indonesian', 
-					'it'     => 'it([-_][[:alpha:]]{2})?|italian',
-					'ja'     => 'ja|japanese', 
-					'ko'     => 'ko|korean', 
-					'ka'     => 'ka|georgian', 
-					'lt'     => 'lt|lithuanian', 
-					'lv'     => 'lv|latvian', 
-					'ms'     => 'ms|malay', 
-					'nl'     => 'nl([-_][[:alpha:]]{2})?|dutch',
-					'no'     => 'no|norwegian',
-					'pl'     => 'pl|polish',
-					'pt-br'  => 'pt[-_]br|brazilian portuguese',
-					'pt'     => 'pt([-_][[:alpha:]]{2})?|portuguese',
-					'ro'     => 'ro|romanian',
-					'ru'     => 'ru|russian',
-					'sk'     => 'sk|slovak',
-					'sl'     => 'sl|slovenian',
-					'sq'     => 'sq|albanian',
-					'sr'     => 'sr|serbian',
-					'sr-lat' => 'sr[-_]lat|serbian latin',
-					'sv'     => 'sv|swedish', 
-					'th'     => 'th|thai', 
-					'tr'     => 'tr|turkish', 
-					'uk'     => 'uk|ukrainian', 
-					'zh-tw'  => 'zh[-_]tw|chinese traditional',
-					'zh'     => 'zh|chinese simplified',
-				);
-				// Language is not defined yet :
-				// 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE
-				//    variable
-				if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
-					$accepted    = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
-					$acceptedCnt = count($accepted);
-					for ($i = 0; $i < $acceptedCnt && $lang==''; $i++) {
-						foreach($array_languages as $key => $value) {
-							if (eregi('^('.$value.')(;q=[0-9]\\.[0-9])?$', $accepted[$i])) {
-								$lang = $key;
-								break;
-							}
-						}
-					}
+				$language = load_class('user_info')->language();
+				if(isset($language[0]['code'])){
+					$lang = substr($language[0]['code'],0,2);
 				}
-				// 2. try to findout user's language by checking its HTTP_USER_AGENT variable
-				if ($lang == '' && !empty($_SERVER['HTTP_USER_AGENT'])) {
-					foreach($array_languages as $key => $value) {
-						if (eregi('(\(|\[|;[[:space:]])('.$value.')(;|\]|\))', $_SERVER['HTTP_USER_AGENT'])) {
-							$lang = $key;
-							break;
-						}
-					}
-				}
 			}
 		}
 		if(!in_array($lang, $this->config['supported']))	$lang = $this->config['lang'];

Modified: websites/pbidir.com/bibivu/tpl/pbidir/download.php
===================================================================
--- websites/pbidir.com/bibivu/tpl/pbidir/download.php	2008-06-07 10:10:24 UTC (rev 2034)
+++ websites/pbidir.com/bibivu/tpl/pbidir/download.php	2008-06-07 12:58:01 UTC (rev 2035)
@@ -13,12 +13,11 @@
 		?>&nbsp;-&nbsp;<a href="<?=$mirror['home']?>"><?=load_library('lang')->get('download_mirror_home')?></a><?php
 	}
 	?></h2><?php
+	if($pbi_release['md5']!=''){
+		?><br/><?=load_library('lang')->get('md5')?>: <?=$pbi_release['md5']?><br /><br /><?php
+	}
 }
 ?>
-<?php
-if($pbi_release['md5']!=''){
-	?><br/><?=load_library('lang')->get('md5')?>: <?=$pbi_release['md5']?><br /><br /><?php
-} ?>
 <br/><?=load_library('lang')->get('download_nostart')?> <a href="<?=$uri?>"><?=load_library('lang')->get('download_clickhere')?></a><br /><br />
 <a href="<?=$pbi_uri?>/<?=$pbi['id']?>"><?=load_library('lang')->get('download_return_pbi')?></a><br /><br />
 <script type="text/javascript" language="javascript"><!-- 



More information about the Commits mailing list