aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boot.php2
-rw-r--r--include/enotify.php170
-rw-r--r--include/items.php14
-rw-r--r--mod/profile.php12
-rw-r--r--view/email_notify_html.tpl26
-rw-r--r--view/email_notify_text.tpl11
-rw-r--r--view/en/mail_received_html_body_eml.tpl2
7 files changed, 232 insertions, 5 deletions
diff --git a/boot.php b/boot.php
index 6c94fb132..354b51a94 100644
--- a/boot.php
+++ b/boot.php
@@ -830,7 +830,7 @@ function profile_load(&$a, $nickname, $profile = 0) {
}
if(($r === false) || (! count($r))) {
- notice( t('No profile') . EOL );
+ notice( t('Requested profile is not available.') . EOL );
$a->error = 404;
return;
}
diff --git a/include/enotify.php b/include/enotify.php
new file mode 100644
index 000000000..11a5d70dd
--- /dev/null
+++ b/include/enotify.php
@@ -0,0 +1,170 @@
+<?php
+
+
+ // send email notification if requested.
+/*
+ $notif_params = array(
+ 'type' => NOTIFY_MAIL,
+ 'notify_flags' => $importer['notify_flags'],
+ 'language' => $importer['language'],
+ 'to_name' => $importer['username'],
+ 'to_email' => $importer['email'],
+ 'item' => $msg,
+ 'source_name' => $msg['from-name'],
+ 'source_link' => $importer['url'],
+ 'source_photo' => $importer['thumb'],
+ );
+*/
+ //notification($notif_params);
+
+
+function notification($params) {
+
+ $a = get_app();
+ $banner = t('Friendica Notification');
+ $product = FRIENDICA_PLATFORM;
+ $siteurl = z_path();
+ $thanks = t('Thank You,');
+ $sitename = get_config('config','sitename');
+ $site_admin = sprintf( t('%s Administrator'), $sitename);
+
+ $sender_name = t('Administrator');
+ $sender_email = t('noreply') . '@' . $a->get_hostname();
+
+ $title = $params['item']['title'];
+ $body = $params['item']['body'];
+
+ if($params['type'] == NOTIFY_MAIL) {
+
+ $subject = sprintf( t('New mail received at %s'),$sitename);
+
+ $preamble = sprintf( t('%s sent you a new private message at %s.'),$params['source_name'],$sitename);
+ $sitelink = t('Please visit %s to view and/or reply to your private messages.');
+ $tsitelink = sprintf( $email_visit, $siteurl . '/message' );
+ $hsitelink = sprintf( $email_visit, '<a href="' . $siteurl . '/message">' . $sitename . '</a>');
+
+ }
+
+
+ // send email notification if notification preferences permit
+
+ require_once('bbcode.php');
+ if(intval($params['notify-flags']) & intval($params['type'])) {
+
+ push_lang($params['language']);
+
+ $msg = array();
+ $msg['fromname'] = $sender_name;
+ $msg['fromemail'] = $sender_email;
+
+ $msg['textversion'] = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
+ $body))),ENT_QUOTES,'UTF-8'));
+ $msg['htmlversion'] = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
+ "<br />\n",$body))));
+
+ // load the template for private message notifications
+ $tpl = get_view_template('email_notify_html.tpl');
+ $email_html_body_tpl = replace_macros($tpl,array(
+ '$banner' => $banner,
+ '$product' => $product,
+ '$preamble' => $preamble,
+ '$source_name' => $parama['source_name'],
+ '$source_link' => $params['source_link'],
+ '$source_photo' => $params['source_photo'],
+ '$username' => $params['to_name'],
+ '$hsitelink' => $hsitelink,
+ '$thanks' => $thanks,
+ '$site_admin' => $site_admin,
+ '$title' => stripslashes($msg['title']), // subject of the message
+ '$htmlversion' => $msg['htmlversion'], // html version of the message
+
+ ));
+
+ // load the template for private message notifications
+ $tpl = get_intltext_template('mail_received_text_body_eml.tpl');
+ $email_text_body_tpl = replace_macros($tpl,array(
+ '$username' => $importer['username'],
+ '$siteName' => $a->config['sitename'], // name of this site
+ '$siteurl' => $a->get_baseurl(), // descriptive url of this site
+ '$thumb' => $importer['thumb'], // thumbnail url for sender icon
+ '$email' => $importer['email'], // email address to send to
+ '$url' => $importer['url'], // full url for the site
+ '$from' => $msg['from-name'], // name of the person sending the message
+ '$title' => stripslashes($msg['title']), // subject of the message
+ '$textversion' => $msg['textversion'], // text version of the message
+ '$mimeboundary' => $msg['mimeboundary'], // mime message divider
+ '$hostname' => $a->get_hostname() // name of this host
+ ));
+
+ // use the EmailNotification library to send the message
+ require_once("include/EmailNotification.php");
+ EmailNotification::sendTextHtmlEmail(
+ $msg['notificationfromname'],
+ $msg['notificationfromemail'],
+ $msg['notificationfromemail'],
+ $importer['email'],
+ $subject,
+ $email_html_body_tpl,
+ $email_text_body_tpl
+ );
+ pop_lang();
+ }
+}
+
+require_once('include/email.php');
+
+class enotify {
+ /**
+ * Send a multipart/alternative message with Text and HTML versions
+ *
+ * @param fromName name of the sender
+ * @param fromEmail email fo the sender
+ * @param replyTo replyTo address to direct responses
+ * @param toEmail destination email address
+ * @param messageSubject subject of the message
+ * @param htmlVersion html version of the message
+ * @param textVersion text only version of the message
+ */
+ static public function send($params) {
+ $fromName = email_header_encode($params['fromName'],'UTF-8');
+ $messageSubject = email_header_encode($params['messageSubject'],'UTF-8');
+
+
+ // generate a mime boundary
+ $mimeBoundary =rand(0,9)."-"
+ .rand(10000000000,9999999999)."-"
+ .rand(10000000000,9999999999)."=:"
+ .rand(10000,99999);
+
+ // generate a multipart/alternative message header
+ $messageHeader =
+ "From: {$params['fromName']} <{$params['fromEmail']}>\n" .
+ "Reply-To: {$params['replyTo']}\n" .
+ "MIME-Version: 1.0\n" .
+ "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
+
+ // assemble the final multipart message body with the text and html types included
+ $textBody = chunk_split(base64_encode($params['textVersion']));
+ $htmlBody = chunk_split(base64_encode($params['htmlVersion']));
+ $multipartMessageBody =
+ "--" . $mimeBoundary . "\n" . // plain text section
+ "Content-Type: text/plain; charset=UTF-8\n" .
+ "Content-Transfer-Encoding: base64\n\n" .
+ $textBody . "\n" .
+ "--" . $mimeBoundary . "\n" . // text/html section
+ "Content-Type: text/html; charset=UTF-8\n" .
+ "Content-Transfer-Encoding: base64\n\n" .
+ $htmlBody . "\n" .
+ "--" . $mimeBoundary . "--\n"; // message ending
+
+ // send the message
+ $res = mail(
+ $toEmail, // send to address
+ $messageSubject, // subject
+ $multipartMessageBody, // message body
+ $messageHeader // message headers
+ );
+ logger("sendTextHtmlEmail: returns " . $res, LOGGER_DEBUG);
+ }
+}
+?> \ No newline at end of file
diff --git a/include/items.php b/include/items.php
index 50c5e56c1..4666211d8 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1824,6 +1824,20 @@ function local_delivery($importer,$data) {
// send email notification if requested.
+ $notif_params = array(
+ 'type' => NOTIFY_MAIL,
+ 'notify_flags' => $importer['notify_flags'],
+ 'language' => $importer['language'],
+ 'to_name' => $importer['username'],
+ 'to_email' => $importer['email'],
+ 'item' => $msg,
+ 'source_name' => $msg['from-name'],
+ 'source_link' => $importer['url'],
+ 'source_photo' => $importer['thumb'],
+ );
+
+ //notification($notif_params);
+
require_once('bbcode.php');
if($importer['notify-flags'] & NOTIFY_MAIL) {
diff --git a/mod/profile.php b/mod/profile.php
index d2f9d7e29..946499895 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -7,9 +7,15 @@ function profile_init(&$a) {
if($a->argc > 1)
$which = $a->argv[1];
else {
- notice( t('No profile') . EOL );
- $a->error = 404;
- return;
+ $r = q("select nickname from user where blocked = 0 and account_expired = 0 and verified = 1 order by rand() limit 1");
+ if(count($r)) {
+ $which = $r[0]['nickname'];
+ }
+ else {
+ notice( t('Requested profile is not available.') . EOL );
+ $a->error = 404;
+ return;
+ }
}
$profile = 0;
diff --git a/view/email_notify_html.tpl b/view/email_notify_html.tpl
new file mode 100644
index 000000000..ab449de52
--- /dev/null
+++ b/view/email_notify_html.tpl
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional //EN">
+<html>
+<head>
+ <title>$banner</title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+</head>
+<body>
+<table style="border:1px solid #ccc">
+ <tbody>
+ <tr><td colspan="2" style="background:#084769; color:#FFFFFF; font-weight:bold; font-family:'lucida grande', tahoma, verdana,arial, sans-serif; padding: 4px 8px; vertical-align: middle; font-size:16px; letter-spacing: -0.03em; text-align: left;"><img style="width:32px;height:32px; float:left;" src='$siteurl/images/friendica-32.png'><div style="padding:7px; margin-left: 5px; float:left; font-size:18px;letter-spacing:1px;">$product</div><div style="clear: both;"></div></td></tr>
+
+
+ <tr><td style="padding-top:22px;" colspan="2">$preamble</td></tr>
+
+
+ <tr><td style="padding-left:22px;padding-top:22px;width:60px;" valign="top" rowspan=3><a href="$source_link"><img style="border:0px;width:48px;height:48px;" src="$source_photo"></a></td>
+ <td style="padding-top:22px;"><a href="$source_link">$source_name</a></td></tr>
+ <tr><td style="font-weight:bold;padding-bottom:5px;">$title</td></tr>
+ <tr><td style="padding-right:22px;">$htmlversion</td></tr>
+ <tr><td style="padding-top:11px;padding-bottom:11px;" colspan="2">$hsitelink</td></tr>
+ <tr><td></td><td>$thanks</td></tr>
+ <tr><td></td><td>$site_admin</td></tr>
+ </tbody>
+</table>
+</body>
+</html>
diff --git a/view/email_notify_text.tpl b/view/email_notify_text.tpl
new file mode 100644
index 000000000..450adc1d4
--- /dev/null
+++ b/view/email_notify_text.tpl
@@ -0,0 +1,11 @@
+$preamble
+
+$title
+
+$textversion
+
+$tsitelink
+
+$thanks
+$site_admin
+
diff --git a/view/en/mail_received_html_body_eml.tpl b/view/en/mail_received_html_body_eml.tpl
index 23d9ac4c2..bd105a61b 100644
--- a/view/en/mail_received_html_body_eml.tpl
+++ b/view/en/mail_received_html_body_eml.tpl
@@ -17,7 +17,7 @@
<td style="padding-top:22px;"><a href="$url">$from</a></td></tr>
<tr><td style="font-weight:bold;padding-bottom:5px;">$title</td></tr>
<tr><td style="padding-right:22px;">$htmlversion</td></tr>
- <tr><td style="padding-top:11px;padding-bottom:11px;" colspan="2">Please login at <a href="$siteurl">$siteurl</a> to read and reply to your private messages.</td></tr>
+ <tr><td style="padding-top:11px;padding-bottom:11px;" colspan="2">Please login at <a href="$siteurl/message">$siteurl/message</a> to read and reply to your private messages.</td></tr>
<tr><td></td><td>Thank You,</td></tr>
<tr><td></td><td>$siteName Administrator</td></tr>
</tbody>