Example #1
0
 function cache()
 {
     $this->_aParams = $this->_oDb->getPairs("SELECT `Name`, `VALUE` FROM `sys_options`", "Name", "VALUE");
     if (empty($this->_aParams)) {
         $this->_aParams = array();
         return false;
     }
     return $this->_oCache->setData($this->_sCacheFile, $this->_aParams);
 }
Example #2
0
 function __construct($oConfig = null)
 {
     parent::__construct();
     if (is_a($oConfig, 'BxDolConfig')) {
         $this->_sPrefix = $oConfig->getDbPrefix();
     }
 }
Example #3
0
 /**
  * Instance of db class
  *
  * @return static
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new static();
     }
     return self::$instance;
 }
Example #4
0
 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;
 }
Example #5
0
 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;
 }
 /**
  * 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();
 }
Example #7
0
 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;
 }
 function __construct(&$aSystem)
 {
     $this->_aSystem =& $aSystem;
     $this->_sTable = $this->_aSystem['table_cmts'];
     $this->_sTableTrack = $this->_aSystem['table_track'];
     parent::__construct();
 }
Example #9
0
 function BxDolCmtsQuery(&$aSystem)
 {
     $this->_aSystem =& $aSystem;
     $this->_sTable = $this->_aSystem['table_cmts'];
     $this->_sTableTrack = $this->_aSystem['table_track'];
     parent::BxDolDb();
 }
Example #10
0
 public function __construct()
 {
     if (isset($GLOBALS['bxDolClasses'][get_class($this)])) {
         trigger_error('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
     }
     parent::__construct();
 }
Example #11
0
 function BxDolModuleDb($oConfig = null)
 {
     parent::BxDolDb();
     if (is_a($oConfig, 'BxDolConfig')) {
         $this->_sPrefix = $oConfig->getDbPrefix();
     }
 }
 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;
 }
Example #13
0
 function __construct()
 {
     parent::__construct();
     if (class_exists('BxDolDb') && BxDolDb::getInstance()) {
         $this->_aConfig['aLessConfig']['bx-page-width'] = getParam('main_div_width');
     }
 }
Example #14
0
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;
}
Example #15
0
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;
}
Example #16
0
 /**
  * Get singleton instance of the class
  */
 public static function getInstance($aDbConf = false, &$sError = null)
 {
     if (!isset($GLOBALS['bxDolClasses'][__CLASS__])) {
         if (false === $aDbConf && !defined('BX_DATABASE_HOST')) {
             return null;
         }
         $o = new BxDolDb($aDbConf);
         $sErrorMessage = $o->connect();
         if ($sErrorMessage) {
             if ($sError !== null) {
                 $sError = $sErrorMessage;
             }
             return null;
         } else {
             $GLOBALS['bxDolClasses'][__CLASS__] = $o;
         }
     }
     return $GLOBALS['bxDolClasses'][__CLASS__];
 }
Example #17
0
 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;
 }
Example #18
0
 public function __construct(&$oModule)
 {
     parent::__construct();
     $this->_oModule = $oModule;
     $aSystem = $this->_oModule->getSystemInfo();
     $this->_sTableTrack = $aSystem['table_track'];
     $this->_sTriggerTable = $aSystem['trigger_table'];
     $this->_sTriggerFieldId = $aSystem['trigger_field_id'];
     $this->_sTriggerFieldCount = $aSystem['trigger_field_count'];
     $this->_iPeriod = (int) $aSystem['period'];
 }
Example #19
0
 function BxDolPermalinks()
 {
     parent::BxDolDb();
     $oCache = $GLOBALS['MySQL']->getDbCacheObject();
     $this->aLinks = $oCache->getData($GLOBALS['MySQL']->genDbCacheKey('sys_permalinks'));
     if (null === $this->aLinks) {
         if (!$this->cache()) {
             $this->aLinks = array();
         }
     }
 }
 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();
         }
     }
 }
Example #21
0
 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;
 }
Example #22
0
 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');
 }
Example #23
0
 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));
 }
Example #24
0
 /**
  * constructor
  */
 function BxDolPrivacyQuery($sTable = '', $sFieldId = '', $sFieldOwnerId = '')
 {
     parent::BxDolDb();
     $this->_sTable = $sTable;
     $this->_sFieldId = $sFieldId;
     $this->_sFieldOwnerId = $sFieldOwnerId;
     $this->_sGroupCache = 'sys_ps_group_';
     $this->_sGroupsByOwnersCache = 'sys_ps_groups_owners_';
     $this->_sGroupMembersCache = 'sys_ps_group_members_';
     $this->_sObjectCache = 'sys_ps_object_';
     $this->_sActionCache = 'sys_ps_action_';
     $this->_sActionDefaultCache = 'sys_ps_action_default_';
 }
Example #25
0
 /**
  * constructor
  */
 function __construct($sTable = '', $sFieldId = '', $sFieldOwnerId = '')
 {
     parent::__construct();
     $this->_sTable = $sTable;
     $this->_sFieldId = $sFieldId;
     $this->_sFieldOwnerId = $sFieldOwnerId;
     $this->_sGroupCache = 'sys_ps_group_';
     $this->_sGroupsByOwnersCache = 'sys_ps_groups_owners_';
     $this->_sGroupMembersCache = 'sys_ps_group_members_';
     $this->_sObjectCache = 'sys_ps_object_';
     $this->_sActionCache = 'sys_ps_action_';
     $this->_sActionDefaultCache = 'sys_ps_action_default_';
 }
Example #26
0
 public function __construct(&$oModule)
 {
     parent::__construct();
     $this->_oModule = $oModule;
     $aSystem = $this->_oModule->getSystemInfo();
     $this->_sTable = $aSystem['table_main'];
     $this->_sTableTrack = $aSystem['table_track'];
     $this->_sTriggerTable = $aSystem['trigger_table'];
     $this->_sTriggerFieldId = $aSystem['trigger_field_id'];
     $this->_sTriggerFieldRate = $aSystem['trigger_field_rate'];
     $this->_sTriggerFieldCount = $aSystem['trigger_field_count'];
     $this->_iPostTimeout = (int) $aSystem['post_timeout'];
 }
 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;
 }
Example #28
0
 function __construct(&$oMain)
 {
     $this->_oMain = $oMain;
     $aSystem = $this->_oMain->getSystemInfo();
     $this->_sTable = $aSystem['table'];
     $this->_sTriggerTable = $aSystem['trigger_table'];
     $this->_sTriggerFieldId = $aSystem['trigger_field_id'];
     $this->_sTriggerFieldTitle = $aSystem['trigger_field_title'];
     $this->_sTriggerFieldComments = $aSystem['trigger_field_comments'];
     $this->_sTableImages = $aSystem['table_images'];
     $this->_sTableImages2Entries = $aSystem['table_images2entries'];
     parent::__construct();
 }
 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'];
 }
Example #30
0
 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));
 }