ENDHTML;
if($message->from != $data->login)
print " from}\">Block | from}&subject=". urlencode("Re: {$message->subject}") ."\">Antwoord | ";
else
print " ";
print "id}\">Delete | \n";
}
}
else if($_GET['p'] == "del") {
if(isset($_GET['id']))
$_POST['id'] = $_GET['id'];
foreach($_POST['id'] as $msgid) {
$dbres = mysql_query("SELECT `outbox`,`inbox`,`from`,`to` FROM `[messages]` WHERE `id`='$msgid' AND (`from`='{$data->login}' OR `to`='{$data->login}')");
if($message = mysql_fetch_object($dbres)) {
if($message->from == $data->login)
mysql_query("UPDATE `[messages]` SET `outbox`=0 WHERE `id`='$msgid'");
else
mysql_query("UPDATE `[messages]` SET `inbox`=0 WHERE `id`='$msgid'");
}
}
print <<Berichten |
- Inbox
- Outbox
- Nieuw bericht
- Block list
|
Bericht(en) verwijderd |
ENDHTML;
}
else if($_GET['p'] == "block") {
print <<Block list |
- Inbox
- Outbox
- Nieuw bericht
- Block list
|
ENDHTML;
if(isset($_POST['update_list'])) {
$newlist = "";
if(isset($_POST['blocklist'])) {
foreach($_POST['blocklist'] as $blocked) {
if($info = mysql_fetch_object(mysql_query("SELECT `login` FROM `[users]` WHERE `login`='{$blocked}'"))) {
$newlist = preg_replace("/,{$info->login},/i",'',$newlist);
$newlist .= ",{$info->login},";
}
}
}
mysql_query("UPDATE `[users]` SET `blocklist`='$newlist' WHERE `login`='{$data->login}'");
print " De block list is geupdate | ";
$blocklist = $newlist;
}
else {
$dbres = mysql_query("SELECT `blocklist` FROM `[users]` WHERE `login`='{$data->login}'");
$blocklist = mysql_fetch_object($dbres);
$blocklist = $blocklist->blocklist;
}
if(isset($_GET['add'])) {
$dbres = mysql_query("SELECT `login` FROM `[users]` WHERE `login`='{$_GET['add']}'");
if($sender = mysql_fetch_object($dbres)) {
$blocklist = preg_replace("/,{$sender->login},/i",'',$blocklist);
$blocklist .= ",{$sender->login},";
mysql_query("UPDATE `[users]` SET `blocklist`='$blocklist' WHERE `login`='{$data->login}'");
print " {$sender->login} is geblokt | \n";
}
}
print << | \n";
}
else if($_GET['p'] == "new") {
print <<Nieuw bericht |
- Inbox
- Outbox
- Nieuw bericht
- Block list
|
ENDHTML;
if(isset($_POST['to'],$_POST['message'])) {
if(strtolower($_POST['to']) != strtolower($data->login)) {
$dbres = mysql_query("SELECT `login`,`Mobieltje`,`blocklist` FROM `[users]` WHERE `login`='{$_POST['to']}'");
$info = mysql_fetch_object($dbres);
if($info == false)
print " '{$_POST['to']}' bestaat niet | \n";
else if($info->Mobieltje == 0)
print " {$info->login} heeft geen mobiel | \n";
else if(preg_match("/,{$data->login},/i",$info->blocklist))
print " {$info->login} heeft je geblockt | \n";
else {
$_POST['subject'] = preg_replace('/','<',$_POST['subject']);
$_POST['message'] = preg_replace('/','<',$_POST['message']);
$dbres = mysql_query("SELECT `login` FROM `[users]` WHERE `login`='{$_POST['to']}'");
if($recp = mysql_fetch_object($dbres)) {
$forwardedFor = ($_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['HTTP_CLIENT_IP'];
$forwardedFor = preg_replace('/, .+/','',$forwardedFor);
mysql_query("INSERT INTO `[messages]`(`time`,`IP`,`forwardedFor`,`from`,`to`,`subject`,`message`) values(NOW(),'{$_SERVER['REMOTE_ADDR']}','$forwardedFor','{$data->login}','{$recp->login}','{$_POST['subject']}','{$_POST['message']}')");
mysql_query("DELETE FROM `[temp]` WHERE `id`='{$_POST['id']}' AND `code`='{$_POST['code']}' AND `area`='message'");
print " Bericht verzonden | \n";
}
}
}
else
print " Je kan geen bericht naar jezelf sturen | \n";
}
$_REQUEST['message'] = stripslashes($_REQUEST['message']);
print <<
| |