Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RigvedManoj committed Dec 18, 2017
0 parents commit 160db99
Show file tree
Hide file tree
Showing 25 changed files with 1,829 additions and 0 deletions.
158 changes: 158 additions & 0 deletions chat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php
session_start();
if(empty($_SESSION['username']))
{
header("Location:signup.php");
}
else {
$name=$_SESSION['username'];
}

if (isset($_GET['id']))
{
$frnd=$_GET['id'];
}
$_SESSION['name']=$frnd;
$frnds[0]="";
$text[0]="";
?>
<html>
<head>
<style>

#input
{
position: fixed;
bottom: 0px;
left:5%;
width: 50%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
#send
{
position: fixed;
bottom: 0px;
left:55%;
background:lightblue;
border-radius: 4px;
width: 8em;
height: 3em;
margin: 8px 0;
cursor: pointer;
}
#language
{
position: fixed;
bottom: 0px;
left:63%;
background:lightblue;
border-radius: 4px;
width: 8em;
height: 3em;
margin: 8px 0;
cursor: pointer;
}
h2
{
padding: 4px 450px;
display: inline-block;
position: relative;
text-align: center;
}
</style>
</head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href=decorate.css>
<body id="body">
<ul>
<h2><?php echo $frnd?></h2>
<li>
<a><?php echo $name?></a>
<ul class="dropdown">
<li><a href="signup.php">Log out</a></li>
<li><a href="homepage.php">Homepage</a></li>
<li><a href="find.php">Find Friends</a></li>
</ul>
</li>
</ul>
<input type="text" id="input"></input>
<button id="send" onclick="send()">send</button>
<select id="language" onclick="language()" >
<option id='ru'value='ru'>RUSSIAN</option>
<option id='en'value='en'>ENGLISH</option>
<option id='bg'value='bg'>BULGARIAN</option>
<option id='fr'value='fr'>FRENCH</option>
<option id='sq'value='sq'>ALBANIAN</option>
<option id='ar'value= 'ar'>ARABIC</option>
<option id='da'value='da'>DANISH</option></select>
<br>
<div id="response"></div>
<footer><br><br><br><br></footer>
</body>
</html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
var testing=[];
var frnd=<?php echo json_encode($frnd); ?>;
function start()
{
$.ajax({url: "retrieve.php?id="+frnd}).done(function(html){
testing=html;
console.log(testing[0]);
$("#response").html(html);
});;
listen();
}
start();
function listen()
{
window.scrollTo(0,document.body.scrollHeight);
var xhttp;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
start();
}
};
xhttp.open("GET", "server.php", true);
xhttp.send();
}
function send()
{
var x=document.createElement("DIV");

var name= <?php echo json_encode($name); ?>;
var text=document.getElementById('input').value;
document.getElementById('input').value="";
var xhttp;
xhttp = new XMLHttpRequest();
xhttp.open("GET", "store.php?id="+text, true);
xhttp.send();
}
</script>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("elements", "1", {
packages: "keyboard"
});
function onload()
{
var kbd = new google.elements.keyboard.Keyboard(
['ru'],['input']);
}
function language()
{
var code=document.getElementById("language").value;
var kbd = new google.elements.keyboard.Keyboard(
[code],['input']);
}

google.setOnLoadCallback(onload);

</script>
36 changes: 36 additions & 0 deletions check.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
$q = $_REQUEST["q"];
$servername = "localhost";
$username = "root";
$password = "AthlonY2";//enter mysql password
$dbname = "Platform";


$n=0;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT name FROM SIGNUP";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$name=$row["name"];
if($name==$q)
{
$n=1;
echo "taken";
break;
}
}
}
if($n==0)
{
echo "available";
}
$conn->close();
?>
18 changes: 18 additions & 0 deletions client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/*$host = "127.0.0.1";
$port = 25005;
$message = "Hello Server";
echo "Message To server :".$message;
// create socket
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
// connect to server
$result = socket_connect($socket, $host, $port) or die("Could not connect to server\n");
// send string to server
socket_write($socket, $message, strlen($message)) or die("Could not send data to server\n");
// get server response
$result = socket_read ($socket, 1024) or die("Could not read server response\n");
echo "Reply From Server :".$result;
// close socket
socket_close($socket);*/
?>
22 changes: 22 additions & 0 deletions database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
$servername = "localhost";
$username = "root";
$password = "AthlonY2";

// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

// Create database
$sql = "CREATE DATABASE Platform";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully";
} else {
echo "Error creating database: " . $conn->error;
}

$conn->close();
?>
42 changes: 42 additions & 0 deletions decorate.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ul{
padding: 0;
list-style: none;
background: #f2f2f2;
text-align: right;
}
ul li{
display: inline-block;
position: relative;
line-height: 21px;
text-align: left;
}
ul li a{
display: block;
padding: 8px 25px;
color: #333;
text-decoration: none;
}
ul li a:hover{
color: #fff;
background: #939393;
}

#a1:hover
{

background: #f2f2f2;
}
ul li ul.dropdown{
min-width: 125px; /* Set width of the dropdown */
background: #f2f2f2;
display: none;
position: absolute;
z-index: 999;
left: 0;
}
ul li:hover ul.dropdown{
display: block; /* Display the dropdown */
}
ul li ul.dropdown li{
display: block;
}
114 changes: 114 additions & 0 deletions find.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php
session_start();
if(empty($_SESSION['username']))
{
header("Location:signup.php");
}
else {
$name=$_SESSION['username'];
}
$servername = "localhost";
$username = "root";
$password = "AthlonY2";
$dbname = "Platform";
$i=0;
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT name FROM SIGNUP";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
if($row["name"]!=$name)
{ $frnd[$i]=$row["name"];
$i++;
}
}
}
?>
<html>
<head>
<style>
ol
{
list-style-type: circle;
}
li
{
cursor: pointer;
width: auto;
}
li:hover
{
color: #939393;
width: auto;
}
</style>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href=decorate.css>
<body id="body">
<ul>
<li>
<a><?php echo $name?></a>
<ul class="dropdown">
<li><a href="signup.php">Log out</a></li>
<li><a href="homepage.php">Homepage</a></li>
<li><a href="find.php">Find Friends</a></li>
</ul>
</li>
</ul>
<input autofocus type="search" onkeyup="search()" id="input"></input>
</body>
<script>
var frnd= <?php echo json_encode($frnd); ?>;
var a=document.createElement("OL");
a.setAttribute("id", "myOL");
document.body.appendChild(a);
var i=0;
for(i=0;i<frnd.length;i++)
{
var y = document.createElement("LI");
y.setAttribute("id",i);
var t1 = document.createTextNode(frnd[i]);
y.appendChild(t1);
document.getElementById("myOL").appendChild(y);
var f1 = document.getElementById(i);
f1.addEventListener("click",modify);

}

function modify(e)
{
var id=e.target.id;
var send=document.getElementById(id).innerHTML;
window.location.href = "chat.php?id="+send;
}

function search()
{
var z=document.getElementById("myOL");
document.body.removeChild(z);
var a=document.createElement("OL");
a.setAttribute("id", "myOL");
document.body.appendChild(a);
var search=document.getElementById('input').value;
i=0;
for(i=0;i<frnd.length;i++)
{
if(frnd[i].indexOf(search) !== -1)
{ var y = document.createElement("LI");
y.setAttribute("id",i);
var t1 = document.createTextNode(frnd[i]);
y.appendChild(t1);
document.getElementById("myOL").appendChild(y);
var f1 = document.getElementById(i);
f1.addEventListener("click",modify);
}
}
}
</script>
Loading

0 comments on commit 160db99

Please sign in to comment.