-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
718 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
// database information | ||
$DB_USER="root"; | ||
$DB_PASSWORD=""; | ||
$DB_HOST="localhost"; | ||
$DB_DATABASE="AnonChat"; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
// database information | ||
$DB_USER="root"; | ||
$DB_PASSWORD=""; | ||
$DB_HOST="localhost"; | ||
$DB_DATABASE="AnonChat"; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8"> | ||
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="style.css"/> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | ||
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> | ||
<script> | ||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | ||
|
||
ga('create', 'UA-71929754-1', 'auto'); | ||
ga('send', 'pageview'); | ||
|
||
</script> | ||
<title>Safe Chat: Login</title> | ||
</head> | ||
<body class="b1"> | ||
<div class="container top30 "> | ||
<table class="table-responsive col-sm-6 text-center center t1"> | ||
<tr> | ||
<td class="text-centered"> | ||
<div class="row col-center top15"><h1><span class="h1 label label-default">Safe Chat</span></h1></div> | ||
|
||
<form action="joinChat.php" id="form" method="post"> | ||
<div class="row form-group top50"> | ||
<div class="col-sm-4 text-right"><span style="font-size: 16px" class="label label-primary">Name:</span></div> | ||
<div class="col-sm-4"><input class="form-control pull-left" type="text" id="name" name="name" maxlength="12" autocomplete="off" required></div> | ||
</div> | ||
<div class="row form-group top10"> | ||
<div class="col-sm-4 text-right"><span style="font-size: 16px" class="label label-primary">Chatroom:</span></div> | ||
<div class="col-sm-4"><input class="form-control pull-left" type="text" id="chat" name="chat" maxlength="12" autocomplete="off" onkeydown="if (event.keyCode == 13) document.getElementById('button').click()" required></div> | ||
</div> | ||
<div class="row top15"><input class="btn btn-default btn-md" id="button" type="submit" value="Enter"></div> | ||
</form> | ||
<div class="row top15"></div> | ||
<div class="row top15"></div> | ||
<div class="row top15"></div> | ||
<div class="row top15"></div> | ||
<div class="row top15"></div> | ||
|
||
<div class="row top100" style="text-align: center;"> | ||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-question-sign"></span></button> | ||
</div> | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
|
||
|
||
<div id="footer" class="mastfoot" style="text-align: center;" > | ||
<div class="inner"> | ||
<br> | ||
Site created and maintained by <a href="mailto:[email protected]" style="color: #fff">Cole</a>. | ||
<br> | ||
</b><em>Copyright © 2015 · All rights reserved.</em> | ||
</div> | ||
</div> | ||
|
||
<!-- Modal --> | ||
<div class="modal fade" id="myModal" role="dialog"> | ||
<div class="modal-dialog modal-lg"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal">×</button> | ||
<h4 class="modal-title" style="align-text: center;">Welcome to Safe Chat!</h4> | ||
</div> | ||
<div class="modal-body"> | ||
<h2>About:</h2> | ||
<p>Safe Chat is chatting application designed for maximum security. At any given instance only 20 | ||
messages per chat are saved in the database. When another message is sent the 21st message is | ||
deleted. Users also have the option to wipe the contents of any chat completely. This can be | ||
accomplished by clicking the "trash" button located at the top left of the chat page. Chatroom | ||
names must be shared outside of this application, thus adding another level of security. | ||
</p> | ||
<h2>Use:</h2> | ||
<p> | ||
On the login page you may enter the chatroom you wish to enter and the name you wish to | ||
possess within the chat. If the chatroom you wish to enter has already been created then you will | ||
be directed to that chat with any previously saved messages rendered. Otherwise a brand new empty | ||
chat will be created. Upon arrival to the chatroom, messages can be sent by typing in the textarea | ||
and pressing enter or hitting the "send" button. Message number, timestamp, and the sender are | ||
displayed for each message. The "trash" button at the top left of the screen can be used to erase | ||
all messages within a given chat. Refreshes will redirect you back to the login page. | ||
</p> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
session_start(); | ||
|
||
//database info | ||
require_once('dbconfig.php'); | ||
$con = mysqli_connect($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_DATABASE); | ||
|
||
$name = mysqli_escape_string($con, $_POST["name"]); | ||
$chat = mysqli_escape_string($con, $_POST["chat"]); | ||
|
||
$_SESSION["chat"] = $chat; | ||
$_SESSION["name"] = $name; | ||
|
||
|
||
if(!mysql_num_rows(mysqli_query("SHOW TABLES LIKE '".`$chat`."'"))==1){ | ||
//table doesn't exits | ||
mysqli_query($con,"CREATE TABLE `$chat` ( | ||
`name` text NOT NULL, | ||
`message` text NOT NULL, | ||
`time` text NOT NULL, | ||
`m_num` int )"); | ||
} | ||
|
||
//close db conection | ||
mysqli_close($con); | ||
header("Refresh:0; url=chat.php");sudo | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
.top5 { margin-top:5px; } | ||
.top7 { margin-top:7px; } | ||
.top10 { margin-top:10px; } | ||
.top15 { margin-top:15px; } | ||
.top17 { margin-top:17px; } | ||
.top30 { margin-top:30px; } | ||
.top50 { margin-top:50px; } | ||
.top100 { margin-top:100px; } | ||
.center { | ||
float: none; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
.h1 { | ||
font-size: 40px; | ||
} | ||
|
||
.h2 { | ||
font-size: 30px; | ||
} | ||
|
||
.b1{ | ||
background-color: black; | ||
} | ||
|
||
.b2{ | ||
background-color: lightslategrey; | ||
} | ||
|
||
.t1{ | ||
border: 2px solid white; | ||
height: 600px; | ||
} | ||
|
||
table{ | ||
border-collapse: collapse; | ||
align: left; | ||
height: 500px; | ||
line-height: 20px; | ||
padding: 2px; | ||
|
||
} | ||
th{ | ||
border-collapse: collapse; | ||
align: left; | ||
} | ||
|
||
td { | ||
border-collapse: collapse; | ||
align: left; | ||
height: 20px; | ||
font-family: Ubuntu; | ||
color: white; | ||
background-color: black; | ||
} | ||
th, td { | ||
padding: 2px; | ||
} | ||
|
||
#footer { | ||
bottom:0; | ||
width:100%; | ||
height:60px; /* Height of the footer */ | ||
} | ||
html,body | ||
{ | ||
width: 100%; | ||
height: 100%; | ||
margin: 0px; | ||
padding: 0px; | ||
overflow-x: hidden; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
session_start(); | ||
|
||
//database info | ||
require_once('dbconfig.php'); | ||
$con = mysqli_connect($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_DATABASE); | ||
|
||
$name = $_SESSION["name"]; | ||
$chat = $_SESSION["chat"]; | ||
|
||
$data = []; | ||
$iter = 1; | ||
|
||
$result = mysqli_query($con, "select * from `$chat` order by `m_num` asc"); | ||
while($row = mysqli_fetch_array($result)){ | ||
$data[$iter] = $row; | ||
$iter++; | ||
} | ||
|
||
mysqli_close($con); | ||
|
||
$data["current_user"] = $name; | ||
|
||
if(mysqli_num_rows($result) == 0){ | ||
$data["empty"] = "true"; | ||
} | ||
else{ | ||
$data["empty"] = "false"; | ||
} | ||
|
||
echo json_encode($data); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
session_start(); | ||
|
||
//database info | ||
require_once('dbconfig.php'); | ||
$con = mysqli_connect($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_DATABASE); | ||
|
||
$name = $_SESSION["name"]; | ||
$chat = $_SESSION["chat"]; | ||
$message = mysqli_escape_string($con, $_POST["message"]); | ||
|
||
$messageNum = mysqli_num_rows(mysqli_query($con, "select * from `$chat`")); | ||
|
||
$time = date("h:i:sa"); | ||
$mydate=getdate(date("U")); | ||
$date = $mydate[mon] . "/" . $mydate[mday] . "/" . $mydate[year]; | ||
$timestamp = $date . " @ " . $time; | ||
|
||
mysqli_query($con,"update `$chat` set m_num = m_num + 1"); | ||
mysqli_query($con, "insert into `$chat` (name, message, time, m_num) values ('$name','$message','$timestamp','1')"); | ||
|
||
if($messageNum == 20){ | ||
mysqli_query($con, "delete from `$chat` where `m_num` = '21'"); | ||
} | ||
|
||
$data = []; | ||
$iter = 1; | ||
|
||
$result = mysqli_query($con, "select * from `$chat` order by `m_num` asc"); | ||
while($row = mysqli_fetch_array($result)){ | ||
$data[$iter] = $row; | ||
$iter++; | ||
} | ||
|
||
mysqli_close($con); | ||
|
||
$data["current_user"] = $name; | ||
echo json_encode($data); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
session_start(); | ||
|
||
//database info | ||
require_once('dbconfig.php'); | ||
$con = mysqli_connect($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_DATABASE); | ||
|
||
$chat = $_SESSION["chat"]; | ||
|
||
mysqli_query($con, "delete from `$chat`"); | ||
mysqli_close($con); | ||
?> |