pulsecast.php aktualisiert
This commit is contained in:
@@ -1,12 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/*
|
||||||
* Plugin Name: PulseCast
|
Plugin Name: PulseCast
|
||||||
* Plugin URI: https://git.viper.ipv64.net/M_Viper/PulseCast/
|
Plugin URI: https://git.viper.ipv64.net/M_Viper/PulseCast/
|
||||||
* Description: Sende Broadcasts (sofort oder geplant) an deine StatusAPI direkt aus dem WordPress-Backend. Flexibel für Homenetzwerk, externe Server und gemischte Setups.
|
Description: Sende Broadcasts (sofort oder geplant) an deine StatusAPI direkt aus dem WordPress-Backend. Flexibel für Homenetzwerk, externe Server und gemischte Setups.
|
||||||
* Version: 1.0.3
|
Version: 1.0.3
|
||||||
* Author: M_Viper
|
Author: M_Viper
|
||||||
* Author URI: https://m-viper.de
|
Author URI: https://m-viper.de
|
||||||
*/
|
Requires at least: 6.8
|
||||||
|
Tested up to: 6.8
|
||||||
|
PHP Version: 7.4
|
||||||
|
License: GPL2
|
||||||
|
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
Text Domain: pulsecast
|
||||||
|
Tags: broadcast, statusapi, wordpress, backend, scheduling, network, server, flexible
|
||||||
|
Support: [Discord Support](https://discord.com/invite/FdRs4BRd8D)
|
||||||
|
Support: [Telegram Support](https://t.me/M_Viper04)
|
||||||
|
*/
|
||||||
|
|
||||||
if (!defined('ABSPATH')) exit;
|
if (!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
@@ -220,6 +229,9 @@ class PulseCast {
|
|||||||
|
|
||||||
$settings = get_option(self::OPTION_KEY, []);
|
$settings = get_option(self::OPTION_KEY, []);
|
||||||
$schedules = get_option(self::SCHEDULES_KEY, []);
|
$schedules = get_option(self::SCHEDULES_KEY, []);
|
||||||
|
$wp_tz = wp_timezone();
|
||||||
|
$tz_name = $wp_tz->getName();
|
||||||
|
$tz_offset = $wp_tz->getOffset(new DateTime('now')) / 3600;
|
||||||
|
|
||||||
// Automatische Status-Aktualisierung beim Seitenladen
|
// Automatische Status-Aktualisierung beim Seitenladen
|
||||||
$this->auto_refresh_status();
|
$this->auto_refresh_status();
|
||||||
@@ -248,6 +260,16 @@ class PulseCast {
|
|||||||
if (isset($_GET['pulsecast_error'])) {
|
if (isset($_GET['pulsecast_error'])) {
|
||||||
echo '<div class="notice notice-error is-dismissible pulsecast-auto-dismiss"><p>' . esc_html(urldecode($_GET['pulsecast_error'])) . '</p></div>';
|
echo '<div class="notice notice-error is-dismissible pulsecast-auto-dismiss"><p>' . esc_html(urldecode($_GET['pulsecast_error'])) . '</p></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warnung wenn Zeitzone auf UTC steht
|
||||||
|
if ($tz_offset == 0) {
|
||||||
|
?>
|
||||||
|
<div class="notice notice-warning">
|
||||||
|
<p><strong>⚠️ PulseCast Zeitzone:</strong> Deine WordPress-Zeitzone ist aktuell auf <strong><?php echo esc_html($tz_name); ?></strong> eingestellt.</p>
|
||||||
|
<p>Dadurch werden "Lokale Zeit" und "UTC" als gleich angezeigt. Bitte gehe zu <a href="<?php echo admin_url('options-general.php'); ?>">Einstellungen > Allgemein</a> und wähle deine Stadt (z.B. Berlin), damit die Umrechnung korrekt funktioniert.</p>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
$current_server_time = current_time('Y-m-d H:i:s');
|
$current_server_time = current_time('Y-m-d H:i:s');
|
||||||
$current_utc_time = gmdate('Y-m-d H:i:s');
|
$current_utc_time = gmdate('Y-m-d H:i:s');
|
||||||
@@ -259,12 +281,12 @@ class PulseCast {
|
|||||||
<h1>PulseCast — Broadcasts</h1>
|
<h1>PulseCast — Broadcasts</h1>
|
||||||
|
|
||||||
<div class="notice notice-info">
|
<div class="notice notice-info">
|
||||||
<p><strong>Aktuelle Zeit (Server-Zeitzone):</strong> <?php echo esc_html($current_server_time); ?></p>
|
<p><strong>Aktuelle Zeit (WordPress-Zeitzone: <?php echo esc_html($tz_name); ?>):</strong> <?php echo esc_html($current_server_time); ?></p>
|
||||||
<p><strong>Aktuelle Zeit (UTC):</strong> <?php echo esc_html($current_utc_time); ?></p>
|
<p><strong>Aktuelle Zeit (UTC):</strong> <?php echo esc_html($current_utc_time); ?></p>
|
||||||
<?php if (!empty($current_api_url)): ?>
|
<?php if (!empty($current_api_url)): ?>
|
||||||
<p><strong>API Endpoint:</strong> <code><?php echo esc_html($current_api_url); ?></code></p>
|
<p><strong>API Endpoint:</strong> <code><?php echo esc_html($current_api_url); ?></code></p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<p class="description">Zeitgeplante Broadcasts werden in UTC an die StatusAPI gesendet.</p>
|
<p class="description">Zeitgeplante Broadcasts werden in UTC an die StatusAPI gesendet, aber hier in deiner Lokalzeit angezeigt.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>Einstellungen</h2>
|
<h2>Einstellungen</h2>
|
||||||
@@ -516,7 +538,7 @@ class PulseCast {
|
|||||||
<td><textarea name="sched_message" id="sched_message" rows="3" class="large-text" required></textarea></td>
|
<td><textarea name="sched_message" id="sched_message" rows="3" class="large-text" required></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><label for="sched_time">Zeit (YYYY-MM-DD HH:MM, Server-Zeitzone)</label></th>
|
<th><label for="sched_time">Zeit (YYYY-MM-DD HH:MM, <?php echo esc_html($tz_name); ?>)</label></th>
|
||||||
<td>
|
<td>
|
||||||
<input name="sched_time" id="sched_time" type="datetime-local" class="regular-text" required>
|
<input name="sched_time" id="sched_time" type="datetime-local" class="regular-text" required>
|
||||||
<p class="description">Beispiel: <?php echo esc_html(date('Y-m-d\TH:i', strtotime('+1 hour'))); ?> (in einer Stunde)</p>
|
<p class="description">Beispiel: <?php echo esc_html(date('Y-m-d\TH:i', strtotime('+1 hour'))); ?> (in einer Stunde)</p>
|
||||||
@@ -564,11 +586,29 @@ class PulseCast {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="widefat">
|
<table class="widefat">
|
||||||
<thead><tr><th>ID</th><th>Nachricht</th><th>Sendezeit (Lokal)</th><th>Sendezeit (UTC)</th><th>Status</th><th>Wiederholung</th><th>Aktionen</th></tr></thead>
|
<thead><tr><th>ID</th><th>Nachricht</th><th>Endzeit (Lokal)</th><th>Sendezeit (UTC)</th><th>Status</th><th>Wiederholung</th><th>Aktionen</th></tr></thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($schedules as $id => $s):
|
<?php foreach ($schedules as $id => $s):
|
||||||
$local_time = get_date_from_gmt(gmdate('Y-m-d H:i:s', $s['time']), 'Y-m-d H:i:s');
|
// --- FIX: EXPLIZITE DATUMSKONVERTIERUNG ---
|
||||||
$utc_time = gmdate('Y-m-d H:i:s', $s['time']);
|
// Wir nehmen an, dass $s['time'] ein UTC Timestamp ist
|
||||||
|
|
||||||
|
// 1. Lokale Zeit berechnen (UTC Timestamp -> WP Timezone)
|
||||||
|
try {
|
||||||
|
$date_local = new DateTime('@' . $s['time']);
|
||||||
|
$date_local->setTimezone($wp_tz);
|
||||||
|
$local_time = $date_local->format('Y-m-d H:i:s');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$local_time = 'Fehler';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. UTC Zeit berechnen (UTC Timestamp -> UTC)
|
||||||
|
try {
|
||||||
|
$date_utc = new DateTime('@' . $s['time']);
|
||||||
|
$utc_time = $date_utc->format('Y-m-d H:i:s');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$utc_time = 'Fehler';
|
||||||
|
}
|
||||||
|
|
||||||
$now = time();
|
$now = time();
|
||||||
$scheduled_time = $s['time'];
|
$scheduled_time = $s['time'];
|
||||||
$time_diff = $now - $scheduled_time;
|
$time_diff = $now - $scheduled_time;
|
||||||
|
|||||||
Reference in New Issue
Block a user