2020-06-03 15:31:18 +00:00
|
|
|
<?php
|
2023-08-23 16:16:35 +00:00
|
|
|
include_once('../lib/phpmailer/PHPMailer.php');
|
|
|
|
include_once('../lib/phpmailer/SMTP.php');
|
2020-06-03 15:31:18 +00:00
|
|
|
|
|
|
|
$statement = $RUNTIME['PDO']->prepare("CREATE TABLE IF NOT EXISTS im_offline_send (`id` int(6) NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
|
|
|
|
$statement->execute();
|
|
|
|
|
|
|
|
function isMailAllreadySend($id)
|
|
|
|
{
|
|
|
|
GLOBAL $RUNTIME;
|
|
|
|
|
2023-08-23 16:16:34 +00:00
|
|
|
$statement = $RUNTIME['PDO']->prepare("SELECT 1 FROM im_offline_send WHERE id = ? LIMIT 1");
|
2020-06-03 15:31:18 +00:00
|
|
|
$statement->execute(array($id));
|
|
|
|
|
|
|
|
if($statement->rowCount() != 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
$IMTYP = array(
|
|
|
|
"0" => "eine Nachricht",
|
|
|
|
"3" => "eine Gruppeneinladung",
|
|
|
|
"4" => "ein Inventaritem",
|
|
|
|
"5" => "eine Bestätigung zur Annahme von Inventar",
|
|
|
|
"6" => "eine Information zur Ablehnung von Inventar",
|
|
|
|
"7" => "eine Aufforderung zur Gruppenwahl",
|
|
|
|
"9" => "ein Inventaritem von einem Script",
|
|
|
|
"19" => "eine Nachricht von einem Script",
|
|
|
|
"32" => "eine Gruppennachricht",
|
|
|
|
"38" => "eine Freundschaftsanfrage",
|
|
|
|
"39" => "eine Bestätigung über die Annahme der Freundschaft",
|
|
|
|
"40" => "eine Information über das Ablehnen der Freundschaft"
|
|
|
|
);
|
|
|
|
|
|
|
|
//$statement = $RUNTIME['PDO']->prepare("SELECT * FROM im_offline WHERE PrincipalID = '1148b04d-7a93-49e9-b3c9-ea0cdeec38f7'");
|
2023-08-23 16:16:34 +00:00
|
|
|
$statement = $RUNTIME['PDO']->prepare("SELECT ID,PrincipalID,Message FROM im_offline");
|
2020-06-03 15:31:18 +00:00
|
|
|
$statement->execute();
|
|
|
|
|
|
|
|
while($row = $statement->fetch())
|
|
|
|
{
|
2023-08-23 16:16:35 +00:00
|
|
|
include 'app/OpenSim.php';
|
2023-08-23 16:16:35 +00:00
|
|
|
$opensim = new OpenSim();
|
|
|
|
|
|
|
|
$email = $opensim->getUserMail($row['PrincipalID']);
|
|
|
|
$allowOfflineIM = $opensim->allowOfflineIM($row['PrincipalID']);
|
2020-06-03 15:31:18 +00:00
|
|
|
|
|
|
|
if($email != "" && $allowOfflineIM == "TRUE")
|
|
|
|
{
|
|
|
|
if(isMailAllreadySend($row['ID']) == FALSE)
|
|
|
|
{
|
|
|
|
$statementSend = $RUNTIME['PDO']->prepare('INSERT INTO im_offline_send (id) VALUES (:idnummer)');
|
|
|
|
$statementSend->execute(['idnummer' => $row['ID']]);
|
|
|
|
|
|
|
|
$mail = new PHPMailer(true);
|
|
|
|
|
|
|
|
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
|
|
|
|
$mail->isSMTP();
|
|
|
|
$mail->Host = $RUNTIME['SMTP']['SERVER'];
|
2021-01-08 01:32:07 +00:00
|
|
|
$mail->Port = $RUNTIME['SMTP']['PORT'];
|
|
|
|
$mail->SMTPAuth = false;
|
2020-06-03 15:31:18 +00:00
|
|
|
|
|
|
|
$mail->setFrom($RUNTIME['SMTP']['ADRESS'], $RUNTIME['GRID']['NAME']);
|
2023-08-23 16:16:35 +00:00
|
|
|
$mail->addAddress($email, $opensim->getUserName($row['PrincipalID']));
|
2020-06-03 15:31:18 +00:00
|
|
|
|
|
|
|
$XMLMESSAGE = new SimpleXMLElement($row['Message']);
|
|
|
|
|
|
|
|
$HTMLMESSAGE = "Du hast ".$IMTYP["".$XMLMESSAGE->dialog.""]." in ".$RUNTIME['GRID']['NAME']." bekommen. <br><p><ul><li>".htmlspecialchars($XMLMESSAGE->message)."</li></ul></p>Gesendet von: ";
|
|
|
|
|
|
|
|
if(isset($XMLMESSAGE->fromAgentName))
|
|
|
|
$HTMLMESSAGE .= $XMLMESSAGE->fromAgentName;
|
|
|
|
|
|
|
|
if(isset($XMLMESSAGE->RegionID) && isset($XMLMESSAGE->Position))
|
|
|
|
{
|
|
|
|
if($XMLMESSAGE->Position->X != 0 || $XMLMESSAGE->Position->X != 0 || $XMLMESSAGE->Position->X != 0)
|
|
|
|
{
|
2023-08-23 16:16:35 +00:00
|
|
|
$HTMLMESSAGE .= " @ ".$opensim->getRegionName($XMLMESSAGE->RegionID)."/".$XMLMESSAGE->Position->X."/".$XMLMESSAGE->Position->Y."/".$XMLMESSAGE->Position->Z;
|
2020-06-03 15:31:18 +00:00
|
|
|
}else{
|
2023-08-23 16:16:35 +00:00
|
|
|
$HTMLMESSAGE .= " @ ".$opensim->getRegionName($XMLMESSAGE->RegionID);
|
2020-06-03 15:31:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//die($HTMLMESSAGE);
|
|
|
|
|
|
|
|
$HTML = new HTML();
|
2023-08-23 16:16:35 +00:00
|
|
|
$HTML->importHTML("templates/mail.html");
|
2020-06-03 15:31:18 +00:00
|
|
|
$HTML->setSeitenInhalt($HTMLMESSAGE);
|
|
|
|
$HTML->build();
|
|
|
|
|
|
|
|
$mail->isHTML(true);
|
|
|
|
$mail->Subject = "Du hast ".$IMTYP["".$XMLMESSAGE->dialog.""]." in ".$RUNTIME['GRID']['NAME'].".";
|
|
|
|
$mail->Body = $HTML->ausgabe();
|
|
|
|
$mail->AltBody = strip_tags($HTMLMESSAGE);
|
|
|
|
|
|
|
|
//print_r($mail);
|
|
|
|
$mail->send();
|
|
|
|
}else{
|
|
|
|
//echo $row['ID']." wurde bereits gesendet.";
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//echo $row['PrincipalID']." möchte keine offline IM oder hat keine E-MAIL Adresse hinterlegt.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|