php-chatbox-met-ajax

Gesponsorde koppelingen

PHP script bestanden

  1. php-chatbox-met-ajax

« Lees de omschrijving en reacties

Je kunt het hier downloaden.
Hier zijn de smilies apart te downloaden.

PHPhulp mirror:
PHP chat codes
PHP chat smilies

de databases:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
CREATE TABLE `chat` (
  `id` int(11) NOT NULL auto_increment,
  `nick` varchar(50) NOT NULL,
  `bericht` text NOT NULL,
  `time` char(30) NOT NULL,
  `code` varchar(50) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
CREATE TABLE `contact` (
  `id` int(11) NOT NULL auto_increment,
  `id1` varchar(11) NOT NULL,
  `id2` varchar(11) NOT NULL,
  `acc` varchar(3) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
CREATE TABLE `gesprek` (
  `id` int(11) NOT NULL auto_increment,
  `id1` varchar(50) NOT NULL,
  `id2` varchar(50) NOT NULL,
  `time` char(30) NOT NULL,
  `status` varchar(50) NOT NULL,
  `code` varchar(50) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
CREATE TABLE `login` (
  `id` int(11) NOT NULL auto_increment,
  `naam` varchar(50) NOT NULL,
  `ww` varchar(50) NOT NULL,
  `rank` varchar(50) NOT NULL default 'member',
  `lastlogin` char(30) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;


index.php:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
session_start();
if($_SESSION['naam']) {
$melding = '<script language="javascript">
alert("Je bent al ingelogd.");
window.open("loggedin/index.php","_self");
</script>'
;
}
else{
include "config.php";

if($_POST['login']) {
if($_POST['naam']) {
if($_POST['ww']) {

$ip_query = mysql_query("SELECT * FROM login WHERE naam = '" .$_POST['naam']. "'");
$check = mysql_num_rows($ip_query);
if($check == "0"){

$melding = '<script language="javascript">
alert("Je naam of wachtwoord klopt niet");
window.open("index.php","_self");
</script>'
;

}
else{

$query = mysql_query("SELECT * FROM login WHERE naam='" .$_POST['naam']. "' ") or die (mysql_error());
while ($obj = mysql_fetch_object($query)) {
   $id = htmlspecialchars($obj->id);
   $naam = htmlspecialchars($obj->naam);
   $ww1 = htmlspecialchars($obj->ww);
   $rank = htmlspecialchars($obj->rank);
   $ww = md5($_POST['ww']);
   if($_POST['naam'] == $naam) {
   if($ww1 == $ww) {
  
   $onlinetijd = "10";  // 10 seconden

// als je $onlinetijd veranderd, moet je ook de "5 minuten" veranderen naar $onlinetijd/60 !!!!    


    
$sql3 =  "SELECT * FROM login WHERE id = '".$id."'";
$res3 = mysql_query($sql3);
    while($row3 = mysql_fetch_array($res3)){
if($row3['lastlogin'] + $onlinetijd > time()){
$melding = '<script language="javascript">
alert("Je bent al ingelogd");
window.open("index.php","_self");
</script>'
;
}
else{

   $melding = '<script language="javascript">
alert("Je bent ingelogd");
window.open("loggedin/index.php","_self");
</script>'
;
   $_SESSION['naam'] = $naam;
   $_SESSION['rank'] = $rank;
   $_SESSION['userid'] = $id;
   }
   }
   }
else{//ww's zijn verkeerd #1
   $melding = '<script language="javascript">
alert("Je naam of wachtwoord klopt niet");
window.open("index.php","_self");
</script>'
;
   }
//#1 sluiten
   }else{//naam klopt niet #2
   $melding = '<script language="javascript">
alert("Je naam of wachtwoord klopt niet");
window.open("index.php","_self");
</script>'
;
   }
//#2 sluiten
   }//while sluiten
   }//else van ip_query sluiten
   }else{//geen ww? #3
   $melding = '<script language="javascript">
alert("Je moet wel een wachtwoord intypen");
window.open("index.php","_self");
</script>'
;
   }
//#3 sluiten
   }else{//geen naam? #4
   $melding = '<script language="javascript">
alert("Je moet wel een naam intypen");
window.open("index.php","_self");
</script>'
;
   }
//#4 afsluiten
   }//post login afsluiten
   }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MesChat</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script language="javascript">
function loading(){
    var getObj = document.getElementById('loginfield');
    getObj.innerHTML = '<form id="form1" name="form1" method="post" action="index.php"><label for="textfield">Naam</label><input type="text" name="naam" id="naam" /><br /><label for="label">Wachwoord</label><input type="password" name="ww" id="label" /><br /><label for="Submit"></label><input type="submit" name="login" value="Login" id="login" /></form><a href="register.php">Registreer</a><br />';
}
</script>
</head>

<body onload="loading();">
<div align="center">
<?php
if($melding) {
echo $melding;
}
else{
?>

<div id="loginfield">
Je hebt javascript niet aanstaan!
</div>
<?php
}
?>

</div>
</body>
</html>

register.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
session_start();

include "config.php";

if($_POST['register']) {
if($_POST['naam']) {
if($_POST['ww1']) {
if($_POST['ww2']) {
if($_POST['ww2'] == $_POST['ww1']) {

$check_query = mysql_query("SELECT * FROM login WHERE naam = '" .$_POST['naam']. "'");
$check = mysql_num_rows($check_query);
if($check == "0"){
$ww = md5($_POST['ww1']);

mysql_query("INSERT INTO login (naam, ww)  
    VALUES ('"
.$_POST['naam']."', '".$ww."')") or die(mysql_error());
    $melding = "Je bent geregistreerd en kunt <a href='index.php'>hier</a> inloggen";
}
else{//#1 naam bestaat al
$melding = "De door jou gekozen naam is al geregistreerd";
}
//#1 afsluiten
}else{//#2 ww's niet het zelfde
$melding = "De door jou gekozen wachtwoorden zijn niet het zelfde";
}
//#2 afsluiten
}else{//#3 wachtwoord 2 niet ingevuld
$melding = "Je moet wel een wachtwoord invullen";
}
//#3 afsluiten
}else{//#4 ww 1 niet ingevuld
$melding = "Je moet wel een wachtwoord invullen";
}
//#4 afsluiten
}else{//#5 geen naam
$melding = "Je moet wel een naam invullen";
}
//#5 afsluiten
}//post register afsluiten
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>MesChat</title>
</head>

<body>
<div align="center">
<?php
if($_SESSION['naam']) {
echo "Je bent ingelogd als ".$_SESSION['naam'];
}
else{
if($melding) {
echo $melding;
}
else{
?>

<form id="form1" name="form1" method="post" action="register.php">
  <label for="textfield">Naam</label>
  <input name="naam" type="text" id="naam" maxlength="50" />
  <br />
  <label for="label">Wachtwoord</label>
  <input type="password" name="ww2" id="label" />
  <br />
  <label for="label2">Wachtwoord</label>
  <input name="ww1" type="password" id="label2" value="" />  
  <br />
  <label for="Submit"></label>
  <input type="submit" name="register" value="Registreer" id="register" />
</form>
<?php
}
}

?>

</div>
</body>
</html>

logout.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
session_start();
session_destroy();
include"config.php";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MesChat</title>
</head>

<body>
<div align="center">
<script language="javascript">
alert("Je bent uitgelogd.");
window.open("index.php","_self");
</script>
</div>
</body>
</html>

config.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php

//Instellingen van de MySQL en database
$dbhost = 'localhost';  //Naam van je server  
$dbname = '***';    //Naam van je database
$dbuser = '***';     //Naam van de gebruiker
$dbpassword = '***';     //Wachtwoord gebruiker

//Verbinding maken met de database

$db = mysql_connect("$dbhost", "$dbuser", "$dbpassword")
or die ("Verbinding mislukt");
mysql_select_db("$dbname", $db);

$datum=date("j M Y"); //datum bepalen, type: 01 Sep 2004
//Sleutels en Waarden voor de vervanging bepalen in een array

$maand['Jan']="januari";  //engelse maand met hoofdletter, nederlandse niet
$maand['Feb']="februari";
$maand['Mar']="maart";
$maand['Apr']="april";
$maand['May']="mei";
$maand['Jun']="juni";
$maand['Jul']="juli";
$maand['Aug']="augustus";
$maand['Sep']="september";
$maand['Oct']="oktober";
$maand['Nov']="november";
$maand['Dec']="december";

foreach($maand as $k=>$v){
    $datum=str_replace($k, $v, $datum);
  };
  function
code() {
$tekens = 'AbCDeFgHiJklmNoPQrStUvWXyZ1234567890';
$code = '';
for ($i=0; $i<6; $i++)
{

    $code .= $tekens {rand (0, strlen ($tekens) - 1)};
}

$rand = rand(1,4);
if($rand == 1) {
$code = sha1(md5(sha1(md5($code))));
}
elseif($rand == 2) {
$code = md5(sha1(md5(sha1($code))));
}
elseif($rand == 3) {
$code = md5(md5(sha1(sha1($code))));
}
elseif($rand == 4) {
$code = sha1(sha1(md5(md5($code))));
}

return $code;
}

?>

style.css
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
/* CSS Document */
input, textarea, select {
    background-color:#FFFFFF;
    border:1px solid #000000;
    font-family:Verdana;
    font-size:9pt;
    font-weight: bold;
    color:#000000;
    text-decoration:none;
}
body,td,th {
    font-family: Verdana;
}
a:link {
    color: #0000FF;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #0000FF;
}
a:hover {
    text-decoration: underline;
    color: #00FF00;
}
a:active {
    text-decoration: none;
    color: #FF0000;
}

loggedin/index.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
session_start();
if(!$_SESSION['time']) {
$_SESSION['time'] = time();
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MesChat</title>
<link rel="stylesheet" type="text/css" href="../style.css" />
<style type="text/css">
#chatmenu{
width:730px;
height:25px;
position:absolute;
right:5px;
top:5px;
}
#chatwindow{
width:730px;
height:500px;
position:absolute;
right:0px;
top:30px;
}
#online{
width:200px;
height:500px;
position:absolute;
left:5px;
top:5px;
}
#header {
font-size:22px;
}
</style>
<script type="text/javascript">
<!--
function loadchat(code){
    var getObj = document.getElementById('chatwindow');
    getObj.innerHTML = '<object id="chatbox" type="text/html" width="730" height="500" data="chatbox.php?code='+code+'"></object>';
}
function loadtoevoeg(){
    var getObj = document.getElementById('chatwindow');
    getObj.innerHTML = '<object id="chatbox" type="text/html" width="730" height="500" data="toevoegen.php"></object>';
}
<?php
if($_SESSION['rank'] == 'admin') {
echo '
function loadadmin(){
    var getObj = document.getElementById(\'chatwindow\');
    getObj.innerHTML = \'<object id="chatbox" type="text/html" width="730" height="500" data="admin_online.php"></object>\';
}
'
;
}

?>

var xmlHttp1

function contactacc(res, id)
{
xmlHttp1=GetXmlHttpObject()
if (xmlHttp1==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url1="contactacc.php?res="+res+"&id="+id;
xmlHttp1.onreadystatechange=stateChanged1;
xmlHttp1.open("GET",url1,true);
xmlHttp1.send(null);
}

function stateChanged1()
{
if (xmlHttp1.readyState==4)
{
document.getElementById("contactacc").innerHTML=xmlHttp1.responseText;
online();
}
}
var xmlHttp

function online()
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="online.php";
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("onlinecontact").innerHTML=xmlHttp.responseText;
}
}

var xmlHttp2

function chatmenu()
{
xmlHttp2=GetXmlHttpObject()
if (xmlHttp2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url2="gesprekmenu.php";
xmlHttp2.onreadystatechange=stateChanged2;
xmlHttp2.open("GET",url2,true);
xmlHttp2.send(null);
}

function stateChanged2()
{
if (xmlHttp2.readyState==4)
{
document.getElementById("chatmenu").innerHTML=xmlHttp2.responseText;
}
}

var xmlHttp3

function closechat(code)
{
xmlHttp3=GetXmlHttpObject()
if (xmlHttp3==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url3="closechat.php?code="+code;
xmlHttp3.onreadystatechange=stateChanged3;
xmlHttp3.open("GET",url3,true);
xmlHttp3.send(null);
}

function stateChanged3()
{
if (xmlHttp3.readyState==4)
{
chatmenu();
loadchat('full');
}
}

var xmlHttp4

function newchat(id)
{
xmlHttp4=GetXmlHttpObject()
if (xmlHttp4==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url4="newchat.php?id="+id;
xmlHttp4.onreadystatechange=stateChanged4;
xmlHttp4.open("GET",url4,true);
xmlHttp4.send(null);
}

function stateChanged4()
{
if (xmlHttp4.readyState==4)
{
chatmenu();
}
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

setInterval(online, 9000);
setInterval(chatmenu, 5000);
//-->
</script>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body onload="loadchat('full');">
<?php
if($_SESSION['naam']) {
//HIER DE NORMALE WEBSITE \/
?>

<div id="chatmenu" align="right"></div>
<div id="chatwindow"></div><div id="online">

<span id="header">MENU</span><br />
<a href="#" onclick="loadtoevoeg();">Voeg contact toe</a><br />
<a href="#" onclick="loadchat('full');">Chat</a><br />
<a target='_parent' href="../logout.php">Log uit</a>
<br />
<br />
<span id="header">ONLINE</span><br />
<div id='onlinecontact'>
<script language="javascript">
online();
chatmenu();
</script>
</div><div id="contactacc"></div>
<?php
if($_SESSION['rank'] == 'admin') {
echo '
<br /><span id="header">ADMIN</span><br />
<div id="admin">
<a href="#" onclick="loadadmin();">Alle accounts</a>
</div>'
;
}

?>

</div>
<?php
}
else
{
//HIER DE FOUTMELDING \/
?>

<script language="javascript">
alert("Hiervoor moet je ingelogd zijn je wordt terug gestuurd naar de beginpagina.");
window.open("../index.php",'_self');
</script>
<?php
}
?>

</body>
</html>

loggedin/admin_online.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
session_start();
if($_SESSION['naam']) {
if($_SESSION['rank'] == 'admin') {
include "../config.php";

$tijd = time();

$sql1 = "UPDATE login SET lastlogin = '" .$tijd. "' WHERE id = '" .$_SESSION['userid']. "'";
$res1 = mysql_query($sql1) or die(mysql_error());

$onlinetijd = "10";  // 10 seconden

// als je $onlinetijd veranderd, moet je ook de "5 minuten" veranderen naar $onlinetijd/60 !!!!    


    
$sql3 =  "SELECT * FROM login ORDER BY lastlogin DESC";
$res3 = mysql_query($sql3);
    while($row3 = mysql_fetch_array($res3)){

if($row3['lastlogin'] + $onlinetijd > time()){

echo '<b><font color="green">O</font></b> <u>'.$row3['naam'].'</u><br />';

        }
else{
        
echo "<b><font color='red'>O</font></b> <u>".$row3['naam']."</u><br />";
        }
        }      
        }      
    }

    
?>

loggedin/chat.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
session_start();
if($_SESSION['naam']) {
include "../config.php";

function
parseubb($bericht){
   $bericht = str_replace ("[br]","\n",$bericht);
   $bericht = str_replace ("\n","<br>",$bericht);
   $bericht = str_replace ("","<b>Code:</b><br><table bgcolor=\"#000000\" cellspacing=\"1\" width=\"90%\"><tr><td><table cellpadding=2 cellspacing=\"0\" bgcolor=\"#FFFFFF\" width=\"100%\"><tr><td><font face=Courier size=\"1\" color=\"#000000\">", $bericht);
   $bericht = str_replace ("", "</font></td></tr></table></td></tr></table>", $bericht);
   $bericht = preg_replace("/\[b\](.*?)\[\/b\]/si", "<b>\\1</b>",$bericht);
   $bericht = preg_replace("/\[i\](.*?)\[\/i\]/si", "<i>\\1</i>",$bericht);
   $bericht = preg_replace("/\[u\](.*?)\[\/u\]/si", "<u>\\1</u>",$bericht);
   $bericht = preg_replace("/\[s\](.*?)\[\/s\]/si", "<s>\\1</s>",$bericht);
   $bericht = preg_replace("/\[move\](.*?)\[\/move\]/si", "<div align=\"center\"><marquee width=\"90%\">\\1</marquee></div>",$bericht);
   $bericht = preg_replace ("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "<font color=\"\\1\">\\2</font>", $bericht);
   $bericht = preg_replace ("/\[font=(.*)\](.*)\[\/font\]/", "<font face=\"$1\">$2</font>", $bericht);
   $bericht = preg_replace ("/\[size=(.*)\](.*)\[\/size\]/", "<font size=\"$1\">$2</font>", $bericht);
   $bericht = preg_replace("/\[img\](.*?)\[\/img\]/si", "<img src=\"\\1\" border=\"0\">",$bericht);
   $bericht = preg_replace("/\[tt\](.*?)\[\/tt\]/si", "<tt>\\1</tt>",$bericht);
   $bericht = preg_replace("/\[left\](.*?)\[\/left\]/si", "<div align=\"left\">\\1</div>",$bericht);
   $bericht = preg_replace("/\[center\](.*?)\[\/center\]/si", "<div align=\"center\">\\1</div>",$bericht);
   $bericht = preg_replace("/\[right\](.*?)\[\/right\]/si", "<div align=\"right\">\\1</div>",$bericht);
   $bericht = preg_replace("/\[sub\](.*?)\[\/sub\]/si", "<sub>\\1</sub>",$bericht);
   $bericht = preg_replace("/\[sup\](.*?)\[\/sup\]/si", "<sup>\\1</sup>",$bericht);
   $bericht = preg_replace("/\[fixed\](.*?)\[\/fixed\]/si", "<font face=\"Courier New\">\\1</font>",$bericht);
   $bericht = str_replace ("[[","{{",$bericht);
   $bericht = str_replace ("]]","}}",$bericht);
   $bericht = str_replace ("|","&#124;",$bericht);
   $bericht = preg_replace("/\[pre\](.*?)\[\/pre\]/si", "<pre>\\1</pre>",$bericht);
   $bericht = str_replace ("{{","[",$bericht);
   $bericht = str_replace ("}}","]",$bericht);
   $bericht = str_replace ("[hr]","<hr color=\"#FFFFFF\" noshade />",$bericht);
   $bericht = eregi_replace("\\[email=([^\\[]*)\\]([^\\[]*)\\[/email\\]", "<a href=\"mailto:\\1\">\\2</a>",$bericht);  
   $bericht = eregi_replace("\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\2</a>",$bericht);
   $bericht = preg_replace("/\[url\](.*?)\[\/url\]/si", "<a href=\"\\1\" target=_blank>\\1</a>",$bericht);
   $bericht = preg_replace("/\[email\](.*?)\[\/email\]/si", "<a href=\"mailto:\\1\">\\1</a>",$bericht);
   $bericht = preg_replace ("#\[ftp\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/ftp\]#", "<a href=\"ftp://\\1\\2\" target=\"_blank\">\\2</a>", $bericht);
   $bericht = preg_replace ("#\[ftp\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/ftp\]#", "<a href=\"ftp://\\1\" target=\"_blank\">\\1</a>", $bericht);
   $bericht = preg_replace ("#\[ftp=([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/ftp\]#", "<a href=\"ftp://\\1\\2\" target=\"_blank\">\\2</a>", $bericht);
   $bericht = preg_replace ("#\[ftp=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/ftp\]#", "<a href=\"ftp://\\1\" target=\"_blank\">\\2</a>", $bericht);  
   $bericht = str_replace(":)"," <img src=\"images/smilies/smile.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace("8["," <img src=\"images/smilies/huh.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(":o"," <img src=\"images/smilies/ohmy.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(";)"," <img src=\"images/smilies/wink.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(":P"," <img src=\"images/smilies/tongue.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(":p"," <img src=\"images/smilies/tongue.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(":D"," <img src=\"images/smilies/biggrin.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace("8)"," <img src=\"images/smilies/cool.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace("*-)"," <img src=\"images/smilies/rolleyes.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(":?"," <img src=\"images/smilies/dry.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(":@"," <img src=\"images/smilies/mad.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(":("," <img src=\"images/smilies/sad.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace("8-)"," <img src=\"images/smilies/unsure.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(":["," <img src=\"images/smilies/blink.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace("[:-]"," <img src=\"images/smilies/ph34r.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(";/"," <img src=\"images/smilies/happy.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace("[-)"," <img src=\"images/smilies/sleep.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace("(l)"," <img src=\"images/smilies/wub.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(":s"," <img src=\"images/smilies/wacko.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace(":S"," <img src=\"images/smilies/wacko.gif\" alt=\"Smilie\" />",$bericht);
 $bericht = str_replace ("kut","****",$bericht);
 $bericht = str_replace ("fuck","****",$bericht);
 $bericht = str_replace ("fucking","****",$bericht);
 $bericht = str_replace ("facking","****",$bericht);
 $bericht = str_replace ("focking","****",$bericht);
 $bericht = str_replace ("fack","****",$bericht);
 $bericht = str_replace ("fock","****",$bericht);
 $bericht = str_replace ("hoer","****",$bericht);
 $bericht = str_replace ("porno","****",$bericht);
 $bericht = str_replace ("lul","****",$bericht);
 $bericht = str_replace ("neuken","****",$bericht);
 $bericht = str_replace ("verneuk","****",$bericht);
 $bericht = str_replace ("slet","****",$bericht);
 $bericht = str_replace ("teef","****",$bericht);
 $bericht = str_replace ("kanker","****",$bericht);
 $bericht = str_replace ("tering","****",$bericht);
return $bericht;
}


$query1 = mysql_query("SELECT * FROM gesprek WHERE code = '".$_GET['code']."' AND id1 = '".$_SESSION['userid']."'") or die (mysql_error());
while ($obj1 = mysql_fetch_assoc($query1)) {
   $stat = $obj1['status'];

if($stat == 'sluit') {
echo '<b>Je contact heeft het venster gesloten. Alles wat je nu zegt kan hij/zij niet meer ontvangen.</b>';
    }
    }

$query = mysql_query("SELECT * FROM chat WHERE code = '".$_GET['code']."' ORDER BY id ASC") or die (mysql_error());
while ($obj = mysql_fetch_assoc($query)) {
   $nick = $obj['nick'];
       $bericht = htmlspecialchars($obj['bericht']);
    $time1 = $obj['time'];
    if($time1 > $_SESSION['time']) {
    echo '<br /><b>'.$nick.':</b> '.parseubb($bericht);
    }
    }
}

?>

loggedin/chatbox.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
session_start();
if($_SESSION['naam']) {
if($_GET['code'] == "full") {
$chatcode = "full";
}
else{
$chatcode = $_GET['code'];
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MesChat</title>
<link rel="stylesheet" type="text/css" href="../style.css" />
<script language="javascript">
function scrollb() {
document.getElementById("chatbox").scrollTop = document.getElementById("chatbox").scrollHeight;
}
function addSmilie(code)
{
document.writeform.bericht.value+=code;
document.writeform.bericht.focus();
}

var xmlHttp1

function write1()
{
xmlHttp1=GetXmlHttpObject()
if (xmlHttp1==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var bericht = document.writeform.bericht.value;
<?php
if($_SESSION['rank'] == "admin") {
echo "var nick = document.writeform.nickname.value;";
}
else{
echo "var nick = '".$_SESSION['naam']."';";
}

echo "var code = \"".$chatcode."\";";
?>

var url1="write.php?b="+bericht+"&nick="+nick+"&code="+code;
xmlHttp1.onreadystatechange=stateChanged1;
xmlHttp1.open("GET",url1,true);
xmlHttp1.send(null);
}

function stateChanged1()
{
if (xmlHttp1.readyState==4)
{
document.getElementById("verstuurd").innerHTML="Verstuurd!";
document.writeform.bericht.value="";
chat();
}
}

var xmlHttp

<?php
echo "var code = \"".$chatcode."\";";
?>


function chat()
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="chat.php?code="+code;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("chatbox").innerHTML=xmlHttp.responseText;
scrollb();
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
setInterval(chat, 5000);
function entsub(event)
        {
              if (event && event.which == 13)
                write1();
              else
            return true;
            
        }
</script>
<style type="text/css">
#chatbox {
width:700px;
height:250px;
overflow:auto;
position:absolute;
left:50%;
top:10px;
margin-left: -350px;
border:1px #000000 dotted;
}
#write {
width:700px;
overflow:auto;
position:absolute;
left:50%;
top:265px;
margin-left:-350px;
border:1px #000000 dotted;
}
</style>
</head>

<body>
<div id='chatbox'> </div>
<div id='write'>
  <form id="writeform" name="writeform">
    Nickname:
    <?php
if($_SESSION['rank'] == "admin") {
echo '<input name="nickname" type="text" id="nickname" value="'.$_SESSION['naam'].'"  />';
}
else{
      echo '<input name="nickname" type="text" id="nickname" value="'.$_SESSION['naam'].'" disabled="disabled" />';
      }

      ?>

      <br />
  Bericht: <br />
  <textarea name="bericht" rows="3" id="bericht" style="width:90%;" onkeypress="return entsub(event)"></textarea>
  <div id='smilies'><a href="#" onclick="addSmilie(':D');"><img src="images/smilies/biggrin.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie(':[');"><img src="images/smilies/blink.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie('8)');"><img src="images/smilies/cool.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie(':?');"><img src="images/smilies/dry.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie(';/');"><img src="images/smilies/happy.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie('8[');"><img src="images/smilies/huh.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie(':@');"><img src="images/smilies/mad.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie(':o');"><img src="images/smilies/ohmy.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie('[:-]');"><img src="images/smilies/ph34r.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie('*-)');"><img src="images/smilies/rolleyes.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie(':(');"><img src="images/smilies/sad.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie('[-)');"><img src="images/smilies/sleep.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie(':)');"><img src="images/smilies/smile.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie(':P');"><img src="images/smilies/tongue.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie('8-)');"><img src="images/smilies/unsure.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie(':S');"><img src="images/smilies/wacko.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie(';)');"><img src="images/smilies/wink.gif" width="20" height="20" border="0" /></a><a href="#" onclick="addSmilie('(l)');"><img src="images/smilies/wub.gif" width="22" height="29" border="0" /></a></div>
  <br />
  <input name="verstuur" type="button" id="verstuur" value="Verstuur" onclick="write1()" />
  <span id="verstuurd"></span></form>
</div>
<script language="javascript">
chat();
</script>
</body>
</html>
<?php
}
?>

loggedin/closechat.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
<?php
session_start();
include "../config.php";
if($_SESSION['naam']) {
if($_GET['code']) {
mysql_query("UPDATE gesprek SET status = 'sluit' WHERE code = '" .$_GET['code']. "'") or die (mysql_error());
}
}

?>

loggedin/contactacc.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
session_start();
include "../config.php";
if($_SESSION['naam']) {
if($_GET['res'] == 'wei') {
mysql_query("UPDATE contact SET acc = 'wei' WHERE id1 = '" .$_GET['id']. "' AND id2 = '" .$_SESSION['userid']. "'") or die (mysql_error());
echo "<br />Geweigerd";

}
elseif($_GET['res'] == 'acc') {

$check_query = mysql_query("SELECT * FROM contact WHERE id1 = '" .$_SESSION['userid']. "' AND id2 = '" .$_GET['id']. "'");
$check = mysql_num_rows($check_query);
if($check == "0"){

mysql_query("UPDATE contact SET acc = 'acc' WHERE id1 = '" .$_GET['id']. "' AND id2 = '" .$_SESSION['userid']. "'") or die (mysql_error());
mysql_query("INSERT INTO contact (id1, id2, acc)  
    VALUES ('"
.$_SESSION['userid']."', '".$_GET['id']."', 'acc')") or die(mysql_error());
    echo "<br />Geaccepteerd";
    
    }
else{
    
    mysql_query("UPDATE contact SET acc = 'acc' WHERE id1 = '" .$_SESSION['userid']. "' AND id2 = '" .$_GET['id']. "'") or die (mysql_error());
    echo "<br />Geaccepteerd";
    }
}
}

?>

loggedin/contacttoevoeg.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
session_start();
include "../config.php";
if($_SESSION['naam']) {
if($_GET['id']) {
$check_query = mysql_query("SELECT * FROM contact WHERE id1 = '" .$_SESSION['userid']. "' AND id2 = '".$_GET['id']."'");
$check = mysql_num_rows($check_query);
if($check == "0"){
mysql_query("INSERT INTO contact (id1, id2, acc)  
    VALUES ('"
.$_SESSION['userid']."', '".$_GET['id']."', 'nee')") or die(mysql_error());
    echo 'Je contact is toegevoegd, je moet kunt pas contact met dit contact maken als hij/zij je heeft geaccepteerd.';
    }
else{
    echo 'Dit contact is al contact.';
}
}
}

?>

loggedin/gesprekmenu.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
session_start();
include "../config.php";
if($_SESSION['naam']) {
echo '<a href="#" onclick="loadchat(\'full\');">All Chat</a>';
$query = mysql_query("SELECT * FROM gesprek WHERE id1 ='".$_SESSION['userid']."' AND status = 'acc' ORDER BY id DESC") or die (mysql_error());
while ($obj = mysql_fetch_assoc($query)) {
    $time1 = $obj['time'];
    $id3 = $obj['id2'];
    $code1 = $obj['code'];
    if($time1 > $_SESSION['time']) {
    $query1 = mysql_query("SELECT * FROM login WHERE id ='".$id3."'") or die (mysql_error());
while ($obj1 = mysql_fetch_assoc($query1)) {
    $nick = $obj1['naam'];
    echo ' || <b><a href="#" onclick="loadchat(\''.$code1.'\');">'.$nick.'</a></b> |<a href="#" onclick="closechat(\''.$code1.'\');">X</a>|';
    }
    }
    }
}

?>

loggedin/newchat.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
session_start();
include "../config.php";
if($_SESSION['naam']) {
if($_GET['id']) {
if($_GET['id'] != $_SESSION['userid']) {
$check_query = mysql_query("SELECT * FROM gesprek WHERE id1 = '" .$_SESSION['userid']. "' AND id2 = '".$_GET['id']."' AND status = 'acc'");
$check = mysql_num_rows($check_query);
if($check == "0"){
$code1 = code();
mysql_query("INSERT INTO gesprek (id1, id2, status, time, code)  
    VALUES ('"
.$_SESSION['userid']."', '".$_GET['id']."', 'acc', '".time()."', '".$code1."')") or die(mysql_error());
mysql_query("INSERT INTO gesprek (id1, id2, status, time, code)  
    VALUES ('"
.$_GET['id']."', '".$_SESSION['userid']."', 'acc', '".time()."', '".$code1."')") or die(mysql_error());    
    echo $code1;
    }
    }
    }
    }

    ?>

loggedin/online.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
session_start();
if($_SESSION['naam']) {
include "../config.php";

function
dec_str($line, $len)
{

    if (strlen($line) > $len)
        $afgekort = substr($line, 0, $len) . "...";
    else
        $afgekort = $line;

    return ($afgekort);
}


$tijd = time();

$sql1 = "UPDATE login SET lastlogin = '" .$tijd. "' WHERE id = '" .$_SESSION['userid']. "'";
$res1 = mysql_query($sql1) or die(mysql_error());

$onlinetijd = "10";  // 10 seconden

// als je $onlinetijd veranderd, moet je ook de "5 minuten" veranderen naar $onlinetijd/60 !!!!    


    
$sql3 =  "SELECT * FROM login ORDER BY lastlogin DESC";
$res3 = mysql_query($sql3);
    while($row3 = mysql_fetch_array($res3)){

    $sql2 =  "SELECT * FROM contact WHERE id1 = '" .$_SESSION['userid']."'";
$res2 = mysql_query($sql2);
    while($row2 = mysql_fetch_array($res2)){
    
if($row2['id2'] == $row3['id']) {

if($row3['lastlogin'] + $onlinetijd > time()){

if($row2['acc'] == 'acc') {
echo '<b><font color="green">O</font></b> <u><a href="#" onclick="newchat(\''.$row3['id'].'\');">'. dec_str($row3['naam'], 12) .'</a></u><br />';
}
elseif($row2['acc'] == 'nee') {
echo "<b><font color='green'>O</font></b> <u>".dec_str($row3['naam'], 12) ."</u> (nog niet geaccepteerd)<br />";
}
elseif($row2['acc'] == 'wei') {
echo "<b><font color='green'>O</font></b> <u>".dec_str($row3['naam'], 12) ."</u> (geweigerd)<br />";
}

        }
else{
        
        if($row2['acc'] == 'acc') {
echo "<b><font color='red'>O</font></b> <u>".dec_str($row3['naam'], 12)."</u><br />";
}
elseif($row2['acc'] == 'nee') {
echo "<b><font color='red'>O</font></b> <u>".dec_str($row3['naam'], 12) ."</u> (nog niet geaccepteerd)<br />";
}
elseif($row2['acc'] == 'wei') {
echo "<b><font color='red'>O</font></b> <u>".dec_str($row3['naam'], 12) ."</u> (geweigerd)<br />";
}
        }
        }      
        }      
    }

     $sql4 =  "SELECT * FROM contact WHERE id2 = '" .$_SESSION['userid']."' AND acc = 'nee'";
$res4 = mysql_query($sql4);
    while($row4 = mysql_fetch_array($res4)){
    $sql5 =  "SELECT * FROM login WHERE id = '".$row4['id1']."'";
$res5 = mysql_query($sql5);
    while($row5 = mysql_fetch_array($res5)){
    echo "<br /><br /><span id='contact".$row4['id1']."'>".$row5['naam']." heeft jou toegevoegd als contact: <a href='#' onclick='contactacc(\"acc\", \"".$row4['id1']."\")'>accepteren</a> / <a href='#' onclick='contactacc(\"wei\", \"".$row4['id1']."\")'>weigeren</a></span>";
    }
    }
    }

?>

loggedin/toevoegen.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
session_start();
if($_SESSION['naam']) {
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>MesChat</title>
<link rel="stylesheet" type="text/css" href="../style.css" />
<script language="javascript">
var xmlHttp

function contact(str)
{
if (str.length==0)
  {
  document.getElementById("sug").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="toevoegenhint.php?naam="+str;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("sug").innerHTML=xmlHttp.responseText;
}
}

var xmlHttp1

function toevoegcontact(id)
{
xmlHttp1=GetXmlHttpObject()
if (xmlHttp1==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="contacttoevoeg.php?id="+id;
xmlHttp1.onreadystatechange=stateChanged1;
xmlHttp1.open("GET",url,true);
xmlHttp1.send(null);
}

function stateChanged1()
{
if (xmlHttp1.readyState==4)
{
document.getElementById("uit").innerHTML=xmlHttp1.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
function check(naam, id) {
var checkcontact = confirm('Weet je zeker dat je '+naam+' als contact wilt toevoegen?')
if(checkcontact) {
toevoegcontact(id);
}
}
</script>
</head>

<body>
<form>
   Naam van contact:
   <input type="text" id="txt1"
onkeyup="contact(this.value)">
</form>

<div style="border:1px #000000 dotted;"><span id="sug"></span><span id="uit"></span></div>
</body>
</html>
<?php
}
?>

loggedin/toevoegenhint.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
session_start();
if($_SESSION['naam']) {
include "../config.php";
if($_GET['naam']) {
$query = mysql_query("SELECT * FROM login WHERE naam LIKE '".$_GET['naam']."%'") or die (mysql_error());
while ($obj = mysql_fetch_assoc($query)) {
   $nick = $obj['naam'];
   $id = $obj['id'];
   echo "<a href='#' onclick='check(\"".$nick."\", \"".$id."\")'>".$nick."</a><br />";
   }
   }
   }

   ?>

loggedin/write.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
session_start();
if($_SESSION['naam']) {
include "../config.php";


if($_GET['b']) {
if($_GET['nick']) {
if($_GET['code']) {
if($_SESSION['rank'] == 'admin') {
$nick = $_GET['nick'];
}
else{
$nick = $_SESSION['naam'];
}

mysql_query("INSERT INTO chat (nick, bericht, time, code)  
    VALUES ('"
.$nick."', '".$_GET['b']."', '".time()."', '".$_GET['code']."')") or die(mysql_error());
    }
}
}
}

?>

en dan in loggedin/images/smilies alle smilies zetten

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.