Changeset 13383 for trunk/xmlrpc/BxDolXMLRPCMedia.php
- Timestamp:
- 12/07/09 21:36:04 (2 years ago)
- File:
-
- 1 edited
-
trunk/xmlrpc/BxDolXMLRPCMedia.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xmlrpc/BxDolXMLRPCMedia.php
r13382 r13383 3 3 class BxDolXMLRPCMedia 4 4 { 5 // ------------------ get files in category6 7 function getVideoInCategory($sUser, $sPwd, $sNick, $sCat)8 {9 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick);10 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd)))11 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));12 13 return BxDolXMLRPCMedia::_getFilesInCategory ('videos', $iIdProfile, $sCat, 'video', 'getToken', 'flash/modules/video/files/get_mobile.php?id=');14 }15 16 function getAudioInCategory($sUser, $sPwd, $sNick, $sCat)17 {18 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick);19 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd)))20 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));21 22 return BxDolXMLRPCMedia::_getFilesInCategory ('sounds', $iIdProfile, $sCat, 'mp3', 'getMp3Token', 'flash/modules/mp3/files/get_file.php?id=');23 }24 25 function _getFilesInCategory ($sModuleName, $iIdProfile, $sCat, $sWidget = '', $sFuncToken = '', $sTokenUrl = '')26 {27 if ($sWidget && preg_match('/^[a-zA-Z0-9_]+$/', $sWidget)) {28 $GLOBALS['sModule'] = $sWidget;29 require_once (BX_DIRECTORY_PATH_ROOT . "flash/modules/{$sWidget}/inc/header.inc.php");30 } else {31 $sWidget = '';32 }33 34 $sCat = process_db_input($sCat, BX_TAGS_NO_ACTION, BX_SLASHES_NO_ACTION);35 36 $a = BxDolService::call ($sModuleName, 'get_files_in_cat', array((int)$iIdProfile, $sCat), 'Search');37 if (!$a)38 return new xmlrpcval (array(), "array");39 foreach ($a as $k => $aRow)40 {41 $sToken = '';42 if ($sFuncToken)43 $sToken = $sFuncToken($aRow['id']);44 45 $sUrl = $sTokenUrl && $sToken ? BX_DOL_URL_ROOT . $sTokenUrl . $aRow['id'] . '&token=' . $sToken : $aRow['file'];46 47 $a = array (48 'id' => new xmlrpcval($aRow['id']),49 'title' => new xmlrpcval($aRow['title']),50 'desc' => new xmlrpcval(BxDolService::call ($sModuleName, 'get_length', array($aRow['size']), 'Search')),51 'icon' => new xmlrpcval($aRow['icon']),52 'thumb' => new xmlrpcval($aRow['thumb']),53 'file' => new xmlrpcval($sUrl),54 'cat' => new xmlrpcval($sCat),55 'rate' => new xmlrpcval($aRow['voting_rate']),56 'rate_count' => new xmlrpcval((int)$aRow['voting_count']),57 );58 $aFiles[] = new xmlrpcval($a, 'struct');59 }60 return new xmlrpcval ($aFiles, "array");61 }62 63 // ------------------ categories list64 65 function getAudioCategories ($sUser, $sPwd, $sNick)66 {67 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick);68 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd)))69 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));70 71 return BxDolXMLRPCMedia::_getMediaCategories ('music', $iIdProfile);72 }73 74 function getVideoCategories ($sUser, $sPwd, $sNick)75 {76 $iIdProfile = BxDolXMLRPCUtil::getIdByNickname ($sNick);77 if (!$iIdProfile || !($iId = BxDolXMLRPCUtil::checkLogin ($sUser, $sPwd)))78 return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1,"int")), "struct"));79 80 return BxDolXMLRPCMedia::_getMediaCategories ('video', $iIdProfile);81 }82 83 function _getMediaCategories ($sType, $iIdProfile)84 {85 $iIdProfile = (int)$iIdProfile;86 switch ($sType) {87 case 'photo':88 $sTable = 'bx_photos_files';89 $sFieldId = 'ID';90 $sFieldOwner = 'Owner';91 $sType = 'bx_photos';92 break;93 case 'video':94 $sTable = 'RayVideoFiles';95 $sFieldId = 'ID';96 $sFieldOwner = 'Owner';97 $sType = 'bx_videos';98 break;99 case 'music':100 $sTable = 'RayMp3Files';101 $sFieldId = 'ID';102 $sFieldOwner = 'Owner';103 $sType = 'bx_sounds';104 break;105 default:106 return new xmlrpcval (array(), "array");107 }108 109 if (!($r = db_res ("110 SELECT `c`.`Category`, COUNT(`f`.`$sFieldId`) AS `Num`111 FROM `sys_categories` AS `c`112 LEFT JOIN `$sTable` AS `f` ON (`f`.`$sFieldId` = `c`.`ID` AND `f`.`$sFieldOwner` = '$iIdProfile')113 WHERE `c`.`Type` = '$sType' AND (`c`.`Owner` = '0' OR `c`.`Owner` = '$iIdProfile')114 GROUP BY `c`.`Category`")))115 return new xmlrpcval (array(), "array");116 $aFiles = array ();117 while ($a = mysql_fetch_array ($r))118 {119 $aFile = array (120 'Id' => new xmlrpcval($a['Category']),121 'Title' => new xmlrpcval($a['Category']),122 'Num' =>new xmlrpcval($a['Num']),123 );124 $aFiles[] = new xmlrpcval($aFile, 'struct');125 }126 return new xmlrpcval ($aFiles, "array");127 }128 129 5 // ----------------- albums list 130 6
Note: See TracChangeset
for help on using the changeset viewer.