<?PHP
/**
*
* RC4PHP : Raul's Classes For PHP <http://rc4php.sourceforge.net/>
* Copyright (c) 2006, Raul IONESCU
* Bucharest, ROMANIA
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @package RC4PHP
* @copyright Copyright (c) 2006, Raul IONESCU.
* @author Raul IONESCU <hide@address.com>
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @version 0.6.3 (development)
* @category Base class
* @access public
*
* PHP versions 5.1 or greater
*/
//////////////////////////////////////////////////////////////////
require_once('rc4php_autoload.php');
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
/**
* class RC4PHP
*
* It's the base class who will be extended by other classes.
*
* GET PROPERTIES
* ---------------------------------------------------------------------------
* os = operating system
*
* @access public
*/
class RC4PHP
{
//////////////////////////////////////////////////////////////////
const CRLF="\r\n";
//////////////////////////////////////////////////////////////////
const OS_UNKNOWN=0;
const OS_WINDOWS=1;
const OS_UNIX=2;
const OS_MAC=3;
protected static $OS=0;
//////////////////////////////////////////////////////////////////
public function __construct()
///class RC4PHP///////////////////////////////////////////////////
{
self::_checkPHPVersion();
$this->_setOS();
}
//////////////////////////////////////////////////////////////////
public function __get($varname)
///class RC4PHP///////////////////////////////////////////////////
{
$varname=@strtoupper($varname);
switch($varname)
{
case 'OS':
$this->_setOS();
return self::$OS;
default: return false;
}
}
//////////////////////////////////////////////////////////////////
protected static function _checkPHPExtension($extension)
///class RC4PHP///////////////////////////////////////////////////
{
static $verifiedExtensions=array();
$extension=strtolower($extension);
if(isset($verifiedExtensions[$extension]) && $verifiedExtensions[$extension])
return;
$verifiedExtensions[$extension]=@extension_loaded($extension);
if(!$verifiedExtensions[$extension])
{
switch(self::$OS)
{
case self::OS_WINDOWS:
$extension='php_'.$extension.'.'.PHP_SHLIB_SUFFIX;
break;
case self::OS_UNIX:
case self::OS_MAC:
default:
$extension.='.'.PHP_SHLIB_SUFFIX;
}
$verifiedExtensions[$extension]=@dl($extension);
if(!$verifiedExtensions[$extension]) throw new Exception('Can not load required PHP extension: "'.$extension.'".'.(isset($php_errormsg)?(' '.$php_errormsg):('')),-1);
}
}
//////////////////////////////////////////////////////////////////
private static function _checkPHPVersion()
///class RC4PHP///////////////////////////////////////////////////
{
static $phpVersionError=false;
if(!$phpVersionError) $phpVersionError=@version_compare(PHP_VERSION,'5.1.0','<');
if($phpVersionError) exit('Minimum required PHP version is 5.1.0 or greater.');
}
//////////////////////////////////////////////////////////////////
private function _setOS()
///class RC4PHP///////////////////////////////////////////////////
{
if(!self::$OS)
{
$OS=@php_uname('s');
if(stripos($OS,'Windows')!==false)
{ self::$OS=self::OS_WINDOWS; }
else
{
if((stripos($OS,'Unix')!==false) || (stripos($OS,'Linux')!==false) || (stripos($OS,'BSD')!==false)) { self::$OS=self::OS_UNIX; }
else
{
if(stripos($OS,'Mac')!==false) { define('RC4PHP_OS',RC4PHP_OS_MAC); }
else { self::$OS=self::OS_MAC; }
}
}
unset($OS);
}
}
//////////////////////////////////////////////////////////////////
}
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
?>