コード例 #1
0
 /**
  * Returns allow-origin rules
  *
  * @param bool    $cdnftp
  * @return string
  */
 public static function allow_origin($cdnftp = false)
 {
     switch (true) {
         case Util_Environment::is_apache():
         case Util_Environment::is_litespeed():
             $r = "<IfModule mod_headers.c>\n";
             $r .= "    Header set Access-Control-Allow-Origin \"*\"\n";
             $r .= "</IfModule>\n";
             if (!$cdnftp) {
                 return $r;
             } else {
                 return "<FilesMatch \"\\.(ttf|ttc|otf|eot|woff|woff2|font.css)\$\">\n" . $r . "</FilesMatch>\n";
             }
     }
     return '';
 }
コード例 #2
0
 /**
  * Sets data
  *
  * @param string  $key
  * @param string  $var
  * @param int     $expire
  * @param string  $group  Used to differentiate between groups of cache values
  * @return boolean
  */
 function set($key, $var, $expire = 0, $group = '')
 {
     $key = $this->get_item_key($key);
     $sub_path = $this->_get_path($key);
     $path = $this->_cache_dir . '/' . $sub_path;
     $dir = dirname($path);
     if (!@is_dir($dir)) {
         if (!Util_File::mkdir_from($dir, W3TC_CACHE_DIR)) {
             return false;
         }
     }
     $tmppath = $path . '.' . getmypid();
     $fp = @fopen($tmppath, 'w');
     if (!$fp) {
         return false;
     }
     if ($this->_locking) {
         @flock($fp, LOCK_EX);
     }
     @fputs($fp, $var['content']);
     @fclose($fp);
     if ($this->_locking) {
         @flock($fp, LOCK_UN);
     }
     // some hostings create files with restrictive permissions
     // not allowing apache to read it later
     @chmod($path, 0644);
     if (@filesize($tmppath) > 0) {
         @unlink($path);
         @rename($tmppath, $path);
     }
     @unlink($tmppath);
     $old_entry_path = $path . '.old';
     @unlink($old_entry_path);
     if (Util_Environment::is_apache() && isset($var['headers']) && isset($var['headers']['Content-Type']) && substr($var['headers']['Content-Type'], 0, 8) == 'text/xml') {
         file_put_contents(dirname($path) . '/.htaccess', "<IfModule mod_mime.c>\n" . "    RemoveType .html_gzip\n" . "    AddType text/xml .html_gzip\n" . "    RemoveType .html\n" . "    AddType text/xml .html\n" . "</IfModule>");
     }
     return true;
 }
コード例 #3
0
 /**
  * Generates directives for file cache dir
  *
  * @param Config  $config
  * @return string
  */
 private function rules_cache_generate($config)
 {
     switch (true) {
         case Util_Environment::is_apache():
         case Util_Environment::is_litespeed():
             return $this->rules_cache_generate_apache($config);
         case Util_Environment::is_nginx():
             return $this->rules_cache_generate_nginx($config);
     }
     return '';
 }
コード例 #4
0
 /**
  * Generates rules for WP dir
  *
  * @param Config  $config
  * @return string
  */
 private static function rules_generate($config)
 {
     switch (true) {
         case Util_Environment::is_apache():
         case Util_Environment::is_litespeed():
             return self::rules_generate_apache($config);
         case Util_Environment::is_nginx():
             return self::rules_generate_nginx($config);
     }
     return '';
 }
コード例 #5
0
ファイル: self_test.php プロジェクト: developmentDM2/Whohaha
    ?>
</code>
            <?php 
} else {
    ?>
            <code><?php 
    _e('Not available', 'w3-total-cache');
    ?>
</code>
            <?php 
}
?>
        </li>

        <?php 
if (Util_Environment::is_apache()) {
    $apache_modules = function_exists('apache_get_modules') ? apache_get_modules() : false;
    $modules = array('mod_deflate', 'mod_env', 'mod_expires', 'mod_filter', 'mod_ext_filter', 'mod_headers', 'mod_mime', 'mod_rewrite', 'mod_setenvif');
    ?>
            <?php 
    foreach ($modules as $module) {
        ?>
                <li>
                    <?php 
        echo $module;
        ?>
:
                    <?php 
        if ($apache_modules) {
            ?>
                        <?php 
コード例 #6
0
 /**
  * Generate rules related to prevent for media 404 error by WP
  *
  * @param Config  $config
  * @return string
  */
 private function rules_no404wp_generate($config)
 {
     switch (true) {
         case Util_Environment::is_apache():
         case Util_Environment::is_litespeed():
             return $this->rules_no404wp_generate_apache($config);
     }
     return false;
 }
コード例 #7
0
 /**
  * Checks if the platform running WP is supported by New Relic.
  * The verifications is based on https://newrelic.com/docs/php/new-relic-for-php
  *
  * @return array
  */
 function verify_compatibility()
 {
     $php_versions = array('5.2.x', '5.3.x', '5.4.x');
     $verified = array();
     $version = explode('.', PHP_VERSION);
     $php_version = sprintf('%s.%s.%s', $version[0], $version[1], $version[2]);
     $php_version_ok = version_compare($php_version, '5.2', '>') && version_compare($php_version, '5.5', '<');
     $supported_string = __('Supported', 'w3-total-cache');
     $verified[__('PHP version', 'w3-total-cache')] = $php_version_ok ? $supported_string : sprintf(__('Not supported: %s. Supported versions are %s.', 'w3-total-cache'), $php_version, implode(', ', $php_versions));
     $os_name = php_uname('s');
     switch ($os_name) {
         case 'Linux':
             /**
              * Any other version of Linux with kernel 2.6.13 or later
              * (2.6.26 and later highly recommended) and glibc 2.5 or later
              */
             $version = explode('.', php_uname('r'));
             $os_version = sprintf('%d.%d.%d', $version[0], $version[1], $version[2]);
             $os_check = version_compare($os_version, '2.6.13', '>=');
             break;
         case 'FreeBSD':
             /**
              * You must enable the linkthr build option so that the New Relic agent will not cause your PHP to hang.
              */
             $version = explode('.', php_uname('r'));
             $os_version = sprintf('%d.%d', $version[0], $version[1]);
             $os_check = version_compare($os_version, '7.3', '>=');
             break;
         case 'MacOS/X':
             /**
              * MacOS/X configurations do not use the standard /etc/init.d/newrelic-daemon script.
              * Instead, they use /usr/bin/newrelic-daemon-service in the same way; for example:
              * /usr/bin/newrelic-daemon-service restart.
              */
             $version = explode('.', php_uname('r'));
             $os_version = sprintf('%d.%d', $version[0], $version[1]);
             $os_check = version_compare($os_version, '10.5', '>=');
             break;
         case 'Open Solaris':
             /**
              * snv_134b or later
              */
             $version = explode('.', php_uname('r'));
             $os_version = sprintf('%d', $version[0]);
             $os_check = version_compare($os_version, '10', '==');
             break;
         default:
             $os_check = false;
             $os_name = php_uname();
             $os_version = '';
     }
     $verified[__('Operating System', 'w3-total-cache')] = $os_check ? $supported_string : sprintf(__('Not Supported. (%s %s See %s page.)', 'w3-total-cache'), $os_name, $os_version, '<a href="https://newrelic.com/docs/php/new-relic-for-php#requirements" target="_blank">
         NewRelic Requirements</a>');
     /**
      * Apache 2.2 or 2.4 via mod_php
      * Or any web server that supports FastCGI using php-fpm
      */
     $server = explode('/', $_SERVER['SERVER_SOFTWARE']);
     $ws_check = false;
     $ws_name = $_SERVER['SERVER_SOFTWARE'];
     $ws_version = '';
     if (sizeof($server) > 1) {
         $ws_name = $server[0];
         $ws_version = $server[1];
         if (sizeof($version = explode('.', $ws_version)) > 1) {
             $ws_version = sprintf('%d.%d', $version[0], $version[1]);
         }
     }
     switch (true) {
         case Util_Environment::is_apache():
             if ($ws_version) {
                 $ws_check = version_compare($ws_version, '2.2', '>=') || version_compare($ws_version, '2.4', '>=');
             }
             break;
         case Util_Environment::is_nginx():
             $ws_check = php_sapi_name() == 'fpm-fcgi';
             $ws_name .= php_sapi_name();
             break;
         default:
             $ws_check = php_sapi_name() == 'fpm-fcgi';
             $ws_name = $_SERVER['SERVER_SOFTWARE'];
             $ws_version = '';
     }
     $verified[__('Web Server', 'w3-total-cache')] = $ws_check ? $supported_string : sprintf(__('Not Supported. (%s %s See %s page.)', 'w3-total-cache'), $ws_name, $ws_version, '<a href="https://newrelic.com/docs/php/new-relic-for-php#requirements" target="_blank">
                                     NewRelic Requirements</a>');
     return $verified;
 }
コード例 #8
0
 /**
  * Returns true if we can check rules
  *
  * @return bool
  */
 public static function can_check_rules()
 {
     return Util_Environment::is_apache() || Util_Environment::is_litespeed() || Util_Environment::is_nginx();
 }