Ejemplo n.º 1
0
 public function verifyToken()
 {
     return;
     $aCheck = array('/video/frame/', '/subscribe/complete/', '/ad/complete/', '/music/upload/');
     if ($sPlugin = Phpfox_Plugin::get('log.service_session___verifyToken_start')) {
         eval($sPlugin);
     }
     if (defined('PHPFOX_SKIP_POST_PROTECTION')) {
         return;
     }
     if (isset($_GET[PHPFOX_GET_METHOD]) && (in_array($_GET[PHPFOX_GET_METHOD], $aCheck) || preg_match('/\\/api\\/gateway\\/callback\\/(.*?)\\//', $_GET[PHPFOX_GET_METHOD], $aMatches))) {
         return;
     }
     // CSRF
     if (Phpfox::getParam('core.csrf_protection_level') != 'low' && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
         if (!isset($_POST[Phpfox::getTokenName()]['security_token'])) {
             $this->_log(Phpfox::getPhrase('error.csrf_token_set'));
         }
         if (Phpfox::getParam('core.csrf_protection_level') == 'high') {
             $sToken = Phpfox::getLib('session')->get('security_token');
             if (!$sToken) {
                 $this->_log(Phpfox::getPhrase('error.csrf_session_token'));
             }
         } else {
             $sToken = $this->getToken();
         }
         if ($sToken != $_POST[Phpfox::getTokenName()]['security_token']) {
             $this->_log(Phpfox::getPhrase('error.csrf_detected'));
         }
     }
 }
Ejemplo n.º 2
0
	public function globalSearch($sQuery, $bIsTagSearch = false)
	{
		if ($bIsTagSearch === true)
		{
			return;
		}
		
		$sKeywordSearch = '(u.full_name LIKE \'%' . Phpfox::getLib('database')->escape($sQuery) . '%\' OR (u.email LIKE \'%' . Phpfox::getLib('database')->escape($sQuery) . '@%\' OR u.email = \'' . Phpfox::getLib('database')->escape($sQuery) . '\'))';

		$iCnt = $this->database()->select('COUNT(*)')
		->from($this->_sTable, 'u')
		->where($sKeywordSearch)
		->execute('getSlaveField');

		$aUsers = $this->database()->select('u.joined, ' . Phpfox::getUserField())
		->from($this->_sTable, 'u')
		->where($sKeywordSearch)
		->limit(10)
		->order('u.joined DESC')
		->execute('getSlaveRows');

		if (count($aUsers))
		{
			$aResults = array();
			$aResults['total'] = $iCnt;
			$aResults['menu'] = Phpfox::getPhrase('user.members');
			$aResults['form'] = '<form method="post" action="' . Phpfox::getLib('url')->makeUrl('user.browse') . '"><div><input type="hidden" name="' . Phpfox::getTokenName() . '[security_token]" value="' . Phpfox::getService('log.session')->getToken() . '" /></div><div><input name="search[keyword]" value="' . Phpfox::getLib('parse.output')->clean($sQuery) . '" size="20" type="hidden" /></div><div><input type="hidden" name="search[type]" value="2" /></div><div><input type="submit" value="' . Phpfox::getPhrase('user.view_more_members') . '" class="search_button" /></div></form>';
			foreach ($aUsers as $iKey => $aUser)
			{
				$aResults['results'][$iKey] = array(
					'link' => Phpfox::getLib('url')->makeUrl($aUser['user_name']),
					'title' => $aUser['full_name'],					
					'image' => Phpfox::getLib('image.helper')->display(array(
							'user' => $aUser,
							'suffix' => '_75',
							'max_width' => 75,
							'max_height' => 75
						)
					),
					'extra_info' => Phpfox::getPhrase('user.a_href_link_member_a_joined_joined', array(
							'link' => Phpfox::getLib('url')->makeUrl('user.browse'),
							'joined' => Phpfox::getTime(Phpfox::getParam('core.global_update_time'), $aUser['joined'])
						)
					)
				);
			}

			return $aResults;
		}
	}
Ejemplo n.º 3
0
 /** 
  * Returns paging info: 'totalPages', 'totalRows', 'current', 'fromRow','toRow', 'firstUrl', 'prevUrl', 'nextUrl', 'lastUrl',  'urls' (url=>page)
  * 
  * @param Url $oUrl page url
  * @return array paging info
  */
 private function _getInfo()
 {
     if ($this->getTotalPages() == 0) {
         return false;
     }
     $sParams = '';
     if (count($this->_aParams)) {
         foreach ($this->_aParams as $iKey => $sValue) {
             if (in_array($iKey, array('phpfox', Phpfox::getTokenName(), 'page', PHPFOX_GET_METHOD, 'ajax_page_display'))) {
                 continue;
             }
             if (is_array($sValue)) {
                 foreach ($sValue as $sKey => $sNewValue) {
                     if (is_numeric($sKey)) {
                         continue;
                     }
                     $sParams .= '&amp;' . $iKey . '[' . $sKey . ']=' . $sNewValue;
                 }
             } else {
                 if (PHPFOX_IS_AJAX && $iKey == 'feed' && Phpfox::isModule('comment') && Phpfox::getParam('comment.load_delayed_comments_items')) {
                     continue;
                 }
                 $sParams .= '&amp;' . $iKey . '=' . $sValue;
             }
         }
     }
     $aInfo = array('totalPages' => $this->_iPagesCount, 'totalRows' => $this->_iCnt, 'current' => $this->_iPage, 'fromRow' => $this->_iFirstRow + 1, 'toRow' => $this->_iLastRow, 'displaying' => $this->_iCnt <= $this->_iPageSize * $this->_iPage ? $this->_iCnt : $this->_iPageSize * $this->_iPage, 'sParams' => $sParams, 'phrase' => $this->_sPhrase, 'icon' => $this->_sIcon);
     list($nStart, $nEnd) = $this->_getPos();
     $oUrl = Phpfox::getLib('url');
     $oUrl->clearParam('page');
     if ($this->_iPage != 1) {
         $oUrl->setParam($this->_sUrlKey, 1);
         $aInfo['firstAjaxUrl'] = 1;
         $aInfo['firstUrl'] = $oUrl->getFullUrl();
         $oUrl->setParam($this->_sUrlKey, $this->_iPage - 1);
         $aInfo['prevAjaxUrl'] = $this->_iPage - 1;
         $aInfo['prevUrl'] = $oUrl->getFullUrl();
         Phpfox::getLib('template')->setHeader('<link rel="prev" href="' . $aInfo['prevUrl'] . '" />');
     }
     for ($i = $nStart; $i <= $nEnd; $i++) {
         if ($this->_iPage == $i) {
             $oUrl->setParam($this->_sUrlKey, $i);
             $aInfo['urls'][$oUrl->getFullUrl()] = $i;
         } else {
             $oUrl->setParam($this->_sUrlKey, $i);
             $aInfo['urls'][$oUrl->getFullUrl()] = $i;
         }
     }
     $oUrl->setParam($this->_sUrlKey, $this->_iPage + 1);
     $aInfo['nextAjaxUrlPager'] = $oUrl->getFullUrl();
     if ($this->_iPagesCount != $this->_iPage) {
         $oUrl->setParam($this->_sUrlKey, $this->_iPage + 1);
         $aInfo['nextAjaxUrl'] = $this->_iPage + 1;
         $aInfo['nextUrl'] = $oUrl->getFullUrl();
         Phpfox::getLib('template')->setHeader('<link rel="next" href="' . $aInfo['nextUrl'] . '" />');
         $oUrl->setParam($this->_sUrlKey, $this->_iPagesCount);
         $aInfo['lastUrl'] = $oUrl->getFullUrl();
         $aInfo['lastAjaxUrl'] = $this->_iPagesCount;
     }
     $aInfo['sParamsAjax'] = str_replace("'", "\\'", $aInfo['sParams']);
     Phpfox::getLib('template')->assign(array('aPager' => $aInfo, 'sAjax' => $this->_sAjax));
 }
Ejemplo n.º 4
0
 public function getAdminLoginLog($iId)
 {
     $aLog = $this->database()->select('al.*, ' . Phpfox::getUserField())->from(Phpfox::getT('admincp_login'), 'al')->join(Phpfox::getT('user'), 'u', 'u.user_id = al.user_id')->where('al.login_id = ' . (int) $iId)->execute('getSlaveRow');
     if (!isset($aLog['login_id'])) {
         return Phpfox_Error::set(Phpfox::getPhrase('admincp.not_a_valid_login_log'));
     }
     $aLog['attempt'] = $this->_getAdminLoginAttempt($aLog['is_failed']);
     $aLog['cache_data'] = unserialize($aLog['cache_data']);
     $aLog['cache_data']['request'] = unserialize($aLog['cache_data']['request']);
     $aLog['cache_data']['token'] = isset($aLog['cache_data']['request']['phpfox']['security_token']) ? $aLog['cache_data']['request']['phpfox']['security_token'] : $aLog['cache_data']['request'][Phpfox::getTokenName()]['security_token'];
     $aLog['cache_data']['email'] = $aLog['cache_data']['request']['val']['email'];
     return $aLog;
 }
Ejemplo n.º 5
0
 public function globalSearch($sQuery, $bIsTagSearch = false)
 {
     $sCondition = 'p.in_process = 0 AND p.view_id = 0 AND p.item_id = 0 AND p.privacy = 0';
     if ($bIsTagSearch === false) {
         $sCondition .= ' AND (p.title LIKE \'%' . $this->database()->escape($sQuery) . '%\' OR pi.text_parsed LIKE \'%' . $this->database()->escape($sQuery) . '%\')';
     }
     if ($bIsTagSearch == true) {
         $this->database()->innerJoin(Phpfox::getT('tag'), 'tag', 'tag.item_id = p.video_id AND tag.category_id = \'video\' AND tag.tag_url = \'' . $this->database()->escape($sQuery) . '\'');
     }
     $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'p')->join(Phpfox::getT('video_text'), 'pi', 'pi.video_id = p.video_id')->where($sCondition)->execute('getSlaveField');
     if ($bIsTagSearch == true) {
         $this->database()->innerJoin(Phpfox::getT('tag'), 'tag', 'tag.item_id = p.video_id AND tag.category_id = \'video\' AND tag.tag_url = \'' . $this->database()->escape($sQuery) . '\'')->group('p.video_id');
     }
     $aRows = $this->database()->select('p.title, p.title_url, p.time_stamp, p.image_path, p.image_server_id, ' . Phpfox::getUserField())->from($this->_sTable, 'p')->join(Phpfox::getT('video_text'), 'pi', 'pi.video_id = p.video_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = p.user_id')->where($sCondition)->limit(10)->order('p.time_stamp DESC')->execute('getSlaveRows');
     if (count($aRows)) {
         $aResults = array();
         $aResults['total'] = $iCnt;
         $aResults['menu'] = Phpfox::getPhrase('video.videos');
         if ($bIsTagSearch == true) {
             $aResults['form'] = '<div><input type="button" value="' . Phpfox::getPhrase('video.view_more_videos') . '" class="search_button" onclick="window.location.href = \'' . Phpfox::getLib('url')->makeUrl('video', array('tag', $sQuery)) . '\';" /></div>';
         } else {
             $aResults['form'] = '<form method="post" action="' . Phpfox::getLib('url')->makeUrl('video') . '"><div><input type="hidden" name="' . Phpfox::getTokenName() . '[security_token]" value="' . Phpfox::getService('log.session')->getToken() . '" /></div><div><input name="search[keyword]" value="' . Phpfox::getLib('parse.output')->clean($sQuery) . '" size="20" type="hidden" /></div><div><input type="submit" name="submit" value="' . Phpfox::getPhrase('video.view_more_videos') . '" class="search_button" /></div></form>';
         }
         foreach ($aRows as $iKey => $aRow) {
             $aResults['results'][$iKey] = array('title' => $aRow['title'], 'link' => Phpfox::getLib('url')->makeUrl($aRow['user_name'], array('video', $aRow['title_url'])), 'image' => Phpfox::getLib('image.helper')->display(array('server_id' => $aRow['image_server_id'], 'title' => $aRow['title'], 'path' => 'video.url_image', 'file' => $aRow['image_path'], 'suffix' => '_120', 'max_width' => 75, 'max_height' => 75)), 'extra_info' => Phpfox::getPhrase('video.video_added_on_time_stamp_by_full_name', array('link' => Phpfox::getLib('url')->makeUrl('video'), 'time_stamp' => Phpfox::getTime(Phpfox::getParam('core.global_update_time'), $aRow['time_stamp']), 'user_link' => Phpfox::getLib('url')->makeUrl($aRow['user_name']), 'full_name' => $this->preParse()->clean($aRow['full_name']))));
         }
         return $aResults;
     }
 }
Ejemplo n.º 6
0
 /**
  * Gets any data we plan to place within the HTML tags <head></head>.
  * This method also groups the data to give the template a nice clean look.
  *
  * @return string|array $sData Returns the HTML data to be placed within <head></head>
  */
 public function getHeader($bReturnArray = false)
 {
     if (Phpfox::isAdminPanel()) {
         $this->setHeader(array('custom.css' => 'style_css'));
     }
     if ($this->delayedHeaders) {
         foreach ($this->delayedHeaders as $header) {
             $this->setHeader('cache', $header);
         }
     }
     // $this->setHeader('<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">');
     Core\Event::trigger('lib_phpfox_template_getheader', $this);
     foreach ((new Core\App())->all() as $App) {
         if ($App->head && is_array($App->head)) {
             foreach ($App->head as $head) {
                 $this->setHeader($head);
             }
         }
         if ($App->settings) {
             $Setting = new Core\Setting();
             foreach ($App->settings as $key => $setting) {
                 if (isset($setting->js_variable)) {
                     $this->setHeader('<script>var ' . $key . ' = "' . $Setting->get($key) . '";</script>');
                 }
             }
         }
     }
     $aArrayData = array();
     $sData = '';
     $sJs = '';
     $iVersion = $this->getStaticVersion();
     $oUrl = Phpfox_Url::instance();
     $aUrl = $oUrl->getParams();
     if (!defined('PHPFOX_DESIGN_DND')) {
         define('PHPFOX_DESIGN_DND', false);
     }
     if (!PHPFOX_IS_AJAX_PAGE) {
         ($sPlugin = Phpfox_Plugin::get('template_getheader')) ? eval($sPlugin) : false;
         $sJs .= "\t\t\tvar oCore = {'core.is_admincp': " . (Phpfox::isAdminPanel() ? 'true' : 'false') . ", 'core.section_module': '" . Phpfox_Module::instance()->getModuleName() . "', 'profile.is_user_profile': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? 'true' : 'false') . ", 'log.security_token': '" . Phpfox::getService('log.session')->getToken() . "', 'core.url_rewrite': '" . Phpfox::getParam('core.url_rewrite') . "', 'core.country_iso': '" . (Phpfox::isUser() ? Phpfox::getUserBy('country_iso') : '') . "', 'core.can_move_on_a_y_and_x_axis' : " . (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.can_move_on_a_y_and_x_axis') ? 'true' : 'false') . ", 'core.default_currency': '" . (defined('PHPFOX_INSTALLER') ? 'USD' : Phpfox::getService('core.currency')->getDefault()) . "', 'core.enabled_edit_area': " . (Phpfox::getParam('core.enabled_edit_area') ? 'true' : 'false') . ", 'core.disable_hash_bang_support': " . (Phpfox::getParam('core.disable_hash_bang_support') ? 'true' : 'false') . ", 'core.site_wide_ajax_browsing': " . (!defined('PHPFOX_IN_DESIGN_MODE') && Phpfox::getParam('core.site_wide_ajax_browsing') && !Phpfox::isAdminPanel() && Phpfox::isUser() ? 'true' : 'false') . ", 'profile.user_id': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? Profile_Service_Profile::instance()->getProfileUserId() : 0) . "};\n";
         // You are filtering out the controllers which should not load 'content' ajaxly, finding a way for pages.view/1/info and like that
         $sProgressCssFile = $this->getStyle('css', 'progress.css');
         $sStylePath = str_replace(Phpfox::getParam('core.path'), '', str_replace('progress.css', '', $sProgressCssFile));
         $aJsVars = array('sJsHome' => Phpfox::getParam('core.path'), 'sJsHostname' => $_SERVER['HTTP_HOST'], 'sSiteName' => Phpfox::getParam('core.site_title'), 'sJsStatic' => $oUrl->getDomain() . PHPFOX_STATIC, 'sJsStaticImage' => Phpfox::getParam('core.url_static_image'), 'sImagePath' => $this->getStyle('image'), 'sStylePath' => $this->getStyle('css'), 'sVersion' => Phpfox::getId(), 'sJsAjax' => $oUrl->getDomain() . PHPFOX_STATIC . 'ajax.php', 'sStaticVersion' => $iVersion, 'sGetMethod' => PHPFOX_GET_METHOD, 'sDateFormat' => defined('PHPFOX_INSTALLER') ? '' : Phpfox::getParam('core.date_field_order'), 'sEgiftStyle' => $this->getStyle('css', 'display.css', 'egift'), 'sGlobalTokenName' => Phpfox::getTokenName(), 'sController' => Phpfox_Module::instance()->getFullControllerName(), 'bJsIsMobile' => Phpfox::isMobile() ? true : false, 'sProgressCssFile' => $sProgressCssFile, 'sHostedVersionId' => defined('PHPFOX_IS_HOSTED_VERSION') ? PHPFOX_IS_HOSTED_VERSION : '');
         if (!defined('PHPFOX_INSTALLER')) {
             $aJsVars['bWysiwyg'] = Phpfox::getParam('core.wysiwyg') != 'default' && Phpfox::getParam('core.allow_html') ? true : false;
             $aJsVars['sEditor'] = Phpfox::getParam('core.wysiwyg');
             $aJsVars['sJsCookiePath'] = Phpfox::getParam('core.cookie_path');
             $aJsVars['sJsCookieDomain'] = Phpfox::getParam('core.cookie_domain');
             $aJsVars['sJsCookiePrefix'] = Phpfox::getParam('core.session_prefix');
             $aJsVars['bPhotoTheaterMode'] = Phpfox::isModule('photo') ? Phpfox::getParam('photo.view_photos_in_theater_mode') : false;
             $aJsVars['bUseHTML5Video'] = false;
             // ((Phpfox::isModule('video') && Phpfox::getParam('video.upload_for_html5')) ? true : false);
             if (Phpfox::isAdmin()) {
                 $aJsVars['sAdminCPLocation'] = Phpfox::getParam('admincp.admin_cp');
             } else {
                 $aJsVars['sAdminCPLocation'] = '';
             }
             if (Phpfox::isModule('notification')) {
                 $aJsVars['notification.notify_ajax_refresh'] = Phpfox::getParam('notification.notify_ajax_refresh');
             }
             $sLocalDatepicker = PHPFOX_STATIC . 'jscript/jquery/locale/jquery.ui.datepicker-' . strtolower(Phpfox_Locale::instance()->getLangId()) . '.js';
             if (file_exists($sLocalDatepicker)) {
                 $sFile = str_replace(PHPFOX_STATIC . 'jscript/', '', $sLocalDatepicker);
                 $this->setHeader(array($sFile => 'static_script'));
             }
             /* Only in a few cases will we want to add the visitor's IP */
             if (Phpfox::getParam('core.google_api_key') != '' && Phpfox::getParam('core.ip_infodb_api_key')) {
                 // $aJsVars['sIP'] = Phpfox_Request::instance()->getIp();
             }
             $aJsVars['bEnableMicroblogSite'] = Phpfox::isModule('microblog') ? Phpfox::getParam('microblog.enable_microblog_site') : false;
         }
         ($sPlugin = Phpfox_Plugin::get('template_getheader_setting')) ? eval($sPlugin) : false;
         if (Phpfox::isModule('input') && false) {
             $this->setHeader('cache', array('browse.css' => 'style_css'));
         }
         $sJs .= "\t\t\tvar oParams = {";
         $iCnt = 0;
         foreach ($aJsVars as $sVar => $sValue) {
             $iCnt++;
             if ($iCnt != 1) {
                 $sJs .= ",";
             }
             if (is_bool($sValue)) {
                 $sJs .= "'{$sVar}': " . ($sValue ? 'true' : 'false');
             } elseif (is_numeric($sValue)) {
                 $sJs .= "'{$sVar}': " . $sValue;
             } else {
                 $sJs .= "'{$sVar}': '" . str_replace("'", "\\'", $sValue) . "'";
             }
         }
         $sJs .= "};\n";
         if (!defined('PHPFOX_INSTALLER')) {
             $aLocaleVars = array('core.are_you_sure', 'core.yes', 'core.no', 'core.save', 'core.cancel', 'core.go_advanced', 'core.processing', 'emoticon.emoticons', 'attachment.attach_files', 'core.close', 'core.language_packages', 'core.move_this_block', 'core.uploading', 'language.loading', 'core.saving', 'core.loading_text_editor', 'core.quote', 'core.loading');
             if (Phpfox::isModule('im') && Phpfox::getParam('im.enable_im_in_footer_bar')) {
                 $aLocaleVars[] = 'im.find_your_friends';
             }
             ($sPlugin = Phpfox_Plugin::get('template_getheader_language')) ? eval($sPlugin) : false;
             $sJs .= "\t\t\tvar oTranslations = {";
             $iCnt = 0;
             foreach ($aLocaleVars as $sValue) {
                 $aParts = explode('.', $sValue);
                 if ($aParts[0] != 'core' && !Phpfox::isModule($aParts[0])) {
                     continue;
                 }
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sValue}': '" . html_entity_decode(str_replace("'", "\\'", Phpfox::getPhrase($sValue)), null, 'UTF-8') . "'";
             }
             $sJs .= "};\n";
             $aModules = Phpfox_Module::instance()->getModules();
             $sJs .= "\t\t\tvar oModules = {";
             $iCnt = 0;
             foreach ($aModules as $sModule => $iModuleId) {
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sModule}': true";
             }
             $sJs .= "};\n";
         }
         if (count($this->_aImages)) {
             $sJs .= "\t\t\tvar oJsImages = {";
             foreach ($this->_aImages as $sKey => $sImage) {
                 $sJs .= $sKey . ': \'' . $sImage . '\',';
             }
             $sJs = rtrim($sJs, ',');
             $sJs .= "};\n";
         }
         /*
         if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active'])
         {
         */
         $aEditorButtons = Phpfox::getLib('editor')->getButtons();
         $iCnt = 0;
         $sJs .= "\t\t\tvar oEditor = {";
         if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active']) {
             foreach ($this->_aEditor as $sVar => $mValue) {
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sVar}': " . (is_bool($mValue) ? $mValue === true ? 'true' : 'false' : "'{$mValue}'") . "";
             }
             $sJs .= ", ";
         }
         $sJs .= "images:[";
         foreach ($aEditorButtons as $mEditorButtonKey => $aEditorButton) {
             $sJs .= "{";
             foreach ($aEditorButton as $sEditorButtonKey => $sEditorButtonValue) {
                 $sJs .= "" . $sEditorButtonKey . ": '" . $sEditorButtonValue . "',";
             }
             $sJs = rtrim($sJs, ',') . "},";
         }
         $sJs = rtrim($sJs, ',') . "]";
         $sJs .= "};\n";
         // }
         if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn')) {
             $sData .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/' . Phpfox::getParam('core.jquery_google_cdn_version') . '/jquery.min.js"></script>' . "\n";
         }
     }
     if (PHPFOX_IS_AJAX_PAGE) {
         $this->_aCacheHeaders = array();
     }
     $bIsHttpsPage = false;
     if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.force_https_secure_pages')) {
         if (in_array(str_replace('mobile.', '', Phpfox_Module::instance()->getFullControllerName()), Phpfox::getService('core')->getSecurePages()) && (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
             $bIsHttpsPage = true;
         }
     }
     $aSubCache = array();
     $sStyleCacheData = '';
     $sJsCacheData = '';
     $aCacheJs = array();
     $aCacheCSS = array();
     $this->_sFooter = '';
     $sJs .= "\t\t\t" . 'var $Behavior = {}, $Ready = $Ready = function(callback) {$Behavior[callback.toString().length] = callback;}, $Events = {}, $Event = function(callback) {$Events[callback.toString().length] = callback;};' . "\n";
     $sJs .= "\t\t\t" . 'var $Core = {};' . "\n";
     $aCustomCssFile = array();
     foreach ($this->_aHeaders as $aHeaders) {
         if (!is_array($aHeaders)) {
             $aHeaders = array($aHeaders);
         }
         foreach ($aHeaders as $mKey => $mValue) {
             $sQmark = strpos($mKey, '?') ? '&amp;' : '?';
             if (is_numeric($mKey)) {
                 if ($mValue === null) {
                     continue;
                 }
                 if ($bReturnArray) {
                     $aArrayData[] = $mValue;
                 } else {
                     if (is_string($mValue) && (strpos($mValue, '.js') !== false || strpos($mValue, 'javascript') !== false)) {
                         if (strpos($mValue, 'RecaptchaOptions')) {
                             $sData .= "\t\t" . $mValue . "\n";
                         } else {
                             $this->_sFooter .= "\t\t" . $mValue;
                         }
                     } else {
                         if (is_string($mValue)) {
                             $sData .= "\t\t" . $mValue . "\n";
                         } else {
                             $sData .= "\t\t" . implode($mValue) . "\n";
                         }
                     }
                 }
             } else {
                 if ($mKey == 'master') {
                     $aMaster = array('css' => array(), 'jscript' => array());
                     foreach ($mValue as $sValKey => $sValVal) {
                         if (strpos($sValKey, '.css') !== false) {
                             if ($sValVal == 'style_css') {
                                 $aMaster['css'][] = 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $this->getThemeFolder() . PHPFOX_DS . 'style' . PHPFOX_DS . $this->getStyleFolder() . PHPFOX_DS . 'css' . PHPFOX_DS . $sValKey;
                             } else {
                                 if (strpos($sValVal, 'module_') !== false) {
                                     $aMaster['css'][] = 'module' . PHPFOX_DS . str_replace('module_', '', $sValVal) . PHPFOX_DS . 'static' . PHPFOX_DS . 'css' . PHFPFOX_DS . $this->getThemeFolder() . PHPFOX_DS . $this->getStyleFolder() . PHPFOX_DS . $sValKey;
                                 }
                             }
                         } else {
                             if (strpos($sValKey, '.js') !== false) {
                                 if ($sValVal == 'static_script') {
                                     $aMaster['jscript'][] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $sValKey;
                                 } else {
                                     if (strpos($sValVal, 'module_') !== false) {
                                         $aMaster['jscript'][] = 'module' . PHPFOX_DS . str_replace('module_', '', $sValVal) . PHPFOX_DS . 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $sValKey;
                                     }
                                 }
                             }
                         }
                     }
                     unset($this->_aHeaders[$mKey]);
                     // just to avoid confusions
                     $this->_aHeaders['master'] = $aMaster;
                 } else {
                     $bToHead = false;
                     // This happens when the developer needs something to go to <head>
                     if (is_array($mValue)) {
                         $aKeyHead = array_keys($mValue);
                         $aKeyValue = array_values($mValue);
                         $bToHead = $mKey == 'head';
                         $mKey = array_pop($aKeyHead);
                         $mValue = array_pop($aKeyValue);
                     }
                     switch ($mValue) {
                         case 'style_script':
                             if (isset($aSubCache[$mKey][$mValue])) {
                                 continue;
                             }
                             if ($bReturnArray) {
                                 $aArrayData[] = $this->getStyle('jscript', $mKey);
                             } else {
                                 //$sJsCacheData .= str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey)) . ',';
                                 if ($bToHead == 'head') {
                                     $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey));
                                 } else {
                                     $aCacheJs[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey));
                                 }
                             }
                             break;
                         case 'style_css':
                             $bCustomStyle = false;
                             if ($bCustomStyle === false) {
                                 if ($bReturnArray) {
                                     $aArrayData[] = $this->getStyle('css', $mKey);
                                 } else {
                                     $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey));
                                 }
                             } else {
                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT')) {
                                     $bLoadCustomThemeOverwrite = true;
                                 } else {
                                     if ($bReturnArray) {
                                         $aArrayData[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey;
                                     } else {
                                         if (isset($this->_aCacheHeaders[$mKey])) {
                                             // $sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . ',';
                                             $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . '';
                                         } else {
                                             if ($bIsHttpsPage) {
                                                 //$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_secure_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
                                                 $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_secure_' . $mKey;
                                             } else {
                                                 //$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
                                                 $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey;
                                             }
                                         }
                                     }
                                 }
                             }
                             break;
                         case 'static_script':
                             if (isset($aSubCache[$mKey][$mValue])) {
                                 continue;
                             }
                             if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn')) {
                                 if ($mKey == 'jquery/ui.js' || $mKey == 'jquery/jquery.js') {
                                     if ($mKey == 'jquery/ui.js') {
                                         $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/' . Phpfox::getParam('core.jquery_ui_google_cdn_version') . '/jquery-ui.min.js"></script>' . "\n";
                                     }
                                     continue;
                                 }
                             }
                             if ($bReturnArray) {
                                 $aArrayData[] = Phpfox::getParam('core.url_static_script') . $mKey;
                             } else {
                                 if (isset($this->_aCacheHeaders[$mKey])) {
                                     // $sJsCacheData .= $mKey . ',';
                                     if ($bToHead == 'head') {
                                         $aCacheCSS[] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $mKey;
                                     } else {
                                         $aCacheJs[] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $mKey;
                                     }
                                 } else {
                                     //$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static_script') . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                     if ($bToHead == 'head') {
                                         $aCacheCSS[] = 'static/jscript/' . $mKey;
                                     } else {
                                         $aCacheJs[] = 'static/jscript/' . $mKey;
                                     }
                                 }
                             }
                             break;
                         default:
                             if (preg_match('/module/i', $mValue)) {
                                 $aParts = explode('_', $mValue);
                                 if (isset($aParts[1]) && Phpfox::isModule($aParts[1])) {
                                     if (substr($mKey, -3) == '.js') {
                                         if ($bReturnArray) {
                                             $aArrayData[] = Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                         } else {
                                             if (isset($this->_aCacheHeaders[$mKey])) {
                                                 //$sJsCacheData .= 'module/' . $aParts[1] . '/static/jscript/' . $mKey . ',';
                                                 $aCacheJs[] = 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                             } else {
                                                 /*
                                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT'))
                                                 {
                                                 	$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getCdnPath() . 'module/' . $aParts[1] . '/static/jscript/' . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                                 }	
                                                 else
                                                 {
                                                 */
                                                 //$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                                 $aCacheJs[] = 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                                 // }
                                             }
                                         }
                                     } elseif (substr($mKey, -4) == '.css') {
                                         $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                         $bCustomStyle = false;
                                         if ($bCustomStyle === false) {
                                             if ($bReturnArray) {
                                                 //$aArrayData[] = $this->getStyle('css', $mKey, $aParts[1]);
                                                 $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                             } else {
                                                 /*
                                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT'))
                                                 {
                                                     $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . str_replace(Phpfox::getParam('core.path'), Phpfox::getCdnPath(), $this->getStyle('css', $mKey, $aParts[1])) . $sQmark . 'v=' . $iVersion . '" />' . "\n";
                                                 }
                                                 else
                                                 {
                                                 */
                                                 $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                                 // }
                                             }
                                         } else {
                                             //$sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey . ',';
                                             $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey;
                                         }
                                     }
                                 }
                             }
                             break;
                     }
                     $aSubCache[$mKey][$mValue] = true;
                 }
             }
         }
     }
     $sCacheData = '';
     $sCacheData .= "\n\t\t<script type=\"text/javascript\">\n";
     $sCacheData .= $sJs;
     $sCacheData .= "\t\t</script>";
     if (!empty($sStyleCacheData)) {
         $sCacheData .= "\n\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=css&amp;s=' . $sStylePath . '&amp;f=' . rtrim($sStyleCacheData, ',') . '&amp;v=' . $iVersion . '" />';
     }
     if (!empty($sJsCacheData)) {
         $sCacheData .= "\n\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=js&amp;f=' . rtrim($sJsCacheData, ',') . '&amp;v=' . $iVersion . '"></script>';
     }
     if (!empty($sCacheData)) {
         $sData = preg_replace('/<link rel="shortcut icon" type="image\\/x-icon" href="(.*?)" \\/>/i', '<link rel="shortcut icon" type="image/x-icon" href="\\1" />' . $sCacheData, $sData);
     }
     if ($bReturnArray) {
         $sData = '';
     }
     $aCacheJs = array_unique($aCacheJs);
     $aSubCacheCheck = array();
     foreach ($aCacheCSS as $sFile) {
         if (defined('PHPFOX_INSTALLER')) {
             $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . $sFile . $sQmark . 'v=' . $iVersion . '" />' . "\n";
         } else {
             if (isset($aSubCacheCheck[$sFile])) {
                 continue;
             }
             $aSubCacheCheck[$sFile] = true;
             $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.path') . $sFile . $sQmark . 'v=' . $iVersion . '" />' . "\n";
         }
     }
     foreach ($aCacheJs as $sFile) {
         if (defined('PHPFOX_INSTALLER')) {
             $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="../' . $sFile . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
         } else {
             $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.path') . $sFile . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
         }
     }
     if (!defined('PHPFOX_INSTALLER')) {
         $this->_sFooter .= "\t\t" . '<script type="text/javascript"> $Core.init(); </script>' . "\n";
     }
     if (count($this->_aPhrases)) {
         $sData .= "\n\t\t<script type=\"text/javascript\">\n\t\t";
         foreach ($this->_aPhrases as $sVar => $sPhrase) {
             $sPhrase = html_entity_decode($sPhrase, null, 'UTF-8');
             $sData .= "\t\t\toTranslations['{$sVar}'] = '" . str_replace("'", "\\'", $sPhrase) . "';\n";
         }
         $sData .= "\t\t</script>\n";
     }
     if (!defined('PHPFOX_INSTALLER') && !Phpfox::isAdminPanel()) {
         $Request = \Phpfox_Request::instance();
         if ($Request->segment(1) == 'theme' && $Request->segment(2) == 'demo') {
             $sData .= '<link href="' . Phpfox::getParam('core.path') . 'theme/default/flavor/default.css?v=' . Phpfox::internalVersion() . '" rel="stylesheet">';
         } else {
             $Theme = $this->_theme->get();
             $sData .= '<link href="' . Phpfox::getParam('core.path') . 'themes/' . $Theme->folder . '/flavor/' . $Theme->flavor_folder . '.css?v=' . Phpfox::internalVersion() . '" rel="stylesheet">';
         }
     }
     if (!defined('PHPFOX_INSTALLER')) {
         $Apps = new Core\App();
         foreach ($Apps->all() as $App) {
             $assets = $App->path . 'assets/';
             if (file_exists($assets . 'autoload.js')) {
                 $url = str_replace(PHPFOX_DIR_SITE, Phpfox::getParam('core.path'), $assets) . 'autoload.js';
                 $this->_sFooter .= '<script src="' . $url . '?v=' . Phpfox::internalVersion() . '"></script>';
             }
             if (file_exists($assets . 'autoload.css')) {
                 $url = str_replace(PHPFOX_DIR_SITE, Phpfox::getParam('core.path'), $assets) . 'autoload.css';
                 $sData .= '<link href="' . $url . '?v=' . Phpfox::internalVersion() . '" rel="stylesheet">';
             }
         }
         if (!Phpfox::isAdminPanel() && is_object($this->_theme)) {
             $asset = $this->_theme->get()->getPath() . 'assets/autoload.js';
             if (file_exists($asset)) {
                 $url = str_replace([PHPFOX_DIR_SITE, PHPFOX_DIR], Phpfox::getParam('core.path'), $asset);
                 $this->_sFooter .= '<script src="' . $url . '?v=' . Phpfox::internalVersion() . '"></script>';
             }
         }
     }
     if (isset($this->_meta['head'])) {
         $sData .= $this->_meta['head'];
         if (Phpfox::isAdmin()) {
             $this->_sFooter .= '<script>var page_editor_meta = ' . json_encode(['head' => $this->_meta['head']]) . ';</script>';
         }
     }
     if ($bReturnArray) {
         $aArrayData[] = $sData;
         return $aArrayData;
     }
     // Convert meta data
     $bHasNoDescription = false;
     if (count($this->_aMeta) && !PHPFOX_IS_AJAX_PAGE && !defined('PHPFOX_INSTALLER')) {
         $oPhpfoxParseOutput = Phpfox::getLib('parse.output');
         $aFind = array('&lt;', '&gt;', '$');
         $aReplace = array('<', '>', '&36;');
         foreach ($this->_aMeta as $sMeta => $sMetaValue) {
             $sMetaValue = str_replace($aFind, $aReplace, $sMetaValue);
             $sMetaValue = strip_tags($sMetaValue);
             $sMetaValue = str_replace(array("\n", "\r"), "", $sMetaValue);
             $bIsCustomMeta = false;
             switch ($sMeta) {
                 case 'keywords':
                     if (isset($this->_meta['keywords'])) {
                         $sMetaValue = $this->_meta['keywords'];
                         continue;
                     }
                     $sKeywordSearch = Phpfox::getParam('core.words_remove_in_keywords');
                     if (!empty($sKeywordSearch)) {
                         $aKeywordsSearch = array_map('trim', explode(',', $sKeywordSearch));
                     }
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_keyword_limit'));
                     $sMetaValue = trim(rtrim(trim($sMetaValue), ','));
                     $aParts = explode(',', $sMetaValue);
                     $sMetaValue = '';
                     $aKeywordCache = array();
                     foreach ($aParts as $sPart) {
                         $sPart = trim($sPart);
                         if (isset($aKeywordCache[$sPart])) {
                             continue;
                         }
                         if (isset($aKeywordsSearch) && in_array(strtolower($sPart), array_map('strtolower', $aKeywordsSearch))) {
                             continue;
                         }
                         $sMetaValue .= $sPart . ', ';
                         $aKeywordCache[$sPart] = true;
                     }
                     $sMetaValue = rtrim(trim($sMetaValue), ',');
                     break;
                 case 'description':
                     if (isset($this->_meta['description'])) {
                         $sMetaValue = $this->_meta['description'];
                         continue;
                     }
                     $bHasNoDescription = true;
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
                     break;
                 case 'robots':
                     $bIsCustomMeta = false;
                     break;
                 default:
                     $bIsCustomMeta = true;
                     break;
             }
             $sMetaValue = str_replace('"', '\\"', $sMetaValue);
             $sMetaValue = Phpfox_Locale::instance()->convert($sMetaValue);
             $sMetaValue = html_entity_decode($sMetaValue, null, 'UTF-8');
             $sMetaValue = str_replace(array('<', '>'), '', $sMetaValue);
             if ($bIsCustomMeta) {
                 if ($sMeta == 'og:description') {
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
                 }
                 switch ($sMeta) {
                     case 'canonical':
                         $sCanonical = $sMetaValue;
                         $sCanonical = preg_replace('/\\/when\\_([a-zA-Z0-9\\-]+)\\//i', '/', $sCanonical);
                         $sCanonical = preg_replace('/\\/show\\_([a-zA-Z0-9\\-]+)\\//i', '/', $sCanonical);
                         $sCanonical = preg_replace('/\\/view\\_\\//i', '/', $sCanonical);
                         if (Phpfox::isMobile()) {
                             if (Phpfox::getParam('core.url_rewrite') == '1') {
                                 $sCanonical = str_replace(Phpfox::getParam('core.path') . 'mobile/', Phpfox::getParam('core.path'), $sMetaValue);
                             } elseif (Phpfox::getParam('core.url_rewrite') == '2') {
                                 $sCanonical = str_replace('?' . PHPFOX_GET_METHOD . '=/mobile/', '?' . PHPFOX_GET_METHOD . '=/', $sMetaValue);
                             }
                         }
                         $sData .= "\t\t<link rel=\"canonical\" href=\"{$sCanonical}\" />\n";
                         if (!Phpfox::isMobile()) {
                             $sMobileReplace = '';
                             if (Phpfox::getParam('core.url_rewrite') == '1') {
                                 $sMobileReplace = str_replace(Phpfox::getParam('core.path'), Phpfox::getParam('core.path') . 'mobile/', $sCanonical);
                             } elseif (Phpfox::getParam('core.url_rewrite') == '2') {
                                 $sMobileReplace = str_replace('?' . PHPFOX_GET_METHOD . '=/', '?' . PHPFOX_GET_METHOD . '=/mobile/', $sCanonical);
                             }
                             $sData .= "\t\t<link rel=\"alternate\" media=\"only screen and (max-width: 640px)\" href=\"{$sMobileReplace}\" />\n";
                         }
                         break;
                     default:
                         $sData .= "\t\t<meta property=\"{$sMeta}\" content=\"{$sMetaValue}\" />\n";
                         break;
                 }
             } else {
                 if (strpos($sData, 'meta name="' . $sMeta . '"') !== false) {
                     $sData = preg_replace("/<meta name=\"{$sMeta}\" content=\"(.*?)\" \\/>\n\t/i", "<meta" . ($sMeta == 'description' ? ' property="og:description" ' : '') . " name=\"{$sMeta}\" content=\"" . $sMetaValue . "\" />\n\t", $sData);
                 } else {
                     $sData = preg_replace('/<meta/', '<meta name="' . $sMeta . '" content="' . $sMetaValue . '" />' . "\n\t\t" . '<meta', $sData, 1);
                 }
             }
         }
         if (!$bHasNoDescription) {
             $sData .= "\t\t" . '<meta name="description" content="' . Phpfox::getLib('parse.output')->clean(Phpfox_Locale::instance()->convert(Phpfox::getParam('core.description'))) . '" />' . "\n";
         }
     }
     // Clear from memory
     $this->_aHeaders = array();
     $this->_aMeta = array();
     return $sData;
 }
Ejemplo n.º 7
0
 /**
  * Quick function that can be used to identify if a user is logged it or not and if not
  * they will not be able to use the specific feature and display a login form.
  *
  * @return mixed Returns true if they are logged in or simply exisits the script and returns JavaScript to display the login form.
  */
 public function isUser()
 {
     if (!Phpfox::isUser()) {
         if (isset(self::$_aParams['width'])) {
             echo '<script type="text/javascript">$(\'.js_box_title\').html(\'' . Phpfox::getPhrase('user.login_ajax') . '\');</script>';
             Phpfox::getBlock('user.login-ajax');
         } else {
             if (Phpfox_Request::instance()->get('do') != '') {
                 Phpfox::getLib('session')->set('redirect', Phpfox_Request::instance()->get('do'));
             }
             echo "tb_show('" . Phpfox::getPhrase('user.login_title') . "', \$.ajaxBox('user.login', 'height=250&width=400" . (isset(self::$_aParams[Phpfox::getTokenName()]['is_admincp']) && self::$_aParams[Phpfox::getTokenName()]['is_admincp'] ? '&' . Phpfox::getTokenName() . '[is_admincp]=1' : '') . "'));";
             echo "\$('body').css('cursor', 'auto');";
         }
         exit;
     }
     return true;
 }
Ejemplo n.º 8
0
    /** 
     * Returns paging info: 'totalPages', 'totalRows', 'current', 'fromRow','toRow', 'firstUrl', 'prevUrl', 'nextUrl', 'lastUrl',  'urls' (url=>page)
     * 
     * @param Url $oUrl page url
     * @return array paging info
     */
    private function _getInfo()
    {
        $sParams = '';
        if (count($this->_aParams))
        {
	        foreach ($this->_aParams as $iKey => $sValue)
	        {
	        	if (in_array($iKey, array(
	        				'phpfox',
	        				Phpfox::getTokenName(),
	        				'page',
	        				PHPFOX_GET_METHOD,
	        				'ajax_page_display'
	        			)
	        		)
	        	)
	        	{
	        		continue;
	        	}
	        	
	        	$sParams .= '&amp;' . $iKey . '=' . $sValue;
	        }        
        }

    	$aInfo = array(
            'totalPages' => $this->_iPagesCount,
            'totalRows'  => $this->_iCnt,
            'current'    => $this->_iPage,
            'fromRow'    => $this->_iFirstRow+1,
            'toRow'      => $this->_iLastRow,
            'displaying' => ($this->_iCnt <= ($this->_iPageSize * $this->_iPage) ? $this->_iCnt : ($this->_iPageSize * $this->_iPage)),
            'sParams' => $sParams,
            'phrase' => $this->_sPhrase,
            'icon' => $this->_sIcon
        );        

        list($nStart, $nEnd) = $this->_getPos();        
        
        $oUrl = Phpfox::getLib('url');
        $oUrl->clearParam('page');
        
        if ($this->_iPage != 1)
        {
        	$oUrl->setParam($this->_sUrlKey, 1);
        	$aInfo['firstAjaxUrl'] = 1;
        	$aInfo['firstUrl'] = $oUrl->getFullUrl();
    
        	$oUrl->setParam($this->_sUrlKey, $this->_iPage-1);
        	$aInfo['prevAjaxUrl'] = ($this->_iPage-1);
            $aInfo['prevUrl'] = $oUrl->getFullUrl();        	
        }        
       
        for ($i = $nStart; $i <= $nEnd; $i++)
        {
            if ($this->_iPage == $i)
            {
                $oUrl->setParam($this->_sUrlKey, $i); 
            	$aInfo['urls'][$oUrl->getFullUrl()] = $i;
            }
            else
            {
            	$oUrl->setParam($this->_sUrlKey, $i);            	
            	$aInfo['urls'][$oUrl->getFullUrl()] = $i;
            }
        }
        
        $oUrl->setParam($this->_sUrlKey, ($this->_iPage + 1));  
        $aInfo['nextAjaxUrlPager'] = $oUrl->getFullUrl();  
        
        if ($this->_iPagesCount != $this->_iPage)
        {
       		$oUrl->setParam($this->_sUrlKey, ($this->_iPage + 1));       		
       		$aInfo['nextAjaxUrl'] = ($this->_iPage + 1);       		
       		$aInfo['nextUrl'] = $oUrl->getFullUrl();             
       		
            $oUrl->setParam($this->_sUrlKey, $this->_iPagesCount);
            $aInfo['lastUrl']= $oUrl->getFullUrl();       		
            $aInfo['lastAjaxUrl'] = $this->_iPagesCount;
        }        

        Phpfox::getLib('template')->assign(array(
        		'aPager' => $aInfo,
        		'sAjax' => $this->_sAjax
        	)
        );
    }	
Ejemplo n.º 9
0
 public function globalSearch($sQuery, $bIsTagSearch = false)
 {
     ($sPlugin = Phpfox_Plugin::get('blog.component_service_callback_globalsearch__start')) ? eval($sPlugin) : false;
     $sCondition = 'b.is_approved = 1 AND b.privacy = 1 AND b.post_status = 1';
     if ($bIsTagSearch == false) {
         $sCondition .= ' AND (b.title LIKE \'%' . $this->database()->escape($sQuery) . '%\' OR bt.text_parsed LIKE \'%' . $this->database()->escape($sQuery) . '%\')';
     }
     if ($bIsTagSearch == true) {
         $this->database()->innerJoin(Phpfox::getT('tag'), 'tag', 'tag.item_id = b.blog_id AND tag.category_id = \'blog\' AND tag.tag_url = \'' . $this->database()->escape($sQuery) . '\'');
     }
     $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'b')->join(Phpfox::getT('blog_text'), 'bt', 'bt.blog_id = b.blog_id')->where($sCondition)->execute('getSlaveField');
     if ($bIsTagSearch == true) {
         $this->database()->innerJoin(Phpfox::getT('tag'), 'tag', 'tag.item_id = b.blog_id AND tag.category_id = \'blog\' AND tag.tag_url = \'' . $this->database()->escape($sQuery) . '\'')->group('b.blog_id');
     }
     $aRows = $this->database()->select('b.title, b.title_url, b.time_stamp, ' . Phpfox::getUserField())->from($this->_sTable, 'b')->join(Phpfox::getT('blog_text'), 'bt', 'bt.blog_id = b.blog_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = b.user_id')->where($sCondition)->limit(10)->order('b.time_stamp DESC')->execute('getSlaveRows');
     if (count($aRows)) {
         $aResults = array();
         $aResults['total'] = $iCnt;
         $aResults['menu'] = Phpfox::getPhrase('blog.search_blogs');
         if ($bIsTagSearch == true) {
             $aResults['form'] = '<div><input type="button" value="' . Phpfox::getPhrase('blog.view_more_blogs') . '" class="search_button" onclick="window.location.href = \'' . Phpfox_Url::instance()->makeUrl('blog', array('tag', $sQuery)) . '\';" /></div>';
         } else {
             $aResults['form'] = '<form method="post" action="' . Phpfox_Url::instance()->makeUrl('blog') . '"><div><input type="hidden" name="' . Phpfox::getTokenName() . '[security_token]" value="' . Phpfox::getService('log.session')->getToken() . '" /></div><div><input name="search[search]" value="' . Phpfox::getLib('parse.output')->clean($sQuery) . '" size="20" type="hidden" /></div><div><input type="submit" name="search[submit]" value="' . Phpfox::getPhrase('blog.view_more_blogs') . '" class="search_button" /></div></form>';
         }
         foreach ($aRows as $iKey => $aRow) {
             $aResults['results'][$iKey] = array('title' => $aRow['title'], 'link' => Phpfox_Url::instance()->makeUrl($aRow['user_name'], array('blog', $aRow['title_url'])), 'image' => Phpfox::getLib('image.helper')->display(array('server_id' => $aRow['server_id'], 'title' => $aRow['full_name'], 'path' => 'core.url_user', 'file' => $aRow['user_image'], 'suffix' => '_120', 'max_width' => 75, 'max_height' => 75)), 'extra_info' => Phpfox::getPhrase('blog.blog_created_on_time_stamp_by_full_name', array('link' => Phpfox_Url::instance()->makeUrl('blog'), 'time_stamp' => Phpfox::getTime(Phpfox::getParam('core.global_update_time'), $aRow['time_stamp']), 'user_link' => Phpfox_Url::instance()->makeUrl($aRow['user_name']), 'full_name' => $aRow['full_name'])));
         }
         ($sPlugin = Phpfox_Plugin::get('blog.component_service_callback_globalsearch__return')) ? eval($sPlugin) : false;
         return $aResults;
     }
     ($sPlugin = Phpfox_Plugin::get('blog.component_service_callback_globalsearch__end')) ? eval($sPlugin) : false;
 }
Ejemplo n.º 10
0
 /**
  * Gets any data we plan to place within the HTML tags <head></head>.
  * This method also groups the data to give the template a nice clean look.
  *
  * @return string $sData Returns the HTML data to be placed within <head></head>
  */
 public function getHeader($bReturnArray = false)
 {
     if (Phpfox::isMobile()) {
         $this->setHeader(array('mobile.css' => 'style_css'));
     }
     if (!defined('PHPFOX_INSTALLER')) {
         $this->setHeader(array('custom.css' => 'style_css'));
         $aLocale = Phpfox::getLib('locale')->getLang();
         if ($aLocale['direction'] == 'rtl') {
             $this->setHeader(array('rtl.css' => 'style_css'));
         }
         $sCustomCss = '';
         $aThemeCache = $this->getThemeCache();
         if (isset($aThemeCache['l_width']) && $aThemeCache['l_width'] > 0) {
             $sCustomCss .= '#left { width:' . (int) $aThemeCache['l_width'] . 'px; }';
             $sCustomCss .= '#main_content { margin-left:' . (int) $aThemeCache['l_width'] . 'px; }';
         }
         if (isset($aThemeCache['c_width']) && $aThemeCache['c_width'] > 0) {
             $sCustomCss .= '.content3, .item_view .js_feed_comment_border, .item_view .item_tag_holder, .item_view .attachment_holder_view { width:' . (int) $aThemeCache['c_width'] . 'px; }';
         }
         if (isset($aThemeCache['r_width']) && $aThemeCache['r_width'] > 0) {
             $sCustomCss .= '#right { width:' . (int) $aThemeCache['r_width'] . 'px; }';
             $sCustomCss .= '.content4 { width:' . (960 - (int) $aThemeCache['r_width']) . 'px; }';
         }
         if (!empty($sCustomCss)) {
             $this->setHeader('<style type="text/css">' . $sCustomCss . '</style>');
         }
     }
     $aArrayData = array();
     $sData = '';
     $sCss = '';
     $sJs = '';
     $iVersion = $this->getStaticVersion();
     $oUrl = Phpfox::getLib('url');
     if (defined('PHPFOX_IS_HOSTED_SCRIPT')) {
         $oCache = Phpfox::getLib('cache');
     } else {
         $oCache = Phpfox::getLib('cache', array('storage' => 'file', 'free' => true));
     }
     $aUrl = $oUrl->getParams();
     if (Phpfox::getUserParam('core.can_design_dnd') && Phpfox::getService('theme')->isInDnDMode() && (!isset($aUrl['req2']) || $aUrl['req2'] != 'designer')) {
         if (!defined('PHPFOX_DESIGN_DND')) {
             define('PHPFOX_DESIGN_DND', true);
         }
         /* .
          * Tells if the user is Design mode with Drag and Drop support.
          * Its important to note the difference in the purpose of this
          * constant as it does Not tell if the user CAN enter DesignDND 
          * mode but instead it tells if the user IS already in this 
          * mode
          * .
          */
         $this->_aHeaders[] = array('designdnd.js' => 'module_theme');
     } else {
         if (!defined('PHPFOX_DESIGN_DND')) {
             define('PHPFOX_DESIGN_DND', false);
         }
     }
     if (!PHPFOX_IS_AJAX_PAGE) {
         if (!defined('PHPFOX_INSTALLER')) {
             if (!Phpfox::isAdminPanel()) {
                 $oDb = Phpfox::getLib('database');
                 $oFileCache = Phpfox::getLib('cache');
                 $sFileThemeCssId = $oFileCache->set(array('theme', 'theme_css' . $iVersion));
                 $aCacheStyles = array();
                 if (!($aCacheStyles = $oFileCache->get($sFileThemeCssId))) {
                     $aSavedStyles = $oDb->select('tc.module_id, tc.file_name')->from(Phpfox::getT('theme_css'), 'tc')->where('style_id = ' . (int) $this->_aTheme['style_id'] . '')->execute('getRows');
                     foreach ($aSavedStyles as $aSavedStyle) {
                         $aCacheStyles[$aSavedStyle['module_id'] ? $aSavedStyle['module_id'] : null][$aSavedStyle['file_name']] = true;
                     }
                     $oFileCache->save($sFileThemeCssId, $aCacheStyles);
                 }
             }
         }
         ($sPlugin = Phpfox_Plugin::get('template_getheader')) ? eval($sPlugin) : false;
         $sJs .= "\t\t\tvar oCore = {'core.is_admincp': " . (Phpfox::isAdminPanel() ? 'true' : 'false') . ", 'core.section_module': '" . Phpfox::getLib('module')->getModuleName() . "', 'profile.is_user_profile': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? 'true' : 'false') . ", 'log.security_token': '" . Phpfox::getService('log.session')->getToken() . "', 'core.url_rewrite': '" . Phpfox::getParam('core.url_rewrite') . "', 'core.country_iso': '" . (Phpfox::isUser() ? Phpfox::getUserBy('country_iso') : '') . "', 'core.can_move_on_a_y_and_x_axis' : " . (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.can_move_on_a_y_and_x_axis') ? 'true' : 'false') . ", 'core.default_currency': '" . (defined('PHPFOX_INSTALLER') ? 'USD' : Phpfox::getService('core.currency')->getDefault()) . "', 'core.enabled_edit_area': " . (Phpfox::getParam('core.enabled_edit_area') ? 'true' : 'false') . ", 'core.disable_hash_bang_support': " . (Phpfox::getParam('core.disable_hash_bang_support') ? 'true' : 'false') . ", 'core.site_wide_ajax_browsing': " . (!defined('PHPFOX_IN_DESIGN_MODE') && Phpfox::getParam('core.site_wide_ajax_browsing') && !Phpfox::isAdminPanel() && Phpfox::isUser() ? 'true' : 'false') . ", 'profile.user_id': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? Phpfox::getService('profile')->getProfileUserId() : 0) . "};\n";
         // You are filtering out the controllers which should not load 'content' ajaxly, finding a way for pages.view/1/info and like that
         $sProgressCssFile = $this->getStyle('css', 'progress.css');
         $sStylePath = str_replace(Phpfox::getParam('core.path'), '', str_replace('progress.css', '', $sProgressCssFile));
         $aJsVars = array('sJsHome' => Phpfox::getParam('core.path'), 'sJsHostname' => $_SERVER['HTTP_HOST'], 'sSiteName' => Phpfox::getParam('core.site_title'), 'sJsStatic' => $oUrl->getDomain() . PHPFOX_STATIC, 'sJsStaticImage' => Phpfox::getParam('core.url_static_image'), 'sImagePath' => $this->getStyle('image'), 'sStylePath' => $this->getStyle('css'), 'sVersion' => Phpfox::getId(), 'sJsAjax' => $oUrl->getDomain() . PHPFOX_STATIC . 'ajax.php', 'sStaticVersion' => $iVersion, 'sGetMethod' => PHPFOX_GET_METHOD, 'sDateFormat' => defined('PHPFOX_INSTALLER') ? '' : Phpfox::getParam('core.date_field_order'), 'sJsAjax' => $oUrl->getDomain() . PHPFOX_STATIC . 'ajax.php', 'sEgiftStyle' => $this->getStyle('css', 'display.css', 'egift'), 'sGlobalTokenName' => Phpfox::getTokenName(), 'sController' => Phpfox::getLib('module')->getFullControllerName(), 'bJsIsMobile' => Phpfox::isMobile() ? true : false, 'sProgressCssFile' => $sProgressCssFile, 'sHostedVersionId' => defined('PHPFOX_IS_HOSTED_VERSION') ? PHPFOX_IS_HOSTED_VERSION : '');
         if (!defined('PHPFOX_INSTALLER')) {
             $aJsVars['bWysiwyg'] = Phpfox::getParam('core.wysiwyg') != 'default' && Phpfox::getParam('core.allow_html') ? true : false;
             $aJsVars['sEditor'] = Phpfox::getParam('core.wysiwyg');
             $aJsVars['sJsCookiePath'] = Phpfox::getParam('core.cookie_path');
             $aJsVars['sJsCookieDomain'] = Phpfox::getParam('core.cookie_domain');
             $aJsVars['sJsCookiePrefix'] = Phpfox::getParam('core.session_prefix');
             $aJsVars['bPhotoTheaterMode'] = Phpfox::isModule('photo') ? Phpfox::getParam('photo.view_photos_in_theater_mode') : false;
             $aJsVars['bUseHTML5Video'] = Phpfox::getParam('video.upload_for_html5') ? true : false;
             if (Phpfox::isAdmin()) {
                 $aJsVars['sAdminCPLocation'] = Phpfox::getParam('admincp.admin_cp');
             } else {
                 $aJsVars['sAdminCPLocation'] = '';
             }
             if (Phpfox::isModule('notification')) {
                 $aJsVars['notification.notify_ajax_refresh'] = Phpfox::getParam('notification.notify_ajax_refresh');
             }
             if (Phpfox::isModule('im')) {
                 if (Phpfox::isUser()) {
                     $aJsVars['im_beep'] = Phpfox::getUserBy('im_beep');
                 }
                 $this->setHeader(array('player/' . Phpfox::getParam('core.default_music_player') . '/core.js' => 'static_script'));
                 $aJsVars['im_interval_for_update'] = Phpfox::getParam('im.js_interval_value');
                 if (Phpfox::getParam('im.server_for_ajax_calls') != '') {
                     $aJsVars['im_server'] = Phpfox::getParam('im.server_for_ajax_calls');
                 }
             } elseif (Phpfox::isModule('video')) {
                 $this->setHeader(array('player/' . Phpfox::getParam('core.default_music_player') . '/core.js' => 'static_script'));
             }
             $sLocalDatepicker = PHPFOX_STATIC . 'jscript/jquery/locale/jquery.ui.datepicker-' . strtolower(Phpfox::getLib('locale')->getLangId()) . '.js';
             if (file_exists($sLocalDatepicker)) {
                 $sFile = str_replace(PHPFOX_STATIC . 'jscript/', '', $sLocalDatepicker);
                 $this->setHeader(array($sFile => 'static_script'));
             }
             /* Only in a few cases will we want to add the visitor's IP */
             if (Phpfox::getParam('core.google_api_key') != '' && Phpfox::getParam('core.ip_infodb_api_key')) {
                 // $aJsVars['sIP'] = Phpfox::getLib('request')->getIp();
             }
             $aJsVars['bEnableMicroblogSite'] = Phpfox::isModule('microblog') ? Phpfox::getParam('microblog.enable_microblog_site') : false;
         }
         ($sPlugin = Phpfox_Plugin::get('template_getheader_setting')) ? eval($sPlugin) : false;
         if (Phpfox::isModule('input') && false) {
             $this->setHeader('cache', array('browse.css' => 'style_css'));
         }
         $sJs .= "\t\t\tvar oParams = {";
         $iCnt = 0;
         foreach ($aJsVars as $sVar => $sValue) {
             $iCnt++;
             if ($iCnt != 1) {
                 $sJs .= ",";
             }
             if (is_bool($sValue)) {
                 $sJs .= "'{$sVar}': " . ($sValue ? 'true' : 'false');
             } elseif (is_numeric($sValue)) {
                 $sJs .= "'{$sVar}': " . $sValue;
             } else {
                 $sJs .= "'{$sVar}': '" . str_replace("'", "\\'", $sValue) . "'";
             }
         }
         $sJs .= "};\n";
         if (!defined('PHPFOX_INSTALLER')) {
             $aLocaleVars = array('core.are_you_sure', 'core.yes', 'core.no', 'core.save', 'core.cancel', 'core.go_advanced', 'core.processing', 'emoticon.emoticons', 'attachment.attach_files', 'core.close', 'core.language_packages', 'core.move_this_block', 'core.uploading', 'language.loading', 'core.saving', 'core.loading_text_editor', 'core.quote', 'core.loading');
             if (Phpfox::isModule('im') && Phpfox::getParam('im.enable_im_in_footer_bar')) {
                 $aLocaleVars[] = 'im.find_your_friends';
             }
             ($sPlugin = Phpfox_Plugin::get('template_getheader_language')) ? eval($sPlugin) : false;
             $sJs .= "\t\t\tvar oTranslations = {";
             $iCnt = 0;
             foreach ($aLocaleVars as $sValue) {
                 $aParts = explode('.', $sValue);
                 if ($aParts[0] != 'core' && !Phpfox::isModule($aParts[0])) {
                     continue;
                 }
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sValue}': '" . html_entity_decode(str_replace("'", "\\'", Phpfox::getPhrase($sValue)), null, 'UTF-8') . "'";
             }
             $sJs .= "};\n";
             $aModules = Phpfox::getLib('module')->getModules();
             $sJs .= "\t\t\tvar oModules = {";
             $iCnt = 0;
             foreach ($aModules as $sModule => $iModuleId) {
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sModule}': true";
             }
             $sJs .= "};\n";
         }
         if (count($this->_aImages)) {
             $sJs .= "\t\t\tvar oJsImages = {";
             foreach ($this->_aImages as $sKey => $sImage) {
                 $sJs .= $sKey . ': \'' . $sImage . '\',';
             }
             $sJs = rtrim($sJs, ',');
             $sJs .= "};\n";
         }
         /*
         if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active'])
         {
         */
         $aEditorButtons = Phpfox::getLib('editor')->getButtons();
         $iCnt = 0;
         $sJs .= "\t\t\tvar oEditor = {";
         if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active']) {
             foreach ($this->_aEditor as $sVar => $mValue) {
                 $iCnt++;
                 if ($iCnt != 1) {
                     $sJs .= ",";
                 }
                 $sJs .= "'{$sVar}': " . (is_bool($mValue) ? $mValue === true ? 'true' : 'false' : "'{$mValue}'") . "";
             }
             $sJs .= ", ";
         }
         $sJs .= "images:[";
         foreach ($aEditorButtons as $mEditorButtonKey => $aEditorButton) {
             $sJs .= "{";
             foreach ($aEditorButton as $sEditorButtonKey => $sEditorButtonValue) {
                 $sJs .= "" . $sEditorButtonKey . ": '" . $sEditorButtonValue . "',";
             }
             $sJs = rtrim($sJs, ',') . "},";
         }
         $sJs = rtrim($sJs, ',') . "]";
         $sJs .= "};\n";
         // }
         if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn')) {
             $sData .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/' . Phpfox::getParam('core.jquery_google_cdn_version') . '/jquery.min.js"></script>' . "\n";
         }
     }
     if (PHPFOX_IS_AJAX_PAGE) {
         $this->_aCacheHeaders = array();
     }
     $bIsHttpsPage = false;
     if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.force_https_secure_pages')) {
         if (in_array(str_replace('mobile.', '', Phpfox::getLib('module')->getFullControllerName()), Phpfox::getService('core')->getSecurePages()) && (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
             $bIsHttpsPage = true;
         }
     }
     $aSubCache = array();
     $sStyleCacheData = '';
     $sJsCacheData = '';
     $aUrl = Phpfox::getLib('url')->getParams();
     // These two arrays hold the files to be combined+minified and put in CDN (if available)
     $aCacheJs = array();
     $aCacheCSS = array();
     $this->_sFooter = '';
     $sJs .= "\t\t\t" . 'var $Behavior = {};' . "\n";
     $sJs .= "\t\t\t" . 'var $Core = {};' . "\n";
     if (Phpfox::getParam('core.defer_loading_user_images') || Phpfox::getParam('core.defer_loading_images')) {
         $this->setHeader('cache', array('defer_image.js' => 'module_core'));
     }
     if (Phpfox::getParam('core.include_master_files')) {
         $aMasterJS = array();
         $aMasterCSS = array();
     }
     $aCustomCssFile = array();
     foreach ($this->_aHeaders as $aHeaders) {
         if (!is_array($aHeaders)) {
             $aHeaders = array($aHeaders);
         }
         foreach ($aHeaders as $mKey => $mValue) {
             $sQmark = strpos($mKey, '?') ? '&amp;' : '?';
             if (is_numeric($mKey)) {
                 if ($mValue === null) {
                     continue;
                 }
                 if ($bReturnArray) {
                     $aArrayData[] = $mValue;
                 } else {
                     if (is_string($mValue) && (strpos($mValue, '.js') !== false || strpos($mValue, 'javascript') !== false)) {
                         if (strpos($mValue, 'RecaptchaOptions')) {
                             $sData .= "\t\t" . $mValue . "\n";
                         } else {
                             $this->_sFooter .= "\t\t" . $mValue;
                         }
                     } else {
                         if (is_string($mValue)) {
                             $sData .= "\t\t" . $mValue . "\n";
                         } else {
                             $sData .= "\t\t" . implode($mValue) . "\n";
                         }
                     }
                 }
             } else {
                 if ($mKey == 'master') {
                     $aMaster = array('css' => array(), 'jscript' => array());
                     foreach ($mValue as $sValKey => $sValVal) {
                         if (strpos($sValKey, '.css') !== false) {
                             if ($sValVal == 'style_css') {
                                 $aMaster['css'][] = 'theme' . PHPFOX_DS . 'frontend' . PHPFOX_DS . $this->getThemeFolder() . PHPFOX_DS . 'style' . PHPFOX_DS . $this->getStyleFolder() . PHPFOX_DS . 'css' . PHPFOX_DS . $sValKey;
                             } else {
                                 if (strpos($sValVal, 'module_') !== false) {
                                     $aMaster['css'][] = 'module' . PHPFOX_DS . str_replace('module_', '', $sValVal) . PHPFOX_DS . 'static' . PHPFOX_DS . 'css' . PHFPFOX_DS . $this->getThemeFolder() . PHPFOX_DS . $this->getStyleFolder() . PHPFOX_DS . $sValKey;
                                 }
                             }
                         } else {
                             if (strpos($sValKey, '.js') !== false) {
                                 if ($sValVal == 'static_script') {
                                     $aMaster['jscript'][] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $sValKey;
                                 } else {
                                     if (strpos($sValVal, 'module_') !== false) {
                                         $aMaster['jscript'][] = 'module' . PHPFOX_DS . str_replace('module_', '', $sValVal) . PHPFOX_DS . 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $sValKey;
                                     }
                                 }
                             }
                         }
                     }
                     unset($this->_aHeaders[$mKey]);
                     // just to avoid confusions
                     $this->_aHeaders['master'] = $aMaster;
                 } else {
                     $bToHead = false;
                     // This happens when the developer needs something to go to <head>
                     if (is_array($mValue)) {
                         $aKeyHead = array_keys($mValue);
                         $aKeyValue = array_values($mValue);
                         $bToHead = $mKey == 'head';
                         $mKey = array_pop($aKeyHead);
                         $mValue = array_pop($aKeyValue);
                     }
                     switch ($mValue) {
                         case 'style_script':
                             if (isset($aSubCache[$mKey][$mValue])) {
                                 continue;
                             }
                             if ($bReturnArray) {
                                 $aArrayData[] = $this->getStyle('jscript', $mKey);
                             } else {
                                 //$sJsCacheData .= str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey)) . ',';
                                 if ($bToHead == 'head') {
                                     $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey));
                                 } else {
                                     $aCacheJs[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey));
                                 }
                             }
                             break;
                         case 'style_css':
                             $bCustomStyle = false;
                             if (!defined('PHPFOX_INSTALLER') && !Phpfox::isAdminPanel()) {
                                 if (isset($aCacheStyles[null][$mKey])) {
                                     if (defined('PHPFOX_IS_HOSTED_SCRIPT')) {
                                         $sCssCustomCacheId = $oCache->set($this->_aTheme['style_id'] . '_custom_css_file');
                                     } else {
                                         if ($bIsHttpsPage) {
                                             $sCssCustomCacheId = $oCache->set(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_secure_' . $mKey);
                                         } else {
                                             $sCssCustomCacheId = $oCache->set(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey);
                                         }
                                     }
                                     if (!($aCss = defined('PHPFOX_IS_HOSTED_SCRIPT') ? $oCache->get($sCssCustomCacheId) : $oCache->isCached($sCssCustomCacheId))) {
                                         $oDb = Phpfox::getLib('database');
                                         $aCss = $oDb->select('tc.css_id, tc.css_data, tc.css_data_original')->from(Phpfox::getT('theme_css'), 'tc')->where('style_id = ' . (int) $this->_aTheme['style_id'] . ' AND file_name = \'' . $oDb->escape($mKey) . '\'')->execute('getRow');
                                         if (isset($aCss['css_id'])) {
                                             $oCache->save($sCssCustomCacheId, defined('PHPFOX_IS_HOSTED_SCRIPT') ? $aCss : Phpfox::getLib('file.minimize')->css($aCss['css_data']));
                                             $bCustomStyle = true;
                                         }
                                     } else {
                                         if (defined('PHPFOX_IS_HOSTED_SCRIPT') && isset($aCss['css_id'])) {
                                             $bCustomStyle = true;
                                         } else {
                                             if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey)) {
                                                 $bCustomStyle = true;
                                             }
                                         }
                                     }
                                 } else {
                                     if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey)) {
                                         $bCustomStyle = true;
                                     }
                                 }
                             }
                             if ($bCustomStyle === false) {
                                 if ($bReturnArray) {
                                     $aArrayData[] = $this->getStyle('css', $mKey);
                                 } else {
                                     $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey));
                                 }
                             } else {
                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT')) {
                                     $bLoadCustomThemeOverwrite = true;
                                 } else {
                                     if ($bReturnArray) {
                                         $aArrayData[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey;
                                     } else {
                                         if (isset($this->_aCacheHeaders[$mKey])) {
                                             // $sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . ',';
                                             $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . '';
                                         } else {
                                             if ($bIsHttpsPage) {
                                                 //$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_secure_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
                                                 $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_secure_' . $mKey;
                                             } else {
                                                 //$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
                                                 $aCustomCssFile[] = Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey;
                                             }
                                         }
                                     }
                                 }
                             }
                             break;
                         case 'static_script':
                             if (isset($aSubCache[$mKey][$mValue])) {
                                 continue;
                             }
                             if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn')) {
                                 if ($mKey == 'jquery/ui.js' || $mKey == 'jquery/jquery.js') {
                                     if ($mKey == 'jquery/ui.js') {
                                         $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/' . Phpfox::getParam('core.jquery_ui_google_cdn_version') . '/jquery-ui.min.js"></script>' . "\n";
                                     }
                                     continue;
                                 }
                             }
                             if ($bReturnArray) {
                                 $aArrayData[] = Phpfox::getParam('core.url_static_script') . $mKey;
                             } else {
                                 if (isset($this->_aCacheHeaders[$mKey])) {
                                     // $sJsCacheData .= $mKey . ',';
                                     if ($bToHead == 'head') {
                                         $aCacheCSS[] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $mKey;
                                     } else {
                                         $aCacheJs[] = 'static' . PHPFOX_DS . 'jscript' . PHPFOX_DS . $mKey;
                                     }
                                 } else {
                                     //$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static_script') . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                     if ($bToHead == 'head') {
                                         $aCacheCSS[] = 'static/jscript/' . $mKey;
                                     } else {
                                         $aCacheJs[] = 'static/jscript/' . $mKey;
                                     }
                                 }
                             }
                             break;
                         default:
                             if (preg_match('/module/i', $mValue)) {
                                 $aParts = explode('_', $mValue);
                                 if (isset($aParts[1]) && Phpfox::isModule($aParts[1])) {
                                     if (substr($mKey, -3) == '.js') {
                                         if ($bReturnArray) {
                                             $aArrayData[] = Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                         } else {
                                             if (isset($this->_aCacheHeaders[$mKey])) {
                                                 //$sJsCacheData .= 'module/' . $aParts[1] . '/static/jscript/' . $mKey . ',';
                                                 $aCacheJs[] = 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                             } else {
                                                 /*
                                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT'))
                                                 {
                                                 	$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getCdnPath() . 'module/' . $aParts[1] . '/static/jscript/' . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                                 }	
                                                 else
                                                 {
                                                 */
                                                 //$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                                                 $aCacheJs[] = 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
                                                 // }
                                             }
                                         }
                                     } elseif (substr($mKey, -4) == '.css') {
                                         $aCacheCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                         $bCustomStyle = false;
                                         if (!defined('PHPFOX_INSTALLER') && !Phpfox::isAdminPanel()) {
                                             if (isset($aCacheStyles[$aParts[1]][$mKey])) {
                                                 $sCssCustomCacheId = $oCache->set(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey);
                                                 if (!$oCache->isCached($sCssCustomCacheId)) {
                                                     $oDb = Phpfox::getLib('database');
                                                     $aCss = $oDb->select('tc.css_id, tc.css_data')->from(Phpfox::getT('theme_css'), 'tc')->where('module_id = \'' . $oDb->escape($aParts[1]) . '\' AND style_id = ' . (int) $this->_aTheme['style_id'] . ' AND file_name = \'' . $oDb->escape($mKey) . '\'')->execute('getRow');
                                                     if (isset($aCss['css_id'])) {
                                                         $oCache->save($sCssCustomCacheId, Phpfox::getLib('file.minimize')->css($aCss['css_data']));
                                                         $bCustomStyle = true;
                                                     }
                                                 } else {
                                                     if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey)) {
                                                         $bCustomStyle = true;
                                                     }
                                                 }
                                             } else {
                                                 if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey)) {
                                                     $bCustomStyle = true;
                                                 }
                                             }
                                         }
                                         if ($bCustomStyle === false) {
                                             if ($bReturnArray) {
                                                 //$aArrayData[] = $this->getStyle('css', $mKey, $aParts[1]);
                                                 $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                             } else {
                                                 /*
                                                 if (defined('PHPFOX_IS_HOSTED_SCRIPT'))
                                                 {
                                                     $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . str_replace(Phpfox::getParam('core.path'), Phpfox::getCdnPath(), $this->getStyle('css', $mKey, $aParts[1])) . $sQmark . 'v=' . $iVersion . '" />' . "\n";
                                                 }
                                                 else
                                                 {
                                                 */
                                                 $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1]));
                                                 // }
                                             }
                                         } else {
                                             //$sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey . ',';
                                             $aCachesCSS[] = str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey;
                                         }
                                     }
                                 }
                             }
                             break;
                     }
                     $aSubCache[$mKey][$mValue] = true;
                 }
             }
         }
     }
     $sCacheData = '';
     $sCacheData .= "\n\t\t<script type=\"text/javascript\">\n";
     $sCacheData .= $sJs;
     $sCacheData .= "\t\t</script>";
     if (!empty($sStyleCacheData)) {
         $sCacheData .= "\n\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=css&amp;s=' . $sStylePath . '&amp;f=' . rtrim($sStyleCacheData, ',') . '&amp;v=' . $iVersion . '" />';
     }
     if (!empty($sJsCacheData)) {
         $sCacheData .= "\n\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=js&amp;f=' . rtrim($sJsCacheData, ',') . '&amp;v=' . $iVersion . '"></script>';
     }
     if (Phpfox::getParam('core.include_master_files') && Phpfox::isAdminPanel() != true && isset($this->_aHeaders['master'])) {
         // $this->_aHeaders[master] is created in the foreach above and it takes the files listed in Phpfox::getMasterFiles
         $aMasterFiles = $this->_aHeaders['master'];
         require_once PHPFOX_DIR_LIB . 'jsmin/jsmin2.class.php';
         // if the file doesnt exist load the default ones
         if ($this->_sThemeFolder != 'default' || $this->_sStyleFolder != 'default') {
             foreach ($aMasterFiles['css'] as $iKey => $sFile) {
                 if (file_exists(PHPFOX_DIR . $sFile) != true) {
                     // include the default master file
                     $sFile = str_replace($this->getThemeFolder(), 'default', $sFile);
                     $sFile = str_replace($this->getStyleFolder(), 'default', $sFile);
                     $aMasterFiles['css'][$iKey] = $sFile;
                 }
             }
         }
         $sMasterCSSUrl = Phpfox::getLib('file.minimize')->minify($aMasterFiles['css'], $sQmark . 'v=' . $iVersion, false);
         $sCacheData .= "\n\t\t" . '<!-- CSS Master --> <link rel="stylesheet" type="text/css" href="' . $sMasterCSSUrl . '" />';
         $sMasterJSUrl = Phpfox::getLib('file.minimize')->minify($aMasterFiles['jscript'], $sQmark . 'v=' . $iVersion, true);
         $this->_sFooter .= "\n\t\t" . '<!-- JS Master --> <script type="text/javascript" src="' . $sMasterJSUrl . '"></script>';
     }
     if (!empty($sCacheData)) {
         $sData = preg_replace('/<link rel="shortcut icon" type="image\\/x-icon" href="(.*?)" \\/>/i', '<link rel="shortcut icon" type="image/x-icon" href="\\1" />' . $sCacheData, $sData);
     }
     if ($bReturnArray) {
         $sData = '';
     }
     $aCacheJs = array_unique($aCacheJs);
     if (Phpfox::getParam('core.cache_js_css')) {
         $aJqueryPlugins = array();
         foreach ($aCacheJs as $iKey => $sFile) {
             //  if ( (strpos($sFile, 'jquery') !== false) && (strpos($sFile, 'plugin') !== false) )
             if (strpos($sFile, 'jquery') !== false) {
                 // We minify JQuery plug-ins in their own file
                 $aJqueryPlugins[] = $sFile;
                 unset($aCacheJs[$iKey]);
             }
             if ($sFile == 'static/jscript/wysiwyg/tiny_mce/tiny_mce.js') {
                 $this->_sFooter .= "\n\t\t" . '<!-- TinyMCE --> <script type="text/javascript" src="' . Phpfox::getParam('core.path') . $sFile . '?v=' . $iVersion . '"></script>' . "";
                 unset($aCacheJs[$iKey]);
             }
         }
         require_once PHPFOX_DIR_LIB . 'jsmin/jsmin2.class.php';
         if (!empty($aJqueryPlugins)) {
             $sPluginsUrl = Phpfox::getLib('file.minimize')->minify($aJqueryPlugins, $sQmark . 'v=' . $iVersion, true);
             $this->_sFooter .= "\n\t\t" . '<!-- JQuery Plugins --> <script type="text/javascript" src="' . $sPluginsUrl . '"></script>' . "";
         }
         if (!empty($aCacheJs)) {
             $aCacheJs = array_unique($aCacheJs);
             $sJsUrl = Phpfox::getLib('file.minimize')->minify($aCacheJs, $sQmark . 'v=' . $iVersion, true, true);
             $this->_sFooter .= "\n\t\t" . '<!-- Minified --> <script type="text/javascript" src="' . $sJsUrl . '"></script>' . "";
         }
         if (!empty($aCacheCSS)) {
             $sCSSUrl = Phpfox::getLib('file.minimize')->minify($aCacheCSS, $sQmark . 'v=' . $iVersion, false);
             $sData .= "\n\t\t" . '<!-- Minified --> <link rel="stylesheet" type="text/css" href="' . $sCSSUrl . '" />' . "";
         }
         if (!empty($aCustomCssFile)) {
             foreach ($aCustomCssFile as $sCustomCssFile) {
                 $sData .= "\n\t\t" . '<!-- Custom --> <link rel="stylesheet" type="text/css" href="' . $sCustomCssFile . '" />' . "";
             }
         }
     } else {
         $aSubCacheCheck = array();
         foreach ($aCacheCSS as $sFile) {
             if (defined('PHPFOX_INSTALLER')) {
                 $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . $sFile . $sQmark . 'v=' . $iVersion . '" />' . "\n";
             } else {
                 if (isset($aSubCacheCheck[$sFile])) {
                     continue;
                 }
                 $aSubCacheCheck[$sFile] = true;
                 $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.path') . $sFile . $sQmark . 'v=' . $iVersion . '" />' . "\n";
             }
         }
         if (!empty($aCustomCssFile)) {
             foreach ($aCustomCssFile as $sCustomCssFile) {
                 $sData .= "\n\t\t" . '<!-- Custom --> <link rel="stylesheet" type="text/css" href="' . $sCustomCssFile . '" />' . "";
             }
         }
         if (Phpfox::getParam('core.defer_loading_js')) {
         } else {
             foreach ($aCacheJs as $sFile) {
                 if (defined('PHPFOX_INSTALLER')) {
                     $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="../' . $sFile . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                 } else {
                     $this->_sFooter .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.path') . $sFile . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
                 }
             }
         }
         if (!defined('PHPFOX_INSTALLER')) {
             $this->_sFooter .= "\t\t" . '<script type="text/javascript"> $Core.init(); </script>' . "\n";
         }
     }
     if (defined('PHPFOX_TEMPLATE_CSS_FILE')) {
         //$this->setHeader(PHPFOX_TEMPLATE_CSS_FILE);
         $sData .= PHPFOX_TEMPLATE_CSS_FILE;
     }
     // And in its own file custom.css maybe check if its not empty like when using the default theme
     /*
             $sCustomFile = 'theme/' . (Phpfox::isAdminPanel() ? 'adminpanel' : (Phpfox::isMobile() ? 'mobile' : 'frontend')) . '/' . $this->getThemeFolder() . '/style/' . $this->getStyleFolder() . '/css/custom.css';
             
             if (Phpfox::getParam('core.cache_js_css') && file_exists(PHPFOX_DIR . $sCustomFile) && filesize(PHPFOX_DIR . $sCustomFile) > 0)
             {
     	$sCustomUrl = Phpfox::getLib('file.minimize')->minify($sCustomFile, $sQmark . 'v=' . $iVersion, false);
     	$sData .= "\n\t\t" . '<!-- Custom --> <link rel="stylesheet" type="text/css" href="' . $sCustomUrl .'" />';
     }
     */
     if (count($this->_aPhrases)) {
         $sData .= "\n\t\t<script type=\"text/javascript\">\n\t\t";
         foreach ($this->_aPhrases as $sVar => $sPhrase) {
             $sPhrase = html_entity_decode($sPhrase, null, 'UTF-8');
             $sData .= "\t\t\toTranslations['{$sVar}'] = '" . str_replace("'", "\\'", $sPhrase) . "';\n";
         }
         $sData .= "\t\t</script>\n";
     }
     if ($bReturnArray) {
         $aArrayData[] = $sData;
         return $aArrayData;
     }
     // Convert meta data
     $bHasNoDescription = false;
     if (count($this->_aMeta) && !PHPFOX_IS_AJAX_PAGE && !defined('PHPFOX_INSTALLER')) {
         $oPhpfoxParseOutput = Phpfox::getLib('parse.output');
         $aFind = array('&lt;', '&gt;', '$');
         $aReplace = array('<', '>', '&36;');
         foreach ($this->_aMeta as $sMeta => $sMetaValue) {
             $sMetaValue = str_replace($aFind, $aReplace, $sMetaValue);
             $sMetaValue = strip_tags($sMetaValue);
             $sMetaValue = str_replace(array("\n", "\r"), "", $sMetaValue);
             $bIsCustomMeta = false;
             switch ($sMeta) {
                 case 'keywords':
                     $sKeywordSearch = Phpfox::getParam('core.words_remove_in_keywords');
                     if (!empty($sKeywordSearch)) {
                         $aKeywordsSearch = array_map('trim', explode(',', $sKeywordSearch));
                     }
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_keyword_limit'));
                     $sMetaValue = trim(rtrim(trim($sMetaValue), ','));
                     $aParts = explode(',', $sMetaValue);
                     $sMetaValue = '';
                     $aKeywordCache = array();
                     foreach ($aParts as $sPart) {
                         $sPart = trim($sPart);
                         if (isset($aKeywordCache[$sPart])) {
                             continue;
                         }
                         if (isset($aKeywordsSearch) && in_array(strtolower($sPart), array_map('strtolower', $aKeywordsSearch))) {
                             continue;
                         }
                         $sMetaValue .= $sPart . ', ';
                         $aKeywordCache[$sPart] = true;
                     }
                     $sMetaValue = rtrim(trim($sMetaValue), ',');
                     break;
                 case 'description':
                     $bHasNoDescription = true;
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
                     break;
                 case 'robots':
                     $bIsCustomMeta = false;
                     break;
                 default:
                     $bIsCustomMeta = true;
                     break;
             }
             $sMetaValue = str_replace('"', '\\"', $sMetaValue);
             $sMetaValue = Phpfox::getLib('locale')->convert($sMetaValue);
             $sMetaValue = html_entity_decode($sMetaValue, null, 'UTF-8');
             $sMetaValue = str_replace(array('<', '>'), '', $sMetaValue);
             if ($bIsCustomMeta) {
                 if ($sMeta == 'og:description') {
                     $sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
                 }
                 switch ($sMeta) {
                     case 'canonical':
                         $sCanonical = $sMetaValue;
                         $sCanonical = preg_replace('/\\/when\\_([a-zA-Z0-9\\-]+)\\//i', '/', $sCanonical);
                         $sCanonical = preg_replace('/\\/show\\_([a-zA-Z0-9\\-]+)\\//i', '/', $sCanonical);
                         $sCanonical = preg_replace('/\\/view\\_\\//i', '/', $sCanonical);
                         if (Phpfox::isMobile()) {
                             if (Phpfox::getParam('core.url_rewrite') == '1') {
                                 $sCanonical = str_replace(Phpfox::getParam('core.path') . 'mobile/', Phpfox::getParam('core.path'), $sMetaValue);
                             } elseif (Phpfox::getParam('core.url_rewrite') == '2') {
                                 $sCanonical = str_replace('?' . PHPFOX_GET_METHOD . '=/mobile/', '?' . PHPFOX_GET_METHOD . '=/', $sMetaValue);
                             }
                         }
                         $sData .= "\t\t<link rel=\"canonical\" href=\"{$sCanonical}\" />\n";
                         if (!Phpfox::isMobile()) {
                             $sMobileReplace = '';
                             if (Phpfox::getParam('core.url_rewrite') == '1') {
                                 $sMobileReplace = str_replace(Phpfox::getParam('core.path'), Phpfox::getParam('core.path') . 'mobile/', $sCanonical);
                             } elseif (Phpfox::getParam('core.url_rewrite') == '2') {
                                 $sMobileReplace = str_replace('?' . PHPFOX_GET_METHOD . '=/', '?' . PHPFOX_GET_METHOD . '=/mobile/', $sCanonical);
                             }
                             $sData .= "\t\t<link rel=\"alternate\" media=\"only screen and (max-width: 640px)\" href=\"{$sMobileReplace}\" />\n";
                         }
                         break;
                     default:
                         $sData .= "\t\t<meta property=\"{$sMeta}\" content=\"{$sMetaValue}\" />\n";
                         break;
                 }
             } else {
                 if (strpos($sData, 'meta name="' . $sMeta . '"') !== false) {
                     $sData = preg_replace("/<meta name=\"{$sMeta}\" content=\"(.*?)\" \\/>\n\t/i", "<meta" . ($sMeta == 'description' ? ' property="og:description" ' : '') . " name=\"{$sMeta}\" content=\"" . $sMetaValue . "\" />\n\t", $sData);
                 } else {
                     $sData = preg_replace('/<meta/', '<meta name="' . $sMeta . '" content="' . $sMetaValue . '" />' . "\n\t\t" . '<meta', $sData, 1);
                 }
             }
         }
         if (!$bHasNoDescription) {
             $sData .= "\t\t" . '<meta name="description" content="' . Phpfox::getLib('parse.output')->clean(Phpfox::getLib('locale')->convert(Phpfox::getParam('core.description'))) . '" />' . "\n";
         }
     }
     // Clear from memory
     $this->_aHeaders = array();
     $this->_aMeta = array();
     if (isset($bLoadCustomThemeOverwrite)) {
         $sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.rackspace_url') . 'file/static/' . $aCss['css_data_original'] . '" />' . "\n";
     }
     return $sData;
 }
Ejemplo n.º 11
0
 /**
  * Displays an image on the site based on params passed
  *
  * @param array $aParams Holds an ARRAY of params about the image
  * @return string Returns the HTML <image> or the full path to the image based on the params passed with the 1st argument
  */
 public function display($aParams, $bIsLoop = false)
 {
     static $aImages = array();
     // Create hash for cache
     $sHash = md5(serialize($aParams));
     // Return cached image
     if (isset($aImages[$sHash])) {
         return $aImages[$sHash];
     }
     $bIsServer = !empty($aParams['server_id']) ? true : false;
     if ($sPlugin = Phpfox_Plugin::get('image_helper_display_start')) {
         eval($sPlugin);
         if (isset($mReturnPlugin)) {
             return $mReturnPlugin;
         }
     }
     if (isset($aParams['theme'])) {
         $sSrc = Phpfox::getLib('template')->getStyle('image', $aParams['theme']);
         $sDirSrcTemp = str_replace(Phpfox::getParam('core.path'), PHPFOX_DIR, $sSrc);
         if (isset($aParams['default']) && !file_exists($sDirSrcTemp)) {
             $sSrc = Phpfox::getLib('template')->getStyle('image', $aParams['default']);
         }
     }
     if (isset($aParams['max_height']) && !is_numeric($aParams['max_height'])) {
         $aParams['max_height'] = Phpfox::getParam($aParams['max_height']);
     }
     if (isset($aParams['max_width']) && !is_numeric($aParams['max_width'])) {
         $aParams['max_width'] = Phpfox::getParam($aParams['max_width']);
     }
     // Check if this is a users profile image
     $bIsOnline = false;
     $bDefer = false;
     if (isset($aParams['user'])) {
         $bDefer = Phpfox::getParam('core.defer_loading_user_images');
         $sSuffix = '';
         if (isset($aParams['user_suffix'])) {
             $sSuffix = $aParams['user_suffix'];
         }
         $sOnline = '';
         if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.display_user_online_status') && isset($aParams['user']) && isset($aParams['user'][$sSuffix . 'is_invisible']) && !$aParams['user'][$sSuffix . 'is_invisible'] && isset($aParams['user'][$sSuffix . 'last_activity']) && $aParams['user'][$sSuffix . 'last_activity'] > PHPFOX_TIME - Phpfox::getParam('log.active_session') * 60 && !isset($aParams['no_online_status'])) {
             $bIsOnline = true;
         }
         // Create the local params
         $aParams['server_id'] = isset($aParams['user']['user_' . $sSuffix . 'server_id']) ? $aParams['user']['user_' . $sSuffix . 'server_id'] : (isset($aParams['user'][$sSuffix . 'server_id']) ? $aParams['user'][$sSuffix . 'server_id'] : '');
         $aParams['file'] = $aParams['user'][$sSuffix . 'user_image'];
         $aParams['path'] = 'core.url_user';
         $aParams['title'] = $bIsOnline ? Phpfox::getPhrase('core.full_name_is_online', array('full_name' => Phpfox::getLib('parse.output')->shorten($aParams['user'][$sSuffix . 'full_name'], Phpfox::getParam('user.maximum_length_for_full_name')))) : Phpfox::getLib('parse.output')->shorten($aParams['user'][$sSuffix . 'full_name'], Phpfox::getParam('user.maximum_length_for_full_name'));
         // Create the users link
         // $sLink = Phpfox::getLib('url')->makeUrl('profile', $aParams['user'][$sSuffix . 'user_name']);
         if (!empty($aParams['user']['profile_page_id']) && !empty($aParams['user']['page_id'])) {
             if (empty($aParams['user']['user_name'])) {
                 $sLink = Phpfox::getLib('url')->makeUrl('pages', $aParams['user']['page_id']);
             }
         } else {
             $sLink = Phpfox::getLib('url')->makeUrl('profile', $aParams['user'][$sSuffix . 'user_name']);
         }
         if (!empty($aParams['server_id'])) {
             $bIsServer = true;
         }
         if (Phpfox::getParam('user.prevent_profile_photo_cache') && isset($aParams['user'][$sSuffix . 'user_id']) && $aParams['user'][$sSuffix . 'user_id'] == Phpfox::getUserId()) {
             $aParams['time_stamp'] = true;
         }
     }
     $bIsValid = true;
     if (!isset($aParams['theme'])) {
         if (empty($aParams['file'])) {
             $iWidth = 80;
             $iHeight = 70;
             if (isset($aParams['path']) && $aParams['path'] == 'core.url_user' && !isset($aParams['is_page_image'])) {
                 static $aGenders = null;
                 if ($aGenders === null) {
                     $aGenders = array();
                     foreach ((array) Phpfox::getParam('core.global_genders') as $iKey => $aGender) {
                         if (isset($aGender[3])) {
                             $aGenders[$iKey] = $aGender[3];
                         }
                     }
                 }
                 $sGender = '';
                 if (isset($aParams['user']) && isset($aParams['user'][$sSuffix . 'gender'])) {
                     if (isset($aGenders[$aParams['user'][$sSuffix . 'gender']])) {
                         $sGender = $aGenders[$aParams['user'][$sSuffix . 'gender']] . '_';
                     }
                 }
                 $sImageSuffix = '';
                 if (!empty($aParams['suffix'])) {
                     $aParams['suffix'] = str_replace('_square', '', $aParams['suffix']);
                     $iHeight = ltrim($aParams['suffix'], '_');
                     $iWidth = ltrim($aParams['suffix'], '_');
                     if ((int) $iWidth >= 200) {
                         // $sSrc .= '_noimage';
                     } else {
                         $sImageSuffix = $aParams['suffix'];
                     }
                 }
                 $sSrc = Phpfox::getLib('template')->getStyle('image', 'noimage/' . $sGender . 'profile' . $sImageSuffix . '.png');
             } else {
                 $sSrc = Phpfox::getLib('template')->getStyle('image', 'noimage/item.png');
             }
             $bIsValid = false;
         } else {
             $aParams['file'] = preg_replace('/%[^s]/', '%%', $aParams['file']);
             $sSrc = Phpfox::getParam($aParams['path']) . sprintf($aParams['file'], isset($aParams['suffix']) ? $aParams['suffix'] : '');
         }
     }
     if (!defined('PHPFOX_INSTALLER') && !Phpfox::getParam('core.allow_cdn')) {
         $bIsServer = false;
     }
     if ($bIsServer === false && !file_exists(str_replace(Phpfox::getParam('core.path'), PHPFOX_DIR, $sSrc))) {
         ($sPlugin = Phpfox_Plugin::get('image_helper_display_notfound')) ? eval($sPlugin) : false;
         if (preg_match("/\\{file\\/videos\\/(.*)\\/(.*)\\.jpg\\}/i", $sSrc, $aMatches)) {
             $sSrc = Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]);
         }
         if ((preg_match('/file\\/pic\\/pages\\/\\[GROUP\\](.*)/i', $sSrc, $aMatches) || preg_match('/file\\/pic\\/user\\/\\[GROUP\\](.*)/i', $sSrc, $aMatches)) && isset($aMatches[1])) {
             $sSrc = Phpfox::getParam('core.path') . 'file/pic/group/' . $aMatches[1];
         }
         if (preg_match("/\\{file\\/pic\\/(.*)\\/(.*)\\.jpg\\}/i", $sSrc, $aMatches)) {
             switch ($aMatches[1]) {
                 case 'album':
                     $sSrc = Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]);
                     break;
                 case 'groups/gallery':
                     if (isset($aParams['max_width'])) {
                         if ($aParams['max_width'] >= 300) {
                             if (file_exists(PHPFOX_DIR . 'file' . PHPFOX_DS . 'pic' . PHPFOX_DS . 'groups' . PHPFOX_DS . 'gallery' . PHPFOX_DS . str_replace(array('{', '}'), '', $aMatches[2]) . '_view.jpg')) {
                                 $sSrc = Phpfox::getParam('core.path') . 'file/pic/groups/gallery/' . str_replace(array('{', '}'), '', $aMatches[2]) . '_view.jpg';
                             } else {
                                 $sSrc = Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]);
                             }
                         } elseif ($aParams['max_width'] <= 250) {
                             $sSrc = Phpfox::getParam('core.path') . 'file/pic/groups/gallery/thumb/' . str_replace(array('{', '}'), '', $aMatches[2]) . '.jpg';
                         }
                     } else {
                         $sSrc = Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]);
                     }
                     break;
                 case 'user':
                     if (preg_match('/(.*)_(.*?)_square/i', $aMatches[2])) {
                         $sSrc = Phpfox::getParam('core.path') . preg_replace('/(.*)_square/i', '\\1', str_replace(array('{', '}'), '', $aMatches[0]));
                     } else {
                         if (isset($aParams['max_width']) && $aParams['max_width'] > 120) {
                             $sSrc = Phpfox::getParam('core.path') . 'file/pic/user/' . preg_replace('/(.*)_(.*)/i', '\\1_120', str_replace(array('{', '}'), '', $aMatches[2])) . '.jpg';
                         } else {
                             $sSrc = Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]);
                         }
                     }
                     break;
                 case 'gallery':
                     if (isset($aParams['max_width'])) {
                         if ($aParams['max_width'] >= 300) {
                             if (!empty($aParams['suffix']) && file_exists(PHPFOX_DIR . str_replace(array('{', '.jpg}'), array('', $aParams['suffix'] . '.jpg'), $aMatches[0]))) {
                                 $sSrc = Phpfox::getParam('core.path') . str_replace(array('{', '.jpg}'), array('', $aParams['suffix'] . '.jpg'), $aMatches[0]);
                             } else {
                                 if (file_exists(PHPFOX_DIR . 'file' . PHPFOX_DS . 'pic' . PHPFOX_DS . 'gallery' . PHPFOX_DS . str_replace(array('{', '}'), '', $aMatches[2]) . '_view.jpg')) {
                                     $sSrc = Phpfox::getParam('core.path') . 'file/pic/gallery/' . str_replace(array('{', '}'), '', $aMatches[2]) . '_view.jpg';
                                 } else {
                                     $sSrc = Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]);
                                 }
                             }
                         } elseif ($aParams['max_width'] <= 250) {
                             if (!empty($aParams['suffix']) && file_exists(PHPFOX_DIR . str_replace(array('{', '.jpg}'), array('', $aParams['suffix'] . '.jpg'), $aMatches[0]))) {
                                 $sSrc = Phpfox::getParam('core.path') . str_replace(array('{', '.jpg}'), array('', $aParams['suffix'] . '.jpg'), $aMatches[0]);
                             } else {
                                 if (file_exists(PHPFOX_DIR . 'file/pic/gallery/thumb/' . str_replace(array('{', '}'), '', $aMatches[2]) . '.jpg')) {
                                     $sSrc = Phpfox::getParam('core.path') . 'file/pic/gallery/thumb/' . str_replace(array('{', '}'), '', $aMatches[2]) . '.jpg';
                                 } else {
                                     $sSrc = Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]);
                                 }
                             }
                         }
                     } else {
                         $sSrc = Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]);
                     }
                     break;
                 default:
                     break;
             }
         }
         $bForcePassImage = false;
         $sNewDirSrc = '';
         if (preg_match("/file\\/pic\\/photo\\//i", $sSrc)) {
             if (preg_match('/(.*)\\[PHPFOX_CUSTOM_URL\\](.*)\\-(.*)\\.(.*)/i', $sSrc, $aCustomMatches)) {
                 $sSrc = str_replace('[PHPFOX_CUSTOM_URL]', '', $sSrc);
                 // http://www.phpfox.com/tracker/view/15350/
                 if (Phpfox::getParam('photo.delete_original_after_resize')) {
                     $aSizes = Phpfox::getParam('photo.photo_pic_sizes');
                     $sSize = max($aSizes);
                     $sNewDirSrc = Phpfox::getParam('photo.dir_photo') . $aCustomMatches[2] . '_' . $sSize . '.' . $aCustomMatches[4];
                 } else {
                     $sNewDirSrc = Phpfox::getParam('photo.dir_photo') . $aCustomMatches[2] . '.' . $aCustomMatches[4];
                 }
                 $bForcePassImage = true;
             } else {
                 preg_match("/^(.*?)_(75|100|150|240|500|1024)\\.(.*?)\$/i", $sSrc, $aMatches);
                 if (isset($aMatches[2])) {
                     if (!in_array((int) $aMatches[2], Phpfox::getParam('photo.photo_pic_sizes'))) {
                         $aUserPicSizes = Phpfox::getParam('photo.photo_pic_sizes');
                         uasort($aUserPicSizes, array($this, '_cmp'));
                         if (isset($aUserPicSizes[0])) {
                             $sSrc = $aMatches[1] . '_' . $aUserPicSizes[0] . preg_replace("/([0-9])/i", "", $aMatches[2]) . '.' . $aMatches[3];
                         }
                     }
                 }
             }
         }
         if (preg_match('/\\{([0-9]+)\\}(.*)/i', $sSrc, $aCustomMatches)) {
             $bForcePassImage = true;
             $bIsServer = true;
             $sSrc = Phpfox::getService('video')->getCustomUrl($aCustomMatches[1]) . 'view/' . $aCustomMatches[2];
         }
         if (preg_match("/file\\/pic\\/user\\//i", $sSrc)) {
             preg_match("/^(.*)_(.*?)\\.(.*?)\$/i", $sSrc, $aMatches);
             if (isset($aMatches[2])) {
                 if ($aMatches[2] == 'square') {
                     $aSubParts = explode('_', $aMatches[1]);
                     $aMatches[2] = $aSubParts[1];
                 }
                 if (!in_array((int) $aMatches[2], Phpfox::getParam('user.user_pic_sizes'))) {
                     $aUserPicSizes = Phpfox::getParam('user.user_pic_sizes');
                     uasort($aUserPicSizes, array($this, '_cmp'));
                     if (isset($aUserPicSizes[0])) {
                         $sSrc = $aMatches[1] . '_' . $aUserPicSizes[0] . preg_replace("/([0-9])/i", "", $aMatches[2]) . '.' . $aMatches[3];
                     }
                 } else {
                     if (!file_exists(str_replace(Phpfox::getParam('core.path'), PHPFOX_DIR, $sSrc))) {
                         $sSrc = $aMatches[1] . '.' . $aMatches[3];
                     }
                 }
             }
         } else {
             if (preg_match("/^(.*)_square\\.(.*?)\$/i", $sSrc, $aMatches)) {
                 $sNewSrc = $aMatches[1] . '.' . $aMatches[2];
                 if (file_exists(str_replace(Phpfox::getParam('core.path'), PHPFOX_DIR, $sNewSrc))) {
                     $sSrc = $sNewSrc;
                 }
             }
         }
     }
     $sDirSrc = str_replace(Phpfox::getParam('core.path'), PHPFOX_DIR, $sSrc);
     if ($bIsServer === true) {
         if (Phpfox::getParam('core.allow_cdn')) {
             if (!$bIsValid) {
             } else {
                 $sSrc = Phpfox::getLib('cdn')->getUrl($sSrc, $aParams['server_id']);
             }
         } else {
             if (substr($aParams['file'], 0, 7) == 'http://') {
                 $sSrc = $aParams['file'];
             }
         }
     }
     if (!defined('PHPFOX_INSTALLER') && Phpfox::isModule('photo') && Phpfox::getParam('photo.protect_photos_from_public') && preg_match("/photo/i", $sDirSrc)) {
         $_SESSION[Phpfox::getTokenName()]['image']['photo_' . md5($sDirSrc)] = true;
     }
     if (isset($aParams['max_height']) && isset($aParams['max_width'])) {
         if ($bIsServer === true) {
             if (file_exists($sDirSrc) && !is_dir($sDirSrc)) {
                 list($iHeight, $iWidth) = $this->getNewSize($sDirSrc, $aParams['max_height'], $aParams['max_width']);
             } else {
                 preg_match('/(.*)\\/(.*)-(.*)-(.*)_(.*?)/i', $aParams['file'], $aLbMatches);
                 if (isset($aLbMatches[2]) && isset($aLbMatches[3])) {
                     list($iHeight, $iWidth) = $this->getNewSize(null, $aParams['max_height'], $aParams['max_width'], $aLbMatches[2], $aLbMatches[3]);
                 } else {
                     $bNoWidthHeightFound = true;
                 }
             }
         } else {
             if (isset($bForcePassImage) && $bForcePassImage === true) {
                 $sDirSrc = $sNewDirSrc;
             }
             if (file_exists($sDirSrc) && !is_dir($sDirSrc)) {
                 list($iHeight, $iWidth) = $this->getNewSize($sDirSrc, $aParams['max_height'], $aParams['max_width']);
             } else {
                 if (isset($aParams['no_default']) && $aParams['no_default']) {
                     return '';
                 }
                 $iWidth = $aParams['max_width'];
                 $iHeight = $aParams['max_height'];
                 if ($aParams['max_width'] > 120) {
                     $iWidth = 120;
                     $iHeight = 105;
                 }
                 $sSize = '';
                 if (strpos($sSrc, '_') && preg_match("/^(.*?)_(.*?)\\.(.*?)\$/i", $sSrc, $aMatches) && isset($aMatches[2]) && in_array($aMatches[2], array(20, 50, 60, 75, 100, 120))) {
                     $sSize = $aMatches[1] == 'thumb' || $aMatches[1] == 'view' ? '' : '_' . $aMatches[2];
                 }
                 if (isset($aParams['path']) && $aParams['path'] == 'core.url_user') {
                     if (Phpfox::getParam('user.cache_user_inner_joins') && !$bIsLoop && isset($sSuffix)) {
                         $aCachedUserInfo = Phpfox::getService('user')->getStaticInfo($aParams['user'][$sSuffix . 'user_id']);
                         if (!empty($aCachedUserInfo['user_image'])) {
                             $aParams['user'][$sSuffix . 'user_image'] = $aCachedUserInfo['user_image'];
                             return $this->display($aParams, true);
                         }
                     }
                     $sSrc = Phpfox::getLib('template')->getStyle('image', 'noimage/' . (empty($sGender) ? '' : $sGender) . 'profile' . $sSize . '.png');
                     preg_match("/^(.*?)_(.*?)\\.(.*?)\$/i", $sSrc, $aMatches);
                 } else {
                     $sSrc = Phpfox::getLib('template')->getStyle('image', 'noimage/item.png');
                 }
                 if (!empty($sSize)) {
                     $sSrc = preg_replace("/(.*?)_square\\.(.*?)/i", "\\1.\\2", $sSrc);
                     $sNoImageSrc = str_replace(Phpfox::getParam('core.path'), PHPFOX_DIR, $sSrc);
                     list($iHeight, $iWidth) = $this->getNewSize($sNoImageSrc, $aParams['max_height'], $aParams['max_width']);
                 }
             }
         }
         if (isset($aParams['href'])) {
             $sLink = $aParams['href'];
             // Check if image is a thumbnail or a general view image
             if (strpos($sSrc, '_thumb') || strpos($sSrc, '_view')) {
                 // Get the original image source
                 if ($bIsServer) {
                     $sOrigSrc = preg_replace("/(_thumb|_view)/i", "", $sSrc);
                     $sLink = $sOrigSrc;
                 } else {
                     $sOrigSrc = str_replace(array(Phpfox::getParam('core.path'), '/'), array('', PHPFOX_DS), PHPFOX_DIR . ltrim(preg_replace("/(_thumb|_view)/i", "", $sSrc), '/'));
                 }
                 // Get the original image width/height
                 list($iOrigWidth, $iOrigHeight) = getimagesize($sOrigSrc);
                 // If the width/height is less then the max width/height then we should not display the thickbox feature
                 if ($iOrigWidth < $aParams['max_width'] && $iOrigHeight < $aParams['max_height']) {
                     unset($sLink);
                 }
             }
         }
     }
     // Use thickbox effect?
     if (isset($aParams['thickbox'])) {
         // Remove the image suffix (eg _thumb.jpg, _view.jpg, _75.jpg etc...).
         if (preg_match('/female\\_noimage\\.png/i', $sSrc)) {
             $sLink = $sSrc;
         } elseif (preg_match('/^(.*)_(.*)_square\\.(.*)$/i', $sSrc, $aMatches)) {
             $sLink = $aMatches[1] . (isset($aParams['thickbox_suffix']) ? $aParams['thickbox_suffix'] : '') . '.' . $aMatches[3];
         } else {
             $sLink = preg_replace("/^(.*)_(.*)\\.(.*)\$/i", "\$1" . (isset($aParams['thickbox_suffix']) ? $aParams['thickbox_suffix'] : '') . ".\$3", $sSrc);
         }
     }
     if (isset($aParams['no_link']) && $aParams['no_link']) {
         unset($sLink);
     }
     // Windows slash fix
     $sSrc = str_replace("\\", '/', $sSrc);
     if (preg_match("/file\\/pic\\/photo\\//i", $sSrc)) {
         if (Phpfox::getParam('core.defer_loading_images')) {
             $bDefer = true;
         }
     }
     if (isset($aParams['return_url']) && $aParams['return_url']) {
         return $sSrc . (isset($aParams['time_stamp']) ? '?t=' . uniqid() : '');
     }
     if (isset($aParams['title'])) {
         $aParams['title'] = Phpfox::getLib('parse.output')->clean(html_entity_decode($aParams['title'], null, 'UTF-8'));
     }
     /*
     if (Phpfox::getParam('core.allow_cdn') && preg_match('/s3\.amazonaws\.com/i', $sSrc))
     {
     	$aParams['class'] = 'js_cdn_image' . (isset($aParams['class']) ? ' ' . $aParams['class'] : '') ;
     }
     */
     $sImage = '';
     $sAlt = '';
     if (isset($aParams['alt_phrase'])) {
         $sAlt = html_entity_decode(Phpfox::getPhrase($aParams['alt_phrase']), null, 'UTF-8');
         unset($aParams['alt_phrase']);
     }
     if (isset($aParams['class']) && $aParams['class'] == 'js_hover_title') {
         $aParams['title'] = Phpfox::getLib('parse.output')->shorten($aParams['title'], 100, '...');
     }
     if (isset($sLink)) {
         $sImage .= '<a href="' . $sLink;
         if (isset($aParams['thickbox']) && isset($aParams['time_stamp'])) {
             $sImage .= '?t=' . uniqid();
         }
         $sImage .= '"';
         if (isset($aParams['title'])) {
             $sImage .= ' title="' . htmlspecialchars($aParams['title']) . '"';
         }
         if (isset($aParams['thickbox'])) {
             $sImage .= ' class="thickbox"';
         }
         if (isset($aParams['target'])) {
             $sImage .= ' target="' . $aParams['target'] . '"';
         }
         $sImage .= '>';
     }
     if (PHPFOX_IS_AJAX) {
         $aAjaxCall = Phpfox::getLib('request')->get('core');
         if (isset($aAjaxCall['call']) && in_array($aAjaxCall['call'], array('core.loadDelayedBlocks'))) {
         } else {
             $bDefer = false;
         }
     }
     $sImage .= '<img';
     if ($bDefer == true) {
         $aParams['class'] = ' image_deferred ' . (isset($aParams['class']) ? ' ' . $aParams['class'] : '');
         $sImage .= ' data-src="' . $sSrc . (isset($aParams['time_stamp']) ? '?t=' . uniqid() : '') . '" src="' . Phpfox::getLib('template')->getStyle('image', 'misc/defer_holder.gif') . '" ';
     } else {
         $sImage .= ' src="' . $sSrc . (isset($aParams['time_stamp']) ? '?t=' . uniqid() : '') . '" ';
     }
     if (isset($aParams['title'])) {
         $sImage .= ' alt="' . htmlspecialchars($aParams['title']) . '" ';
     } else {
         $sImage .= ' alt="' . htmlspecialchars($sAlt) . '" ';
     }
     if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.display_user_online_status') && isset($aParams['user'])) {
         $sImage .= ' title="' . htmlspecialchars($aParams['title']) . '"';
     }
     if (isset($aParams['js_hover_title'])) {
         $sImage .= ' class="js_hover_title" ';
         unset($aParams['js_hover_title']);
     }
     if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('user.display_user_online_status') && isset($aParams['user']) && !isset($aParams['no_online_status'])) {
         $sImage .= ' class="' . ($bIsOnline ? 'image_online_status' : 'image_online') . (isset($aParams['class']) ? ' ' . $aParams['class'] : '') . '" ';
         unset($aParams['class']);
     }
     if (isset($aParams['force_max'])) {
         $iHeight = $aParams['max_height'];
         $iWidth = $aParams['max_width'];
     }
     if (!empty($iHeight)) {
         $sImage .= 'height="' . $iHeight . '" ';
     }
     if (!empty($iWidth)) {
         $sImage .= 'width="' . $iWidth . '" ';
     }
     if (isset($bNoWidthHeightFound)) {
         $sImage .= ' style="max-width:' . $aParams['max_width'] . 'px;max-height:' . $aParams['max_height'] . 'px;' . (isset($aParams['style']) ? $aParams['style'] : '') . '" ';
     }
     if (isset($aParams['force_max'])) {
         unset($aParams['force_max']);
     }
     unset($aParams['server_id'], $aParams['src'], $aParams['max_height'], $aParams['max_width'], $aParams['href'], $aParams['user_name'], $aParams['file'], $aParams['suffix'], $aParams['path'], $aParams['thickbox'], $aParams['no_default'], $aParams['full_name'], $aParams['user_id'], $aParams['time_stamp'], $aParams['user'], $aParams['title'], $aParams['theme'], $aParams['default'], $aParams['user_suffix'], $aParams['target'], $aParams['alt']);
     foreach ($aParams as $sKey => $sValue) {
         $sImage .= ' ' . $sKey . '="' . str_replace('"', '\\"', $sValue) . '" ';
     }
     $sImage .= '/>' . (isset($sLink) ? '</a>' : '');
     $aImages[$sHash] = $sImage;
     return $sImage;
 }
Ejemplo n.º 12
0
			
<?php 
        }
    }
    ?>
		</ul>
<?php 
}
?>
	<div class="clear"></div>
</div>	

<div class="activity_feed_form">
	<form method="post" action="#" id="js_activity_feed_form" enctype="multipart/form-data">
<?php 
echo '<div><input type="hidden" name="' . Phpfox::getTokenName() . '[security_token]" value="' . Phpfox::getService('log.session')->getToken() . '" /></div>';
?>
		<div id="js_custom_privacy_input_holder"></div>
<?php 
if (Phpfox::getParam('video.convert_servers_enable') && isset($this->_aVars['sCustomVideoHash'])) {
    ?>
			<div><input type="hidden" name="_v_hash" value="<?php 
    echo $this->_aVars['sCustomVideoHash'];
    ?>
" /></div>
<?php 
}
if (isset($this->_aVars['aFeedCallback']['module'])) {
    ?>
			<div><input type="hidden" name="val[callback_item_id]" value="<?php 
    echo $this->_aVars['aFeedCallback']['item_id'];
Ejemplo n.º 13
0
    public function run()
    {
        $oRequest = Phpfox::getLib('request');
        $db = PhpFox::getLib('database');
        // Limit per page, start offset at zero
        $iOffset = (int) $oRequest->get('offset', 0);
        $sAction = $oRequest->get('Confirm', 'Start');
        $iLimit = 500;
        $aPrivacySettings = array();
        //Set form token for version 3xx
        if ((int) substr(Phpfox::getVersion(), 0, 1) < 3) {
            $s1 = 'v2_no_token';
            $s2 = 'v2_no_token';
        } else {
            $s1 = Phpfox::getTokenName();
            $s2 = Phpfox::getService('log.session')->getToken();
        }
        // Run only if Userpresets Module is present
        if (!phpFox::isModule('Userpresets')) {
            die('User Preset addon must be present.');
        }
        // Set profile privacy based upon admincp setting
        switch (Phpfox::getParam('user.on_register_privacy_setting')) {
            case 'network':
                $aPrivacySettings['profile.view_profile'] = '1';
                break;
            case 'friends_only':
                $aPrivacySettings['profile.view_profile'] = '2';
                break;
            case 'no_one':
                $aPrivacySettings['profile.view_profile'] = '4';
                break;
            default:
                break;
        }
        // Get Userpreset parameters and build the privacy array
        $aSettings = Phpfox::getService('admincp.setting')->search("product_id = 'Preset_New_User'");
        foreach ($aSettings as $aSetting) {
            $aParts = explode('__', $aSetting['var_name']);
            if (phpFox::isModule($aParts[0])) {
                $sUserPrivacy = str_replace('__', '.', $aSetting['var_name']);
                $sGetParam = $aSetting['module_id'] . '.' . $aSetting['var_name'];
                if ($aSetting['type_id'] == 'drop') {
                    $iPrivacySetting = NULL;
                    $iPrivacySetting = Phpfox::getParam($sGetParam);
                    if (isset($iPrivacySetting) && (int) $iPrivacySetting > 0) {
                        $aPrivacySettings[$sUserPrivacy] = $iPrivacySetting;
                    }
                }
            }
        }
        if ($sAction == 'Start') {
            //add confirm form
            $iTotUsers = $db->select('COUNT(*)')->from(Phpfox::getT('user'))->where('view_id = 0')->execute('getField');
            $iTotPrivacy = $db->select('COUNT(*)')->from(Phpfox::getT('user_privacy'))->execute('getField');
            $iTotNewPrivacy = count($aPrivacySettings);
            $sWarn = 'This action will remove approximately ' . $iTotPrivacy . ' Records from ' . $iTotUsers . ' users from the user privacy table and 
				replace them with approximately ' . $iTotUsers * $iTotNewPrivacy . ' records.  The new settings will be taken from the parameters that 
				you have set in the New User Privacy Setting Module.  <br /><br />
				This will not affect the operation of PhpFox but it will nullify any privacy
				settings that your users have set in favor of the ones that you will be setting.
				<br /><br />Do you want to continue?';
            echo '
			<div style="width:500px;margin:0px auto;text-align:left;padding:15px;border:1px solid #333;background-color:#eee;">
			<div> ' . $sWarn . ' </div>
			<form method="POST" name="form" id="form" action="http://' . Phpfox::getParam('core.host') . '/tools/dbfixPRIVACY.php">
			<div><input type="hidden" name="' . $s1 . '[security_token]" value="' . $s2 . '" /></div>
			<div style="width:400px;margin:0px auto;text-align:right;padding:15px;background-color:#eee;">
			<input type=hidden name="offset" value="0">
			<input type="submit" name="Confirm" value="Continue" />
			<input type="submit" name="Confirm" value="Cancel" />
			</div>
			</form>
			</div>';
        }
        if ($sAction == 'Cancel') {
            die("No Records Changed");
        }
        // Empty privacy table at start of batch
        if ($sAction == 'Continue' && $iOffset == 0) {
            $db->query('TRUNCATE ' . Phpfox::getT('user_privacy'));
            echo 'Processing records from ' . $iOffset . ' to ' . ($iOffset + $iLimit) . '<br />';
        }
        if ($sAction == 'Continue') {
            // For each user
            $aRows = $this->database()->select('user_id')->from(Phpfox::getT('user'))->order('user_id')->where('view_id = 0')->limit($iOffset, $iLimit)->execute('getSlaveRows');
            $iCount = 0;
            foreach ($aRows as $row) {
                ++$iCount;
                $userid = $row['user_id'];
                $s = '';
                foreach ($aPrivacySettings as $k => $v) {
                    $s .= "({$userid}, '{$k}',{$v}),";
                }
                $s = 'INSERT INTO ' . Phpfox::getT('user_privacy') . " (`user_id`, `user_privacy`, `user_value`) VALUES" . substr($s, 0, -1);
                $db->query($s);
            }
            // Did do a full batch?
            if ($iCount == $iLimit) {
                // Get another batch
                $iOffset += $iLimit;
                echo 'Processing records from ' . $iOffset . ' to ' . ($iOffset + $iLimit) . '<br />';
                echo '
				<form method="POST" name="form2" id="form2" action="http://' . Phpfox::getParam('core.host') . '/tools/dbfixPRIVACY.php?offset=' . $iOffset . '">
				<div><input type="hidden" name="' . $s1 . '[security_token]" value="' . $s2 . '" /></div>
				<input type=hidden name="offset" value="' . $iOffset . '">
				<input type=hidden name="Confirm" value="Continue">
				</form>
				<script language=javascript>document.form2.submit();</script>
				';
                exit;
            }
            // count < limit we are done
            echo '<hr><h1>' . ($iCount + $iOffset) . ' Records Processed</h1>';
            return;
        }
    }
Ejemplo n.º 14
0
	/**
	 * Quick function that can be used to identify if a user is logged it or not and if not
	 * they will not be able to use the specific feature and display a login form.
	 *
	 * @return mixed Returns true if they are logged in or simply exisits the script and returns JavaScript to display the login form.
	 */
	public function isUser()
	{
		if (!Phpfox::isUser())
		{			
			if (isset(self::$_aParams['width'])) // && isset(self::$_aParams['height']))
			{
				// echo '<script type="text/javascript">$(\'#TB_ajaxContent\').height(210); tb_position(210); $(\'body\').css(\'cursor\', \'auto\');</script>';
				Phpfox::getBlock('user.login-ajax');	
			}
			else 
			{				
				if (Phpfox::getLib('request')->get('do') != '')
				{
					Phpfox::getLib('session')->set('redirect', Phpfox::getLib('request')->get('do'));
				}
				
				echo "tb_show('" . Phpfox::getPhrase('user.login_title') . "', \$.ajaxBox('user.login', 'height=250&width=400" . ((isset(self::$_aParams[Phpfox::getTokenName()]['is_admincp']) && self::$_aParams[Phpfox::getTokenName()]['is_admincp']) ? '&' . Phpfox::getTokenName() . '[is_admincp]=1' : '') . "'));";
				echo "$('body').css('cursor', 'auto');";
			}
			exit;
		}
		return true;
	}	
Ejemplo n.º 15
0
	/**
	 * Gets any data we plan to place within the HTML tags <head></head>.
	 * This method also groups the data to give the template a nice clean look.
	 *
	 * @return string $sData Returns the HTML data to be placed within <head></head>
	 */
	public function getHeader($bReturnArray = false)
	{		
		if (Phpfox::isMobile())
		{				
			$this->setHeader(array(
					'mobile.css' => 'style_css'
				)
			);			
		}

		if (!defined('PHPFOX_INSTALLER'))
		{
			$this->setHeader(array(
					'custom.css' => 'style_css'
				)
			);
			
			if (defined('PHPFOX_TEMPLATE_CSS_FILE'))
			{
				$this->setHeader(PHPFOX_TEMPLATE_CSS_FILE);
			}
			
			$sCustomCss = '';			
			$aThemeCache = $this->getThemeCache();
			if (isset($aThemeCache['l_width']) && $aThemeCache['l_width'] > 0)
			{
				$sCustomCss .= '#left { width:' . (int) $aThemeCache['l_width'] . 'px; }';
				$sCustomCss .= '#main_content { margin-left:' . (int) $aThemeCache['l_width'] . 'px; }';
			}			
			if (isset($aThemeCache['c_width']) && $aThemeCache['c_width'] > 0)
			{
				$sCustomCss .= '.content3, .item_view .js_feed_comment_border, .item_view .item_tag_holder, .item_view .attachment_holder_view { width:' . (int) $aThemeCache['c_width'] . 'px; }';				
			}
			if (isset($aThemeCache['r_width']) && $aThemeCache['r_width'] > 0)
			{
				$sCustomCss .= '#right { width:' . (int) $aThemeCache['r_width'] . 'px; }';
				$sCustomCss .= '.content4 { width:' . (960 - (int) $aThemeCache['r_width']) . 'px; }';
			}

			if (!empty($sCustomCss))
			{
				$this->setHeader('<style type="text/css">' . $sCustomCss . '</style>');
			}			
		}
		$aArrayData = array();
		$sData = '';
		$sCss = '';
		$sJs = '';
		$iVersion = $this->getStaticVersion();
		$oUrl = Phpfox::getLib('url');		
		$oCache = Phpfox::getLib('cache', array(
				'storage' => 'file',
				'free' => true
			)
		);		
		$aUrl = $oUrl->getParams();
		if (Phpfox::getUserParam('core.can_design_dnd') && Phpfox::getService('theme')->isInDnDMode() && (!isset($aUrl['req2']) || $aUrl['req2'] != 'designer'))
		{
			define('PHPFOX_DESIGN_DND', true);
			/* .
			 * Tells if the user is Design mode with Drag and Drop support.
			 * Its important to note the difference in the purpose of this
			 * constant as it does Not tell if the user CAN enter DesignDND 
			 * mode but instead it tells if the user IS already in this 
			 * mode
			 * .
			 */
			$this->_aHeaders[] = array('designdnd.js' => 'module_theme');
		}
		else
		{
			if (!defined('PHPFOX_DESIGN_DND'))
			{
				define('PHPFOX_DESIGN_DND', false);
			}
		}
			
		if (!PHPFOX_IS_AJAX_PAGE)
		{
			if (!defined('PHPFOX_INSTALLER'))
			{
				if (!Phpfox::isAdminPanel())
				{
					$oDb = Phpfox::getLib('database');
					$oFileCache = Phpfox::getLib('cache');
					$sFileThemeCssId = $oFileCache->set(array('theme', 'theme_css' . $iVersion));
					$aCacheStyles = array();
					if (!($aCacheStyles = $oFileCache->get($sFileThemeCssId)))
					{
						$aSavedStyles = $oDb->select('tc.module_id, tc.file_name')
							->from(Phpfox::getT('theme_css'), 'tc')
							->where('style_id = ' . (int) $this->_aTheme['style_id'] . '')		
							->execute('getRows');
						foreach ($aSavedStyles as $aSavedStyle)
						{
							$aCacheStyles[($aSavedStyle['module_id'] ? $aSavedStyle['module_id'] : null)][$aSavedStyle['file_name']] = true;
						}			
						
						$oFileCache->save($sFileThemeCssId, $aCacheStyles);
					}					
				}
			}			
		
			(($sPlugin = Phpfox_Plugin::get('template_getheader')) ? eval($sPlugin) : false);
			
			$sJs .= "\t\t\tvar oCore = {'core.is_admincp': " . (Phpfox::isAdminPanel() ? 'true' : 'false') . ", 'core.section_module': '" . Phpfox::getLib('module')->getModuleName() . "', 'profile.is_user_profile': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? 'true' : 'false') . ", 'log.security_token': '" . Phpfox::getService('log.session')->getToken() . "', 'core.url_rewrite': '" . Phpfox::getParam('core.url_rewrite') . "', 'core.country_iso': '" . (Phpfox::isUser() ? Phpfox::getUserBy('country_iso') : '') . "', 'core.can_move_on_a_y_and_x_axis' : " . ((!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.can_move_on_a_y_and_x_axis')) ? 'true' : 'false') . ", 'core.default_currency': '" . (defined('PHPFOX_INSTALLER') ? 'USD' : Phpfox::getService('core.currency')->getDefault()) . "', 'core.enabled_edit_area': " . (Phpfox::getParam('core.enabled_edit_area') ? 'true' : 'false') . ", 'core.disable_hash_bang_support': " . (Phpfox::getParam('core.disable_hash_bang_support') ? 'true' : 'false') . ", 'core.site_wide_ajax_browsing': " . ((!defined('PHPFOX_IN_DESIGN_MODE') && Phpfox::getParam('core.site_wide_ajax_browsing') && !Phpfox::isAdminPanel() && Phpfox::isUser()) ? 'true' : 'false') . ", 'profile.user_id': " . (defined('PHPFOX_IS_USER_PROFILE') && PHPFOX_IS_USER_PROFILE ? Phpfox::getService('profile')->getProfileUserId() : 0) . "};\n";

			$sProgressCssFile = $this->getStyle('css', 'progress.css');
			$sStylePath = str_replace(Phpfox::getParam('core.path'), '', str_replace('progress.css', '', $sProgressCssFile));
			
			$aJsVars = array(
				'sJsHome' => Phpfox::getParam('core.path'),
				'sJsHostname' => $_SERVER['HTTP_HOST'],
				'sJsStatic' => $oUrl->getDomain() . PHPFOX_STATIC,
				'sJsStaticImage' => Phpfox::getParam('core.url_static_image'),
				'sImagePath' => $this->getStyle('image'),
				'sStylePath' => $this->getStyle('css'),
				'sVersion' => Phpfox::getId(),
				'sJsAjax' => $oUrl->getDomain() . PHPFOX_STATIC . 'ajax.php',
				'sStaticVersion' => $iVersion,
				'sGetMethod' => PHPFOX_GET_METHOD,
				'sDateFormat' => (defined('PHPFOX_INSTALLER') ? '' : Phpfox::getParam('core.date_field_order')),
				'sJsAjax' => $oUrl->getDomain() . PHPFOX_STATIC . 'ajax.php',
				'sEgiftStyle' => $this->getStyle('css','display.css','egift'),
				'sGlobalTokenName' => Phpfox::getTokenName(),
				'sController' => Phpfox::getLib('module')->getFullControllerName(),
				'bJsIsMobile' => (Phpfox::isMobile() ? true : false),
				'sProgressCssFile' => $sProgressCssFile
			);	
			
			if (!defined('PHPFOX_INSTALLER'))
			{
				$aJsVars['bWysiwyg'] = ((Phpfox::getParam('core.wysiwyg') != 'default' && Phpfox::getParam('core.allow_html')) ? true : false);
				$aJsVars['sEditor'] = Phpfox::getParam('core.wysiwyg');	
				$aJsVars['sJsCookiePath'] = Phpfox::getParam('core.cookie_path');
				$aJsVars['sJsCookieDomain'] = Phpfox::getParam('core.cookie_domain');
				$aJsVars['sJsCookiePrefix'] = Phpfox::getParam('core.session_prefix');	
				$aJsVars['bPhotoTheaterMode'] = (Phpfox::isModule('photo') ? Phpfox::getParam('photo.view_photos_in_theater_mode') : false);
				if (Phpfox::isAdmin())
				{
					$aJsVars['sAdminCPLocation'] = Phpfox::getParam('admincp.admin_cp');
				}
				else
				{
					$aJsVars['sAdminCPLocation'] = '';
				}
				if (Phpfox::isModule('notification'))
				{
					$aJsVars['notification.notify_ajax_refresh'] = Phpfox::getParam('notification.notify_ajax_refresh');
				}
				if (Phpfox::isModule('im'))
				{
					$aJsVars['im_interval_for_update'] = Phpfox::getParam('im.js_interval_value');
					if (Phpfox::getParam('im.server_for_ajax_calls') != '')
					{
						$aJsVars['im_server'] = Phpfox::getParam('im.server_for_ajax_calls');
					}
				}
			}
			
			(($sPlugin = Phpfox_Plugin::get('template_getheader_setting')) ? eval($sPlugin) : false);

			$sJs .= "\t\t\tvar oParams = {";
			$iCnt = 0;
			foreach ($aJsVars as $sVar => $sValue)
			{
				$iCnt++;
				if ($iCnt != 1)
				{
					$sJs .= ",";
				}
				
				if (is_bool($sValue))
				{
					$sJs .= "'{$sVar}': " . ($sValue ? 'true' : 'false');	
				}
				elseif (is_numeric($sValue))
				{
					$sJs .= "'{$sVar}': " . $sValue;	
				}
				else 
				{
					$sJs .= "'{$sVar}': '{$sValue}'";	
				}
			}			
			$sJs .= "};\n";		
			
			if (!defined('PHPFOX_INSTALLER'))
			{			
				$aLocaleVars = array(
					'core.are_you_sure',
					'core.yes',
					'core.no',
					'core.save',
					'core.cancel',
					'core.go_advanced',
					'core.processing',
					'emoticon.emoticons',
					'attachment.attach_files',
					'core.close',					
//					'core.toggle_fullscreen',	
					'core.language_packages',
					'core.move_this_block',
					'core.uploading',
					'language.loading',
					'core.saving',
					'core.loading_text_editor',
					'core.quote'
				);
				
				if (Phpfox::isModule('im') && Phpfox::getParam('im.enable_im_in_footer_bar'))
				{
					$aLocaleVars[] = 'im.find_your_friends';
				}
				
				(($sPlugin = Phpfox_Plugin::get('template_getheader_language')) ? eval($sPlugin) : false);
				
				$sJs .= "\t\t\tvar oTranslations = {";
				$iCnt = 0;
				foreach ($aLocaleVars as $sValue)
				{
					$aParts = explode('.', $sValue);
					
					if ($aParts[0] != 'core' && !Phpfox::isModule($aParts[0]))
					{
						continue;
					}					
					
					$iCnt++;
					if ($iCnt != 1)
					{
						$sJs .= ",";
					}
	
					$sJs .= "'{$sValue}': '" . html_entity_decode(str_replace("'", "\'", Phpfox::getPhrase($sValue)), null, 'UTF-8') . "'";
				}				
				$sJs .= "};\n";			
					
				$aModules = Phpfox::getLib('module')->getModules();
				$sJs .= "\t\t\tvar oModules = {";
				$iCnt = 0;
				foreach ($aModules as $sModule => $iModuleId)
				{
					$iCnt++;
					if ($iCnt != 1)
					{
						$sJs .= ",";
					}				
					$sJs .= "'{$sModule}': true";
				}
				$sJs .= "};\n";			
			}			

			if (count($this->_aImages))
			{
				$sJs .= "\t\t\tvar oJsImages = {";
				foreach ($this->_aImages as $sKey => $sImage)
				{
					$sJs .= $sKey . ': \'' . $sImage. '\',';
				}
				$sJs = rtrim($sJs, ',');
				$sJs .= "};\n";			
			}		
		
		/*
		if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active'])
		{
		*/
			$aEditorButtons = Phpfox::getLib('editor')->getButtons();
			
			$iCnt = 0;						
			$sJs .= "\t\t\tvar oEditor = {";
			
			if (count($this->_aEditor) && isset($this->_aEditor['active']) && $this->_aEditor['active'])
			{
				foreach ($this->_aEditor as $sVar => $mValue)
				{
					$iCnt++;
					if ($iCnt != 1)
					{
						$sJs .= ",";
					}				
					$sJs .= "'{$sVar}': " . (is_bool($mValue) ? ($mValue === true ? 'true' : 'false') : "'{$mValue}'") . "";
				}
				
				$sJs .= ", ";
			}
			$sJs .= "images:[";
			foreach ($aEditorButtons as $mEditorButtonKey => $aEditorButton)
			{
				$sJs .= "{";
				foreach ($aEditorButton as $sEditorButtonKey => $sEditorButtonValue)			
				{
					$sJs .= "" . $sEditorButtonKey . ": '" . $sEditorButtonValue . "',";	
				}
				$sJs = rtrim($sJs, ',') . "},";
			}	
			$sJs = rtrim($sJs, ',') . "]";
			
			$sJs .= "};\n";	
		// }

			if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn'))
			{
				$sData .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/' . Phpfox::getParam('core.jquery_google_cdn_version') . '/jquery.min.js"></script>' . "\n";
			}
		}
		
		if (PHPFOX_IS_AJAX_PAGE)
		{
			$this->_aCacheHeaders = array();
		}
		
			$aSubCache = array();
			$sStyleCacheData = '';
			$sJsCacheData = '';		
			$aUrl = Phpfox::getLib('url')->getParams();
			
			foreach ($this->_aHeaders as $aHeaders)
			{
				if (!is_array($aHeaders))
				{
					$aHeaders = array($aHeaders);
				}			
				
				foreach ($aHeaders as $mKey => $mValue)
				{															
					$sQmark = (strpos($mKey, '?') ? '&amp;' : '?');
					
					if (is_numeric($mKey))
					{
						if ($mValue === null)
						{
							continue;
						}				

						if ($bReturnArray)
						{
							$aArrayData[] = $mValue;
						}
						else 
						{
							$sData .= "\t\t" . $mValue . "\n";
						}
					}
					else 
					{							
						switch ($mValue)
						{
							case 'style_script':
								
								if (isset($aSubCache[$mKey][$mValue]))
								{
									continue;
								}								
								
								if ($bReturnArray)
								{
									$aArrayData[] = $this->getStyle('jscript', $mKey);	
								}
								else 
								{
									if (isset($this->_aCacheHeaders[$mKey]))
									{
										$sJsCacheData .= str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('jscript', $mKey)) . ',';
									}
									else 
									{
										$sData .= "\t\t" . '<script type="text/javascript" src="' . $this->getStyle('jscript', $mKey) . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
									}
								}
							break;							
							case 'style_css':							
								$bCustomStyle = false;
								if (!defined('PHPFOX_INSTALLER') && !Phpfox::isAdminPanel())
								{
									if (isset($aCacheStyles[null][$mKey]))
									{
										$sCssCustomCacheId = $oCache->set(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey);
										
										if (!($oCache->isCached($sCssCustomCacheId)))										
										{									
											$oDb = Phpfox::getLib('database');
											$aCss = $oDb->select('tc.css_id, tc.css_data')
												->from(Phpfox::getT('theme_css'), 'tc')
												->where('style_id = ' . (int) $this->_aTheme['style_id'] . ' AND file_name = \'' . $oDb->escape($mKey) . '\'')		
												->execute('getRow');
												
											if (isset($aCss['css_id']))
											{											
												$aCss['css_data'] = str_replace('../image/layout/', $this->getStyle('image') . 'layout/', $aCss['css_data']);
												
												$oCache->save($sCssCustomCacheId, Phpfox::getLib('file.minimize')->css($aCss['css_data']));												
												
												$bCustomStyle = true;
											}									
										}
										else 
										{
											if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey))
											{
												$bCustomStyle = true;
											}
										}								
									}
									else 
									{
										if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $mKey))
										{
											$bCustomStyle = true;
										}										
									}
								}
							
								if ($bCustomStyle === false)
								{
									if ($bReturnArray)
									{
										$aArrayData[] = $this->getStyle('css', $mKey);
									}
									else 
									{
										if (isset($this->_aCacheHeaders[$mKey]))
										{
											$sStyleCacheData .= (Phpfox::isAdminPanel() ? str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey)) : $mKey) . ',';
										}
										else 
										{
											$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . $this->getStyle('css', $mKey) . $sQmark . 'v=' . $iVersion . '" />' . "\n";
										}
									}
								}
								else 
								{
									if (isset($this->_aCacheHeaders[$mKey]))
									{
										$sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . ',';
									}
									else 
									{
										$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
									}									
								}
								
								break;
							case 'static_script':				
							
								if (isset($aSubCache[$mKey][$mValue]))
								{
									continue;
								}							
											
								if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.load_jquery_from_google_cdn'))
								{											
									if ($mKey == 'jquery/ui.js' || $mKey == 'jquery/jquery.js')
									{				
										if ($mKey == 'jquery/ui.js')
										{					
											$sData .= "\t\t" . '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/' . Phpfox::getParam('core.jquery_ui_google_cdn_version') . '/jquery-ui.min.js"></script>' . "\n";											
										}
										
										continue;
									}									
								}								
								
								if ($bReturnArray)
								{
									$aArrayData[] = Phpfox::getParam('core.url_static_script') . $mKey;	
								}
								else 
								{
									if (isset($this->_aCacheHeaders[$mKey]))
									{
										$sJsCacheData .= $mKey . ',';
									}
									else 
									{									
										$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static_script') . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
									}
								}
								break;
							default:							
								if (preg_match('/module/i', $mValue))
								{
									$aParts = explode('_', $mValue);
									if (isset($aParts[1]) && Phpfox::isModule($aParts[1]))
									{
										if (substr($mKey, -3) == '.js')
										{											
											if ($bReturnArray)
											{
												$aArrayData[] = Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey;
											}
											else 
											{
												if (isset($this->_aCacheHeaders[$mKey]))
												{
													$sJsCacheData .= 'module/' . $aParts[1] . '/static/jscript/' . $mKey . ',';
												}
												else 
												{																		
													$sData .= "\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.path') . 'module/' . $aParts[1] . '/static/jscript/' . $mKey . $sQmark . 'v=' . $iVersion . '"></script>' . "\n";
												}
											}
										}
										elseif (substr($mKey, -4) == '.css')
										{											
											$bCustomStyle = false;
											if (!defined('PHPFOX_INSTALLER') && !Phpfox::isAdminPanel())
											{											
												if (isset($aCacheStyles[$aParts[1]][$mKey]))
												{
													$sCssCustomCacheId = $oCache->set(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey);
													
													if (!($oCache->isCached($sCssCustomCacheId)))										
													{									
														$oDb = Phpfox::getLib('database');
														$aCss = $oDb->select('tc.css_id, tc.css_data')
															->from(Phpfox::getT('theme_css'), 'tc')
															->where('module_id = \'' . $oDb->escape($aParts[1]) . '\' AND style_id = ' . (int) $this->_aTheme['style_id'] . ' AND file_name = \'' . $oDb->escape($mKey) . '\'')		
															->execute('getRow');
															
														if (isset($aCss['css_id']))
														{															
															$oCache->save($sCssCustomCacheId, Phpfox::getLib('file.minimize')->css($aCss['css_data']));																							
															
															$bCustomStyle = true;
														}									
													}
													else 
													{
														if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey))
														{
															$bCustomStyle = true;
														}
													}										
												}
												else 
												{
													if (file_exists(PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey))
													{
														$bCustomStyle = true;
													}													
												}
											}
											
											if ($bCustomStyle === false)
											{
												if ($bReturnArray)
												{
													$aArrayData[] = $this->getStyle('css', $mKey, $aParts[1]);
												}
												else 
												{																								
													if (isset($this->_aCacheHeaders[$mKey]))
													{
														$sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', $this->getStyle('css', $mKey, $aParts[1])) . ',';	
													}
													else 
													{
														$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . $this->getStyle('css', $mKey, $aParts[1]) . $sQmark . 'v=' . $iVersion . '" />' . "\n";											
													}
												}
											}
											else 
											{
												if (isset($this->_aCacheHeaders[$mKey]))
												{
													$sStyleCacheData .= str_replace(Phpfox::getParam('core.path'), '', Phpfox::getParam('core.url_file')) . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey . ',';
												}
												else 
												{
													$sData .= "\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_file') . 'static/' . $this->_aTheme['style_id'] . '_' . $aParts[1] . '_' . $mKey . '?v=' . $iVersion . '" />' . "\n";
												}												
											}
										}
									}
								}							
								break;							
							}
							
						$aSubCache[$mKey][$mValue] = true;
					}
				}
			}	
		
		$sCacheData = '';
		$sCacheData .= "\n\t\t<script type=\"text/javascript\">\n";
		$sCacheData .= $sJs;
		$sCacheData .= "\t\t</script>";			
		if (!empty($sStyleCacheData))
		{
			$sCacheData .= "\n\t\t" . '<link rel="stylesheet" type="text/css" href="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=css&amp;s=' . $sStylePath . '&amp;f=' . rtrim($sStyleCacheData, ',') . '&amp;v=' . $iVersion . '" />';
		}
		
		if (!empty($sJsCacheData))
		{
			$sCacheData .= "\n\t\t" . '<script type="text/javascript" src="' . Phpfox::getParam('core.url_static') . 'gzip.php?t=js&amp;f=' . rtrim($sJsCacheData, ',') . '&amp;v=' . $iVersion . '"></script>';
		}		
		
		if (!empty($sCacheData))
		{
			$sData = preg_replace('/<link rel="shortcut icon" type="image\/x-icon" href="(.*?)" \/>/i', '<link rel="shortcut icon" type="image/x-icon" href="\\1" />' . $sCacheData, $sData);
		}		
		
		if ($bReturnArray)
		{
			$sData = '';
		}
		
		if (count($this->_aPhrases))
		{
			$sData .= "\t\t<script type=\"text/javascript\">\n\t\t<!--\n";
			foreach ($this->_aPhrases as $sVar => $sPhrase)
			{
				$sData .= "\t\t\toTranslations['{$sVar}'] = '" . str_replace("'", "\'", $sPhrase) . "';\n";
			}
			$sData .= "\t\t-->\n\t\t</script>\n";
		}		
		
		if ($bReturnArray)
		{
			$aArrayData[] = $sData;			
			
			return $aArrayData;
		}
	
		// Convert meta data		
		if (count($this->_aMeta) && !PHPFOX_IS_AJAX_PAGE && !defined('PHPFOX_INSTALLER'))
		{
			$oPhpfoxParseOutput = Phpfox::getLib('parse.output');
			$aFind = array(
				'&lt;',
				'&gt;',
				'$'
			);
			$aReplace = array(
				'<',
				'>',
				'&36;'
			);			
			
			foreach ($this->_aMeta as $sMeta => $sMetaValue)
			{
				$sMetaValue = str_replace($aFind, $aReplace, $sMetaValue);
				$sMetaValue = strip_tags($sMetaValue);
				$sMetaValue = str_replace(array("\n", "\r"), "", $sMetaValue);		
				$bIsCustomMeta = false;
						
				switch ($sMeta)
				{
					case 'keywords':						
						$sKeywordSearch = Phpfox::getParam('core.words_remove_in_keywords');
						if (!empty($sKeywordSearch))
						{
							$aKeywordsSearch = array_map('trim', explode(',', $sKeywordSearch));							
						}
						$sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_keyword_limit'));
						$sMetaValue = trim(rtrim(trim($sMetaValue), ','));
						$aParts = explode(',', $sMetaValue);
						$sMetaValue = '';
						$aKeywordCache = array();
						foreach ($aParts as $sPart)
						{
							$sPart = trim($sPart);
							
							if (isset($aKeywordCache[$sPart]))
							{
								continue;
							}
							
							if (isset($aKeywordsSearch) && in_array(strtolower($sPart), array_map('strtolower', $aKeywordsSearch)))
							{
								continue;
							}
							
							$sMetaValue .= $sPart . ', ';
							
							$aKeywordCache[$sPart] = true;
						}
						$sMetaValue = rtrim(trim($sMetaValue), ',');
						break;
					case 'description':
						$sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
						break;
					default:
						$bIsCustomMeta = true;
						break;
				}
				$sMetaValue = str_replace('"', '\"', $sMetaValue);
				$sMetaValue = Phpfox::getLib('locale')->convert($sMetaValue);				
				$sMetaValue = html_entity_decode($sMetaValue, null, 'UTF-8');
				$sMetaValue = str_replace(array('<', '>'), '', $sMetaValue);		
				if ($bIsCustomMeta)
				{
					if ($sMeta == 'og:description')
					{
						$sMetaValue = $oPhpfoxParseOutput->shorten($oPhpfoxParseOutput->clean($sMetaValue), Phpfox::getParam('core.meta_description_limit'));
					}
					
					$sData .= "\t\t<meta property=\"{$sMeta}\" content=\"{$sMetaValue}\" />\n";	
				}
				else 
				{
					$sData = preg_replace("/<meta name=\"{$sMeta}\" content=\"(.*?)\" \/>\n\t/i", "<meta name=\"{$sMeta}\" content=\"" . $sMetaValue . "\" />\n\t", $sData);
				}
			}
		}
			
		// Clear from memory
		$this->_aHeaders = array();		
		$this->_aMeta = array();		
		
		return $sData;
	}