/** * Check if user is spammer * @param $aValues - array with keys: ip, email, username * @param $sDesc - desctiption, for example: join * @return true - on positive detection, false - on error or no spammer detection */ public function isSpammer($aValues, $sDesc) { if (!getParam('bx_antispam_stopforumspam_enable')) { return false; } if (!$aValues || !is_array($aValues)) { return false; } $aRequestParams = array('f' => 'json'); foreach ($this->_aKeys as $k => $b) { if (isset($aValues[$k])) { $aRequestParams[$k] = rawurlencode($aValues[$k]); } } $s = bx_file_get_contents('http://www.stopforumspam.com/api', $aRequestParams); if (!$s) { return false; } $aResult = json_decode($s, true); if (null === $aResult || !$aResult['success']) { return false; } foreach ($this->_aKeys as $k => $b) { if (isset($aResult[$k]) && $aResult[$k]['appears']) { $this->onPositiveDetection($sDesc); return true; } } return false; }
public function getSplash() { if ($this->_oConfig->getUri() != $this->getCode()) { return ''; } $sDownloadUrl = 'http://ci.boonex.com/'; $sVersion = '8.0'; $sVersionFull = '8.0.0'; $sBuild = ''; $mixedResponse = bx_file_get_contents($sDownloadUrl . "builds/latest-release-file.txt"); if ($mixedResponse !== false) { $sFile = trim(bx_process_input($mixedResponse)); $aMatches = array(); if ((int) preg_match("/([0-9]\\.[0-9])\\.([0-9])-?([A-Z]*[a-z]*[0-9]{1,3})/", $sFile, $aMatches) > 0 && !empty($aMatches[1]) && !empty($aMatches[3])) { $sDownloadUrl .= 'builds/' . $sFile; $sVersion = $aMatches[1]; $sBuild = $aMatches[3]; } if ((int) preg_match("/Trident-v\\.([0-9A-Za-z\\.-]+)\\.zip/", $sFile, $aMatches) > 0) { $sVersionFull = $aMatches[1]; } } $this->addCss(array('splash-phone.css', 'splash-tablet.css', 'splash-desktop.css')); return $this->parseHtmlByName('splash.html', array('download_url' => $sDownloadUrl, 'version_full' => $sVersionFull, 'version' => $sVersion, 'build' => $sBuild)); }
function BxRSS($url) { $this->items = array(); if ($url and $this->sXmlText = bx_file_get_contents($url)) { $this->_doFillFromText(); } else { return null; } }
function actionHandle() { // check CSRF token if ($this->_getCsrfToken() != bx_get('state')) { $this->_oTemplate->getPage(_t('_Error'), MsgBox(_t('_bx_dolphcon_state_invalid'))); return; } // check code $sCode = bx_get('code'); if (!$sCode) { $sErrorDescription = bx_get('error_description') ? bx_get('error_description') : _t('_Error occured'); $this->_oTemplate->getPage(_t('_Error'), MsgBox($sErrorDescription)); return; } // make request for token $s = bx_file_get_contents($this->_oConfig->sApiUrl . 'token', array('client_id' => $this->_oConfig->sApiID, 'client_secret' => $this->_oConfig->sApiSecret, 'grant_type' => 'authorization_code', 'code' => $sCode, 'redirect_uri' => $this->_oConfig->sPageHandle), 'post'); // handle error if (!$s || NULL === ($aResponse = json_decode($s, true)) || !isset($aResponse['access_token']) || isset($aResponse['error'])) { $sErrorDescription = isset($aResponse['error_description']) ? $aResponse['error_description'] : _t('_Error occured'); $this->_oTemplate->getPage(_t('_Error'), MsgBox($sErrorDescription)); return; } // get the data, especially access_token $sAccessToken = $aResponse['access_token']; $sExpiresIn = $aResponse['expires_in']; $sExpiresAt = new \DateTime('+' . $sExpiresIn . ' seconds'); $sRefreshToken = $aResponse['refresh_token']; // request info about profile $s = bx_file_get_contents($this->_oConfig->sApiUrl . 'api/me', array(), 'get', array('Authorization: Bearer ' . $sAccessToken)); // handle error if (!$s || NULL === ($aResponse = json_decode($s, true)) || !$aResponse || isset($aResponse['error'])) { $sErrorDescription = isset($aResponse['error_description']) ? $aResponse['error_description'] : _t('_Error occured'); $this->_oTemplate->getPage(_t('_Error'), MsgBox($sErrorDescription)); return; } $aRemoteProfileInfo = $aResponse; if ($aRemoteProfileInfo) { // check if user logged in before $iLocalProfileId = $this->_oDb->getProfileId($aRemoteProfileInfo['id']); if ($iLocalProfileId) { // user already exists $aLocalProfileInfo = getProfileInfo($iLocalProfileId); $this->setLogged($iLocalProfileId, $aLocalProfileInfo['Password']); } else { // register new user $sAlternativeNickName = ''; if (getID($aRemoteProfileInfo['NickName'])) { $sAlternativeNickName = $this->getAlternativeName($aRemoteProfileInfo['NickName']); } $this->getJoinAfterPaymentPage($aRemoteProfileInfo); $this->_createProfile($aRemoteProfileInfo, $sAlternativeNickName); } } else { $this->_oTemplate->getPage(_t('_Error'), MsgBox(_t('_bx_dolphcon_profile_error_info'))); } }
public function getVersionUpdateInfo() { $s = bx_file_get_contents($this->_sUrlVersionCheck, array('v' => bx_get_ver())); if (!$s) { return null; } $a = json_decode($s, true); if (!isset($a['latest_version'])) { return null; } return $a; }
public function load($sUrl, $aParams = array()) { $sContent = bx_file_get_contents($sUrl, $aParams); if (empty($sContent)) { return false; } //echo $sContent; exit; //--- Uncomment to debug $mixedResult = json_decode($sContent, true); if (is_null($mixedResult)) { return false; } return $mixedResult; }
public function getFeed($mixedId, $iUserId = 0) { $sUrl = $this->getUrl($mixedId); $aMarkers = array('SiteUrl' => BX_DOL_URL_ROOT); if ($iUserId) { $oProfile = BxDolProfile::getInstance($iUserId); if (!$oProfile) { $oProfile = BxDolProfileUndefined::getInstance(); } $aMarkers['NickName'] = $oProfile->getDisplayName(); } $sUrl = bx_replace_markers($sUrl, $aMarkers); header('Content-Type: text/xml; charset=utf-8'); return bx_file_get_contents($sUrl . (defined('BX_PROFILER') && BX_PROFILER && 0 == strncmp(BX_DOL_URL_ROOT, $sUrl, strlen(BX_DOL_URL_ROOT)) ? '&bx_profiler_disable=1' : '')); }
/** * Check captcha. */ public function check() { $mixedResponce = bx_file_get_contents($this->sVerifyUrl, array('secret' => $this->_sKeyPrivate, 'response' => bx_process_input(bx_get('g-recaptcha-response')), 'remoteip' => getVisitorIP())); if ($mixedResponce === false) { return false; } $aResponce = json_decode($mixedResponce, true); if (isset($aResponce['success']) && $aResponce['success'] === true) { return true; } if (!empty($aResponce['error-codes'])) { $this->_error = $aResponce['error-codes']; } return false; }
/** * 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, '/', $sPath); $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; }
/** * Assign avatar to user * * @param $sAvatarUrl string * @return void */ function _assignAvatar($sAvatarUrl, $iProfileId = false) { if (!$iProfileId) { $iProfileId = getLoggedId(); } if (BxDolInstallerUtils::isModuleInstalled('avatar')) { BxDolService::call('avatar', 'make_avatar_from_image_url', array($sAvatarUrl)); } if (BxDolRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader')) { bx_import('BxDolPrivacyQuery'); $oPrivacy = new BxDolPrivacyQuery(); $sTmpFile = tempnam($GLOBALS['dir']['tmp'], 'bxoauth'); if (false !== file_put_contents($sTmpFile, bx_file_get_contents($sAvatarUrl))) { $aFileInfo = array('medTitle' => _t('_sys_member_thumb_avatar'), 'medDesc' => _t('_sys_member_thumb_avatar'), 'medTags' => _t('_ProfilePhotos'), 'Categories' => array(_t('_ProfilePhotos')), 'album' => str_replace('{nickname}', getUsername($iProfileId), getParam('bx_photos_profile_album_name')), 'albumPrivacy' => $oPrivacy->getDefaultValueModule('photos', 'album_view')); BxDolService::call('photos', 'perform_photo_upload', array($sTmpFile, $aFileInfo, false), 'Uploader'); @unlink($sTmpFile); } } }
function checkForUpdates($aModule) { if (empty($aModule['update_url'])) { return array(); } $sData = bx_file_get_contents($aModule['update_url'], array('uri' => $aModule['uri'], 'path' => $aModule['path'], 'version' => $aModule['version'], 'domain' => $_SERVER['HTTP_HOST'])); $aValues = $aIndexes = array(); $rParser = xml_parser_create('UTF-8'); xml_parse_into_struct($rParser, $sData, $aValues, $aIndexes); xml_parser_free($rParser); $aInfo = array(); if (isset($aIndexes['VERSION'])) { $aInfo['version'] = $aValues[$aIndexes['VERSION'][0]]['value']; } if (isset($aIndexes['LINK'])) { $aInfo['link'] = $aValues[$aIndexes['LINK'][0]]['value']; } if (isset($aIndexes['PACKAGE'])) { $aInfo['package'] = $aValues[$aIndexes['PACKAGE'][0]]['value']; } return $aInfo; }
protected function storeFileLocally_Queue($mixedHandler) { $aQueue = $this->_oDb->getFromQueue($mixedHandler); if (!$aQueue || !$aQueue['file_url_source']) { return false; } $sFileData = bx_file_get_contents($aQueue['file_url_source']); if (false === $sFileData) { return false; } $sTmpFile = $this->getTmpFilename($mixedHandler); if (!file_put_contents($sTmpFile, $sFileData)) { return false; } return $sTmpFile; }
function _processLinkUpload() { $aOwner = $this->_oDb->getUser($this->_getAuthorId()); $sUrl = trim(process_db_input($_POST['url'], BX_TAGS_STRIP)); if (empty($sUrl)) { return array('code' => 1, 'message' => '_wall_msg_link_empty_link'); } $sContent = bx_file_get_contents($sUrl); preg_match("/<title>(.*)<\\/title>/", $sContent, $aMatch); $sTitle = $aMatch[1]; preg_match("/<meta.*name[='\" ]+description['\"].*content[='\" ]+(.*)['\"].*><\\/meta>/", $sContent, $aMatch); $sDescription = $aMatch[1]; return array('object_id' => $aOwner['id'], 'content' => $this->_oTemplate->parseHtmlByName('common_link.html', array('title' => $sTitle, 'url' => strpos($sUrl, 'http://') === false && strpos($sUrl, 'https://') === false ? 'http://' . $sUrl : $sUrl, 'description' => $sDescription)), 'title' => $aOwner['username'] . ' ' . _t('_wall_shared_link'), 'description' => $sUrl . ' - ' . $sTitle); }
<?php /** * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ * CC-BY License - http://creativecommons.org/licenses/by/3.0/ */ require_once './inc/header.inc.php'; require_once './inc/db.inc.php'; require_once './inc/profiles.inc.php'; $aPredefinedRssFeeds = array('boonex_news' => 'http://www.boonex.com/notes/featured_posts/?rss=1', 'boonex_version' => 'http://rss.boonex.com/', 'boonex_unity_market' => 'http://www.boonex.com/market/latest/?rss=1', 'boonex_unity_lang_files' => 'http://www.boonex.com/market/tag/translations&rss=1', 'boonex_unity_market_templates' => 'http://www.boonex.com/market/tag/templates&rss=1', 'boonex_unity_market_featured' => 'http://www.boonex.com/market/featured_posts?rss=1'); if (isset($aPredefinedRssFeeds[$_GET['ID']])) { $sCont = $aPredefinedRssFeeds[$_GET['ID']]; } else { $sQuery = "SELECT `Content` FROM `sys_page_compose` WHERE `ID` = " . (int) $_GET['ID']; $sCont = db_value($sQuery); if (!$sCont) { exit; } } list($sUrl) = explode('#', $sCont); $sUrl = str_replace('{SiteUrl}', $site['url'], $sUrl); $iMemID = (int) $_GET['member']; if ($iMemID) { $aMember = getProfileInfo($iMemID); $sUrl = str_replace('{NickName}', $aMember['NickName'], $sUrl); } header('Content-Type: text/xml'); echo bx_file_get_contents($sUrl . (BX_PROFILER && 0 == strncmp($site['url'], $sUrl, strlen($site['url'])) ? '&bx_profiler_disable=1' : ''));
function save($path) { $s = bx_file_get_contents($this->oStorage->getFileUrlById($this->iFileId)); if (!$s) { return false; } return file_put_contents($path, $s) ? true : false; }
/** * make avatar from image url, also it makes it square * @param $sImg url to the image * @return true on success or false on error */ function serviceMakeAvatarFromImageUrl($sImgUrl) { if (!$this->_iProfileId) { return false; } $s = bx_file_get_contents($sImgUrl); if (!$s) { return false; } $sImagePath = BX_AVA_DIR_TMP . '_' . $this->_iProfileId . BX_AVA_EXT; if (!file_put_contents($sImagePath, $s)) { return false; } return $this->serviceMakeAvatarFromImage($sImagePath); }
function getSiteInfo($sSourceUrl, $aProcessAdditionalTags = array()) { $aResult = array(); $sContent = bx_file_get_contents($sSourceUrl); if ($sContent) { $sCharset = ''; preg_match("/<meta.+charset=([A-Za-z0-9-]+).+>/i", $sContent, $aMatch); if (isset($aMatch[1])) { $sCharset = $aMatch[1]; } if (preg_match("/<title[^>]*>(.*)<\\/title>/i", $sContent, $aMatch)) { $aResult['title'] = $aMatch[1]; } else { $aResult['title'] = parse_url($sSourceUrl, PHP_URL_HOST); } $aResult['description'] = bx_parse_html_tag($sContent, 'meta', 'name', 'description', 'content', $sCharset); $aResult['keywords'] = bx_parse_html_tag($sContent, 'meta', 'name', 'keywords', 'content', $sCharset); if ($aProcessAdditionalTags) { foreach ($aProcessAdditionalTags as $k => $a) { $aResult[$k] = bx_parse_html_tag($sContent, isset($a['tag']) ? $a['tag'] : 'meta', isset($a['name_attr']) ? $a['name_attr'] : 'itemprop', isset($a['name']) ? $a['name'] : $k, isset($a['content_attr']) ? $a['content_attr'] : 'content', $sCharset); } } } return $aResult; }
function getSiteInfo($sSourceUrl) { $aResult = array(); $sContent = bx_file_get_contents($sSourceUrl); if (strlen($sContent)) { preg_match("/<title>(.*)<\\/title>/", $sContent, $aMatch); $aResult['title'] = $aMatch[1]; preg_match("/<meta.*name[='\" ]+description['\"].*content[='\" ]+(.*)['\"].*><\\/meta>/", $sContent, $aMatch); $aResult['description'] = $aMatch[1]; } return $aResult; }
public function getFormAttachLink() { $iUserId = $this->getUserId(); bx_import('BxDolForm'); $oForm = BxDolForm::getObjectInstance('mod_tml_attach_link', 'mod_tml_attach_link_add'); $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'add_attach_link/'; $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url'); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $sLink = $oForm->getCleanValue('url'); $sLinkContent = bx_file_get_contents($sLink); $aMatch = array(); preg_match($this->_oConfig->getPregPattern('meta_title'), $sLinkContent, $aMatch); $sLinkTitle = $aMatch ? $aMatch[1] : ''; preg_match($this->_oConfig->getPregPattern('meta_description'), $sLinkContent, $aMatch); $sLinkDescription = $aMatch ? $aMatch[1] : ''; $iId = (int) $oForm->insert(array('profile_id' => $iUserId, 'title' => $sLinkTitle, 'text' => $sLinkDescription, 'added' => time())); if (!empty($iId)) { return array('item' => $this->_oTemplate->getAttachLinkItem($iUserId, $iId)); } return array('msg' => _t('_adm_nav_err_menus_create')); } return array('form' => $oForm->getCode(), 'form_id' => $oForm->id); }
/** * Get facebook locales * @return locales array, lang is array key and locale is array value */ protected function _getLocalesFacebook() { $oCache = $GLOBALS['MySQL']->getDbCacheObject(); $sCacheKey = $GLOBALS['MySQL']->genDbCacheKey('sys_social_sharing_locales_fb'); $aData = $oCache->getData($sCacheKey); if (null === $aData) { $sXML = bx_file_get_contents('http://www.facebook.com/translations/FacebookLocales.xml'); if (!$sXML) { return false; } $xmlLocates = new SimpleXMLElement($sXML); $aData = array(); foreach ($xmlLocates->locale as $xmlLocale) { $sLocale = (string) $xmlLocale->codes->code->standard->representation; $aData[$sLocale] = 1; } $oCache->setData($sCacheKey, $aData); } return $aData; }
function _geocodeGoogle($sAddress, &$fLatitude, &$fLongitude, &$sCountryCode) { $sAddress = rawurlencode($sAddress); $sUrl = "http://maps.googleapis.com/maps/api/geocode/json"; $s = bx_file_get_contents($sUrl, array('address' => $sAddress, 'sensor' => 'false')); $oData = json_decode($s); if (null == $oData) { return 404; } if ('OK' != $oData->status) { return 404; } foreach ($oData->results as $oResult) { $sShortNameCountry = ''; foreach ($oResult->address_components as $oAddressComponent) { if (in_array('country', $oAddressComponent->types)) { $sShortNameCountry = $oAddressComponent->short_name; } } if (!$sCountryCode || $sShortNameCountry && $sCountryCode == $sShortNameCountry) { $fLatitude = $oResult->geometry->location->lat; $fLongitude = $oResult->geometry->location->lng; $sCountryCode = $sShortNameCountry; return 200; } } return 404; }
/** * Gets the account problem image and returns the relative path to the cached image */ function _getNoResponseImage($sUrl, $aOptions) { // create cache directory if it doesn't exist _createCacheDirectory(); $aOptions = _generateOptions($aOptions); $aArgs['stwaccesskeyid'] = 'accountproblem'; if ($aOptions['SizeCustom']) { $aArgs['stwxmax'] = $aOptions['SizeCustom']; } else { $aArgs['stwsize'] = $aOptions['Size']; } $sRequestUrl = 'http://images.shrinktheweb.com/xino.php'; $sRemoteData = bx_file_get_contents($sRequestUrl, $aArgs); if ($sRemoteData != '') { $aResponse = _getXMLResponse($sRemoteData); if (!$aResponse['exists'] && $aResponse['thumbnail'] != '') { $sImageUrl = $aResponse['thumbnail']; $sFilename = NO_RESPONSE_IMAGE; $sFile = THUMBNAIL_DIR . $sFilename; $isDownloaded = _downloadRemoteImageToLocalPath($sImageUrl, $sFile); if ($isDownloaded == true) { return THUMBNAIL_URI . $sFilename; } } } return false; }
/** * 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, '/', $sPath); $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*;'e", "'url\\s*\\(\\s*[\\'|\"]*\\s*([a-zA-Z0-9\\.\\/\\?\\#_-]+)\\s*[\\'|\"]*\\s*\\)'e"), array("", "'url(' . \$sPath . '\\1)'"), $sContent); } else { $sContent = preg_replace("'@import\\s+url\\s*\\(\\s*[\\'|\"]*\\s*([a-zA-Z0-9\\.\\/_-]+)\\s*[\\'|\"]*\\s*\\)\\s*;'e", "\$this->_compileCss(realpath(\$sPath . dirname('\\1')) . DIRECTORY_SEPARATOR . basename('\\1'), \$aIncluded)", $sContent); $sContent = preg_replace_callback("'url\\s*\\(\\s*[\\'|\"]*\\s*([a-zA-Z0-9\\.\\/\\?\\#_-]+)\\s*[\\'|\"]*\\s*\\)'", create_function('$aMatches', 'return BxDolTemplate::_callbackParseUrl("' . addslashes($sPath) . '", $aMatches);'), $sContent); } return $sContent; }
function _geocode($sAddress, $sCountryCode = '') { $sStatus = false; $sAddress = rawurlencode($sAddress); $sUrl = bx_proto() . "://maps.googleapis.com/maps/api/geocode/json"; $s = bx_file_get_contents($sUrl, array('address' => $sAddress, 'sensor' => 'false')); $oData = json_decode($s); if (null == $oData) { return false; } if ('OK' != $oData->status) { return false; } foreach ($oData->results as $oResult) { $sShortNameCountry = ''; foreach ($oResult->address_components as $oAddressComponent) { if (in_array('country', $oAddressComponent->types)) { $sShortNameCountry = $oAddressComponent->short_name; } } if (!$sCountryCode || $sShortNameCountry && $sCountryCode == $sShortNameCountry) { $oLocation = $oResult->geometry->location; return array($oLocation->lat, $oLocation->lng, $sShortNameCountry); } } return false; }
* CC-BY License - http://creativecommons.org/licenses/by/3.0/ */ require_once './inc/header.inc.php'; require_once './inc/db.inc.php'; require_once './inc/profiles.inc.php'; $aPredefinedRssFeeds = array('boonex_news' => 'https://www.boonex.com/notes/featured_posts/?rss=1', 'boonex_version' => 'http://rss.boonex.com/', 'boonex_unity_market' => 'https://www.boonex.com/market/latest/?rss=1', 'boonex_unity_lang_files' => 'https://www.boonex.com/market/tag/translations&rss=1', 'boonex_unity_market_templates' => 'https://www.boonex.com/market/tag/templates&rss=1', 'boonex_unity_market_featured' => 'https://www.boonex.com/market/featured_posts?rss=1'); if (isset($aPredefinedRssFeeds[$_GET['ID']])) { $sCont = $aPredefinedRssFeeds[$_GET['ID']]; } elseif (0 === strncmp('forum|', $_GET['ID'], 6)) { $a = explode('|', $_GET['ID']); if (!is_array($a) || 3 != count($a)) { exit; } $sCont = BX_DOL_URL_ROOT . $a[0] . '/' . $a[1] . '/rss/forum/' . $a[2] . '.htm'; } else { $sQuery = "SELECT `Content` FROM `sys_page_compose` WHERE `ID` = " . (int) $_GET['ID']; $sCont = db_value($sQuery); if (!$sCont) { exit; } } list($sUrl) = explode('#', $sCont); $sUrl = str_replace('{SiteUrl}', $site['url'], $sUrl); $iMemID = (int) $_GET['member']; if ($iMemID) { $aMember = getProfileInfo($iMemID); $sUrl = str_replace('{NickName}', $aMember['NickName'], $sUrl); } header('Content-Type: text/xml'); echo bx_file_get_contents(defined('BX_PROFILER') && BX_PROFILER && 0 === strncmp($site['url'], $sUrl, strlen($site['url'])) ? bx_append_url_params($sUrl, 'bx_profiler_disable=1') : $sUrl);
public function getFormAttachLink() { $iUserId = $this->getUserId(); $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_attach_link'), $this->_oConfig->getObject('form_display_attach_link_add'), $this->_oTemplate); $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'add_attach_link/'; $oForm->aInputs['url']['checker']['params']['preg'] = $this->_oConfig->getPregPattern('url'); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $sLink = $oForm->getCleanValue('url'); $sLinkContent = bx_file_get_contents($sLink); $aMatches = array(); preg_match($this->_oConfig->getPregPattern('url'), $sLink, $aMatches); $sLink = (empty($aMatches[1]) ? 'http://' : '') . $aMatches[0]; $aMatches = array(); preg_match($this->_oConfig->getPregPattern('meta_title'), $sLinkContent, $aMatches); $sLinkTitle = $aMatches ? $aMatches[1] : ''; $aMatches = array(); preg_match($this->_oConfig->getPregPattern('meta_description'), $sLinkContent, $aMatches); $sLinkDescription = $aMatches ? $aMatches[1] : ''; $iId = (int) $oForm->insert(array('profile_id' => $iUserId, 'url' => $sLink, 'title' => $sLinkTitle, 'text' => $sLinkDescription, 'added' => time())); if (!empty($iId)) { return array('item' => $this->_oTemplate->getAttachLinkItem($iUserId, $iId)); } return array('msg' => _t('_bx_timeline_txt_err_cannot_perform_action')); } return array('form' => $oForm->getCode(), 'form_id' => $oForm->id); }
function embedReadUrl($sUrl) { return bx_file_get_contents($sUrl); }
/** * 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 = ''; $aAPUrl = parse_url($sAbsolutePath); if (!empty($aAPUrl['path'])) { $aAPPath = pathinfo($aAPUrl['path']); if (!empty($aAPPath['basename'])) { $sPath = bx_rtrim_str($sAbsolutePath, $aAPPath['basename']); $sName = $aAPPath['basename']; } } $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; /* Match URL based imports like the following: * @import 'http://[domain]/modules/[vendor]/[module]/template/css/view.css'; * Is mainly needed for CSS files which are gotten from LESS compiler. */ $sContent = preg_replace_callback("'@import\\s+[\\'|\"]*\\s*" . str_replace("/", "\\/", BX_DOL_URL_ROOT) . "([a-zA-Z0-9\\.\\/_-]+)\\s*[\\'|\"]*\\s*;'", function ($aMatches) use($oTemplate, $sPath, $aIncluded) { return $oTemplate->_compileCss(realpath(BX_DIRECTORY_PATH_ROOT . $aMatches[1]), $aIncluded); }, $sContent); /* Match relative path based imports like the following: * @import url(../../../../../../base/profile/template/css/main.css); * Is mainly needed for default CSS files. */ $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 readUrl($sUrl, $aParams = array()) { return bx_file_get_contents($sUrl, $aParams); }
protected function storeFileLocally_Storage($mixedHandler) { $oStorageOriginal = BxDolStorage::getObjectInstance($this->_aObject['source_params']['object']); if (!$oStorageOriginal) { return false; } $aFile = $oStorageOriginal->getFile($mixedHandler); if (!$aFile) { return false; } $sUrl = $oStorageOriginal->getFileUrlById($mixedHandler); if (!$sUrl) { return false; } $sFileData = bx_file_get_contents($sUrl); if (false === $sFileData) { return false; } $sTmpFile = $this->getTmpFilename($aFile['file_name']); if (!file_put_contents($sTmpFile, $sFileData)) { return false; } return $sTmpFile; }