working with app
This commit is contained in:
parent
f7826664a9
commit
10a9f9da52
30
.vscode/launch.json
vendored
30
.vscode/launch.json
vendored
@ -21,10 +21,11 @@
|
|||||||
],
|
],
|
||||||
"program": "${workspaceFolder}/bin/www",
|
"program": "${workspaceFolder}/bin/www",
|
||||||
"env": {
|
"env": {
|
||||||
"HOST": "localhost",
|
"DBHOST": "vps.k-world.me.uk",
|
||||||
"DBUSER": "root",
|
"DBUSER": "root",
|
||||||
"DBPASS": "example",
|
"DBPASS": "Grd555269",
|
||||||
"DATABASE":"BBLB_DNS"
|
"DATABASE": "BBLB_DNS",
|
||||||
|
"DBPORT": "3306",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -36,10 +37,27 @@
|
|||||||
],
|
],
|
||||||
"program": "${workspaceFolder}/lib/checker.js",
|
"program": "${workspaceFolder}/lib/checker.js",
|
||||||
"env": {
|
"env": {
|
||||||
"HOST": "localhost",
|
"DBHOST": "vps.k-world.me.uk",
|
||||||
"DBUSER": "root",
|
"DBUSER": "root",
|
||||||
"DBPASS": "example",
|
"DBPASS": "Grd555269",
|
||||||
"DATABASE":"BBLB_DNS"
|
"DATABASE": "BBLB_DNS",
|
||||||
|
"DBPORT": "3306",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "AddAcccount",
|
||||||
|
"skipFiles": [
|
||||||
|
"<node_internals>/**"
|
||||||
|
],
|
||||||
|
"program": "${workspaceFolder}/lib/addAccounts.js",
|
||||||
|
"env": {
|
||||||
|
"DBHOST": "vps.k-world.me.uk",
|
||||||
|
"DBUSER": "root",
|
||||||
|
"DBPASS": "Grd555269",
|
||||||
|
"DATABASE": "BBLB_DNS",
|
||||||
|
"DBPORT": "3306",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
2
.vscode/settings.json
vendored
Normal file
2
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
{
|
||||||
|
}
|
12
app.js
12
app.js
@ -12,6 +12,7 @@ var streamsRouter = require('./routes/getStreams');
|
|||||||
var getUserAccounts = require('./routes/getUserAccounts')
|
var getUserAccounts = require('./routes/getUserAccounts')
|
||||||
var singleUserCheck = require('./routes/singleCheck')
|
var singleUserCheck = require('./routes/singleCheck')
|
||||||
var addAccount = require('./routes/addAccount')
|
var addAccount = require('./routes/addAccount')
|
||||||
|
var deleteAccount = require('./routes/deleteAccount')
|
||||||
var readCookie = require('./routes/readCookie')
|
var readCookie = require('./routes/readCookie')
|
||||||
var getStreamNames = require('./routes/getStreamNames')
|
var getStreamNames = require('./routes/getStreamNames')
|
||||||
var login = require('./routes/login')
|
var login = require('./routes/login')
|
||||||
@ -39,12 +40,13 @@ const users = {
|
|||||||
|
|
||||||
app.use('/', indexRouter);
|
app.use('/', indexRouter);
|
||||||
app.use('/login', basicAuth(users), login)
|
app.use('/login', basicAuth(users), login)
|
||||||
app.use('/getStreams', streamsRouter);
|
// app.use('/getStreams', streamsRouter);
|
||||||
app.use('/getUserAccounts', getUserAccounts);
|
app.use('/getUserAccounts', basicAuth(users), getUserAccounts);
|
||||||
app.use('/singleCheck', basicAuth(users), singleUserCheck)
|
app.use('/singleCheck', basicAuth(users), singleUserCheck)
|
||||||
app.use('/addAccount', addAccount)
|
app.use('/addAccount', basicAuth(users), addAccount)
|
||||||
app.use('/readCookie', readCookie)
|
app.use('/deleteAccount', basicAuth(users), deleteAccount)
|
||||||
app.use('/getStreamNames', getStreamNames)
|
// app.use('/readCookie', readCookie)
|
||||||
|
// app.use('/getStreamNames', getStreamNames)
|
||||||
|
|
||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
|
8
client/package-lock.json
generated
8
client/package-lock.json
generated
@ -1910,14 +1910,6 @@
|
|||||||
"@testing-library/dom": "^7.28.1"
|
"@testing-library/dom": "^7.28.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@testing-library/user-event": {
|
|
||||||
"version": "12.7.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-12.7.3.tgz",
|
|
||||||
"integrity": "sha512-IdSHkWfbeSSJRFlldvHDWfVX0U18TbXIvLSGII+JbqkJrsflFr4OWlQIua0TvcVVJNna3BNrNvRSvpQ0yvSXlA==",
|
|
||||||
"requires": {
|
|
||||||
"@babel/runtime": "^7.12.5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@types/anymatch": {
|
"@types/anymatch": {
|
||||||
"version": "1.3.1",
|
"version": "1.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz",
|
||||||
|
@ -20,6 +20,7 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./client
|
context: ./client
|
||||||
dockerfile: Dockerfile.prod
|
dockerfile: Dockerfile.prod
|
||||||
|
# dockerfile: .dockerfile
|
||||||
image: "karl0ss/bblbtv_dns-frontend"
|
image: "karl0ss/bblbtv_dns-frontend"
|
||||||
ports:
|
ports:
|
||||||
- "6969:6969"
|
- "6969:6969"
|
||||||
|
@ -5,10 +5,19 @@ const sql = require('./mysql')
|
|||||||
|
|
||||||
function storeAccountToDB(accountDetails) {
|
function storeAccountToDB(accountDetails) {
|
||||||
const encryptedPassword = cryptr.encrypt(accountDetails.password);
|
const encryptedPassword = cryptr.encrypt(accountDetails.password);
|
||||||
const result = sql.query(`INSERT userAccounts (username, password, stream, userID) VALUES ("${accountDetails.username}", "${encryptedPassword}", "${accountDetails.stream}", ${accountDetails.userId})`);
|
const result = sql.query(`INSERT userAccounts (username, password, stream, userID, expiaryDate) VALUES ("${accountDetails.username}", "${encryptedPassword}", "${accountDetails.stream}", ${accountDetails.userId}, 123)`);
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeAccountFromDB(accountDetails) {
|
||||||
|
const result = sql.query(`DELETE FROM userAccounts WHERE
|
||||||
|
username = '${accountDetails.user}' AND
|
||||||
|
stream = '${accountDetails.stream}' AND
|
||||||
|
userId = ${accountDetails.userId} `);
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function retrievePasswordFromDB(user, userAccUser) {
|
function retrievePasswordFromDB(user, userAccUser) {
|
||||||
let userId
|
let userId
|
||||||
try {
|
try {
|
||||||
@ -39,11 +48,20 @@ WHERE userAccounts.userID = ${userId} AND userAccounts.username = '${userAccUser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// accountDetails = {
|
||||||
|
// "username": "Darren110921",
|
||||||
|
// "password" :"saD2V2kjyNqH",
|
||||||
|
// "stream": "Badger",
|
||||||
|
// "userId" : "2"
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
// retrievePasswordFromDB('Karl', 'Karl2903')
|
|
||||||
|
// retrievePasswordFromDB('Karl', 'Maxine2206')
|
||||||
|
// storeAccountToDB(accountDetails)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
removeAccountFromDB,
|
||||||
storeAccountToDB,
|
storeAccountToDB,
|
||||||
retrievePasswordFromDB
|
retrievePasswordFromDB
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
[
|
[
|
||||||
"http://webservgroup.xyz/smarters4567891/api/home.php?action=dns",
|
"http://webservgroup.xyz/smarters4567891/api/home.php?action=dns",
|
||||||
"https://topsapp.xyz/SMARTERS/scotslad/api/home.php?action=dns"
|
"http://panelhost.xyz/cli3nts/Funky/Smarters/api/home.php?action=dns"
|
||||||
]
|
]
|
137
lib/checker.js
137
lib/checker.js
@ -11,7 +11,11 @@ const { gotRequest } = require('./gotRequest')
|
|||||||
|
|
||||||
const { decryptPassword } = require('./password')
|
const { decryptPassword } = require('./password')
|
||||||
|
|
||||||
const { getAllUserAccounts } = require('./getUser')
|
const { getAllUserAccounts, getUserAccountsCheck } = require('./getUser')
|
||||||
|
|
||||||
|
const { setExpired } = require('./setExpired')
|
||||||
|
|
||||||
|
const { removeAccountFromDB } = require('../lib/Accounts')
|
||||||
|
|
||||||
const delay = ms => new Promise(res => setTimeout(res, ms));
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
||||||
|
|
||||||
@ -82,20 +86,21 @@ async function newCheck() {
|
|||||||
return user
|
return user
|
||||||
})
|
})
|
||||||
for (let userAccount of userAccounts) {
|
for (let userAccount of userAccounts) {
|
||||||
console.log(userAccount.username, userAccount.passwordDecryped)
|
if (userAccount.expiaryDate != 123 && Math.round(Date.now() / 1000) > userAccount.expiaryDate) {
|
||||||
|
setExpired(userAccount)
|
||||||
|
} else {
|
||||||
for (let streamURL of streamURLS) {
|
for (let streamURL of streamURLS) {
|
||||||
process.stdout.write('.')
|
process.stdout.write('.')
|
||||||
let url = await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped)
|
let url = await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped)
|
||||||
// console.log(url)
|
|
||||||
let t = await gotRequest(url)
|
let t = await gotRequest(url)
|
||||||
let body = t.body
|
let body = t.body
|
||||||
if (t.statusCode == 200 && body !== "") {
|
if (t.statusCode == 200 && body !== "") {
|
||||||
try {
|
try {
|
||||||
body = JSON.parse(body)
|
body = JSON.parse(body)
|
||||||
if (body.user_info.auth) {
|
if (body.user_info.auth) {
|
||||||
// var date = new Date(body.user_info.exp_date * 1000).toLocaleDateString('en-GB')
|
var date = new Date(body.user_info.exp_date * 1000).toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
|
||||||
process.stdout.write('\n')
|
// process.stdout.write('\n')
|
||||||
console.log(`Match - ${userAccount.username} - ${streamURL} - Expires - ${body.user_info.exp_date}`)
|
console.log(`${userAccount.username} - ${userAccount.stream} - ${streamURL} - Expires ${date}.`)
|
||||||
await updateStreamData(userAccount, streamURL, body.user_info.exp_date)
|
await updateStreamData(userAccount, streamURL, body.user_info.exp_date)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -105,13 +110,129 @@ async function newCheck() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async function newUserCheck(accountData) {
|
||||||
|
streamURLS = await getStreamsNew()
|
||||||
|
let userAccounts = await getUserAccountsCheck(accountData.userId)
|
||||||
|
userAccounts = userAccounts.map(user => {
|
||||||
|
user.passwordDecryped = decryptPassword(user.password)
|
||||||
|
return user
|
||||||
|
})
|
||||||
|
|
||||||
|
for (let userAccount of userAccounts) {
|
||||||
|
if (userAccount.expiaryDate != 123 && Math.round(Date.now() / 1000) > userAccount.expiaryDate) {
|
||||||
|
setExpired(userAccount)
|
||||||
|
} else {
|
||||||
|
for (let streamURL of streamURLS) {
|
||||||
|
process.stdout.write('.')
|
||||||
|
let url = await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped)
|
||||||
|
let t = await gotRequest(url)
|
||||||
|
let body = t.body
|
||||||
|
if (t.statusCode == 200 && body !== "") {
|
||||||
|
try {
|
||||||
|
body = JSON.parse(body)
|
||||||
|
if (body.user_info.auth) {
|
||||||
|
var date = new Date(body.user_info.exp_date * 1000).toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
|
||||||
|
// process.stdout.write('\n')
|
||||||
|
console.log(`${userAccount.username} - ${userAccount.stream} - ${streamURL} - Expires ${date}.`)
|
||||||
|
await updateStreamData(userAccount, streamURL, body.user_info.exp_date)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function newSingleCheck(accountData) {
|
||||||
|
streamURLS = await getStreamsNew()
|
||||||
|
let userAccounts = await getUserAccountsCheck(accountData.userId)
|
||||||
|
userAccounts = userAccounts.map(user => {
|
||||||
|
user.passwordDecryped = decryptPassword(user.password)
|
||||||
|
return user
|
||||||
|
})
|
||||||
|
var result = userAccounts.filter(obj => {
|
||||||
|
return obj.username === accountData.username && obj.passwordDecryped === accountData.password && obj.stream === accountData.stream
|
||||||
|
})
|
||||||
|
|
||||||
|
for (let userAccount of result) {
|
||||||
|
if (userAccount.expiaryDate != 123 && Math.round(Date.now() / 1000) > userAccount.expiaryDate) {
|
||||||
|
setExpired(userAccount)
|
||||||
|
} else {
|
||||||
|
for (let streamURL of streamURLS) {
|
||||||
|
process.stdout.write('.')
|
||||||
|
let url = await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped)
|
||||||
|
let t = await gotRequest(url)
|
||||||
|
let body = t.body
|
||||||
|
if (t.statusCode == 200 && body !== "") {
|
||||||
|
try {
|
||||||
|
body = JSON.parse(body)
|
||||||
|
if (body.user_info.auth) {
|
||||||
|
var date = new Date(body.user_info.exp_date * 1000).toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
|
||||||
|
// process.stdout.write('\n')
|
||||||
|
console.log(`${userAccount.username} - ${userAccount.stream} - ${streamURL} - Expires ${date}.`)
|
||||||
|
await updateStreamData(userAccount, streamURL, body.user_info.exp_date)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
removeAccountFromDB({
|
||||||
|
"user": userAccount.username,
|
||||||
|
"stream": userAccount.stream,
|
||||||
|
"userId": accountData.userId
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// async function newSingleCheck(userData) {
|
||||||
|
// streamURLS = await getStreamsNew()
|
||||||
|
// for (let streamURL of streamURLS) {
|
||||||
|
// process.stdout.write('.')
|
||||||
|
// let url = await buildURL(streamURL, userData.username, userData.password)
|
||||||
|
// // console.log(url)
|
||||||
|
// let t = await gotRequest(url)
|
||||||
|
// let body = t.body
|
||||||
|
// if (t.statusCode == 200 && body !== "") {
|
||||||
|
// try {
|
||||||
|
// body = JSON.parse(body)
|
||||||
|
// if (body.user_info.auth) {
|
||||||
|
// // var date = new Date(body.user_info.exp_date * 1000).toLocaleDateString('en-GB')
|
||||||
|
// // process.stdout.write('\n')
|
||||||
|
// await updateStreamData(userAccount, streamURL, body.user_info.exp_date)
|
||||||
|
// console.log(`Match - ${username} - ${streamURL} - Expires - ${body.user_info.exp_date}`)
|
||||||
|
// return (`Match - ${username} - ${streamURL} - Expires - ${body.user_info.exp_date}`)
|
||||||
|
// // break
|
||||||
|
// }
|
||||||
|
// } catch (error) {
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
|
||||||
// main()
|
// main()
|
||||||
// singleCheck('Karl2903')
|
// singleCheck('Karl2903')
|
||||||
newCheck()
|
// newCheck()
|
||||||
|
// newSingleCheck('Karl1607', 'Ybkjqszr1z')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
newCheck,
|
newCheck,
|
||||||
singleCheck,
|
singleCheck,
|
||||||
main
|
main,
|
||||||
|
newSingleCheck,
|
||||||
|
newUserCheck
|
||||||
}
|
}
|
@ -3,14 +3,31 @@ const sql = require('./mysql')
|
|||||||
function getUserAccounts(user) {
|
function getUserAccounts(user) {
|
||||||
let data = sql.query(`SELECT
|
let data = sql.query(`SELECT
|
||||||
userAccounts.username,
|
userAccounts.username,
|
||||||
streams.streamName,
|
userAccounts.stream,
|
||||||
streams.streamURL,
|
userAccounts.streamURL,
|
||||||
userAccounts.expiaryDate
|
userAccounts.expiaryDate
|
||||||
FROM users
|
FROM users
|
||||||
INNER JOIN userAccounts
|
INNER JOIN userAccounts
|
||||||
ON users.id = userAccounts.userID
|
ON users.id = userAccounts.userID
|
||||||
INNER JOIN streams
|
WHERE users.id = '${user}'`)
|
||||||
ON userAccounts.stream = streams.streamName
|
// console.log(data)
|
||||||
|
if (data.length == 0) {
|
||||||
|
return 'User Not Found'
|
||||||
|
} else {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUserAccountsCheck(user) {
|
||||||
|
let data = sql.query(`SELECT
|
||||||
|
userAccounts.username,
|
||||||
|
userAccounts.stream,
|
||||||
|
userAccounts.streamURL,
|
||||||
|
userAccounts.expiaryDate,
|
||||||
|
userAccounts.password
|
||||||
|
FROM users
|
||||||
|
INNER JOIN userAccounts
|
||||||
|
ON users.id = userAccounts.userID
|
||||||
WHERE users.id = '${user}'`)
|
WHERE users.id = '${user}'`)
|
||||||
// console.log(data)
|
// console.log(data)
|
||||||
if (data.length == 0) {
|
if (data.length == 0) {
|
||||||
@ -23,8 +40,12 @@ function getUserAccounts(user) {
|
|||||||
function getAllUserAccounts() {
|
function getAllUserAccounts() {
|
||||||
let data = sql.query(`SELECT
|
let data = sql.query(`SELECT
|
||||||
userAccounts.username,
|
userAccounts.username,
|
||||||
userAccounts.password
|
userAccounts.password,
|
||||||
|
userAccounts.expiaryDate,
|
||||||
|
userAccounts.stream
|
||||||
FROM userAccounts
|
FROM userAccounts
|
||||||
|
WHERE userAccounts.expiaryDate != '0'
|
||||||
|
ORDER BY userAccounts.id DESC
|
||||||
`)
|
`)
|
||||||
// console.log(data)
|
// console.log(data)
|
||||||
if (data.length == 0) {
|
if (data.length == 0) {
|
||||||
@ -34,8 +55,21 @@ FROM userAccounts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
function getUserId(user) {
|
||||||
getUserAccounts,
|
let data = sql.query(`SELECT id FROM users WHERE userName = '${user}'`)
|
||||||
getAllUserAccounts
|
// console.log(data)
|
||||||
|
if (data.length == 0) {
|
||||||
|
return 'User Not Found'
|
||||||
|
} else {
|
||||||
|
return data[0].id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getUserAccounts,
|
||||||
|
getAllUserAccounts,
|
||||||
|
getUserId,
|
||||||
|
getUserAccountsCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ const sql = require('./mysql')
|
|||||||
|
|
||||||
function getUsers() {
|
function getUsers() {
|
||||||
let data = sql.query(`SELECT
|
let data = sql.query(`SELECT
|
||||||
|
|
||||||
userName,
|
userName,
|
||||||
password
|
password
|
||||||
FROM users
|
FROM users
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
[
|
|
||||||
"https://trippy.pro:443",
|
|
||||||
"https://itty.in:443"
|
|
||||||
]
|
|
7
lib/otherURLs.json
Normal file
7
lib/otherURLs.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[
|
||||||
|
"https://trippy.pro:443",
|
||||||
|
"https://itty.in:443",
|
||||||
|
"https://tictacs.win",
|
||||||
|
"http://sting.ltd:25461",
|
||||||
|
"http://37723998.to:2052"
|
||||||
|
]
|
17
lib/setExpired.js
Normal file
17
lib/setExpired.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const sql = require('./mysql')
|
||||||
|
|
||||||
|
function setExpired(userAccount) {
|
||||||
|
console.log(userAccount.username + ' ' + userAccount.stream + ' Expired on ' + userAccount.expiaryDate.toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }))
|
||||||
|
let result
|
||||||
|
try {
|
||||||
|
result = sql.query(`UPDATE userAccounts SET expiaryDate = "0" WHERE username = "${userAccount.username}" AND password = "${userAccount.password}"; `);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
setExpired
|
||||||
|
}
|
||||||
|
|
@ -1,20 +1,28 @@
|
|||||||
var express = require('express');
|
var express = require('express');
|
||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
|
|
||||||
const { storeAccountToDB } = require('../lib/addAccounts')
|
const { storeAccountToDB } = require('../lib/Accounts')
|
||||||
const { getUserName } = require('../lib/getUsers')
|
const { getUserId } = require('../lib/getUser')
|
||||||
|
const { newSingleCheck } = require('../lib/checker')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* POST postUser page. */
|
/* POST postUser page. */
|
||||||
router.post('/', async function (req, res, next) {
|
router.post('/', async function (req, res, next) {
|
||||||
let postData = req.body
|
let postData = req.body
|
||||||
postData.userId = Number(req.signedCookies.user)
|
postData.userId = getUserId(req.auth.user)
|
||||||
let userName = await getUserName(req.signedCookies.user)
|
let userName = req.auth.user
|
||||||
let result = await storeAccountToDB(postData)
|
let result = await storeAccountToDB(postData)
|
||||||
console.log(result)
|
console.log(result)
|
||||||
if (result.affectedRows < 1) {
|
if (result.affectedRows < 1) {
|
||||||
res.send('Adding account failed')
|
res.send('Adding account failed')
|
||||||
} else {
|
} else {
|
||||||
|
a = await newSingleCheck(postData)
|
||||||
|
if (a) {
|
||||||
res.send('Account ' + postData.username + ' Added successfully to ' + userName)
|
res.send('Account ' + postData.username + ' Added successfully to ' + userName)
|
||||||
|
} else {
|
||||||
|
res.send(500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
22
routes/deleteAccount.js
Normal file
22
routes/deleteAccount.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
var express = require('express');
|
||||||
|
var router = express.Router();
|
||||||
|
|
||||||
|
const { removeAccountFromDB} = require('../lib/Accounts')
|
||||||
|
const { getUserId } = require('../lib/getUser')
|
||||||
|
|
||||||
|
|
||||||
|
/* POST postUser page. */
|
||||||
|
router.post('/', async function (req, res, next) {
|
||||||
|
let postData = req.body
|
||||||
|
postData.userId = getUserId(req.auth.user)
|
||||||
|
let userName = req.auth.user
|
||||||
|
let result = await removeAccountFromDB(postData)
|
||||||
|
console.log(result)
|
||||||
|
if (result.affectedRows < 1) {
|
||||||
|
res.send('Adding account failed')
|
||||||
|
} else {
|
||||||
|
res.send('Account ' + postData.username + ' Deleted from ' + userName)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
@ -4,7 +4,7 @@ const fs = require('fs');
|
|||||||
|
|
||||||
let DNSArray = require('../lib/DNSArray.json')
|
let DNSArray = require('../lib/DNSArray.json')
|
||||||
let streamArrays = require('../lib/streamArray.json')
|
let streamArrays = require('../lib/streamArray.json')
|
||||||
const otherDNS = require('../lib/otherDNS.json')
|
const otherURLs = require('../lib/otherURLs.json')
|
||||||
|
|
||||||
const { gotRequest } = require('../lib/gotRequest')
|
const { gotRequest } = require('../lib/gotRequest')
|
||||||
|
|
||||||
@ -54,12 +54,17 @@ async function getStreamsNew() {
|
|||||||
for (let index = 0; index < DNSArray.length; index++) {
|
for (let index = 0; index < DNSArray.length; index++) {
|
||||||
const url = DNSArray[index];
|
const url = DNSArray[index];
|
||||||
requestData = await gotRequest(url)
|
requestData = await gotRequest(url)
|
||||||
let DNSList = JSON.parse(requestData.body)
|
let DNSList = requestData.body
|
||||||
|
if (typeof DNSList === 'string' || DNSList instanceof String) {
|
||||||
|
DNSList = JSON.parse(DNSList)
|
||||||
|
}
|
||||||
DNSList = splitToArray(DNSList.su)
|
DNSList = splitToArray(DNSList.su)
|
||||||
DNSList.forEach(url => {
|
DNSList.forEach(url => {
|
||||||
jointArray.push(url)
|
jointArray.push(url)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
jointArray.unshift(...otherURLs)
|
||||||
|
|
||||||
return jointArray
|
return jointArray
|
||||||
}
|
}
|
||||||
/* GET users listing. */
|
/* GET users listing. */
|
||||||
@ -71,4 +76,3 @@ router.get('/', async function (req, res, next) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
router, getStreams, getStreamsNew
|
router, getStreams, getStreamsNew
|
||||||
}
|
}
|
||||||
;
|
|
@ -1,16 +1,13 @@
|
|||||||
var express = require('express');
|
var express = require('express');
|
||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
|
|
||||||
const { getUserAccounts } = require('../lib/getUser')
|
const { getUserAccounts, getUserId } = require('../lib/getUser')
|
||||||
|
|
||||||
/* POST postUser page. */
|
/* POST postUser page. */
|
||||||
router.get('/', async function (req, res, next) {
|
router.get('/', async function (req, res, next) {
|
||||||
if (req.cookies.user === undefined) {
|
let userId = await getUserId(req.auth.user)
|
||||||
res.send('Cookie Not Set')
|
let data = await getUserAccounts(userId)
|
||||||
} else {
|
|
||||||
let data = await getUserAccounts(req.cookies.user)
|
|
||||||
res.send(data)
|
res.send(data)
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
var express = require('express');
|
var express = require('express');
|
||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
|
|
||||||
const { singleCheck } = require('../lib/checker')
|
const { storeAccountToDB } = require('../lib/Accounts')
|
||||||
|
const { getUserId } = require('../lib/getUser')
|
||||||
|
const { newUserCheck } = require('../lib/checker')
|
||||||
|
|
||||||
/* POST postUser page. */
|
/* POST postUser page. */
|
||||||
router.post('/', async function (req, res, next) {
|
router.get('/', async function (req, res, next) {
|
||||||
let postedUsername = req.body.username
|
let postData = req.body
|
||||||
|
postData.userId = getUserId(req.auth.user)
|
||||||
let data = await singleCheck(postedUsername)
|
a = await newUserCheck(postData)
|
||||||
|
if (a) {
|
||||||
res.send(data);
|
res.send(200)
|
||||||
|
} else {
|
||||||
|
res.send(500);
|
||||||
|
}
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user