コード例 #1
0
ファイル: video_upload.php プロジェクト: qhuit/dcosta
 /**
  * Options page callback
  */
 public function cloudAndDmUploadAction()
 {
     $video_id = $_POST["video_id"];
     check_ajax_referer($video_id . 'pluploadan');
     switch ($_POST['account_name']) {
         case 'cloud':
             $status = wp_handle_upload($_FILES[$video_id . 'async-upload'], array('test_form' => false, 'action' => 'plupload_action'));
             if (!isset($status['error']) && isset($status['file'])) {
                 $info = pathinfo($status['file']);
                 $filesize = filesize($status['file']);
                 try {
                     $obj_dailymotioncloud = new DailymotionCloudOwnMethod($this->usname, $this->appsecret);
                     $media_id = $obj_dailymotioncloud->uploadDailymotionCloudVideo($status['file'], $info['filename']);
                     unlink($status['file']);
                     print str_replace(",", "_", $info['filename']) . '|+|' . $media_id->id . '|+|' . $status['url'] . '|+|' . $this->fileSizeConvert($filesize) . '|+|' . $_POST['account_name'];
                     exit;
                 } catch (Exception $e) {
                     $filename = $info['filename'];
                     unlink($status['file']);
                     error_log($e->getMessage(), 0);
                     error_log($e->getMessage(), 1, "*****@*****.**");
                     die("error|+|{$filename}|+|Failed to transfer on dailymotion cloud");
                 }
             } else {
                 $filename = $info['filename'];
                 die("error|+|{$filename}|+|Failed to open input stream");
                 exit;
             }
             break;
         case 'dailymotion':
             $status = wp_handle_upload($_FILES[$video_id . 'async-upload'], array('test_form' => false, 'action' => 'plupload_action'));
             if (!isset($status['error']) && isset($status['file'])) {
                 $info = pathinfo($status['file']);
                 $filesize = filesize($status['file']);
                 try {
                     $obj_dailymotion = new DailymotionOwnMethod();
                     $media_id = (object) $obj_dailymotion->uploadVideoOnDailymotion($status['file'], $info['filename'], $this->chennelname);
                     unlink($status['file']);
                     print str_replace(",", "_", $info['filename']) . '|+|' . $media_id->id . '|+|' . $status['url'] . '|+|' . $this->fileSizeConvert($filesize) . '|+|' . $_POST['account_name'];
                     exit;
                 } catch (Exception $e) {
                     $filename = $info['filename'];
                     unlink($status['file']);
                     error_log($e->getMessage(), 0);
                     error_log($e->getMessage(), 1, "*****@*****.**");
                     die("error|+|{$filename}|+|Failed to transfer on dailymotion");
                 }
             } else {
                 $filename = $info['filename'];
                 die("error|+|{$filename}|+|Failed to open input stream");
                 exit;
             }
             break;
         default:
             break;
     }
 }