if (count($aFiles) > 0) { for ($i = 0; $i < count($aFiles); $i++) { $bResult = deleteVideo($aFiles[$i]); } } $sContents = parseXml($aXmlTemplates['result'], "", SUCCESS_VAL); } break; /** * Upload user's file */ /** * Upload user's file */ case 'uploadFile': $sContents = uploadVideo($_FILES['Filedata']['tmp_name'], $sId); $sContentsType = "other"; break; case 'initFile': $sContents = initVideo($sId, $sTitle, $sCategory, $sTags, $sDesc); $sContentsType = "other"; break; case 'publishRecordedFile': $sContents = publishRecordedVideo($sId, $sTitle, $sCategory, $sTags, $sDesc); $sContentsType = "other"; break; case 'removeTempFiles': deleteTempFiles($sId); break; case 'screenshot': $sPlayFile = $sFilesPath . $sId . (file_exists($sFilesPath . $sId . M4V_EXTENSION) ? M4V_EXTENSION : FLV_EXTENSION);
function _shareVideo($sFilePath, $isMoveUploadedFile = true, $sImageFilePath = '', $sRealFilename = '') { $sAuthorCheck = $this->checkAuthorBeforeAdd(); if (!$this->_iOwnerId) { return false; } if (!$this->oModule->_iProfileId) { $this->oModule->_iProfileId = $this->_iOwnerId; } if (empty($sAuthorCheck) && $this->oModule->isAllowedAdd()) { $sFilePath = process_db_input($sFilePath, BX_TAGS_STRIP, BX_SLASHES_NO_ACTION); $sImageFilePath = mb_strlen($sImageFilePath) > 0 ? process_db_input($sImageFilePath, BX_TAGS_STRIP, BX_SLASHES_NO_ACTION) : ''; if (mb_strlen($sRealFilename) > 0) { $sRealFilename = process_db_input($sRealFilename, BX_TAGS_STRIP); $iPointPos = strrpos($sRealFilename, '.'); $sExt = substr($sRealFilename, $iPointPos + 1); if (!$this->oModule->_oConfig->checkAllowedExts(strtolower($sExt))) { return $this->getVideoAddError(); } $this->sTempFilename = substr($sRealFilename, 0, $iPointPos); } $sROwnerID = $this->_iOwnerId ? $this->_iOwnerId : $this->_getAuthorId(); $iMID = uploadVideo($sFilePath, $sROwnerID, $isMoveUploadedFile, $sImageFilePath, $sRealFilename); if ($iMID > 0) { $this->addObjectToAlbum($this->oModule->oAlbums, $_POST['extra_param_album'], $iMID, false); $this->oModule->isAllowedAdd(true, true); $aDefault = array('title' => $this->sTempFilename, 'description' => $this->sTempFilename); return $this->GenSendFileInfoForm($iMID, $aDefault); } else { return $this->getVideoAddError(); } } else { return $sAuthorCheck; } }
/** * @return array with the following keys: * - id: uploaded file ID if file was successfully uploaded * - error: error message if file wasn't successfully uploaded */ function performUpload($sFilePath, $sRealFilename = '', $aInfo = array(), $isMoveUploadedFile = true) { $iOwner = $this->_getAuthorId(); if ($this->_iOwnerId) { $iOwner = $this->oModule->_iProfileId = $this->_iOwnerId; } if (!$sRealFilename) { $sRealFilename = pathinfo($sFilePath, PATHINFO_BASENAME); } // basic checking before upload if ($this->checkAuthorBeforeAdd()) { return array('error' => _t('_LOGIN_REQUIRED_AE1')); } if (!$this->oModule->_oConfig->checkAllowedExtsByFilename($sRealFilename)) { return array('error' => _t('_sys_txt_wrong_file_extension')); } if (!$this->oModule->isAllowedAdd()) { return array('error' => _t('_Access denied')); } // perform upload $GLOBALS['sModule'] = 'video'; include $GLOBALS['sModulesPath'] . $GLOBALS['sModule'] . '/inc/header.inc.php'; $this->sTempFilename = pathinfo($sRealFilename, PATHINFO_FILENAME); if (!($iMID = uploadVideo(process_db_input($sFilePath), $iOwner, $isMoveUploadedFile, '', process_db_input($sRealFilename), $this->oModule->_oConfig->aFilesConfig))) { return array('error' => _t('_sys_txt_upload_failed')); } // update uploaded file info if needed if ($aInfo) { foreach (array('title', 'categories', 'tags', 'desc') as $sKey) { $aInfo[$sKey] = isset($aInfo[$sKey]) ? $aInfo[$sKey] : ''; } $this->initFile($iMID, $aInfo['title'], $aInfo['categories'], $aInfo['tags'], $aInfo['desc']); } // add uploaded file to the album $sAlbum = empty($_POST['extra_param_album']) ? getParam('sys_album_default_name') : $_POST['extra_param_album']; $aAlbumParams = isset($_POST['extra_param_albumPrivacy']) ? array('privacy' => (int) $_POST['extra_param_albumPrivacy']) : array(); $this->addObjectToAlbum($this->oModule->oAlbums, !empty($aInfo['album']) ? $aInfo['album'] : $sAlbum, $iMID, false, $iOwner, $aAlbumParams); // perfom action $this->oModule->isAllowedAdd(true, true); // return uploaded file ID return array('id' => $iMID); }
function _shareVideo($sFilePath, $isMoveUploadedFile = true, $sImageFilePath = '', $sRealFilename = '') { $sAuthorCheck = $this->checkAuthorBeforeAdd(); if (!$this->_iOwnerId) { return false; } if (!$this->oModule->_iProfileId) { $this->oModule->_iProfileId = $this->_iOwnerId; } if (empty($sAuthorCheck) && $this->oModule->isAllowedAdd()) { $sFilePath = process_db_input($sFilePath, BX_TAGS_STRIP, BX_SLASHES_NO_ACTION); $sImageFilePath = mb_strlen($sImageFilePath) > 0 ? process_db_input($sImageFilePath, BX_TAGS_STRIP, BX_SLASHES_NO_ACTION) : ''; if (!empty($sRealFilename)) { $iPointPos = strrpos($sRealFilename, '.'); $sExt = substr($sRealFilename, $iPointPos + 1); if (!$this->oModule->_oConfig->checkAllowedExts(strtolower($sExt))) { return $this->getVideoAddError(); } $this->sTempFilename = substr($sRealFilename, 0, $iPointPos); } $iFileSize = filesize($sFilePath); if (!$iFileSize || $iFileSize > $this->iMaxFilesize) { return $this->getVideoAddError(_t('_' . $this->oModule->_oConfig->getMainPrefix() . '_size_error', _t_format_size($this->iMaxFilesize))); } $sROwnerID = $this->_iOwnerId ? $this->_iOwnerId : $this->_getAuthorId(); $iMID = uploadVideo($sFilePath, $sROwnerID, $isMoveUploadedFile, $sImageFilePath, process_db_input($sRealFilename, BX_TAGS_STRIP)); if ($iMID > 0) { $sAlbum = $_POST['extra_param_album']; $aAlbumParams = isset($_POST['extra_param_albumPrivacy']) ? array('privacy' => (int) $_POST['extra_param_albumPrivacy']) : array(); $this->addObjectToAlbum($this->oModule->oAlbums, $sAlbum, $iMID, false, $sROwnerID, $aAlbumParams); $this->oModule->isAllowedAdd(true, true); $aDefault = array('title' => $this->sTempFilename); return $this->GenSendFileInfoForm($iMID, $aDefault); } else { return $this->getVideoAddError(); } } else { return $sAuthorCheck; } }