Skip to content

Commit

Permalink
Terminado, falta testar e corrigir defeitos
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasrodrigues10 committed Sep 12, 2017
1 parent ee47210 commit 661b353
Show file tree
Hide file tree
Showing 28 changed files with 1,231 additions and 0 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Chat Legal - O novo chat da uol #
Site: http://chatlegal.site11.com/

<p align="center">
<img width="460" height="300" src="http://gigadicas.com/v2/wp-content/uploads/2016/02/ChatBubbles650.jpg">
</p>

# [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/Tiagoeem/embarcados-Diurno/tree/LucasRodrigues_14005565/awesome)

[![Github-Release](https://img.shields.io/github/release/filoe/cscore.svg)](https://github.com/Tiagoeem/embarcados-Diurno/tree/LucasRodrigues_14005565/releases)

## Descrição

Para a realização desse site, foi utilizado a magnifica técnica do [EXtreme Go Horse](http://sou.gohorseprocess.com.br/).

## Integrantes do Projeto
* **Lucas de Moura Rodrigues** - *14.00556-5*
* **Levon Tcholakian Chahestian** - *14.01587-0*
* **Raul Freitas Vaz** - *14.03065-9*

<p align="center">
<img width="460" height="300" src="https://cdn-images-1.medium.com/max/800/1*pAiFtxYHdjg4-HP6e46wZA.gif">
</p>


## Objetivos:

<strike>Conexão com o banco de dados: conn.php</strike><br>
<strike>Registro do usuário: signup.php e register.php</strike><br>
<strike>A senha deve ser inserida com proteção md5</strike><br>
<strike>Login do usuário: login.php</strike><br>
<strike>Adição de uma nova sala de bate-papo: add_chatroom.php</strike><br>
<strike>Deleção de uma nova sala de bate-papo: deleteroom.php</strike><br>
<strike>Adicionar membros à sala de bate-papo existente: addmember.php</strike><br>
<strike>Mostrar conversa e enviar mensagens: fetch_chat.php e send_message.php</strike><br>

## Defeitos:

Quando cria sala precisa sair e entrar para aparecer o nome e botoes<br>
Login valido nao aparece mensagem de sucesso<br>
Login invalido nao parece mensagem de erro<br>
Formatacao da mensagem no chat provavelmente não está igual ao do luiz <br>

## Sprints:

* ** 1º Começar o site**

* ** 2º Terminar o site **
Binary file added Trabalho em sala P3.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions conn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
//Variaveis para conexao com o banco de dados
$host = 'localhost';
$usuario = 'id2877653_root123';
$senha = '12345';
$database = 'id2877653_chatdb';

//Conexao com o banco de dados
$conn = new mysqli($host,$usuario,$senha,$database);

//Checa se tem erro
if($conn->connect_error){
die("Erro: " . $conn->connect_error);
}
?>
90 changes: 90 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php session_start();?>
<!DOCTYPE html>

<html>

<head>

<title>PHP Simple Chat System using AJAX</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<style>

#login_form{

width:350px;

height:350px;

position:relative;

top:50px;

margin: auto;

padding: auto;

}

</style>

</head>

<body>

<div class="container">

<div id="login_form" class="well">

<h2><center><span class="glyphicon glyphicon-lock"></span> Please Login</center></h2>

<hr>

<form method="POST" action="login.php">

Username: <input type="text" name="username" class="form-control" required>

<div style="height: 10px;"></div>

Password: <input type="password" name="password" class="form-control" required>

<div style="height: 10px;"></div>

<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-log-in"></span> Login</button> No account? <a href="signup.php"> Sign up</a>

</form>

<div style="height: 15px;"></div>

<div style="color: red; font-size: 15px;">

<center>

<?php
if(isset($_SESSION['msg'])){

echo $_SESSION['msg'];

unset($_SESSION['msg']);

}
include "conn.php";

?>

</center>

</div>

</div>

</div>

</body>

</html>
23 changes: 23 additions & 0 deletions login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
session_start();
include('conn.php');

$usuario = $_POST['username'];
$senha = $_POST['password'];

$senha = md5($senha);
$query = "SELECT * FROM user WHERE username = '$usuario' AND password = '$senha'";

$result = $conn->query($query);

if($result->num_rows > 0){
$row = $result->fetch_assoc();
$_SESSION["id"] = $row["userid"];
header('Location:user/index.php');
}else{
header('Location: user/erro.php');
}

$conn->close();

?>
51 changes: 51 additions & 0 deletions register.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
session_start();
include "conn.php";

$nome = $_POST['name'];
$usuario = $_POST['username'];
$senha = $_POST['password'];

$situacaoU = ""; //erro de usuario igual
$situacao = ""; //erros gerais

$query = "SELECT * FROM user WHERE username = '$usuario'";
$result = $conn->query($query);
$row = $result->fetch_assoc();
if($result->num_rows > 0){//se encontrar um usuario igual
$situacaoU = "Usuario já Registrado";
}

if($situacaoU === ""){//insere se nao tiver iguais
$senha = md5($senha);
$query = "INSERT INTO user (uname,password,username,access) VALUES ('$nome','$senha','$usuario',2);";
if($conn->query($query)){
$situacao = "Deu certo";
header("Location: index.php");
}else{
$situacao = "Deu errado ";
}
}

$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
</head>
<body>
<h1>Geral:<?=$situacao?></h1>
<h1>Usuario igual:<?=$situacaoU?></h1>

<!-- jQuery first, then Tether, then Bootstrap JS. -->
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</body>
</html>
41 changes: 41 additions & 0 deletions signup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<title>PHP Simple Chat System using AJAX</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
#signup_form{
width:350px;
height:430px;
position:relative;
top:50px;
margin: auto;
padding: auto;
}
</style>
</head>
<body>
<div class="container">
<div id="signup_form" class="well">
<h2><center><span class="glyphicon glyphicon-user"></span> Sign Up</center></h2>
<hr>
<form method="POST" action="register.php">
Name: <input type="text" name="name" class="form-control" required>
<div style="height: 10px;"></div>
Username: <input type="text" name="username" class="form-control" required>
<div style="height: 10px;"></div>
Password: <input type="password" name="password" class="form-control" required>
<div style="height: 10px;"></div>
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-save"></span> Sign Up</button> <a href="index.php"> Back to Login</a>
</form>
<div style="height: 15px;"></div>
<div style="color: red; font-size: 15px;">
<center>
</center>
</div>
</div>
</div>
</body>
</html>
23 changes: 23 additions & 0 deletions user/confirm_password.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
include('session.php');

$cid=$_POST['chatid'];
$pass=$_POST['chat_pass'];

$query=mysqli_query($conn,"select * from chatroom where chatroomid='$cid'");
$row=mysqli_fetch_array($query);

if ($row['chat_password']==$pass){
mysqli_query($conn,"insert into chat_member (chatroomid, userid) values ('$cid', '".$_SESSION['id']."')");
header('location: chatroom.php?id='.$cid);
}

else{
?>
<script>
window.alert('Incorrect Password!');
window.history.back();
</script>
<?php
}
?>
21 changes: 21 additions & 0 deletions user/deleteroom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

include('../conn.php');

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

session_start();
$del = 0;

$id = $_POST["id"];
$del = $_POST["del"];

if($del == 1){
$query = mysqli_query($conn,"DELETE FROM chatroom WHERE userid='$_SESSION[id]' and chatroomid= '$id'");
}

$conn->close();

?>
19 changes: 19 additions & 0 deletions user/erro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
</head>
<body>
<h1>Erro!</h1>
<!-- jQuery first, then Tether, then Bootstrap JS. -->
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions user/fetch_chat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
session_start();

include "../conn.php";
$idRoom = $_POST['id'];
$query = "SELECT * FROM chat WHERE chatroomid = '$idRoom'";
$result = $conn->query($query);
if($result->num_rows > 0){
while($row = $result->fetch_assoc()) {
$userid = $row["userid"];
$query = "SELECT * FROM user WHERE userid='$userid'";
$result2 = $conn->query($query);
$row2 = $result2->fetch_assoc();
echo $row["chat_date"]. " - " . $row2["uname"]. " - " . $row["message"]. "<br>";
}
}
?>
13 changes: 13 additions & 0 deletions user/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>

<title>PHP Simple Chat System using AJAX</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="../css/dataTables.bootstrap.css" rel="stylesheet">
<link href="../css/dataTables.responsive.css" rel="stylesheet">
</head>
Loading

0 comments on commit 661b353

Please sign in to comment.