本文整理汇总了PHP中Bitrix\Main\HttpApplication类的典型用法代码示例。如果您正苦于以下问题:PHP HttpApplication类的具体用法?PHP HttpApplication怎么用?PHP HttpApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HttpApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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();
}
示例2: search
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);
}
示例3: initializeData
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);
}
示例4: setDebugModeOn
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;
}
示例5: addPropertyValueField
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");
}
}
示例6: dropIndexByName
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;
}
示例7: execute
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) {
//.........这里部分代码省略.........
示例8: getmicrotime
<?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"]);
示例9: truncateTable
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);
}
}
示例10: prepareSql
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).')';
}
示例11: resetAutoIncrement
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;
}
示例12: resetLegacyPath
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();
}
示例13: getNameOfParentOfType
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;
}
示例14: getBoundsByWord
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();
}
示例15: deleteByTaskId
/**
* 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;
}