10 public static function Init($bDoConnect =
false)
12 if (is_object(self::$connection))
18 $isConnectionExists = $pool->getConnection(static::CONNECTION_NAME) !==
null;
19 if (!$isConnectionExists)
21 $pool->cloneConnection(
22 $pool::DEFAULT_CONNECTION_NAME,
23 static::CONNECTION_NAME
29 self::$connection = $pool->getConnection(static::CONNECTION_NAME);
37 if (!is_object(self::$connection))
43 defined(
"BX_SECURITY_SQL_LOG_BIN")
45 BX_SECURITY_SQL_LOG_BIN ===
false
46 || BX_SECURITY_SQL_LOG_BIN ===
"N"
50 CSecurityDB::Query(
"SET sql_log_bin = 0",
"Module: security; Class: CSecurityDB; Function: Init; File: ".__FILE__.
"; Line: ".__LINE__);
53 $rs =
CSecurityDB::Query(
"SHOW TABLES LIKE 'b_sec_session'",
"Module: security; Class: CSecurityDB; Function: Init; File: ".__FILE__.
"; Line: ".__LINE__);
65 if (defined(
"MYSQL_TABLE_TYPE") && MYSQL_TABLE_TYPE <>
'')
67 $rs =
CSecurityDB::Query(
"SET storage_engine = '".MYSQL_TABLE_TYPE.
"'",
"Module: security; Class: CSecurityDB; Function: Init; File: ".__FILE__.
"; Line: ".__LINE__);
76 SESSION_ID VARCHAR(250) NOT NULL,
77 TIMESTAMP_X TIMESTAMP NOT NULL,
78 SESSION_DATA LONGTEXT,
79 PRIMARY KEY(SESSION_ID),
80 KEY ix_b_sec_session_time (TIMESTAMP_X)
82 ",
"Module: security; Class: CSecurityDB; Function: Init; File: ".__FILE__.
"; Line: ".__LINE__);
84 return is_object(
$rs);
89 if (is_object(self::$connection))
91 self::$connection->disconnect();
92 self::$connection =
null;
103 return "DATE_ADD(now(), INTERVAL - ".intval($sec).
" SECOND)";
106 public static function Query($strSql, $error_position)
108 if (!is_object(self::$connection))
113 if (is_object(self::$connection))
115 $strSql = preg_replace(
"/^\\s*SELECT\\s+(?!GET_LOCK|RELEASE_LOCK)/i",
"SELECT SQL_NO_CACHE ", $strSql);
118 $result = self::$connection->query($strSql);
121 catch (\
Bitrix\Main\Db\SqlQueryException $e)
123 AddMessage2Log($error_position.
" MySql Query Error: ".$strSql.
" [".$e.
"]",
"security");
130 public static function QueryBind($strSql, $arBinds, $error_position)
132 foreach ($arBinds as
$key => $value)
133 $strSql = str_replace(
":".
$key,
"'".$value.
"'", $strSql);
149 public static function Lock($id, $timeout = 60)
151 static $lock_id =
"";
157 $rsLock =
CSecurityDB::Query(
"DO RELEASE_LOCK('".$lock_id.
"')",
"Module: security; Class: CSecurityDB; Function: Lock; File: ".__FILE__.
"; Line: ".__LINE__);
166 $rsLock =
CSecurityDB::Query(
"SELECT GET_LOCK('".md5($id).
"', ".intval($timeout).
") as L",
"Module: security; Class: CSecurityDB; Function: Lock; File: ".__FILE__.
"; Line: ".__LINE__);
170 if ($arLock[
"L"] ==
"0")
176 return is_object($rsLock);
181 $rsLock =
CSecurityDB::Query(
"SELECT GET_LOCK('".md5($lock_id).
"', 0) as L",
"Module: security; Class: CSecurityDB; Function: LockTable; File: ".__FILE__.
"; Line: ".__LINE__);
185 if ($arLock[
"L"] ==
"0")
188 return array(
"lock_id" => $lock_id);
198 if (is_array($table_lock))
200 CSecurityDB::Query(
"SELECT RELEASE_LOCK('".$table_lock[
"lock_id"].
"')",
"Module: security; Class: CSecurityDB; Function: UnlockTable; File: ".__FILE__.
"; Line: ".__LINE__);
static UnlockTable($table_lock)
static Query($strSql, $error_position)
static CurrentTimeFunction()
static QueryBind($strSql, $arBinds, $error_position)
static Init($bDoConnect=false)
static Lock($id, $timeout=60)
static LockTable($table_name, $lock_id)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
AddMessage2Log($text, $module='', $traceDepth=6, $showArgs=false)
if(empty($signedUserToken)) $key