protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln("Install bitrix..."); global $DB, $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $DBDebug, $DBDebugToFile, $APPLICATION, $USER, $arWizardConfig, $MESS; $bitrixRoot = $this->projectPath; $_SERVER["DOCUMENT_ROOT"] = $bitrixRoot; $_SERVER["REQUEST_URI"] = "/index.php"; $_SERVER["QUERY_STRING"] = ""; define("B_PROLOG_INCLUDED", true); ob_start(); require_once "{$bitrixRoot}/bitrix/modules/main/install/wizard/wizard.php"; ob_end_clean(); $output->writeln("Step 1. Create database:"); $wizard = new \CWizardBase("nonlux.createDb.wizard", null); $dbName = time() . "_db"; $output->writeln("database name: {$dbName}"); $data = $this->getConfig(array("agree_license", "user", "password", "database", "utf8", "dbType", "host", "create_user", "create_database", "root_user", "root_password", 'file_access_perms', 'folder_access_perms', 'bitrixRoot')); foreach ($data as $key => $value) { $wizard->SetVar($key, $value); } $step = new \CreateDBStep(); $wizard->AddStep($step); $step->OnPostForm(); $output->writeln("Done"); require_once $bitrixRoot . '/bitrix/php_interface/dbconn.php'; $output->writeln("Step 2. Install modules:"); $wizard = new \CWizardBase("nonlux.installModules.wizard", null); $data = array_merge(array("nextStep" => "main", "nextStepStage" => "utf8"), $this->getConfig(array('bitrixRoot', "user", "password", "utf8"))); $step = new CreateModulesStep(); $wizard->AddStep($step); foreach ($data as $key => $value) { $wizard->SetVar($key, $value); } do { $output->writeln("Install " . $wizard->GetVar("nextStep") . " " . $wizard->GetVar("nextStepStage")); $step->OnPostForm(); if ($wizard->GetVar("nextStep") === 'main' && $wizard->GetVar("nextStepStage") === 'files') { $HttpApplication = \Bitrix\Main\HttpApplication::getInstance(); $HttpApplication->initializeBasicKernel(); $HttpApplication->getCache()->clearCache(true); $GLOBALS['CACHE_MANAGER']->Clean('b_option'); Option::clearOptions("main"); } } while ($wizard->GetVar('nextStep') != '__finish'); $output->writeln("Done"); $USER = new \CUser(); $policy = $USER->GetSecurityPolicy(); $output->writeln("Step 3. Create admin:"); $data = $this->getConfig(array('email', 'login', 'admin_password_confirm', 'admin_password', 'user_name', "utf8", 'user_surname')); foreach ($data as $key => $value) { $wizard->SetVar($key, $value); } $wizard = new \CWizardBase("nonlux.admin.wizard", null); $step = new \CreateAdminStep(); $wizard->AddStep($step); $step->OnPostForm(); $output->writeln("Done"); $step = new \FinishStep(); $step->ShowStep(); }
public static function search($words) { $dbConnection = Main\HttpApplication::getConnection(); $dbHelper = Main\HttpApplication::getConnection()->getSqlHelper(); $wordStatTableName = WordStatTable::getTableName(); $preparedLike = array(); foreach ($words as $word) { $preparedLike[] = "%TABLE_NAME%.WORD like '" . $dbHelper->forSql($word) . "%'"; } $preparedLike = implode(' or ', $preparedLike); $sql = "\n\t\t\tselect C.*, WS_CITY.WORD as CWORD, WS_VILLAGE.WORD as VWORD, WS_STREET.WORD as SWORD from " . static::getTableName() . " C\n\n\t\t\t\tinner join b_sale_loc_word_stat WS_STREET on \n\n\t\t\t\t\t(\n\t\t\t\t\t\tWS_STREET.TYPE_ID = '7'\n\t\t\t\t\t\tand\n\t\t\t\t\t\tWS_STREET.LOCATION_ID = C.STREET_ID\n\t\t\t\t\t\tand\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(" . str_replace(array('%TABLE_NAME%'), array('WS_STREET'), $preparedLike) . ")\n\t\t\t\t\t\t\tor\n\t\t\t\t\t\t\t(WS_STREET.LOCATION_ID = '0')\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\n\t\t\t\tinner join b_sale_loc_word_stat WS_VILLAGE on \n\n\t\t\t\t\t(\n\t\t\t\t\t\tWS_VILLAGE.TYPE_ID = '6'\n\t\t\t\t\t\tand\n\t\t\t\t\t\tWS_VILLAGE.LOCATION_ID = C.VILLAGE_ID\n\t\t\t\t\t\tand\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(" . str_replace(array('%TABLE_NAME%'), array('WS_VILLAGE'), $preparedLike) . ")\n\t\t\t\t\t\t\tor\n\t\t\t\t\t\t\t(WS_VILLAGE.LOCATION_ID = '0')\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\n\t\t\t\tinner join b_sale_loc_word_stat WS_CITY on \n\n\t\t\t\t\t(\n\t\t\t\t\t\tWS_CITY.TYPE_ID = '3'\n\t\t\t\t\t\tand\n\t\t\t\t\t\tWS_CITY.LOCATION_ID = C.CITY_ID\n\t\t\t\t\t\tand\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(" . str_replace(array('%TABLE_NAME%'), array('WS_CITY'), $preparedLike) . ")\n\t\t\t\t\t\t\tor\n\t\t\t\t\t\t\t(WS_CITY.LOCATION_ID = '0')\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\n\t\t\torder by C.TYPE_SORT desc\n\t\t\tlimit 5\n\t\t"; /* $sql = " select * from ".static::getTableName()." C where ( C.CITY_ID = 0 or C.CITY_ID in ( select LOCATION_ID from b_sale_loc_word_stat where TYPE_ID = 3 and (".$preparedLike.") ) ) and ( C.VILLAGE_ID = 0 or C.VILLAGE_ID in ( select LOCATION_ID from b_sale_loc_word_stat where TYPE_ID = 6 and (".$preparedLike.") ) ) and ( C.STREET_ID = 0 or C.STREET_ID in ( select LOCATION_ID from b_sale_loc_word_stat where TYPE_ID = 7 and (".$preparedLike.") ) ) order by C.TYPE_SORT desc limit 5 "; */ print '<pre>'; print_r($sql); print '</pre>'; return $dbConnection->query($sql); }
public static function initializeData() { $locationTable = Location\LocationTable::getTableName(); $groupLocationTable = Location\GroupLocationTable::getTableName(); $siteLocationTable = Location\SiteLocationTable::getTableName(); // ORACLE: OK, MSSQL: OK $sql = "\n\t\t\tinsert into " . static::getTableName() . " \n\t\t\t\t(LOCATION_ID, SITE_ID) \n\t\t\tselect LC.ID, LS.SITE_ID\n\t\t\t\tfrom " . $siteLocationTable . " LS\n\t\t\t\t\tinner join " . $locationTable . " L on LS.LOCATION_ID = L.ID and LS.LOCATION_TYPE = 'L'\n\t\t\t\t\tinner join " . $locationTable . " LC on LC.LEFT_MARGIN >= L.LEFT_MARGIN and LC.RIGHT_MARGIN <= L.RIGHT_MARGIN\n\t\t\tunion \n\t\t\tselect LC.ID, LS.SITE_ID\n\t\t\t\tfrom " . $siteLocationTable . " LS\n\t\t\t\t\tinner join " . $groupLocationTable . " LG on LS.LOCATION_ID = LG.LOCATION_GROUP_ID and LS.LOCATION_TYPE = 'G'\n\t\t\t\t\tinner join " . $locationTable . " L on LG.LOCATION_ID = L.ID\n\t\t\t\t\tinner join " . $locationTable . " LC on LC.LEFT_MARGIN >= L.LEFT_MARGIN and LC.RIGHT_MARGIN <= L.RIGHT_MARGIN\n\t\t"; Main\HttpApplication::getConnection()->query($sql); }
public static function setDebugModeOn() { global $DB, $APPLICATION; // define("PERFMON_STARTED", $DB->ShowSqlStat."|".\Bitrix\Main\Data\Cache::getShowCacheStat()."|".$APPLICATION->ShowIncludeStat); $DB->ShowSqlStat = true; $application = \Bitrix\Main\HttpApplication::getInstance(); $application->getConnection()->startTracker(); \Bitrix\Main\Data\Cache::setShowCacheStat(COption::GetOptionString("perfmon", "cache_log") === "Y"); $APPLICATION->ShowIncludeStat = true; }
protected static function addPropertyValueField($tableAlias = 'V', &$arFields, &$arSelectFields) { $tableAlias = \Bitrix\Main\HttpApplication::getConnection()->getSqlHelper()->forSql($tableAlias); // locations kept in CODEs, but must be shown as IDs if (CSaleLocation::isLocationProMigrated()) { $arSelectFields = array_merge(array('PROP_TYPE'), $arSelectFields); // P.TYPE should be there and go above our join $arFields['VALUE'] = array("FIELD" => "\n\t\t\t\tCASE\n\n\t\t\t\t\tWHEN\n\t\t\t\t\t\tP.TYPE = 'LOCATION'\n\t\t\t\t\tTHEN\n\t\t\t\t\t\tCAST(L.ID as " . \Bitrix\Sale\Location\DB\Helper::getSqlForDataType('char', 255) . ")\n\n\t\t\t\t\tELSE\n\t\t\t\t\t\t" . $tableAlias . ".VALUE\n\t\t\t\tEND\n\t\t\t", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location L ON (P.TYPE = 'LOCATION' AND " . $tableAlias . ".VALUE IS NOT NULL AND " . $tableAlias . ".VALUE = L.CODE)"); $arFields['VALUE_ORIG'] = array("FIELD" => $tableAlias . ".VALUE", "TYPE" => "string"); } else { $arFields['VALUE'] = array("FIELD" => $tableAlias . ".VALUE", "TYPE" => "string"); } }
public static function dropIndexByName($indexName, $tableName) { $dbConnection = Main\HttpApplication::getConnection(); $dbHelper = $dbConnection->getSqlHelper(); $indexName = $dbHelper->forSql(trim($indexName)); $tableName = $dbHelper->forSql(trim($tableName)); if (!strlen($indexName) || !strlen($tableName)) { return false; } if (!static::checkIndexNameExists($indexName, $tableName)) { return false; } $dbConnection->query("drop index {$indexName} on {$tableName}"); return true; }
protected function execute(InputInterface $input, OutputInterface $output) { global $DB, $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $DBDebug, $DBDebugToFile, $APPLICATION, $USER, $arWizardConfig, $MESS; $bitrixRoot = $this->projectPath; $output->writeln("Install bitrix... in {$bitrixRoot}"); $st = 1; /* $output->writeln("Step $st. Create database:"); ++$st; $wizard = new \CWizardBase("nonlux.createDb.wizard", null); $dbName = $this->config['database']; $output->writeln("database name: $dbName"); $data = $this->getConfig(array( "agree_license", "user" , "password", "database", "utf8", "dbType", "host", "create_user", "create_database", "root_user", "root_password", 'file_access_perms', 'folder_access_perms', 'bitrixRoot' )); foreach ($data as $key => $value) { $wizard->SetVar($key, $value); } $step = new \CreateDBStep(); $wizard->AddStep($step); $step->OnPostForm(); $errors=$step->GetErrors(); if (isset($errors[0])){ $last_error=iconv('cp1251', 'utf-8', $errors[0][0]); throw new \Exception($last_error); } $output->writeln("Done"); */ $output->writeln("Step {$st}. Generate config files:"); ++$st; $data = $this->getConfig(array("agree_license", "user", "password", "database", "utf8", "dbType", "host", "create_user", "create_database", "root_user", "root_password", 'file_access_perms', 'folder_access_perms', 'bitrixRoot')); $settings = sprintf("<?php\nreturn array (\n 'className' => '\\\\Bitrix\\\\Main\\\\DB\\\\MysqliConnection',\n 'host' => '%s',\n 'database' => '%s',\n 'login' => '%s',\n 'password' => '%s',\n 'options' => 2,\n );\n", $data['host'], $data['database'], $data['user'], $data['password']); file_put_contents($bitrixRoot . '/bitrix/.db_settings.php', $settings); $settings = "<?php return require(__DIR__.'/.settings_prod.php');"; file_put_contents($bitrixRoot . '/bitrix/.settings.php', $settings); $output->writeln("Done"); $_SERVER["DOCUMENT_ROOT"] = $bitrixRoot; $_SERVER["REQUEST_URI"] = "/index.php"; $_SERVER["QUERY_STRING"] = ""; define("B_PROLOG_INCLUDED", true); ob_start(); require_once "{$bitrixRoot}/bitrix/modules/main/install/wizard/wizard.php"; ob_end_clean(); require_once $bitrixRoot . '/bitrix/php_interface/dbconn.php'; $connection = \Bitrix\Main\Application::getConnection(); var_dump($connection); $output->writeln("Step {$st}. Install modules:"); ++$st; $wizard = new \CWizardBase("nonlux.installModules.wizard", null); $data = array_merge(array("nextStep" => "main", "nextStepStage" => "files"), $this->getConfig(array('bitrixRoot', "user", "password", "utf8"))); $step = new CreateModulesStep(); $wizard->AddStep($step); foreach ($data as $key => $value) { $wizard->SetVar($key, $value); } do { $wizard->SetVar("nextStepStage", "files"); $output->writeln("Install " . $wizard->GetVar("nextStep") . " " . $wizard->GetVar("nextStepStage")); $step->OnPostForm(); if ($wizard->GetVar("nextStep") === 'main' && $wizard->GetVar("nextStepStage") === 'files') { $HttpApplication = \Bitrix\Main\HttpApplication::getInstance(); $HttpApplication->initializeBasicKernel(); $HttpApplication->getCache()->clearCache(true); $GLOBALS['CACHE_MANAGER']->Clean('b_option'); Option::clearOptions("main"); } } while ($wizard->GetVar('nextStep') != '__finish'); $output->writeln("Done"); /* $USER = new \CUser; $policy = $USER->GetSecurityPolicy(); $output->writeln("Step $st. Create admin:"); ++$st; $data = $this->getConfig(array( 'email', 'login', 'admin_password_confirm', 'admin_password', 'user_name', "utf8", 'user_surname' )); foreach ($data as $key => $value) { $wizard->SetVar($key, $value); } $wizard = new \CWizardBase("nonlux.admin.wizard", null); $step = new \CreateAdminStep(); $wizard->AddStep($step); $step->OnPostForm(); $output->writeln("Done"); $step = new \FinishStep(); $step->ShowStep(); */ }
<?php if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/d7.php")) { function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return (double) $usec + (double) $sec; } require_once dirname(__FILE__) . "/../bx_root.php"; include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/lib/loader.php"; /** @var $application \Bitrix\Main\HttpApplication */ $application = \Bitrix\Main\HttpApplication::getInstance(); $application->turnOnCompatibleMode(); $application->setInputParameters($_GET, $_POST, $_FILES, $_COOKIE, $_SERVER, $_ENV); $application->initialize(); $page = new \Bitrix\Main\PublicPage(); $application->setPage($page); $application->start(); CMain::PrologActions(); return; } define("START_EXEC_PROLOG_BEFORE_1", microtime()); $GLOBALS["BX_STATE"] = "PB"; if (isset($_REQUEST["BX_STATE"])) { unset($_REQUEST["BX_STATE"]); } if (isset($_GET["BX_STATE"])) { unset($_GET["BX_STATE"]); } if (isset($_POST["BX_STATE"])) { unset($_POST["BX_STATE"]);
public static function truncateTable($tableName) { $dbConnection = Main\HttpApplication::getConnection(); $tableName = $dbConnection->getSqlHelper()->forSql($tableName); if ($dbConnection->isTableExists($tableName)) { Main\HttpApplication::getConnection()->query('truncate table ' . $tableName); } }
protected function prepareSql($row) { if(!is_array($row) || empty($row)) return ''; $sql = array(); foreach($this->fldVector as $fld => $none) { $val = $row[$fld]; // only numeric and literal fields supported at the moment if($this->tableMap[$fld]['data_type'] == 'integer') $sql[] = intval($val); else $sql[] = "'".Main\HttpApplication::getConnection()->getSqlHelper()->forSql($val)."'"; } return '('.implode(',', $sql).')'; }
public static function resetAutoIncrement($tableName, $startIndex = 1) { $startIndex = intval($startIndex); if ($startIndex <= 0 || !strlen($tableName)) { return false; } $dbConnection = Main\HttpApplication::getConnection(); $dbHelper = $dbConnection->getSqlHelper(); $tableName = $dbHelper->forSql(trim($tableName)); if (strlen($tableName) > 27) { // too long return false; } if ($sqName = Helper::checkSequenceExistsForTable($tableName)) { $dbConnection->query('drop sequence ' . $sqName); } $dbConnection->query('create sequence ' . $sqName . ' start with ' . $startIndex . ' increment by 1 NOMAXVALUE NOCYCLE NOCACHE NOORDER'); $dbConnection->query("\n\t\t\tCREATE OR REPLACE TRIGGER " . $tableName . "_I\n\t\t\tBEFORE INSERT\n\t\t\tON " . $tableName . "\n\t\t\tFOR EACH ROW\n\t\t\tBEGIN\n\t\t\t\tIF :NEW.ID IS NULL THEN\n\t\t\t\t\tSELECT " . $sqName . ".NEXTVAL INTO :NEW.ID FROM dual;\n\t\t\t\tEND IF;\n\t\t\tEND;\n\t\t"); return true; }
public static function resetLegacyPath() { Helper::dropTable(self::TABLE_LEGACY_RELATIONS); $dbConnection = \Bitrix\Main\HttpApplication::getConnection(); $dbConnection->query("create table " . self::TABLE_LEGACY_RELATIONS . " (\n\t\t\tID " . Helper::getSqlForDataType('int') . ",\n\t\t\tCOUNTRY_ID " . Helper::getSqlForDataType('int') . ",\n\t\t\tREGION_ID " . Helper::getSqlForDataType('int') . ",\n\t\t\tCITY_ID " . Helper::getSqlForDataType('int') . "\n\t\t)"); $dbConnection->query("insert into " . self::TABLE_LEGACY_RELATIONS . " (ID, COUNTRY_ID, REGION_ID, CITY_ID) select ID, COUNTRY_ID, REGION_ID, CITY_ID from b_sale_location"); Location\LocationTable::resetLegacyPath(); }
protected static function getNameOfParentOfType($item, $typeCode, $strLang = LANGUAGE_ID) { /* $item = Location\LocationTable::getList(array('filter' => array( '<=LEFT_MARGIN' => $item['LEFT_MARGIN'], '>=RIGHT_MARGIN' => $item['RIGHT_MARGIN'], '=TYPE.CODE' => $typeCode, '=NAME.LANGUAGE_ID' => $strLang ), 'select' => array( ToUpper($typeCode).'_NAME' => 'NAME.NAME', ToUpper($typeCode).'_NAME_ORIG' => 'NAME.NAME', ToUpper($typeCode).'_SHORT_NAME' => 'NAME.SHORT_NAME', ToUpper($typeCode).'_NAME_LANG' => 'NAME.LANGUAGE_ID' )))->fetch(); */ global $DB; $dbConnection = Main\HttpApplication::getConnection(); $dbHelper = $dbConnection->getSqlHelper(); $types = self::getTypes(); $typeCode = ToUpper($dbHelper->forSql($typeCode)); $strLang = substr($dbHelper->forSql($strLang), 0, 2); $mappedTypes = array("'" . intval($types[$typeCode]) . "'"); if ($typeCode == 'CITY' && intval($types['VILLAGE'])) { $mappedTypes[] = "'" . intval($types['VILLAGE']) . "'"; } $query = "\n\t\t\tselect \n\t\t\t\tN.NAME as " . $typeCode . "_NAME,\n\t\t\t\tN.SHORT_NAME as " . $typeCode . "_SHORT_NAME,\n\t\t\t\tL.ID as " . $typeCode . "_ID\n\t\t\tfrom \n\t\t\t\tb_sale_loc_name N\n\t\t\t\tinner join b_sale_location L on \n\t\t\t\t\tN.LOCATION_ID = L.ID \n\t\t\t\t\tand\n\t\t\t\t\tN.LANGUAGE_ID = '" . $strLang . "'\n\t\t\t\t\tand\n\t\t\t\t\tL.LEFT_MARGIN <= '" . intval($item['LEFT_MARGIN']) . "'\n\t\t\t\t\tand\n\t\t\t\t\tL.RIGHT_MARGIN >= '" . intval($item['RIGHT_MARGIN']) . "'\n\t\t\t\t\tand\n\t\t\t\t\tL.TYPE_ID in (" . implode(', ', $mappedTypes) . ")\n\t\t"; $item = $DB->query($query)->fetch(); $item[$typeCode . '_NAME_ORIG'] = $item[$typeCode . '_NAME']; $item[$typeCode . '_NAME_LANG'] = $item[$typeCode . '_NAME']; if (!is_array($item)) { return array(); } return $item; }
public static function getBoundsByWord($word) { $word = trim($word); $dbConnection = Main\HttpApplication::getConnection(); $sql = "select MIN(POSITION) as INF, MAX(POSITION) as SUP from " . static::getTableName() . " where WORD like '" . ToUpper($dbConnection->getSqlHelper()->forSql($word)) . "%'"; return $dbConnection->query($sql)->fetch(); }
/** * Removes a task from favorites for all users. This function DOES NOT check permissions. * * @param integer Task id * @param mixed[] Behaviour * * <li> LOW_LEVEL boolean If set to true, function will ignore all events and do a low-level db query * * @return \Bitrix\Main\Entity\DeleteResult */ public static function deleteByTaskId($taskId, $behaviour = array('LOW_LEVEL' => false)) { $taskId = Assert::expectIntegerPositive($taskId, '$taskId'); if (!is_array($behaviour)) { $behaviour = array(); } if (!isset($behaviour['LOW_LEVEL'])) { $behaviour['LOW_LEVEL'] = false; } if ($behaviour['LOW_LEVEL']) { HttpApplication::getConnection()->query("delete from " . static::getTableName() . " where TASK_ID = '" . intval($taskId) . "'"); $result = true; } else { $result = array(); $res = static::getList(array('filter' => array('=TASK_ID' => $taskId))); while ($item = $res->fetch()) { $result[] = static::delete(array('TASK_ID' => $item['TASK_ID'], 'USER_ID' => $item['USER_ID'])); } } return $result; }
public static function cleanUp() { Main\HttpApplication::getConnection()->query('truncate table ' . static::getTableName()); }
/** * This method is for internal use only. It may be changed without any notification further, or even mystically disappear. * * @access private */ public static function deleteMultipleByParentRangeSql($sql) { if (!strlen($sql)) { throw new Main\SystemException('Range sql is empty'); } $dbConnection = Main\HttpApplication::getConnection(); $dbConnection->query('delete from ' . static::getTableName() . ' where ' . static::getReferenceFieldName() . ' in (' . $sql . ')'); }
/** * Removes all checklist's items for given template. * This function is low-level, i.e. it disrespects any events\callbacks * * @param integer $templateId * @throws \Bitrix\Main\ArgumentException */ public static function deleteByTemplateId($templateId) { $templateId = Assert::expectIntegerPositive($templateId, '$templateId'); \Bitrix\Main\HttpApplication::getConnection()->query("DELETE FROM " . static::getTableName() . " WHERE TEMPLATE_ID = '" . $templateId . "'"); }
public static function initData($parameters = array()) { static::cleanUp(); $sql = "\n\t\t\tinsert into b_sale_loc_search_sitelink \n\t\t\t\t(LOCATION_ID, SITE_ID) \n\t\t\tselect distinct LC.ID, LS.SITE_ID\n\t\t\t\tfrom b_sale_loc_2site LS\n\t\t\t\t\tinner join b_sale_location L on LS.LOCATION_ID = L.ID\n\t\t\t\t\tinner join b_sale_location LC on LC.LEFT_MARGIN >= L.LEFT_MARGIN and LC.RIGHT_MARGIN <= L.RIGHT_MARGIN\n\t\t"; Main\HttpApplication::getConnection()->query($sql); }
function InstallModule($_1998741287, $_1652945689) { if ($_1998741287 == ___125355289(1660)) { $GLOBALS['____1308158154'][361](E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_PARSE); global $DB, $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $DBDebug, $DBDebugToFile, $APPLICATION; $_918413367 = \Bitrix\Main\HttpApplication::getInstance(); $_918413367->initializeBasicKernel(); require_once $_SERVER[___125355289(1661)] . BX_PERSONAL_ROOT . ___125355289(1662); require_once $_SERVER[___125355289(1663)] . ___125355289(1664); require_once $_SERVER[___125355289(1665)] . ___125355289(1666) . $DBType . ___125355289(1667); require_once $_SERVER[___125355289(1668)] . ___125355289(1669); require_once $_SERVER[___125355289(1670)] . ___125355289(1671); require_once $_SERVER[___125355289(1672)] . ___125355289(1673) . $DBType . ___125355289(1674); require_once $_SERVER[___125355289(1675)] . ___125355289(1676); require_once $_SERVER[___125355289(1677)] . ___125355289(1678) . $DBType . ___125355289(1679); require_once $_SERVER[___125355289(1680)] . ___125355289(1681) . $DBType . ___125355289(1682); require_once $_SERVER[___125355289(1683)] . ___125355289(1684) . $DBType . ___125355289(1685); require_once $_SERVER[___125355289(1686)] . ___125355289(1687) . $DBType . ___125355289(1688); require_once $_SERVER[___125355289(1689)] . ___125355289(1690) . $DBType . ___125355289(1691); } else { global $DB, $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $DBDebug, $DBDebugToFile, $APPLICATION, $USER, $MESS; $_725846781 = $MESS; require_once $_SERVER[___125355289(1692)] . ___125355289(1693); $MESS = $GLOBALS['____1308158154'][362]($MESS, $_725846781); if ($GLOBALS['____1308158154'][363]($DB->type) == ___125355289(1694) && $GLOBALS['____1308158154'][364](___125355289(1695)) && $GLOBALS['____1308158154'][365](MYSQL_TABLE_TYPE) > min(192, 0, 64)) { $DB->Query(___125355289(1696) . MYSQL_TABLE_TYPE . ___125355289(1697), true); } global $MESS; include $_SERVER[___125355289(1698)] . ___125355289(1699); if (LANGUAGE_ID != ___125355289(1700) && $GLOBALS['____1308158154'][366]($_SERVER[___125355289(1701)] . ___125355289(1702) . LANGUAGE_ID . ___125355289(1703))) { include $_SERVER[___125355289(1704)] . ___125355289(1705) . LANGUAGE_ID . ___125355289(1706); } if (IsModuleInstalled($_1998741287) && $_1652945689 == ___125355289(1707)) { return true; } } @$GLOBALS['____1308158154'][367](round(0 + 3600)); $_751369233 =& $this->__1633338433($_1998741287); if (!$GLOBALS['____1308158154'][368]($_751369233)) { return true; } if ($_1652945689 == ___125355289(1708)) { return true; } elseif ($_1652945689 == ___125355289(1709)) { if (!$this->IsModuleEncode($_1998741287)) { if ($_1998741287 == ___125355289(1710)) { $this->EncodeDemoWizard(); } BXInstallServices::EncodeDir($_SERVER[___125355289(1711)] . ___125355289(1712) . $_1998741287, INSTALL_CHARSET); $this->SetEncodeModule($_1998741287); } return true; } elseif ($_1652945689 == ___125355289(1713)) { $DBDebug = true; if (!$_751369233->InstallDB()) { if ($_1863542457 = $APPLICATION->GetException()) { BXInstallServices::Add2Log($_1863542457->GetString(), ___125355289(1714)); } return false; } $_751369233->InstallEvents(); if ($_1998741287 == ___125355289(1715)) { $_2066407594 = array(___125355289(1716), ___125355289(1717), ___125355289(1718), ___125355289(1719), $GLOBALS['____1308158154'][369](___125355289(1720))); $_1147689662 = $_SERVER[___125355289(1721)] . ___125355289(1722) . $GLOBALS['____1308158154'][370](___125355289(1723), $_2066407594); $_1352053273 = round(0 + 7.5 + 7.5 + 7.5 + 7.5); if ($GLOBALS['____1308158154'][371]($_SERVER[___125355289(1724)] . ___125355289(1725))) { $bxProductConfig = array(); include $_SERVER[___125355289(1726)] . ___125355289(1727); if (isset($bxProductConfig[___125355289(1728)][___125355289(1729)])) { $_774506179 = $GLOBALS['____1308158154'][372]($bxProductConfig[___125355289(1730)][___125355289(1731)]); if ($_774506179 > 1236 / 2 - 618 && $_774506179 < round(0 + 7.5 + 7.5 + 7.5 + 7.5)) { $_1352053273 = $_774506179; } } } $_104682532 = ___125355289(1732); $_279588367 = $GLOBALS['____1308158154'][373](___125355289(1733), $GLOBALS['____1308158154'][374](min(170, 0, 56.666666666667), 890 - 2 * 445, 1152 / 2 - 576, $GLOBALS['____1308158154'][375](___125355289(1734)), $GLOBALS['____1308158154'][376](___125355289(1735)) + $_1352053273, $GLOBALS['____1308158154'][377](___125355289(1736)))); $_357410628 = $GLOBALS['____1308158154'][378](___125355289(1737), $GLOBALS['____1308158154'][379](1352 / 2 - 676, 202 * 2 - 404, min(60, 0, 20), $GLOBALS['____1308158154'][380](___125355289(1738)), $GLOBALS['____1308158154'][381](___125355289(1739)) + $_1352053273, $GLOBALS['____1308158154'][382](___125355289(1740)))); $_2101028031 = $GLOBALS['____1308158154'][383](___125355289(1741), $GLOBALS['____1308158154'][384](min(248, 0, 82.666666666667), 782 - 2 * 391, 904 - 2 * 452, $GLOBALS['____1308158154'][385](___125355289(1742)), $GLOBALS['____1308158154'][386](___125355289(1743)) + $_1352053273, $GLOBALS['____1308158154'][387](___125355289(1744)))); $_1230282874 = ___125355289(1745); $_754705508 = ___125355289(1746) . $GLOBALS['____1308158154'][388]($_279588367, round(0 + 0.25 + 0.25 + 0.25 + 0.25), round(0 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2)) . $GLOBALS['____1308158154'][389]($_2101028031, round(0 + 3), round(0 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2)) . ___125355289(1747) . $GLOBALS['____1308158154'][390]($_357410628, 768 - 2 * 384, round(0 + 1)) . $GLOBALS['____1308158154'][391]($_2101028031, round(0 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2), round(0 + 0.33333333333333 + 0.33333333333333 + 0.33333333333333)) . ___125355289(1748) . $GLOBALS['____1308158154'][392]($_279588367, 1416 / 2 - 708, round(0 + 0.5 + 0.5)) . ___125355289(1749) . $GLOBALS['____1308158154'][393]($_2101028031, 146 * 2 - 292, round(0 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2)) . ___125355289(1750) . $GLOBALS['____1308158154'][394]($_2101028031, round(0 + 1 + 1), round(0 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2)) . ___125355289(1751) . $GLOBALS['____1308158154'][395]($_357410628, round(0 + 0.5 + 0.5), round(0 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2)) . ___125355289(1752); $_104682532 = $GLOBALS['____1308158154'][396](___125355289(1753)) . $GLOBALS['____1308158154'][397](___125355289(1754), $_104682532, ___125355289(1755)); $_1855239886 = $GLOBALS['____1308158154'][398]($_104682532); $_1478677807 = 1360 / 2 - 680; for ($_676804512 = 1496 / 2 - 748; $_676804512 < $GLOBALS['____1308158154'][399]($_754705508); $_676804512++) { $_1230282874 .= $GLOBALS['____1308158154'][400]($GLOBALS['____1308158154'][401]($_754705508[$_676804512]) ^ $GLOBALS['____1308158154'][402]($_104682532[$_1478677807])); if ($_1478677807 == $_1855239886 - round(0 + 0.33333333333333 + 0.33333333333333 + 0.33333333333333)) { $_1478677807 = 924 - 2 * 462; } else { $_1478677807 = $_1478677807 + round(0 + 0.25 + 0.25 + 0.25 + 0.25); } } $_1230282874 = ___125355289(1756) . ___125355289(1757) . ___125355289(1758) . $GLOBALS['____1308158154'][403]($_1230282874) . ___125355289(1759) . ___125355289(1760) . ___125355289(1761); BXInstallServices::CheckDirPath($_1147689662); if (!$GLOBALS['____1308158154'][404]($_1147689662)) { $_1318943328 = @$GLOBALS['____1308158154'][405]($_1147689662, ___125355289(1762)); @$GLOBALS['____1308158154'][406]($_1318943328, $_1230282874); @$GLOBALS['____1308158154'][407]($_1318943328); } $_32065584 = ___125355289(1763); $_24263823 = $GLOBALS[___125355289(1764)]->Query(___125355289(1765) . $GLOBALS['____1308158154'][408](___125355289(1766), ___125355289(1767), $GLOBALS['____1308158154'][409]($_32065584, round(0 + 0.5 + 0.5 + 0.5 + 0.5), round(0 + 2 + 2))) . $GLOBALS['____1308158154'][410](___125355289(1768)) . ___125355289(1769), true); if ($_24263823 !== False) { $_487833102 = false; if ($_976209617 = $_24263823->{$GLOBALS}['_____1887280449'][2]()) { $_487833102 = true; } if (!$_487833102) { $_1352053273 = round(0 + 15 + 15); if ($GLOBALS['____1308158154'][411]($_SERVER[___125355289(1770)] . ___125355289(1771))) { $bxProductConfig = array(); include $_SERVER[___125355289(1772)] . ___125355289(1773); if (isset($bxProductConfig[___125355289(1774)][___125355289(1775)])) { $_774506179 = $GLOBALS['____1308158154'][412]($bxProductConfig[___125355289(1776)][___125355289(1777)]); if ($_774506179 > 968 - 2 * 484 && $_774506179 < round(0 + 7.5 + 7.5 + 7.5 + 7.5)) { $_1352053273 = $_774506179; } } } $_1091999424 = ___125355289(1778); $_279588367 = $GLOBALS['____1308158154'][413](___125355289(1779), $GLOBALS['____1308158154'][414](1392 / 2 - 696, 205 * 2 - 410, 221 * 2 - 442, $GLOBALS['____1308158154'][415](___125355289(1780)), $GLOBALS['____1308158154'][416](___125355289(1781)) + $_1352053273, $GLOBALS['____1308158154'][417](___125355289(1782)))); $_357410628 = $GLOBALS['____1308158154'][418](___125355289(1783), $GLOBALS['____1308158154'][419](189 * 2 - 378, min(196, 0, 65.333333333333), 866 - 2 * 433, $GLOBALS['____1308158154'][420](___125355289(1784)), $GLOBALS['____1308158154'][421](___125355289(1785)) + $_1352053273, $GLOBALS['____1308158154'][422](___125355289(1786)))); $_2101028031 = $GLOBALS['____1308158154'][423](___125355289(1787), $GLOBALS['____1308158154'][424](217 * 2 - 434, 1168 / 2 - 584, min(124, 0, 41.333333333333), $GLOBALS['____1308158154'][425](___125355289(1788)), $GLOBALS['____1308158154'][426](___125355289(1789)) + $_1352053273, $GLOBALS['____1308158154'][427](___125355289(1790)))); $_1230282874 = ___125355289(1791); $_754705508 = ___125355289(1792) . $GLOBALS['____1308158154'][428]($_279588367, min(8, 0, 2.6666666666667), round(0 + 1)) . ___125355289(1793) . $GLOBALS['____1308158154'][429]($_357410628, round(0 + 0.5 + 0.5), round(0 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2)) . ___125355289(1794) . $GLOBALS['____1308158154'][430]($_357410628, 1256 / 2 - 628, round(0 + 0.25 + 0.25 + 0.25 + 0.25)) . $GLOBALS['____1308158154'][431]($_2101028031, round(0 + 2), round(0 + 0.25 + 0.25 + 0.25 + 0.25)) . ___125355289(1795) . $GLOBALS['____1308158154'][432]($_2101028031, 1428 / 2 - 714, round(0 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2)) . ___125355289(1796) . $GLOBALS['____1308158154'][433]($_2101028031, round(0 + 0.75 + 0.75 + 0.75 + 0.75), round(0 + 0.33333333333333 + 0.33333333333333 + 0.33333333333333)) . ___125355289(1797) . $GLOBALS['____1308158154'][434]($_279588367, round(0 + 0.33333333333333 + 0.33333333333333 + 0.33333333333333), round(0 + 1)) . ___125355289(1798) . $GLOBALS['____1308158154'][435]($_2101028031, round(0 + 0.25 + 0.25 + 0.25 + 0.25), round(0 + 0.25 + 0.25 + 0.25 + 0.25)); $_1091999424 = $GLOBALS['____1308158154'][436](___125355289(1799) . $_1091999424, min(212, 0, 70.666666666667), -round(0 + 1.25 + 1.25 + 1.25 + 1.25)) . ___125355289(1800); $_463973618 = $GLOBALS['____1308158154'][437]($_1091999424); $_1478677807 = 169 * 2 - 338; for ($_676804512 = 199 * 2 - 398; $_676804512 < $GLOBALS['____1308158154'][438]($_754705508); $_676804512++) { $_1230282874 .= $GLOBALS['____1308158154'][439]($GLOBALS['____1308158154'][440]($_754705508[$_676804512]) ^ $GLOBALS['____1308158154'][441]($_1091999424[$_1478677807])); if ($_1478677807 == $_463973618 - round(0 + 0.25 + 0.25 + 0.25 + 0.25)) { $_1478677807 = 928 - 2 * 464; } else { $_1478677807 = $_1478677807 + round(0 + 0.2 + 0.2 + 0.2 + 0.2 + 0.2); } } $GLOBALS[___125355289(1801)]->Query(___125355289(1802) . $GLOBALS['____1308158154'][442](___125355289(1803), ___125355289(1804), $GLOBALS['____1308158154'][443]($_32065584, round(0 + 1 + 1), round(0 + 0.8 + 0.8 + 0.8 + 0.8 + 0.8))) . $GLOBALS['____1308158154'][444](___125355289(1805)) . ___125355289(1806) . $GLOBALS[___125355289(1807)]->ForSql($GLOBALS['____1308158154'][445]($_1230282874), 153 * 2 - 306) . ___125355289(1808), True); if ($GLOBALS['____1308158154'][446]($GLOBALS[___125355289(1809)])) { $GLOBALS[___125355289(1810)]->Clean(___125355289(1811)); } } } } } elseif ($_1652945689 == ___125355289(1812)) { if (!$_751369233->InstallFiles()) { if ($_1863542457 = $APPLICATION->GetException()) { BXInstallServices::Add2Log($_1863542457->GetString(), ___125355289(1813)); } return false; } } return true; }
public static function resetLegacyPath() { $dbConnection = Main\HttpApplication::getConnection(); $locTable = static::getTableName(); $types = array(); $res = TypeTable::getList(array('filter' => array('CODE' => array('COUNTRY', 'REGION', 'CITY')), 'select' => array('ID', 'CODE'))); while ($item = $res->fetch()) { $types[$item['CODE']] = $item['ID']; } if (!empty($types)) { if (!$dbConnection->isTableExists('b_sale_loc_rebind')) { $dbConnection->query("create table b_sale_loc_rebind (TARGET_ID " . Helper::getSqlForDataType('int') . ", LOCATION_ID " . Helper::getSqlForDataType('int') . ")"); } else { $dbConnection->query("truncate table b_sale_loc_rebind"); } $sqlWhere = array(); foreach ($types as $code => $id) { $sqlWhere[] = "'" . intval($id) . "'"; } $dbConnection->query("update " . $locTable . " set COUNTRY_ID = NULL, REGION_ID = NULL, CITY_ID = NULL where TYPE_ID in (" . implode(', ', $sqlWhere) . ")"); if (intval($types['REGION']) && intval($types['COUNTRY'])) { // countries for regions $dbConnection->query("insert into b_sale_loc_rebind (TARGET_ID, LOCATION_ID) select A.ID as ONE, B.ID as TWO from " . $locTable . " A inner join " . $locTable . " B on A.TYPE_ID = '" . intval($types['REGION']) . "' and B.TYPE_ID = '" . intval($types['COUNTRY']) . "' and B.LEFT_MARGIN <= A.LEFT_MARGIN and B.RIGHT_MARGIN >= A.RIGHT_MARGIN"); Helper::mergeTables($locTable, 'b_sale_loc_rebind', array('COUNTRY_ID' => 'LOCATION_ID'), array('ID' => 'TARGET_ID')); $dbConnection->query("truncate table b_sale_loc_rebind"); } if (intval($types['REGION']) && intval($types['CITY'])) { // regions for cities $dbConnection->query("insert into b_sale_loc_rebind (TARGET_ID, LOCATION_ID) select A.ID as ONE, B.ID as TWO from " . $locTable . " A inner join " . $locTable . " B on A.TYPE_ID = '" . intval($types['CITY']) . "' and B.TYPE_ID = '" . intval($types['REGION']) . "' and B.LEFT_MARGIN <= A.LEFT_MARGIN and B.RIGHT_MARGIN >= A.RIGHT_MARGIN"); Helper::mergeTables($locTable, 'b_sale_loc_rebind', array('REGION_ID' => 'LOCATION_ID'), array('ID' => 'TARGET_ID')); $dbConnection->query("truncate table b_sale_loc_rebind"); } if (intval($types['COUNTRY']) && intval($types['CITY'])) { // countries for cities $dbConnection->query("insert into b_sale_loc_rebind (TARGET_ID, LOCATION_ID) select A.ID as ONE, B.ID as TWO from " . $locTable . " A inner join " . $locTable . " B on A.TYPE_ID = '" . intval($types['CITY']) . "' and B.TYPE_ID = '" . intval($types['COUNTRY']) . "' and B.LEFT_MARGIN <= A.LEFT_MARGIN and B.RIGHT_MARGIN >= A.RIGHT_MARGIN"); Helper::mergeTables($locTable, 'b_sale_loc_rebind', array('COUNTRY_ID' => 'LOCATION_ID'), array('ID' => 'TARGET_ID')); } Helper::dropTable('b_sale_loc_rebind'); if (intval($types['COUNTRY'])) { $dbConnection->query("update " . $locTable . " set COUNTRY_ID = ID where TYPE_ID = '" . intval($types['COUNTRY']) . "'"); } if (intval($types['REGION'])) { $dbConnection->query("update " . $locTable . " set REGION_ID = ID where TYPE_ID = '" . intval($types['REGION']) . "'"); } if (intval($types['CITY'])) { $dbConnection->query("update " . $locTable . " set CITY_ID = ID where TYPE_ID = '" . intval($types['CITY']) . "'"); } } }
protected function stageRebalanceWalkTree() { if (!isset($this->data['rebalance']['queue'])) { $this->restoreIndexes('IX_B_SALE_LOC_PARENT'); $this->logMessage('initialize Queue'); $this->data['rebalance']['margin'] = -1; $this->data['processed'] = 0; $this->data['rebalance']['queue'] = array(array('I' => 'root', 'D' => 0)); $tableName = Location\LocationTable::getTableName(); $res = Main\HttpApplication::getConnection()->query("select count(*) as CNT from {$tableName}")->fetch(); $this->data['rebalance']['cnt'] = intval($res['CNT']); } $i = -1; while (!empty($this->data['rebalance']['queue']) && $this->checkQuota()) { $i++; $node =& $this->data['rebalance']['queue'][0]; if (isset($node['L'])) { // we have already been here array_shift($this->data['rebalance']['queue']); if ($node['I'] != 'root') { $this->acceptRebalancedNode(array('I' => $node['I'], 'D' => $node['D'], 'L' => $node['L'], 'R' => ++$this->data['rebalance']['margin'])); } else { $this->data['rebalance']['margin']++; } } else { $a = $this->getCachedBundle($node['I']); if (!empty($a)) { // go deeper $node['L'] = ++$this->data['rebalance']['margin']; foreach ($a as $id) { if ($this->checkNodeIsParent($id)) { array_unshift($this->data['rebalance']['queue'], array('I' => $id, 'D' => $node['D'] + 1)); } else { $this->acceptRebalancedNode(array('I' => $id, 'D' => $node['D'] + 1, 'L' => ++$this->data['rebalance']['margin'], 'R' => ++$this->data['rebalance']['margin'])); } } } else { array_shift($this->data['rebalance']['queue']); $this->acceptRebalancedNode(array('I' => $node['I'], 'D' => $node['D'], 'L' => ++$this->data['rebalance']['margin'], 'R' => ++$this->data['rebalance']['margin'])); } } } $this->logMessage('Q size is ' . count($this->data['rebalance']['queue']) . ' already processed: ' . $this->data['processed'] . '/' . $this->data['rebalance']['cnt']); $this->logMemoryUsage(); if (empty($this->data['rebalance']['queue'])) { // last flush & then merge $this->mergeRebalancedNodes(); $this->nextStage(); return; } $this->rebalanceInserter->flush(); $this->nextStep(); }
function InitPureDB() { if (!function_exists('SendError')) { function SendError($str) { } } if (!function_exists('IsModuleInstalled')) { function IsModuleInstalled($module) { if ($m = trim($module)) return file_exists($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/'.$m); return false; } } global $DB, $DBType, $DBDebug, $DBDebugToFile, $DBHost, $DBName, $DBLogin, $DBPassword, $DBSQLServerType; /** * Defined in dbconn.php * @var $DBType * @var $DBDebug * @var $DBDebugToFile * @var $DBHost * @var $DBName * @var $DBLogin * @var $DBPassword */ require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/dbconn.php"); if(defined('BX_UTF')) define('BX_UTF_PCRE_MODIFIER', 'u'); else define('BX_UTF_PCRE_MODIFIER', ''); include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/lib/loader.php"); $application = \Bitrix\Main\HttpApplication::getInstance(); $application->initializeBasicKernel(); require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/".$DBType."/database.php"); $DB = new CDatabase; $DB->debug = $DBDebug; $DB->DebugToFile = $DBDebugToFile; if(!($DB->Connect($DBHost, $DBName, $DBLogin, $DBPassword)) || !($DB->DoConnect())) { if(file_exists(($fname = $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/dbconn_error.php"))) include($fname); else include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/dbconn_error.php"); die(); } if (file_exists($fname = $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/after_connect.php")) require_once($fname); if (file_exists($fname = $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/after_connect_d7.php")) require_once($fname); }
public function initializeData() { $dbConnection = Main\HttpApplication::getConnection(); $res = Location\LocationTable::getList(array('select' => array('ID', 'TYPE_ID', 'DEPTH_LEVEL', 'SORT'), 'order' => array('LEFT_MARGIN' => 'asc'), 'limit' => self::STEP_SIZE, 'offset' => $this->procData['OFFSET'])); $this->procData['TYPE_SORT'] = $this->rarefact($this->procData['TYPE_SORT']); $cnt = 0; while ($item = $res->fetch()) { // tmp!!!! //$name = Location\Name\LocationTable::getList(array('select' => array('NAME'), 'filter' => array('=LOCATION_ID' => $item['ID'], '=LANGUAGE_ID' => 'ru')))->fetch(); if ($item['DEPTH_LEVEL'] < $this->procData['DEPTH']) { $newPC = array(); foreach ($this->procData['PATH'] as $dl => $id) { if ($dl >= $item['DEPTH_LEVEL']) { break; } $newPC[$dl] = $id; } $this->procData['PATH'] = $newPC; } $this->procData['PATH'][$item['DEPTH_LEVEL']] = array('TYPE' => $item['TYPE_ID'], 'ID' => $item['ID']); if (is_array($this->procData['ALLOWED_TYPES']) && in_array($item['TYPE_ID'], $this->procData['ALLOWED_TYPES'])) { $data = array('LOCATION_ID' => $item['ID'], 'RELEVANCY' => $this->procData['TYPE_SORT'][$item['TYPE_ID']] + $item['SORT']); $wordsAdded = array(); /* _dump_r('############################'); _dump_r('LOCATION: '.$name['NAME']); _dump_r('TYPE RELEVANCY: '.$data['RELEVANCY']); _dump_r('PATH:'); _dump_r($this->procData['PATH']); */ $this->procData['DEPTH'] = $item['DEPTH_LEVEL']; // pre-load missing words $wordCount = 0; foreach ($this->procData['PATH'] as &$pathItem) { if (!isset($pathItem['WORDS'])) { $sql = "\n\t\t\t\t\t\t\tselect WS.POSITION from " . WordTable::getTableNameWord2Location() . " WL\n\t\t\t\t\t\t\t\tinner join " . WordTable::getTableName() . " WS on WL.WORD_ID = WS.ID\n\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\tWL.LOCATION_ID = '" . intval($pathItem['ID']) . "'\n\t\t\t\t\t\t"; $wordRes = $dbConnection->query($sql); $pathItem['WORDS'] = array(); while ($wordItem = $wordRes->fetch()) { $pathItem['WORDS'][] = $wordItem['POSITION']; } $pathItem['WORDS'] = array_unique($pathItem['WORDS']); } $wordCount += count($pathItem['WORDS']); } // count words //_dump_r('Words total: '.$wordCount); $wOffset = 0; foreach ($this->procData['PATH'] as &$pathItem) { foreach ($pathItem['WORDS'] as $i => $position) { $wordWeight = $wordCount - $wOffset; $tmpData = $data; $tmpData['RELEVANCY'] += $wordWeight; //_dump_r(' Word relevancy: '.$data['RELEVANCY'].' ==>> '.$tmpData['RELEVANCY']); if (!isset($wordsAdded[$position])) { $this->indexInserter->insert(array_merge(array('POSITION' => $position), $tmpData)); $wordsAdded[$position] = true; } $wOffset++; } } unset($pathItem); } $cnt++; } $this->indexInserter->flush(); $this->procData['OFFSET'] += self::STEP_SIZE; return !$cnt; }
public static function resetAutoIncrement($tableName, $startIndex = 1) { $startIndex = intval($startIndex); if ($startIndex <= 0 || !strlen($tableName)) { return false; } $dbConnection = Main\HttpApplication::getConnection(); $dbHelper = $dbConnection->getSqlHelper(); $dbName = $dbConnection->getDbName(); $tableName = $dbHelper->forSql(trim($tableName)); $dbConnection->query("DBCC CHECKIDENT('" . $dbName . ".dbo." . $tableName . "', RESEED, " . ($startIndex - 1) . ")"); return true; }
} $GLOBALS['____1055296423'][6](___1201625077(222), getmicrotime()); $GLOBALS['____1055296423'][7](___1201625077(223), true); require_once $_SERVER[___1201625077(224)] . BX_ROOT . ___1201625077(225); require_once $_SERVER[___1201625077(226)] . BX_ROOT . ___1201625077(227); if ($GLOBALS['____1055296423'][8](PHP_VERSION, ___1201625077(228)) >= 858 - 2 * 429 && @ini_get_bool(___1201625077(229)) != true) { $HTTP_POST_FILES = $_FILES; $HTTP_SERVER_VARS = $_SERVER; $HTTP_GET_VARS = $_GET; $HTTP_POST_VARS = $_POST; $HTTP_COOKIE_VARS = $_COOKIE; $HTTP_ENV_VARS = $_ENV; } UnQuoteAll(); FormDecode(); $_1756257894 = \Bitrix\Main\HttpApplication::getInstance(); $_1756257894->initializeBasicKernel(); require_once $_SERVER[___1201625077(230)] . BX_PERSONAL_ROOT . ___1201625077(231); if ($GLOBALS['____1055296423'][9](___1201625077(232))) { $GLOBALS['____1055296423'][10](___1201625077(233), ___1201625077(234)); } else { $GLOBALS['____1055296423'][11](___1201625077(235), ___1201625077(236)); } if (!$GLOBALS['____1055296423'][12](___1201625077(237))) { $GLOBALS['____1055296423'][13](___1201625077(238), round(0 + 3600)); } if (!$GLOBALS['____1055296423'][14](___1201625077(239))) { $GLOBALS['____1055296423'][15](___1201625077(240), round(0 + 3600)); } if (!$GLOBALS['____1055296423'][16](___1201625077(241))) { $GLOBALS['____1055296423'][17](___1201625077(242), round(0 + 1800 + 1800));
public static function switchIndexes($way = true) { Main\HttpApplication::getConnection()->query('alter table ' . static::getTableName() . ' ' . ($way ? 'enable' : 'disable') . ' keys'); }
public static function mergeRelationsFromTemporalTable($temporalTabName, $additinalFlds = array(), $fldMap = array()) { $dbConnection = Main\HttpApplication::getConnection(); $dbHelper = $dbConnection->getSqlHelper(); $temporalTabName = Assert::expectStringNotNull($temporalTabName, false, 'Name of temporal table must be a non-zero length string'); $temporalTabName = $dbHelper->forSql($temporalTabName); $entityTableName = static::getTableName(); if (!is_array($additinalFlds)) { $additinalFlds = array(); } $additinalFlds = array_merge(array('LEFT_MARGIN', 'RIGHT_MARGIN', 'DEPTH_LEVEL'), $additinalFlds); $fldReplace = array(); foreach ($additinalFlds as &$fld) { $fld = $dbHelper->forSql($fld); $fldReplace[$fld] = is_array($fldMap) && isset($fldMap[$fld]) ? $dbHelper->forSql($fldMap[$fld]) : $fld; } $idReplace = is_array($fldMap) && isset($fldMap['ID']) ? $dbHelper->forSql($fldMap['ID']) : 'ID'; if ($dbConnection->getType() == 'mysql') { $sql = 'update ' . $entityTableName . ', ' . $temporalTabName . ' set '; $additFldCnt = count($additinalFlds); for ($i = 0; $i < $additFldCnt; $i++) { $sql .= $entityTableName . '.' . $additinalFlds[$i] . ' = ' . $temporalTabName . '.' . $fldReplace[$additinalFlds[$i]] . ($i == count($additinalFlds) - 1 ? '' : ', '); } $sql .= ' where ' . $entityTableName . '.ID = ' . $temporalTabName . '.' . $idReplace; } elseif ($dbConnection->getType() == 'mssql') { $sql = 'update ' . $entityTableName . ' set '; $additFldCnt = count($additinalFlds); for ($i = 0; $i < $additFldCnt; $i++) { $sql .= $additinalFlds[$i] . ' = ' . $temporalTabName . '.' . $fldReplace[$additinalFlds[$i]] . ($i == count($additinalFlds) - 1 ? '' : ', '); } $sql .= ' from ' . $entityTableName . ' join ' . $temporalTabName . ' on ' . $entityTableName . '.ID = ' . $temporalTabName . '.' . $idReplace; } elseif ($dbConnection->getType() == 'oracle') { // update tab1 set (aa,bb) = (select aa,bb from tab2 where tab2.id = tab1.id) $sql = 'update ' . $entityTableName . ' set (' . implode(', ', $additinalFlds) . ') = (select ' . implode(', ', $fldReplace) . ' from ' . $temporalTabName . ' where ' . $entityTableName . '.ID = ' . $temporalTabName . '.' . $idReplace . ')'; } $dbConnection->query($sql); }
protected static function escapeArray($columns) { foreach ($columns as &$col) { $col = Main\HttpApplication::getConnection()->getSqlHelper()->forSql($col); } return $columns; }
/** * @return HttpResponse */ public function getResponse() { $context = $this->application->getContext(); return $context->getResponse(); }