aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php7
-rw-r--r--include/Scrape.php14
-rw-r--r--include/api.php28
-rw-r--r--include/bb2diaspora.php6
-rw-r--r--include/bbcode.php17
-rw-r--r--include/conversation.php6
-rw-r--r--include/email.php20
-rw-r--r--include/group.php2
-rw-r--r--include/html2bbcode.php8
-rw-r--r--include/template_processor.php8
-rw-r--r--include/text.php20
11 files changed, 100 insertions, 36 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 7524c0cea..45920041e 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -133,7 +133,12 @@ function contact_photo_menu($contact) {
$o = "";
foreach($menu as $k=>$v){
- if ($v!="") $o .= "<li><a href='$v'>$k</a></li>\n";
+ if ($v!="") {
+ if(($k !== t("View recent")) && ($k !== t("Send PM")))
+ $o .= "<li><a target=\"redir\" href=\"$v\">$k</a></li>\n";
+ else
+ $o .= "<li><a href=\"$v\">$k</a></li>\n";
+ }
}
return $o;
}}
diff --git a/include/Scrape.php b/include/Scrape.php
index b80f24c22..58468a40d 100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
@@ -430,7 +430,8 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$addr = $orig_url;
$network = NETWORK_MAIL;
$name = substr($url,0,strpos($url,'@'));
- $profile = 'http://' . substr($url,strpos($url,'@')+1);
+ $phost = substr($url,strpos($url,'@')+1);
+ $profile = 'http://' . $phost;
// fix nick character range
$vcard = array('fn' => $name, 'nick' => $name, 'photo' => gravatar_img($url));
$notify = 'smtp ' . random_string();
@@ -441,8 +442,15 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$adr = imap_rfc822_parse_adrlist($x->from,'');
elseif(stristr($x->to,$orig_url))
$adr = imap_rfc822_parse_adrlist($x->to,'');
- if(isset($adr) && strlen($adr[0]->personal))
- $vcard['fn'] = notags($adr[0]->personal);
+ if(isset($adr)) {
+ foreach($adr as $feadr) {
+ if((strcasecmp($feadr->mailbox,$name) == 0)
+ &&(strcasecmp($feadr->host,$phost) == 0)
+ && (strlen($feadr->personal))) {
+ $vcard['fn'] = notags($feadr->personal);
+ }
+ }
+ }
}
imap_close($mbox);
}
diff --git a/include/api.php b/include/api.php
index 1f58a6baa..5d008c290 100644
--- a/include/api.php
+++ b/include/api.php
@@ -466,6 +466,7 @@
}
return null;
}
+
// TODO - media uploads
function api_statuses_update(&$a, $type) {
if (local_user()===false) return false;
@@ -475,7 +476,32 @@
// logger('api_post: ' . print_r($_POST,true));
- $_POST['body'] = urldecode(requestdata('status'));
+ if(requestdata('htmlstatus')) {
+ require_once('library/HTMLPurifier.auto.php');
+ require_once('include/html2bbcode.php');
+
+ $txt = requestdata('htmlstatus');
+ if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
+
+ $txt = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
+ '[youtube]$1[/youtube]', $txt);
+
+ $txt = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#s',
+ '[youtube]$1[/youtube]', $txt);
+
+ $config = HTMLPurifier_Config::createDefault();
+ $config->set('Cache.DefinitionImpl', null);
+
+
+ $purifier = new HTMLPurifier($config);
+ $txt = $purifier->purify($txt);
+
+ $_POST['body'] = html2bbcode($txt);
+ }
+
+ }
+ else
+ $_POST['body'] = urldecode(requestdata('status'));
$parent = requestdata('in_reply_to_status_id');
if(ctype_digit($parent))
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 591aaf7fa..5b240bdd2 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -42,6 +42,8 @@ function stripdcode_br_cb($s) {
function bb2diaspora($Text,$preserve_nl = false) {
+ $ev = bbtoevent($Text);
+
// Replace any html brackets with HTML Entities to prevent executing HTML or script
// Don't use strip_tags here because it breaks [url] search by replacing & with amp
@@ -52,7 +54,6 @@ function bb2diaspora($Text,$preserve_nl = false) {
// After we're finished processing the bbcode we'll
// replace all of the event code with a reformatted version.
- $ev = bbtoevent($Text);
if($preserve_nl)
$Text = str_replace(array("\n","\r"), array('',''),$Text);
@@ -185,7 +186,10 @@ function bb2diaspora($Text,$preserve_nl = false) {
$Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text);
}
+ $Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
+ $Text = preg_replace('/\[(.*?)\\\\_(.*?)\]\((.*?)\)/ism','[$1_$2]($3)',$Text);
+ $Text = preg_replace('/\[(.*?)\\\\\*(.*?)\]\((.*?)\)/ism','[$1*$2]($3)',$Text);
call_hooks('bb2diaspora',$Text);
diff --git a/include/bbcode.php b/include/bbcode.php
index 86b7fdb4b..3886af37d 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -15,6 +15,13 @@ function stripcode_br_cb($s) {
function bbcode($Text,$preserve_nl = false) {
+ // If we find any event code, turn it into an event.
+ // After we're finished processing the bbcode we'll
+ // replace all of the event code with a reformatted version.
+
+ $ev = bbtoevent($Text);
+
+
// Replace any html brackets with HTML Entities to prevent executing HTML or script
// Don't use strip_tags here because it breaks [url] search by replacing & with amp
@@ -27,11 +34,6 @@ function bbcode($Text,$preserve_nl = false) {
if($preserve_nl)
$Text = str_replace(array("\n","\r"), array('',''),$Text);
- // If we find any event code, turn it into an event.
- // After we're finished processing the bbcode we'll
- // replace all of the event code with a reformatted version.
-
- $ev = bbtoevent($Text);
// Set up the parameters for a URL search string
$URLSearchString = "^\[\]";
@@ -41,7 +43,7 @@ function bbcode($Text,$preserve_nl = false) {
// Perform URL Search
- $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\%\$\!\+\,]+)/", '$1<a href="$2" target="external-link">$2</a>', $Text);
+ $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/", '$1<a href="$2" target="external-link">$2</a>', $Text);
$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/m", '<a href="$1" target="external-link">$1</a>', $Text);
$Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/m", '<a href="$1" target="external-link">$2</a>', $Text);
@@ -157,7 +159,8 @@ function bbcode($Text,$preserve_nl = false) {
$Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text);
}
-
+ // fix any escaped ampersands that may have been converted into links
+ $Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
call_hooks('bbcode',$Text);
diff --git a/include/conversation.php b/include/conversation.php
index 6b5bf8d7c..6aad2485a 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -111,7 +111,7 @@ function conversation(&$a, $items, $mode, $update) {
}
if($mode === 'notes') {
- $profile_owner = $a->profile['profile_uid'];
+ $profile_owner = local_user();
$page_writeable = true;
}
@@ -381,12 +381,12 @@ function conversation(&$a, $items, $mode, $update) {
}
}
-
$likebuttons = '';
+ $shareable = ((($profile_owner == local_user()) && ($mode != 'display') && (! $item['private'])) ? true : false);
if($page_writeable) {
if($toplevelpost) {
- $likebuttons = replace_macros((($item['private'] || ($profile_owner != local_user())) ? $noshare_tpl : $like_tpl),array(
+ $likebuttons = replace_macros(((($shareable)) ? $like_tpl : $noshare_tpl),array(
'$id' => $item['id'],
'$likethis' => t("I like this \x28toggle\x29"),
'$nolike' => t("I don't like this \x28toggle\x29"),
diff --git a/include/email.php b/include/email.php
index 1f485e430..a36d9adab 100644
--- a/include/email.php
+++ b/include/email.php
@@ -4,7 +4,7 @@ function email_connect($mailbox,$username,$password) {
if(! function_exists('imap_open'))
return false;
- $mbox = imap_open($mailbox,$username,$password);
+ $mbox = @imap_open($mailbox,$username,$password);
return $mbox;
}
@@ -14,19 +14,19 @@ function email_poll($mbox,$email_addr) {
if(! ($mbox && $email_addr))
return array();
- $search1 = imap_search($mbox,'FROM "' . $email_addr . '"', SE_UID);
+ $search1 = @imap_search($mbox,'FROM "' . $email_addr . '"', SE_UID);
if(! $search1)
$search1 = array();
- $search2 = imap_search($mbox,'TO "' . $email_addr . '"', SE_UID);
+ $search2 = @imap_search($mbox,'TO "' . $email_addr . '"', SE_UID);
if(! $search2)
$search2 = array();
- $search3 = imap_search($mbox,'CC "' . $email_addr . '"', SE_UID);
+ $search3 = @imap_search($mbox,'CC "' . $email_addr . '"', SE_UID);
if(! $search3)
$search3 = array();
- $search4 = imap_search($mbox,'BCC "' . $email_addr . '"', SE_UID);
+ $search4 = @imap_search($mbox,'BCC "' . $email_addr . '"', SE_UID);
if(! $search4)
$search4 = array();
@@ -45,12 +45,12 @@ function construct_mailbox_name($mailacct) {
function email_msg_meta($mbox,$uid) {
- $ret = (($mbox && $uid) ? imap_fetch_overview($mbox,$uid,FT_UID) : array(array()));
+ $ret = (($mbox && $uid) ? @imap_fetch_overview($mbox,$uid,FT_UID) : array(array()));
return ((count($ret)) ? $ret[0] : array());
}
function email_msg_headers($mbox,$uid) {
- $raw_header = (($mbox && $uid) ? imap_fetchheader($mbox,$uid,FT_UID) : '');
+ $raw_header = (($mbox && $uid) ? @imap_fetchheader($mbox,$uid,FT_UID) : '');
$raw_header = str_replace("\r",'',$raw_header);
$ret = array();
$h = split("\n",$raw_header);
@@ -74,7 +74,7 @@ function email_msg_headers($mbox,$uid) {
function email_get_msg($mbox,$uid) {
$ret = array();
- $struc = (($mbox && $uid) ? imap_fetchstructure($mbox,$uid,FT_UID) : null);
+ $struc = (($mbox && $uid) ? @imap_fetchstructure($mbox,$uid,FT_UID) : null);
if(! $struc)
return $ret;
@@ -103,8 +103,8 @@ function email_get_part($mbox,$uid,$p,$partno) {
// DECODE DATA
$data = ($partno)
- ? imap_fetchbody($mbox,$uid,$partno, FT_UID|FT_PEEK)
- : imap_body($mbox,$uid,FT_UID|FT_PEEK);
+ ? @imap_fetchbody($mbox,$uid,$partno, FT_UID|FT_PEEK)
+ : @imap_body($mbox,$uid,FT_UID|FT_PEEK);
// Any part may be encoded, even plain text messages, so check everything.
if ($p->encoding==4)
diff --git a/include/group.php b/include/group.php
index 8798adf5a..d92e24e20 100644
--- a/include/group.php
+++ b/include/group.php
@@ -124,7 +124,7 @@ function group_public_members($gid) {
$r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member`
LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
WHERE `gid` = %d AND `group_member`.`uid` = %d
- AND ( `contact`.`network` = '%s' OR `contact`.`notify` = '' )",
+ AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ",
intval($gid),
intval(local_user()),
dbesc(NETWORK_OSTATUS)
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index d4e8cce66..8025c336b 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -24,6 +24,10 @@ function html2bbcode($s) {
'/\<u\>(.*?)\<\/u\>/is',
'/\<ul\>(.*?)\<\/ul\>/is',
'/\<li\>(.*?)\<\/li\>/is',
+ '/\<img(.*?)width: *([0-9]+)(.*?)height: *([0-9]+)(.*?)src=\"(.*?)\" (.*?)\>/is',
+ '/\<img(.*?)height: *([0-9]+)(.*?)width: *([0-9]+)(.*?)src=\"(.*?)\" (.*?)\>/is',
+ '/\<img(.*?)src=\"(.*?)\"(.*?)width: *([0-9]+)(.*?)height: *([0-9]+)(.*?)\>/is',
+ '/\<img(.*?)src=\"(.*?)\"(.*?)height: *([0-9]+)(.*?)width: *([0-9]+)(.*?)\>/is',
'/\<img(.*?) src=\"(.*?)\" (.*?)\>/is',
'/\<div(.*?)\>(.*?)\<\/div\>/is',
'/\<br(.*?)\>/is',
@@ -50,6 +54,10 @@ function html2bbcode($s) {
'[u]$1[/u]',
'[list]$1[/list]',
'[*]$1',
+ '[img=$2x$4]$6[/img]',
+ '[img=$4x$2]$6[/img]',
+ '[img=$4x$6]$2[/img]',
+ '[img=$6x$4]$2[/img]',
'[img]$2[/img]',
'$2',
"\n",
diff --git a/include/template_processor.php b/include/template_processor.php
index 056d25488..f64fe4c0f 100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -165,9 +165,11 @@
$a = get_app();
$this->lang=array();
- foreach ($a->strings as $k=>$v){
- $k = preg_replace("/[^a-z0-9-]/", "", str_replace(" ","-", strtolower($k)));
- $this->lang[$k] = $v;
+ if(is_array($a->strings) && count($a->strings)) {
+ foreach ($a->strings as $k=>$v){
+ $k = preg_replace("/[^a-z0-9-]/", "", str_replace(" ","-", strtolower($k)));
+ $this->lang[$k] = $v;
+ }
}
return $this->lang;
}
diff --git a/include/text.php b/include/text.php
index 78eae145e..1f038c49c 100644
--- a/include/text.php
+++ b/include/text.php
@@ -482,13 +482,12 @@ function get_tags($s) {
// we might be inside a bbcode color tag - leave it alone
continue;
}
+ if(substr($mtch,-1,1) === '.')
+ $mtch = substr($mtch,0,-1);
// ignore strictly numeric tags like #1
if((strpos($mtch,'#') === 0) && ctype_digit(substr($mtch,1)))
continue;
- if(substr($mtch,-1,1) === '.')
- $ret[] = substr($mtch,0,-1);
- else
- $ret[] = $mtch;
+ $ret[] = $mtch;
}
}
return $ret;
@@ -579,11 +578,13 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
$url = $contact['url'];
$sparkle = '';
+ $redir = false;
if($redirect) {
$a = get_app();
$redirect_url = $a->get_baseurl() . '/redir/' . $contact['id'];
if(local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === 'dfrn')) {
+ $redir = true;
$url = $redirect_url;
$sparkle = ' sparkle';
}
@@ -594,6 +595,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
if($textmode) {
return '<div class="contact-block-textdiv' . $class . '"><a class="contact-block-link' . $class . $sparkle
. (($click) ? ' fakelink' : '') . '" '
+ . (($redir) ? ' target="redir" ' : '')
. (($url) ? ' href="' . $url . '"' : '') . $click
. '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name']
. '" >'. $contact['name'] . '</a></div>' . "\r\n";
@@ -601,6 +603,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
else {
return '<div class="contact-block-div' . $class . '"><a class="contact-block-link' . $class . $sparkle
. (($click) ? ' fakelink' : '') . '" '
+ . (($redir) ? ' target="redir" ' : '')
. (($url) ? ' href="' . $url . '"' : '') . $click . ' ><img class="contact-block-img' . $class . $sparkle . '" src="'
. $contact['micro'] . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name']
. '" /></a></div>' . "\r\n";
@@ -640,7 +643,8 @@ function valid_email($x){
if(! function_exists('linkify')) {
function linkify($s) {
- $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+]*)/", ' <a href="$1" target="external-link">$1</a>', $s);
+ $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\'\%\$\!\+]*)/", ' <a href="$1" target="external-link">$1</a>', $s);
+ $s = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$s);
return($s);
}}
@@ -661,7 +665,7 @@ if(! function_exists('smilies')) {
function smilies($s) {
$a = get_app();
- return str_replace(
+ $s = str_replace(
array( '&lt;3', '&lt;/3', '&lt;\\3', ':-)', ':)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O',
'~friendika', 'Diaspora*' ),
array(
@@ -685,6 +689,10 @@ function smilies($s) {
'<a href="http://joindiaspora.com">Diaspora<img src="' . $a->get_baseurl() . '/images/diaspora.png" alt="Diaspora*" /></a>',
), $s);
+
+ call_hooks('smilie', $s);
+ return $s;
+
}}