summaryrefslogtreecommitdiff
path: root/feed.php
diff options
context:
space:
mode:
Diffstat (limited to 'feed.php')
-rw-r--r--feed.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/feed.php b/feed.php
new file mode 100644
index 0000000..b1f7630
--- /dev/null
+++ b/feed.php
@@ -0,0 +1,42 @@
+<?php
+use Suin\RSSWriter\Channel;
+use Suin\RSSWriter\Feed;
+use Suin\RSSWriter\Item;
+
+function generate_feed($mail, $user_string, $inbox_string) {
+ $feed = new Feed();
+
+ $channel = new Channel();
+ $channel
+ ->title(htmlspecialchars($user_string . " / " . $inbox_string, ENT_XML1, 'UTF-8'))
+ ->description($inbox_string)
+ ->url("https://www.maxmail.xyz")
+ ->language('en-US')
+ ->copyright('Copyright 2016, maxmail.xyz')
+ ->pubDate(strtotime("r", date(time())))
+ ->lastBuildDate(strtotime("r", date(time())))
+ ->ttl(60)
+ ->appendTo($feed);
+
+ for( $i = 0; $i < count($mail); $i++ ) {
+ $item = new Item();
+
+ if( is_null($mail[$i]['textPlain']) ) {
+ $body = $mail[$i]['textHtml'];
+ } else {
+ $body = $mail[$i]['textPlain'];
+ }
+ $item
+ ->title( htmlspecialchars($mail[$i]["mailbox"] . ": " . $mail[$i]['subject'], ENT_XML1, 'UTF-8') )
+ ->description( "<pre>" . $body . "</pre>" )
+ #->description($body)
+ ->url("https://www.maxmail.xyz/" . $user_string)
+ ->author( htmlspecialchars($mail[$i]['fromName'] . "<" . $mail[$i]['fromAddress'] . ">", ENT_XML1, 'UTF-8') )
+ ->pubDate( strtotime($mail[$i]['date'] ) )
+ ->appendTo($channel);
+ }
+
+ ob_start();
+ echo $feed;
+ return ob_get_clean();
+}