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


PHP Utils::isFunctionDisabled方法代码示例

本文整理汇总了PHP中Grav\Common\Utils::isFunctionDisabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::isFunctionDisabled方法的具体用法?PHP Utils::isFunctionDisabled怎么用?PHP Utils::isFunctionDisabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Grav\Common\Utils的用法示例。


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

示例1: get

 /**
  * Makes a request to the URL by using the preferred method
  * @param  string $uri URL to call
  * @param  array $options An array of parameters for both `curl` and `fopen`
  * @param  callable $callback Either a function or callback in array notation
  * @return string The response of the request
  */
 public static function get($uri = '', $options = [], $callback = null)
 {
     if (!self::isCurlAvailable() && !self::isFopenAvailable()) {
         throw new \RuntimeException('Could not start an HTTP request. `allow_url_open` is disabled and `cURL` is not available');
     }
     // disable time limit if possible to help with slow downloads
     if (!Utils::isFunctionDisabled('set_time_limit') && !ini_get('safe_mode')) {
         set_time_limit(0);
     }
     $options = array_replace_recursive(self::$defaults, $options);
     $method = 'get' . ucfirst(strtolower(self::$method));
     self::$callback = $callback;
     return static::$method($uri, $options, $callback);
 }
开发者ID:krsreenatha,项目名称:grav,代码行数:21,代码来源:Response.php

示例2: get

 /**
  * Makes a request to the URL by using the preferred method
  *
  * @param  string   $uri      URL to call
  * @param  array    $options  An array of parameters for both `curl` and `fopen`
  * @param  callable $callback Either a function or callback in array notation
  *
  * @return string The response of the request
  */
 public static function get($uri = '', $options = [], $callback = null)
 {
     if (!self::isCurlAvailable() && !self::isFopenAvailable()) {
         throw new \RuntimeException('Could not start an HTTP request. `allow_url_open` is disabled and `cURL` is not available');
     }
     // check if this function is available, if so use it to stop any timeouts
     try {
         if (!Utils::isFunctionDisabled('set_time_limit') && !ini_get('safe_mode') && function_exists('set_time_limit')) {
             set_time_limit(0);
         }
     } catch (\Exception $e) {
     }
     $options = array_replace_recursive(self::$defaults, $options);
     $method = 'get' . ucfirst(strtolower(self::$method));
     self::$callback = $callback;
     return static::$method($uri, $options, $callback);
 }
开发者ID:dweelie,项目名称:grav,代码行数:26,代码来源:Response.php

示例3: get

 /**
  * Makes a request to the URL by using the preferred method
  *
  * @param  string   $uri      URL to call
  * @param  array    $options  An array of parameters for both `curl` and `fopen`
  * @param  callable $callback Either a function or callback in array notation
  *
  * @return string The response of the request
  */
 public static function get($uri = '', $options = [], $callback = null)
 {
     if (!self::isCurlAvailable() && !self::isFopenAvailable()) {
         throw new \RuntimeException('Could not start an HTTP request. `allow_url_open` is disabled and `cURL` is not available');
     }
     // check if this function is available, if so use it to stop any timeouts
     try {
         if (!Utils::isFunctionDisabled('set_time_limit') && !ini_get('safe_mode') && function_exists('set_time_limit')) {
             set_time_limit(0);
         }
     } catch (\Exception $e) {
     }
     $config = Grav::instance()['config'];
     $overrides = [];
     // SSL Verify Peer and Proxy Setting
     $settings = ['method' => $config->get('system.gpm.method', self::$method), 'verify_peer' => $config->get('system.gpm.verify_peer', true), 'proxy_url' => $config->get('system.gpm.proxy_url', $config->get('system.proxy_url', false))];
     if (!$settings['verify_peer']) {
         $overrides = array_replace_recursive([], $overrides, ['curl' => [CURLOPT_SSL_VERIFYPEER => $settings['verify_peer']], 'fopen' => ['ssl' => ['verify_peer' => $settings['verify_peer'], 'verify_peer_name' => $settings['verify_peer']]]]);
     }
     // Proxy Setting
     if ($settings['proxy_url']) {
         $proxy = parse_url($settings['proxy_url']);
         $fopen_proxy = ($proxy['scheme'] ?: 'http') . '://' . $proxy['host'] . (isset($proxy['port']) ? ':' . $proxy['port'] : '');
         $overrides = array_replace_recursive([], $overrides, ['curl' => [CURLOPT_PROXY => $proxy['host'], CURLOPT_PROXYTYPE => 'HTTP'], 'fopen' => ['proxy' => $fopen_proxy, 'request_fulluri' => true]]);
         if (isset($proxy['port'])) {
             $overrides['curl'][CURLOPT_PROXYPORT] = $proxy['port'];
         }
         if (isset($proxy['user']) && isset($proxy['pass'])) {
             $fopen_auth = $auth = base64_encode($proxy['user'] . ':' . $proxy['pass']);
             $overrides['curl'][CURLOPT_PROXYUSERPWD] = $proxy['user'] . ':' . $proxy['pass'];
             $overrides['fopen']['header'] = "Proxy-Authorization: Basic {$fopen_auth}";
         }
     }
     $options = array_replace_recursive(self::$defaults, $options, $overrides);
     $method = 'get' . ucfirst(strtolower($settings['method']));
     self::$callback = $callback;
     return static::$method($uri, $options, $callback);
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:47,代码来源:Response.php

示例4: download

 /**
  * Provides the ability to download a file to the browser
  *
  * @param      $file            the full path to the file to be downloaded
  * @param bool $force_download  as opposed to letting browser choose if to download or render
  */
 public static function download($file, $force_download = true)
 {
     if (file_exists($file)) {
         // fire download event
         self::getGrav()->fireEvent('onBeforeDownload', new Event(['file' => $file]));
         $file_parts = pathinfo($file);
         $filesize = filesize($file);
         // check if this function is available, if so use it to stop any timeouts
         try {
             if (!Utils::isFunctionDisabled('set_time_limit') && !ini_get('safe_mode') && function_exists('set_time_limit')) {
                 set_time_limit(0);
             }
         } catch (\Exception $e) {
         }
         ignore_user_abort(false);
         if ($force_download) {
             header('Content-Description: File Transfer');
             header('Content-Type: application/octet-stream');
             header('Content-Disposition: attachment; filename=' . $file_parts['basename']);
             header('Content-Transfer-Encoding: binary');
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Pragma: public');
         } else {
             header("Content-Type: " . Utils::getMimeType($file_parts['extension']));
         }
         header('Content-Length: ' . $filesize);
         // 8kb chunks for now
         $chunk = 8 * 1024;
         $fh = fopen($file, "rb");
         if ($fh === false) {
             return;
         }
         // Repeat reading until EOF
         while (!feof($fh)) {
             echo fread($fh, $chunk);
             ob_flush();
             // flush output
             flush();
         }
         exit;
     }
 }
开发者ID:khanduras,项目名称:grav,代码行数:49,代码来源:Utils.php

示例5: testIsFunctionDisabled

 public function testIsFunctionDisabled()
 {
     $disabledFunctions = explode(',', ini_get('disable_functions'));
     if ($disabledFunctions[0]) {
         $this->assertEquals(Utils::isFunctionDisabled($disabledFunctions[0]), true);
     }
 }
开发者ID:getgrav,项目名称:grav,代码行数:7,代码来源:UtilsTest.php


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