2025-01-13 08:00:21 +00:00
|
|
|
"use strict";(()=>{var e={};e.id=9171,e.ids=[9171],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,s){return s in r?r[s]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,s)):"function"==typeof r&&"default"===s?r:void 0}}})},99323:(e,r,s)=>{s.r(r),s.d(r,{config:()=>E,default:()=>S,routeModule:()=>f});var n={};s.r(n),s.d(n,{default:()=>p});var o=s(89947),t=s(2706),c=s(96762),a=s(48786),i=s(87369);let u=s(29021),l=s(21820),{execSync:_,spawnSync:d}=s(79646);async function p(e,r){if("POST"!==e.method)return r.json({success:!1,msg:"Wrong Method"});let s=await (0,i.A)(e);if(!s?.logged_in_status)return r.json({success:!1,log:"Unauthorized"});try{let s=e.body.user.id.toString().replace(/[^0-9]/g,"").replace(/\//g,""),n=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${s}/backups`;u.existsSync(n)||u.mkdirSync(n);let o=Date.now().toString();u.mkdirSync(`${n}/${o}`);let t=await (0,a.A)("SHOW databases LIKE ?",[`datasquirel_user_${s}_%`]);for(let e=0;e<t.length;e++){let r=t[e],s=Object.values(r)[0].replace(/[^a-z0-9\_]/g,""),c=l.platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe'":"mysqldump",a={cwd:process.cwd()},i=`${n}/${o}/${s}.sql`;l.platform().match(/win/i)&&(a.shell="bash.exe");let u=`${c} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD} ${s} > ${i}`;console.log(`addUserBackup.ts exe => ${u}`),d(c,["-u",process.env.DSQL_DB_USERNAME,"-h",process.env.DSQL_DB_HOST,`-p${process.env.DSQL_DB_PASSWORD}`,s,">",i],a)}u.copyFileSync(`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${s}/main.json`,`${n}/${o}/main.json`),r.json({success:!0})}catch(e){console.log(e.message),r.json({success:!1})}}let S=(0,c.M)(n,"default"),E=(0,c.M)(n,"config"),f=new o.PagesAPIRouteModule({definition:{kind:t.A.PAGES_API,page:"/api/admin/addUserBackup",pathname:"/api/admin/addUserBackup",bundlePath:"",filename:""},userland:n})},87369:(e,r,s)=>{s.d(r,{A:()=>t});var n=s(95969),o=s(89159);async function t(e){let{keyCookieName:r,csrfCookieName:s}=(0,o.A)(),t=`${r}_su`;if(!e.cookies?.[t])return console.log("No auth key cookie found"),null;let c=(0,n.A)({encryptedString:e.cookies[t]});if(!c)return console.log("No user payload found"),null;let a=JSON.parse(c);return a.password!==process.env.DSQL_USER_KEY?(console.log("Invalid password"),null):a.authKey!==process.env.DSQL_SPECIAL_KEY?(console.log("Invalid auth key"),null):a}},89159:(e,r,s)=>{s.d(r,{A:()=>n});function n(e){let r=process.env.DSQL_COOKIES_PREFIX||"dsql_",s=process.env.DSQL_COOKIES_KEY_NAME||"key",n=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",o=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",t=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),c=r;e?.userId&&(c+=`user_${e.userId}_`),t&&(c+=`${t}_`),c+=s;let a=r;e?.userId&&(a+=`user_${e.userId}_`),t&&(a+=`${t}_`),a+=n;let i=r;return e?.userId&&(i+=`user_${e.userId}_`),t&&(i+=`${t}_`),{keyCookieName:c,csrfCookieName:a,oneTimeCodeName:i+=o}}},95969:(e,r,s)=>{s.d(r,{A:()=>t});var n=s(55511),o=s(79428);function t({encryptedString:e,encryptionKey:r,encryptionSalt:s}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let t=r||process.env.DSQL_ENCRYPTION_PASSWORD,c=s||process.env.DSQL_ENCRYPTION_SALT,a=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!t?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!c?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let i=(0,n.scryptSync)(t,c,a),u=o.Buffer.alloc(16,0),l=(0,n.createDecipheriv)("aes-192-cbc",i,u);try{let r=l.update(e,"hex","utf8");return r+=l.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e
|