function bxMockFree(&$o) { $sClassName = bx_ltrim_str(get_class($o), 'Mock_'); $sClassName = preg_replace('/_[A-Za-z0-9]+$/', '', $sClassName); unset($GLOBALS['bxDolClasses'][$sClassName]); unset($o); }
public function __construct() { parent::__construct(); $this->aInstallPermissions = array('inc', 'cache', 'cache_public', 'logs', 'tmp', 'storage', defined('BX_SYSTEM_FFMPEG') ? bx_ltrim_str(BX_SYSTEM_FFMPEG, BX_DIRECTORY_PATH_ROOT) : 'plugins/ffmpeg/ffmpeg.exe'); // remove 'inc' folder if script is already installed if (defined('BX_DOL')) { array_shift($this->aInstallPermissions); } $this->aPostInstallPermissions = array(); if (defined('BX_DOL_INSTALL') && BX_DOL_INSTALL) { $this->bInstallScript = true; $this->sRootPath = BX_INSTALL_URL_ROOT; } else { $this->bInstallScript = false; $this->sRootPath = BX_DOL_URL_ROOT; } }
/** * Private callback function for CSS compiler. * * @param string $sPath CSS file absolute path. * @param array $aMatches matched parts of image's URL. * @return string converted image's URL. */ function _callbackParseUrl($sPath, $aMatches) { $sFile = basename($aMatches[1]); $sDirectory = dirname($aMatches[1]); $sRootPath = realpath(BX_DIRECTORY_PATH_ROOT); $sAbsolutePath = realpath($sPath . $sDirectory) . DIRECTORY_SEPARATOR . $sFile; $sRootPath = str_replace(DIRECTORY_SEPARATOR, '/', $sRootPath); $sAbsolutePath = str_replace(DIRECTORY_SEPARATOR, '/', $sAbsolutePath); return 'url(' . bx_ltrim_str($sAbsolutePath, $sRootPath, BX_DOL_URL_ROOT) . ')'; }
/** * Less CSS * * @param mixed $mixed CSS string to process with Less compiler or an array with CSS file's Path and URL. * @return mixed string or an array with CSS file's Path and URL. */ function _lessCss($mixed) { require_once BX_DIRECTORY_PATH_PLUGINS . 'lessphp/lessc.inc.php'; $oLess = new lessc(); $oLess->setVariables($this->_oConfigTemplate->aLessConfig); if (is_array($mixed) && isset($mixed['url']) && isset($mixed['path'])) { $sPathFile = realpath($mixed['path']); $aInfoFile = pathinfo($sPathFile); if (!isset($aInfoFile['extension']) || $aInfoFile['extension'] != 'less') { return $mixed; } $sPathRoot = realpath(BX_DIRECTORY_PATH_ROOT); $sFile = $this->_sLessCachePrefix . trim(str_replace(array('.' . $aInfoFile['extension'], DIRECTORY_SEPARATOR), array('', '_'), bx_ltrim_str($sPathFile, $sPathRoot)), '_') . '.css'; $oLess->checkedCompile($mixed['path'], $this->_sCachePublicFolderPath . $sFile); return array('url' => $this->_sCachePublicFolderUrl . $sFile, 'path' => $this->_sCachePublicFolderPath . $sFile); } return $oLess->compile($mixed); }
function getDataReturnUrl($bSsl = false) { $sResult = BX_DOL_URL_ROOT . $this->_sDataReturnUrl; if ($bSsl && strpos($sResult, 'https://') === false) { $sResult = 'https://' . bx_ltrim_str($sResult, 'http://'); } return $sResult; }
protected function filePathWithoutBase($sPath) { return bx_ltrim_str($sPath, $this->_sModulePath); }
function actionChangePermissions($bInstall = true) { $aPermissions = $bInstall ? $this->_aConfig['install_permissions'] : $this->_aConfig['uninstall_permissions']; $aResult = $aChangeItems = array(); foreach ($aPermissions as $sPermissions => $aFiles) { $sCheckFunction = 'is' . ucfirst($sPermissions); foreach ($aFiles as $sFile) { $sPath = bx_ltrim_str($this->_sModulePath . $sFile, BX_DIRECTORY_PATH_ROOT); if (BxDolInstallerUtils::$sCheckFunction($sPath)) { continue; } $aResult[] = array('path' => $this->_sModulePath . $sFile, 'permissions' => $sPermissions); $aChangeItems[] = array('file' => $sFile, 'path' => $sPath, 'permissions' => $sPermissions); } } if (empty($aChangeItems)) { return BX_DOL_INSTALLER_SUCCESS; } bx_import('BxDolFtp'); $oFile = new BxDolFtp($_SERVER['HTTP_HOST'], getParam('sys_ftp_login'), getParam('sys_ftp_password'), getParam('sys_ftp_dir')); if (!$oFile->connect()) { return array('code' => BX_DOL_INSTALLER_FAILED, 'content_msg' => '_adm_txt_modules_wrong_permissions_change_cannot_connect_to_ftp', 'content_data' => $aResult); } if (!$oFile->isDolphin()) { return array('code' => BX_DOL_INSTALLER_FAILED, 'content_msg' => '_adm_txt_modules_wrong_permissions_change_destination_not_valid', 'content_data' => $aResult); } $aResult = array(); foreach ($aChangeItems as $aChangeItem) { if (!$oFile->setPermissions($aChangeItem['path'], $aChangeItem['permissions'])) { $aResult[] = array('path' => $this->_sModulePath . $aChangeItem['file'], 'permissions' => $aChangeItem['permissions']); } } return empty($aResult) ? BX_DOL_INSTALLER_SUCCESS : array('code' => BX_DOL_INSTALLER_FAILED, 'content_msg' => '_adm_txt_modules_wrong_permissions_change', 'content_data' => $aResult); }
/** * Gets an instance of class pathing necessary parameters if it's necessary. * * @param string $sClassName class name. * @param array $aParams an array of parameters to be pathed to the constructor of the class. * @param array $aModule an array with module description. Is used when the requested class is located in some module. * @return unknown */ function bx_instance($sClassName, $aParams = array(), $mixedModule = array()) { if (isset($GLOBALS['bxDolClasses'][$sClassName])) { return $GLOBALS['bxDolClasses'][$sClassName]; } if ($mixedModule) { if (!is_array($mixedModule)) { $o = BxDolModule::getInstance($mixedModule); $mixedModule = $o->_aModule; } $sClassName = bx_ltrim_str($sClassName, $mixedModule['class_prefix']); bx_import($sClassName, $mixedModule); $sClassName = $mixedModule['class_prefix'] . $sClassName; } $oClass = new ReflectionClass($sClassName); $GLOBALS['bxDolClasses'][$sClassName] = empty($aParams) ? $oClass->newInstance() : $oClass->newInstanceArgs($aParams); return $GLOBALS['bxDolClasses'][$sClassName]; }
{ return $this->sMarker; } } global $_page, $glHeader, $glFooter, $logged, $_ni; $GLOBALS['name_index'] = $_page['name_index'] = 55; $_page['header'] = $gConf['def_title']; $_page['header_text'] = $gConf['def_title']; $_ni = $_page['name_index']; $_page_cont[$_ni]['page_main_code'] = '-=++=-'; global $gConf; $sCssPathUrl = bx_ltrim_str($gConf['url']['css'], BX_DOL_URL_ROOT); $sCssPathDir = bx_ltrim_str("{$gConf['dir']['layouts']}{$gConf['skin']}/css/", BX_DIRECTORY_PATH_ROOT); $GLOBALS['oSysTemplate']->addCss("{$sCssPathDir}|{$sCssPathUrl}|main.css"); $sJsPathUrl = bx_ltrim_str($gConf['url']['js'], BX_DOL_URL_ROOT); $sJsPathDir = bx_ltrim_str($gConf['dir']['js'], BX_DIRECTORY_PATH_ROOT); $GLOBALS['oSysTemplate']->addJs(array('history.js', "{$sJsPathDir}|{$sJsPathUrl}|util.js", "{$sJsPathDir}|{$sJsPathUrl}|BxError.js", "{$sJsPathDir}|{$sJsPathUrl}|BxXmlRequest.js", "{$sJsPathDir}|{$sJsPathUrl}|BxXslTransform.js", "{$sJsPathDir}|{$sJsPathUrl}|BxForum.js", "{$sJsPathDir}|{$sJsPathUrl}|BxHistory.js", "{$sJsPathDir}|{$sJsPathUrl}|BxLogin.js", "{$sJsPathDir}|{$sJsPathUrl}|BxAdmin.js")); $GLOBALS['BxDolTemplateInjections']['page_' . $_ni]['injection_body'][] = array('type' => 'text', 'data' => 'id="body" onload="if(!document.body) { document.body = document.getElementById(\'body\'); }; h = new BxHistory(\'' . $gConf['url']['base'] . '\'); document.h = h; return h.init(\'h\'); "'); if (BX_ORCA_INTEGRATION == 'dolphin') { $aVars = array('ForumBaseUrl' => $gConf['url']['base']); $GLOBALS['oTopMenu']->setCustomSubActions($aVars, 'bx_forum_title', false); } if (isLogged()) { bx_import('BxDolEditor'); $oEditor = BxDolEditor::getObjectInstance(); $sEditorId = isset($_REQUEST['new_topic']) ? '#tinyEditor' : '#fakeEditor'; if ($oEditor) { if ('sys_tinymce' == $oEditor->getObjectName()) { $oEditor->setCustomConf('setup : function(ed) { ed.on("init", function(e) {
/** * Compile CSS files' structure(@see @import css_file_path) in one file. * * @param string $sAbsolutePath CSS file absolute path(full URL for external CSS/JS files). * @param array $aIncluded an array of already included CSS files. * @return string result of operation. */ function _compileCss($sAbsolutePath, &$aIncluded) { if (isset($aIncluded[$sAbsolutePath])) { return ''; } $bExternal = strpos($sAbsolutePath, "http://") !== false || strpos($sAbsolutePath, "https://") !== false; if ($bExternal) { $sPath = $sAbsolutePath; $sName = ''; $sContent = bx_file_get_contents($sAbsolutePath); } else { $aFileInfo = pathinfo($sAbsolutePath); $sPath = $aFileInfo['dirname'] . DIRECTORY_SEPARATOR; $sName = $aFileInfo['basename']; $sContent = file_get_contents($sPath . $sName); } if (empty($sContent)) { return ''; } $sUrl = bx_ltrim_str($sPath, realpath(BX_DIRECTORY_PATH_ROOT), BX_DOL_URL_ROOT); $sUrl = str_replace(DIRECTORY_SEPARATOR, '/', $sUrl); $sContent = "\r\n/*--- BEGIN: " . $sUrl . $sName . "---*/\r\n" . $sContent . "\r\n/*--- END: " . $sUrl . $sName . "---*/\r\n"; $aIncluded[$sAbsolutePath] = 1; $sContent = str_replace(array("\n\r", "\r\n", "\r"), "\n", $sContent); if ($bExternal) { $sContent = preg_replace(array("'@import\\s+url\\s*\\(\\s*[\\'|\"]*\\s*([a-zA-Z0-9\\.\\/_-]+)\\s*[\\'|\"]*\\s*\\)\\s*;'", "'url\\s*\\(\\s*[\\'|\"]*\\s*([a-zA-Z0-9\\.\\/\\?\\#_=-]+)\\s*[\\'|\"]*\\s*\\)'"), array("", "'url('" . $sPath . "'\\1)'"), $sContent); } else { try { $oTemplate =& $this; $sContent = preg_replace_callback("'@import\\s+url\\s*\\(\\s*[\\'|\"]*\\s*([a-zA-Z0-9\\.\\/_-]+)\\s*[\\'|\"]*\\s*\\)\\s*;'", function ($aMatches) use($oTemplate, $sPath, $aIncluded) { return $oTemplate->_compileCss(realpath($sPath . dirname($aMatches[1])) . DIRECTORY_SEPARATOR . basename($aMatches[1]), $aIncluded); }, $sContent); $sContent = preg_replace_callback("'url\\s*\\(\\s*[\\'|\"]*\\s*([a-zA-Z0-9\\.\\/\\?\\#_=-]+)\\s*[\\'|\"]*\\s*\\)'", function ($aMatches) use($oTemplate, $sPath) { $sFile = basename($aMatches[1]); $sDirectory = dirname($aMatches[1]); $sRootPath = realpath(BX_DIRECTORY_PATH_ROOT); $sAbsolutePath = realpath(addslashes($sPath) . $sDirectory) . DIRECTORY_SEPARATOR . $sFile; $sRootPath = str_replace(DIRECTORY_SEPARATOR, '/', $sRootPath); $sAbsolutePath = str_replace(DIRECTORY_SEPARATOR, '/', $sAbsolutePath); return 'url(' . bx_ltrim_str($sAbsolutePath, $sRootPath, BX_DOL_URL_ROOT) . ')'; }, $sContent); } catch (Exception $oException) { return ''; } } return $sContent; }
function getRepostedLanguageKey($sType, $sAction, $mixedObjectId, $bTitle = false) { $sLanguageKey = '_wall_reposted_'; if ($bTitle) { $sLanguageKey .= 'title_'; } $sLanguageKey .= bx_ltrim_str($sType, $this->_oConfig->getPrefix('common_post'), ''); if (!empty($sAction)) { $sLanguageKey .= '_' . $sAction; } if ($this->_oConfig->isGrouped($sType, $sAction, $mixedObjectId)) { $sLanguageKey .= '_grouped'; } return $sLanguageKey; }
function actionChangePermissions($bInstall = true) { $aPermissions = $bInstall ? $this->_aConfig['install_permissions'] : $this->_aConfig['uninstall_permissions']; $aResult = array(); foreach ($aPermissions as $sPermissions => $aFiles) { $sCheckFunction = 'is' . ucfirst($sPermissions); $sCptPermissions = _t('_adm_txt_modules_' . $sPermissions); foreach ($aFiles as $sFile) { if (!BxDolInstallerUtils::$sCheckFunction(bx_ltrim_str($this->_sModulePath . $sFile, BX_DIRECTORY_PATH_ROOT))) { $aResult[] = array('path' => $this->_sModulePath . $sFile, 'permissions' => $sCptPermissions); } } } return empty($aResult) ? BX_DOL_INSTALLER_SUCCESS : array('code' => BX_DOL_INSTALLER_FAILED, 'content' => $aResult); }
public function setTransientUpgradeCronJob($sUnpackedPath) { $sUnpackedPath = rtrim($sUnpackedPath, '/') . '/'; bx_import('BxDolCronQuery'); return BxDolCronQuery::getInstance()->addTransientJobClass('sys_perform_upgrade', 'BxDolUpgradeCron', bx_ltrim_str($sUnpackedPath, BX_DIRECTORY_PATH_ROOT) . 'BxDolUpgradeCron.php'); }
function bx_mkdir_r($sDirName, $rights = 0777) { $sDirName = bx_ltrim_str($sDirName, BX_DIRECTORY_PATH_ROOT); $aDirs = explode('/', $sDirName); $sDir = ''; foreach ($aDirs as $sPart) { $sDir .= $sPart . '/'; if (!is_dir(BX_DIRECTORY_PATH_ROOT . $sDir) && strlen(BX_DIRECTORY_PATH_ROOT . $sDir) > 0 && !file_exists(BX_DIRECTORY_PATH_ROOT . $sDir)) { if (!mkdir(BX_DIRECTORY_PATH_ROOT . $sDir, $rights)) { return false; } } } return true; }
protected function filePathWithoutBase($sPath) { return bx_ltrim_str($sPath, BX_DIRECTORY_PATH_ROOT); }
/** * Insert/Delete CSS file from output stack. * * @param string $sType the file type (css or js) * @param string $sAction add/delete * @param mixed $mixedFiles string value represents a single CSS file name. An array - array of CSS file names. * @return boolean result of operation. */ function _processFiles($sType, $sAction, $mixedFiles, $bDynamic = false, $bSystem = false) { if (empty($mixedFiles)) { return $bDynamic ? "" : false; } if (is_string($mixedFiles)) { $mixedFiles = array($mixedFiles); } $sUpcaseType = ucfirst($sType); $sMethodLocate = '_getAbsoluteLocation' . $sUpcaseType; $sMethodWrap = '_wrapInTag' . $sUpcaseType; $sResult = ''; foreach ($mixedFiles as $sFile) { //--- Process 3d Party CSS/JS file ---// if (strpos($sFile, "http://") !== false || strpos($sFile, "https://") !== false) { $sUrl = $sFile; $sPath = $sFile; } else { if (strpos($sFile, "|") !== false) { $sFile = implode('', explode("|", $sFile)); $sFile = bx_ltrim_str($sFile, BX_DIRECTORY_PATH_ROOT); $sUrl = BX_DOL_URL_ROOT . $sFile; $sPath = realpath(BX_DIRECTORY_PATH_ROOT . $sFile); } else { $sUrl = $this->{$sMethodLocate}('url', $sFile); $sPath = $this->{$sMethodLocate}('path', $sFile); } } if (empty($sPath) || empty($sUrl)) { continue; } $sArrayKey = $sType . ($bSystem ? '_system' : '_compiled'); switch ($sAction) { case 'add': if ($bDynamic) { $sResult .= $this->{$sMethodWrap}($sUrl); } else { $bFound = false; $aSearchIn = $bSystem ? $this->aPage[$sArrayKey] : array_merge($this->aPage[$sType . '_system'], $this->aPage[$sArrayKey]); foreach ($aSearchIn as $iKey => $aValue) { if ($aValue['url'] == $sUrl && $aValue['path'] == $sPath) { $bFound = true; break; } } if (!$bFound) { $this->aPage[$sArrayKey][] = array('url' => $sUrl, 'path' => $sPath); } } break; case 'delete': if (!$bDynamic) { foreach ($this->aPage[$sArrayKey] as $iKey => $aValue) { if ($aValue['url'] == $sUrl) { unset($this->aPage[$sArrayKey][$iKey]); break; } } } break; } } return $bDynamic ? $sResult : true; }
function _getCommonData($aEvent) { $sPrefix = $this->_oConfig->getPrefix('common_post'); $sEventType = bx_ltrim_str($aEvent['type'], $sPrefix, ''); $sTmplName = ''; $aTmplVars = array(); $aResult = array('content' => '', 'comments' => ''); switch ($sEventType) { case BX_WALL_PARSE_TYPE_TEXT: $aResult['content'] = bx_linkify_html($aEvent['content'], 'class="' . BX_DOL_LINK_CLASS . '"'); $sTmplName = 'common'; $aTmplVars['cpt_added_new'] = _t('_wall_added_' . $sEventType); break; case BX_WALL_PARSE_TYPE_LINK: $aResult['content'] = $aEvent['content']; $sTmplName = 'common'; $aTmplVars['cpt_added_new'] = _t('_wall_added_' . $sEventType); break; case BX_WALL_PARSE_TYPE_PHOTOS: case BX_WALL_PARSE_TYPE_SOUNDS: case BX_WALL_PARSE_TYPE_VIDEOS: $aContent = unserialize($aEvent['content']); $iContent = (int) $aContent['id']; $aResult = array_merge($aResult, $this->_getCommonMedia($aContent['type'], $iContent)); $sTmplName = 'common'; $aTmplVars['cpt_added_new'] = _t('_wall_added_' . $sEventType); break; case BX_WALL_PARSE_TYPE_REPOST: if (empty($aEvent['content'])) { return array(); } $aContent = unserialize($aEvent['content']); $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']); $sMethod = $this->_oConfig->isSystem($aContent['type'], $aContent['action']) ? '_getSystemData' : '_getCommonData'; $aResult = array_merge($aResult, $this->{$sMethod}($aReposted)); if (empty($aResult) || !is_array($aResult)) { return array(); } $sTmplName = 'repost'; $aTmplVars['cpt_reposted'] = _t($this->_oModule->getRepostedLanguageKey($aReposted['type'], $aReposted['action'], $aReposted['object_id'])); break; } $aResult['content'] = $this->parseHtmlByTemplateName($sTmplName, array_merge(array('post_type' => $sEventType, 'author_url' => getProfileLink($aEvent['object_id']), 'author_username' => getNickName($aEvent['object_id']), 'bx_if:show_wall_owner' => array('condition' => (int) $aEvent['owner_id'] != 0 && (int) $aEvent['owner_id'] != (int) $aEvent['object_id'], 'content' => array('owner_url' => getProfileLink($aEvent['owner_id']), 'owner_username' => getNickName($aEvent['owner_id']))), 'content' => $aResult['content']), $aTmplVars)); return $aResult; }
function copyFiles() { // TODO: use standalone copying require_once BX_DIRECTORY_PATH_CLASSES . 'BxDolFile.php'; $o = BxDolFile::getInstance(); $sDirSource = bx_ltrim_str(BX_UPGRADE_DIR_UPGRADES . $this->sFolder . '/files/', BX_DIRECTORY_PATH_ROOT); if (!$o->copy($sDirSource, '')) { return "Files copying failed"; } return true; }