Esempio n. 1
0
 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 : '');
 }
Esempio n. 2
0
 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 : '');
 }