From 8c928e67ba9f122343f53400cf0f4dae8104ffd7 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 30 Mar 2012 23:18:46 -0700 Subject: warning cleanup --- include/text.php | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 0b825cc39..f758c37ee 100644 --- a/include/text.php +++ b/include/text.php @@ -205,7 +205,6 @@ function hex2bin($s) { return ''; if(! ctype_xdigit($s)) { - logger('hex2bin: illegal input: ' . print_r(debug_backtrace(), true)); return($s); } -- cgit v1.2.3 From 0cf2e051bbe98166e99025bc1f32a6e8e08a26f2 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 31 Mar 2012 14:48:35 -0700 Subject: escape % in file_tag_query as it is ultimately embedded in a sprintf --- include/text.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index f758c37ee..64f6f72a8 100644 --- a/include/text.php +++ b/include/text.php @@ -1306,6 +1306,10 @@ function file_tag_decode($s) { } function file_tag_file_query($table,$s,$type = 'file') { + + // this is ultimately going into a vsprintf + $s = str_replace('%','%%',$s); + if($type == 'file') $str = preg_quote( '[' . file_tag_encode($s) . ']' ); else -- cgit v1.2.3 From 53f799f2bc125fadf527e3c65e8e9882d53d9aea Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 31 Mar 2012 15:25:17 -0700 Subject: handle escaped file chars in display and search --- include/contact_widgets.php | 2 +- include/text.php | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 1f70e536f..7346b95af 100755 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -87,7 +87,7 @@ function fileas_widget($baseurl,$selected = '') { $cnt = preg_match_all('/\[(.*?)\]/',$saved,$matches,PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { - $unescaped = file_tag_decode($mtch[1]); + $unescaped = xmlify(file_tag_decode($mtch[1])); $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : '')); } } diff --git a/include/text.php b/include/text.php index 64f6f72a8..191f4fca8 100644 --- a/include/text.php +++ b/include/text.php @@ -920,7 +920,7 @@ function prepare_body($item,$attach = false) { foreach($matches as $mtch) { if(strlen($x)) $x .= ','; - $x .= file_tag_decode($mtch[1]); + $x .= xmlify(file_tag_decode($mtch[1])); } if(strlen($x)) $s .= '
' . t('Categories:') . ' ' . $x . '
'; @@ -935,7 +935,7 @@ function prepare_body($item,$attach = false) { foreach($matches as $mtch) { if(strlen($x)) $x .= '   '; - $x .= file_tag_decode($mtch[1]). ' ' . t('[remove]') . ''; + $x .= xmlify(file_tag_decode($mtch[1])) . ' ' . t('[remove]') . ''; } if(strlen($x) && (local_user() == $item['uid'])) $s .= '
' . t('Filed under:') . ' ' . $x . '
'; @@ -1307,13 +1307,10 @@ function file_tag_decode($s) { function file_tag_file_query($table,$s,$type = 'file') { - // this is ultimately going into a vsprintf - $s = str_replace('%','%%',$s); - if($type == 'file') - $str = preg_quote( '[' . file_tag_encode($s) . ']' ); + $str = preg_quote( '[' . str_replace('%','%%',file_tag_encode($s)) . ']' ); else - $str = preg_quote( '<' . file_tag_encode($s) . '>' ); + $str = preg_quote( '<' . str_replace('%','%%',file_tag_encode($s)) . '>' ); return " AND " . (($table) ? dbesc($table) . '.' : '') . "file regexp '" . dbesc($str) . "' "; } -- cgit v1.2.3 From e6fd6bfd89ada9b5aeea8fcac1614546deba85aa Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 31 Mar 2012 17:44:34 -0700 Subject: more error handling --- include/conversation.php | 2 +- include/network.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index a9fb807ad..5a922b2b5 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -250,7 +250,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $threads = array(); $threadsid = -1; - if(count($items)) { + if($items && count($items)) { if($mode === 'network-new' || $mode === 'search' || $mode === 'community') { diff --git a/include/network.php b/include/network.php index 22157ff18..9e1ed2091 100755 --- a/include/network.php +++ b/include/network.php @@ -364,6 +364,9 @@ function lrdd($uri, $debug = false) { logger('lrdd: host_meta: ' . $xml, LOGGER_DATA); + if(! stristr($xml,' Date: Sun, 1 Apr 2012 04:52:45 -0300 Subject: line 86: s/Friendika/Friendica/ --- include/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/api.php b/include/api.php index 64772d657..065f14cff 100755 --- a/include/api.php +++ b/include/api.php @@ -83,7 +83,7 @@ $record = $r[0]; } else { logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG); - header('WWW-Authenticate: Basic realm="Friendika"'); + header('WWW-Authenticate: Basic realm="Friendica"'); header('HTTP/1.0 401 Unauthorized'); die('This api requires login'); } -- cgit v1.2.3 From 5c2fdc795fc5273176a7f81d989ad06e16945f1c Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Apr 2012 00:59:35 -0700 Subject: send unverified private mail using zrl --- include/message.php | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) (limited to 'include') diff --git a/include/message.php b/include/message.php index 7ad80ae9c..377d7c715 100755 --- a/include/message.php +++ b/include/message.php @@ -1,4 +1,5 @@ get_baseurl() . ':' . local_user() . ':' . $hash ; + + $convid = 0; + $reply = false; + + require_once('include/Scrape.php'); + + $me = probe_url($replyto); + + if(! $me['name']) + return -2; + + $conv_guid = get_guid(); + + $recip_handle = $recipient['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); + + $sender_nick = basename($replyto); + $sender_host = substr($replyto,strpos($replyto,'://')+3); + $sender_host = substr($sender_host,0,strpos($sender_host,'/')); + $sender_handle = $sender_nick . '@' . $sender_host; + + $handles = $recip_handle . ';' . $sender_handle; + + $r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ", + intval(local_user()), + dbesc($conv_guid), + dbesc($sender_handle), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc($subject), + dbesc($handles) + ); + + $r = q("select * from conv where guid = '%s' and uid = %d limit 1", + dbesc($conv_guid), + intval($recipient['uid']) + ); + if(count($r)) + $convid = $r[0]['id']; + + if(! $convid) { + logger('send message: conversation not found.'); + return -4; + } + + $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, + `contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`) + VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )", + intval($recipient['uid']), + dbesc(get_guid()), + intval($convid), + dbesc($me['name']), + dbesc($me['photo']), + dbesc($me['url']), + 0, + dbesc($subject), + dbesc($body), + 0, + 0, + 0, + dbesc($uri), + dbesc($replyto), + datetime_convert(), + 1 + ); + + return 0; + +} -- cgit v1.2.3 From f0b8d016154e274f5bfe4d3ec5ac3950621cc2ce Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Apr 2012 03:19:37 -0700 Subject: try slightly better detection of html in feeds --- include/items.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 9f7eb84d9..e09b888ca 100755 --- a/include/items.php +++ b/include/items.php @@ -416,7 +416,7 @@ function get_atom_elements($feed,$item) { // the wild, by sanitising it and converting supported tags to bbcode before we rip out any remaining // html. - if((strpos($res['body'],'<') !== false) || (strpos($res['body'],'>') !== false)) { + if((strpos($res['body'],'<') !== false) && (strpos($res['body'],'>') !== false)) { $res['body'] = reltoabs($res['body'],$base_url); @@ -429,13 +429,14 @@ function get_atom_elements($feed,$item) { // we shouldn't need a whitelist, because the bbcode converter // will strip out any unsupported tags. - // $config->set('HTML.Allowed', 'p,b,a[href],i'); $purifier = new HTMLPurifier($config); $res['body'] = $purifier->purify($res['body']); - $res['body'] = html2bbcode($res['body']); + $res['body'] = @html2bbcode($res['body']); } + else + $res['body'] = escape_tags($res['body']); $allow = $item->get_item_tags(NAMESPACE_DFRN,'comment-allow'); if($allow && $allow[0]['data'] == 1) -- cgit v1.2.3 From 9b4bef8ac49131f8138d360805645e2da44913ae Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Apr 2012 06:46:12 -0700 Subject: that didn't quite work out --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index e09b888ca..8f8b3ccd0 100755 --- a/include/items.php +++ b/include/items.php @@ -435,8 +435,8 @@ function get_atom_elements($feed,$item) { $res['body'] = @html2bbcode($res['body']); } - else - $res['body'] = escape_tags($res['body']); +// else +// $res['body'] = escape_tags($res['body']); $allow = $item->get_item_tags(NAMESPACE_DFRN,'comment-allow'); if($allow && $allow[0]['data'] == 1) -- cgit v1.2.3 From 00bbb9ad362539cc945254eb66af33e2e470440b Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Apr 2012 15:43:57 -0700 Subject: slight improvement in handling of plaintext feeds --- include/items.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 8f8b3ccd0..ee6960534 100755 --- a/include/items.php +++ b/include/items.php @@ -435,8 +435,15 @@ function get_atom_elements($feed,$item) { $res['body'] = @html2bbcode($res['body']); } -// else -// $res['body'] = escape_tags($res['body']); + elseif(! $have_real_body) { + + // it's not one of our messages and it has no tags + // so it's probably just text. We'll escape it just to be safe. + + $res['body'] = escape_tags($res['body']); + } + + // this tag is obsolete but we keep it for really old sites $allow = $item->get_item_tags(NAMESPACE_DFRN,'comment-allow'); if($allow && $allow[0]['data'] == 1) -- cgit v1.2.3 From 581b54c974a9b9a050a8a0b9a17a19bd41b1f2f5 Mon Sep 17 00:00:00 2001 From: Michael Johnston Date: Sun, 1 Apr 2012 21:28:31 -0400 Subject: allow users to set categories on their posts --- include/contact_widgets.php | 28 +++++++++++ include/conversation.php | 2 + include/text.php | 112 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 7346b95af..e0f37f078 100755 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -103,3 +103,31 @@ function fileas_widget($baseurl,$selected = '') { )); } +function categories_widget($baseurl,$selected = '') { + $a = get_app(); + + $saved = get_pconfig($a->profile['profile_uid'],'system','filetags'); + if(! strlen($saved)) + return; + + $matches = false; + $terms = array(); + $cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $unescaped = xmlify(file_tag_decode($mtch[1])); + $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : '')); + } + } + + return replace_macros(get_markup_template('categories_widget.tpl'),array( + '$title' => t('Categories'), + '$desc' => '', + '$sel_all' => (($selected == '') ? 'selected' : ''), + '$all' => t('Everything'), + '$terms' => $terms, + '$base' => $baseurl, + + )); +} + diff --git a/include/conversation.php b/include/conversation.php index 5a922b2b5..df92a40ed 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -974,6 +974,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { '$shortnoloc' => t('clear location'), '$title' => "", '$placeholdertitle' => t('Set title'), + '$category' => "", + '$placeholdercategory' => t('Categories (comma-separated list)'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$shortpermset' => t('permissions'), diff --git a/include/text.php b/include/text.php index 191f4fca8..f204e3f9b 100644 --- a/include/text.php +++ b/include/text.php @@ -1314,6 +1314,118 @@ function file_tag_file_query($table,$s,$type = 'file') { return " AND " . (($table) ? dbesc($table) . '.' : '') . "file regexp '" . dbesc($str) . "' "; } +// ex. given music,video return