settings = parse_ini_file( $settingsFile, true );
$this->imagesFolder = $this->key( "general", "images_folder", "/images/com_sobi2/clients/" );
$this->catImagesFolder = $this->key( "general", "cat_images_folder", "/images/stories/" );
$this->templatesDir = $this->key( "general", "templates_dir", "templates" );
$this->disalowedtags = explode( "|", $this->key( "general", "disallowed_tags", "script|object|iframe|applet|meta|form|onmouseover|onmouseout" ) );
array_walk( $this->disalowedtags, "sobi2trim" );
$this->allowableFilesExt = explode( "|", $this->key( "general", "allowed_files_ext", "gif|jpg|png" ) );
array_walk( $this->allowableFilesExt, "sobi2trim" );
$this->allowedExtAudio = explode( "|", $this->key( "general", "allowed_ext_audio", "mp3|wav|wma" ) );
array_walk( $this->allowedExtAudio, "sobi2trim" );
$this->allowedExtVideo = explode( "|", $this->key( "general", "allowed_ext_video", "mpg|mpeg|wmv|avi|flv|mov|swf" ) );
array_walk( $this->allowedExtVideo, "sobi2trim" );
$this->allowedEmbedUrl = explode( "|", $this->key( "general", "allowed_embbed_url", "http://www.youtube.com|http://www.myvideo.de" ) );
array_walk( $this->allowedEmbedUrl, "sobi2trim" );
$this->forceCustomHead = ( class_exists( 'JURI' ) && defined( '_JEXEC' ) ) ? false : $this->key( "general", "force_custom_head_tag", true );
//Kompatibilitaet f�r Schluessel die die Sektion gewechselt haben
if (isset ($this->settings['frontpage']['browser_title_separator'])) {
$this->settings['general']['browser_title_separator'] = $this->settings['frontpage']['browser_title_separator'];
}
if (isset ($this->settings['frontpage']['reverse_browser_title'])) {
$this->settings['general']['reverse_browser_title'] = $this->settings['frontpage']['reverse_browser_title'];
}
if (isset ($this->settings['frontpage']['generator_append'])) {
$this->settings['general']['generator_append'] = $this->settings['frontpage']['generator_append'];
}
if (isset ($this->settings['frontpage']['meta_keys_append'])) {
$this->settings['general']['meta_keys_append'] = $this->settings['frontpage']['meta_keys_append'];
}
if (isset ($this->settings['frontpage']['meta_desc_append'])) {
$this->settings['general']['meta_desc_append'] = $this->settings['frontpage']['meta_desc_append'];
}
}
sobi2Config::loadBridge();
sobi2bridge::init( $this );
if ( class_exists( 'JURI' ) && defined( '_JEXEC' ) ) { //J15
if ( ! defined( '_SOBI_ADM_PATH' ) && $this->mainframe->getName() != 'administrator' ) {
$params = & $this->mainframe->getPageParameters( 'com_sobi2' );
$this->set( 'params', $params );
}
}
else { //J10
if ( ! defined( '_SOBI_ADM_PATH' )) {
if ( ! defined( '_SOBI_MAMBO' ) ) {
$menu = $this->mainframe->get( 'menu' );
$params = new mosParameters( $menu->params );
$params->def( 'back_button', $this->mainframe->getCfg( 'back_button' ) );
$params->def( 'pageclass_sfx', '' );
}
else {
$params = new stdClass( );
if ( $config->sobi2Itemid ) {
sobi2Config::loadBridge();
$menu = & sobi2bridge::jMenu( $config->getDb() );
$menu->load( $config->sobi2Itemid );
$params = & sobi2bridge::jParams( $menu->params );
}
else {
$menu = null;
$params = new mosEmpty( );
}
$params->def( 'pageclass_sfx', $this->mainframe->getCfg( 'back_button' ) );
$params->def( 'back_button', $this->mainframe->getCfg( 'back_button' ) );
}
$this->set( 'params', $params );
}
}
if ( $this->key( "compat", "use_mos_conf_livesite", false ) ) {
if ( class_exists( 'JURI' ) ) {
$this->liveSite = substr_replace( JURI::root(), '', - 1, 1 );
}
else {
global $mosConfig_live_site;
$this->liveSite = $mosConfig_live_site;
}
}
else {
$protocol = ( ( sobi2Config::request( $_SERVER, "SERVER_PORT", 0 ) == 443 ) || sobi2Config::request( $_SERVER, "HTTPS", false ) ) ? "https" : "http";
$host = sobi2Config::request( $_SERVER, "HTTP_HOST", null );
if ( $host && $protocol ) {
$path = sobi2Config::request( $_SERVER, "SCRIPT_NAME", null );
$path = str_replace( array( "/index.php" , "/index2.php" , "/index3.php" ), null, $path );
$subdir = null;
if ( defined( "_SOBI2_ADMIN" ) ) {
if ( $path != "/administrator" ) {
$subdir = str_replace( "/administrator", null, $path );
}
}
else {
if ( strlen( $path ) ) {
$subdir = $path;
}
}
$this->liveSite = "{$protocol}://{$host}{$subdir}";
}
else {
trigger_error( "Cannot investigate live site address |{$protocol}://{$host}{$subdir}|" );
if ( class_exists( 'JURI' ) ) {
$this->liveSite = substr_replace( JURI::root(), '', - 1, 1 );
}
else {
global $mosConfig_live_site;
$this->liveSite = $mosConfig_live_site;
}
}
}
$query = "SELECT `configValue`, `configKey` FROM `#__sobi2_config`";
$this->database->setQuery( $query );
$configValues = $this->database->loadObjectList();
if ( $this->database->getErrorNum() ) {
trigger_error( "DB reports: " . $this->database->stderr(), E_USER_WARNING );
}
foreach ( $configValues as $value ) {
$this->configValues[ $value->configKey ] = $value->configValue;
}
$this->S2_pluginsPath = _SOBI_FE_PATH . DS . "plugins";
$this->nullDate = $this->getNullDate();
$this->sobi2Language = $this->getValueFromDB( "frontpage", "language" );
if ( $this->sobi2Language == 'default' ) {
$this->sobi2Language = $this->globalLang;
if ( ! defined( "_SOBI2_ADMIN" ) ) {
$this->efEntryTitleLabel = $this->key( $this->sobi2Language, "ef_entry_title_label", $this->getSobiStr( $this->getValueFromDB( "editForm", "efEntryTitleLabel" ) ) );
$this->efImgLabel = $this->key( $this->sobi2Language, "ef_img_label", $this->getSobiStr( $this->getValueFromDB( "editForm", "efImgLabel" ) ) );
$this->efIcoLabel = $this->key( $this->sobi2Language, "ef_ico_label", $this->getSobiStr( $this->getValueFromDB( "editForm", "efIcoLabel" ) ) );
$this->acceptEntryRules1 = $this->key( $this->sobi2Language, "ef_accept_entry_rules1", $this->getSobiStr( $this->getValueFromDB( "editForm", "acceptEntryRules1" ) ) );
$this->entryRulesURLlabel = $this->key( $this->sobi2Language, "ef_entry_rules_url_label", $this->getSobiStr( $this->getValueFromDB( "editForm", "entryRulesURLlabel" ) ) );
$this->acceptEntryRules2 = $this->key( $this->sobi2Language, "ef_accept_entry_rules2", $this->getSobiStr( $this->getValueFromDB( "editForm", "acceptEntryRules2" ) ) );
$this->entryRulesURL = $this->key( $this->sobi2Language, "ef_entry_rules_url", $this->getSobiStr( $this->getValueFromDB( "editForm", "entryRulesURL" ) ) );
$this->componentName = $this->key( $this->sobi2Language, "directory_name", $this->getSobiStr( $this->getValueFromDB( "editForm", "componentName" ) ) );
$this->basicPriceLabel = $this->key( $this->sobi2Language, "basic_price_label", $this->getSobiStr( $this->getValueFromDB( "general", "basicPriceLabel" ) ) );
}
else {
$this->efEntryTitleLabel = $this->getSobiStr( $this->getValueFromDB( "editForm", "efEntryTitleLabel" ) );
$this->efImgLabel = $this->getSobiStr( $this->getValueFromDB( "editForm", "efImgLabel" ) );
$this->efIcoLabel = $this->getSobiStr( $this->getValueFromDB( "editForm", "efIcoLabel" ) );
$this->acceptEntryRules1 = $this->getSobiStr( $this->getValueFromDB( "editForm", "acceptEntryRules1" ) );
$this->entryRulesURLlabel = $this->getSobiStr( $this->getValueFromDB( "editForm", "entryRulesURLlabel" ) );
$this->acceptEntryRules2 = $this->getValueFromDB( "editForm", "acceptEntryRules2" );
$this->entryRulesURL = $this->getValueFromDB( "editForm", "entryRulesURL" );
$this->componentName = $this->getSobiStr( $this->getValueFromDB( "general", "componentName" ) );
$this->basicPriceLabel = $this->getValueFromDB( "general", "basicPriceLabel" );
}
}
else {
$this->efEntryTitleLabel = $this->getSobiStr( $this->getValueFromDB( "editForm", "efEntryTitleLabel" ) );
$this->efImgLabel = $this->getSobiStr( $this->getValueFromDB( "editForm", "efImgLabel" ) );
$this->efIcoLabel = $this->getSobiStr( $this->getValueFromDB( "editForm", "efIcoLabel" ) );
$this->acceptEntryRules1 = $this->getSobiStr( $this->getValueFromDB( "editForm", "acceptEntryRules1" ) );
$this->entryRulesURLlabel = $this->getSobiStr( $this->getValueFromDB( "editForm", "entryRulesURLlabel" ) );
$this->acceptEntryRules2 = $this->getValueFromDB( "editForm", "acceptEntryRules2" );
$this->entryRulesURL = $this->getValueFromDB( "editForm", "entryRulesURL" );
$this->componentName = $this->getSobiStr( $this->getValueFromDB( "general", "componentName" ) );
$this->basicPriceLabel = $this->getValueFromDB( "general", "basicPriceLabel" );
}
$this->efEntryTitleLength = $this->getValueFromDB( "editForm", "efEntryTitleLength" );
$this->debug = $this->getValueFromDB( "frontpage", "debug" );
$this->debugTmpl = $this->getValueFromDB( "frontpage", "debugTmpl" );
if ( $this->debug == 0 ) {
$this->debug = 8;
}
$this->showComponentLink = $this->getValueFromDB( "frontpage", "showComponentLink" );
$this->showSearchLink = $this->getValueFromDB( "frontpage", "showSearchLink" );
$this->ssrs = $this->getValueFromDB( "general", "ssrs" );
$this->showAddNewEntryLink = $this->getValueFromDB( "frontpage", "showAddNewEntryLink" );
$this->entryExpirationTime = $this->getValueFromDB( "general", "entryExpirationTime" );
$this->autopublishEntry = $this->getValueFromDB( "general", "autopublishEntry" );
$this->showListingOnFp = $this->getValueFromDB( "frontpage", "showListingOnFp" );
$this->allowRenew = $this->getValueFromDB( "general", "allowRenew" );
$this->allowRenewDaysForExp = $this->getValueFromDB( "general", "allowRenewDaysForExp" );
$this->renewDeleteFees = $this->getValueFromDB( "payment", "renewDeleteFees" );
$this->renewDiscount = $this->getValueFromDB( "general", "renewDiscount" );
$this->renewExpirationTime = $this->getValueFromDB( "general", "renewExpirationTime" );
if ( ! $this->renewExpirationTime && ! defined( "_SOBI2_ADMIN" ) ) {
$this->renewExpirationTime = $this->entryExpirationTime;
}
$this->itemsInLine = $this->getValueFromDB( "frontpage", "itemsInLine" );
$this->itemsInLine = $this->itemsInLine > 0 ? $this->itemsInLine : 2;
$this->defTemplate = $this->getValueFromDB( "general", "defTpl" );
if ( $this->defTemplate != 'default' ) {
$this->loadTplCss( $this->defTemplate );
}
$this->lineOnSite = $this->getValueFromDB( "frontpage", "lineOnSite" );
$this->lineOnSite = $this->lineOnSite > 0 ? $this->lineOnSite : 4;
$this->showCatListOnFp = $this->getValueFromDB( "frontpage", "showCatListOnFp" );
$this->showCatListInCat = $this->getValueFromDB( "frontpage", "showCatListInCat" );
$this->catListAs = $this->getValueFromDB( "frontpage", "catListAs" );
$this->catsListInLine = $this->getValueFromDB( "frontpage", "catsListInLine" );
$this->catsListInLine = $this->catsListInLine > 0 ? $this->catsListInLine : 1;
$this->showEntriesFromSubcats = $this->getValueFromDB( "frontpage", "showEntriesFromSubcats" );
$this->currency = $this->getValueFromDB( "editForm", "currency" );
$this->showIcoInVC = $this->getValueFromDB( "frontpage", "showIcoInVC" );
$this->showImgInVC = $this->getValueFromDB( "frontpage", "showImgInVC" );
$this->curencyDecSeparator = $this->getValueFromDB( "general", "curencyDecSeparator" );
$this->allowUserToEditEntry = $this->getValueFromDB( "general", "allowUserToEditEntry" );
$this->allowUserDelete = $this->getValueFromDB( "general", "allowUserDelete" );
$this->allowQuickEdit = $this->getValueFromDB( "general", "allowQuickEdit" );
$this->listingOrdering = $this->getValueFromDB( "general", "listingOrdering" );
$this->catsOrdering = $this->getValueFromDB( "general", "catsOrdering" );
$this->useMeta = $this->getValueFromDB( "general", "useMeta" );
$this->checkOutTime = date( 'Y-m-d H:i:s', time() - ( 5 * 60 * 60 ) + ( $this->offset * 60 * 60 ) );
$this->showComponentDescription = $this->getValueFromDB( "frontpage", "showComponentDescription" );
$this->showCatDesc = $this->getValueFromDB( "frontpage", "showCatDesc" );
$this->subcatsShow = $this->getValueFromDB( "frontpage", "subcatsShow" );
$this->subcatsNumber = $this->getValueFromDB( "frontpage", "subcatsNumber" );
$this->subcatsOrdering = $this->getValueFromDB( "frontpage", "subcatsOrdering" );
$this->subcatsNumber = $this->subcatsNumber > 0 ? $this->subcatsNumber : 2;
$this->sobi2BorderColor = $this->getValueFromDB( "general", "sobi2BorderColor" );
$this->sobi2BackgroundImg = $this->getValueFromDB( "general", "sobi2BackgroundImg" );
$this->maxCatsForEntry = $this->getValueFromDB( "editForm", "maxCatsForEntry" );
$this->showCatItemsCount = $this->getValueFromDB( "general", "showCatItemsCount" );
$this->allowUsingBackground = $this->getValueFromDB( "general", "allowUsingBackground" );
$this->pby = $this->getValueFromDB( "general", "pby" );
$this->allowAnoDetails = $this->getValueFromDB( "general", "allowAnoDetails" );
$this->basicPrice = $this->getValueFromDB( "general", "basicPrice" );
$this->showAlphaIndex = $this->getValueFromDB( "frontpage", "showAlphaIndex" );
$this->ajaxSearchSlidInAfterSearch = $this->getValueFromDB( "frontpage", "ajaxSearchSlidInAfterSearch" );
$this->ajaxSearchSlidInOnStart = $this->getValueFromDB( "frontpage", "ajaxSearchSlidInOnStart" );
$this->ajaxSearchUseSlider = $this->getValueFromDB( "frontpage", "ajaxSearchUseSlider" );
$this->ajaxSearchCatsForFields = $this->getValueFromDB( "frontpage", "ajaxSearchCatsForFields" );
$this->ajaxSearchCatsContHeight = $this->getValueFromDB( "frontpage", "ajaxSearchCatsContHeight" );
$this->ajaxSearchCatsFieldsDepend = $this->getValueFromDB( "frontpage", "ajaxSearchCatsFieldsDepend" );
$this->mailAdmGid = $this->getValueFromDB( "general", "mailAdmGid" );
$this->mailFieldId = $this->getValueFromDB( "general", "mailFieldId" );
$this->mailSoJ = $this->getValueFromDB( "general", "mailSoJ" );
$this->showComponentDescInSearch = $this->getValueFromDB( "search", "showComponentDescInSearch" );
$this->allowFeEntr = $this->getValueFromDB( "general", "allowFeEntr" );
$this->cmod = $this->key( "general", "change_file_permissions", false );
$this->dmod = $this->key( "general", "directories_permissions", 755 );
$this->fmod = $this->key( "general", "files_permissions", 664 );
$this->useFormTpl = $this->getValueFromDB( "general", "useFormTpl" );
$this->cacheL2Enabled = $this->getValueFromDB( "cache", "cacheL2Enabled" );
$this->cacheL2dvEnabled = $this->cacheL2Enabled ? $this->getValueFromDB( "cache", "cacheL2dvEnabled" ) : false;
$this->cacheL2Lifetime = $this->getValueFromDB( "cache", "cacheL2Lifetime" );
$this->cacheL2strLen = $this->getValueFromDB( "cache", "cacheL2strLen" );
$this->cacheL3Enabled = $this->getValueFromDB( "cache", "cacheL3Enabled" );
$this->cacheL3strLen = $this->getValueFromDB( "cache", "cacheL3strLen" );
sobi2Config::import( 'sobi2.cache.class' );
$this->sobiCache = new sobiCache( $this );
$this->forceMenuId = $this->getValueFromDB( "general", "forceMenuId" );
$Itemid = ( int ) sobi2Config::request( $_REQUEST, "Itemid", 0 );
if ( ! ( $this->forceMenuId ) && ! ( defined( "_SOBI2_ADMIN" ) ) ) {
$query = "SELECT COUNT(*) FROM `#__menu` WHERE `id` = {$Itemid} AND `link` LIKE '%com_sobi2%' AND `published` = '1'";
$this->database->setQuery( $query );
$c = $this->database->loadResult();
if ( $this->database->getErrorNum() ) {
trigger_error( "DB reports: " . $this->database->stderr(), E_USER_WARNING );
}
if ( ! $c ) {
$this->forceMenuId = true;
}
}
if ( ( $this->forceMenuId || ! $Itemid ) ) {
if ( ! ( class_exists( 'JFactory' ) ) ) {
$query = "SELECT `id` FROM `#__menu` WHERE `link` LIKE '%index.php?option=com_sobi2%' AND `type` = 'components' AND `published` = '1' LIMIT 1";
}
else {
$query = "SELECT `id` FROM `#__menu` WHERE `link` LIKE '%index.php?option=com_sobi2' AND `type` = 'component' AND `published` = '1' LIMIT 1";
}
$this->database->setQuery( $query );
$this->sobi2Itemid = $this->database->loadResult();
if ( $this->database->getErrorNum() ) {
trigger_error( "DB reports: " . $this->database->stderr(), E_USER_WARNING );
}
sobi2Config::loadBridge();
$menu = & sobi2bridge::jMenu( $this->database );
$menu->load( $this->sobi2Itemid );
if ( empty( $this->sobi2Itemid ) ) {
$this->sobi2Itemid = 0;
}
}
else {
$this->sobi2Itemid = ( int ) $Itemid;
}
$this->useDetailsView = $this->getValueFromDB( "frontpage", "useDetailsView" );
$this->useRSSfeed = $this->getValueFromDB( "general", "useRSSfeed" );
$this->useSigsiuTree = $this->key( "compat", "use_sigsiutree", true );
$aTreeImgs = $this->getValueFromDB( "general", "SigsiuTreeImages" );
$aTreeImgs = explode( ",", $aTreeImgs );
foreach ( $aTreeImgs as $img ) {
$img = explode( "=", $img );
$this->aTreeImages[ trim( $img[ 0 ] ) ] = trim( $img[ 1 ] );
unset( $img );
}
unset( $aTreeImgs );
$waySearchFields = $this->getValueFromDB( "general", "waySearchFields" );
$waySearchFields = explode( ";", $waySearchFields );
foreach ( $waySearchFields as $field ) {
if ( $field && ! empty( $field ) ) {
$field = explode( "=", $field );
$this->waySearchFields[ trim( $field[ 0 ] ) ] = trim( $field[ 1 ] );
}
}
$this->googleSmallMapControl = $this->key( "google_maps", "small_map_control", true );
$this->googleMapTypeControl = $this->key( "google_maps", "map_type_control", false );
$this->publishedItems = $this->key( "users_own_listing", "can_see_expired" ) ? 4 : 0;
if ($this->key( "users_own_listing", "can_see_unpublished" ) == 1) {
$this->publishedItems = ($this->publishedItems) ? 7 : 6;
}
$this->getEmails();
$this->getDetails();
$this->getEditForm();
$s = explode( '.', $_SERVER['SERVER_ADDR'] );
if ( ( !defined( '_SOBI_ADM_PATH' ) ) || ( sobi2Config::request( $_REQUEST, 'no_html' ) ) || strstr( $_SERVER['SERVER_NAME'], 'localhost' ) || ( isset( $s[ 0 ] ) && ( $s[ 0 ] == 192 || $s[ 0 ] == 127 ) ) ) {
$this->ssrs = 1;
}
$GLOBALS[ 'sobi2_config_construct_cs' ] = false;
}
/**
* @param string $tpl
*/
function loadTplCss ( $tpl )
{
if ( $css = sobi2Config::translateDirPath( "templates|{$tpl}|css", 'front', true ) ) {
$cssDir = opendir( $css );
while ( $file = readdir( $cssDir ) ) {
$f = explode( '.', $file );
if ( strtolower( $f[ count( $f ) - 1 ] ) == 'css' ) {
$this->loadCSS( "components/com_sobi2/templates/{$tpl}/css/{$file}" );
}
}
}
}
/**
* @param string $name
* @param mixed $attr
*/
function set ( $name, $attr )
{
$this->storeHouse[ $name ] = $attr;
}
/**
* @param string $name
* @param mixed $default
* @return mixed
*/
function get ( $name, $default = null )
{
return isset( $this->storeHouse[ $name ] ) ? $this->storeHouse[ $name ] : $default;
}
/**
* @param string $name
* @param mixed $attr
*/
function set_ ( $name, &$attr )
{
$this->storeHouse[ $name ] = &$attr;
}
/**
* @param string $name
* @param mixed $default
* @return mixed
*/
function &get_ ( $name )
{
return $this->storeHouse[ $name ];
}
/**
* @param string $name
* @return bool
*/
function isset_ ( $name )
{
return isset( $this->storeHouse[ $name ] ) ? true : false;
}
/**
* Converting gived ini-string to an array
*
* @param string $str
* @return array
*/
function iniToArr ( $str )
{
sobi2Config::import( "includes|helper.class" );
return sobi2Helper::iniToArr( $str );
}
/**
* Converting gived array to ini-string
*
* @param unknown_type $arr
* @return unknown
*/
function arrToIni ( $arr )
{
sobi2Config::import( "includes|helper.class" );
return sobi2Helper::arrToIni( $arr );
}
/**
* @param string $section
* @param string $key
* @param string $def
* @return string
*/
function &key ( $section, $key = null, $def = false )
{
if ( ! $key ) {
if ( is_array( $this->settings ) && isset( $this->settings[ $section ] ) ) {
return $this->settings[ $section ];
}
else {
return $def;
}
}
elseif ( is_array( $this->settings ) && isset( $this->settings[ $section ][ $key ] ) ) {
return $this->settings[ $section ][ $key ];
}
else {
return $def;
}
}
/**
* importing file
*
* @param string $path
* @param string $start
* @param string $ext
* @param bool $require
* @param bool $once
* @param bool $warning
*/
function import ( $path, $start = "front", $warning = true, $once = true, $ext = ".php" )
{
switch ( $start )
{
case "root":
$include = _SOBI_CMSROOT . DS;
break;
case "front":
$include = _SOBI_FE_PATH . DS;
break;
case "adm":
if ( defined( "_SOBI_ADM_PATH" ) ) {
$include = _SOBI_ADM_PATH . DS;
}
else {
return false;
}
break;
default:
case "absolute":
$include = null;
break;
}
if ( strstr( $path, $ext ) ) {
$ext = null;
}
$include = $include ? $include . DS . $path . $ext : $path . $ext;
$include = str_replace( '|', DS, $include );
$include = str_replace( DS . DS, DS, $include );
if ( ! file_exists( $include ) || ! is_readable( $include ) ) {
if ( $warning ) {
trigger_error( "sobi2Config::import(): File {$include} does not exist or is not readable.", E_USER_WARNING );
}
return false;
}
else {
if ( $once ) {
if ( ! include_once ( $include ) ) {
if ( $warning ) {
trigger_error( "sobi2Config::import(): Cannot import file {$include}", E_USER_WARNING );
}
return false;
}
else {
return true;
}
}
else {
if ( ! include ( $include ) ) {
if ( $warning ) {
trigger_error( "sobi2Config::import(): Cannot import file {$include}", E_USER_WARNING );
}
return false;
}
else {
return true;
}
}
}
}
/**
* Enter description here...
*
* @param string $path
* @param string $start
* @param bool $existCheck
* @param string $ext
* @return string
*/
function translatePath ( $path, $start = "front", $existCheck = true, $ext = ".php" )
{
switch ( $start )
{
case "root":
$spoint = _SOBI_CMSROOT . DS;
break;
case "front":
$spoint = _SOBI_FE_PATH . DS;
break;
case "adm":
if ( defined( "_SOBI_ADM_PATH" ) ) {
$spoint = _SOBI_ADM_PATH . DS;
}
else {
return false;
}
break;
case "absolute":
default:
$spoint = null;
break;
}
if ( strlen( $ext ) && strstr( $path, $ext ) ) {
$ext = null;
}
$path = $spoint ? $spoint . DS . $path . $ext : $path . $ext;
$path = str_replace( "|", DS, $path );
$path = str_replace( DS . DS, DS, $path );
if ( $existCheck ) {
if ( ! file_exists( $path ) || ! is_readable( $path ) ) {
return false;
}
else {
return $path;
}
}
else {
return $path;
}
}
/**
* @param string $path
* @param string $start
* @param bool $existCheck
* @return string
*/
function translateDirPath ( $path, $start = "front", $existCheck = false )
{
return sobi2Config::translatePath( $path, $start, $existCheck, null );
}
/**
* @return mosUser
*/
function &getUser ()
{
return $this->user;
}
/**
* @return database
*/
function &getDb ()
{
return $this->database;
}
/**
* @return string
*/
function getAbsolutePath ()
{
return $this->absolutePath;
}
/**
* @return string
*/
function getLiveSite ()
{
return $this->liveSite;
}
/**
* @return string
*/
function getGlobalLang ()
{
return $this->globalLang;
}
/**
* @return string
*/
function getSiteName ()
{
return $this->sitename;
}
/**
* @return mosMainFrame
*/
function &getMainframe ()
{
return $this->mainframe;
}
/**
* @return frontend
*/
function &getFrontend ()
{
return $this->frontend;
}
/**
* @return frontend
*/
function setFrontend ( &$frontend )
{
$this->frontend = &$frontend;
}
/**
* @return string
*/
function getOffset ()
{
return $this->offset;
}
/**
* @return string
*/
function parseTemplate ( $tpl, $content = null )
{
static $parsed = array();
if ( in_array( $tpl, $parsed ) ) {
return true;
}
$parsed[] = $tpl;
ini_set( "display_errors", "on" );
@ini_set( 'track_errors', '1' );
$url = $_SERVER[ 'REQUEST_URI' ] . "&err=1&no_html=1";
$config = & sobi2Config::getInstance();
if ( ! file_exists( $tpl ) ) {
trigger_error( "sobi2config::parseTemplate(): Template file |{$tpl}| does not exist " );
sobi2config::debOut( "sobi2config::parseTemplate(): Template file |{$tpl}| does not exist " );
return false;
}
else {
if ( ! $content ) {
ob_start();
$content = eval( '?' . '>' . rtrim( file_get_contents( $tpl ) ) );
ob_end_clean();
}
if ( $content === false ) {
ob_end_clean();
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-cache' );
ob_start();
highlight_file( $tpl );
$tplContent = ob_get_contents();
ob_end_clean();
if ( $stream = fopen( "{$config->liveSite}/{$url}", 'r' ) ) {
if ( function_exists( "stream_get_contents" ) ) {
$err = stream_get_contents( $stream );
}
else {
$err = null;
while ( ! feof( $stream ) ) {
$err .= fread( $stream, 8192 );
}
}
fclose( $stream );
}
else {
$err = null;
}
$tplContent = explode( "
", $tplContent );
if ( $err ) {
$l = strpos( $err, "Parse error:" );
$err = substr( $err, $l );
$l = strpos( $err, "on line" );
$errNr = str_replace( "on line", null, substr( $err, $l ) );
$errNr = sobi2_ereg_replace( "[^0-9]", null, $errNr );
$err = str_replace( _SOBI_FE_PATH, " ... ", $err );
$err = str_replace( "Parse error", "Sobi2 template parse error", $err );
$config->debOut( $err );
}
if ( $tplContent && isset( $errNr ) && $errNr ) {
$counter = 0;
foreach ( $tplContent as $line ) {
$counter ++;
if ( $errNr && $counter == $errNr ) {
echo "
'; echo implode( ''; } } function getSelectedCats ( $sid ) { static $entry_catids = array(); if (!isset($entry_catids[$sid])) { $config = & sobi2Config::getInstance(); $db = & $config->getDb(); $query = "SELECT rel.catid FROM #__sobi2_categories AS cat LEFT JOIN #__sobi2_cat_items_relations AS rel ON cat.catid = rel.catid AND cat.published = 1 WHERE itemid = {$sid} "; $db->setQuery( $query ); $r = $db->loadResultArray(); if ( $db->getErrorNum() ) { trigger_error( "sobi_sef::getSelectedCats(): DB reports: " . $db->stderr(), E_USER_WARNING ); } $entry_catids[$sid] = $r; } return $entry_catids[$sid]; } /** * Parse url and replace Itemid if necessary * * @param string $url * @return string */ function itemid ( $url ) { if ( class_exists( 'JURI' ) ) { static $store = array(); $hold = str_replace( array( 'index.php?option=com_sobi2' , '&' , '&' ), array( null , '|' , '|' ), $url ); if ( isset( $store[ $hold ] ) && ! empty( $store[ $hold ] ) ) { return $store[ $hold ]; } $this->initMenu(); $link = null; if (strstr($url, 'catid')) { preg_match( '/catid=(\d+)/', $url, $link ); } if ( !empty($link) && isset($link[1]) && ($link[1] != 0) && ($link[1] != 1) ) { if ( ! $link[ 1 ] ) { $url = str_replace( array( '&catid=0' , '&catid=0' ), null, $url ); $url = preg_replace( '/Itemid=(\d+)/', "Itemid={$this->links[ 'default' ][ 'id' ]}", $url ); return $url; } $Itemid = $this->links[ 'default' ][ 'id' ]; if ( isset( $this->links[ $link[ 1 ] ] ) ) { $Itemid = $this->links[ $link[ 1 ] ][ 'id' ]; } /* if not me, maybe my parent */ else { $parents = array(); $this->getParentCats( $link[ 1 ], $parents ); if ( count( $parents ) ) { $parents = array_reverse( $parents ); foreach ( $parents as $cid ) { if ( isset( $this->links[ $cid ] ) ) { $Itemid = $this->links[ $cid ][ 'id' ]; } } } } $url = preg_replace( '/(Itemid=)(\d+)/', "Itemid={$Itemid}", $url ); } elseif ( strstr( $url, 'sobi2Task' ) ) { $link = null; preg_match( '/sobi2Task=(\w+)/', $url, $link ); if ( ! empty( $link ) && isset( $link[ 1 ] ) ) { if ($link[1] == 'sobi2Details') { //wenn Detailansicht $link = null; preg_match( '/sobi2Id=(\d+)/', $url, $link ); $cids = $this->getSelectedCats($link[1]); $id = $this->checkItemid( $cids[ 0 ] ); $url = preg_replace( '/Itemid=(\d+)/', "Itemid={$id}", $url ); } else { if ( isset( $this->links[ $link[ 1 ] ] ) ) { $url = preg_replace( '/Itemid=(\d+)/', "Itemid={$this->links[ $link[ 1 ] ][ 'id' ]}", $url ); } } } } else { $url = preg_replace( '/Itemid=(\d+)/', "Itemid={$this->links[ 'default' ][ 'id' ]}", $url ); } $store[ $hold ] = $url; } return $url; } function fixItemid( $url ) { if( strstr( $url, 'com_sobi2' ) && !defined( '_SOBI2_ADMIN' ) ) { if ( strstr( $url, 'catid' ) ) { $link = null; preg_match( '/catid=(\d+)/', $url, $link ); if ( ! empty( $link ) && isset( $link[ 1 ] ) ) { $id = $this->checkItemid( $link[ 1 ] ); } } elseif ( strstr( $url, 'sobi2Task' ) ) { $link = null; preg_match( '/sobi2Task=(\w+)/', $url, $link ); if ( ! empty( $link ) && isset( $link[ 1 ] ) ) { $id = $this->checkItemid( $link[ 1 ], false ); } } preg_match( '/Itemid=(\d+)/', $url, $link ); if ( ! empty( $link ) && isset( $link[ 1 ] ) ) { $Itemid = $link[ 1 ]; } if (isset( $id )) { if( $Itemid && ($Itemid != $id) ) { $url = str_replace( 'Itemid='.$Itemid, 'Itemid='.$id , $url ); } else { $url .= '&Itemid='.$id; } } } return $url; } /** * @param string $url * @param string $msg */ function redirect ( $url, $msg = null ) { $config =& sobi2Config::getInstance(); $url = $config->fixItemid( $url ); if ( defined( '_JEXEC' ) && class_exists( 'JFactory' ) ) { $msg = strip_tags( $msg ); $url = str_replace( "&", "&", $url ); $m = JFactory::getApplication( 'site' ); $m->redirect( $url, $msg ); } sobi2Config::import( 'includes|phpInputFilter|class.inputfilter', 'root' ); $iFilter = new InputFilter( ); $url = $iFilter->process( $url ); if ( $iFilter->badAttributeValue( array( 'href' , $url ) ) ) { $url = "index.php"; } else { if ( ! empty( $msg ) ) { $msg = $iFilter->process( $msg ); } if ( trim( $msg ) ) { if ( strpos( $url, '?' ) ) { $url .= '&mosmsg=' . urlencode( $msg ); } else { $url .= '?mosmsg=' . urlencode( $msg ); } } } if ( headers_sent() ) { echo "\n"; } else { @ob_end_clean(); // clear output buffer header( 'HTTP/1.1 301 Moved Permanently' ); header( "Location: " . $url ); } exit(); } /** * getting language depends values * * @param string $key - config key to get * @param string $value - field to get (configKey or description for lang keys) * @param string $lang - language for this key * @return string */ function getLangValue ( $key, $value, $lang = null ) { if ( ! $lang ) { $lang = $this->sobi2Language; } static $langValues = array(); static $loaded = false; if ( ! $loaded ) { $query = "SELECT * FROM `#__sobi2_language` ORDER BY `sobi2Lang`"; $this->database->setQuery( $query ); $v = $this->database->loadObjectList(); if ( $this->database->getErrorNum() ) { trigger_error( "DB reports: " . $this->database->stderr(), E_USER_WARNING ); } if ( ! empty( $v ) ) { foreach ( $v as $k ) { $langValues[ $k->sobi2Lang ][ $k->langKey ] = array( "langValue" => $k->langValue , "description" => $k->description , "sobi2Section" => $k->sobi2Section , "fieldid" => $k->fieldid ); } } $loaded = true; } $curLangValues = & $langValues[ $lang ]; if ( isset( $curLangValues[ $key ] ) && $curLangValues[ $key ] ) { $return = $curLangValues[ $key ][ $value ]; } else { $query = "SELECT `description` FROM `#__sobi2_language` " . "WHERE (`sobi2Lang` = 'russian')"; $this->database->setQuery( $query ); $return = $this->database->loadResult(); if ( $this->database->getErrorNum() ) { trigger_error( "DB reports: " . $this->database->stderr(), E_USER_WARNING ); } // else // if ( ! $return ) { // $query = "SELECT `{$value}` FROM `#__sobi2_language` " . "WHERE (`langKey` = '{$key}' AND `sobi2Lang` = 'english')"; // $this->database->setQuery( $query ); // $return = $this->database->loadResult(); // if ( $this->database->getErrorNum() ) { // trigger_error( "DB reports: " . $this->database->stderr(), E_USER_WARNING ); // } // } } return $return; } /** * This function getting values from Databes for configuration keys * * @param string $sobi2Section * @param string $configKey * @return string */ function getValueFromDB ( $sobi2Section, $configKey ) { if ( ! isset( $this->configValues[ $configKey ] ) ) { $query = "SELECT `configValue` FROM `#__sobi2_config` " . "WHERE (`configKey` = '{$configKey}' " . "AND `sobi2Section` = '{$sobi2Section}')"; $this->database->setQuery( $query ); $return = $this->database->loadResult(); if ( $this->database->getErrorNum() ) { trigger_error( "DB reports: " . $this->database->stderr(), E_USER_WARNING ); } else return $return; } else { return $this->configValues[ $configKey ]; } } /** * lists all existing fields * * @param string $selected * @param string $name * @return sobiHTML::selectList */ function getExistingFieldsList ( $selected, $name = 'field' ) { sobi2Config::import( "includes|helper.class" ); return sobi2Helper::getExistingFieldsList( $selected, $name ); } /** * getting latitude and longitude for google maps * * @param integer $sobiId - id of sobi entry * @return array */ function getGeoPosition ( $sobiId ) { sobi2Config::import( "includes|helper.class" ); return sobi2Helper::getGeoPosition( $sobiId ); } /** * getting null date for database * * @return string */ function getNullDate () { /* * fix for mambo (by Websmurf) */ if ( function_exists( "database::getNullDate" ) ) { $nullDate = $this->database->getNullDate(); } else { $nullDate = "0000-00-00 00:00:00"; } return $nullDate; } /** * Function to check if a Header Tag ($headTag) has already been output in the HTML Header and if not, output it. * * @param string $headTag * @return bool */ function forceAddCustomHeadTags ( $headTag ) { /* Save the existing output buffer */ $buf = ob_get_contents(); $buf = trim( $buf ); if ( ! strstr( $buf, "" ) ) { return false; } if ( ! empty( $buf ) && ! headers_sent() ) { /* Clean (erase) the output buffer */ ob_clean(); /* 'i' for case-insensitive search */ $strMatch = '/<\/head>/i'; $strReplace = $headTag . ""; /* find and replace the first string match only */ if ( ! ( $buf = preg_replace( $strMatch, $strReplace, $buf, 1 ) ) ) { echo $buf; return false; } if ( ! strstr( $buf, $headTag ) ) { echo $buf; return false; } /* Output the updated output buffer */ echo $buf; return true; } return false; } /** * returning mos date or mos date + number of days * * @param integer $days * @return datetime */ function getTimeAndDate ( $days = null ) { if ( $days ) { return date( 'Y-m-d H:i:s', time() + ( $days * 24 * 60 * 60 ) + ( $this->getOffset() * 60 * 60 ) ); } else { return date( 'Y-m-d H:i:s', time() + $this->getOffset() * 60 * 60 ); } } /** * not used anymore. * * @param string $string * @return string */ function cleanString ( $string ) { sobi2Config::import( "includes|string.class" ); return sobi2String::cleanString( $string ); } /** * overloading * @return void */ function loadOverlib () { $no_html = sobi2Config::request( $_REQUEST, "no_html", 0, 2 ); if ( $no_html ) { return false; } static $loaded = false; $legacy = false; $config = & sobi2Config::getInstance(); if ( ! $loaded ) { if ( defined( "_JEXEC" ) && class_exists( "JHTML" ) ) { if ( defined( "_SOBI2_ADMIN" ) ) { if ( $config->key( "compat", "use_j10_tooltip_be" ) ) { $legacy = true; } } else { if ( $config->key( "compat", "use_j10_tooltip_fe" ) ) { $legacy = true; } } } else { $legacy = true; } if ( $legacy ) { $b = "\n"; $b .= "\n\n"; $config->addCustomHeadTag( $b ); } else { JHTML::_( 'behavior.tooltip' ); } $loaded = true; } } function loadCalendar ( $format = null, $theme = null ) { static $loaded = false; if ( ! $loaded ) { if ( ! $theme ) { $theme = $this->key( "calendar", "theme", "system" ); } if ( ! ( sobi2Config::translatePath( "includes|js|jscalendar|calendar-{$theme}", "front", true, ".css" ) ) ) { $theme = "system"; } if ( ! $format ) { $format = $this->key( "calendar", "date_format", _SOBI2_CALENDAR_FORMAT ); } $formatTxt = $this->key( "calendar", "date_format_txt", "D, M d" ); $lang = $this->key( "calendar", "language", _SOBI2_CALENDAR_LANG ); if ( ! ( sobi2Config::translatePath( "includes|js|jscalendar|lang|calendar-{$lang}", "front", true, ".js" ) ) ) { $lang = "en"; } $this->addCustomHeadTag( "liveSite}/components/com_sobi2/includes/js/jscalendar/calendar-{$theme}.css\"/>" ); $this->addCustomHeadTag( "" ); $this->addCustomScript( ' function showSobiCalendar( id, bid, format ) { if( !format ) { format = "' . $format . '"; } var el = document.getElementById( id ); if ( calendar != null ) { calendar.hide(); calendar.parseDate( el.value ); } else { var cal = new Calendar( true, null, SobiSelectedDate, SobiCloseCal ); calendar = cal; SobiCal = cal; cal.setRange( 1900, 2090 ); calendar.create(); } calendar.setDateFormat( format ); calendar.setTtDateFormat( "' . $formatTxt . '" ) calendar.parseDate( el.value ); calendar.sel = el; calendar.showAtElement( document.getElementById( bid ) ); return false; } function SobiCloseCal( c ) { c.hide(); } function SobiSelectedDate( c, d ) { c.sel.value = d; } ' ); $this->addCustomHeadTag( "" ); $loaded = true; } } /** * not used anymore. * * @param string $string * @return string */ function escapeSpacialHTML ( $string ) { $trans = get_html_translation_table( ENT_QUOTES ); return strtr( $string, $trans ); } /** * transforming string to use it with javaScript * * @param string $str * @return string */ function jsAddSlashes ( $str ) { sobi2Config::import( "includes|string.class" ); return sobi2String::jsAddSlashes( $str ); } /** * adding "http://" to url's if not added * * @param string $entry * @return string */ function checkHTTP ( $entry ) { sobi2Config::import( "includes|helper.class" ); return sobi2Helper::checkHTTP( $entry ); } /** * MySQL injections filter * * @param string $string - string to clean * @return string */ function clearSQLinjection ( $string ) { if ( ! $string ) { return null; } $iso = explode( '=', _ISO ); if ( ! strstr( strtoupper( $iso[ 1 ] ), 'UTF' ) ) { $string = htmlentities( $string ); } $string = addslashes( $string ); $string = $this->database->getEscaped( $string ); return $string; } function clearSQLinjectionLight ( $string ) { $iso = explode( '=', _ISO ); if ( ! strstr( strtoupper( $iso[ 1 ] ), 'UTF' ) ) { $string = htmlentities( $string ); } $string = addslashes( $string ); $string = $this->database->getEscaped( $string ); return $string; } /** * reversing MySQL injection filter * * @param string $string - string to decode * @return string */ function getSobiStr ( $string ) { if ( $string ) { $iso = defined( "_ISO" ) ? explode( '=', _ISO ) : array( null , "UTF-8" ); if ( strtoupper( $iso[ 1 ] ) != "UTF-8" ) { $string = stripcslashes( stripslashes( stripslashes( html_entity_decode( $string ) ) ) ); } else { $string = stripcslashes( stripslashes( stripslashes( $string ) ) ); } if ( ! strstr( "
', $this->debStore ); echo '