/** * Establishes a connection to the database. * Includes php_interface/after_connect_d7.php on success. * Throws exception on failure. * * @return void * @throws \Bitrix\Main\DB\ConnectionException */ protected function connectInternal() { if ($this->isConnected) { return; } $connectionInfo = array("UID" => $this->login, "PWD" => $this->password, "Database" => $this->database, "ReturnDatesAsStrings" => true); if (($this->options & self::PERSISTENT) != 0) { $connectionInfo["ConnectionPooling"] = true; } else { $connectionInfo["ConnectionPooling"] = false; } $connection = sqlsrv_connect($this->host, $connectionInfo); if (!$connection) { throw new ConnectionException('MS Sql connect error', $this->getErrorMessage()); } $this->resource = $connection; $this->isConnected = true; // hide cautions sqlsrv_configure("WarningsReturnAsErrors", 0); /** @noinspection PhpUnusedLocalVariableInspection */ global $DB, $USER, $APPLICATION; if ($fn = \Bitrix\Main\Loader::getPersonal("php_interface/after_connect_d7.php")) { include $fn; } }
public static function runInitScripts() { if (($includePath = \Bitrix\Main\Loader::getLocal("init.php")) !== false) { require_once $includePath; } if (($includePath = \Bitrix\Main\Loader::getPersonal("php_interface/init.php")) !== false) { require_once $includePath; } if (($includePath = \Bitrix\Main\Loader::getPersonal("php_interface/" . SITE_ID . "/init.php")) !== false) { require_once $includePath; } }
protected function connectInternal() { if ($this->isConnected) { return; } $dbHost = $this->dbHost; $dbPort = 0; if (($pos = strpos($dbHost, ":")) !== false) { $dbPort = intval(substr($dbHost, $pos + 1)); $dbHost = substr($dbHost, 0, $pos); } if (($this->dbOptions & self::PERSISTENT) != 0) { $dbHost = "p:" . $dbHost; } /** @var $connection \mysqli */ $connection = \mysqli_init(); if (!$connection) { throw new ConnectionException('Mysql init failed'); } if (!empty($this->dbInitCommand)) { if (!$connection->options(MYSQLI_INIT_COMMAND, $this->dbInitCommand)) { throw new ConnectionException('Setting mysql init command failed'); } } if ($dbPort > 0) { $r = $connection->real_connect($dbHost, $this->dbLogin, $this->dbPassword, $this->dbName, $dbPort); } else { $r = $connection->real_connect($dbHost, $this->dbLogin, $this->dbPassword, $this->dbName); } if (!$r) { throw new ConnectionException('Mysql connect error', sprintf('(%s) %s', $connection->connect_errno, $connection->connect_error)); } $this->resource = $connection; $this->isConnected = true; // nosql memcached driver if (isset($this->configuration['memcache'])) { $memcached = \Bitrix\Main\Application::getInstance()->getConnectionPool()->getConnection($this->configuration['memcache']); mysqlnd_memcache_set($this->resource, $memcached->getResource()); } //global $DB, $USER, $APPLICATION; if ($fn = \Bitrix\Main\Loader::getPersonal("php_interface/after_connect_d7.php")) { include $fn; } }
protected function connectInternal() { if ($this->isConnected) { return; } if (($this->dbOptions & self::PERSISTENT) != 0) { $connection = oci_pconnect($this->dbLogin, $this->dbPassword, $this->dbName); } else { $connection = oci_connect($this->dbLogin, $this->dbPassword, $this->dbName); } if (!$connection) { throw new ConnectionException('Oracle connect error', $this->getErrorMessage()); } $this->isConnected = true; $this->resource = $connection; global $DB, $USER, $APPLICATION; if ($fn = \Bitrix\Main\Loader::getPersonal("php_interface/after_connect_d7.php")) { include $fn; } }
/** * Establishes a connection to the database. * Includes php_interface/after_connect_d7.php on success. * Throws exception on failure. * * @return void * @throws \Bitrix\Main\DB\ConnectionException */ protected function connectInternal() { if ($this->isConnected) { return; } if (($this->options & self::PERSISTENT) != 0) { $connection = oci_pconnect($this->login, $this->password, $this->database); } else { $connection = oci_new_connect($this->login, $this->password, $this->database); } if (!$connection) { throw new ConnectionException('Oracle connect error', $this->getErrorMessage()); } $this->isConnected = true; $this->resource = $connection; /** @noinspection PhpUnusedLocalVariableInspection */ global $DB, $USER, $APPLICATION; if ($fn = \Bitrix\Main\Loader::getPersonal("php_interface/after_connect_d7.php")) { include $fn; } }
protected function connectInternal() { if ($this->isConnected) { return; } if (($this->dbOptions & self::PERSISTENT) != 0) { $connection = mysql_pconnect($this->dbHost, $this->dbLogin, $this->dbPassword); } else { $connection = mysql_connect($this->dbHost, $this->dbLogin, $this->dbPassword, true); } if (!$connection) { throw new ConnectionException('Mysql connect error', mysql_error()); } if (!mysql_select_db($this->dbName, $connection)) { throw new ConnectionException('Mysql select db error', mysql_error($connection)); } $this->resource = $connection; $this->isConnected = true; if ($fn = \Bitrix\Main\Loader::getPersonal("php_interface/after_connect_d7.php")) { include $fn; } }
protected function connectInternal() { if ($this->isConnected) { return; } $connectionInfo = array("UID" => $this->dbLogin, "PWD" => $this->dbPassword, "Database" => $this->dbName, "ReturnDatesAsStrings" => true); if (($this->dbOptions & self::PERSISTENT) != 0) { $connectionInfo["ConnectionPooling"] = true; } else { $connectionInfo["ConnectionPooling"] = false; } $connection = sqlsrv_connect($this->dbHost, $connectionInfo); if (!$connection) { throw new ConnectionException('MS Sql connect error', $this->getErrorMessage()); } $this->connectionResource = $connection; $this->isConnected = true; global $DB, $USER, $APPLICATION; if ($fn = \Bitrix\Main\Loader::getPersonal("php_interface/after_connect.php")) { include $fn; } }
public static function clearCache($full = false, $initDir = "") { if ($full !== true && $full !== false && $initDir === "" && is_string($full)) { $initDir = $full; $full = true; } $res = true; if ($full === true) { $obCache = static::createInstance(); $obCache->cleanDir($initDir, "cache"); } $path = Main\Loader::getPersonal("cache" . $initDir); if (is_dir($path) && ($handle = opendir($path))) { while (($file = readdir($handle)) !== false) { if ($file === "." || $file === "..") { continue; } if (is_dir($path . "/" . $file)) { if (!static::clearCache($full, $initDir . "/" . $file)) { $res = false; } else { @chmod($path . "/" . $file, BX_DIR_PERMISSIONS); //We suppress error handle here because there may be valid cache files in this dir @rmdir($path . "/" . $file); } } elseif ($full) { @chmod($path . "/" . $file, BX_FILE_PERMISSIONS); if (!unlink($path . "/" . $file)) { $res = false; } } elseif (substr($file, -4) === ".php") { $c = static::createInstance(); if ($c->isCacheExpired($path . "/" . $file)) { @chmod($path . "/" . $file, BX_FILE_PERMISSIONS); if (!unlink($path . "/" . $file)) { $res = false; } } } else { //We should skip unknown file //it will be deleted with full cache cleanup } } closedir($handle); } return $res; }
protected function runInitScripts() { if (!$this->dispatcher instanceof Dispatcher) { throw new \Exception(); } if (($includePath = Loader::getLocal("init_d7.php")) !== false) { require_once $includePath; } if (($includePath = Loader::getPersonal("php_interface/init_d7.php")) !== false) { require_once $includePath; } // константы после init.php define("BX_CRONTAB_SUPPORT", defined("BX_CRONTAB")); if (!defined("BX_FILE_PERMISSIONS")) { define("BX_FILE_PERMISSIONS", 0644); } if (!defined("BX_DIR_PERMISSIONS")) { define("BX_DIR_PERMISSIONS", 0755); } }