astrXbian/www/boris/functions.php

67 lines
1.0 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;
}