Esempio n. 1
0
 /**
  * Deletes vwvr clip
  *
  * @param array $params
  * @return array
  */
 public function ajaxDeleteClip($params)
 {
     $clipId = $params['clipId'];
     $ownerId = $this->clipService->findClipOwner($clipId);
     $isOwner = OW::getUser()->isAuthorized('vwvr', 'add', $ownerId);
     $isModerator = OW::getUser()->isAuthorized('vwvr');
     if (!$isOwner && !$isModerator) {
         throw new Redirect404Exception();
         return;
     }
     // find room_name
     $clipRec = $this->clipService->findClipById($clipId);
     $clipName = $clipRec->title . $clipRec->recordingId;
     if ($clipName) {
         // delete recorded file from recordPath
         $config = OW::getConfig();
         $recordPath = $config->getValue('vwvr', 'recordPath');
         if (file_exists($fileRecordPath = $recordPath . "/" . $clipName . ".flv")) {
             unlink($fileRecordPath);
         }
         if (file_exists($fileRecordPath = $recordPath . "/" . $clipName . ".mp4")) {
             unlink($fileRecordPath);
         }
         // delete recorded file from streams and recordings folder
         $dirname = 'streams';
         if (file_exists('../../' . $dirname)) {
             $dir = '../../' . $dirname;
         } elseif (file_exists('../../../' . $dirname)) {
             $dir = '../../../' . $dirname;
         } elseif (file_exists('../../../../' . $dirname)) {
             $dir = '../../../../' . $dirname;
         } elseif (file_exists('../../../../../' . $dirname)) {
             $dir = '../../../../../' . $dirname;
         } elseif (file_exists('../../../../../../' . $dirname)) {
             $dir = '../../../../../../' . $dirname;
         }
         // $streamsPath = realpath($dir);
         $streamsPath = realpath("../" . $dir);
         // delete file if exists
         if (file_exists($fileStreamsPath = $streamsPath . "/streams/" . $clipName . ".flv")) {
             unlink($fileStreamsPath);
         }
         if (file_exists($fileStreamsPath = $streamsPath . "/streams/" . $clipName . ".key")) {
             unlink($fileStreamsPath);
         }
         if (file_exists($fileStreamsPath = $streamsPath . "/streams/" . $clipName . ".meta")) {
             unlink($fileStreamsPath);
         }
         // delete file from recordings directory
         if (file_exists($fileRecordings = OW_DIR_ROOT . "ow_plugins/vwvideorecorder/vr/recordings/" . $clipName . ".vwr")) {
             unlink($fileRecordings);
         }
     }
     $delResult = $this->clipService->deleteClip($clipId);
     if ($delResult) {
         $return = array('result' => true, 'msg' => OW::getLanguage()->text('vwvr', 'clip_deleted'), 'url' => OW_Router::getInstance()->urlForRoute('vwvr_vwview_list_vr'));
     } else {
         $return = array('result' => false, 'error' => OW::getLanguage()->text('vwvr', 'clip_not_deleted'));
     }
     return $return;
 }