Exemplo n.º 1
0
 public static function dontJbetolo($type = 'jbetolo')
 {
     if (self::param('listen_request', 0) && JRequest::getCmd('nojbetolo', 0) == 1) {
         return true;
     }
     $app = JFactory::getApplication()->getName();
     $user = JFactory::getUser();
     $allowedIn = $type == 'jbetolo' ? self::param('allow_in') : 'site';
     if (!self::$allowAll && ($allowedIn == 'anonymous' && !$user->guest || $allowedIn != 'anonymous' && $app != $allowedIn && $allowedIn != 'all' || $app == 'administrator' && $user->guest)) {
         return true;
     }
     $document = JFactory::getDocument();
     $doctype = $document->getType();
     if ($doctype != 'html') {
         return true;
     }
     if ($type == 'cdn') {
         if (!(bool) self::param('cdn_enabled', false)) {
             return true;
         }
     }
     $donts = self::$donts[$type];
     if ($type == 'jbetolo') {
         $excludeComponents = self::param('exclude_components');
     } else {
         $excludeComponents = self::param($type . '_exclude_components');
     }
     if (!empty($excludeComponents)) {
         $excludeComponents = explode(',', $excludeComponents);
         foreach ($excludeComponents as $i => $component) {
             if (substr($component, 0, 4) != 'com_') {
                 $excludeComponents[$i] = 'com_' . $component;
             }
         }
         if (is_array($donts['option'])) {
             $donts['option'] = array_merge($donts['option'], $excludeComponents);
         } else {
             $donts['option'] = $excludeComponents;
         }
     }
     $excludeURLs = self::param('exclude_urls', array());
     if (!empty($excludeURLs)) {
         $excludeURLs = explode(',', $excludeURLs);
         foreach ($excludeURLs as &$url) {
             if (strpos($url, self::EXCLUDE_REG_PREFIX) === false) {
                 parse_str($url, $url);
             } else {
                 $url = str_replace(self::EXCLUDE_REG_PREFIX, '', $url);
             }
         }
     }
     $excludeURLs[] = array('option' => 'com_maqmahelpdesk', 'task' => 'ticket_view');
     $excludeURLs[] = array('option' => 'com_jevents', 'task' => 'icalevent.edit');
     $excludeURLs[] = array('option' => 'com_content', 'task' => 'article.add');
     $excludeURLs[] = array('option' => 'com_content', 'task' => 'article.edit');
     $excludeURLs[] = array('option' => 'com_k2', 'task' => 'article.add');
     $excludeURLs[] = array('option' => 'com_k2', 'task' => 'article.edit');
     $excludeURLs[] = array('option' => 'com_easydiscuss', 'view' => 'ask');
     $currentURL = jbetoloHelper::currentURL();
     if (!empty($excludeURLs)) {
         $input = JFactory::getApplication()->input;
         foreach ($excludeURLs as $url) {
             $match = true;
             if (is_string($url)) {
                 $match = preg_match('#' . preg_quote($url) . '#', $currentURL);
             } else {
                 foreach ($url as $k => $v) {
                     //                                                $val = JRequest::getVar($k, self::$dontsEmpty);
                     $val = $input->get($k, self::$dontsEmpty);
                     if ($val != $v) {
                         $match = false;
                         break;
                     }
                 }
             }
             if ($match) {
                 return true;
             }
         }
     }
     if (self::checkRules($donts)) {
         return true;
     }
     $excludeBrowsers = self::param('exclude_browsers');
     if (!empty($excludeBrowsers)) {
         $excludeBrowsers = explode("\n", $excludeBrowsers);
         jimport('joomla.environment.browser');
         $navigator = JBrowser::getInstance();
         foreach ($excludeBrowsers as $excludeBrowser) {
             $excludeBrowser = strtolower($excludeBrowser);
             $excludeBrowser = trim($excludeBrowser);
             $additionalCheck = false;
             $_excludeBrowser = explode('-version', $excludeBrowser);
             $_excludeBrowser[0] = jbetoloHelper::browser($_excludeBrowser[0]);
             if (count($_excludeBrowser) > 1) {
                 if ($navigator->isBrowser($_excludeBrowser[0])) {
                     if (self::browserCompare($_excludeBrowser, 'version', $navigator)) {
                         return true;
                     }
                 }
                 $additionalCheck = true;
             }
             if (!$additionalCheck) {
                 $excludeBrowser = jbetoloHelper::browser($excludeBrowser);
                 if ($navigator->isBrowser($excludeBrowser)) {
                     return true;
                 }
             }
         }
     }
     if ((bool) self::param('exclude_mobile', 0)) {
         jimport('joomla.environment.browser');
         $navigator = JBrowser::getInstance();
         if ($navigator->isMobile()) {
             return true;
         }
     }
     return false;
 }