function PageCodeClear() { global $oAdmTemplate, $oCacheUtilities, $aCacheTypes; $sChartData = ''; foreach ($aCacheTypes as $r) { if ('all' == $r['action']) { continue; } $iSize = $oCacheUtilities->size($r['action']); $sChartData .= ",\n['" . bx_js_string($r['title'], BX_ESCAPE_STR_APOS) . "', {v:" . $iSize . ", f:'" . bx_js_string(_t_format_size($iSize)) . "'}]"; } $s = $oAdmTemplate->parseHtmlByName('cache.html', array('bx_repeat:clear_action' => $aCacheTypes, 'chart_data' => trim($sChartData, ','))); return DesignBoxAdmin(_t('_adm_txt_cache'), $s, $GLOBALS['aTopItems'], '', 11); }
function serviceAcceptFile() { $sResult = ''; if ($_FILES) { for ($i = 0; $i < count($_FILES['file']['tmp_name']); $i++) { if ($_FILES['file']['error'][$i]) { if ($_FILES['file']['error'][$i] == UPLOAD_ERR_INI_SIZE) { $sResult .= $this->getFileAddError(_t('_sys_txt_upload_size_error', _t_format_size($this->iMaxFilesize))); } continue; } $sResult .= $this->_shareFile($_FILES['file']['tmp_name'][$i], true, $_FILES['file']['name'][$i], array('file_type' => $_FILES['file']['type'][$i])); } } else { $sResult = $this->getFileAddError(_t('_sys_txt_upload_size_error', _t_format_size($this->iMaxFilesize))); } return $sResult != '' ? $this->GenJquieryInjection() . $sResult : ''; }
public function serviceGetBlockSpace($bDynamic = false) { $bInclideScriptSpace = false; //Use dynamic loading by default if this setting is enabled. $sJsObject = $this->getPageJsObject(); $aChartData = array(); if (!$bDynamic) { $aItems = array(array('label' => '_adm_dbd_txt_su_database', 'value' => $this->getDbSize())); if ($bInclideScriptSpace) { $iSizeDiskTotal = $this->getFolderSize(BX_DIRECTORY_PATH_ROOT); $iSizeDiskMedia = $this->getFolderSize(BX_DIRECTORY_STORAGE); $aItems[] = array('label' => '_adm_dbd_txt_su_system', 'value' => $iSizeDiskTotal - $iSizeDiskMedia); } bx_import('BxDolModuleQuery'); $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'all')); foreach ($aModules as $aModule) { $sName = $aModule['name']; $sTitle = $aModule['title']; if ($aModule['name'] == 'system') { $sName = 'sys'; $sTitle = _t('_adm_dbd_txt_su_system_media'); } $aItems[] = array('label' => $sTitle, 'value' => (int) $this->oDb->getModuleStorageSize($sName)); } $iSizeTotal = 0; $aChartData = array(); foreach ($aItems as $sColor => $aItem) { $iSizeTotal += $aItem['value']; $aChartData[] = array(bx_js_string(strip_tags(_t($aItem['label'])), BX_ESCAPE_STR_APOS), array('v' => $aItem['value'], 'f' => bx_js_string(_t_format_size($aItem['value'])))); } } $sContent = BxDolStudioTemplate::getInstance()->parseHtmlByName('dbd_space.html', array('bx_if:show_content' => array('condition' => !$bDynamic, 'content' => array('js_object' => $sJsObject, 'chart_data' => json_encode($aChartData))), 'bx_if:show_loader' => array('condition' => $bDynamic, 'content' => array('js_object' => $sJsObject)))); return array('content' => $sContent); }
/** * Get readable representation of restrictions by file size. * @param $iProfileId profile id * @return string */ public function getRestrictionsTextFileSize($iProfileId) { return _t('_sys_storage_restriction_size', _t_format_size($this->getMaxUploadFileSize($iProfileId))); }
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; } }
function getBlockCode_ViewFile() { $oVotingView = new BxTemplVotingView('bx_files', $this->aFileInfo['medID']); if ($this->aFileInfo['prevItem'] > 0) { $aPrev = $this->oDb->getFileInfo(array('fileId' => $this->aFileInfo['prevItem']), true, array('medUri', 'medTitle')); } if ($this->aFileInfo['nextItem'] > 0) { $aNext = $this->oDb->getFileInfo(array('fileId' => $this->aFileInfo['nextItem']), true, array('medUri', 'medTitle')); } //icon $sIcon = $this->oDb->getTypeIcon($this->aFileInfo['Type']); if (!$sIcon) { $sIcon = 'default.png'; } $aUnit = array('pic' => $this->oTemplate->getIconUrl($sIcon), 'fileTitle' => $this->aFileInfo['medTitle'], 'fileSize' => (int) $this->aFileInfo['medSize'] > 0 ? _t_format_size((int) $this->aFileInfo['medSize']) : 0, 'fileExt' => $this->aFileInfo['medExt'], 'fileDescription' => $this->aFileInfo['medDesc'], 'rate' => $oVotingView->isEnabled() ? $oVotingView->getBigVoting(1, $this->aFileInfo['Rate']) : '', 'favInfo' => $this->oDb->getFavoritesCount($this->aFileInfo['medID']), 'viewInfo' => $this->aFileInfo['medViews'], 'albumUri' => BX_DOL_URL_ROOT . $this->oConfig->getBaseUri() . 'browse/album/' . $this->aFileInfo['albumUri'] . '/owner/' . $this->aFileInfo['NickName'], 'albumCaption' => $this->aFileInfo['albumCaption'], 'bx_if:prev' => array('condition' => $this->aFileInfo['prevItem'] > 0, 'content' => array('linkPrev' => BX_DOL_URL_ROOT . $this->oConfig->getBaseUri() . 'view/' . $aPrev['medUri'], 'titlePrev' => $aPrev['medTitle'], 'percent' => $this->aFileInfo['nextItem'] > 0 ? 50 : 100)), 'bx_if:next' => array('condition' => $this->aFileInfo['nextItem'] > 0, 'content' => array('linkNext' => BX_DOL_URL_ROOT . $this->oConfig->getBaseUri() . 'view/' . $aNext['medUri'], 'titleNext' => $aNext['medTitle'], 'percent' => $this->aFileInfo['prevItem'] > 0 ? 50 : 100))); $sCode = $this->oTemplate->parseHtmlByName('view_unit.html', $aUnit); return array($sCode, array(), array(), false); }
function getSearchUnitShort($aData) { //var_dump($aData); exit; $aUnit = array(); $aUnit['unitClass'] = $this->aCurrent['name']; // title $aUnit['titleLink'] = $this->getCurrentUrl('file', $aData['id'], $aData['uri']); $aUnit['title'] = $aData['title']; // from $aUnit['fromLink'] = getProfileLink($aData['ownerId']); $aUnit['from'] = getNickName($aData['ownerId']); //extension $aUnit['ext'] = $aData['Ext']; //size $aUnit['size'] = _t_format_size($aData['size']); // when $aUnit['when'] = defineTimeInterval($aData['date']); // pic $sPicName = is_null($aData['Icon']) ? 'default.png' : $aData['Icon']; $aUnit['pic'] = $this->oModule->_oTemplate->getIconUrl($sPicName); $aUnit['id'] = $aData['id']; return $this->oModule->_oTemplate->parseHtmlByName('browse_unit_short.html', $aUnit, array('{', '}')); }
protected function _getCellQuotaMaxFileSize($mixedValue, $sKey, $aField, $aRow) { return parent::_getCellDefault($mixedValue > 0 ? _t_format_size($mixedValue) : '∞', $sKey, $aField, $aRow); }
/** * @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')); } $iFileSize = filesize($sFilePath); if (!$iFileSize || $iFileSize > $this->iMaxFilesize) { return array('error' => _t('_' . $this->oModule->_oConfig->getMainPrefix() . '_size_error', _t_format_size($this->iMaxFilesize))); } $this->sTempFilename = pathinfo($sRealFilename, PATHINFO_FILENAME); if (!($iMID = $this->performFileUpload($sFilePath, array(), $isMoveUploadedFile, $sRealFilename, isset($aExtraParams['file_type']) ? $aExtraParams['file_type'] : ''))) { return array('error' => _t('_sys_txt_upload_failed')); } return array('id' => $iMID); }
protected function getCacheChartData($bAsString = true) { $oCacheUtilities = BxDolCacheUtilities::getInstance(); $aChartData = array(); foreach ($this->aItemsCache as $aItem) { if ($aItem['name'] == 'all') { continue; } $iSize = $oCacheUtilities->size($aItem['name']); if ($iSize === false) { continue; } $aChartData[] = array(bx_js_string(_t('_adm_dbd_txt_c_' . $aItem['name']), BX_ESCAPE_STR_APOS), array('v' => $iSize, 'f' => bx_js_string(_t_format_size($iSize)))); } if (empty($aChartData)) { return false; } return $bAsString ? json_encode($aChartData) : $aChartData; }
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) { $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; } }
function _shareFile($sFilePath, $isMoveUploadedFile = true, $sRealFilename = '', $sFileType = '') { $sAuthorCheck = $this->checkAuthorBeforeAdd(); if (empty($sAuthorCheck)) { //$this->sTempFilename = substr($sRealFilename, 0, strrpos($sRealFilename, '.')); $iFileSize = filesize($sFilePath); if (!$iFileSize || $iFileSize > $this->iMaxFilesize) { return $this->getFileAddError(_t('_' . $this->oModule->_oConfig->getMainPrefix() . '_size_error', _t_format_size($this->iMaxFilesize))); } $iPointPos = strrpos($sRealFilename, '.'); $sExt = substr($sRealFilename, $iPointPos + 1); if (!$this->oModule->_oConfig->checkAllowedExts($sExt)) { return $this->getFileAddError(); } $this->sTempFilename = substr($sRealFilename, 0, $iPointPos); $iMID = $this->performFileUpload($sFilePath, array(), $isMoveUploadedFile, $sRealFilename, $sFileType); if ($iMID > 0) { //upload success $aDefault = array('title' => $this->sTempFilename, 'description' => $this->sTempFilename); return $this->GenSendFileInfoForm($iMID, $aDefault); } else { return $this->getFileAddError(); } } else { return $sAuthorCheck; } }