16 lines
5.6 KiB
JavaScript
16 lines
5.6 KiB
JavaScript
"use strict";(()=>{var e={};e.id=9885,e.ids=[9885],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},79428:e=>{e.exports=require("buffer")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},21820:e=>{e.exports=require("os")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,t){return t in r?r[t]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,t)):"function"==typeof r&&"default"===t?r:void 0}}})},57856:(e,r,t)=>{t.r(r),t.d(r,{config:()=>f,default:()=>m,routeModule:()=>y});var n={};t.r(n),t.d(n,{default:()=>S});var s=t(89947),o=t(2706),a=t(96762),c=t(29021),i=t.n(c),l=t(21820),u=t.n(l),d=t(79646),p=t(67619),_=t(87369);async function S(e,r){if("GET"!==e.method)return r.json({success:!1,msg:"Failed"});let t=await (0,_.A)(e);if(!t?.logged_in_status)return r.json({success:!1,log:"No Logs"});let n="./.tmp/backups";i().existsSync(n)||i().mkdirSync("./.tmp/backups");let s=Date.now().toString();i().mkdirSync(`${n}/${s}`);let o=u().platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe'":"mysqldump";try{let e={cwd:process.cwd()},t=`${n}/${s}/datasquirel.sql`;u().platform().match(/win/i)&&(e.shell="bash.exe");let a=`${o} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD} datasquirel > ${t}`;console.log(`createNewBackup.ts exe => ${a}`),(0,d.execSync)(a,e),i().copyFileSync("./jsonData/dbSchemas/main.json",`${n}/${s}/datasquirelSchema.json`),function({rootFolderPath:e,destinationFolderPath:r}){try{i().mkdirSync(r),function e(r,t){let n=i().readdirSync(r);for(let s=0;s<n.length;s++){let o=n[s];o?.match(/\..{2,5}$/)?i().copyFileSync(`${r}/${o}`,`${t}/${o}`):(i().mkdirSync(`${t}/${o}`,{recursive:!0}),e(`${r}/${o}`,`${t}/${o}`))}}(e,r)}catch(e){return console.log(e.message),!1}}({rootFolderPath:`${process.env.DSQL_USER_DB_SCHEMA_PATH}`,destinationFolderPath:`${n}/${s}/userSchemas`}),r.json({success:!0})}catch(e){r.json({success:!1}),(0,p.A)({component:"/api/admin/createNewBackup/lines-73-90",message:e.message})}}let m=(0,a.M)(n,"default"),f=(0,a.M)(n,"config"),y=new s.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/admin/createNewBackup",pathname:"/api/admin/createNewBackup",bundlePath:"",filename:""},userland:n})},87369:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(95969),s=t(89159);async function o(e){let{keyCookieName:r,csrfCookieName:t}=(0,s.A)(),o=`${r}_su`;if(!e.cookies?.[o])return console.log("No auth key cookie found"),null;let a=(0,n.A)({encryptedString:e.cookies[o]});if(!a)return console.log("No user payload found"),null;let c=JSON.parse(a);return c.password!==process.env.DSQL_USER_KEY?(console.log("Invalid password"),null):c.authKey!==process.env.DSQL_SPECIAL_KEY?(console.log("Invalid auth key"),null):c}},89159:(e,r,t)=>{t.d(r,{A:()=>n});function n(e){let r=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",n=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",s=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",o=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),a=r;e?.userId&&(a+=`user_${e.userId}_`),o&&(a+=`${o}_`),a+=t;let c=r;e?.userId&&(c+=`user_${e.userId}_`),o&&(c+=`${o}_`),c+=n;let i=r;return e?.userId&&(i+=`user_${e.userId}_`),o&&(i+=`${o}_`),{keyCookieName:a,csrfCookieName:c,oneTimeCodeName:i+=s}}},67619:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(29021),s=t.n(n);async function o({user:e,message:r,component:t,noMail:n,req:o}){let a=new Date,c=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],t=o.headers["cf-connecting-ip"],n=Array.isArray(e)?e[0]:e?.split(",")[0],s=t||n||r||o.socket.remoteAddress;if(!s)return null;return String(s)}catch(e){return null}})();try{let n=`🚀 SERVER ERROR ===========================
|
|
Error Message: ${r}
|
|
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(n+=`
|
|
User Id: ${e?.id}
|
|
User Name: ${e?.first_name} ${e?.last_name}
|
|
User Email: ${e?.email}`),o?.url&&(n+=`
|
|
URL: ${o.url}`),o?.body&&(n+=`
|
|
Request Body: ${JSON.stringify(o.body,null,4)}`),c&&(n+=`
|
|
IP: ${c}`),n+=`
|
|
Date: ${a.toDateString()}
|
|
========================================`,s().existsSync("./.tmp/error.log")||s().writeFileSync("./.tmp/error.log","","utf-8");let i=s().readFileSync("./.tmp/error.log","utf-8");s().writeFileSync("./.tmp/error.log",n),s().appendFileSync("./.tmp/error.log",`
|
|
|
|
|
|
|
|
|
|
${i}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},95969:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(55511),s=t(79428);function o({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let o=r||process.env.DSQL_ENCRYPTION_PASSWORD,a=t||process.env.DSQL_ENCRYPTION_SALT,c=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!o?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!a?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let i=(0,n.scryptSync)(o,a,c),l=s.Buffer.alloc(16,0),u=(0,n.createDecipheriv)("aes-192-cbc",i,l);try{let r=u.update(e,"hex","utf8");return r+=u.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}});var t=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../../webpack-api-runtime.js");r.C(e);var t=r(r.s=57856);module.exports=t})(); |