當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Horde::webServerID方法代碼示例

本文整理匯總了PHP中Horde::webServerID方法的典型用法代碼示例。如果您正苦於以下問題:PHP Horde::webServerID方法的具體用法?PHP Horde::webServerID怎麽用?PHP Horde::webServerID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Horde的用法示例。


在下文中一共展示了Horde::webServerID方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: downloadUrl

 /**
  * Returns a URL to be used for downloading, that takes into account any
  * special browser quirks (i.e. IE's broken filename handling).
  *
  * @param string $filename  The filename of the download data.
  * @param array $params     Any additional parameters needed.
  * @param string $url       The URL to alter. If none passed in, will use
  *                          the file 'view.php' located in the current
  *                          module's base directory.
  *
  * @return string  The download URL.
  */
 function downloadUrl($filename, $params = array(), $url = null)
 {
     global $browser;
     $horde_url = false;
     if (is_null($url)) {
         global $registry;
         $url = Util::addParameter(Horde::url($registry->get('webroot', 'horde') . '/services/download/'), 'module', $registry->getApp());
         $horde_url = true;
     }
     /* Add parameters. */
     if (!is_null($params)) {
         $url = Util::addParameter($url, $params);
     }
     /* If we are using the default Horde download link, add the
      * filename to the end of the URL. Although not necessary for
      * many browsers, this should allow every browser to download
      * correctly. */
     if ($horde_url) {
         $url = Util::addParameter($url, 'fn', '/' . rawurlencode($filename));
     } elseif ($browser->hasQuirk('break_disposition_filename')) {
         /* Some browsers will only obtain the filename correctly
          * if the extension is the last argument in the query
          * string and rest of the filename appears in the
          * PATH_INFO element. */
         $filename = rawurlencode($filename);
         /* Get the webserver ID. */
         $server = Horde::webServerID();
         /* Get the name and extension of the file.  Apache 2 does
          * NOT support PATH_INFO information being passed to the
          * PHP module by default, so disable that
          * functionality. */
         if ($server != 'apache2') {
             if ($pos = strrpos($filename, '.')) {
                 $name = '/' . preg_replace('/\\./', '%2E', substr($filename, 0, $pos));
                 $ext = substr($filename, $pos);
             } else {
                 $name = '/' . $filename;
                 $ext = '';
             }
             /* Enter the PATH_INFO information. */
             if ($pos = strpos($url, '?')) {
                 $url = substr($url, 0, $pos) . $name . substr($url, $pos);
             } else {
                 $url .= $name;
             }
         }
         /* Append the extension, if it exists. */
         if ($server == 'apache2' || !empty($ext)) {
             $url = Util::addParameter($url, 'fn_ext', '/' . $filename);
         }
     }
     return $url;
 }
開發者ID:justinlyon,項目名稱:scc,代碼行數:65,代碼來源:Horde.php


注:本文中的Horde::webServerID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。