-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
374 lines (344 loc) · 14.4 KB
/
app.js
File metadata and controls
374 lines (344 loc) · 14.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
var express = require('express');
var app = express();
var path = require('path');
var mongo = require('mongodb');
const MongoClient = require('mongodb').MongoClient;
// stats require
// const fetch = require("node-fetch");
const https = require('https');
const axios = require('axios')
const ApexM = require('./modals/Apex');
const R6API = require('r6api.js').default;
var path = require('path');
var apex = require('./stats/apex.js')
const Apex = require('./modals/Apex');
const cors = require("cors");
const corsOptions = {
origin: '*',
credentials: true, //access-control-allow-credentials:true
optionSuccessStatus: 200,
}
var ObjectId = require('mongodb').ObjectId;
app.use(cors(corsOptions))
// process.env.URI ||
var url = "mongodb://blazing:blazingbane@comments-shard-00-00.9fhsn.mongodb.net:27017,comments-shard-00-01.9fhsn.mongodb.net:27017,comments-shard-00-02.9fhsn.mongodb.net:27017/test?replicaSet=atlas-2rxnym-shard-0&ssl=true&authSource=admin"
MongoClient.connect(url, {
useNewUrlParser: true,
useUnifiedTopology: true
}, function(err, db) {
if (err) throw err;
db.close();
});
app.set('view engine', 'ejs');
app.use("/public", express.static(path.join(__dirname, "/public")));
app.get('/', function(req, res) {
var url = "mongodb://blazing:blazingbane@comments-shard-00-00.9fhsn.mongodb.net:27017,comments-shard-00-01.9fhsn.mongodb.net:27017,comments-shard-00-02.9fhsn.mongodb.net:27017/test?replicaSet=atlas-2rxnym-shard-0&ssl=true&authSource=admin"
MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("youtube");
dbo.collection("donations").find({}).limit(5).sort("amt", -1).toArray(function(err, result) {
if (err) throw err;
array = result
dbo.collection("donations").find({}).limit(5).sort("time", -1).toArray(function(err, result) {
if (err) throw err;
arrayT = result
dbo.collection("live").find({}).sort("count", -1).limit(20).toArray(function(err, result) {
if (err) throw err;
pillars = result
res.render('index', { array, arrayT, pillars })
db.close();
});
});
});
});
// res.render("index")
})
app.get('/pc', function(req, res) {
res.render("pc")
// res.sendFile(path.join(__dirname, 'views/pc.html'));
})
var pillars = ["JayanthRaj Vipergaming War-hulk War-lord Sritan Ravan-gaming Asura-Vajresh Seven-yeshwanth Imvjgamer Rexop Baresspanda Ramp-sd Dunde-ganesh Shivanand-yadav Serious-gaming Suresh-reddy Mahesh-yadav Bewakoof-edits JSC-gaming Balagoni-gamer Arun-perem Ak-47 Sai-Krishna Pavan-gandham My3-ravi Siva-chaitanya Vinod-mourya Speedy-s9 Prabhath-verma Sunil-p Charan-cherry Harsha-reddy Sg-king Affective-gaming Imspeed Ghost-gamer Overpro-Yt Gamerd Unitedwestand Lightz Bullymaguire Chotku Gamer111 Max-master Cdking Manigamingtelugu Cyclonous Crazy Asura-rekrax Aditya-verma Abhishek monstol elcin kavin-walton ryft-yt wyatt"]
app.get('/viewer/:Par', function name(req, res) {
obid = req.params.Par
console.log(obid);
var url = "mongodb://blazing:blazingbane@comments-shard-00-00.9fhsn.mongodb.net:27017,comments-shard-00-01.9fhsn.mongodb.net:27017,comments-shard-00-02.9fhsn.mongodb.net:27017/test?replicaSet=atlas-2rxnym-shard-0&ssl=true&authSource=admin"
MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("youtube");
dbo.collection("live").find({ '_id': ObjectId(obid) }).toArray(function(err, result) {
if (err) throw err;
console.log(result);
viewer = result
maxage = 1
res.render('viewer', { viewer })
db.close();
});
});
})
app.get('/pillers', function(req, res) {
var url = "mongodb://blazing:blazingbane@comments-shard-00-00.9fhsn.mongodb.net:27017,comments-shard-00-01.9fhsn.mongodb.net:27017,comments-shard-00-02.9fhsn.mongodb.net:27017/test?replicaSet=atlas-2rxnym-shard-0&ssl=true&authSource=admin"
// res.render('test')
MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("youtube");
dbo.collection("donations").find({}).limit(5).sort("amt", -1).toArray(function(err, result) {
if (err) throw err;
array = result
total = 0
array.forEach(element => {
total = element.amt + total
});
dbo.collection("donations").find({}).limit(10).sort("time", -1).toArray(function(err, result) {
function date(date1, date2) {
datef = new Date(date1).getTime()
datel = new Date(date2).getTime()
Difference_In_Time = date2 - date1;
Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24)
return ((datel - datef) / (1000 * 3600 * 24));
}
if (err) throw err;
arrayT = result
dbo.collection("live").find({}).sort("count", -1).toArray(function(err, result) {
if (err) throw err;
pillars = result
maxage = 1
pillars.forEach(element => {
age = date(element.first, element.last)
if (maxage < age) {
maxage = age
}
});
console.log(maxage);
res.render('pillers', { array, arrayT, pillars, total, maxage })
db.close();
});
});
});
});
});
var url = process.env.URI || "mongodb://root:Rlsss%405007@cluster0-shard-00-00.uj92c.mongodb.net:27017,cluster0-shard-00-01.uj92c.mongodb.net:27017,cluster0-shard-00-02.uj92c.mongodb.net:27017/myFirstDatabase?ssl=true&replicaSet=atlas-fb8wzy-shard-0&authSource=admin&retryWrites=true&w=majority"
MongoClient.connect(url, {
useNewUrlParser: true,
useUnifiedTopology: true
}, function(err, db) {
if (err) throw err;
db.close();
});
app.get('/stats', function(req, res) {
res.render('stats')
});
app.get('/battlefield', function(req, res) {
res.render('bfs')
});
app.get('/bf/:Name', function(req, res) {
var bfv = 0
var bf1 = 0
var bf4 = 0
var nobf = 0
var id = req.params.Name
const start = async function() {
let response4
response4 = await axios.get(
"https://api.gametools.network/bf4/stats/?name=" + id + "&lang=en-us", {}
).catch(error => {
bf4 = undefined
});
let response5
response5 = await axios.get(
"https://api.gametools.network/bfv/all/?name=" + id + "&lang=en-us", {}
).catch(error => {
bfv = undefined
});
if (response5.data.error) {
bfv = undefined
}
// if (response4.data.error) {
// bf4 = undefined
// }
let response1
response1 = await axios.get(
"https://api.gametools.network/bf1/all/?name=" + id + "&lang=en-us", {}
).catch(error => {
bf1 = undefined
});
if (response1.data.error) {
bf1 = undefined
}
if (bf1 != undefined)
bf1 = response1.data
if (bf4 != undefined)
bf4 = undefined
// bf4 = response4.data
if (bfv != undefined)
bfv = {...response5.data }
console.log(bf1);
console.log(bfv);
if (bf1 == undefined && bfv == undefined && bf4 == undefined) {
nobf = 'Buy a Game NOOB'
}
res.render('bf', { bfv, bf4, bf1, id, nobf })
}
start()
});
app.get('/apex/:Name', function(req, res) {
var url = "mongodb://root:Rlsss%405007@cluster0-shard-00-00.uj92c.mongodb.net:27017,cluster0-shard-00-01.uj92c.mongodb.net:27017,cluster0-shard-00-02.uj92c.mongodb.net:27017/myFirstDatabase?ssl=true&replicaSet=atlas-fb8wzy-shard-0&authSource=admin&retryWrites=true&w=majority"
const id = req.params.Name
apex.user(id, 'PC').then(data => {
global.ap = {...data.data }
var obj = {};
try {
function data() {
MongoClient.connect(url, { useNewUrlParser: true, useUnifiedTopology: true }, function(err, db) {
if (err) throw err;
var dbo = db.db("Names");
var myobj = { uname: id };
dbo.collection("Apex").updateOne({ uname: id }, { $set: { uname: id } }, { upsert: true })
});
}
ap.stats.forEach(element => {
Object.assign(obj, {
[element.metadata.name]: element.value
});
});
if (typeof ap != 'undefined') {
data()
res.render('apexold', { ap, obj });
} else {
res.render('refresh')
}
} catch (error) {
res.render('refresh')
}
});
});
app.get('/r6/:Name', function(req, res) {
var url = "mongodb://root:Rlsss%405007@cluster0-shard-00-00.uj92c.mongodb.net:27017,cluster0-shard-00-01.uj92c.mongodb.net:27017,cluster0-shard-00-02.uj92c.mongodb.net:27017/myFirstDatabase?ssl=true&replicaSet=atlas-fb8wzy-shard-0&authSource=admin&retryWrites=true&w=majority"
const un = req.params.Name
const username = req.params.Name
platform = 'uplay';
function data() {
MongoClient.connect(url, { useNewUrlParser: true, useUnifiedTopology: true },
function(err, db) {
if (err) throw err;
var dbo = db.db("Names");
dbo.collection("R6").updateOne({ uname: username }, { $set: { uname: username } }, { upsert: true })
});
}
const start = async function() {
var email = "kondashivaradhan007@gmail.com"
var pass = "Rlsss@5007"
const r6api = new R6API({ email: email, password: pass });
// try {
const id = await r6api.findByUsername(platform, username).then(el => el[0].userId);
const stats = await r6api.getStats(platform, id).then(el => el[0]);
const rank = await r6api.getRanks('uplay', id, { regions: ['apac'] });
ba = rank[0]
ra = rank[0].seasons[Object.keys(ba.seasons)].regions.apac
var obj = {}
var indu = stats.pvp.operators
// console.log(indu);
var dmax = 1;
var amax = 1;
if (typeof stats != 'undefined' && typeof ra != 'undefined') {
var dmax = 1;
var amax = 1;
Object.values(indu).forEach(element => {
if (dmax < element.kills && element.role == 'defender') {
dmax = element.kills
}
})
Object.values(indu).forEach(element => {
if (amax < element.kills && element.role == 'attacker') {
amax = element.kills
}
})
// data()
res.render('r6others', { indu, dmax, amax, ra, obj, stats, username });
} else {
res.render('refresh')
}
// } catch (error) {
// res.render('refresh')
// }
}
start()
});
app.get('/discord', function(req, res) {
res.render('discord')
});
app.get('/:User/:Legend', function(req, res) {
const id = req.params.User
const legend = req.params.Legend
apex.user(id, 'PC').then(data => {
adata = {...data.data }
if (typeof adata != 'undefined')
res.render('legends', { id, legend, adata })
else {
res.render('refresh')
}
});
});
app.get('/r6s', function(req, res) {
var url = "mongodb://root:Rlsss%405007@cluster0-shard-00-00.uj92c.mongodb.net:27017,cluster0-shard-00-01.uj92c.mongodb.net:27017,cluster0-shard-00-02.uj92c.mongodb.net:27017/myFirstDatabase?ssl=true&replicaSet=atlas-fb8wzy-shard-0&authSource=admin&retryWrites=true&w=majority"
function data() {
try {
MongoClient.connect(url, { useNewUrlParser: true, useUnifiedTopology: true }, function(err, db) {
if (err) throw err;
var dbo = db.db("Names");
dbo.collection("R6").find({}).toArray(function(err, result) {
if (err) throw err;
obj = result;
var an = [];
for (var o in obj) {
an.push(obj[o].uname);
}
db.close();
res.render('r6s', { an: an });
});
});
} catch (error) {
console.log(error);
}
}
data()
// res.render('r6s')
});
app.get('/apex', function(req, res) {
var url = "mongodb://root:Rlsss%405007@cluster0-shard-00-00.uj92c.mongodb.net:27017,cluster0-shard-00-01.uj92c.mongodb.net:27017,cluster0-shard-00-02.uj92c.mongodb.net:27017/myFirstDatabase?ssl=true&replicaSet=atlas-fb8wzy-shard-0&authSource=admin&retryWrites=true&w=majority"
function data() {
MongoClient.connect(url, { useNewUrlParser: true, useUnifiedTopology: true }, function(err, db) {
if (err) throw err;
var dbo = db.db("Names");
dbo.collection("Apex").find({}).toArray(function(err, result) {
if (err) throw err;
obj = result;
var an = [];
for (var o in obj) {
an.push(obj[o].uname);
}
db.close();
console.log(an);
res.render('apex', { an: an });
});
});
}
data()
});
app.get('/data',function(req,res){
var url = "mongodb://blazing:blazingbane@comments-shard-00-00.9fhsn.mongodb.net:27017,comments-shard-00-01.9fhsn.mongodb.net:27017,comments-shard-00-02.9fhsn.mongodb.net:27017/test?replicaSet=atlas-2rxnym-shard-0&ssl=true&authSource=admin"
MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("youtube");
dbo.collection("live").find({}).sort("count", -1).toArray(function(err, result) {
if (err) throw err;
pillars = result
maxage = 1
console.log(maxage);
res.json({pillars });
db.close();
});
});
})
app.listen(process.env.PORT || 5000)
console.log('====================================');
console.log('sever started at http://localhost:5000 for Blazing Bane mega website');