1
0
Fork 0

add email info

master
Chris 2021-01-08 02:29:46 +01:00
parent e6a326b8fc
commit 656f09a9e8
2 changed files with 70 additions and 13 deletions

55
cron/IARMonitor.php Normal file
View File

@ -0,0 +1,55 @@
<?php
$statement = $RUNTIME['PDO']->prepare("CREATE TABLE IF NOT EXISTS `iarstates` (`userID` VARCHAR(36) NOT NULL COLLATE 'utf8_unicode_ci', `filesize` INT(11) NOT NULL, `iarfilename` VARCHAR(64) NOT NULL COLLATE 'utf8_unicode_ci', PRIMARY KEY (`userID`) USING BTREE) COLLATE='utf8_unicode_ci' ENGINE=InnoDB;");
$statement->execute();
$statement = $RUNTIME['PDO']->prepare("SELECT * FROM iarstates");
$statement->execute();
while($row = $statement->fetch())
{
$email = $RUNTIME['OPENSIM']->getUserMail($row['userID']);
$filesize = filesize("data/".$row['iarfilename']);
if($filesize != $row['filesize'])
{
$statementUpdate = $RUNTIME['PDO']->prepare('UPDATE iarstates SET filesize = :filesize WHERE userID = :userID');
$statementUpdate->execute(['filesize' => $filesize, 'userID' => $row['userID']]);
continue;
}else{
$statementUpdate = $RUNTIME['PDO']->prepare('DELETE FROM iarstates WHERE userID = :userID');
$statementUpdate->execute(['userID' => $row['userID']]);
$mail = new PHPMailer(true);
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->isSMTP();
$mail->Host = $RUNTIME['SMTP']['SERVER'];
$mail->Port = $RUNTIME['SMTP']['PORT'];
$mail->SMTPAuth = false;
$mail->setFrom($RUNTIME['SMTP']['ADRESS'], $RUNTIME['GRID']['NAME']);
$mail->addAddress($email, $RUNTIME['OPENSIM']->getUserName($row['userID']));
$HTMLMESSAGE = 'Deine IAR ist bereit zum Download! <br> Du kannst sie <a href="'.$RUNTIME['IAR']['BASEURL'].$row['iarfilename'].'">hier</a> downloaden.';
$HTML = new HTML();
$HTML->importHTML("style/mail.html");
$HTML->setSeitenInhalt($HTMLMESSAGE);
$HTML->build();
$mail->isHTML(true);
$mail->Subject = "Deine IAR steht nun bereit.";
$mail->Body = $HTML->ausgabe();
$mail->AltBody = strip_tags($HTMLMESSAGE);
$mail->send();
$mail->SmtpClose();
}
}
?>

View File

@ -19,21 +19,23 @@
if(isset($_REQUEST['createIAR'])) if(isset($_REQUEST['createIAR']))
{ {
if($IARRUNNING == FALSE)
$iarname = md5(time().$_SESSION['UUID'] . rand()).".iar";
$APIURL = $RUNTIME['SIDOMAN']['URL']."api.php?CONTAINER=".$RUNTIME['SIDOMAN']['CONTAINER']."&KEY=".$RUNTIME['SIDOMAN']['PASSWORD']."&METODE=COMMAND&COMMAND=".urlencode("save iar ".$_SESSION['FIRSTNAME']." ".$_SESSION['LASTNAME']." /* PASSWORD /downloads/".$iarname);
$APIResult = file_get_contents($APIURL);
if(trim($APIResult) == "DONE")
{ {
$HTML->ReplaceSeitenInhalt("%%IARINFOMESSAGE%%", '<div class="alert alert-danger" role="alert">Deine IAR wird jetzt erstellt und der Download Link wird dir per E-Mail zugesendet. '.$APIResult.'</div>'); $iarname = md5(time().$_SESSION['UUID'] . rand()).".iar";
$statementIARSTART = $RUNTIME['PDO']->prepare('INSERT INTO iarstates (userID, filesize, iarfilename) VALUES (:userID, :filesize, :iarfilename)'); $APIURL = $RUNTIME['SIDOMAN']['URL']."api.php?CONTAINER=".$RUNTIME['SIDOMAN']['CONTAINER']."&KEY=".$RUNTIME['SIDOMAN']['PASSWORD']."&METODE=COMMAND&COMMAND=".urlencode("save iar ".$_SESSION['FIRSTNAME']." ".$_SESSION['LASTNAME']." /* PASSWORD /downloads/".$iarname);
$statementIARSTART->execute(['userID' => $_SESSION['UUID'], 'filesize' => 0, 'iarfilename' => $iarname]); $APIResult = file_get_contents($APIURL);
}else{
$HTML->ReplaceSeitenInhalt("%%IARINFOMESSAGE%%", '<div class="alert alert-danger" role="alert">Es ist etwas schiefgelaufen, bitte warte etwas und versuche es erneut. '.$APIURL.'</div>');
if(trim($APIResult) == "DONE")
{
$HTML->ReplaceSeitenInhalt("%%IARINFOMESSAGE%%", '<div class="alert alert-danger" role="alert">Deine IAR wird jetzt erstellt und der Download Link wird dir per E-Mail zugesendet. '.$APIResult.'</div>');
$statementIARSTART = $RUNTIME['PDO']->prepare('INSERT INTO iarstates (userID, filesize, iarfilename) VALUES (:userID, :filesize, :iarfilename)');
$statementIARSTART->execute(['userID' => $_SESSION['UUID'], 'filesize' => 0, 'iarfilename' => $iarname]);
}else{
$HTML->ReplaceSeitenInhalt("%%IARINFOMESSAGE%%", '<div class="alert alert-danger" role="alert">Es ist etwas schiefgelaufen, bitte warte etwas und versuche es erneut. '.$APIURL.'</div>');
}
} }
} }