本文整理汇总了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;
}
示例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;
}
示例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';
}
示例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;
}
}
示例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, '/');
}
示例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;
}