// lastpostings 0.3.P: VERSION FÜR POSTGRESQL // Hubzilla-Umgebung laden require_once '/var/www/klacker.org/boot.php'; require_once '/var/www/klacker.org/include/bbcode.php'; // Für bbcode() // Kanal-ID und -name ermitteln $channel_id = isset($_SESSION['uid']) ? intval($_SESSION['uid']) : 59; $channel_name = isset($a->channel['channel_name']) ? $a->channel['channel_name'] : 'tutorial01'; // SQL-Abfrage: Nur eigene Postings (item_origin=1) mit mimetype='text/bbcode' $sql = sprintf( "SELECT id, mid, title, body FROM item WHERE uid = %d AND item_origin = 1 AND verb IN ('Create', 'Announce') AND mimetype = 'text/bbcode' ORDER BY id DESC LIMIT %d", intval($channel_id), 3 // Anzahl der anzuzeigenden Postings ); $result = q($sql); // Ergebnisse verarbeiten $items = []; if (is_array($result)) { $items = $result; } elseif ($result && property_exists($result, 'num_rows') && $result->num_rows > 0) { while ($item = $result->fetch()) { $items[] = $item; } } // Ausgabe if (!empty($items)) { echo '
'; foreach ($items as $item) { $title = htmlspecialchars($item['title'] ?? '', ENT_QUOTES, 'UTF-8'); $body = bbcode($item['body'] ?? ''); // BBCode → HTML $summary = mb_substr($body, 0, 512, 'UTF-8'); if (mb_strlen($body, 'UTF-8') > 512) { $summary .= '…'; } // UUID aus der mid-URL extrahieren $mid = basename($item['mid'] ?? ''); // Link zum Posting: /channel/[Kanalname]?mid=[UUID] $read_more_link = '..::Weiterlesen::..'; echo '
'; if ($title) { echo '
' . $title . '
'; } echo '

' . $summary . '

'; echo $read_more_link; echo '
'; } echo '
'; } else { echo '

Keine Beiträge gefunden.

'; }