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 "
{$counter}   "; } else { echo "{$counter}:   "; } echo $line; if ( $errNr && $counter == $errNr ) { echo "
"; } else { echo "
"; } } exit(); } else { trigger_error( "sobi2config::parseTemplate(): Cannot parse template file |{$tpl}| " ); sobi2config::debOut( "sobi2config::parseTemplate(): Cannot parse template file |{$tpl}| " ); } return false; } else { return true; } } } /** * singleton * * @return sobi2Config */ function &getInstance () { if ( isset( $GLOBALS[ 'sobi2_config_construct_cs' ] ) && $GLOBALS[ 'sobi2_config_construct_cs' ] == true ) { sobi2Config::debOut( "Critical Error: calling \"getInstance\" method from the config constructor." ); sobi2Config::debOut( "Please notify Sobi2 Development Team" ); ob_start(); if ( function_exists( 'debug_print_backtrace' ) ) { debug_print_backtrace(); } else { print_r( debug_backtrace() ); } $bugtrace = ob_get_contents(); ob_end_clean(); $bugtrace = str_replace( "\n", '
', $bugtrace ); $bugtrace = str_replace( _SOBI_CMSROOT, null, $bugtrace ); sobi2Config::debOut( 'Debug Output:
' . $bugtrace . '' ); exit(); } static $config; if ( defined( '_SOBI2_ADMIN' ) ) { return adminConfig::getInstance(); } if ( ! is_a( $config, 'sobi2Config' ) ) { $config = new sobi2Config( ); } return $config; } /** * Adding selected css script to header * * @param string $script - script name to add */ function loadCSS ( $script ) { $this->addCustomHeadTag( "liveSite}/{$script}\" type=\"text/css\"/>" ); } /** * Adding selected script to header * * @param string $script - script name to add * @param string $ext - script file extension * @param string $params - parameters for script */ function loadScript ( $script, $ext = 'js', $params = null ) { $params = $params ? "?{$params}" : null; static $l = array(); if ( ! key_exists( $script, $l ) ) { $l[] = $script; $this->addCustomHeadTag( "" ); } } /** * adding javascript to header * @param string $script * @param bool $noScriptTag */ function addCustomScript ( $script, $addScriptTag = true, $skipComments = false ) { $s = null; $s = $addScriptTag ? "\n\t" : $s; $this->addCustomHeadTag( $s ); } /** * @param string $html * @param bool $force */ function addCustomHeadTag ( $html, $force = false ) { if ( ( defined( "_SOBI_MAMBO" ) && ( defined( "_SOBI2_ADMIN" ) || sobi2_eregi( "index2.php", $_SERVER[ 'REQUEST_URI' ] ) ) ) || $force ) { if ( $this->forceCustomHead ) { if ( ! ( $this->forceAddCustomHeadTags( $html ) ) ) { echo "\n \n\t {$html} \n \n\n"; } } else { echo $html; } } else { $this->mainframe->addCustomHeadTag( $html ); } $this->header .= $html; } /** * @param string $html */ function appendPathWay ( $html ) { if ( defined( "_JEXEC" ) && class_exists( "JRequest" ) ) { $pattern = '/"[^"]*"/'; preg_match( $pattern, $html, $matches ); $url = isset( $matches[ 0 ] ) ? $matches[ 0 ] : null; if ( ! $url ) { $title = strip_tags( str_replace( " ", null, $html ) ); } else { $url = str_replace( array( '"' , $this->liveSite . "/" , "amp;" ), null, $url ); $title = strip_tags( str_replace( " ", null, $html ) ); } $pathway = & $this->mainframe->getPathway(); $pathway->addItem( $title, $url ); } else { $this->mainframe->appendPathWay( $html ); } } /** * @param string $title */ function setPageTitle ( $title ) { $this->mainframe->setPageTitle( html_entity_decode( $title ) ); } /** * security function to check if user have permision to be an admin * @return boolean */ function checkPerm () { $this->admPermission = $this->getValueFromDB( 'adm', 'admPermission' ); $return = false; if ( ! $this->admPermission ) { if ( class_exists( 'JFactory' ) ) { $user = & JFactory::getUser(); if ( $user->authorize( 'com_users', 'manage' ) ) { $return = true; } } else { if ( $this->acl->acl_check( 'administration', 'manage', 'users', $this->user->usertype, 'components', 'com_users' ) ) { $return = true; } else { $return = false; } } } elseif ( $this->admPermission == 1 ) { if ( class_exists( 'JFactory' ) ) { $user = & JFactory::getUser(); if ( $user->authorize( 'com_content', 'edit', 'content', 'all' ) ) { $return = true; } } else { if ( $this->acl->acl_check( 'action', 'edit', 'users', $this->user->usertype, 'content', 'all' ) ) { $return = true; } else { $return = false; } } } if ( count( $this->S2_plugins ) ) { foreach ( $this->S2_plugins as $plugin ) { if ( method_exists( $plugin, 'permissionsCheck' ) ) { $plugin->permissionsCheck( $return ); } } } return $return; } /** * initialazing all parameters needed for new entry/edit form * */ function getEditForm () { if ( $this->user->id && ! $this->key( "edit_form", "seccode_registered", true ) ) { $this->useSecurityCode = false; } else { $this->useSecurityCode = defined( "_JEXEC" ) ? false : $this->getValueFromDB( "editForm", "useSecurityCode" ); } $this->secImgBgColor = $this->getValueFromDB( "editForm", "secImgBgColor" ); $this->secImgFontColor = $this->getValueFromDB( "editForm", "secImgFontColor" ); $this->secImgLineColor = $this->getValueFromDB( "editForm", "secImgLineColor" ); $this->secImgBorderColor = $this->getValueFromDB( "editForm", "secImgBorderColor" ); $this->needToAcceptEntryRules = $this->getValueFromDB( "editForm", "needToAcceptEntryRules" ); $this->entryRulesURLextern = $this->getValueFromDB( "editForm", "entryRulesURLextern" ); if ( ! $this->catPrices = $this->key( "cats_payment" ) ) { $this->catPrices[ 2 ] = $this->getValueFromDB( "editForm", "cat2price" ); $this->catPrices[ 3 ] = $this->getValueFromDB( "editForm", "cat3price" ); $this->catPrices[ 4 ] = $this->getValueFromDB( "editForm", "cat4price" ); $this->catPrices[ 5 ] = $this->getValueFromDB( "editForm", "cat5price" ); } else { $this->maxCatsForEntry = count( $this->catPrices ); } $this->checkReferer = $this->getValueFromDB( "editForm", "checkReferer" ); $this->allowMultiTitle = $this->getValueFromDB( "editForm", "allowMultiTitle" ); $this->allowUsingImg = $this->getValueFromDB( "editForm", "allowUsingImg" ); if ( $this->allowUsingImg ) { $this->priceForImg = $this->getValueFromDB( "editForm", "priceForImg" ); } $this->allowUsingIco = $this->getValueFromDB( "editForm", "allowUsingIco" ); if ( $this->allowUsingIco ) { $this->priceForIco = $this->getValueFromDB( "editForm", "priceForIco" ); } $this->needToConfirmNew = $this->getValueFromDB( "editForm", "needToConfirmNew" ); $this->thumbWidth = $this->getValueFromDB( "editForm", "thumbWidth" ); $this->thumbHeigth = $this->getValueFromDB( "editForm", "thumbHeigth" ); $this->imgWidth = $this->getValueFromDB( "editForm", "imgWidth" ); $this->imgHeigth = $this->getValueFromDB( "editForm", "imgHeigth" ); $this->allowAnonymous = $this->getValueFromDB( "editForm", "allowAnonymous" ); $this->notifyAuthorNew = $this->getValueFromDB( "editForm", "notifyAuthorNew" ); $this->notifyAuthorChanges = $this->getValueFromDB( "editForm", "notifyAuthorChanges" ); $this->notifyAdminChanges = $this->getValueFromDB( "editForm", "notifyAdminChanges" ); $this->notifyAdmins = $this->getValueFromDB( "editForm", "notifyAdmins" ); $this->emailOnAppr = $this->getValueFromDB( "editForm", "emailOnAppr" ); $this->maxFileSize = $this->getValueFromDB( "editForm", "maxFileSize" ) / 1024; $this->mailFooter = "\n\n" . $this->getValueFromDB( "editForm", "mailFooter" ); $this->allowAddingToParentCats = $this->getValueFromDB( "editForm", "allowAddingToParentCats" ); } /** * initialazing all parameters for details view * */ function getDetails () { $this->showIcoInDetails = $this->getValueFromDB( "details", "showIcoInDetails" ); $this->showImageInDetails = $this->getValueFromDB( "details", "showImageInDetails" ); $this->useWaySearch = $this->getValueFromDB( "details", "useWaySearch" ); $this->waySearchUrl = $this->getValueFromDB( "details", "waySearchUrl" ); $this->waySearchLabel = $this->getValueFromDB( "details", "waySearchLabel" ); $this->showHits = $this->getValueFromDB( "details", "showHits" ); $this->showAddedDate = $this->getValueFromDB( "details", "showAddedDate" ); $this->useGoogleMaps = $this->getValueFromDB( "details", "useGoogleMaps" ); if ( $this->useGoogleMaps ) { $this->getGoogleMaps(); } } /** * initialazing all parameters for payment class */ function getPayment () { $this->mailFees = $this->getValueFromDB( "payment", "mailFees" ); $this->mailFeesAdm = $this->getValueFromDB( "payment", "mailFeesAdm" ); $this->useBankTransfer = $this->getValueFromDB( "payment", "useBankTransfer" ); $this->usePayPal = $this->getValueFromDB( "payment", "usePayPal" ); $this->bankData = /*$this->getSobiStr*/( $this->getValueFromDB( "payment", "bankData" ) ); $this->payPalMail = $this->getValueFromDB( "payment", "payPalMail" ); $this->payPalUrl = $this->getValueFromDB( "payment", "payPalUrl" ); if ( ! $this->payPalUrl ) { $this->payPalUrl = "https://www.paypal.com/cgi-bin/webscr"; } $this->payTitle = $this->getSobiStr( $this->getValueFromDB( "payment", "payTitle" ) ); $this->payPalCurrency = $this->getValueFromDB( "payment", "payPalCurrency" ); $this->payPalReturnUrl = $this->getValueFromDB( "payment", "payPalReturnUrl" ); if ( ! $this->payPalReturnUrl ) { $this->payPalReturnUrl = $this->liveSite; } $this->mailFooter = "\n\n" . $this->getValueFromDB( "editForm", "mailFooter" ); } /** * initialazing all parameters needed for google maps */ function getGoogleMaps () { $this->googleMapsApiKey = $this->getValueFromDB( "google", "googleMapsApiKey" ); $this->googleMapsBubble = $this->getValueFromDB( "google", "googleMapsBubble" ); $this->googleMapsHeight = $this->getValueFromDB( "google", "googleMapsHeight" ); $this->googleMapsLatField = $this->getValueFromDB( "google", "googleMapsLatField" ); $this->googleMapsLongField = $this->getValueFromDB( "google", "googleMapsLongField" ); $this->googleMapsWidth = $this->getValueFromDB( "google", "googleMapsWidth" ); $this->googleMapsZoom = $this->getValueFromDB( "google", "googleMapsZoom" ); } function restoreDefaultErrorHandler () { restore_error_handler(); } /** * returning subcategories info * * @param integer $parent * @return array */ function getCategories ( $parent = 1 ) { $published = null; if ( $parent < 1 ) { $parent = 1; } if ( ! ( defined( '_SOBI2_ADMIN' ) ) ) { $published = " published = 1 AND "; } /* don't know exactly why but if I do it with only one query this whole thing will not be translate with JoomFish */ /* Only if I split it in two queries it will b translated */ $query = "SELECT relations.catid " . "FROM `#__sobi2_categories`" . "LEFT JOIN `#__sobi2_cats_relations` AS relations ON `#__sobi2_categories`.catid = relations.catid " . "WHERE `parentid` = {$parent} AND `published` = 1 "; $this->database->setQuery( $query ); $cids = $this->database->loadResultArray(); if ( $this->database->getErrorNum() ) { trigger_error( "DB reports: " . $this->database->stderr(), E_USER_WARNING ); } if ( count( $cids ) ) { $ids = ( ! empty( $cids ) ) ? implode( " , ", $cids ) : null; $query = "SELECT * FROM #__sobi2_categories WHERE catid IN({$ids}) AND published = 1 ORDER BY {$this->catsOrdering}"; $this->database->setQuery( $query ); } $return = $this->database->loadObjectList(); if ( $this->database->getErrorNum() ) { trigger_error( "DB reports: " . $this->database->stderr(), E_USER_WARNING ); } return $return; } /** * getting childs cats for a category * * @param int $catid * @param array $catChilds */ function getChildCats ( $catid, &$catChilds ) { if ( $catid != 1 ) { array_push( $catChilds, $catid ); } $query = "SELECT `catid` FROM `#__sobi2_cats_relations` WHERE `parentid`={$catid}"; $this->database->setQuery( $query ); $results = $this->database->loadObjectList(); /* * if we still have a results */ if ( count( $results ) > 0 && $results != - 100 ) { foreach ( $results as $result ) { $this->getChildCats( $result->catid, $catChilds ); } } } /** * returning parent cats for * * @param integer $catid * @param array $parents */ function getParentCats ( $catid, &$parents ) { static $store = array(); static $subject = 0; if ( ! isset( $store[ $catid ] ) ) { if ( ! $subject ) { $subject = $catid; } //hole papa von catid $query = "SELECT parentid FROM #__sobi2_cats_relations WHERE catid={$catid}"; $this->database->setQuery( $query ); $r = $this->database->loadResult(); // if we still have a results array_push( $parents, $catid ); if ( $r && $r > 1 ) { $this->getParentCats( $r, $parents ); } /* otherwise we are at the begin of the list, so we need to store it */ else { $store[ $subject ] = $parents; $subject = 0; } } else { $parents = array_merge( $parents, $store[ $catid ] ); $store[ $subject ] = $parents; $subject = 0; } } /** * give all emails textes and titles * * @param string $lang - language * @param boolean $remark - remark if sending email. No remark if editing email templates */ function getEmails ( $lang = null, $remark = true ) { if ( ! $lang ) { $lang = $this->sobi2Language; } $this->notifyAuthorNew = ( $this->getValueFromDB( "editForm", "notifyAuthorNew" ) ); $this->notifyAuthorChanges = ( $this->getValueFromDB( "editForm", "notifyAuthorChanges" ) ); $this->notifyAdminChanges = ( $this->getValueFromDB( "editForm", "notifyAdminChanges" ) ); $this->notifyAdmins = ( $this->getValueFromDB( "editForm", "notifyAdmins" ) ); $this->emailOnAppr = ( $this->getValueFromDB( "editForm", "emailOnAppr" ) ); $this->mailFeesAdm = ( $this->getValueFromDB( "payment", "mailFeesAdm" ) ); $this->notifyAuthorRenew = ( $this->getValueFromDB( "editForm", "emailOnRenew" ) ); $this->notifyAdminRenew = ( $this->getValueFromDB( "editForm", "emailOnRenewAdm" ) ); /* * emails for admin */ $this->AdmEmailOnSubmitText = $this->getSobiStr( $this->getValueFromDB( "editForm", "email_on_submit_text" ) ); $this->AdmEmailOnSubmitTitle = $this->getSobiStr( $this->getValueFromDB( "editForm", "email_on_submit_title" ) ); $this->AdmEmailOnUpdateText = $this->getSobiStr( $this->getValueFromDB( "editForm", "email_on_update_text" ) ); $this->AdmEmailOnUpdateTitle = $this->getSobiStr( $this->getValueFromDB( "editForm", "email_on_update_title" ) ); $this->AdmEmailPaymentsText = $this->getSobiStr( $this->getValueFromDB( "payment", "email_payments_text" ) ); $this->AdmEmailPaymentsTitle = $this->getSobiStr( $this->getValueFromDB( "payment", "email_payments_title" ) ); $this->AdmEmailOnRenewText = $this->getSobiStr( $this->getValueFromDB( "editForm", "email_on_renew_text" ) ); $this->AdmEmailOnRenewTitle = $this->getSobiStr( $this->getValueFromDB( "editForm", "email_on_renew_title" ) ); /* * emails for user */ $this->UserEmailOnApproveText = $this->getSobiStr( $this->getLangValue( "email_on_approve_text", "description", $lang ) ); $this->UserEmailOnApproveTitle = $this->getSobiStr( $this->getLangValue( "email_on_approve_title", "description", $lang ) ); $this->UserEmailOnSubmitText = $this->getSobiStr( $this->getLangValue( "email_on_submit_text", "description", $lang ) ); $this->UserEmailOnSubmitTitle = $this->getSobiStr( $this->getLangValue( "email_on_submit_title", "description", $lang ) ); $this->UserEmailOnUpdateText = $this->getSobiStr( $this->getLangValue( "email_on_update_text", "description", $lang ) ); $this->UserEmailOnUpdateTitle = $this->getSobiStr( $this->getLangValue( "email_on_update_title", "description", $lang ) ); $this->UserEmailPaymentsText = $this->getSobiStr( $this->getLangValue( "email_payments_text", "description", $lang ) ); $this->UserEmailPaymentsTitle = $this->getSobiStr( $this->getLangValue( "email_payments_title", "description", $lang ) ); $this->UserEmailOnRenewText = $this->getSobiStr( $this->getLangValue( "email_on_renew_text", "description", $lang ) ); $this->UserEmailOnRenewTitle = $this->getSobiStr( $this->getLangValue( "email_on_renew_title", "description", $lang ) ); /* * if not editing */ if ( $remark ) { $this->AdmEmailOnSubmitText = $this->stringDecode( $this->AdmEmailOnSubmitText ); $this->AdmEmailOnSubmitTitle = $this->stringDecode( $this->AdmEmailOnSubmitTitle ); $this->AdmEmailOnUpdateText = $this->stringDecode( $this->AdmEmailOnUpdateText ); $this->AdmEmailPaymentsText = $this->stringDecode( $this->AdmEmailPaymentsText ); $this->AdmEmailPaymentsTitle = $this->stringDecode( $this->AdmEmailPaymentsTitle ); $this->AdmEmailOnRenewText = $this->stringDecode( $this->AdmEmailOnRenewText ); $this->AdmEmailOnRenewTitle = $this->stringDecode( $this->AdmEmailOnRenewTitle ); $this->UserEmailOnApproveText = $this->stringDecode( $this->UserEmailOnApproveText ); $this->UserEmailOnApproveTitle = $this->stringDecode( $this->UserEmailOnApproveTitle ); $this->UserEmailOnSubmitText = $this->stringDecode( $this->UserEmailOnSubmitText ); $this->UserEmailOnSubmitTitle = $this->stringDecode( $this->UserEmailOnSubmitTitle ); $this->UserEmailOnUpdateText = $this->stringDecode( $this->UserEmailOnUpdateText ); $this->UserEmailOnUpdateTitle = $this->stringDecode( $this->UserEmailOnUpdateTitle ); $this->UserEmailPaymentsText = $this->stringDecode( $this->UserEmailPaymentsText ); $this->UserEmailPaymentsTitle = $this->stringDecode( $this->UserEmailPaymentsTitle ); $this->UserEmailOnRenewText = $this->stringDecode( $this->UserEmailOnRenewText ); $this->UserEmailOnRenewTitle = $this->stringDecode( $this->UserEmailOnRenewTitle ); $this->AdmEmailOnSubmitText = $this->replaceMarkers( $this->AdmEmailOnSubmitText ); $this->AdmEmailOnSubmitTitle = $this->replaceMarkers( $this->AdmEmailOnSubmitTitle ); $this->UserEmailOnSubmitText = $this->replaceMarkers( $this->UserEmailOnSubmitText ); $this->UserEmailOnSubmitTitle = $this->replaceMarkers( $this->UserEmailOnSubmitTitle ); $this->AdmEmailOnUpdateText = $this->replaceMarkers( $this->AdmEmailOnUpdateText ); $this->AdmEmailOnUpdateTitle = $this->replaceMarkers( $this->AdmEmailOnUpdateTitle ); $this->AdmEmailOnRenewText = $this->replaceMarkers( $this->AdmEmailOnRenewText ); $this->AdmEmailOnRenewTitle = $this->replaceMarkers( $this->AdmEmailOnRenewTitle ); $this->AdmEmailPaymentsText = $this->replaceMarkers( $this->AdmEmailPaymentsText ); $this->AdmEmailPaymentsTitle = $this->replaceMarkers( $this->AdmEmailPaymentsTitle ); $this->UserEmailPaymentsText = $this->replaceMarkers( $this->UserEmailPaymentsText ); $this->UserEmailPaymentsTitle = $this->replaceMarkers( $this->UserEmailPaymentsTitle ); $this->UserEmailOnApproveText = $this->replaceMarkers( $this->UserEmailOnApproveText ); $this->UserEmailOnApproveTitle = $this->replaceMarkers( $this->UserEmailOnApproveTitle ); $this->UserEmailOnUpdateText = $this->replaceMarkers( $this->UserEmailOnUpdateText ); $this->UserEmailOnUpdateTitle = $this->replaceMarkers( $this->UserEmailOnUpdateTitle ); $this->UserEmailOnRenewText = $this->replaceMarkers( $this->UserEmailOnRenewText ); $this->UserEmailOnRenewTitle = $this->replaceMarkers( $this->UserEmailOnRenewTitle ); } } /** * Replacing general placeholders * * @param string $string - string to replace * @return string $string */ function replaceMarkers ( $string ) { $string = str_replace( "{sobi}", $this->componentName, $string ); $string = str_replace( "{sitename}", $this->sitename, $string ); if ( ! defined( '_SOBI2_ADMIN' ) && is_object( $this->user ) ) { $string = str_replace( "{user}", $this->user->username, $string ); } $string = str_replace( "{expiration_time}", $this->entryExpirationTime, $string ); return $string; } /** * encoding email subject to 7-Bit ASCII * * @param string $str * @return string */ function makeSubject ( $str ) { if ( $this->key( "string", "mail_subject_base64", true ) ) { $iso = defined( "_ISO" ) ? explode( '=', _ISO ) : array( null , "UTF-8" ); $str = base64_encode( $str ); $str = "=?{$iso[1]}?B?{$str}=?="; } return $str; } /** * giving all available languages * * @param boolean $sbox - if sbox, returning it as selectbox. * @param string $selected - selected language in selectbox * @param string $js - javaScript for selectbox * @param string $name - name of selectbox * @return array */ function getLanguages ( $sbox = true, $selected = null, $js = null, $name = 'slang' ) { sobi2Config::import( "includes|helper.class" ); return sobi2Helper::getLanguages( $sbox, $selected, $js, $name ); } /** * Enter description here... * * @param array $arr named array * @param string $name key to search for * @param mixed $def default value * @param int $mask * @return mixed */ function request ( &$arr, $name, $def = null, $mask = 0 ) { if ( defined( "_JEXEC" ) && class_exists( "JRequest" ) ) { if ( $arr === $_REQUEST ) { $array = 'default'; } elseif ( $arr === $_POST ) { $array = 'POST'; } elseif ( $arr === $_GET ) { $array = 'GET'; } elseif ( $arr === $_COOKIE ) { $array = 'COOKIE'; } elseif ( $arr === $_SERVER ) { $array = 'SERVER'; } elseif ( $arr === $_FILES ) { $array = 'FILES'; } elseif ( $arr === $_ENV ) { $array = 'ENV'; } return JRequest::getVar( $name, $def, $array, 'none', $mask ); } else { return mosGetParam( $arr, $name, $def, $mask ); } } /** * @param string $url * @return string */ function sef ( $url ) { $config = & sobi2Config::getInstance(); if ( $config->key( 'general', 'extended_menu', true ) && class_exists( 'JURI' ) ) { $url = $config->itemid( $url ); } if ( $config->key( 'frontpage', 'sef_on', true ) ) { if ( class_exists( 'JURI' ) ) { $url = str_replace( '&', '&', $url ); $uri = JURI::getInstance(); $prefix = $uri->toString( array( 'scheme' , 'host' , 'port' ) ); $JURL = $prefix . JRoute::_( $url ); return $JURL; } else { return sefRelToAbs( $url ); } } else { return $config->liveSite . '/' . $url; } } /** * Check if given category is linked in Joomla! main manu * * @param int $cid * @return int */ function checkCatItemid ( $cid ) { $this->initMenu(); return isset( $this->links[ $cid ] ) ? $this->links[ $cid ][ 'id' ] : false; } /** * Check if given category is linked in Joomla! main manu * * @param int $cid * @return int */ function checkItemid ( $request = null, $parents = true ) { $this->initMenu(); $Itemid = $this->checkCatItemid( $request ); if ( ! $Itemid ) { if ( is_numeric( $request ) && $parents ) { $parents = array(); $this->getParentCats( ( int ) $request, $parents ); if ( count( $parents ) ) { $parents = array_reverse( $parents ); foreach ( $parents as $cid ) { if ( isset( $this->links[ $cid ] ) ) { $Itemid = $this->links[ $cid ][ 'id' ]; break; } } } } } return $Itemid ? $Itemid : $this->links[ 'default' ][ 'id' ]; } /** * Get all data from Joomla! 1.5 menu links to Sobi2 */ function initMenu () { if ( empty( $this->links ) ) { $db = & $this->getDb(); $db->setQuery( 'SELECT id, link, name FROM #__menu WHERE link LIKE "%index.php?option=com_sobi2%" AND type = "component" AND published = 1' ); $items = $db->loadObjectList(); if ( count( $items ) ) { foreach ( $items as $item ) { if ( strstr( $item->link, 'catid' ) ) { $link = null; preg_match( '/catid=(\d+)/', $item->link, $link ); if ( ! empty( $link ) && isset( $link[ 1 ] ) ) { $this->links[ $link[ 1 ] ][ 'id' ] = $item->id; $this->links[ $link[ 1 ] ][ 'name' ] = $item->name; } if ( ! $link[ 1 ] ) { $this->links[ 'default' ][ 'id' ] = $item->id; } } elseif ( strstr( $item->link, 'sobi2Task' ) ) { $link = null; preg_match( '/sobi2Task=(\w+)/', $item->link, $link ); if ( ! empty( $link ) && isset( $link[ 1 ] ) ) { $this->links[ $link[ 1 ] ][ 'id' ] = $item->id; $this->links[ $link[ 1 ] ][ 'name' ] = $item->name; } } else { $this->links[ 'default' ][ 'id' ] = $item->id; } } if ( ! isset( $this->links[ 'default' ] ) ) { if ( ! $this->sobi2Itemid ) { $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(); } $this->links[ 'default' ][ 'id' ] = $this->sobi2Itemid; } } else { $this->links[ 'default' ][ 'id' ] = 0; } } } function __destruct () { if ( self::request( $_REQUEST, 'no_html', 0 ) ) { return false; } self::debOut( '

Debug End


', false, true ); if ( count( $this->debStore ) > 1 ) { echo '
'; 
			echo implode( '
', $this->debStore ); echo '
'; } } 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( "curencyDecSeparator, ' ' ); if ( $withCurrency ) { $string = str_replace( array( "%value%" , "%currency%" ), array( $string , $this->currency ), $this->key( "string", "currency_format", "%value% %currency%" ) ); } return $string; } /** * checking if the category has child categories * * @param integer $catid - category id to check * @return boolean */ function catHasChild ( $catid ) { $query = "SELECT COUNT(`catid`) FROM `#__sobi2_cats_relations` WHERE `parentid` = '{$catid}'"; $this->database->setQuery( $query ); $hasChild = $this->database->loadResult(); return ( $hasChild ) ? true : false; } /** * @param path The starting file or directory (no trailing slash) * @return TRUE=all succeeded FALSE=one or more chmods failed */ function sobiChmodRecursive ( $path ) { return sobi2Config::chmodRecursive( $path, $this->fmod, $this->dmod ); } /** * Orginal mosMakePath joomla function. Creating directory * @param string - An existing base path * @param string - A path to create from the base path * @global integer - Directory permissions * @return boolean - True if successful */ function sobiMakePath ( $base, $path = null, $mode = NULL ) { sobi2Config::import( "includes|fsystem.class" ); return sobi2Fsystem::makePath( $this, $base, $path, $mode ); } function loadBridge () { static $loaded = false; if ( $loaded ) { return $loaded; } $file = ( defined( '_JEXEC' ) && class_exists( 'JRequest' ) && ! $this->forceLegacy ) ? 'j15' : 'j10'; sobi2Config::import( "includes|bridge|{$file}" ); $loaded = true; } /** * to revert UTF-8 encoding (ajax) * * @param string $string * @return string */ function stringDecode ( $string ) { $iso = defined( "_ISO" ) ? explode( '=', _ISO ) : array( null , "UTF-8" ); if ( strtoupper( $iso[ 1 ] ) == 'UTF-8' ) { return $string; } if ( $this->key( "string", "mb_convert_encoding", true ) && function_exists( "mb_convert_encoding" ) ) { $string = mb_convert_encoding( $string, $iso[ 1 ], "UTF-8" ); } elseif ( $this->key( "string", "iconv", true ) && function_exists( "iconv" ) ) { $string = iconv( "UTF-8", $iso[ 1 ], $string ); } else { switch ( $iso[ 1 ] ) { default: case 'iso-8859-1': $string = utf8_decode( $string ); break; case 'iso-8859-2': $string = $this->utf82iso88592( $string ); break; case 'UTF-8': break; } } return $string; } /** * to save in UTF-8 encoding (ajax) * * @param string $string * @return string */ function stringEncode ( $string ) { $iso = defined( "_ISO" ) ? explode( '=', _ISO ) : array( null , "UTF-8" ); if ( strtoupper( $iso[ 1 ] ) == 'UTF-8' ) { return $string; } if ( $this->key( "string", "mb_convert_encoding", true ) && function_exists( "mb_convert_encoding" ) ) { $string = mb_convert_encoding( $string, "UTF-8", $iso[ 1 ] ); } if ( $this->key( "string", "iconv", true ) && function_exists( "iconv" ) ) { $string = iconv( $iso[ 1 ], "UTF-8", $string ); } else { switch ( $iso[ 1 ] ) { default: case 'iso-8859-1': $string = utf8_encode( $string ); break; case 'iso-8859-2': $string = $this->iso885922utf8( $string ); break; case 'UTF-8': break; } } return $string; } /** * Enter description here... * * @return array */ function translateUserAgent () { static $browser; if ( is_array( $browser ) && ! empty( $browser ) ) { return $browser; } sobi2Config::import( "includes|helper.class" ); $browser = array(); $browser = sobi2Helper::getBrowser( sobi2Config::request( $_SERVER, "HTTP_USER_AGENT", 0, 0x0004 ) ); $os = sobi2Helper::getOs( sobi2Config::request( $_SERVER, "HTTP_USER_AGENT", 0, 0x0004 ) ); $browser[ "os" ] = $os[ "name" ]; $browser[ "os_ver" ] = $os[ "ver" ]; return $browser; } /** * creating transparent png images for IE <= 6.0 * * @param string $icon * @param string $alt * @return string */ function checkPNGImage ( $icon, $alt, $style = null, $class = null, $title = null ) { sobi2Config::import( "includes|fsystem.class" ); return sobi2Fsystem::checkPNGImage( $icon, $alt, $style, $class, $title ); } /** * Enter description here... * * @param string $str * @return string */ function replaceEntities ( $str ) { // if(!$str || empty($str)) { // return null; // } // $iso = explode( '=', _ISO ); // if(strtoupper($iso[1]) != "UTF-8") { // $str = html_entity_decode($str); // } return $str; } /** * janusz@poczta.fm 25-Oct-2003 05:54 * Here are functions to PROPERLY de/encode Unicode (UTF-8) string to ISO-8859-2 (Polish character set). * Regards, Janusz * @param string $tekscik * @return string */ function utf82iso88592 ( $tekscik ) { sobi2Config::import( "includes|string.class" ); return sobi2String::utf82iso88592( $tekscik ); } /** * janusz@poczta.fm 25-Oct-2003 05:54 * Here are functions to PROPERLY de/encode Unicode (UTF-8) string to ISO-8859-2 (Polish character set). * Regards, Janusz * @param string $tekscik * @return string */ function iso885922utf8 ( $tekscik ) { sobi2Config::import( "includes|string.class" ); return sobi2String::iso885922utf8( $tekscik ); } /** * function for send emails * * @param string $subject * @param string $massage * @param string $addresse * @param boolean $forAdmin * @param string $fromMail * @param string $fromName * @param integer $sobiId * @param bool $html * @param string $cc * @param string $bcc * @param string $replyTo * @param string $replyToName */ function sendSobiMail ( $subject, $massage, $addresse = null, $forAdmin = false, $fromMail = null, $fromName = null, $sobiId = 0, $html = 0, $cc = null, $bcc = null, $replyTo = null, $replyToName = null ) { sobi2Config::import( "includes|mail.class" ); return sobi2Mail::send( $subject, $massage, $addresse, $forAdmin, $fromMail, $fromName, $sobiId, $html, $cc, $bcc, $replyTo, $replyToName ); } /** * @param string $path * @param int $fmode * @param int $dmode */ function chmodRecursive ( $path, $fmode = null, $dmode = null, $force = false ) { sobi2Config::import( "includes|fsystem.class" ); return sobi2Fsystem::chmodRecursive( $path, $fmode, $dmode, $force ); } /** * write errors to log file * * @param string $msg */ function logSobiError ( $msg ) { if ( $this->debug == - 1 || ! ( strstr( $msg, "com_sobi2" ) ) || strstr( $msg, "session" ) ) { return null; } @sobi2Config::chmodRecursive( _SOBI_CMSROOT . DS . "administrator" . DS . "components" . DS . "com_sobi2" . DS . "error_logfile.txt", 0777, 0777 ); if ( ! $log = @fopen( _SOBI_CMSROOT . DS . "administrator" . DS . "components" . DS . "com_sobi2" . DS . "error_logfile.txt", "a+" ) ) { return null; } $now = $this->getTimeAndDate(); if ( isset( $_SERVER[ "REMOTE_ADDR" ] ) ) { $ip = $_SERVER[ "REMOTE_ADDR" ]; } else { $ip = "none"; } if ( isset( $_SERVER[ "HTTP_REFERER" ] ) ) { $ref = $_SERVER[ "HTTP_REFERER" ]; } else { $ref = "none"; } if ( isset( $_SERVER[ "HTTP_USER_AGENT" ] ) ) { $browser = $_SERVER[ "HTTP_USER_AGENT" ]; } else { $browser = "none"; } if ( isset( $_SERVER[ "REQUEST_URI" ] ) ) { $requestet = $_SERVER[ "REQUEST_URI" ]; } else { $requestet = "none"; } $msg = str_replace( "\n", "
", $msg ); $logMsg = "{$now}: \n" . "\t IP: {$ip} \n" . "\t Requestet URI: {$requestet} \n" . "\t Refferer: {$ref} \n" . "\t Browser: {$browser}\n" . "\t Error: {$msg} \n" . "---------------------------------------------------------\n"; fwrite( $log, $logMsg ); fclose( $log ); @sobi2Config::chmodRecursive( _SOBI_CMSROOT . DS . "administrator" . DS . "components" . DS . "com_sobi2" . DS . "error_logfile.txt", 0664, 0775 ); } /** * Clear and remove a directory recursive * * @param string $dir */ function removeDirRecursive ( $dir ) { sobi2Config::import( "includes|fsystem.class" ); return sobi2Fsystem::removeDirRecursive( $dir ); } function _d ( $str, $out = false ) { return sobi2Config::debOut( $str, $out, true, true, 1 ); } /** * @param string $str */ function debOut ( $str, $out = false, $s = false, $file = false, $f = 0 ) { static $store = array(); static $c = 0; $o = null; if($file) { $from = debug_backtrace(); $called = $from[ $f ]; $called[ 'file' ] = str_replace( dirname( __FILE__ ) . DS, null, $called[ 'file' ] ); $cfrom = isset( $from[ $f + 1 ] ) ? $from[ $f + 1 ] : array( 'function' => '' , 'class' => '' ); $cClass = isset( $cfrom[ 'class' ] ) ? $cfrom[ 'class' ] : 'none'; $cFunct = isset( $cfrom[ 'function' ] ) ? $cfrom[ 'function' ] : 'none'; $function = " {$cClass}::{$cFunct} in "; $o = "Called from{$function}file {$called[ 'file' ]}:{$called[ 'line' ]}"; } if ( ! $str ) { $str = "Empty"; } if ( $out ) { $o .= ""; } else { $o .= ""; } if ( $s ) { if ( isset( $GLOBALS[ 'sobi2_config_construct_cs' ] ) && ! $GLOBALS[ 'sobi2_config_construct_cs' ] ) { $config = & self::getInstance(); $config->debStore = & $store; } $c ++; $store[] = "[{$c}] {$o}"; } else { echo $o; } } function sobi2setcookie($name, $value) { $config =& sobi2Config::getInstance(); //$cookieDomain = str_replace("http://", null, $config->getLiveSite()); $cycle = $config->key("search", "cookie_lifecycle", 0); if ($cycle) { $cycle = time() + $cycle; } setcookie($name, $value, $cycle, "/"); } } if ( ! function_exists( "overideErrorHandling" ) ) { /** * @param integer $errno * @param string $msg * @param string $file * @param string $line * @param array $context */ function overideErrorHandling ( $errno, $msg, $file, $line, $context ) { /* if critical section do nothing */ if ( isset( $GLOBALS[ 'sobi2_config_construct_cs' ] ) && $GLOBALS[ 'sobi2_config_construct_cs' ] == true ) { return false; } if ( ! stristr( $file, "com_sobi2" ) || strstr( $file, "session" ) || strstr( $msg, "ob_end_clean" ) ) { return null; } $config = & sobi2Config::getInstance(); if ( $errno != 2048 ) { if ( $config->debug > 100 ) { $debugLevel = $config->debug - 100; } else { $debugLevel = $config->debug; } if ( $debugLevel == 9 || ( $debugLevel == 8 && ( $errno < 8 || $errno == 512 || $errno == 256 ) ) || ( $debugLevel == 7 && $errno == 256 ) ) { $config->logSobiError( "{$msg} (Error number:{$errno}) in file: {$file} at the line: {$line}." ); } } } } if ( ! function_exists( 'sobi2trim' ) ) { /** * @param array $v */ function sobi2trim ( &$v ) { $v = trim( $v ); } } //Replacements for deprecated functions in PHP5.3 if (! function_exists('sobi2_ereg')) { function sobi2_ereg ($pattern, $string) { return preg_match ('/'.$pattern.'/', $string); } } if (! function_exists('sobi2_eregi')) { function sobi2_eregi ($pattern, $string) { return preg_match ('/'.$pattern.'/i', $string); } } if (! function_exists('sobi2_eregi_replace')) { function sobi2_eregi_replace($pattern, $replacement, $string) { return preg_replace ('/'.$pattern.'/i', $replacement, $string); } } if (! function_exists('sobi2_ereg_replace')) { function sobi2_ereg_replace($pattern, $replacement, $string) { return preg_replace ('/'.$pattern.'/', $replacement, $string); } } if (! function_exists('sobi2_split')) { function sobi2_split ($pattern, $string) { return preg_split ('/'.$pattern.'/', $string); } } ?>