To add Highwinds CDN URL tokenization/hashing, please perform the following steps:
1) Add the following function into admin/functions.custom.php
function mechbunny_cdn_hook($array) {
global $hashKey;
global $hashTime;
global $hashZone;
$rrow = $array[0];
$subdir = 'videos/'.$rrow[filename][0] . '/' . $rrow[filename][1] . '/' . $rrow[filename][2] . '/' . $rrow[filename][3] . '/' . $rrow[filename][4] . '/';
$file = $subdir.$array[0][$array[1]];
$config = array(
'zone' => $hashZone, // hwcdn zone hash
'secret' => $hashKey, // secret key
'enabled' => true, // enable cdn urls
'delay' => $hashTime, // delay
);
$mediaobjects=array('mp4','zip','wmv','mov','wav','flv','jpeg','jpg','png','m3u8'); // accepted file formats array for cdn
$path_parts = pathinfo($file);
$extension=$path_parts['extension'];
if (in_array($extension,$mediaobjects) && ($config['enabled'])){
// pre parse to correct common cdn url signing compat issues
while( strpos( ($file=str_replace('//','/',$file)), '//' ) !== false ); // strip out double slashes
$file = str_replace(' ',"%20", $file); // urlencode spaces in file names
if($file[0] != '/'){ $file = '/'.$file.''; } // check and prepend a initial / if not present
$uri = $file;
$disect = pathinfo($uri);
$ttl = time() + (1 * 1 * 1 * $config['delay']);
if ($extension == "m3u8"){
$pathlen = strlen($disect['dirname']);
$message = $disect['dirname'] . "?expires=" . $ttl . "&l=". $pathlen ."&secret=" . $config['secret'];
$digest = md5($message);
$token_value = "?expires=" . $ttl . '&l='. $pathlen .'&token=' . $digest;
$file = 'https://'.$config['zone'] .'.ssl.hwcdn.net'.$file.''.$token_value.'';
}
else {
$urilen = strlen($uri);
$message = $uri . "?expires=" . $ttl . "&l=". $urilen ."&secret=" . $config['secret'];
$digest = md5($message);
$token_value = "?expires=" . $ttl . '&l='. $urilen .'&token=' . $digest;
$file = 'https://'.$config['zone'].'.ssl.hwcdn.net'.$file.''.$token_value.'';
}
return $file;
}
else{
return $file;
}
}
2) Add the following into the admin/config.php file:
$hashFunction = 'mechbunny_cdn_hook';
$hashKey = 'SECRET HASH KEY GOES HERE';
$hashTime = 7200;
$hashZone = "HASH ZONE GOES HERE, FOR INSTANCE: v1234567";
hashZone should be only the first part of the HTTPS URL, so if your HTTPS url is v1234567.ssl.hwcdn.net then you just put v1234567