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


PHP kString::getCommonPrefix方法代码示例

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


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

示例1: getAcl

 protected function getAcl($baseUrl, array $urls)
 {
     require_once dirname(__FILE__) . '/../../../../../../infra/general/kString.class.php';
     // strip the filenames of all urls
     foreach ($urls as &$url) {
         $slashPos = strrpos($url, '/');
         if ($slashPos !== false) {
             $url = substr($url, 0, $slashPos + 1);
         }
     }
     $acl = kString::getCommonPrefix($urls);
     // the first comma in csmil denotes the beginning of the non-common URL part
     $commaPos = strpos($acl, ',');
     if ($commaPos !== false) {
         $acl = substr($acl, 0, $commaPos);
     }
     // if the base url has a port, remove it
     $parsedUrl = parse_url($baseUrl);
     if (isset($parsedUrl['port'])) {
         $baseUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'];
         if (isset($parsedUrl['path'])) {
             $baseUrl .= $parsedUrl['path'];
         }
     }
     $acl = $baseUrl . $acl . '*';
     return $acl;
 }
开发者ID:DBezemer,项目名称:server,代码行数:27,代码来源:kCloudFrontUrlTokenizer.php

示例2: getAcl

 protected function getAcl($baseUrl, array $urls)
 {
     require_once dirname(__FILE__) . '/../../../../../../infra/general/kString.class.php';
     // strip the filenames of all urls
     foreach ($urls as &$url) {
         $slashPos = strrpos($url, '/');
         if ($slashPos !== false) {
             $url = substr($url, 0, $slashPos + 1);
         }
     }
     $acl = kString::getCommonPrefix($urls);
     // the first comma in csmil denotes the beginning of the non-common URL part
     $commaPos = strpos($acl, ',');
     if ($commaPos !== false) {
         $acl = substr($acl, 0, $commaPos);
     }
     $acl = $baseUrl . $acl . '*';
     return $acl;
 }
开发者ID:kubrickfr,项目名称:server,代码行数:19,代码来源:kCloudFrontUrlTokenizer.php

示例3: generateMultiUrl

 protected static function generateMultiUrl(array $flavors)
 {
     $urls = array();
     foreach ($flavors as $flavor) {
         $urls[] = $flavor['url'];
     }
     $urls = array_unique($urls);
     if (count($urls) == 1) {
         $baseUrl = reset($urls);
         return '/' . ltrim($baseUrl, '/');
     }
     $prefix = kString::getCommonPrefix($urls);
     $prefixLen = strlen($prefix);
     $postfix = kString::getCommonPostfix($urls);
     $postfixLen = strlen($postfix);
     $middlePart = ',';
     foreach ($urls as $url) {
         $middlePart .= substr($url, $prefixLen, strlen($url) - $prefixLen - $postfixLen) . ',';
     }
     $baseUrl = $prefix . $middlePart . $postfix;
     return '/' . ltrim($baseUrl, '/') . '.urlset';
 }
开发者ID:DBezemer,项目名称:server,代码行数:22,代码来源:VodPackagerDeliveryUtils.php

示例4: tokenizeMultiUrls

 /**
  * @param string $baseUrl
  * @param array $flavors
  */
 public function tokenizeMultiUrls(&$baseUrl, &$flavors)
 {
     if ($this->usePrefix) {
         //in case of a cached-in tokenizer - need to require bootstrap
         require_once dirname(__FILE__) . '/../../../../../../' . 'infra/general/kString.class.php';
         $strings = array();
         foreach ($flavors as $flavor) {
             $url = $flavor["url"];
             if (substr($url, 0, 4) == "mp4:") {
                 $url = substr($url, 4);
             }
             $strings[] = $url;
         }
         $prefix = kString::getCommonPrefix($strings);
         $pos = strrpos($prefix, "/");
         if ($pos) {
             //include slash sign in prefix substr
             $pos++;
             $prefix = substr($prefix, 0, $pos);
         }
     } else {
         $prefix = "";
         foreach ($flavors as $flavor) {
             $url = $flavor["url"];
             if (substr($url, 0, 4) == "mp4:") {
                 $url = substr($url, 4);
             }
             $prefix = $prefix . $url . ";";
         }
     }
     $factory = new StreamTokenFactory();
     $token = $factory->getToken($this->type, $prefix, null, $this->profile, $this->key, null, $this->window, null, null, null);
     $auth = "?auth=" . $token->getToken() . "&aifp={$this->aifp}&slist={$prefix}";
     $baseUrl .= $auth;
     foreach ($flavors as &$flavor) {
         $url = $flavor["url"];
         $flavor["url"] = $url . $auth;
     }
 }
开发者ID:DBezemer,项目名称:server,代码行数:43,代码来源:kAkamaiRtmpUrlTokenizer.php

示例5: generateMultiUrl

 protected static function generateMultiUrl(array $flavors, entry $entry)
 {
     $urls = array();
     foreach ($flavors as $flavor) {
         $urls[] = $flavor['url'];
     }
     $urls = array_unique($urls);
     if (count($urls) == 1) {
         $baseUrl = reset($urls);
         return '/' . ltrim($baseUrl, '/');
     }
     $prefix = kString::getCommonPrefix($urls);
     $postfix = kString::getCommonPostfix($urls);
     if ($entry->getType() == entryType::PLAYLIST) {
         // in case of a playlist, need to merge the flavor params of the urls
         // instead of using a urlset, since nginx-vod does not support urlsets of
         // non-trivial mapping responses.
         // so instead of building:
         //		/p/123/serveFlavor/entryId/0_abc/flavorParamIds/100,1,2,3,/forceproxy/true/name/a.mp4.urlset
         // we build:
         //		/p/123/serveFlavor/entryId/0_abc/flavorParamIds/1001,1002,1003/forceproxy/true/name/a.mp4.urlset
         $prefix = substr($prefix, 0, strrpos($prefix, '/') + 1);
         $postfix = substr($postfix, strpos($postfix, '/'));
     }
     $prefixLen = strlen($prefix);
     $postfixLen = strlen($postfix);
     $middlePart = ',';
     foreach ($urls as $url) {
         $middlePart .= substr($url, $prefixLen, strlen($url) - $prefixLen - $postfixLen) . ',';
     }
     if ($entry->getType() == entryType::PLAYLIST && strpos($middlePart, '/') === false) {
         $middlePart = rtrim(ltrim($middlePart, ','), ',');
         $result = $prefix . $middlePart . $postfix;
     } else {
         $result = $prefix . $middlePart . $postfix . '.urlset';
     }
     return '/' . ltrim($result, '/');
 }
开发者ID:wzur,项目名称:server,代码行数:38,代码来源:VodPackagerDeliveryUtils.php

示例6: getAcl

 /**
  * @param array $urls
  * @return string
  */
 protected function getAcl(array $urls)
 {
     require_once dirname(__FILE__) . '/../../../../../../infra/general/kString.class.php';
     $acl = kString::getCommonPrefix($urls);
     // the first comma in csmil denotes the beginning of the non-common URL part
     $commaPos = strpos($acl, ',');
     if ($commaPos !== false) {
         $acl = substr($acl, 0, $commaPos);
     }
     // don't sign the manifest file name when playing HLS/HDS via AkamaiHD
     $postfixes = $this->customPostfixes ? explode(',', $this->customPostfixes) : array('/master.m3u8', '/manifest.f4m');
     foreach ($postfixes as $postfix) {
         if (substr($acl, -strlen($postfix)) == $postfix) {
             $acl = substr($acl, 0, -strlen($postfix));
         }
     }
     if (!$acl) {
         return false;
     }
     $acl .= $this->aclPostfix;
     return $acl;
 }
开发者ID:DBezemer,项目名称:server,代码行数:26,代码来源:kAkamaiSecureHDUrlTokenizer.php


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