public function space($srv) { $data = []; switch ($srv) { case 'local_server': $space = disk_free_space('/'); break; default: $space = StorageServer::getEmptySpace($srv); break; } if ($space !== null) { $data['error'] = null; } else { $data['error'] = "Erreur"; } $data['empty_space'] = $space; return new JsonResponse($data); //shell_exec('ssh dreamvids@stor1.dreamvids.fr "df -h"'); }
if (!isset($argv)) { exit; } if (count($argv) >= 4 && count($argv) <= 5) { $type = $argv[2]; $media = $argv[3]; $quality = $argv[4]; switch ($type) { case 'video': $splited = explode('/', $media); $filename = $splited[count($splited) - 1]; $channelId = $splited[count($splited) - 2]; $resolution = $quality == 'hd' ? '1280x720p' : '640x360p'; $url = StorageServer::backup($filename . '_' . $resolution . '.mp4', $channelId, true); $url = StorageServer::backup($filename . '_' . $resolution . '.webm', $channelId, true); StorageServer::unlockFreestServer(); break; case 'live-record': $input = $liveRecordingsSource . $media . '.' . $liveRecordingsSourceExt; $output = $liveRecordingsDestination . $media . '-live.mp4'; if (file_exists($input) && file_exists($liveRecordingsDestination)) { $commandOut = array(); $exit_code = -1; exec('ffmpeg -y -i ' . escapeshellarg($input) . ' -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 ' . escapeshellarg($output), $output, $exit_code); if ($exit_code == 0) { liveRecordConvertedCallback($media); } } break; } } else {
public static function getFreestServer() { $serv = json_decode(file_get_contents(CACHE . self::$filepath)); return $serv->id != 0 ? StorageServer::find($serv->id) : false; }
public static function upload($file, $type, $fileId, $channelId, $default = '', $backup = false) { if (!file_exists(ROOT . 'uploads/')) { mkdir(ROOT . 'uploads'); } if (!file_exists(ROOT . 'uploads/' . $channelId . '/')) { mkdir(ROOT . 'uploads/' . $channelId); } if ($file['name'] != '') { $name = $file['name']; $ext = explode('.', $name); $ext = $ext[count($ext) - 1]; switch ($type) { case 'vid': if (in_array(strtolower($ext), array('webm', 'mp4', 'm4a', 'mpg', 'mpeg', '3gp', '3g2', 'asf', 'wma', 'mov', 'avi', 'wmv', 'ogg', 'ogv', 'flv', 'mkv'))) { $path = 'uploads/' . $channelId . '/' . $fileId . '.' . $ext; move_uploaded_file($file['tmp_name'], ROOT . $path); $duration = self::getVideoDuration(ROOT . $path); StorageServer::lockFreestServer(); self::convert(ROOT . $path); $serv = StorageServer::getFreestServer(); return array($serv->address . $path, $duration); } break; case 'img': if (in_array(strtolower($ext), array('jpeg', 'jpg', 'png', 'gif', 'tiff', 'svg'))) { $path = 'uploads/' . $channelId . '/' . $fileId . '.' . $ext; move_uploaded_file($file['tmp_name'], ROOT . $path); if ($backup) { StorageServer::backup($fileId . '.' . $ext, $channelId); } return WEBROOT . $path . '?' . time(); } break; } } return $default; }
<?php if (!StorageServer::isFreestServerLocked()) { $serv = StorageServer::setFreestServer(); file_put_contents(CACHE . 'server.json', json_encode(array('in_use' => 0, 'id' => $serv))); }