-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
executable file
·121 lines (102 loc) · 4.44 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
session_start();
require("inc/config.inc.php");
function __autoload($class_name) {
include 'classes/'.strtolower($class_name) . '.class.php';
}
DBHandler::initDB();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="js/navi.js"></script>
<script src="js/page.js"></script>
<script src="js/search.js"></script>
<script type="text/javascript" src="js/chat.js"></script>
<link rel="stylesheet" href="css/main.css">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,700,300' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/main.css" type="text/css">
<link rel="shortcut icon" href="img/logo_favicon.png" type="image/png" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="icon" href="img/logo_favicon.png" type="image/png" />
<script src="js/notify.js"></script>
<?php
if(isset($_SESSION['username'])) {
echo '<script type="text/javascript">function WebSocketTest() {
var ws = new WebSocket("ws://ne4y-dev.de:9999");
ws.onopen = function() {
// Web Socket is connected, send data using send()
console.log("connected");
ws.send("ID:" + "'.base64_encode($_SESSION['user_id']).'");
console.log("Autoisierungskey gesendet");
};
ws.onmessage = function (msg) {
var received_msg = msg.data;
console.log("Message is received:" + msg.data);
split = msg.data.split("@");
console.log(msg);
var to = $("#chatID");
if(to && to.val() == split[4]){
appendMessage(split[1], $("#partnerName").val());
}
$.ajax({
url: "request.php?s=getID&id=" + split[2],
success: function (result) {
console.log(split[4])
notify("Sie haben eine neue Nachricht von " + result + " erhalten.", split[4])
}
});
};
ws.onclose = function() {
// websocket is closed.
console.log("connection closed");
};
}</script>';
}
?>
</head>
<body <?php echo (isset($_SESSION['username'])) ? 'onload="WebSocketTest()"' : ''?>>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="index.php?s=home" id="logo" >
<img alt="Brand" src="img/logo_klein.png"/>
</a>
<ul>
<li><a href="index.php?s=home">Suchen</a></li>
<li><a href="index.php?s=ask">Fragen</a></li>
<?php echo isset($_SESSION['username']) ? '<li><a href="index.php?s=profile">Profil</li><li><a href="index.php?s=chats">Chats</li><li><a href="index.php?s=logout">Logout</a></li>' : '<li><a href="index.php?s=login">Login</a></li> <li><a href="index.php?s=register">Registrieren</a></li>';?>
</ul>
</div>
</div>
</nav>
<section class="container">
<?php
if(isset($_GET['s']) && !empty($_GET['s'])) {
if(file_exists(realpath('./sites/')."/".$_GET['s'].".php")) {
include(realpath('./sites/')."/".$_GET['s'].".php");
}
else {
include(realpath('./sites/').'/404.php');
}
}
else {
include(realpath('./sites/home.php'));
}
?>
</section>
<div id="notification"></div>
<script type="text/javascript" src="js/login.js"></script>
<div id="notificationArea">
</div>
</body>
</html>