handleRequest(); $q = isset($_GET['search']) ? $_GET['search'] : ''; $ret = array(); $chatmail_heading = $WRITE_MAIL; if($send && $chat){ if($mail_to){ $chat = substr($chat,0,10000); $chat = str_replace('>','>',$chat); $chat = str_replace('<','<',$chat); $chat = strip_tags($chat); $chat = str_replace("'","'",$chat); $chat = mysql_real_escape_string($chat, $db_handle); if($subject==''){ $subject = $NOSUBJECT; }else{ $subject = strip_tags($subject); $subject = str_replace("'","'",$subject); $subject = mysql_real_escape_string($subject, $db_handle); } $update = mysql_query("INSERT INTO chat_mail (NICK,SENDER,BODY,TIME,SUBJECT,UNREAD)VALUES('".mysql_real_escape_string($mail_to, $db_handle)."','".$_SESSION['nick']."','$chat',CURRENT_TIMESTAMP(),'$subject','0')",$db_handle); $select_msg_to = '
'.$SEND_SUCCESS.'

'; $chatalert = "SELECT Email, (select count(*) from chat_mail where nick = cd.nick and unread between 0 and 3) as unread_count FROM chat_data cd left join chat c on cd.nick = c.nick WHERE cd.nick = '".mysql_real_escape_string($mail_to, $db_handle)."' and cd.chatmail_alert = 1 and c.Nick IS NULL"; $chatalert_result = mysql_query($chatalert, $db_handle); $chatalert_data = mysql_fetch_assoc($chatalert_result); $unread_count = $chatalert_data['unread_count']; $chatalert_receiver = $chatalert_data['Email']; if($chatalert_receiver){ $mail_content = "Hallo $mail_to,

Du hast eine neue Chatmail von $nick im Schulhofchat bekommen.
Um sie direkt zu lesen, log dich direkt auf dem Schulhofchat ein: www.schulhofchat.de
Insgesamt warten $unread_count ungelesene Nachrichten auf Dich.

Viele Grüße vom Schulhofchat


PS: Wenn du diese Benachrichtung nicht mehr erhalten willst kannst du das unter \"Mein Profil\" einstellen."; include_once 'phpmailer/class.phpmailer.php'; $mailc = new PHPMailer(); $mailc->From = "team@schulhofchat.de"; $mailc->FromName = "Schulhofchat-Chatmailalarm"; $mailc->Sender='donotreply@schulhofchat.de'; $mailc->Host = "schulhofchat.de"; $mailc->mailer = 'mail'; $mailc->IsMail(); $mailc->Hostname = 'schulhofchat.de'; $mailc->Subject = 'Du hast eine neue Chatmail im Schulhofchat'; $mailc->Body = $mail_content; $mailc->AltBody = strip_tags(str_replace('
',"\n",$mailc->Body)); $mailc->AddAddress($chatalert_receiver); #$mailc->AddBCC('giese@foreach.de'); $mailc->send(); } }else{ $select_msg_to = '
'.$NO_SELECTION.'
'; } } if($search){ $search=addslashes($search); $query = "select Nick from chat_data where Nick like '".mysql_real_escape_string($search, $db_handle)."%' AND Nick !='".$_SESSION['nick']."' order by Nick"; $result=mysql_query($query,$db_handle); if(mysql_num_rows($result)>0){ $select_msg_to = ''; $select_msg_to .= '
 '.$CHOOSE_NICK.':
 '; $show_content = TRUE; }else{ $select_msg_to = '
'.$NO_HIT.'
'; $select_msg_to .= '
'.$MSG_SEND_TO.'

'; if($ID){ $select_msg_to .= ''; } $select_msg_to .= ' '; } if(mysql_num_rows($result)==1){ $select_msg_to .= ''; while($a=mysql_fetch_array($result)){ $select_msg_to .= "

'; $select_msg_to .= ''; } elseif(!$ID){ $show_subjects = '
'.$MSG_SEND_TO.'

'; $show_subjects .= ' '; } if($what=='answer'){ $query= " select TIME, SENDER, SUBJECT, BODY from chat_mail where NICK='".$_SESSION['nick']."' && ID=".(int)$ID; $result= mysql_query($query,$db_handle); $row=mysql_fetch_array($result); $showtime = substr($row['TIME'],8,2)."."; $showtime .= substr($row['TIME'],5,2)."."; $showtime .= substr($row['TIME'],0,4)." - "; $showtime .= substr($row['TIME'],11,5); $select_msg_to = '
'.$RECEIPIENT.':
'; //now insert > on every line if(substr($row['SUBJECT'],0,3) != "RE:"){ $subject = 'RE: '.$row['SUBJECT']; }else{ $subject = $row['SUBJECT']; } $row['BODY']="> ".$row['BODY']; $row['BODY'] = str_replace(nl,nl.'> ',$row['BODY']); // now put $text_content together $text_content = '('.$showtime.') '.$row['SENDER'].' '.$WROTE.':'.nl.$row['BODY'].nl; $content = ''; $content .= ''; $content .= '
'.$SUBJECT.':
'.$MESSAGE.':
'; $show_subjects = '
'; @mysql_free_result($result); } if($what=='forward'){ $show_subjects = '
'.$MSG_SEND_TO.'

'; $show_subjects .= ''; $show_subjects .= '

'; } if($show_content){ if($insert_forward && $ID){ $result = mysql_query("select TIME, SENDER, SUBJECT, BODY from chat_mail where ID=".(int)$ID,$db_handle); $row=mysql_fetch_array($result); $showtime = substr($row['TIME'],8,2)."."; $showtime .= substr($row['TIME'],5,2)."."; $showtime .= substr($row['TIME'],0,4)." - "; $showtime .= substr($row['TIME'],11,5); if(substr($row['SUBJECT'],0,3) != "FW:"){ $subject = 'FW: '.$row['SUBJECT']; }else{ $subject = $row['SUBJECT']; } $row['BODY']="> ".$row['BODY']; $row['BODY'] = str_replace(nl,nl.'> ',$row['BODY']); // now put $text_content together $text_content = '('.$showtime.') '.$row['SENDER'].' '.$WROTE.':'.nl.$row['BODY'].nl; $content = ''; $content .= ''; $content .= '
'.$SUBJECT.':
'.$MESSAGE.':
'; }else{ $content = ''; $content .= ''; $content .= '
'.$SUBJECT.':
'.$MESSAGE.':
'; } } mysql_close($db_handle); include("messages_tpl.php"); ?>