コード例 #1
0
ファイル: basics.php プロジェクト: bizanto/Hooked
        if (!is_object($mainframe)) {
            global $database, $option;
            $mainframe = new mosMainFrame($database, $option, '.');
            $mainframe->initSession();
        }
        define('PATH_ROOT', $mainframe->getCfg('absolute_path') . DS);
        define('WWW_ROOT', $mainframe->getCfg('live_site') . _DS);
        if (!defined('_PLUGIN_DIR_NAME')) {
            define('_PLUGIN_DIR_NAME', 'mambots');
        }
        break;
    case CMS_JOOMLA15:
    case CMS_JOOMLA16:
        define('PATH_ROOT', JPATH_SITE . DS);
        if (method_exists('mainframe', 'getSiteUrl')) {
            define('WWW_ROOT_ADMIN', $mainframe->getSiteURL());
            // Client side
        }
        define('WWW_ROOT', str_replace('/administrator', '', JURI::Base()));
        // Admin side
        if (!defined('_PLUGIN_DIR_NAME')) {
            define('_PLUGIN_DIR_NAME', 'plugins');
        }
        break;
}
/*********************************************************************
 * START FILE INCLUSIONS	
 *********************************************************************/
# Load paths
require dirname(__FILE__) . DS . 'config' . DS . 'paths.php';
# Load object class. Must be 1st to load
コード例 #2
0
	function getCfg( $config ) {
		switch ( $config ) {
			case 'absolute_path':
				if ( checkJversion() >= 1 ) {
					return JPATH_SITE;
				}
				break;
			case 'live_site':
				if ( checkJversion() >= 1 ) {
					if ( $this->getUi() == 1 ) {
						$live_site	=	JURI::base();
					} elseif ( checkJversion() == 2 ) {
						$live_site	=	preg_replace( '%administrator/%', '', JURI::base() );
					} else {
						$live_site	=	$this->_baseFramework->getSiteURL();
					}
					if ( substr( $live_site, -1, 1 ) == '/' ) {
						// fix erroneous ending / in some joomla 1.5 versions:
						return substr( $live_site, 0, -1 );
					} else {
						return $live_site;
					}
				}
				break;
			case 'lang':
				return $this->_myLanguage;
				break;
			case 'lang_tag':
				return $this->_myLanguageTag;
				break;
			case 'uniquemail':
				if ( checkJversion() >= 1 ) {
					return '1';
				}
				break;
			case 'frontend_userparams':
				if ( checkJversion() == -1 ) {
					return '0';
				}
				// NO break; on purpose for fall-through:
			case 'allowUserRegistration':
			case 'useractivation':
			case 'new_usertype':
				if ( checkJversion() >= 1 ) {
					$usersConfig	=	&JComponentHelper::getParams( 'com_users' );
					$setting		=	$usersConfig->get( $config );
					if ( ( $config == 'new_usertype' ) && ( checkJversion() == 2 ) ) {
						$query		=	'SELECT ' . $this->_cmsDatabase->NameQuote( 'title' )
									.	"\n FROM " . $this->_cmsDatabase->NameQuote( '#__usergroups' )
									.	"\n WHERE " . $this->_cmsDatabase->NameQuote( 'id' ) . " = " . (int) $setting;
						$this->_cmsDatabase->setQuery( $query );
						$setting	=	$this->_cmsDatabase->loadResult();
					}
					if ( ( $config == 'new_usertype' ) && ! $setting ) {
						$setting	=	'Registered';
					}
					return $setting;
				} else {
					if ( $config == 'new_usertype' ) {
						return 'Registered';
					}
				}
				break;
			case 'hits':
			case 'vote':
				if ( checkJversion() >= 1 ) {
					$contentConfig	=	&JComponentHelper::getParams( 'com_content' );
					return $contentConfig->get( 'show_' . $config );
				}
				break;
			case 'dirperms':
			case 'fileperms':
				if ( checkJversion() >= 1 ) {
					return '';		//TBD: these two missing configs should one day go to CB
				}
				break;
			// CB-Specific config params:
			case 'tmp_path':
				$abs_path			=	$this->getCfg('absolute_path');
				$tmpDir				=	$abs_path . '/tmp';
				if ( @is_dir( $tmpDir ) && @is_writable( $tmpDir ) ) {
					return $tmpDir;
				}
				$tmpDir				=	$abs_path . '/media';
				if ( @is_dir( $tmpDir ) && @is_writable( $tmpDir ) ) {
					return $tmpDir;
				}
				// First try the new PHP 5.2.1+ function:
				if ( function_exists( 'sys_get_temp_dir' ) ) {
					$tmpDir		=	@sys_get_temp_dir();
					if ( @is_dir( $tmpDir ) && @is_writable( $tmpDir ) ) {
						return $tmpDir;
					}
				}
				// Based on http://www.phpit.net/article/creating-zip-tar-archives-dynamically-php/2/
				$varsToTry	=	array( 'TMP', 'TMPDIR', 'TEMP' );
				foreach ( $varsToTry as $v ) {
					if ( ! empty( $_ENV[$v] ) ) {
						$tmpDir		=	realpath( $v );
						if ( @is_dir( $tmpDir ) && @is_writable( $tmpDir ) ) {
							return $tmpDir;
						}
					}
				}
				// Try the CMS cache directory and other directories desperately:
				$tmpDirToTry		=	array( $this->getCfg( 'cachepath' ), realpath( '/tmp' ), $abs_path.'/tmp', $abs_path.'/images', $abs_path.'/images/stories', $abs_path.'/images/comprofiler' );
				foreach ( $tmpDirToTry as $tmpDir ) {
					if ( @is_dir( $tmpDir ) && @is_writable( $tmpDir ) ) {
						return $tmpDir;
					}
				}
				return null;
				break;
			case 'offset':
				if ( checkJversion() == 2 ) {
					static $jOffset			=	null;
					if ( $jOffset === null ) {
						$dateTimeZoneUTC		=	new DateTimeZone( 'UTC' );
						$dateTimeZoneCurrent	=	new DateTimeZone( $this->_baseFramework->getCfg( 'offset' ) );
						$dateTimeUTC			=	new DateTime( 'now', $dateTimeZoneUTC );
						$timeOffset				=	$dateTimeZoneCurrent->getOffset( $dateTimeUTC );
						$jOffset				=	$timeOffset / 3600;
					}
					return $jOffset;
				}
				break;
			default:
				break;
		}
		return $this->_baseFramework->getCfg( $config );

	}