Example #1
0
 /**
  * 
  * @staticvar string $sContents
  * @return boolean
  */
 public static function checkModRewriteEnabled($params)
 {
     $oFileRetriever = JchOptimizeFileRetriever::getInstance();
     if (!$oFileRetriever->isHttpAdapterAvailable()) {
         $params->set('htaccess', '0');
     } else {
         $oUri = JchPlatformUri::getInstance();
         $sUrl = $oUri->toString(array('scheme', 'user', 'pass', 'host', 'port')) . JchPlatformPaths::assetPath() . JchPlatformPaths::rewriteBase() . 'test_mod_rewrite';
         $sContents = $oFileRetriever->getFileContents($sUrl);
         if ($sContents == 'TRUE') {
             $params->set('htaccess', '1');
         } else {
             $params->set('htaccess', '0');
         }
     }
     JchPlatformPlugin::saveSettings($params);
 }
 /**
  * 
  * @staticvar string $sContents
  * @return boolean
  */
 public static function checkModRewriteEnabled($params)
 {
     JCH_DEBUG ? JchPlatformProfiler::start('CheckModRewriteEnabled') : null;
     $oFileRetriever = JchOptimizeFileRetriever::getInstance();
     if (!$oFileRetriever->isHttpAdapterAvailable()) {
         $params->set('htaccess', 0);
     } else {
         $oUri = JchPlatformUri::getInstance();
         $sUrl = $oUri->toString(array('scheme', 'user', 'pass', 'host', 'port')) . JchPlatformPaths::assetPath(TRUE);
         $sUrl2 = JchPlatformPaths::rewriteBase() . 'test_mod_rewrite';
         try {
             $sContents = $oFileRetriever->getFileContents($sUrl . $sUrl2);
             if ($sContents == 'TRUE') {
                 $params->set('htaccess', 1);
             } else {
                 $sContents2 = $oFileRetriever->getFileContents($sUrl . '3' . $sUrl2);
                 if ($sContents2 == 'TRUE') {
                     $params->set('htaccess', 3);
                 } else {
                     $params->set('htaccess', 0);
                 }
             }
         } catch (Exception $e) {
             $params->set('htaccess', 0);
         }
     }
     JchPlatformPlugin::saveSettings($params);
     JCH_DEBUG ? JchPlatformProfiler::stop('CheckModRewriteEnabled', TRUE) : null;
 }
Example #3
0
 /**
  * Returns url of aggregated file
  *
  * @param string $sFile		Aggregated file name
  * @param string $sType		css or js
  * @param mixed $bGz		True (or 1) if gzip set and enabled
  * @param number $sTime		Expire header time
  * @return string			Url of aggregated file
  */
 protected function buildUrl($sId, $sType)
 {
     $sPath = JchPlatformPaths::assetPath();
     $iTime = (int) $this->params->get('lifetime', '30');
     $bGz = $this->isGZ();
     if ($this->params->get('htaccess', 0) == 1) {
         $sUrl = JchOptimizeHelper::cookieLessDomain($this->params) . $sPath . JchPlatformPaths::rewriteBase() . ($bGz ? 'gz/' : 'nz/') . $iTime . '/JCHI/' . $sId . '.' . $sType;
     } else {
         $oUri = clone JchPlatformUri::getInstance();
         $oUri->setPath($sPath . '2/jscss.php');
         $aVar = array();
         $aVar['f'] = $sId;
         $aVar['type'] = $sType;
         $aVar['gz'] = $bGz ? 'gz' : 'nz';
         $aVar['d'] = $iTime;
         $aVar['i'] = 'JCHI';
         $oUri->setQuery($aVar);
         $sUrl = htmlentities($oUri->toString(array('path', 'query')));
     }
     return $sUrl;
 }
Example #4
0
 /**
  * 
  * @return type
  */
 protected function cookieLessDomain($sType)
 {
     if ($this->params->get('pro_cookielessdomain_enable', '0') && in_array($sType, $this->params->get('pro_staticfiles', array('css', 'js', 'jpe?g', 'gif', 'png', 'ico', 'bmp', 'pdf')))) {
         return JchOptimizeHelper::cookieLessDomain($this->params, JchPlatformPaths::assetPath(TRUE));
     }
     return JchPlatformPaths::assetPath();
 }
Example #5
0
 /**
  * 
  * @return type
  */
 protected function cookieLessDomain()
 {
     if (JchOptimizeHelper::cookieLessDomain($this->params)) {
         return JchOptimizeHelper::cookieLessDomain($this->params) . JchPlatformPaths::assetPath(TRUE);
     }
     return JchPlatformPaths::assetPath();
 }