astroport-webui/functions.php

92 lines
1.5 KiB
PHP

<?php
function getCollectionType ($filename) {
switch (substr($filename, 0, 1)) {
case 'F': return 'Films';
case 'Y': return 'Youtube';
}
}
function pingFile ($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
//curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return ($httpcode>=200 && $httpcode<300);
}
function guessTypeFromFilename ($filename) {
$ext = substr($filename, (strrpos($filename, '.') + 1));
switch ($ext) {
case 'mkv':
$type = 'video/mkv';
break;
case 'flv':
$type = 'video/flv';
break;
case 'avi':
$type = 'video/x-msvideo';
break;
case 'webm':
$type = 'video/webm';
break;
case 'mkv':
$type = 'video/x-matroska';
break;
case '3gp':
$type = 'video/3gp';
break;
case 'ogv':
$type = 'video/ogv';
break;
default:
$type = 'video/mp4';
break;
}
return $type;
}
function astroport_urlencode ($str) {
$str = str_replace('%', '%25', $str);
$str = str_replace('#', '%23', $str);
$str = str_replace('\'', '%27', $str);
$str = str_replace('"', '%22', $str);
return $str;
}
function quickfix_getYoutubeIdFromIpfsFileName ($name) {
return substr($name, 0, 11);
}
function quickfix_getVideoNameFromIpfsFileName ($name) {
$name = substr($name, 12);
$name = substr($name, 0, strrpos($name, '.'));
return $name;
}