function uploadImage($sUser, $sPwd, $sAlbum, $binImageData, $iDataLength, $sTitle, $sTags, $sDesc)
 {
     if (!($iId = BxDolXMLRPCUtil::checkLogin($sUser, $sPwd))) {
         return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1, "int")), "struct"));
     }
     if (!BxDolXMLRPCMedia::_isMembershipEnabledFor($iIdProfileViewer, 'BX_PHOTOS_ADD', true)) {
         return new xmlrpcval("fail access");
     }
     // write tmp file
     $sTmpFilename = BX_DIRECTORY_PATH_ROOT . "tmp/" . time() . '_' . $iId;
     $f = fopen($sTmpFilename, "wb");
     if (!$f) {
         return new xmlrpcval("fail fopen");
     }
     if (!fwrite($f, $binImageData, (int) $iDataLength)) {
         fclose($f);
         return new xmlrpcval("fail write");
     }
     fclose($f);
     // upload
     $aFileInfo = array();
     $aFileInfo['medTitle'] = process_db_input($sTitle, BX_TAGS_STRIP, BX_SLASHES_NO_ACTION);
     $aFileInfo['medDesc'] = process_db_input($sDesc, BX_TAGS_VALIDATE, BX_SLASHES_NO_ACTION);
     $aFileInfo['medTags'] = process_db_input($sTags, BX_TAGS_STRIP, BX_SLASHES_NO_ACTION);
     $aFileInfo['Categories'] = array(process_db_input($sAlbum, BX_TAGS_STRIP, BX_SLASHES_NO_ACTION));
     $aFileInfo['album'] = process_db_input($sAlbum, BX_TAGS_STRIP, BX_SLASHES_NO_ACTION);
     $isUpdateThumb = (int) db_value("SELECT `Avatar` FROM `Profiles` WHERE `ID` = '{$iId}' LIMIT 1") ? false : true;
     if (BxDolService::call('photos', 'perform_photo_upload', array($sTmpFilename, $aFileInfo, $isUpdateThumb), 'Uploader')) {
         return new xmlrpcval("ok");
     } else {
         return new xmlrpcval("fail upload");
     }
 }
Example #2
0
 function uploadImage($sUser, $sPwd, $sAlbum, $binImageData, $iDataLength, $sTitle, $sTags, $sDesc)
 {
     if (!($iId = BxDolXMLRPCUtil::checkLogin($sUser, $sPwd))) {
         return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1, "int")), "struct"));
     }
     if (!BxDolXMLRPCMedia::_isMembershipEnabledFor($iIdProfileViewer, 'BX_PHOTOS_ADD', true)) {
         return new xmlrpcval("fail access");
     }
     // write tmp file
     $sTmpFilename = BX_DIRECTORY_PATH_ROOT . "tmp/" . time() . '_' . $iId;
     $f = fopen($sTmpFilename, "wb");
     if (!$f) {
         return new xmlrpcval("fail fopen");
     }
     if (!fwrite($f, $binImageData, (int) $iDataLength)) {
         fclose($f);
         return new xmlrpcval("fail write");
     }
     fclose($f);
     // upload
     $aFileInfo = array();
     $aFileInfo['medTitle'] = $sTitle;
     $aFileInfo['medDesc'] = $sDesc;
     $aFileInfo['medTags'] = $sTags;
     $aFileInfo['Categories'] = array($sAlbum);
     $aFileInfo['album'] = $sAlbum;
     if (BxDolService::call('photos', 'perform_photo_upload', array($sTmpFilename, $aFileInfo, 0, $iId), 'Uploader')) {
         return new xmlrpcval("ok");
     } else {
         return new xmlrpcval("fail upload");
     }
 }
Example #3
0
 function _getMediaAlbumsArray($sType, $iIdProfile, $iIdProfileViewer, $isShowEmptyAlbums = false)
 {
     switch ($sType) {
         case 'photo':
             $sModuleName = 'photos';
             $sType = 'bx_photos';
             $sMemAction = 'BX_PHOTOS_VIEW';
             break;
         case 'video':
             $sModuleName = 'videos';
             $sType = 'bx_videos';
             $sMemAction = 'BX_VIDEOS_VIEW';
             break;
         case 'music':
             $sModuleName = 'sounds';
             $sType = 'bx_sounds';
             $sMemAction = 'BX_SOUNDS_VIEW';
             break;
         default:
             return array();
     }
     if (!BxDolXMLRPCMedia::_isMembershipEnabledFor($iIdProfileViewer, $sMemAction)) {
         return array();
     }
     bx_import('BxDolAlbums');
     $o = new BxDolAlbums($sType, (int) $iIdProfile);
     $aList = $o->getAlbumList(array('owner' => (int) $iIdProfile, 'show_empty' => $isShowEmptyAlbums));
     $aRet = array();
     foreach ($aList as $r) {
         if ($iIdProfile != $iIdProfileViewer && !BxDolService::call($sModuleName, 'get_album_privacy', array((int) $r['ID'], $iIdProfileViewer), 'Search')) {
             continue;
         }
         $aRet[] = array('Id' => $r['ID'], 'Title' => $r['Caption'], 'Num' => $r['ObjCount']);
     }
     return $aRet;
 }
 function _uploadFile($sType, $sUser, $sPwd, $sAlbum, $binData, $iDataLength, $sTitle, $sTags, $sDesc, $sExt)
 {
     $sFieldTitle = 'title';
     $sFieldDesc = 'desc';
     $sFieldTags = 'tags';
     $sFieldCats = 'categories';
     $sFieldAlbum = 'album';
     switch ($sType) {
         case 'photo':
             $sModuleName = 'photos';
             $sService = 'perform_photo_upload';
             $sMemAction = 'BX_PHOTOS_ADD';
             $sFieldTitle = 'medTitle';
             $sFieldDesc = 'medDesc';
             $sFieldTags = 'medTags';
             $sFieldCats = 'Categories';
             $sFieldAlbum = 'album';
             $sModuleUnit = 'bx_photos';
             break;
         case 'video':
             $sModuleName = 'videos';
             $sService = 'perform_video_upload';
             $sMemAction = 'BX_VIDEOS_ADD';
             $sModuleUnit = 'bx_videos';
             break;
         case 'music':
             $sModuleName = 'sounds';
             $sService = 'perform_sound_upload';
             $sMemAction = 'BX_SOUNDS_ADD';
             $sModuleUnit = 'bx_sounds';
             break;
         default:
             return array();
     }
     if (!($iId = BxDolXMLRPCUtil::checkLogin($sUser, $sPwd))) {
         return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1, "int")), "struct"));
     }
     if (!BxDolXMLRPCMedia::_isMembershipEnabledFor($iId, $sMemAction, true)) {
         return new xmlrpcval("fail access");
     }
     if (!BxDolService::call($sModuleName, 'is_ext_allowed', array($sExt), 'Uploader')) {
         return new xmlrpcval("fail wrong extension - " . $sExt);
     }
     // write tmp file
     $sTmpFilename = BX_DIRECTORY_PATH_ROOT . "tmp/" . time() . $sType . $iId . '.' . $sExt;
     $f = fopen($sTmpFilename, "wb");
     if (!$f) {
         return new xmlrpcval("fail fopen");
     }
     if (!fwrite($f, $binData, (int) $iDataLength)) {
         fclose($f);
         return new xmlrpcval("fail write");
     }
     fclose($f);
     // upload
     $aFileInfo = array();
     $aFileInfo[$sFieldTitle] = $sTitle;
     $aFileInfo[$sFieldDesc] = $sDesc;
     $aFileInfo[$sFieldTags] = $sTags;
     $aFileInfo[$sFieldCats] = 'photo' == $sType ? array($sAlbum) : $sAlbum;
     $aFileInfo[$sFieldAlbum] = $sAlbum;
     if ('photo' == $sType && BxDolService::call($sModuleName, $sService, array($sTmpFilename, $aFileInfo, 0, $iId), 'Uploader')) {
         return new xmlrpcval("ok");
     } elseif ('photo' != $sType && ($iFileId = BxDolService::call($sModuleName, $sService, array($sTmpFilename, $aFileInfo, true), 'Uploader'))) {
         $oZ = new BxDolAlerts($sModuleUnit, 'add', $iFileId, $iId);
         $oZ->alert();
         return new xmlrpcval("ok");
     } else {
         return new xmlrpcval("fail upload");
     }
 }