public function serviceLoginForm($sParams = '', $sForceRelocate = '') { if (isLogged()) { return false; } // get all auth types $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`'); // define additional auth types if ($aAuthTypes) { $aAddInputEl[''] = _t('_Basic'); // procces all additional menu's items foreach ($aAuthTypes as $iKey => $aItems) { $aAddInputEl[$aItems['Link']] = _t($aItems['Title']); } $aAuthTypes = array('type' => 'select', 'caption' => _t('_Auth type'), 'values' => $aAddInputEl, 'value' => '', 'attrs' => array('onchange' => 'if (this.value) { location.href = "' . BX_DOL_URL_ROOT . '" + this.value }')); } else { $aAuthTypes = array('type' => 'hidden'); } $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login'); $sCustomHtmlBefore = ''; $sCustomHtmlAfter = ''; bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes)); if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT)) { $oForm->aInputs['relocate']['value'] = $sForceRelocate; } elseif ('homepage' == $sForceRelocate) { $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT; } $sFormCode = $oForm->getCode(); $sJoinText = ''; if (strpos($sParams, 'no_join_text') === false) { $sJoinText = '<hr class="bx-def-hr bx-def-margin-sec-topbottom" /><div>' . _t('_sys_txt_login_description', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account')) . '</div>'; } BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js')); return $sCustomHtmlBefore . $sFormCode . $sCustomHtmlAfter . $sJoinText; }
protected function _action($sCache, $sMode = 'clear') { $sFuncCacheObject = $sMode == 'clear' ? '_clearObject' : '_getSizeObject'; $sFuncCacheFile = $sMode == 'clear' ? '_clearFile' : '_getSizeFile'; $mixedResult = false; switch ($sCache) { case 'db': if (getParam('sys_db_cache_enable') != 'on') { break; } $oCacheDb = BxDolDb::getInstance()->getDbCacheObject(); $mixedResult = $this->{$sFuncCacheObject}($oCacheDb, 'db_'); break; case 'template': if (getParam('sys_template_cache_enable') != 'on') { break; } $oCacheTemplates = BxDolTemplate::getInstance()->getTemplatesCacheObject(); $mixedResult = $this->{$sFuncCacheObject}($oCacheTemplates, BxDolStudioTemplate::getInstance()->getCacheFilePrefix($sCache)); break; case 'css': if (getParam('sys_template_cache_css_enable') != 'on') { break; } $mixedResult = $this->{$sFuncCacheFile}(BxDolStudioTemplate::getInstance()->getCacheFilePrefix($sCache), BX_DIRECTORY_PATH_CACHE_PUBLIC); break; case 'js': if (getParam('sys_template_cache_js_enable') != 'on') { break; } $mixedResult = $this->{$sFuncCacheFile}(BxDolStudioTemplate::getInstance()->getCacheFilePrefix($sCache), BX_DIRECTORY_PATH_CACHE_PUBLIC); break; } return $mixedResult; }
public static function getGridObject($sObject) { $oDb = BxDolDb::getInstance(); $sQuery = $oDb->prepare("SELECT * FROM `sys_objects_grid` WHERE `object` = ?", $sObject); $aObject = $oDb->getRow($sQuery); if (!$aObject || !is_array($aObject)) { return false; } // paginate if (!empty($aObject['paginate_url']) && 0 != strncasecmp($aObject['paginate_url'], 'http://', 7) && 0 != strncasecmp($aObject['paginate_url'], 'https://', 8)) { $aObject['paginate_url'] = BX_DOL_URL_ROOT . $aObject['paginate_url']; } // filter if ($aObject['filter_fields']) { $aObject['filter_fields'] = array_map('trim', explode(',', $aObject['filter_fields'])); } if ($aObject['filter_fields_translatable']) { $aObject['filter_fields_translatable'] = array_map('trim', explode(',', $aObject['filter_fields_translatable'])); } // sorting if ($aObject['sorting_fields']) { $aObject['sorting_fields'] = array_map('trim', explode(',', $aObject['sorting_fields'])); } if ($aObject['sorting_fields_translatable']) { $aObject['sorting_fields_translatable'] = array_map('trim', explode(',', $aObject['sorting_fields_translatable'])); $aObject['sorting_fields'] = array_merge($aObject['sorting_fields'], $aObject['sorting_fields_translatable']); } // get fields $sQuery = $oDb->prepare("SELECT * FROM `sys_grid_fields` WHERE `object` = ? ORDER BY `order`", $sObject); $aFields = $oDb->getAllWithKey($sQuery, 'name'); if (!$aFields || !is_array($aFields)) { // it is impossible to have grid without any fields return false; } foreach ($aFields as $sKey => $aRow) { $aObject['fields'][$sKey] = array('title' => _t($aRow['title']), 'width' => $aRow['width'], 'translatable' => $aRow['translatable'], 'chars_limit' => $aRow['chars_limit']); if (empty($aRow['params'])) { continue; } $aAdd = unserialize($aRow['params']); if (!empty($aAdd) && is_array($aAdd)) { $aObject['fields'][$sKey] = array_merge($aObject['fields'][$sKey], $aAdd); } } // get actions $a = array('bulk', 'single', 'independent'); foreach ($a as $sActionType) { $sActionField = 'actions_' . $sActionType; $aObject[$sActionField] = array(); $sQuery = $oDb->prepare("SELECT * FROM `sys_grid_actions` WHERE `object` = ? AND `type` = ? ORDER BY `order`", $sObject, $sActionType); $aActions = $oDb->getAllWithKey($sQuery, 'name'); if (!$aActions || !is_array($aActions)) { continue; } foreach ($aActions as $sKey => $aRow) { $aObject[$sActionField][$sKey] = $aRow['title'] || $aRow['icon'] ? array('title' => _t($aRow['title']), 'icon' => $aRow['icon'], 'confirm' => $aRow['confirm'], 'icon_only' => $aRow['icon_only']) : array(); } } return $aObject; }
function __construct() { parent::__construct(); if (class_exists('BxDolDb') && BxDolDb::getInstance()) { $this->_aConfig['aLessConfig']['bx-page-width'] = getParam('main_div_width'); } }
/** * Constructor */ public function __construct() { parent::__construct(); $this->aZonesUrls = array(2 => BX_DIRECTORY_PATH_MODULES . "boonex/antispam/data/two-level-tlds", 3 => BX_DIRECTORY_PATH_MODULES . "boonex/antispam/data/three-level-tlds"); $this->oDb = BxDolDb::getInstance(); $this->initZones(); }
public function serviceLoginForm($sParams = '', $sForceRelocate = '') { if (isLogged()) { return false; } // get all auth types $aAuthTypes = BxDolDb::getInstance()->fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`'); $oForm = BxDolForm::getObjectInstance('sys_login', 'sys_login'); $sCustomHtmlBefore = ''; $sCustomHtmlAfter = ''; bx_alert('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter, 'aAuthTypes' => &$aAuthTypes)); if ($sForceRelocate && 0 === mb_stripos($sForceRelocate, BX_DOL_URL_ROOT)) { $oForm->aInputs['relocate']['value'] = $sForceRelocate; } elseif ('homepage' == $sForceRelocate) { $oForm->aInputs['relocate']['value'] = BX_DOL_URL_ROOT; } $sFormCode = $oForm->getCode(); $sJoinText = ''; if (strpos($sParams, 'no_join_text') === false) { $sJoinText = '<hr class="bx-def-hr bx-def-margin-sec-topbottom" /><div class="bx-def-font-align-center">' . _t('_sys_txt_login_description', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account')) . '</div>'; } BxDolTemplate::getInstance()->addJs(array('jquery.form.min.js')); $sAuth = $this->serviceMemberAuthCode($aAuthTypes); return $sCustomHtmlBefore . $sAuth . $sFormCode . $sCustomHtmlAfter . $sJoinText; }
function initVideoFile($sId, $sTitle, $sCategory, $sTags, $sDesc) { global $sModule; $oDb = BxDolDb::getInstance(); $sDBModule = DB_PREFIX . ucfirst($sModule); getResult("UPDATE `" . $sDBModule . "Files` SET `Categories`='" . $sCategory . "', `Title`='" . $sTitle . "', `Tags`='" . $sTags . "', `Description`='" . $sDesc . "' WHERE `ID`='" . $sId . "'"); return $oDb->getAffectedRows() > 0 ? true : false; }
public static function getPrivacyObject($sObject) { $oDb = BxDolDb::getInstance(); $sQuery = $oDb->prepare("SELECT * FROM `sys_objects_privacy` WHERE `object` = ?", $sObject); $aObject = $oDb->getRow($sQuery); if (!$aObject || !is_array($aObject)) { return false; } return $aObject; }
function initFile($sId, $sTitle, $sCategory, $sTags, $sDesc) { global $sModule; $oDb = BxDolDb::getInstance(); $sUri = mp3_genUri($sTitle); $sUriPart = empty($sUri) ? "" : "`Uri`='" . $sUri . "', "; $sDBModule = DB_PREFIX . ucfirst($sModule); getResult("UPDATE `" . $sDBModule . "Files` SET `Categories`= ?, `Title`= ?, " . $sUriPart . "`Tags`= ?, `Description`= ? WHERE `ID`= ?", [$sCategory, $sTitle, $sTags, $sDesc, $sId]); return $oDb->getAffectedRows() > 0 ? true : false; }
function __construct() { $this->oDb = BxDolDb::getInstance(); $this->iViewer = getLoggedId(); $this->sCacheFile = 'sys_objects_tag'; $this->sNonParseParams = 'tags_non_parsable'; $this->sCacheTable = 'sys_objects_tag'; $this->sTagTable = 'sys_tags'; $this->aTagFields = array('id' => 'ObjID', 'type' => 'Type', 'tag' => 'Tag', 'date' => 'Date'); $this->aObjFields = array('id' => 'ID', 'name' => 'ObjectName', 'query' => 'Query', 'perm_param' => 'PermalinkParam', 'perm_enable' => 'EnabledPermalink', 'perm_disable' => 'DisabledPermalink', 'lang_key' => 'LangKey'); }
function __construct(&$aModule) { parent::__construct($aModule); $aConfig = array('client_table' => 'bx_oauth_clients', 'access_token_table' => 'bx_oauth_access_tokens', 'refresh_token_table' => 'bx_oauth_refresh_tokens', 'code_table' => 'bx_oauth_authorization_codes', 'user_table' => 'Profiles', 'jwt_table' => '', 'jti_table' => '', 'scope_table' => 'bx_oauth_scopes', 'public_key_table' => ''); $this->_oStorage = new OAuth2\Storage\Pdo(BxDolDb::getInstance()->getLink(), $aConfig); $this->_oServer = new OAuth2\Server($this->_oStorage, array('require_exact_redirect_uri' => false)); // Add the "Client Credentials" grant type (it is the simplest of the grant types) $this->_oServer->addGrantType(new OAuth2\GrantType\ClientCredentials($this->_oStorage)); // Add the "Authorization Code" grant type (this is where the oauth magic happens) $this->_oServer->addGrantType(new OAuth2\GrantType\AuthorizationCode($this->_oStorage)); }
protected function setPageWidth($sParamName) { if (!class_exists('BxDolDb') || !BxDolDb::getInstance() || empty($sParamName)) { return; } $mixedWidth = getParam($sParamName); if (is_numeric($mixedWidth)) { $mixedWidth .= 'px'; } $this->_aConfig['aLessConfig']['bx-page-width'] = $mixedWidth; }
function __construct() { $this->oDb = BxDolDb::getInstance(); $oCache = $this->oDb->getDbCacheObject(); $this->aLinks = $oCache->getData($this->oDb->genDbCacheKey('sys_permalinks')); if (null === $this->aLinks) { if (!$this->cache()) { $this->aLinks = array(); } } }
public static function getMemberInfoKeysByType($sType) { $oDb = BxDolDb::getInstance(); $sQuery = "SELECT * FROM `sys_objects_member_info` WHERE `type` = ? ORDER BY `title` ASC"; $aObjects = $oDb->getPairs($sQuery, 'object', 'title', [$sType]); if (!$aObjects || !is_array($aObjects)) { return false; } foreach ($aObjects as $k => $v) { $aObjects[$k] = _t($v); } return $aObjects; }
public function getSystems() { if (!isset($GLOBALS['bx_dol_live_updates_systems'])) { $GLOBALS['bx_dol_live_updates_systems'] = BxDolDb::getInstance()->fromCache('sys_objects_live_updates', 'getAllWithKey', ' SELECT `id` as `id`, `name` AS `name`, `frequency` AS `frequency`, `service_call` AS `service_call`, `active` AS `active` FROM `sys_objects_live_updates`', 'name'); } return $GLOBALS['bx_dol_live_updates_systems']; }
public static function addMenuItemToSet($aMenuItem) { $oDb = BxDolDb::getInstance(); if (empty($aMenuItem['set_name'])) { return false; } if (empty($aMenuItem['order'])) { $sQuery = $oDb->prepare("SELECT `order` FROM `sys_menu_items` WHERE `set_name` = ? AND `active` = 1 AND `order` != 9999 ORDER BY `order` DESC LIMIT 1", $aMenuItem['set_name']); $iProfileMenuOrder = (int) $oDb->getOne($sQuery); $aMenuItem['order'] = $iProfileMenuOrder + 1; } unset($aMenuItem['id']); return $oDb->query("INSERT INTO `sys_menu_items` SET " . $oDb->arrayToSQL($aMenuItem)); }
public static function addPageBlockToPage($aPageBlock) { $oDb = BxDolDb::getInstance(); if (empty($aPageBlock['object'])) { return false; } if (empty($aPageBlock['order'])) { $iCellId = !empty($aPageBlock['cell_id']) ? (int) $aPageBlock['cell_id'] : 1; $sQuery = $oDb->prepare("SELECT `order` FROM `sys_pages_blocks` WHERE `object` = ? AND `cell_id` = ? AND `active` = 1 ORDER BY `order` DESC LIMIT 1", $aPageBlock['object'], $iCellId); $aPageBlock['order'] = (int) $oDb->getOne($sQuery) + 1; } $sQuery = $oDb->prepare("DELETE FROM `sys_pages_blocks` WHERE `object` = ? AND `type` = ? AND `title` = ?", $aPageBlock['object'], $aPageBlock['type'], $aPageBlock['title']); $oDb->query($sQuery); unset($aPageBlock['id']); return $oDb->query("INSERT INTO `sys_pages_blocks` SET " . $oDb->arrayToSQL($aPageBlock)); }
public function serviceGetProfilesModules() { if (getParam('sys_db_cache_enable')) { // get list of profiles modules from db cache, cache is invalidated when new module is installed $oDb = BxDolDb::getInstance(); $oCache = $oDb->getDbCacheObject(); $sKey = $oDb->genDbCacheKey('profiles_modules_array'); $sKeyTs = $oDb->genDbCacheKey('profiles_modules_ts'); $mixedRetTs = $oCache->getData($sKeyTs); $mixedRet = $oCache->getData($sKey); $iNewestModuleTs = $this->_getLatestModuleTimestamp(); if ($mixedRetTs != null && $mixedRet !== null && $mixedRetTs == $iNewestModuleTs) { $aModulesArray = $mixedRet; } else { $aModulesArray = $this->_getProfilesModules(); $oCache->setData($sKey, $aModulesArray); $oCache->setData($sKeyTs, $iNewestModuleTs); } } else { $aModulesArray = $this->_getProfilesModules(); } return $aModulesArray; }
protected function optimizationMySQL() { $s = ''; $oDb = BxDolDb::getInstance(); foreach ($this->aMysqlOptimizationSettings as $sName => $r) { $a = $this->checkMysqlSetting($sName, $r, $oDb); $aMessage = array('type' => BX_DOL_AUDIT_OK); if (!$a['res']) { $aMessage = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => _t('_sys_audit_msg_must_be', $r['op'], $this->format_output($r['val'], $r))); } $s .= $this->getBlock($sName, $this->format_output($a['real_val'], $r), $this->getMsgHTML($sName, $aMessage)); } echo $this->getSection('MySQL', '', $s); }
public static function &getSystems() { if (!isset($GLOBALS['bx_dol_cmts_systems'])) { $GLOBALS['bx_dol_cmts_systems'] = BxDolDb::getInstance()->fromCache('sys_objects_cmts', 'getAllWithKey', ' SELECT `ID` as `system_id`, `Name` AS `name`, `Table` AS `table`, `CharsPostMin` AS `chars_post_min`, `CharsPostMax` AS `chars_post_max`, `CharsDisplayMax` AS `chars_display_max`, `Nl2br` AS `nl2br`, `PerView` AS `per_view`, `PerViewReplies` AS `per_view_replies`, `BrowseType` AS `browse_type`, `IsBrowseSwitch` AS `is_browse_switch`, `PostFormPosition` AS `post_form_position`, `NumberOfLevels` AS `number_of_levels`, `IsDisplaySwitch` AS `is_display_switch`, `IsRatable` AS `is_ratable`, `ViewingThreshold` AS `viewing_threshold`, `IsOn` AS `is_on`, `RootStylePrefix` AS `root_style_prefix`, `BaseUrl` AS `base_url`, `ObjectVote` AS `object_vote`, `TriggerTable` AS `trigger_table`, `TriggerFieldId` AS `trigger_field_id`, `TriggerFieldTitle` AS `trigger_field_title`, `TriggerFieldComments` AS `trigger_field_comments`, `ClassName` AS `class_name`, `ClassFile` AS `class_file` FROM `sys_objects_cmts`', 'name'); } return $GLOBALS['bx_dol_cmts_systems']; }
protected function getInjectionsData() { $oDb = BxDolDb::getInstance(); $aInjections = $oDb->getAll("SELECT `page_index`, `name`, `key`, `type`, `data`, `replace` FROM `" . $this->_sInjectionsTable . "` WHERE `active`='1'"); if (!$aInjections) { return array(); } foreach ($aInjections as $aInjection) { $aInjections['page_' . $aInjection['page_index']][$aInjection['key']][] = $aInjection; } return $aInjections; }
public static function getNextInQueue($sServer, $iLimit = 5) { $oDb = BxDolDb::getInstance(); $sQuery = $oDb->prepare("SELECT COUNT(*) FROM `" . self::TABLE_QUEUE . "` WHERE `server` = ? AND `status` = 'processing'", $sServer); if ($oDb->getOne($sQuery)) { return array(); } $sQuery = $oDb->prepare("SELECT * FROM `" . self::TABLE_QUEUE . "` WHERE `status` = 'pending' ORDER BY `added` ASC LIMIT ?", $iLimit); return $oDb->getAll($sQuery); }
function escape($s) { return BxDolDb::getInstance()->escape($s, false); }
function endQuery(&$res) { if (!$this->_sQueryIndex) { return; } $iTime = $this->_calcTime($this->_aQueries[$this->_sQueryIndex]['begin']); unset($this->_aQueries[$this->_sQueryIndex]['begin']); $this->_aQueries[$this->_sQueryIndex]['time'] = $this->_formatTime($iTime, 5); $this->_aQueries[$this->_sQueryIndex]['raw_time'] = $iTime; $this->_aQueries[$this->_sQueryIndex]['rows'] = $res ? BxDolDb::getInstance()->getNumRows($res) : ''; $this->_aQueries[$this->_sQueryIndex]['affected'] = $res ? BxDolDb::getInstance()->getAffectedRows($res) : ''; if (isset($this->aConf['long_query']) && $iTime > $this->aConf['long_query']) { $this->logSqlQuery($iTime, $this->_aQueries[$this->_sQueryIndex], $res); } }
/** * Get set from several values for 'in' and 'not in' operators * @param $aValues array of values * return sql code for field with operator IN (NOT IN) */ function getMultiValues($aValues) { $oDb = BxDolDb::getInstance(); return $oDb->implode_escape($aValues); }
/** * it is called on cron every day or similar period to clean old votes */ public static function maintenance() { $iResult = 0; $oDb = BxDolDb::getInstance(); $aSystems = self::getSystems(); foreach ($aSystems as $aSystem) { if (!$aSystem['is_on']) { continue; } $sQuery = $oDb->prepare("DELETE FROM `{$aSystem['table_track']}` WHERE `date` < (UNIX_TIMESTAMP() - ?)", BX_DOL_VIEW_OLD_VIEWS); $iDeleted = (int) $oDb->query($sQuery); if ($iDeleted > 0) { $oDb->query("OPTIMIZE TABLE `{$aSystem['table_track']}`"); } $iResult += $iDeleted; } return $iResult; }
/** * Cache alerts and handlers. * * @return an array with all alerts and handlers. */ public function getAlertsData() { $oDb = BxDolDb::getInstance(); $aResult = array('alerts' => array(), 'handlers' => array()); $aAlerts = $oDb->getAll("SELECT `unit`, `action`, `handler_id` FROM `sys_alerts` ORDER BY `id` ASC"); foreach ($aAlerts as $aAlert) { $aResult['alerts'][$aAlert['unit']][$aAlert['action']][] = $aAlert['handler_id']; } $aHandlers = $oDb->getAll("SELECT `id`, `class`, `file`, `service_call`, `name` FROM `sys_alerts_handlers` ORDER BY `id` ASC"); foreach ($aHandlers as $aHandler) { $aResult['handlers'][$aHandler['id']] = array('class' => $aHandler['class'], 'file' => $aHandler['file'], 'service_call' => $aHandler['service_call'], 'name' => $aHandler['name']); } return $aResult; }
protected function _enable($mixedId, $isChecked) { $oDb = BxDolDb::getInstance(); $sTable = $this->_aOptions['table']; $sFieldId = $this->_aOptions['field_id']; $sFieldActive = $this->_aOptions['field_active']; $sQuery = $oDb->prepare("UPDATE `{$sTable}` SET `{$sFieldActive}` = ? WHERE `{$sFieldId}` = ?", $this->_switcherChecked2State($isChecked), $mixedId); return $oDb->query($sQuery); }
function getData() { $oDb = BxDolDb::getInstance(); return $oDb->getAll("SELECT *, DAYOFMONTH(`Date`) AS `Day`\n FROM `sys_categories`\n WHERE `Date` >= TIMESTAMP(?)\n AND `Date` < TIMESTAMP(?)\n AND `Owner` <> 0 AND `Status` = 'active'", ["{$this->iYear}-{$this->iMonth}-1", "{$this->iNextYear}-{$this->iNextMonth}-1"]); }
/** * Get system DB version, for files version @see BX_DOL_VERSION, these versions must match */ function bx_get_ver($bInvalidateCache = false) { bx_import('BxDolDb'); $oDb = BxDolDb::getInstance(); if ($bInvalidateCache) { $oDb->cleanMemory('sys_version'); } $sQuery = $oDb->prepare("SELECT `version` FROM `sys_modules` WHERE `name` = 'system'"); return $oDb->fromMemory('sys_version', 'getOne', $sQuery); }