-
-
Save davidverhage/4a68a8bfde8af83883c7 to your computer and use it in GitHub Desktop.
php-chat
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
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title></title> | |
<meta http-equiv="refresh" content="2"> | |
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> | |
<style type="text/css"> | |
.chat-body { | |
margin-bottom: 10px; | |
padding-bottom: 5px; | |
border-bottom: 1px dotted #B3A9A9; | |
} | |
.text-muted span.glyphicon-time { | |
margin-right: 5px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container-fluid"> | |
<?php echo file_get_contents('text'); ?> | |
</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
<?php session_start(); ?> | |
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title>Chat Challenge</title> | |
<link rel="icon" type="image/x-icon" href="/favicon.ico"/> | |
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> | |
<style type="text/css"> | |
.container { | |
width: 600px; | |
} | |
.chat-messages { | |
margin-top: 20px; | |
height: 600px; | |
} | |
.chat-form { | |
height: 180px; | |
} | |
iframe { | |
width: 100%; | |
height: 100%; | |
border: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row chat-messages"> | |
<iframe class="messages" src="chat.php"></iframe> | |
</div> | |
<div class="row chat-form"> | |
<form role="form" action="save.php"> | |
<div class="form-group"> | |
<input type="text" class="form-control" name="name" placeholder="Ваше имя" | |
value="<?php echo $_SESSION['name']; ?>"> | |
</div> | |
<div class="input-group"> | |
<input type="text" class="form-control" name="text" placeholder="Сообщение"> | |
<span class="input-group-btn"> | |
<input type="submit" class="btn btn-default" id="btn-chat" value="Послать"/> | |
</span> | |
</div> | |
</form> | |
</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
<?php | |
session_start(); | |
if($_REQUEST['name'] && $_REQUEST['text']) { | |
$name = strip_tags($_REQUEST['name']); | |
$text = strip_tags($_REQUEST['text']); | |
ob_start(); | |
include('template.php'); | |
$out = ob_get_clean(); | |
file_put_contents('text', $out, FILE_APPEND); | |
$_SESSION['name'] = $name; | |
} | |
header('Location: '.$_SERVER['HTTP_REFERER']); |
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
<div class="chat-body clearfix"> | |
<div class="header"> | |
<small class=" text-muted"><span class="glyphicon glyphicon-time"></span><?php echo date('d.m.Y H:i:s') ?></small> | |
<strong class="pull-right primary-font"><?php echo $name; ?></strong> | |
</div> | |
<p> | |
<?php echo $text; ?> | |
</p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment