This repository was archived by the owner on Aug 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
90 lines (76 loc) · 2.3 KB
/
index.js
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
var http = require("http");
var express = require("express");
var fs = require('fs')
const PORT = 8080;
var app = express();
app.use("/css", express.static("css"));
app.use("/js", express.static("js"));
app.get("/", function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(fs.readFileSync('quizbug.html'));
});
app.get("/php/searchDatabase.php", function(req, res) {
function serialize(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
}
while (true) {
try {
console.log("http://quinterest.org/php/searchDatabase.php?" + serialize(req.query))
http.get("http://quinterest.org/php/searchDatabase.php?" + serialize(req.query), function(getres) {
var totData = '';
getres.on('data', function(chunk) {
totData += chunk;
});
getres.on('end', function() {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(totData);
});
});
break;
} catch(e) {
console.log(e);
}
}
});
app.get("/php/loadSubcategories.php", function(req, res) {
function serialize(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
}
console.log("http://quinterest.org/php/loadSubcategories.php?" + serialize(req.query))
http.get("http://quinterest.org/php/loadSubcategories.php?" + serialize(req.query), function(getres) {
var totData = '';
getres.on('data', function(chunk) {
totData += chunk;
});
getres.on('end', function() {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(totData);
});
});
});
app.get("/php/loadTournaments.php", function(req, res) {
function serialize(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
}
console.log("Get Request routed for: ", "http://quinterest.org/php/loadTournaments.php?" + serialize(req.query))
http.get("http://quinterest.org/php/loadTournaments.php?" + serialize(req.query), function(getres) {
var totData = '';
getres.on('data', function(chunk) {
totData += chunk;
});
getres.on('end', function() {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(totData);
});
});
});
app.listen(PORT)