From f5cf66b6929928fe5a4a6cf227f9a2f2195329e5 Mon Sep 17 00:00:00 2001 From: Horus3 Date: Sun, 3 Jul 2016 18:07:29 +0200 Subject: Initial commit. --- .gitignore | 6 ++++ bootstrap.php | 6 ++++ composer.json | 6 ++++ composer.lock | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ feed.php | 42 +++++++++++++++++++++++ imap.php | 69 +++++++++++++++++++++++++++++++++++++ index.php | 11 ++++++ 7 files changed, 247 insertions(+) create mode 100644 .gitignore create mode 100644 bootstrap.php create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 feed.php create mode 100644 imap.php create mode 100644 index.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2888d2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.swp +*~ +*.db +*.xml + +vendor/ diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..68af7d0 --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,6 @@ +=5.3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpImap\\": "src/PhpImap/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD 3-Clause" + ], + "authors": [ + { + "name": "Sergey Barbushin", + "email": "barbushin@gmail.com", + "homepage": "http://linkedin.com/in/barbushin" + } + ], + "description": "PHP class to access mailbox by POP3/IMAP/NNTP using IMAP extension", + "homepage": "https://github.com/barbushin/php-imap", + "keywords": [ + "imap", + "mail", + "php" + ], + "time": "2015-12-14 02:46:12" + }, + { + "name": "suin/php-rss-writer", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/suin/php-rss-writer.git", + "reference": "a7dd2bbc287a05b266406d3afa298d44ebf115f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/suin/php-rss-writer/zipball/a7dd2bbc287a05b266406d3afa298d44ebf115f3", + "reference": "a7dd2bbc287a05b266406d3afa298d44ebf115f3", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Suin\\RSSWriter": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Hidehito Nozawa aka Suin", + "email": "suinyeze@gmail.com" + } + ], + "description": "Yet another simple RSS writer library for PHP 5.4 or later.", + "homepage": "https://github.com/suin/php-rss-writer", + "keywords": [ + "feed", + "generator", + "php", + "rss", + "writer" + ], + "time": "2016-03-19 06:15:37" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/feed.php b/feed.php new file mode 100644 index 0000000..b1f7630 --- /dev/null +++ b/feed.php @@ -0,0 +1,42 @@ +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( "
" . $body . "
" ) + #->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(); +} diff --git a/imap.php b/imap.php new file mode 100644 index 0000000..191447c --- /dev/null +++ b/imap.php @@ -0,0 +1,69 @@ +searchMailbox('ALL'); + if(!$mailsIds) { + #throw new Exception('Mailbox is empty'); + return false; + } + + $return = array(); + + if ( (count($mailsIds) - $max_items) < 0) { + $limit = 0; + } else { + $limit = count($mailsIds) - $max_items; + } + + $cnt = 0; + for( $i = count($mailsIds) - 1; $i >= $limit; $i-- ) { + $mbox = $mailbox->getMail($mailsIds[$i], $markAsSeen = false); + $return[$cnt]["date"] = $mbox->date; + $return[$cnt]["subject"] = $mbox->subject; + $return[$cnt]["fromName"] = $mbox->fromName; + $return[$cnt]["fromAddress"] = $mbox->fromAddress; + $return[$cnt]["to"] = $mbox->to; + $return[$cnt]["toString"] = $mbox->toString; + $return[$cnt]["messageId"] = $mbox->messageId; + $return[$cnt]["textPlain"] = $mbox->textPlain; + $return[$cnt]["textHtml"] = $mbox->textHtml; + $return[$cnt]["mailbox"] = $inbox; + $cnt++; + } + return $return; +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..b40b8e1 --- /dev/null +++ b/index.php @@ -0,0 +1,11 @@ +