当前位置: 首页>>代码示例>>PHP>>正文


PHP gzencode函数代码示例

本文整理汇总了PHP中gzencode函数的典型用法代码示例。如果您正苦于以下问题:PHP gzencode函数的具体用法?PHP gzencode怎么用?PHP gzencode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了gzencode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRecommended

 public function getRecommended()
 {
     static $phpOptions = array();
     if (empty($phpOptions)) {
         $phpOptions[] = array('label' => AText::_('MAIN_REC_SAFEMODE'), 'current' => (bool) ini_get('safe_mode'), 'recommended' => false);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_DISPERRORS'), 'current' => (bool) ini_get('display_errors'), 'recommended' => false);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_MCR'), 'current' => (bool) ini_get('magic_quotes_runtime'), 'recommended' => false);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_MCGPC'), 'current' => (bool) ini_get('magic_quotes_gpc'), 'recommended' => false);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_OUTBUF'), 'current' => (bool) ini_get('output_buffering'), 'recommended' => false);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_SESSIONAUTO'), 'current' => (bool) ini_get('session.auto_start'), 'recommended' => false);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_CURL'), 'current' => function_exists('curl_init'), 'recommended' => true);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_FTP'), 'current' => function_exists('ftp_connect'), 'recommended' => true);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_SSH2'), 'current' => extension_loaded('ssh2'), 'recommended' => true);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_FOPEN'), 'current' => ini_get('allow_url_fopen'), 'recommended' => true);
         if (function_exists('gzencode')) {
             $gz = @gzencode('dd') !== false;
         } else {
             $gz = false;
         }
         $phpOptions[] = array('label' => AText::_('MAIN_REC_GZ'), 'current' => $gz, 'recommended' => true);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_MCRYPT'), 'current' => function_exists('mcrypt_encrypt'), 'recommended' => true);
         $phpOptions[] = array('label' => AText::_('MAIN_REC_DOM'), 'current' => extension_loaded('Dom'), 'recommended' => true);
     }
     return $phpOptions;
 }
开发者ID:akeeba,项目名称:angie,代码行数:25,代码来源:prestashopmain.php

示例2: afterLayout

 function afterLayout()
 {
     if (Configure::read('Cache.disable') || Configure::read('ViewMemcache.disable')) {
         return true;
     }
     try {
         if (!empty($this->_View->viewVars['enableViewMemcache'])) {
             if (isset($this->_View->viewVars['viewMemcacheDuration'])) {
                 // CakeLog::write('debug', "ViewMemCache: duration override: {$this->_View->viewVars['viewMemcacheDuration']}");
                 @Cache::set(array('duration' => $this->_View->viewVars['viewMemcacheDuration'], null, 'view_memcache'));
                 //'+30 days' or seconds
             }
             if (!isset($this->_View->viewVars['viewMemcacheNoFooter'])) {
                 //CakeLog::write('debug', "ViewMemCache: footer disabled");
                 $this->cacheFooter = "\n<!-- ViewCached";
                 if ($this->gzipContent) {
                     $this->cacheFooter .= ' gzipped';
                 }
                 $this->cacheFooter .= ' ' . date('r') . ' -->';
             }
             if ($this->gzipContent && empty($this->_View->viewVars['viewMemcacheDisableGzip'])) {
                 //CakeLog::write('debug', "ViewMemCache: gzipping ".$this->request->here."\n\n".var_export($this->request,true)."\n\n".var_export($_SERVER,true));
                 @Cache::write($this->request->here, gzencode($this->_View->output . $this->cacheFooter, $this->compressLevel), 'view_memcache');
             } else {
                 //CakeLog::write('debug', "ViewMemCache: NOT gzipping ");
                 @Cache::write($this->request->here, $this->_View->output . $this->cacheFooter, 'view_memcache');
             }
         }
     } catch (Exception $e) {
         //do nothing
     }
     return true;
 }
开发者ID:Jpsstack,项目名称:cakephp-viewmemcache,代码行数:33,代码来源:ViewMemcacheHelper.php

示例3: postContent

 function postContent()
 {
     $this->adminGatekeeper();
     $request = $this->getInput('request');
     $key = $this->getInput('key');
     $username = $this->getInput('username');
     $json = $this->getInput('json');
     $follow_redirects = $this->getInput('follow_redirects');
     $method = $this->getInput('method', 'GET');
     $url = \Idno\Core\Idno::site()->config()->getURL();
     if (strripos($url, '/') == strlen($url) - 1) {
         $url = substr($url, 0, strlen($url) - 1);
     }
     $url .= $request;
     $client = new Webservice();
     if ($method == 'POST') {
         $result = $client->post($url, $json, array('X-KNOWN-USERNAME: ' . $username, 'X-KNOWN-SIGNATURE: ' . base64_encode(hash_hmac('sha256', $request, $key, true))));
     } else {
         $result = $client->get($url, null, array('X-KNOWN-USERNAME: ' . $username, 'X-KNOWN-SIGNATURE: ' . base64_encode(hash_hmac('sha256', $request, $key, true))));
     }
     $response = Webservice::getLastResponse();
     $sent_request = Webservice::getLastRequest() . $json;
     $api_request = array('request' => $request, 'key' => $key, 'username' => $username, 'json' => $json, 'sent_request' => $sent_request, 'response' => gzencode($response, 9), 'method' => $method);
     \Idno\Core\Idno::site()->session()->set('api_request', $api_request);
     $this->forward(\Idno\Core\Idno::site()->config()->getURL() . 'admin/apitester/');
 }
开发者ID:sintoris,项目名称:Known,代码行数:26,代码来源:Admin.php

示例4: put

 /**
  * Put file to storage
  *
  * @param  string $file   file path in storage
  * @param  array  $params uploaded data and options
  * @return array  file size and file name
  */
 public function put($file, $params)
 {
     if (empty($params['overwrite'])) {
         $file = $this->generateName($file);
         // check if name is unique and generate new if not
     }
     $file = $this->prefix($file);
     if (!empty($params['compress'])) {
         if (!empty($params['contents'])) {
             $params['contents'] = gzencode($params['contents']);
         }
     }
     if (!fn_mkdir(dirname($file))) {
         return false;
     }
     if (!empty($params['file'])) {
         fn_copy($params['file'], $file);
     } else {
         fn_put_contents($file, $params['contents']);
     }
     if (!file_exists($file)) {
         return false;
     }
     $filesize = filesize($file);
     if (!empty($params['file']) && empty($params['keep_origins'])) {
         fn_rm($params['file']);
     }
     return array($filesize, str_replace($this->prefix(), '', $file));
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:36,代码来源:File.php

示例5: index

 public function index()
 {
     //$sitemap = new google_sitemap; //Create a new Sitemap Object
     $posts = $this->cf_blog_model->getRecentPosts('50');
     $item = $this->cf_sitemap_lib->google_sitemap_item(site_url(), date("Y-m-d", time()), 'daily', '1.0');
     //Create a new Item
     $this->cf_sitemap_lib->add_item($item);
     foreach ($posts->result_array() as $entry) {
         $link = get_page_url($entry);
         //Create a new Item
         $item = $this->cf_sitemap_lib->google_sitemap_item(site_url($link), date("Y-m-d", strtotime($entry['page_date'])), 'daily', '0.5');
         //Append the item to the sitemap object
         $this->cf_sitemap_lib->add_item($item);
     }
     $this->cf_sitemap_lib->build("sitemap.xml");
     //Build it...
     //Let's compress it to gz
     $data = implode("", file("sitemap.xml"));
     $gzdata = gzencode($data, 9);
     $fp = fopen("sitemap.xml.gz", "w");
     fwrite($fp, $gzdata);
     fclose($fp);
     //Let's Ping google
     $this->_pingGoogleSitemaps(base_url() . "/sitemap.xml.gz");
     echo site_url();
 }
开发者ID:ipopovic,项目名称:codefight-cms,代码行数:26,代码来源:sitemap.php

示例6: request

 private function request($url, $data, $apiKey = null, $operation = null)
 {
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectionTimeout);
     curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     if ($this->certificationFile) {
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
         curl_setopt($ch, CURLOPT_CAINFO, $this->certificationFile);
     } else {
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     }
     if ($this->proxy) {
         curl_setopt($ch, CURLOPT_PROXY, $this->proxy);
     }
     $headers = array("Content-Type: application/json+gzip", "User-Agent: QafooLabs Profiler Collector DevMode");
     if ($apiKey) {
         $headers[] = 'X-Profiler-Key: ' . $apiKey;
     }
     if ($operation) {
         $headers[] = 'X-Profiler-Op: ' . $operation;
     }
     curl_setopt($ch, CURLOPT_FAILONERROR, true);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
     curl_setopt($ch, CURLOPT_POSTFIELDS, gzencode(json_encode($data)));
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     if (curl_exec($ch) === false) {
         syslog(LOG_WARNING, "Qafoo Profiler DevMode cURL failed: " . curl_error($ch));
     }
 }
开发者ID:qafoolabs,项目名称:profiler,代码行数:32,代码来源:CurlBackend.php

示例7: send

 /**
  * Compresses data and send it to the client
  *
  * @param String $data - The string to send.
  */
 public static function send($data = '')
 {
     if (!headers_sent()) {
         if (array_key_exists('HTTP_ACCEPT_ENCODING', $_SERVER)) {
             $HTTP_ACCEPT_ENCODING = $_SERVER['HTTP_ACCEPT_ENCODING'];
             if (headers_sent()) {
                 $encoding = false;
             } else {
                 if (strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false) {
                     $encoding = 'x-gzip';
                 } else {
                     if (strpos($HTTP_ACCEPT_ENCODING, 'gzip') !== false) {
                         $encoding = 'gzip';
                     } else {
                         $encoding = false;
                     }
                 }
             }
             // no need to waste resources in compressing very little data
             if (strlen($data) > 2048 && $encoding && function_exists('gzencode')) {
                 $data = gzencode($data, 5);
                 header('Content-Encoding: ' . $encoding);
             }
         }
         header('Content-Length: ' . strlen($data));
     }
     echo $data;
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:33,代码来源:CompressedSender.php

示例8: actionImport

 /**
  * Import products
  */
 public function actionImport()
 {
     $importer = new CsvImporter();
     $importer->deleteDownloadedImages = Yii::app()->request->getPost('remove_images');
     if (Yii::app()->request->isPostRequest && isset($_FILES['file'])) {
         $importer->file = $_FILES['file']['tmp_name'];
         if ($importer->validate() && !$importer->hasErrors()) {
             // Create db backup
             if (isset($_POST['create_dump']) && $_POST['create_dump']) {
                 Yii::import('application.components.SDatabaseDumper');
                 $dumper = new SDatabaseDumper();
                 $file = Yii::getPathOfAlias('webroot.protected.backups') . DIRECTORY_SEPARATOR . 'dump_' . date('Y-m-d_H_i_s') . '.sql';
                 if (is_writable(Yii::getPathOfAlias('webroot.protected.backups'))) {
                     if (function_exists('gzencode')) {
                         file_put_contents($file . '.gz', gzencode($dumper->getDump()));
                     } else {
                         file_put_contents($file, $dumper->getDump());
                     }
                 } else {
                     throw new CHttpException(503, Yii::t('CsvModule.admin', 'Ошибка. Директория для бэкапов недоступна для записи.'));
                 }
             }
             $importer->import();
         }
     }
     $this->render('import', array('importer' => $importer));
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:30,代码来源:DefaultController.php

示例9: template_outputfilter_gzip

function template_outputfilter_gzip($tpl_source, &$template_object)
{
    static $_tpl_saved = '';
    $gzipped = 0;
    if ($template_object->enable_gzip) {
        if (extension_loaded("zlib") && !get_cfg_var('zlib.output_compression') && !$template_object->cache && (strstr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") || $template_object->force_compression)) {
            $_tpl_saved .= $tpl_source . "\n<!-- zlib compression level " . $template_object->compression_level . " -->\n\n";
            $tpl_source = "";
            if ($template_object->send_now == 1) {
                $gzipped = 1;
                $tpl_source = gzencode($_tpl_saved, $template_object->compression_level);
                $_tpl_saved = "";
            }
        }
    } else {
        if (!$template_object->caching && !get_cfg_var('zlib.output_compression')) {
            $_tpl_saved .= $tpl_source . "\n<!-- normal saved output -->\n\n";
            $tpl_source = "";
            if ($template_object->send_now == 1) {
                $tpl_source = $_tpl_saved;
                $_tpl_saved = "";
            }
        }
    }
    if ($template_object->send_now == 1 && $template_object->enable_gzip == 1) {
        if ($gzipped == 1) {
            header("Content-Encoding: gzip");
            header("Content-Length: " . strlen($tpl_source));
        }
    }
    return $tpl_source;
}
开发者ID:20000Hz,项目名称:bak-letvs,代码行数:32,代码来源:outputfilter.gzip.php

示例10: setEncodingToUse

 private function setEncodingToUse($encodingUsed)
 {
     switch ($encodingUsed) {
         case 'identity':
             $this->compressFunction = function ($data) {
                 return $data;
             };
             $this->outputResponse->removeHeader('Content-Encoding');
             break;
         case 'x-gzip':
         case 'gzip':
             $this->compressFunction = function ($data) {
                 return gzencode($data);
             };
             $this->outputResponse->setHeader('Content-Encoding', 'gzip');
             break;
         case 'deflate':
             $this->compressFunction = function ($data) {
                 return zlib_encode($data, 15);
             };
             $this->outputResponse->setHeader('Content-Encoding', 'deflate');
             break;
         case 'bzip2':
             $this->compressFunction = function ($data) {
                 return bzcompress($data);
             };
             $this->outputResponse->setHeader('Content-Encoding', 'bzip2');
             break;
         default:
             throw new \LogicException('Unknown encoding');
     }
 }
开发者ID:tomaka17,项目名称:niysu,代码行数:32,代码来源:ContentEncodingResponseFilter.php

示例11: set

 /**
  * Saves data in the cache.
  *
  * @param string $entryIdentifier An identifier for this specific cache entry
  * @param string $data The data to be stored
  * @param array $tags Tags to associate with this cache entry. If the backend does not support tags, this option can be ignored.
  * @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
  *
  * @return void
  * @throws \TYPO3\CMS\Core\Cache\Exception if no cache frontend has been set.
  * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException if the data is not a string
  */
 public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
 {
     $databaseData = ['created' => $GLOBALS['EXEC_TIME'], 'expires' => $GLOBALS['EXEC_TIME'] + $this->getRealLifetime($lifetime)];
     if (in_array('explanation', $tags)) {
         $databaseData['explanation'] = $data;
         parent::set($entryIdentifier, serialize($databaseData), $tags, $lifetime);
         return;
     }
     // call set in front of the generation, because the set method
     // of the DB backend also call remove
     parent::set($entryIdentifier, serialize($databaseData), $tags, $lifetime);
     $fileName = $this->getCacheFilename($entryIdentifier);
     $cacheDir = PathUtility::pathinfo($fileName, PATHINFO_DIRNAME);
     if (!is_dir($cacheDir)) {
         GeneralUtility::mkdir_deep($cacheDir);
     }
     // normal
     GeneralUtility::writeFile($fileName, $data);
     // gz
     if ($this->configuration->get('enableStaticFileCompression')) {
         $contentGzip = gzencode($data, $this->getCompressionLevel());
         if ($contentGzip) {
             GeneralUtility::writeFile($fileName . '.gz', $contentGzip);
         }
     }
     // htaccess
     $this->writeHtAccessFile($fileName, $lifetime);
 }
开发者ID:qbus-agentur,项目名称:nc_staticfilecache,代码行数:40,代码来源:StaticFileBackend.php

示例12: create

 public function create($paths, $filename = FALSE)
 {
     $archive = new Archive('tar');
     foreach ($paths as $set) {
         $archive->add($set[0], $set[1]);
     }
     $gzfile = gzencode($archive->create());
     if ($filename == FALSE) {
         return $gzfile;
     }
     if (substr($filename, -7) !== '.tar.gz') {
         // Append tar extension
         $filename .= '.tar.gz';
     }
     // Create the file in binary write mode
     $file = fopen($filename, 'wb');
     // Lock the file
     flock($file, LOCK_EX);
     // Write the tar file
     $return = fwrite($file, $gzfile);
     // Unlock the file
     flock($file, LOCK_UN);
     // Close the file
     fclose($file);
     return (bool) $return;
 }
开发者ID:darkcolonist,项目名称:kohana234-doctrine115,代码行数:26,代码来源:Gzip.php

示例13: write_to_file

function write_to_file($filename, $stream_id, $content)
{
    global $GLOBAL_CRON;
    $file_ext = substr($filename, strrpos($filename, '.') + 1);
    switch ($file_ext) {
        case 'gz':
            $string = gzencode($content, 9);
            break;
        case 'bz2':
            $string = bzcompress($content, 9);
            break;
        default:
            $string = $content;
            break;
    }
    flush();
    if (!$GLOBAL_CRON) {
        echo $string;
    } else {
        echo "file " . $filename . " " . strlen($string) . "\n";
    }
    if ($stream_id) {
        return fwrite($stream_id, $string);
    }
}
开发者ID:rabbit-source,项目名称:setbook.ru,代码行数:25,代码来源:pricelist.php

示例14: cssTemplate

function cssTemplate($cssFileName)
{
    global $developmode;
    $fName = substr($cssFileName, 0, strlen($cssFileName) - 4);
    $file = "cache/css/" . $fName . ".gcss";
    $dir = dirname($file);
    $cssfile = "css/{$fName}.css";
    if (!file_exists($dir)) {
        mkdir($dir, 0777, true);
    }
    if (!file_exists($file) || $developmode) {
        $fp = fopen($cssfile, 'r');
        $fz = filesize($cssfile);
        if ($fz) {
            $theData = fread($fp, $fz);
            $patterns = array("/\\/\\*[^*]*?\\*\\//", "/\n/", "/    /");
            $replacements = array("", "", "");
            $theData = preg_replace($patterns, $replacements, $theData);
        } else {
            $theData = "";
        }
        fclose($fp);
        writeToFile($file, gzencode($theData, 9));
        chmod($file, 0777);
    }
    echo "<link href=\"include/component/css.php?f={$fName}\" rel=\"stylesheet\" type=\"text/css\"/>";
}
开发者ID:qichangjun,项目名称:HTMLLearn,代码行数:27,代码来源:template.php

示例15: _generateContent

 protected function _generateContent($code)
 {
     $url = $this->getVersionUrl();
     $type = $this->has('type') ? $this->get('type') : 'echo';
     if ($this->has('gzip_static_dir')) {
         $zlevel = $this->has('gzip_level') ? $this->get('gzip_level') : 3;
         $file_source = lmbFs::normalizePath($this->get('gzip_static_dir'), lmbFs::UNIX) . '/' . str_replace('/', '-', lmbFs::normalizePath($this->getFileUrl(), lmbFs::UNIX));
         lmbFs::cp($this->getFilePath(), $this->getRootDir() . '/' . $file_source);
         $file_gz = $file_source . '.gz';
         lmbFs::safeWrite($this->getRootDir() . '/' . $file_gz, gzencode(file_get_contents($this->getFilePath()), $zlevel, FORCE_DEFLATE));
         $url = $this->addVersion($file_source);
     }
     switch ($type) {
         case 'echo':
             if ($this->has('to_var')) {
                 $code->writePhp($this->get('to_var') . ' = \'' . addslashes($url) . '\';');
             } else {
                 $code->writeHTML(htmlspecialchars($url, 3));
             }
             break;
         case 'js':
             $code->writeHTML('<script type="text/javascript" src="' . htmlspecialchars($url, 3) . '" ></script>');
             break;
         case 'css':
             $code->writeHTML('<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($url, 3) . '" />');
             break;
         default:
             throw new lmbMacroException('Unknown type ' . $type);
     }
 }
开发者ID:snowjobgit,项目名称:limb,代码行数:30,代码来源:file_version.tag.php


注:本文中的gzencode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。