| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/seaside.pacim.de/web/ |
Upload File : |
<?php
if( !isset( $_GET['token'] ) || ( isset( $_GET['token'] ) && $_GET['token'] != "eFD6dx2G4RFBkrYS7Z87" ) ) die('error');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once("includes/config.inc.php");
/* Auf SMTP-Versand umgestellt? Dann TREIBT dieser bestehende Minuten-Cron die neue
* Mailing-Pipeline (Queue + Zeitplan-Regeln + Newsletter). Der alte Versand entfällt damit.
* So ist kein Eingriff in die ISPConfig-Crontab nötig. */
if ( class_exists( 'mailservice' ) && mailservice::smtpEnabled() ) {
@ini_set( 'display_errors', '0' ); error_reporting( 0 );
$r = array( 'ok' => true, 'mode' => 'smtp' );
$r['catchup'] = mailrules::runEventCatchup(); // Buchungsbestätigungen für Direkt-/Online-Buchungen nachziehen
$r['paycatchup'] = mailrules::runPaymentCatchup(); // Rechnungsmails für Zahlungen ohne setPayment-Hook (Online/WP-Sync/ParkingList) nachziehen
$r['scheduled'] = mailrules::runScheduled();
$r['queue'] = mailqueue::processQueue( isset( $_GET['limit'] ) ? (int) $_GET['limit'] : 50 ); // danach senden
$r['newsletter'] = class_exists( 'newsletter' ) ? newsletter::process( 50 ) : null;
$r['push'] = class_exists( 'pushnotify' ) ? pushnotify::processQueue( isset( $_GET['limit'] ) ? (int) $_GET['limit'] : 50 ) : null; // Pushover-Queue mit abarbeiten
if ( class_exists( 'perflog' ) ) { @perflog::runAgent(); } // Debug-Agent (nur Analyse/Bericht, No-Op wenn aus)
echo json_encode( $r );
exit;
}
// Pushover-Queue auch versenden, wenn (noch) NICHT auf SMTP umgestellt ist – Push hängt nicht am Mail-Transport.
if ( class_exists( 'pushnotify' ) ) { @pushnotify::processQueue( isset( $_GET['limit'] ) ? (int) $_GET['limit'] : 50 ); }
// Debug-Agent (Phase 3) – nur Analyse/Bericht, drosselt sich selbst, No-Op wenn deaktiviert.
if ( class_exists( 'perflog' ) ) { @perflog::runAgent(); }
global $oData;
class Mailer {
private $oData;
private $mysql;
const MAIL_SCRIPT = MAIL_SCRIPT;
public function __construct($oData) {
$this->oData = $oData;
$this->mysql = new MysqliDb(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
}
public function sendMails() {
$mailIds = $this->getMailIDs();
if (empty($mailIds)) {
echo json_encode(["status" => 1, "info" => "Keine Mails zu versenden"]);
exit;
}
$urlCheckResult = $this->checkUrl(self::MAIL_SCRIPT);
if ($urlCheckResult['status'] === 0) {
echo json_encode(["status" => 0, "info" => "Nicht erreichbar", "urlStatus" => $urlCheckResult]);
exit;
}
foreach ($mailIds as $mailId) {
$this->sendMail($mailId);
sleep(0.2); // Warte kurz
}
}
private function getMailIDs() {
$arrMails = $this->oData->rawQuery("
SELECT message_id
FROM pacim_messages
WHERE message_status = 0 AND message_template IN (1,3,4,5,8,9,10)
LIMIT 5
");
return array_column($arrMails, 'message_id');
}
private function sendMail($mailId) {
$firstInit = json_decode(json_encode($this->oData->message($mailId)), TRUE);
sleep(0.4);
$mailData = json_decode(json_encode($this->oData->message($mailId)), TRUE);
$mailData['debug'] = isset($_SESSION['user']) && $_SESSION['user'] == DEBUG_USER;
if (isset($mailData['files'])) {
foreach ($mailData['files'] as $name => $file) {
$mailData['file_' . $name] = new CURLFile($file, 'application/pdf', $name);
}
unset($mailData['files']);
}
$ch = curl_init(self::MAIL_SCRIPT);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $mailData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
/*if ($result) {
$response = json_decode($result, true);
if (isset($response['status']) && ( $response['status'] == 1 || $response['status'] == 2 ) ) {*/
$this->mysql->where('message_id', $mailId);
$this->mysql->update('pacim_messages', ['message_status' => 1]);
echo json_encode(["status" => 1, "mail_id" => $mailId]);
/*}
}*/
}
private function checkUrl($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [
'status' => ($httpcode >= 200 && $httpcode < 300) ? 1 : 0,
'response' => $httpcode
];
}
}
// Beispiel zur Verwendung der Klasse
// $oData und $mysql müssen entsprechend initialisiert und übergeben werden
$mailer = new Mailer($oData);
$mailer->sendMails();