BUG 0000 Adjustment for the standardization of code.

- Only modified standardization of code.
This commit is contained in:
Hector Cortez
2013-03-04 09:29:59 -04:00
parent ebbae6dcea
commit 6024e77131
2 changed files with 5563 additions and 5828 deletions

View File

@@ -1,22 +1,22 @@
<?php <?php
/** /**
* class.bootstrap.php * class.bootstrap.php
* *
* @package gulliver.system * @package gulliver.system
* *
*/ */
class Bootstrap class Bootstrap
{ {
static $includeClassPaths = array();
public static $includeClassPaths = array();
protected $relativeIncludePaths = array(); protected $relativeIncludePaths = array();
//below here only approved methods //below here only approved methods
/* the autoloader functions */ /* the autoloader functions */
static function autoloadClass($class) public static function autoloadClass($class)
{ {
//error_log( "$class "); //error_log( "$class ");
$className = strtolower($class); $className = strtolower($class);
@@ -39,6 +39,7 @@ class Bootstrap
/* /*
* these functions still under revision * these functions still under revision
*/ */
public function getSystemConfiguration($globalIniFile = '', $wsIniFile = '', $wsName = '') public function getSystemConfiguration($globalIniFile = '', $wsIniFile = '', $wsName = '')
{ {
$readGlobalIniFile = false; $readGlobalIniFile = false;
@@ -84,8 +85,7 @@ class Bootstrap
} }
// default configuration // default configuration
$config = array ('debug' => 0,'debug_sql' => 0,'debug_time' => 0,'debug_calendar' => 0,'wsdl_cache' => 1,'memory_limit' => '128M','time_zone' => 'America/New_York','memcached' => 0,'memcached_server' => '','default_skin' => 'classic','default_lang' => 'en','proxy_host' => '','proxy_port' => '','proxy_user' => '','proxy_pass' => '' $config = array('debug' => 0, 'debug_sql' => 0, 'debug_time' => 0, 'debug_calendar' => 0, 'wsdl_cache' => 1, 'memory_limit' => '128M', 'time_zone' => 'America/New_York', 'memcached' => 0, 'memcached_server' => '', 'default_skin' => 'classic', 'default_lang' => 'en', 'proxy_host' => '', 'proxy_port' => '', 'proxy_user' => '', 'proxy_pass' => '' );
);
// read the global env.ini configuration file // read the global env.ini configuration file
if ($readGlobalIniFile && ($globalConf = @parse_ini_file($globalIniFile)) !== false) { if ($readGlobalIniFile && ($globalConf = @parse_ini_file($globalIniFile)) !== false) {
@@ -366,7 +366,8 @@ class Bootstrap
* *
* @return void * @return void
*/ */
public function mk_dir($strPath, $rights = 0777) { public function mk_dir($strPath, $rights = 0777)
{
$folder_path = array($strPath); $folder_path = array($strPath);
$oldumask = umask(0); $oldumask = umask(0);
while (!@is_dir(dirname(end($folder_path))) && dirname(end($folder_path)) != '/' && dirname(end($folder_path)) != '.' && dirname(end($folder_path)) != '') { while (!@is_dir(dirname(end($folder_path))) && dirname(end($folder_path)) != '/' && dirname(end($folder_path)) != '.' && dirname(end($folder_path)) != '') {
@@ -394,7 +395,8 @@ class Bootstrap
* @param $resources array * @param $resources array
* a list of files to verify write access * a list of files to verify write access
*/ */
public function verifyWriteAccess($resources) { public function verifyWriteAccess($resources)
{
$noWritable = array(); $noWritable = array();
foreach ($resources as $i => $resource) { foreach ($resources as $i => $resource) {
if (!is_writable($resource)) { if (!is_writable($resource)) {
@@ -419,7 +421,8 @@ class Bootstrap
* @param $data associative * @param $data associative
* array containig the template data * array containig the template data
*/ */
public function renderTemplate($template, $data = array()) { public function renderTemplate($template, $data = array())
{
if (!defined('PATH_THIRDPARTY')) { if (!defined('PATH_THIRDPARTY')) {
throw new Exception('System constant (PATH_THIRDPARTY) is not defined!'); throw new Exception('System constant (PATH_THIRDPARTY) is not defined!');
} }
@@ -481,7 +484,8 @@ class Bootstrap
* @param string $strClass * @param string $strClass
* @return void * @return void
*/ */
public function LoadSystem($strClass) { public function LoadSystem($strClass)
{
require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); require_once (PATH_GULLIVER . 'class.' . $strClass . '.php');
} }
@@ -491,7 +495,8 @@ class Bootstrap
* *
* @author <erik@colosa.com> * @author <erik@colosa.com>
*/ */
public function sys_get_temp_dir() { public function sys_get_temp_dir()
{
if (!function_exists('sys_get_temp_dir')) { if (!function_exists('sys_get_temp_dir')) {
// Based on http://www.phpit.net/ // Based on http://www.phpit.net/
// article/creating-zip-tar-archives-dynamically-php/2/ // article/creating-zip-tar-archives-dynamically-php/2/
@@ -536,9 +541,7 @@ class Bootstrap
foreach ($convertionTable as $urlPattern => $localPath) { foreach ($convertionTable as $urlPattern => $localPath) {
// $urlPattern = addcslashes( $urlPattern , '/'); // $urlPattern = addcslashes( $urlPattern , '/');
$urlPattern = addcslashes($urlPattern, './'); $urlPattern = addcslashes($urlPattern, './');
$urlPattern = '/^' . str_replace( array ('*','?' $urlPattern = '/^' . str_replace(array('*', '?'), array('.*', '.?'), $urlPattern) . '$/';
), array ('.*','.?'
), $urlPattern ) . '$/';
if (preg_match($urlPattern, $url, $match)) { if (preg_match($urlPattern, $url, $match)) {
if ($localPath === false) { if ($localPath === false) {
$realPath = $url; $realPath = $url;
@@ -670,7 +673,8 @@ class Bootstrap
* @param string $urlLink * @param string $urlLink
* @return string * @return string
*/ */
static public function parseURI($uri, $isRestRequest = false) { static public function parseURI($uri, $isRestRequest = false)
{
// *** process the $_POST with magic_quotes enabled // *** process the $_POST with magic_quotes enabled
// The magic_quotes_gpc feature has been DEPRECATED as of PHP 5.3.0. // The magic_quotes_gpc feature has been DEPRECATED as of PHP 5.3.0.
if (get_magic_quotes_gpc() === 1) { if (get_magic_quotes_gpc() === 1) {
@@ -704,7 +708,8 @@ class Bootstrap
* 2 or bigger to check if the temporary file exists. * 2 or bigger to check if the temporary file exists.
* return true if the file exists, otherwise false. * return true if the file exists, otherwise false.
*/ */
public function isPMUnderUpdating($setFlag = 2) { public function isPMUnderUpdating($setFlag = 2)
{
if (!defined('PATH_DATA')) { if (!defined('PATH_DATA')) {
return false; return false;
} }
@@ -738,7 +743,8 @@ class Bootstrap
* array containig the template data * array containig the template data
* @return $content string containing the parsed template content * @return $content string containing the parsed template content
*/ */
public function parseTemplate($template, $data = array()) { public function parseTemplate($template, $data = array())
{
$content = ''; $content = '';
ob_start(); ob_start();
@@ -758,7 +764,8 @@ class Bootstrap
* @param string $strClass * @param string $strClass
* @return void * @return void
*/ */
public function LoadClass($strClass) { public function LoadClass($strClass)
{
$classfile = Bootstrap::ExpandPath("classes") . 'class.' . $strClass . '.php'; $classfile = Bootstrap::ExpandPath("classes") . 'class.' . $strClass . '.php';
if (!file_exists($classfile)) { if (!file_exists($classfile)) {
if (file_exists(PATH_GULLIVER . 'class.' . $strClass . '.php')) { if (file_exists(PATH_GULLIVER . 'class.' . $strClass . '.php')) {
@@ -781,7 +788,8 @@ class Bootstrap
* @param string $strClass * @param string $strClass
* @return void * @return void
*/ */
public function LoadThirdParty($sPath, $sFile) { public function LoadThirdParty($sPath, $sFile)
{
$classfile = PATH_THIRDPARTY . $sPath . '/' . $sFile . ((substr($sFile, 0, - 4) !== '.php') ? '.php' : ''); $classfile = PATH_THIRDPARTY . $sPath . '/' . $sFile . ((substr($sFile, 0, - 4) !== '.php') ? '.php' : '');
return require_once ($classfile); return require_once ($classfile);
} }
@@ -797,7 +805,8 @@ class Bootstrap
* @param string lang * @param string lang
* @return void * @return void
*/ */
public function LoadTranslationObject($lang = SYS_LANG) { public function LoadTranslationObject($lang = SYS_LANG)
{
$defaultTranslations = Array(); $defaultTranslations = Array();
$foreignTranslations = Array(); $foreignTranslations = Array();
@@ -835,7 +844,8 @@ class Bootstrap
* @param string $strSkin * @param string $strSkin
* @return void * @return void
*/ */
public function RenderPage($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = null, $layout = '') { public function RenderPage($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = null, $layout = '')
{
global $G_CONTENT; global $G_CONTENT;
global $G_TEMPLATE; global $G_TEMPLATE;
global $G_SKIN; global $G_SKIN;
@@ -892,7 +902,8 @@ class Bootstrap
* *
* @return void * @return void
*/ */
public function SendTemporalMessage($msgID, $strType, $sType = 'LABEL', $time = null, $width = null, $customLabels = null) { public function SendTemporalMessage($msgID, $strType, $sType = 'LABEL', $time = null, $width = null, $customLabels = null)
{
if (isset($width)) { if (isset($width)) {
$_SESSION ['G_MESSAGE_WIDTH'] = $width; $_SESSION ['G_MESSAGE_WIDTH'] = $width;
} }
@@ -927,7 +938,8 @@ class Bootstrap
* @param string $parameter * @param string $parameter
* @return string * @return string
*/ */
public function header($parameter) { public function header($parameter)
{
if (defined('ENABLE_ENCRYPT') && (ENABLE_ENCRYPT == 'yes') && (substr($parameter, 0, 9) == 'location:')) { if (defined('ENABLE_ENCRYPT') && (ENABLE_ENCRYPT == 'yes') && (substr($parameter, 0, 9) == 'location:')) {
$url = Bootstrap::encrypt(substr($parameter, 10), URL_KEY); $url = Bootstrap::encrypt(substr($parameter, 10), URL_KEY);
header('location:' . $url); header('location:' . $url);
@@ -946,7 +958,8 @@ class Bootstrap
* @access public * @access public
* @return void * @return void
*/ */
public function LoadAllPluginModelClasses() { public function LoadAllPluginModelClasses()
{
// Get the current Include path, where the plugins directories should be // Get the current Include path, where the plugins directories should be
if (!defined('PATH_SEPARATOR')) { if (!defined('PATH_SEPARATOR')) {
define('PATH_SEPARATOR', (substr(PHP_OS, 0, 3) == 'WIN') ? ';' : ':' ); define('PATH_SEPARATOR', (substr(PHP_OS, 0, 3) == 'WIN') ? ';' : ':' );
@@ -982,7 +995,8 @@ class Bootstrap
* @param string $strPath * @param string $strPath
* @return string * @return string
*/ */
public function expandPath($strPath = '') { public function expandPath($strPath = '')
{
$res = ""; $res = "";
$res = PATH_CORE; $res = PATH_CORE;
if ($strPath != "") { if ($strPath != "") {
@@ -1099,7 +1113,8 @@ class Bootstrap
/** /**
* function to calculate the time used to render a page * function to calculate the time used to render a page
*/ */
public function logTimeByPage() { public function logTimeByPage()
{
if (!defined(PATH_DATA)) { if (!defined(PATH_DATA)) {
return false; return false;
} }
@@ -1123,7 +1138,8 @@ class Bootstrap
* @param string $downloadFileName * @param string $downloadFileName
* @return string * @return string
*/ */
public function streamJSTranslationFile($filename, $locale = 'en') { public function streamJSTranslationFile($filename, $locale = 'en')
{
$defaultTranslations = Array(); $defaultTranslations = Array();
$foreignTranslations = Array(); $foreignTranslations = Array();
@@ -1242,7 +1258,6 @@ class Bootstrap
$baseCSSPath = PATH_SKIN_ENGINE . "base" . PATH_SEP . "baseCss" . PATH_SEP; $baseCSSPath = PATH_SKIN_ENGINE . "base" . PATH_SEP . "baseCss" . PATH_SEP;
$output .= file_get_contents($baseCSSPath . 'ext-all-notheme.css'); $output .= file_get_contents($baseCSSPath . 'ext-all-notheme.css');
//$output .= file_get_contents ( $publicExtPath . 'ext-all.css' ); //$output .= file_get_contents ( $publicExtPath . 'ext-all.css' );
//Classic Skin //Classic Skin
$extJsSkin = 'xtheme-gray'; $extJsSkin = 'xtheme-gray';
@@ -1314,7 +1329,8 @@ class Bootstrap
* *
* @return void * @return void
*/ */
public function sendHeaders($filename, $contentType = '', $download = false, $downloadFileName = '') { public function sendHeaders($filename, $contentType = '', $download = false, $downloadFileName = '')
{
if ($download) { if ($download) {
if ($downloadFileName == '') { if ($downloadFileName == '') {
$aAux = explode('/', $filename); $aAux = explode('/', $filename);
@@ -1462,7 +1478,6 @@ class Bootstrap
return $output; return $output;
} }
/** /**
* strip_slashes * strip_slashes
* @param vVar * @param vVar
@@ -1484,7 +1499,6 @@ class Bootstrap
return $vVar; return $vVar;
} }
/** /**
* Function LoadTranslation * Function LoadTranslation
* *
@@ -1523,7 +1537,6 @@ class Bootstrap
} }
return $untranslatedMark . $msgID . $untranslatedMark; return $untranslatedMark . $msgID . $untranslatedMark;
} }
} }
/** /**
@@ -1578,7 +1591,6 @@ class Bootstrap
} }
} }
/** /**
* ************************************* init ********************************************** * ************************************* init **********************************************
* Xml parse collection functions * Xml parse collection functions
@@ -1622,7 +1634,6 @@ class Bootstrap
$cv['__CONTENT__'] = array(); $cv['__CONTENT__'] = array();
$cv['__CONTENT__']['_p'] = &$ary; $cv['__CONTENT__']['_p'] = &$ary;
$ary = &$cv['__CONTENT__']; $ary = &$cv['__CONTENT__'];
} elseif ($r['type'] == 'complete') { } elseif ($r['type'] == 'complete') {
if (isset($ary[$t])) { if (isset($ary[$t])) {
if (isset($ary[$t][0])) { if (isset($ary[$t][0])) {
@@ -1640,7 +1651,6 @@ class Bootstrap
} }
} }
$cv['__VALUE__'] = (isset($r['value']) ? $r['value'] : ''); $cv['__VALUE__'] = (isset($r['value']) ? $r['value'] : '');
} elseif ($r['type'] == 'close') { } elseif ($r['type'] == 'close') {
$ary = &$ary['_p']; $ary = &$ary['_p'];
} }
@@ -1699,7 +1709,6 @@ class Bootstrap
return $total; return $total;
} }
/** /**
* _del_p * _del_p
* *
@@ -2034,26 +2043,16 @@ class Bootstrap
} elseif (strstr($pv_browser_string, '2003')) { } elseif (strstr($pv_browser_string, '2003')) {
$os_working_number = 5.2; $os_working_number = 5.2;
$os_working_type = 'nt'; $os_working_type = 'nt';
} } elseif (strstr($pv_browser_string, 'windows ce')) {// windows CE
elseif ( strstr( $pv_browser_string, 'windows ce' ) )// windows CE
{
$os_working_number = 'ce'; $os_working_number = 'ce';
$os_working_type = 'nt'; $os_working_type = 'nt';
} } elseif (strstr($pv_browser_string, '95')) {
elseif ( strstr( $pv_browser_string, '95' ) )
{
$os_working_number = '95'; $os_working_number = '95';
} } elseif (( strstr($pv_browser_string, '9x 4.9') ) || ( strstr($pv_browser_string, ' me') )) {
elseif ( ( strstr( $pv_browser_string, '9x 4.9' ) ) || ( strstr( $pv_browser_string, ' me' ) ) )
{
$os_working_number = 'me'; $os_working_number = 'me';
} } elseif (strstr($pv_browser_string, '98')) {
elseif ( strstr( $pv_browser_string, '98' ) )
{
$os_working_number = '98'; $os_working_number = '98';
} } elseif (strstr($pv_browser_string, '2000')) {// windows 2000, for opera ID
elseif ( strstr( $pv_browser_string, '2000' ) )// windows 2000, for opera ID
{
$os_working_number = 5.0; $os_working_number = 5.0;
$os_working_type = 'nt'; $os_working_type = 'nt';
} }
@@ -2305,6 +2304,7 @@ class Bootstrap
/** /**
* * Encrypt and decrypt functions *** * * Encrypt and decrypt functions ***
*/ */
/** /**
* Encrypt string * Encrypt string
* *
@@ -2390,9 +2390,7 @@ class Bootstrap
{ {
$e = $scope . $id; $e = $scope . $id;
$e = Bootstrap::encrypt($e, URL_KEY); $e = Bootstrap::encrypt($e, URL_KEY);
$e = str_replace( array ('+','/','=' $e = str_replace(array('+', '/', '='), array('__', '_', '___'), base64_encode($e));
), array ('__','_','___'
), base64_encode( $e ) );
return $e; return $e;
} }
@@ -2408,9 +2406,7 @@ class Bootstrap
*/ */
public function getUIDName($uid, $scope = '') public function getUIDName($uid, $scope = '')
{ {
$e = str_replace( array ('=','+','/' $e = str_replace(array('=', '+', '/'), array('___', '__', '_'), $uid);
), array ('___','__','_'
), $uid );
$e = base64_decode($e); $e = base64_decode($e);
$e = Bootstrap::decrypt($e, URL_KEY); $e = Bootstrap::decrypt($e, URL_KEY);
$e = substr($e, strlen($scope)); $e = substr($e, strlen($scope));
@@ -2480,6 +2476,7 @@ class Bootstrap
* @fn() Evaluate string with the function "fn" * @fn() Evaluate string with the function "fn"
* @author David Callizaya <calidavidx21@hotmail.com> * @author David Callizaya <calidavidx21@hotmail.com>
*/ */
public function replaceDataField($sqlString, $result, $DBEngine = 'mysql') public function replaceDataField($sqlString, $result, $DBEngine = 'mysql')
{ {
if (!is_array($result)) { if (!is_array($result)) {
@@ -2732,7 +2729,6 @@ class Bootstrap
* if the day is 5 and the format is DD or D then -> five * if the day is 5 and the format is DD or D then -> five
* ******************************************************************************************************* * *******************************************************************************************************
*/ */
//scape the literal //scape the literal
switch ($lang) { switch ($lang) {
case 'es': case 'es':
@@ -2791,10 +2787,8 @@ class Bootstrap
$yy = substr($year, strlen($year) - 2, 2); $yy = substr($year, strlen($year) - 2, 2);
$yyyy = $year; $yyyy = $year;
$names = array ('{day}','{DAY}','{month}','{YONTH}','{XONTH}','{year}','{YEAR}','{h}','{i}','{s}' $names = array('{day}', '{DAY}', '{month}', '{YONTH}', '{XONTH}', '{year}', '{YEAR}', '{h}', '{i}', '{s}' );
); $values = array($d, $dd, $m, $mm, $M, $yy, $yyyy, $h, $i, $s );
$values = array ($d,$dd,$m,$mm,$M,$yy,$yyyy,$h,$i,$s
);
$ret = str_replace($names, $values, $format); $ret = str_replace($names, $values, $format);
@@ -2875,7 +2869,6 @@ class Bootstrap
return $campo; return $campo;
} }
/** /**
* evalJScript * evalJScript
* *
@@ -2920,30 +2913,33 @@ class Bootstrap
return $url; return $url;
} }
} }
/** /**
* isWinOs * isWinOs
* *
* @return true if the 3 first letters of PHP_OS got 'WIN', otherwise false. * @return true if the 3 first letters of PHP_OS got 'WIN', otherwise false.
*/ */
function isWinOs() public function isWinOs()
{ {
return strtoupper(substr(PHP_OS, 0, 3)) == "WIN"; return strtoupper(substr(PHP_OS, 0, 3)) == "WIN";
} }
/** /**
* isNTOs * isNTOs
* *
* @return true if PHP_OS is 'WINNT', otherwise false. * @return true if PHP_OS is 'WINNT', otherwise false.
*/ */
function isNTOs() public function isNTOs()
{ {
return PHP_OS == "WINNT"; return PHP_OS == "WINNT";
} }
/** /**
* isLinuxOs * isLinuxOs
* *
* @return true if PHP_OS (upper text) got 'LINUX', otherwise false. * @return true if PHP_OS (upper text) got 'LINUX', otherwise false.
*/ */
function isLinuxOs() public function isLinuxOs()
{ {
return strtoupper(PHP_OS) == "LINUX"; return strtoupper(PHP_OS) == "LINUX";
} }

File diff suppressed because it is too large Load Diff