Skip to content

Commit be21a80

Browse files
committed
first undocumented and uncompleted commit
0 parents  commit be21a80

File tree

2,387 files changed

+351271
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,387 files changed

+351271
-0
lines changed

404.html

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!DOCTYYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="description" content="NIT Delhi, 404 ERROR, PAGE NOT FOUND">
6+
<meta name="keywords" content="NIT Delhi, 404 ERROR, PAGE NOT FOUND">
7+
<meta name="author" content="Sarang Kartikey">
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9+
<link href="https://fonts.googleapis.com/css?family=Raleway:200" rel="stylesheet">
10+
<link rel="icon" href="404.png">
11+
<title>PAGE NOT FOUND</title>
12+
<style>
13+
body{
14+
font-family: 'Raleway', sans-serif;
15+
}
16+
.container{
17+
width: 70%;
18+
display: block;
19+
margin: 0 auto;
20+
}
21+
22+
.image-wrap{
23+
display: block;
24+
margin: 25% auto 0em auto;
25+
height: 150px;
26+
width: 150px;
27+
}
28+
29+
.header-wrap{
30+
text-align: center;
31+
}
32+
33+
.header-wrap h1{
34+
font-weight: 100;
35+
color: #B00000;
36+
margin: 5px;
37+
}
38+
39+
</style>
40+
</head>
41+
<body>
42+
<div class="container">
43+
<div>
44+
<img class="image-wrap" src="404.png" />
45+
</div>
46+
<div class="header-wrap">
47+
<h1>PAGE NOT FOUND</h1>
48+
</div>
49+
</div>
50+
</body>
51+
</html>

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
This is a network access firewall for Unix-like operating systems
2+
using Squid Proxy server , Clamav Antivirus , C-ICAP server , DHCP
3+
server , Iptables firewall , Linux utilities , nodejs , layer 7 filtering
4+
( iptables) , Python , mongodb , Html and Css with all the functionality
5+
like user management , access groups , port forwrding ( routing ) ,
6+
Captive Portal , Http filtering , port blocking etc with centralized
7+
database .
8+
9+
10+
Full and clear documentation is avialable in

admin/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# softChat
2+
A simple centralised chat server with dataBase connection and without socket.io
3+
4+
A chatServer made upof MEAN stack.
5+
6+
MongoDB for DataBase , Nodejs for Server platform , Express as a Web Server and Angular for front-end.
7+
8+
This app has not much dependencies except basic ones like connect-mongo,mongoose,cryptojs etc.
9+
10+
All client polls the server every second to check for any UPDATE.

admin/auth_server.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var express = require('express');
2+
var session = require('express-session');
3+
var mongoStore = require('connect-mongo')(session);
4+
var mongoose = require('mongoose');
5+
var bodyParser = require('body-parser');
6+
var cookieParser = require('cookie-parser');
7+
8+
var app = express();
9+
10+
app.use(cookieParser());
11+
12+
var admins = require('../db').admins;
13+
14+
mongoose.connect('mongodb://localhost/auth');
15+
app.use(express.static('static'));
16+
17+
app.use(bodyParser.urlencoded({ extended: false }));
18+
19+
app.engine('.html',require('ejs').__express);
20+
app.set('views',__dirname + '/views');
21+
app.set('view engine','html');
22+
23+
app.use(session({
24+
secret:'SECRET',
25+
resave: false,
26+
saveUninitialized: true,
27+
store:new mongoStore({
28+
mongooseConnection:mongoose.createConnection('mongodb://localhost/auth'),
29+
collection: 'session' })
30+
}));
31+
32+
require('./routes.js')(app);
33+
34+
app.listen(process.env.PORT || 8080);

admin/controllers/chat_controller.js

+202
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
/**
2+
* Created by chiraj on 7/20/16.
3+
*/
4+
var mongoose = require('mongoose');
5+
6+
var friend = require('./friend_controller');
7+
8+
var User = mongoose.model('userCollection');
9+
10+
var Message = mongoose.model('chatCollection');
11+
12+
var Count = mongoose.model('countCollection');
13+
14+
exports.allChats = function (req,res) {
15+
if(req.session.name){
16+
User.findOne({username:req.params.friendname})
17+
.exec(function (err,doc) {
18+
if(err || !doc)
19+
console.log('Error in finding friend name in database ' + err);
20+
21+
else{
22+
var obj = {
23+
user:{}
24+
};
25+
obj.user.username = doc.username;
26+
obj.user.country = doc.country;
27+
obj.user.email = doc.email;
28+
obj.user.status = doc.status;
29+
obj.user.chats = [];
30+
31+
Message.findOne({chatters:{$all:[req.session.name,req.params.friendname]}}).exec(function (err,doc) {
32+
if(err)
33+
console.log('Error while finding a user \'s chat database ');
34+
35+
else if(!doc) {
36+
37+
// 1 console.log(doc);
38+
39+
//2 console.log('Creating chat DataBase for ' + req.session.name + ' and ' + req.params.friendname);
40+
41+
var chatdoc = new Message({
42+
chatters:[req.session.name,req.params.friendname],
43+
chats:[],
44+
total:0,
45+
firstMsgRead:0,
46+
secondMsgRead:0
47+
});
48+
49+
chatdoc.save(function (err,saved) {
50+
51+
if(err)
52+
console.log('Error while saving in chat database ' + err );
53+
54+
else {
55+
//3 console.log('Doc saved to chat database ' + saved);
56+
57+
obj.user.chats = saved.chats;
58+
59+
obj.user.msgNum = 0;
60+
61+
res.cookie('totalChats',0);
62+
63+
res.json(JSON.stringify(obj));
64+
}
65+
66+
});
67+
68+
}
69+
70+
else{
71+
72+
//4 console.log('Chat DataBase for ' + req.session.name + ' and ' + req.params.friendname + 'Already exists');
73+
res.cookie('totalChats',doc.total);
74+
75+
if(doc.chatters.indexOf(req.session.name) === 0 )
76+
doc.set('firstMsgRead',doc.total);
77+
78+
else
79+
doc.set('secondMsgRead',doc.total);
80+
81+
82+
doc.save(function (err) {
83+
84+
if(err)
85+
console.log('Error saving msgRead in database for ' + req.session.name);
86+
87+
else {
88+
//5 console.log('Updated msgRead for the user ' + req.session.name);
89+
90+
friend.chatupdatecount(); // after checking on all the messages clear that message
91+
}
92+
93+
});
94+
95+
for(var i in doc.chats){
96+
obj.user.chats.push({num:doc.chats[i].num,
97+
msg:doc.chats[i].msg });
98+
99+
}
100+
101+
if(doc.chatters[0] === req.session.name)
102+
obj.user.msgNum = 0;
103+
104+
else
105+
obj.user.msgNum = 1;
106+
107+
res.json(JSON.stringify(obj));
108+
}
109+
});
110+
}
111+
112+
});
113+
}
114+
else{
115+
req.session.msg = 'Login Please';
116+
res.redirect('/login');
117+
}
118+
};
119+
120+
121+
module.exports.msgCollect = function (req,res) {
122+
123+
if(req.session.name) {
124+
125+
if (req.body.message == '') {
126+
res.send('not a proper message');
127+
}
128+
129+
else {
130+
Message.findOne({chatters: {$all: [req.session.name, req.params.sendingTo]}}).exec(function (err, doc) {
131+
132+
if (err || !doc) {
133+
134+
console.log('Error finding chat database ' + err);
135+
136+
req.session.msg = ' Person you are trying to contact can\'t be find in database . ';
137+
res.send('reload');
138+
}
139+
140+
else {
141+
142+
var sessionUser = 1;
143+
if (doc.chatters[0] === req.session.name) {
144+
sessionUser = 0;
145+
}
146+
147+
148+
if (doc.chatters.indexOf(req.session.name) === 0) // updating msgread of the user who writes the current message
149+
doc.update({
150+
$push: {chats: {msg: req.body.message, num: sessionUser}},
151+
$inc: {total: 1, firstMsgRead: 1}
152+
})
153+
.exec(function (err, saved) {
154+
155+
if (err)
156+
console.log('Error Saving message in chats array ' + err);
157+
158+
else {
159+
160+
//6 console.log('Message Saved');
161+
162+
friend.chatupdatecount();
163+
164+
res.send('saved');
165+
166+
}
167+
168+
});
169+
170+
else
171+
doc.update({
172+
$push: {chats: {msg: req.body.message, num: sessionUser}},
173+
$inc: {total: 1, secondMsgRead: 1}
174+
})
175+
.exec(function (err, saved) {
176+
177+
if (err)
178+
console.log('Error Saving message in chats array ' + err);
179+
180+
else {
181+
182+
//7 console.log('Message Saved');
183+
184+
friend.chatupdatecount();
185+
186+
res.send('saved');
187+
188+
}
189+
190+
});
191+
192+
}
193+
194+
});
195+
}
196+
}
197+
198+
else { req.session.msg = 'Login Please ';
199+
res.redirect('/login');
200+
201+
}
202+
};

0 commit comments

Comments
 (0)