aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMichael <icarus@dabo.de>2012-02-19 20:09:42 +0100
committerMichael <icarus@dabo.de>2012-02-19 20:09:42 +0100
commitcafd4003522a472d2709569ea5eb5f80b817af23 (patch)
treebbd512126515afc929de06dce79ba847b9681092 /include
parent73e0e4d78341cb96ef9665a0ee4fb7e7ee2a701f (diff)
parenta9ed5915cebcf51347acaad51d0c252e57bceaff (diff)
downloadvolse-hubzilla-cafd4003522a472d2709569ea5eb5f80b817af23.tar.gz
volse-hubzilla-cafd4003522a472d2709569ea5eb5f80b817af23.tar.bz2
volse-hubzilla-cafd4003522a472d2709569ea5eb5f80b817af23.zip
Merge remote branch 'upstream/master'
Conflicts: view/theme/vier/style.css
Diffstat (limited to 'include')
-rwxr-xr-xinclude/attach.php14
-rwxr-xr-xinclude/auth.php2
-rwxr-xr-xinclude/bb2diaspora.php15
-rwxr-xr-xinclude/bbcode.php85
-rwxr-xr-xinclude/conversation.php254
-rwxr-xr-xinclude/datetime.php9
-rwxr-xr-xinclude/delivery.php22
-rwxr-xr-xinclude/diaspora.php31
-rwxr-xr-xinclude/enotify.php60
-rwxr-xr-xinclude/expire.php5
-rwxr-xr-xinclude/items.php107
-rwxr-xr-xinclude/network.php3
-rwxr-xr-xinclude/notifier.php24
-rwxr-xr-xinclude/oembed.php2
-rwxr-xr-xinclude/plugin.php38
-rwxr-xr-xinclude/poller.php4
-rwxr-xr-xinclude/profile_advanced.php2
-rwxr-xr-xinclude/text.php103
18 files changed, 556 insertions, 224 deletions
diff --git a/include/attach.php b/include/attach.php
index 4001d2af1..6d611cec0 100755
--- a/include/attach.php
+++ b/include/attach.php
@@ -38,6 +38,7 @@ function z_mime_content_type($filename) {
// audio/video
'mp3' => 'audio/mpeg',
+ 'wav' => 'audio/wav',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'ogg' => 'application/ogg',
@@ -68,12 +69,13 @@ function z_mime_content_type($filename) {
return $mime_types[$ext];
}
}
- elseif (function_exists('finfo_open')) {
- $finfo = finfo_open(FILEINFO_MIME);
- $mimetype = finfo_file($finfo, $filename);
- finfo_close($finfo);
- return $mimetype;
- }
+// can't use this because we're just passing a name, e.g. not a file that can be opened
+// elseif (function_exists('finfo_open')) {
+// $finfo = @finfo_open(FILEINFO_MIME);
+// $mimetype = @finfo_file($finfo, $filename);
+// @finfo_close($finfo);
+// return $mimetype;
+// }
else {
return 'application/octet-stream';
}
diff --git a/include/auth.php b/include/auth.php
index fd1c63847..fc52684e6 100755
--- a/include/auth.php
+++ b/include/auth.php
@@ -165,7 +165,7 @@ else {
}
if((! $record) || (! count($record))) {
- logger('authenticate: failed login attempt: ' . trim($_POST['username']));
+ logger('authenticate: failed login attempt: ' . notags(trim($_POST['username'])));
notice( t('Login failed.') . EOL );
goaway(z_root());
}
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index d367b6716..c26b0c334 100755
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -14,9 +14,17 @@ require_once('include/html2bbcode.php');
function diaspora2bb($s) {
$s = html_entity_decode($s,ENT_COMPAT,'UTF-8');
+ $s = str_replace("\r","\n",$s);
$s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s);
+
+ $s = preg_replace('/\#([^\s\#])/','\\#$1',$s);
+
$s = Markdown($s);
+
+ $s = str_replace('&#35;','#',$s);
+ $s = str_replace("\n",'<br />',$s);
+
$s = html2bbcode($s);
// $s = str_replace('&#42;','*',$s);
@@ -30,11 +38,6 @@ function diaspora2bb($s) {
$s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s);
$s = scale_diaspora_images($s);
- // we seem to get a lot of text smushed together with links from Diaspora.
-
- $s = preg_replace('/[^ ]\[url\=(.*?)\]/',' [url=$1]' ,$s);
- $s = preg_replace('/\[\/url\][^ ]/','[/url] ',$s);
-
return $s;
}
@@ -209,7 +212,7 @@ function bb2diaspora($Text,$preserve_nl = false) {
$Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", 'http://vimeo.com/$1',$Text);
-
+ $Text = str_replace('[nosmile]','',$Text);
// oembed tag
// $Text = oembed_bbcode2html($Text);
diff --git a/include/bbcode.php b/include/bbcode.php
index 6b733c8f4..cae867eb8 100755
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -11,7 +11,7 @@ function stripcode_br_cb($s) {
function tryoembed($match){
$url = ((count($match)==2)?$match[1]:$match[2]);
- logger("tryoembed: $url");
+// logger("tryoembed: $url");
$o = oembed_fetch_url($url);
@@ -24,13 +24,40 @@ function tryoembed($match){
}
+// [noparse][i]italic[/i][/noparse] turns into
+// [noparse][ i ]italic[ /i ][/noparse],
+// to hide them from parser.
+function bb_spacefy($st) {
+ $whole_match = $st[0];
+ $captured = $st[1];
+ $spacefied = preg_replace("/\[(.*?)\]/", "[ $1 ]", $captured);
+ $new_str = str_replace($captured, $spacefied, $whole_match);
+ return $new_str;
+}
+
+// The previously spacefied [noparse][ i ]italic[ /i ][/noparse],
+// now turns back and the [noparse] tags are trimed
+// returning [i]italic[/i]
+
+function bb_unspacefy_and_trim($st) {
+ $whole_match = $st[0];
+ $captured = $st[1];
+ $unspacefied = preg_replace("/\[ (.*?)\ ]/", "[$1]", $captured);
+ return $unspacefied;
+}
// BBcode 2 HTML was written by WAY2WEB.net
// extended to work with Mistpark/Friendica - Mike Macgirvin
function bbcode($Text,$preserve_nl = false) {
+ // Hide all [noparse] contained bbtags spacefying them
+
+ $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_spacefy',$Text);
+ $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_spacefy',$Text);
+ $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text);
+
// Extract a single private image which uses data url's since preg has issues with
// large data sizes. Stash it away while we do bbcode conversion, and then put it back
@@ -111,25 +138,34 @@ function bbcode($Text,$preserve_nl = false) {
$Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])ism","<span style=\"color: $1;\">$2</span>",$Text);
// Check for sized text
+ // [size=50] --> font-size: 50px (with the unit).
+ $Text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1px;\">$2</span>",$Text);
$Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1;\">$2</span>",$Text);
- // Check for list text
-
- if(stristr($Text,'[/list]'))
- $Text = str_replace("[*]", "<li>", $Text);
+ // Check for centered text
+ $Text = preg_replace("(\[center\](.*?)\[\/center\])ism","<div style=\"text-align:center;\">$1</div>",$Text);
- if(stristr($Text,'[/list]'))
- $Text = str_replace("[*]", "<li>", $Text);
+ // Check for list text
+ $Text = str_replace("[*]", "<li>", $Text);
+ $Text = preg_replace("/\[li\](.*?)\[\/li\]/ism", '<li>$1</li>' ,$Text);
$Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>' ,$Text);
+ $Text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>'
+,$Text);
$Text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '<ul class="listnone" style="list-style-type: none;">$1</ul>' ,$Text);
$Text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=i\](.*?)\[\/list\]/sm",'<ul class="listlowerroman" style="list-style-type: lower-roman;">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=I\](.*?)\[\/list\]/sm", '<ul class="listupperroman" style="list-style-type: upper-roman;">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=a\](.*?)\[\/list\]/sm", '<ul class="listloweralpha" style="list-style-type: lower-alpha;">$1</ul>' ,$Text);
- $Text = preg_replace("/\[list=A\](.*?)\[\/list\]/sm", '<ul class="listupperalpha" style="list-style-type: upper-alpha;">$1</ul>' ,$Text);
- $Text = preg_replace("/\[li\](.*?)\[\/li\]/sm", '<li>$1</li>' ,$Text);
-
+ $Text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>'
+,$Text);
+ $Text = preg_replace("/\[list=((?-i)i)\](.*?)\[\/list\]/ism",'<ul class="listlowerroman" style="list-style-type:
+lower-roman;">$2</ul>' ,$Text);
+ $Text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '<ul class="listupperroman" style="list-style-type:
+upper-roman;">$2</ul>' ,$Text);
+ $Text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '<ul class="listloweralpha" style="list-style-type:
+lower-alpha;">$2</ul>' ,$Text);
+ $Text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '<ul class="listupperalpha" style="list-style-type:
+upper-alpha;">$2</ul>' ,$Text);
+
+ $Text = preg_replace("/\[th\](.*?)\[\/th\]/sm", '<th>$1</th>' ,$Text);
$Text = preg_replace("/\[td\](.*?)\[\/td\]/sm", '<td>$1</td>' ,$Text);
$Text = preg_replace("/\[tr\](.*?)\[\/tr\]/sm", '<tr>$1</tr>' ,$Text);
$Text = preg_replace("/\[table\](.*?)\[\/table\]/sm", '<table>$1</table>' ,$Text);
@@ -137,7 +173,11 @@ function bbcode($Text,$preserve_nl = false) {
$Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/sm", '<table border="1" >$1</table>' ,$Text);
$Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/sm", '<table border="0" >$1</table>' ,$Text);
-
+ $Text = str_replace('[hr]','<hr />', $Text);
+
+ // This is actually executed in prepare_body()
+
+ $Text = str_replace('[nosmile]','',$Text);
// Check for font change text
$Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm","<span style=\"font-family: $1;\">$2</span>",$Text);
@@ -157,7 +197,15 @@ function bbcode($Text,$preserve_nl = false) {
$QuoteLayout = '<blockquote>$1</blockquote>';
// Check for [quote] text
$Text = preg_replace("/\[quote\](.*?)\[\/quote\]/ism","$QuoteLayout", $Text);
-
+
+ // Check for [quote=Author] text
+
+ $t_wrote = t('$1 wrote:');
+
+ $Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
+ "<blockquote><strong>" . $t_wrote . "</strong> $2</blockquote>",
+ $Text);
+
// [img=widthxheight]image source[/img]
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
@@ -219,6 +267,13 @@ function bbcode($Text,$preserve_nl = false) {
$Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text);
}
+ // Unhide all [noparse] contained bbtags unspacefying them
+ // and triming the [noparse] tag.
+
+ $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_unspacefy_and_trim',$Text);
+ $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_unspacefy_and_trim',$Text);
+ $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_unspacefy_and_trim',$Text);
+
// fix any escaped ampersands that may have been converted into links
$Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
if(strlen($saved_image))
diff --git a/include/conversation.php b/include/conversation.php
index 20c7b2a51..3d13a1179 100755
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -4,6 +4,28 @@
* Render actions localized
*/
function localize_item(&$item){
+
+ $Text = $item['body'];
+ $saved_image = '';
+ $img_start = strpos($Text,'[img]data:');
+ $img_end = strpos($Text,'[/img]');
+
+ if($img_start !== false && $img_end !== false && $img_end > $img_start) {
+ $start_fragment = substr($Text,0,$img_start);
+ $img_start += strlen('[img]');
+ $saved_image = substr($Text,$img_start,$img_end - $img_start);
+ $end_fragment = substr($Text,$img_end + strlen('[/img]'));
+ $Text = $start_fragment . '[!#saved_image#!]' . $end_fragment;
+ $search = '/\[url\=(.*?)\]\[!#saved_image#!\]\[\/url\]' . '/is';
+ $replace = '[url=' . z_path() . '/redir/' . $item['contact-id']
+ . '?f=1&url=' . '$1' . '][!#saved_image#!][/url]' ;
+
+ $Text = preg_replace($search,$replace,$Text);
+
+ if(strlen($saved_image))
+ $item['body'] = str_replace('[!#saved_image#!]', '[img]' . $saved_image . '[/img]',$Text);
+ }
+
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
if ($item['verb']=== ACTIVITY_LIKE || $item['verb']=== ACTIVITY_DISLIKE){
@@ -262,15 +284,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
else
$profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
- $location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
- $coord = (($item['coord']) ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
- if($coord) {
- if($location)
- $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
- else
- $location = '<span class="smalltext">' . $coord . '</span>';
- }
+ $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
+ call_hooks('render_location',$locate);
+ $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate));
localize_item($item);
if($mode === 'network-new')
@@ -494,7 +511,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
}
$likebuttons = '';
- $shareable = ((($profile_owner == local_user()) && ($mode != 'display') && (! $item['private'])) ? true : false);
+ $shareable = ((($profile_owner == local_user()) && (! $item['private'])) ? true : false); //($mode != 'display') &&
if($page_writeable) {
if($toplevelpost) {
@@ -505,6 +522,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share'));
}
+
+ $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
+ $qcomment = (($qc) ? explode("\n",$qc) : null);
+
if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
$comment = replace_macros($cmnt_tpl,array(
'$return_path' => '',
@@ -512,6 +533,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'),
'$id' => $item['item_id'],
'$parent' => $item['parent'],
+ '$qcomment' => $qcomment,
'$profile_uid' => $profile_owner,
'$mylink' => $a->contact['url'],
'$mytitle' => t('This is you'),
@@ -594,16 +616,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$like = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
$dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
- $location = (($item['location']) ? '<a target="map" title="' . $item['location']
- . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
- $coord = (($item['coord']) ? '<a target="map" title="' . $item['coord']
- . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
- if($coord) {
- if($location)
- $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
- else
- $location = '<span class="smalltext">' . $coord . '</span>';
- }
+ $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
+ call_hooks('render_location',$locate);
+
+ $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate));
$indent = (($toplevelpost) ? '' : ' comment');
@@ -620,11 +636,9 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if ($tag!="") $tags[] = bbcode($tag);
}
-
// Build the HTML
$body = prepare_body($item,true);
-
$tmp_item = replace_macros($template,array(
'$type' => implode("",array_slice(split("/",$item['verb']),-1)),
@@ -832,104 +846,114 @@ function format_like($cnt,$arr,$type,$id) {
}}
-function status_editor($a,$x, $notes_cid = 0) {
+function status_editor($a,$x, $notes_cid = 0, $popup=false) {
$o = '';
$geotag = (($x['allow_location']) ? get_markup_template('jot_geotag.tpl') : '');
- $tpl = get_markup_template('jot-header.tpl');
-
- $a->page['htmlhead'] .= replace_macros($tpl, array(
- '$newpost' => 'true',
- '$baseurl' => $a->get_baseurl(),
- '$geotag' => $geotag,
- '$nickname' => $x['nickname'],
- '$ispublic' => t('Visible to <strong>everybody</strong>'),
- '$linkurl' => t('Please enter a link URL:'),
- '$vidurl' => t("Please enter a video link/URL:"),
- '$audurl' => t("Please enter an audio link/URL:"),
- '$term' => t('Tag term:'),
- '$whereareu' => t('Where are you right now?'),
- '$title' => t('Enter a title for this item')
- ));
-
-
- $tpl = get_markup_template("jot.tpl");
-
- $jotplugins = '';
- $jotnets = '';
+ $plaintext = false;
+ if(local_user() && intval(get_pconfig(local_user(),'system','plaintext')))
+ $plaintext = true;
- $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
+ $tpl = get_markup_template('jot-header.tpl');
+
+ $a->page['htmlhead'] .= replace_macros($tpl, array(
+ '$newpost' => 'true',
+ '$baseurl' => $a->get_baseurl(),
+ '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
+ '$geotag' => $geotag,
+ '$nickname' => $x['nickname'],
+ '$ispublic' => t('Visible to <strong>everybody</strong>'),
+ '$linkurl' => t('Please enter a link URL:'),
+ '$vidurl' => t("Please enter a video link/URL:"),
+ '$audurl' => t("Please enter an audio link/URL:"),
+ '$term' => t('Tag term:'),
+ '$whereareu' => t('Where are you right now?'),
+ '$title' => t('Enter a title for this item')
+ ));
- $mail_enabled = false;
- $pubmail_enabled = false;
- if(($x['is_owner']) && (! $mail_disabled)) {
- $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
- intval(local_user())
- );
- if(count($r)) {
- $mail_enabled = true;
- if(intval($r[0]['pubmail']))
- $pubmail_enabled = true;
- }
+ $tpl = get_markup_template("jot.tpl");
+
+ $jotplugins = '';
+ $jotnets = '';
+
+ $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
+
+ $mail_enabled = false;
+ $pubmail_enabled = false;
+
+ if(($x['is_owner']) && (! $mail_disabled)) {
+ $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
+ intval(local_user())
+ );
+ if(count($r)) {
+ $mail_enabled = true;
+ if(intval($r[0]['pubmail']))
+ $pubmail_enabled = true;
}
+ }
- if($mail_enabled) {
- $selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
- $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
- . t("Post to Email") . '</div>';
- }
+ if($mail_enabled) {
+ $selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
+ $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> ' . t("Post to Email") . '</div>';
+ }
+
+ call_hooks('jot_tool', $jotplugins);
+ call_hooks('jot_networks', $jotnets);
+
+ if($notes_cid)
+ $jotnets .= '<input type="hidden" name="contact_allow[]" value="' . $notes_cid .'" />';
+
+ $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
+
+ $o .= replace_macros($tpl,array(
+ '$return_path' => $a->cmd,
+ '$action' => $a->get_baseurl().'/item',
+ '$share' => (($x['button']) ? $x['button'] : t('Share')),
+ '$upload' => t('Upload photo'),
+ '$shortupload' => t('upload photo'),
+ '$attach' => t('Attach file'),
+ '$shortattach' => t('attach file'),
+ '$weblink' => t('Insert web link'),
+ '$shortweblink' => t('web link'),
+ '$video' => t('Insert video link'),
+ '$shortvideo' => t('video link'),
+ '$audio' => t('Insert audio link'),
+ '$shortaudio' => t('audio link'),
+ '$setloc' => t('Set your location'),
+ '$shortsetloc' => t('set location'),
+ '$noloc' => t('Clear browser location'),
+ '$shortnoloc' => t('clear location'),
+ '$title' => "",
+ '$placeholdertitle' => t('Set title'),
+ '$wait' => t('Please wait'),
+ '$permset' => t('Permission settings'),
+ '$shortpermset' => t('permissions'),
+ '$ptyp' => (($notes_cid) ? 'note' : 'wall'),
+ '$content' => '',
+ '$post_id' => '',
+ '$baseurl' => $a->get_baseurl(),
+ '$defloc' => $x['default_location'],
+ '$visitor' => $x['visitor'],
+ '$pvisit' => (($notes_cid) ? 'none' : $x['visitor']),
+ '$emailcc' => t('CC: email addresses'),
+ '$public' => t('Public post'),
+ '$jotnets' => $jotnets,
+ '$emtitle' => t('Example: bob@example.com, mary@example.com'),
+ '$lockstate' => $x['lockstate'],
+ '$acl' => $x['acl'],
+ '$bang' => $x['bang'],
+ '$profile_uid' => $x['profile_uid'],
+ '$preview' => t('Preview'),
+ ));
- call_hooks('jot_tool', $jotplugins);
- call_hooks('jot_networks', $jotnets);
-
- if($notes_cid)
- $jotnets .= '<input type="hidden" name="contact_allow[]" value="' . $notes_cid .'" />';
-
- $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
-
- $o .= replace_macros($tpl,array(
- '$return_path' => $a->cmd,
- '$action' => 'item',
- '$share' => (($x['button']) ? $x['button'] : t('Share')),
- '$upload' => t('Upload photo'),
- '$shortupload' => t('upload photo'),
- '$attach' => t('Attach file'),
- '$shortattach' => t('attach file'),
- '$weblink' => t('Insert web link'),
- '$shortweblink' => t('web link'),
- '$video' => t('Insert video link'),
- '$shortvideo' => t('video link'),
- '$audio' => t('Insert audio link'),
- '$shortaudio' => t('audio link'),
- '$setloc' => t('Set your location'),
- '$shortsetloc' => t('set location'),
- '$noloc' => t('Clear browser location'),
- '$shortnoloc' => t('clear location'),
- '$title' => "",
- '$placeholdertitle' => t('Set title'),
- '$wait' => t('Please wait'),
- '$permset' => t('Permission settings'),
- '$shortpermset' => t('permissions'),
- '$ptyp' => (($notes_cid) ? 'note' : 'wall'),
- '$content' => '',
- '$post_id' => '',
- '$baseurl' => $a->get_baseurl(),
- '$defloc' => $x['default_location'],
- '$visitor' => $x['visitor'],
- '$pvisit' => (($notes_cid) ? 'none' : $x['visitor']),
- '$emailcc' => t('CC: email addresses'),
- '$public' => t('Public post'),
- '$jotnets' => $jotnets,
- '$emtitle' => t('Example: bob@example.com, mary@example.com'),
- '$lockstate' => $x['lockstate'],
- '$acl' => $x['acl'],
- '$bang' => $x['bang'],
- '$profile_uid' => $x['profile_uid'],
- '$preview' => t('Preview'),
- ));
+
+ if ($popup==true){
+ $o = '<div id="jot-popup" style="display: none;">'.$o.'</div>';
+
+ }
return $o;
}
@@ -1004,3 +1028,17 @@ function find_thread_parent_index($arr,$x) {
return $k;
return false;
}
+
+function render_location_google($item) {
+ $location = '';
+ $location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
+ $coord = (($item['coord']) ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
+ if($coord) {
+ if($location)
+ $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
+ else
+ $location = '<span class="smalltext">' . $coord . '</span>';
+ }
+ return $location;
+}
+
diff --git a/include/datetime.php b/include/datetime.php
index d44e995cf..6d395fe3f 100755
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -260,10 +260,11 @@ function relative_date($posted_date) {
);
foreach ($a as $secs => $str) {
- $d = $etime / $secs;
- if ($d >= 1) {
- $r = round($d);
- return $r . ' ' . (($r == 1) ? $str[0] : $str[1]) . t(' ago');
+ $d = $etime / $secs;
+ if ($d >= 1) {
+ $r = round($d);
+ // translators - e.g. 22 hours ago, 1 minute ago
+ return sprintf( t('%1$d %2$s ago'),$r, (($r == 1) ? $str[0] : $str[1]));
}
}
}}
diff --git a/include/delivery.php b/include/delivery.php
index c05358868..677d89388 100755
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -21,6 +21,7 @@ function delivery_run($argv, $argc){
require_once('include/items.php');
require_once('include/bbcode.php');
require_once('include/diaspora.php');
+ require_once('include/email.php');
load_config('config');
load_config('system');
@@ -311,6 +312,13 @@ function delivery_run($argv, $argc){
);
if(count($x)) {
+ if($owner['page-flags'] == PAGE_COMMUNITY && ! $x[0]['writable']) {
+ q("update contact set writable = 1 where id = %d limit 1",
+ intval($x[0]['id'])
+ );
+ $x[0]['writable'] = 1;
+ }
+
require_once('library/simplepie/simplepie.inc');
logger('mod-delivery: local delivery');
local_delivery($x[0],$atom);
@@ -373,7 +381,8 @@ function delivery_run($argv, $argc){
break;
case NETWORK_MAIL :
-
+ case NETWORK_MAIL2:
+
if(get_config('system','dfrn_only'))
break;
// WARNING: does not currently convert to RFC2047 header encodings, etc.
@@ -412,8 +421,15 @@ function delivery_run($argv, $argc){
if($r1 && $r1[0]['reply_to'])
$reply_to = $r1[0]['reply_to'];
- $subject = (($it['title']) ? $it['title'] : t("\x28no subject\x29")) ;
- $headers = 'From: ' . $local_user[0]['username'] . ' <' . $local_user[0]['email'] . '>' . "\n";
+ $subject = (($it['title']) ? email_header_encode($it['title'],'UTF-8') : t("\x28no subject\x29")) ;
+
+ // only expose our real email address to true friends
+
+ if(($contact['rel'] == CONTACT_IS_FRIEND) && (! $contact['blocked']))
+ $headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . $local_user[0]['email'] . '>' . "\n";
+ else
+ $headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . t('noreply') . '@' . $a->get_hostname() . '>' . "\n";
+
if($reply_to)
$headers .= 'Reply-to: ' . $reply_to . "\n";
$headers .= 'Message-id: <' . $it['uri'] . '>' . "\n";
diff --git a/include/diaspora.php b/include/diaspora.php
index cded389c3..a8e02e509 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -598,7 +598,7 @@ function diaspora_request($importer,$xml) {
`uri-date` = '%s',
`avatar-date` = '%s',
`blocked` = 0,
- `pending` = 0,
+ `pending` = 0
WHERE `id` = %d LIMIT 1
",
dbesc($photos[0]),
@@ -611,7 +611,7 @@ function diaspora_request($importer,$xml) {
intval($contact_record['id'])
);
- $u = q("select * from user where id = %d limit 1",intval($importer['uid']));
+ $u = q("select * from user where uid = %d limit 1",intval($importer['uid']));
if($u)
$ret = diaspora_share($u[0],$contact_record);
}
@@ -673,6 +673,14 @@ function diaspora_post($importer,$xml) {
if(strpos($tag,'#') === 0) {
if(strpos($tag,'[url='))
continue;
+
+ // don't link tags that are already embedded in links
+
+ if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body))
+ continue;
+ if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body))
+ continue;
+
$basetag = str_replace('_',' ',substr($tag,1));
$body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
if(strlen($str_tags))
@@ -830,6 +838,15 @@ function diaspora_reshare($importer,$xml) {
if(strpos($tag,'#') === 0) {
if(strpos($tag,'[url='))
continue;
+
+ // don't link tags that are already embedded in links
+
+ if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body))
+ continue;
+ if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body))
+ continue;
+
+
$basetag = str_replace('_',' ',substr($tag,1));
$body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
if(strlen($str_tags))
@@ -1062,6 +1079,15 @@ function diaspora_comment($importer,$xml,$msg) {
if(strpos($tag,'#') === 0) {
if(strpos($tag,'[url='))
continue;
+
+ // don't link tags that are already embedded in links
+
+ if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body))
+ continue;
+ if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body))
+ continue;
+
+
$basetag = str_replace('_',' ',substr($tag,1));
$body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
if(strlen($str_tags))
@@ -1282,6 +1308,7 @@ function diaspora_conversation($importer,$xml,$msg) {
'language' => $importer['language'],
'to_name' => $importer['username'],
'to_email' => $importer['email'],
+ 'uid' =>$importer['importer_uid'],
'item' => array('subject' => $subject, 'body' => $body),
'source_name' => $person['name'],
'source_link' => $person['url'],
diff --git a/include/enotify.php b/include/enotify.php
index 9df9b57e5..a8e6e3de6 100755
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -28,17 +28,19 @@ function notification($params) {
$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);
-
+ $epreamble = sprintf( t('%s sent you a private message.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
$sitelink = t('Please visit %s to view and/or reply to your private messages.');
$tsitelink = sprintf( $sitelink, $siteurl . '/message' );
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/message">' . $sitename . '</a>');
- $itemlink = '';
+ $itemlink = $siteurl . '/message';
}
if($params['type'] == NOTIFY_COMMENT) {
$subject = sprintf( t('%s commented on an item at %s'), $params['source_name'], $sitename);
$preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']);
+ $epreamble = sprintf( t('%s commented on an item/conversation you have been following.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
+
$sitelink = t('Please visit %s to view and/or reply to the conversation.');
$tsitelink = sprintf( $sitelink, $siteurl );
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
@@ -47,6 +49,27 @@ function notification($params) {
if($params['type'] == NOTIFY_WALL) {
$preamble = $subject = sprintf( t('%s posted to your profile wall at %s') , $params['source_name'], $sitename);
+ $epreamble = sprintf( t('%s posted to your profile wall') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
+
+ $sitelink = t('Please visit %s to view and/or reply to the conversation.');
+ $tsitelink = sprintf( $sitelink, $siteurl );
+ $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
+ $itemlink = $params['link'];
+ }
+
+ if($params['type'] == NOTIFY_TAGSELF) {
+ $preamble = $subject = sprintf( t('%s tagged you at %s') , $params['source_name'], $sitename);
+ $epreamble = sprintf( t('%s tagged you') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
+
+ $sitelink = t('Please visit %s to view and/or reply to the conversation.');
+ $tsitelink = sprintf( $sitelink, $siteurl );
+ $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
+ $itemlink = $params['link'];
+ }
+
+ if($params['type'] == NOTIFY_TAGSHARE) {
+ $preamble = $subject = sprintf( t('%s tagged your post at %s') , $params['source_name'], $sitename);
+ $epreamble = sprintf( t('%s tagged your post') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
$sitelink = t('Please visit %s to view and/or reply to the conversation.');
$tsitelink = sprintf( $sitelink, $siteurl );
@@ -57,6 +80,7 @@ function notification($params) {
if($params['type'] == NOTIFY_INTRO) {
$subject = sprintf( t('Introduction received at %s'), $sitename);
$preamble = sprintf( t('You\'ve received an introduction from \'%s\' at %s'), $params['source_name'], $sitename);
+ $epreamble = sprintf( t('You\'ve received an introduction from %s'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
$body = sprintf( t('You may visit their profile at %s'),$params['source_link']);
$sitelink = t('Please visit %s to approve or reject the introduction.');
@@ -68,6 +92,9 @@ function notification($params) {
if($params['type'] == NOTIFY_SUGGEST) {
$subject = sprintf( t('Friend suggestion received at %s'), $sitename);
$preamble = sprintf( t('You\'ve received a friend suggestion from \'%s\' at %s'), $params['source_name'], $sitename);
+ $epreamble = sprintf( t('You\'ve received a friend suggestion for %s from %s'),
+ '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]',
+ '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
$body = t('Name:') . ' ' . $params['item']['name'] . "\n";
$body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
$body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']);
@@ -82,9 +109,27 @@ function notification($params) {
}
- // TODO - create notification entry in DB
+ // from here on everything is in the recipients language
+
+ push_lang($params['language']);
+
+ require_once('include/html2bbcode.php');
+ // create notification entry in DB
+ $r = q("insert into notify (name,url,photo,date,msg,uid,link,type,verb,otype)
+ values('%s','%s','%s','%s','%s',%d,'%s',%d,'%s','%s')",
+ dbesc($params['source_name']),
+ dbesc($params['source_link']),
+ dbesc($params['source_photo']),
+ dbesc(datetime_convert()),
+ dbesc($epreamble),
+ intval($params['uid']),
+ dbesc($itemlink),
+ intval($params['type']),
+ dbesc($params['verb']),
+ dbesc($params['otype'])
+ );
// send email notification if notification preferences permit
@@ -93,7 +138,6 @@ function notification($params) {
logger('notification: sending notification email');
- push_lang($params['language']);
$textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
$body))),ENT_QUOTES,'UTF-8'));
@@ -108,7 +152,7 @@ function notification($params) {
'$preamble' => $preamble,
'$sitename' => $sitename,
'$siteurl' => $siteurl,
- '$source_name' => $parama['source_name'],
+ '$source_name' => $params['source_name'],
'$source_link' => $params['source_link'],
'$source_photo' => $params['source_photo'],
'$username' => $params['to_name'],
@@ -128,7 +172,7 @@ function notification($params) {
'$preamble' => $preamble,
'$sitename' => $sitename,
'$siteurl' => $siteurl,
- '$source_name' => $parama['source_name'],
+ '$source_name' => $params['source_name'],
'$source_link' => $params['source_link'],
'$source_photo' => $params['source_photo'],
'$username' => $params['to_name'],
@@ -153,8 +197,10 @@ function notification($params) {
'htmlVersion' => $email_html_body,
'textVersion' => $email_text_body
));
- pop_lang();
}
+
+ pop_lang();
+
}
require_once('include/email.php');
diff --git a/include/expire.php b/include/expire.php
index 64dbe2536..5fa0ec758 100755
--- a/include/expire.php
+++ b/include/expire.php
@@ -29,6 +29,11 @@ function expire_run($argv, $argc){
$a->set_baseurl(get_config('system','url'));
+ // physically remove anything that has been deleted for more than two months
+
+ $r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
+ q("optimize table item");
+
logger('expire: start');
$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
diff --git a/include/items.php b/include/items.php
index 62f1f2ce5..f4837449d 100755
--- a/include/items.php
+++ b/include/items.php
@@ -814,6 +814,11 @@ function item_store($arr,$force_parent = false) {
call_hooks('post_remote',$arr);
+ if(x($arr,'cancel')) {
+ logger('item_store: post cancelled by plugin.');
+ return 0;
+ }
+
dbesc_array($arr);
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
@@ -900,7 +905,7 @@ function item_store($arr,$force_parent = false) {
);
}
- tgroup_deliver($arr['uid'],$current_post);
+ tag_deliver($arr['uid'],$current_post);
return $current_post;
}
@@ -918,22 +923,22 @@ function get_item_contact($item,$contacts) {
}
-function tgroup_deliver($uid,$item_id) {
-
+function tag_deliver($uid,$item_id) {
- // setup a second delivery chain for forum/community posts if appropriate
+ // look for mention tags and setup a second delivery chain for forum/community posts if appropriate
$a = get_app();
- $deliver_to_tgroup = false;
+ $mention = false;
- $u = q("select * from user where uid = %d and `page-flags` = %d limit 1",
- intval($uid),
- intval(PAGE_COMMUNITY)
+ $u = q("select uid, nickname, language, username, email, `page-flags`, `notify-flags` from user where uid = %d limit 1",
+ intval($uid)
);
if(! count($u))
return;
+ $community_page = (($u[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
+
$i = q("select * from item where id = %d and uid = %d limit 1",
intval($item_id),
intval($uid)
@@ -943,13 +948,6 @@ function tgroup_deliver($uid,$item_id) {
$item = $i[0];
- // prevent delivery looping - only proceed
- // if the message originated elsewhere and is a top-level post
-
- if(($item['wall']) || ($item['origin']) || ($item['id'] != $item['parent']))
- return;
-
-
$link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
// Diaspora uses their own hardwired link URL in @-tags
@@ -961,19 +959,57 @@ function tgroup_deliver($uid,$item_id) {
if($cnt) {
foreach($matches as $mtch) {
if(link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
- $deliver_to_tgroup = true;
- logger('tgroup_deliver: local group mention found: ' . $mtch[2]);
+ $mention = true;
+ logger('tag_deliver: mention found: ' . $mtch[2]);
}
}
}
- if(! $deliver_to_tgroup)
+ if(! $mention)
+ return;
+
+ // send a notification
+
+ require_once('include/enotify.php');
+ notification(array(
+ 'type' => NOTIFY_TAGSELF,
+ 'notify_flags' => $u[0]['notify-flags'],
+ 'language' => $u[0]['language'],
+ 'to_name' => $u[0]['username'],
+ 'to_email' => $u[0]['email'],
+ 'uid' => $u[0]['uid'],
+ 'item' => $item,
+ 'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item['id'],
+ 'source_name' => $item['author-name'],
+ 'source_link' => $item['author-link'],
+ 'source_photo' => $item['author-avatar'],
+ 'verb' => ACTIVITY_TAG,
+ 'otype' => 'item'
+ ));
+
+ if(! $community_page)
+ return;
+
+ // tgroup delivery - setup a second delivery chain
+ // prevent delivery looping - only proceed
+ // if the message originated elsewhere and is a top-level post
+
+ if(($item['wall']) || ($item['origin']) || ($item['id'] != $item['parent']))
return;
// now change this copy of the post to a forum head message and deliver to all the tgroup members
- q("update item set wall = 1, origin = 1, forum_mode = 1 where id = %d limit 1",
+ $c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1",
+ intval($u[0]['uid'])
+ );
+ if(! count($c))
+ return;
+
+ q("update item set wall = 1, origin = 1, forum_mode = 1, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s' where id = %d limit 1",
+ dbesc($c[0]['name']),
+ dbesc($c[0]['url']),
+ dbesc($c[0]['thumb']),
intval($item_id)
);
@@ -990,8 +1026,8 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$a = get_app();
- if((! strlen($contact['issued-id'])) && (! $contact['duplex']) && (! ($owner['page-flags'] == PAGE_COMMUNITY)))
- return 3;
+// if((! strlen($contact['issued-id'])) && (! $contact['duplex']) && (! ($owner['page-flags'] == PAGE_COMMUNITY)))
+// return 3;
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
@@ -1042,7 +1078,9 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$final_dfrn_id = '';
- if(($contact['duplex'] && strlen($contact['pubkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
+ if(($contact['duplex'] && strlen($contact['pubkey']))
+ || ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
+ || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))) {
openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']);
openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']);
}
@@ -1085,7 +1123,10 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
if($dfrn_version >= 2.1) {
- if(($contact['duplex'] && strlen($contact['pubkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
+ if(($contact['duplex'] && strlen($contact['pubkey']))
+ || ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
+ || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))) {
+
openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']);
}
else {
@@ -1481,7 +1522,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(count($r)) {
if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
- $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($datarray['title']),
dbesc($datarray['body']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc($item_id),
@@ -1611,7 +1653,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(count($r)) {
if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
- $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($datarray['title']),
dbesc($datarray['body']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc($item_id),
@@ -1806,6 +1849,7 @@ function local_delivery($importer,$data) {
'language' => $importer['language'],
'to_name' => $importer['username'],
'to_email' => $importer['email'],
+ 'uid' => $importer['importer_uid'],
'item' => $fsugg,
'link' => $a->get_baseurl() . '/notifications/intros',
'source_name' => $importer['name'],
@@ -1857,6 +1901,7 @@ function local_delivery($importer,$data) {
'language' => $importer['language'],
'to_name' => $importer['username'],
'to_email' => $importer['email'],
+ 'uid' => $importer['importer_uid'],
'item' => $msg,
'source_name' => $msg['from-name'],
'source_link' => $importer['url'],
@@ -2129,6 +2174,7 @@ function local_delivery($importer,$data) {
'language' => $importer['language'],
'to_name' => $importer['username'],
'to_email' => $importer['email'],
+ 'uid' => $importer['importer_uid'],
'item' => $datarray,
'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $posted_id,
'source_name' => stripslashes($datarray['author-name']),
@@ -2162,7 +2208,8 @@ function local_delivery($importer,$data) {
if(count($r)) {
if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
- $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($datarray['title']),
dbesc($datarray['body']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc($item_id),
@@ -2248,6 +2295,7 @@ function local_delivery($importer,$data) {
'language' => $importer['language'],
'to_name' => $importer['username'],
'to_email' => $importer['email'],
+ 'uid' => $importer['importer_uid'],
'item' => $datarray,
'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $posted_id,
'source_name' => stripslashes($datarray['author-name']),
@@ -2304,7 +2352,8 @@ function local_delivery($importer,$data) {
if(count($r)) {
if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
- $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($datarray['title']),
dbesc($datarray['body']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc($item_id),
@@ -2800,7 +2849,7 @@ function drop_item($id,$interactive = true) {
// delete the item
- $r = q("UPDATE `item` SET `deleted` = 1, `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `deleted` = 1, `title` = '', `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
@@ -2833,7 +2882,7 @@ function drop_item($id,$interactive = true) {
// If it's the parent of a comment thread, kill all the kids
if($item['uri'] == $item['parent-uri']) {
- $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = ''
+ $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = ''
WHERE `parent-uri` = '%s' AND `uid` = %d ",
dbesc(datetime_convert()),
dbesc(datetime_convert()),
diff --git a/include/network.php b/include/network.php
index 551d5e1d0..25db62d16 100755
--- a/include/network.php
+++ b/include/network.php
@@ -579,6 +579,9 @@ function fetch_xrd_links($url) {
if(! function_exists('validate_url')) {
function validate_url(&$url) {
+ // no naked subdomains
+ if(strpos($url,'.') === false)
+ return false;
if(substr($url,0,4) != 'http')
$url = 'http://' . $url;
$h = @parse_url($url);
diff --git a/include/notifier.php b/include/notifier.php
index ead7aebad..37bc6dae5 100755
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -35,7 +35,7 @@ function notifier_run($argv, $argc){
require_once("datetime.php");
require_once('include/items.php');
require_once('include/bbcode.php');
-
+ require_once('include/email.php');
load_config('config');
load_config('system');
@@ -264,7 +264,7 @@ function notifier_run($argv, $argc){
$deny_people = expand_acl($parent['deny_cid']);
$deny_groups = expand_groups(expand_acl($parent['deny_gid']));
- // if our parent is a forum, uplink to the origonal author causing
+ // if our parent is a forum, uplink to the origional author causing
// a delivery fork
if(intval($parent['forum_mode']) && (! $top_level) && ($cmd !== 'uplink')) {
@@ -526,6 +526,14 @@ function notifier_run($argv, $argc){
);
if(count($x)) {
+
+ if($owner['page-flags'] == PAGE_COMMUNITY && ! $x[0]['writable']) {
+ q("update contact set writable = 1 where id = %d limit 1",
+ intval($x[0]['id'])
+ );
+ $x[0]['writable'] = 1;
+ }
+
require_once('library/simplepie/simplepie.inc');
logger('mod-delivery: local delivery');
local_delivery($x[0],$atom);
@@ -584,6 +592,7 @@ function notifier_run($argv, $argc){
break;
case NETWORK_MAIL:
+ case NETWORK_MAIL2:
if(get_config('system','dfrn_only'))
break;
@@ -625,14 +634,14 @@ function notifier_run($argv, $argc){
if($r1 && $r1[0]['reply_to'])
$reply_to = $r1[0]['reply_to'];
- $subject = (($it['title']) ? $it['title'] : t("\x28no subject\x29")) ;
+ $subject = (($it['title']) ? email_header_encode($it['title'],'UTF-8') : t("\x28no subject\x29")) ;
// only expose our real email address to true friends
- if($contact['rel'] == CONTACT_IS_FRIEND)
- $headers = 'From: ' . $local_user[0]['username'] . ' <' . $local_user[0]['email'] . '>' . "\n";
+ if(($contact['rel'] == CONTACT_IS_FRIEND) && (! $contact['blocked']))
+ $headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . $local_user[0]['email'] . '>' . "\n";
else
- $headers = 'From: ' . $local_user[0]['username'] . ' <' . t('noreply') . '@' . $a->get_hostname() . '>' . "\n";
+ $headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . t('noreply') . '@' . $a->get_hostname() . '>' . "\n";
if($reply_to)
$headers .= 'Reply-to: ' . $reply_to . "\n";
@@ -754,9 +763,10 @@ function notifier_run($argv, $argc){
);
$r2 = q("SELECT `id`, `name`,`network` FROM `contact`
- WHERE `network` = '%s' AND `uid` = %d AND `blocked` = 0 AND `pending` = 0
+ WHERE `network` in ( '%s', '%s') AND `uid` = %d AND `blocked` = 0 AND `pending` = 0
AND `rel` != %d order by rand() ",
dbesc(NETWORK_DFRN),
+ dbesc(NETWORK_MAIL2),
intval($owner['uid']),
intval(CONTACT_IS_SHARING)
);
diff --git a/include/oembed.php b/include/oembed.php
index 118f7fa4a..5c3c595f5 100755
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -11,7 +11,7 @@ function oembed_replacecb($matches){
function oembed_fetch_url($embedurl){
-
+
$txt = Cache::get($embedurl);
$noexts = array("mp3","mp4","ogg","ogv","oga","ogm","webm");
diff --git a/include/plugin.php b/include/plugin.php
index fe325ac3b..85b51edff 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -56,25 +56,29 @@ function reload_plugins() {
if(count($parr)) {
foreach($parr as $pl) {
$pl = trim($pl);
+
+ $fname = 'addon/' . $pl . '/' . $pl . '.php';
- $t = filemtime('addon/' . $pl . '/' . $pl . '.php');
- foreach($installed as $i) {
- if(($i['name'] == $pl) && ($i['timestamp'] != $t)) {
- logger('Reloading plugin: ' . $i['name']);
- @include_once('addon/' . $pl . '/' . $pl . '.php');
-
- if(function_exists($pl . '_uninstall')) {
- $func = $pl . '_uninstall';
- $func();
- }
- if(function_exists($pl . '_install')) {
- $func = $pl . '_install';
- $func();
+ if(file_exists($fname)) {
+ $t = @filemtime($fname);
+ foreach($installed as $i) {
+ if(($i['name'] == $pl) && ($i['timestamp'] != $t)) {
+ logger('Reloading plugin: ' . $i['name']);
+ @include_once($fname);
+
+ if(function_exists($pl . '_uninstall')) {
+ $func = $pl . '_uninstall';
+ $func();
+ }
+ if(function_exists($pl . '_install')) {
+ $func = $pl . '_install';
+ $func();
+ }
+ q("UPDATE `addon` SET `timestamp` = %d WHERE `id` = %d LIMIT 1",
+ intval($t),
+ intval($i['id'])
+ );
}
- q("UPDATE `addon` SET `timestamp` = %d WHERE `id` = %d LIMIT 1",
- intval($t),
- intval($i['id'])
- );
}
}
}
diff --git a/include/poller.php b/include/poller.php
index 89e4488b9..7d42c63b5 100755
--- a/include/poller.php
+++ b/include/poller.php
@@ -369,7 +369,7 @@ function poller_run($argv, $argc){
$xml = fetch_url($contact['poll']);
}
- elseif($contact['network'] === NETWORK_MAIL) {
+ elseif($contact['network'] === NETWORK_MAIL || $contact['network'] === NETWORK_MAIL2) {
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if($mail_disabled)
@@ -462,7 +462,7 @@ function poller_run($argv, $argc){
$datarray['contact-id'] = $contact['id'];
if($datarray['parent-uri'] === $datarray['uri'])
$datarray['private'] = 1;
- if(! get_pconfig($importer_uid,'system','allow_public_email_replies')) {
+ if(($contact['network'] === NETWORK_MAIL) && (! get_pconfig($importer_uid,'system','allow_public_email_replies'))) {
$datarray['private'] = 1;
$datarray['allow_cid'] = '<' . $contact['id'] . '>';
}
diff --git a/include/profile_advanced.php b/include/profile_advanced.php
index ccecb95de..004a58524 100755
--- a/include/profile_advanced.php
+++ b/include/profile_advanced.php
@@ -44,6 +44,8 @@ function advanced_profile(&$a) {
if($a->profile['homepage']) $profile['homepage'] = array( t('Homepage:'), linkify($a->profile['homepage']) );
+ if($a->profile['pub_keywords']) $profile['pub_keywords'] = array( t('Tags:'), $a->profile['pub_keywords']);
+
if($a->profile['politic']) $profile['politic'] = array( t('Political Views:'), $a->profile['politic']);
if($a->profile['religion']) $profile['religion'] = array( t('Religion:'), $a->profile['religion']);
diff --git a/include/text.php b/include/text.php
index 5f4adb27c..b9813cfa9 100755
--- a/include/text.php
+++ b/include/text.php
@@ -428,8 +428,10 @@ if(! function_exists('logger')) {
function logger($msg,$level = 0) {
// turn off logger in install mode
global $a;
- if ($a->module == 'install') return;
-
+ global $db;
+
+ if(($a->module == 'install') || (! ($db && $db->connected))) return;
+
$debugging = get_config('system','debugging');
$loglevel = intval(get_config('system','loglevel'));
$logfile = get_config('system','logfile');
@@ -538,8 +540,10 @@ function contact_block() {
$a = get_app();
$shown = get_pconfig($a->profile['uid'],'system','display_friend_count');
- if(! $shown)
+ if($shown === false)
$shown = 24;
+ if($shown == 0)
+ return;
if((! is_array($a->profile)) || ($a->profile['hide-friends']))
return $o;
@@ -674,41 +678,105 @@ function linkify($s) {
*/
if(! function_exists('smilies')) {
-function smilies($s) {
+function smilies($s, $sample = false) {
$a = get_app();
- $s = str_replace(
- array( '&lt;3', '&lt;/3', '&lt;\\3', ':-)', ':)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O', '\\o/', 'o.O', 'O.o', '\\.../', '\\ooo/',
- '~friendika', '~friendica', 'Diaspora*' ),
- array(
+ $texts = array(
+ '&lt;3',
+ '&lt;/3',
+ '&lt;\\3',
+ ':-)',
+// ':)',
+ ';-)',
+// ';)',
+ ':-(',
+// ':(',
+ ':-P',
+// ':P',
+ ':-"',
+ ':-&quot;',
+ ':-x',
+ ':-X',
+ ':-D',
+// ':D',
+ '8-|',
+ '8-O',
+ ':-O',
+ '\\o/',
+ 'o.O',
+ 'O.o',
+ '\\.../',
+ '\\ooo/',
+ ":'(",
+ ":-!",
+ ":-/",
+ ":-[",
+ "8-)",
+ ':beer',
+ ':homebrew',
+ ':coffee',
+ ':facepalm',
+ ':headdesk',
+ '~friendika',
+ '~friendica',
+ 'Diaspora*'
+ );
+
+ $icons = array(
'<img src="' . $a->get_baseurl() . '/images/smiley-heart.gif" alt="<3" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":-)" />',
- '<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":)" />',
+// '<img src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":)" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";-)" />',
+// '<img src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";)"/>',
'<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":-(" />',
- '<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":(" />',
+// '<img src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":(" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" />',
- '<img src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":P" />',
+// '<img src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":P" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-\"" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-\"" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" />',
+// '<img src="' . $a->get_baseurl() . '/images/smiley-laughing.gif" alt=":D"/>',
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-shaka.gif" alt="\\.../" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-shaka.gif" alt="\\ooo/" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-cool.gif" alt="8-)" />',
+ '<img src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":beer" />',
+ '<img src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" />',
+ '<img src="' . $a->get_baseurl() . '/images/coffee.gif" alt=":coffee" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-bangheaddesk.gif" alt=":headdesk" />',
'<a href="http://project.friendika.com">~friendika <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendika" /></a>',
'<a href="http://friendica.com">~friendica <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendica" /></a>',
'<a href="http://diasporafoundation.org">Diaspora<img src="' . $a->get_baseurl() . '/images/diaspora.png" alt="Diaspora*" /></a>',
- ), $s);
+ );
+
+ $params = array('texts' => $texts, 'icons' => $icons, 'string' => $s);
+ call_hooks('smilie', $params);
- call_hooks('smilie', $s);
+ if($sample) {
+ $s = '<div class="smiley-sample">';
+ for($x = 0; $x < count($params['texts']); $x ++) {
+ $s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>';
+ }
+ }
+ else {
+ $s = str_replace($params['texts'],$params['icons'],$params['string']);
+ }
+
return $s;
}}
@@ -785,10 +853,10 @@ function prepare_body($item,$attach = false) {
case 'audio':
case 'image':
case 'text':
- $icon = '<div class="attachtype type-' . $icontype . '"></div>';
+ $icon = '<div class="attachtype icon s22 type-' . $icontype . '"></div>';
break;
default:
- $icon = '<div class="attachtype type-unkn"></div>';
+ $icon = '<div class="attachtype icon s22 type-unkn"></div>';
break;
}
$title = ((strlen(trim($matches[4]))) ? escape_tags(trim($matches[4])) : escape_tags($matches[1]));
@@ -814,7 +882,10 @@ function prepare_text($text) {
require_once('include/bbcode.php');
- $s = smilies(bbcode($text));
+ if(stristr($text,'[nosmile]'))
+ $s = bbcode($text);
+ else
+ $s = smilies(bbcode($text));
return $s;
}}