if (!isset($options['raw']) && !isset($options['curl'])) { $params['format'] = '3'; } # PHP // renew all ks'es if (!isset($options['no-renew'])) { $renewedSessions = array(); foreach ($params as $key => &$value) { if ($key != 'ks' && !preg_match('/[\\d]+:ks/', $key)) { continue; } if (isset($renewedSessions[$value])) { $value = $renewedSessions[$value]; continue; } $renewedKs = KalturaSession::extendKs($value); if (!$renewedKs) { continue; } $renewedSessions[$value] = $renewedKs; $value = $renewedKs; } } // get the service url if (isset($options['url']) && is_string($options['url'])) { $serviceUrl = $options['url']; } else { $serviceUrl = isset($config['apiHost']) ? $config['apiHost'] : 'www.kaltura.com'; } if (strpos($serviceUrl, '://') === false) { if (isset($options['https'])) {
// =================================================================================================== require_once dirname(__FILE__) . '/lib/KalturaCommandLineParser.php'; require_once dirname(__FILE__) . '/lib/KalturaSession.php'; $commandLineSwitches = array(array(KalturaCommandLineParser::SWITCH_NO_VALUE, 'b', 'bare', 'Print only the KS itself'), array(KalturaCommandLineParser::SWITCH_REQUIRES_VALUE, 'e', 'expiry', 'Session expiry (seconds)')); // parse command line $options = KalturaCommandLineParser::parseArguments($commandLineSwitches); $arguments = KalturaCommandLineParser::stripCommandLineSwitches($commandLineSwitches, $argv); if (!$arguments) { $usage = "Usage: renewKs [switches] <ks>\nOptions:\n"; $usage .= KalturaCommandLineParser::getArgumentsUsage($commandLineSwitches); die($usage); } $input = $arguments[0]; $ks = $input; $expiry = isset($options['expiry']) ? $options['expiry'] : 86400; $patterns = array('/\\/ks\\/([a-zA-Z0-9+_\\-]+=*)/', '/&ks=([a-zA-Z0-9+\\/_\\-]+=*)/', '/\\?ks=([a-zA-Z0-9+\\/_\\-]+=*)/'); foreach ($patterns as $pattern) { preg_match_all($pattern, $input, $matches); if ($matches[1]) { $ks = reset($matches[1]); break; } } KalturaSecretRepository::init(); if (!isset($options['bare'])) { echo "ks\t"; } echo str_replace($ks, KalturaSession::extendKs($ks, $expiry), $input); if (!isset($options['bare'])) { echo "\n"; }