public function upload() { $app = App::getInstance(); $user_id = SessionManager::getInstance()->getUserID(); if (!empty($_FILES['file']['name'])) { $filename = $_FILES['file']['name']; $file = sprintf("%s/%s", PathUtils::getTmpDir('tmp/uploads'), $filename); $saved = move_uploaded_file($_FILES['file']['tmp_name'], $file); } elseif (!empty($_POST['file']) && !empty($_POST['data'])) { $filename = $_POST['file']; $file = sprintf("%s/%s", PathUtils::getTmpDir('tmp/uploads'), $filename); $data = !empty($_POST['base64']) ? base64_decode($_POST['data']) : $_POST['data']; $saved = file_put_contents($file, $data); } if (!empty($file) & !empty($saved)) { try { $type = PathUtils::getFileType($file); $event = new UploadEvent($user_id, ['file' => $file]); if ($app->dispatch("user_upload_{$type}", $event)) { if ($upload = $event->getURL()) { HttpResponse::getInstance()->display(['url' => $upload], '', true); } } } finally { @unlink($file); } } HttpResponse::getInstance()->displayError("Unable to upload file"); }
/** * @param ActiveModel $project */ public function index($project) { $ytConfig = App::getInstance()->config->getKey(YouTubeWrapper::youtubeKey); $settings = ['api_key' => $ytConfig['api_key'], 'title' => $project->title]; if ($project->public != 'y') { $scope['hidden'] = true; if ($project->user_id != SessionManager::getInstance()->getUserID()) { $project = []; $settings['private'] = true; } } View::forge('ActiveTheme/StockVideoPage.php', ['settings' => json_encode($settings)], $project); }
public function upload($video) { if (!empty($video['url'])) { $ytWrapper = YouTubeWrapper::getInstance(); if ($user_id = SessionManager::getInstance()->getUserID()) { if ($url = $ytWrapper->uploadS3URL($user_id, $video['url'], 'public', $video['title'], $video['description'], $video['category'], $video['keywords'])) { App::getInstance()->dispatch(Swf2VidEvent::USER_UPLOAD_VIDEO, new UserEvent($user_id, array_merge($video, ['upload_url' => $url]))); HttpResponse::getInstance()->display(['url' => $url], '', true); } } } else { throw new UploadError("Video url cannot be empty"); } throw new UploadError("Unable to upload at this time, sorry."); }
public function index($urls) { if ($files = HttpProxy::getInstance()->proxy($urls)) { $app = App::getInstance(); $user_id = SessionManager::getInstance()->getUserID(); foreach ($files as $file) { $event = new UploadEvent($user_id, ['file' => $file['local']]); if ($app->dispatch(UploadEvent::USER_UPLOAD_IMAGE, $event)) { if ($upload = $event->getURL()) { $results[] = ['src' => $file['remote'], 'copy' => $upload]; } } } } HttpResponse::getInstance()->display(!empty($results) ? $results : ''); }
public function index($urls, $width, $height) { if ($images = HttpProxy::getInstance()->proxy($urls)) { $app = App::getInstance(); $user_id = SessionManager::getInstance()->getUserID(); foreach ($images as $image) { $resized = self::resize_image($image['local'], $width ?: 854, $height ?: 480); $event = new UploadEvent($user_id, ['file' => $resized]); if ($app->dispatch(UploadEvent::USER_UPLOAD_IMAGE, $event)) { if ($upload = $event->getURL()) { $results[] = ['src' => $image['remote'], 'copy' => $upload]; } } } } HttpResponse::getInstance()->display(!empty($results) ? $results : ''); }
/** * @return mixed * @throws \Minute\Errors\ConfigError */ public function getUserVideoLevel() { return App::getInstance()->config->getKey(Swf2Vid::swf2vidKey . '/video-level', SessionManager::getInstance()->getMinPaidLevel()); }