Example #1
0
 function _shareMusic($sFilePath, $isMoveUploadedFile = true, $sRealFilename = '')
 {
     global $sModule;
     $sAuthorCheck = $this->checkAuthorBeforeAdd();
     if (!$this->oModule->_iProfileId) {
         $this->oModule->_iProfileId = $this->_iOwnerId;
     }
     if (empty($sAuthorCheck) && $this->oModule->isAllowedAdd()) {
         $bAutoActive = false;
         $sFilePath = process_db_input($sFilePath, 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->getMusicAddError();
             }
             $this->sTempFilename = substr($sRealFilename, 0, $iPointPos);
             /*
                             if (strtolower($sExt) == 'mp3' && getSettingValue($sModule, "autoApprove") == true)
                                 $bAutoActive = true;*/
         }
         $iFileSize = filesize($sFilePath);
         if (!$iFileSize || $iFileSize > $this->iMaxFilesize) {
             return $this->getMusicAddError(_t('_' . $this->oModule->_oConfig->getMainPrefix() . '_size_error', _t_format_size($this->iMaxFilesize)));
         }
         $sROwnerID = $this->_iOwnerId ? $this->_iOwnerId : $this->_getAuthorId();
         $iMID = uploadMusic($sFilePath, $sROwnerID, process_db_input($sRealFilename, BX_TAGS_STRIP), $isMoveUploadedFile);
         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, $bAutoActive, $sROwnerID, $aAlbumParams);
             $this->oModule->isAllowedAdd(true, true);
             $aDefault = array('title' => $this->sTempFilename);
             return $this->GenSendFileInfoForm($iMID, $aDefault);
         } else {
             return $this->getMusicAddError();
         }
     } else {
         return $sAuthorCheck;
     }
 }
Example #2
0
         if (count($aFiles) > 0) {
             for ($i = 0; $i < count($aFiles); $i++) {
                 $bResult = deleteFile($aFiles[$i]);
             }
         }
         $sContents = parseXml($aXmlTemplates['result'], "", SUCCESS_VAL);
     }
     break;
     /**
      * Upload user's file
      */
 /**
  * Upload user's file
  */
 case 'uploadFile':
     $sContents = uploadMusic($_FILES['Filedata']['tmp_name'], $sId, $sFile);
     $sContentsType = "other";
     break;
 case 'initFile':
     $sContents = initFile($sId, $sTitle, $sCategory, $sTags, $sDesc);
     $sContentsType = "other";
     break;
 case 'publishRecordedFile':
     $sContents = publishRecordedFile($sId, $sTitle, $sCategory, $sTags, $sDesc);
     $sContentsType = "other";
     break;
 case 'removeTempFiles':
     deleteTempMp3s($sId);
     break;
     /**
      * set user's uploaded file time
Example #3
0
 /**
  * @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, $aExtraParams = array())
 {
     $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'] = 'mp3';
     include $GLOBALS['sModulesPath'] . $GLOBALS['sModule'] . '/inc/header.inc.php';
     $this->sTempFilename = pathinfo($sRealFilename, PATHINFO_FILENAME);
     if (!($iMID = uploadMusic(process_db_input($sFilePath), $iOwner, process_db_input($sRealFilename), $isMoveUploadedFile))) {
         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
     $sExt = strtolower(pathinfo($sRealFilename, PATHINFO_EXTENSION));
     $sAlbum = !empty($_POST['extra_param_album']) > 0 ? $_POST['extra_param_album'] : getParam('sys_album_default_name');
     $sAlbum = isset($aInfo['album']) ? $aInfo['album'] : $sAlbum;
     $sAutoActive = $sExt == 'mp3' && getSettingValue($sModule, "autoApprove") == true;
     $this->addObjectToAlbum($this->oModule->oAlbums, $sAlbum, $iMID, $sAutoActive);
     $this->oModule->isAllowedAdd(true, true);
     return array('id' => $iMID);
 }
Example #4
0
 function _shareMusic($sFilePath, $isMoveUploadedFile = true, $sRealFilename = '')
 {
     global $sModule;
     $sAuthorCheck = $this->checkAuthorBeforeAdd();
     if (!$this->oModule->_iProfileId) {
         $this->oModule->_iProfileId = $this->_iOwnerId;
     }
     if (empty($sAuthorCheck) && $this->oModule->isAllowedAdd()) {
         $bAutoActive = false;
         $sFilePath = process_db_input($sFilePath, 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->getMusicAddError();
             }
             $this->sTempFilename = substr($sRealFilename, 0, $iPointPos);
             if (strtolower($sExt) == 'mp3' && getSettingValue($sModule, "autoApprove") == true) {
                 $bAutoActive = true;
             }
         }
         $sROwnerID = $this->_iOwnerId ? $this->_iOwnerId : $this->_getAuthorId();
         $iMID = uploadMusic($sFilePath, $sROwnerID, $sRealFilename, $isMoveUploadedFile);
         if ($iMID > 0) {
             $this->addObjectToAlbum($this->oModule->oAlbums, $_POST['extra_param_album'], $iMID, $bAutoActive);
             $this->oModule->isAllowedAdd(true, true);
             $aDefault = array('title' => $this->sTempFilename, 'description' => $this->sTempFilename);
             return $this->GenSendFileInfoForm($iMID, $aDefault);
         } else {
             return $this->getMusicAddError();
         }
     } else {
         return $sAuthorCheck;
     }
 }