diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/acl.php | 10 | ||||
-rw-r--r-- | mod/directory.php | 14 | ||||
-rw-r--r-- | mod/help.php | 20 | ||||
-rw-r--r-- | mod/poco.php | 211 | ||||
-rw-r--r-- | mod/search.php | 17 | ||||
-rw-r--r-- | mod/share.php | 2 | ||||
-rw-r--r-- | mod/sharedwithme.php | 38 | ||||
-rw-r--r-- | mod/xpoco.php | 7 |
8 files changed, 83 insertions, 236 deletions
diff --git a/mod/acl.php b/mod/acl.php index d406942c3..8eff93a9a 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -33,7 +33,7 @@ function acl_init(&$a){ $sql_extra2 = "AND ( xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'%" . dbesc($search) . ((strpos($search,'@') === false) ? "%@%'" : "%'")) . ") "; // This horrible mess is needed because position also returns 0 if nothing is found. W/ould be MUCH easier if it instead returned a very large value - // Otherwise we could just order by LEAST(POSTION($search IN xchan_name),POSITION($search IN xchan_addr)). + // Otherwise we could just order by LEAST(POSITION($search IN xchan_name),POSITION($search IN xchan_addr)). $order_extra2 = "CASE WHEN xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) ." then POSITION('".dbesc($search)."' IN xchan_name) else position('".dbesc($search)."' IN xchan_addr) end, "; $col = ((strpos($search,'@') !== false) ? 'xchan_addr' : 'xchan_name' ); $sql_extra3 = "AND $col like " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " "; @@ -171,6 +171,7 @@ function acl_init(&$a){ ); } elseif(($type == 'a') || ($type == 'p')) { + $r = q("SELECT abook_id as id, xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and not (xchan_flags & %d)>0 @@ -180,6 +181,7 @@ function acl_init(&$a){ intval(XCHAN_FLAGS_DELETED) ); + } elseif($type == 'x') { $r = navbar_complete($a); @@ -209,7 +211,7 @@ function acl_init(&$a){ foreach($r as $g){ // remove RSS feeds from ACLs - they are inaccessible - if(strpos($g['hash'],'/')) + if(strpos($g['hash'],'/') && $type != 'a') continue; if(($g['abook_their_perms'] & PERMS_W_TAGWALL) && $type == 'c' && (! $noforums)) { @@ -233,7 +235,7 @@ function acl_init(&$a){ "id" => $g['id'], "xid" => $g['hash'], "link" => $g['nick'], - "nick" => substr($g['nick'],0,strpos($g['nick'],'@')), + "nick" => (($g['nick']) ? substr($g['nick'],0,strpos($g['nick'],'@')) : t('RSS')), "self" => (($g['abook_flags'] & ABOOK_FLAG_SELF) ? 'abook-self' : ''), "taggable" => '', "label" => '', @@ -248,6 +250,8 @@ function acl_init(&$a){ 'count' => $count, 'items' => $items, ); + + echo json_encode($o); diff --git a/mod/directory.php b/mod/directory.php index 4ceda293d..2a07208a4 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -274,17 +274,21 @@ function directory_content(&$a) { $arr = array('contact' => $rr, 'entry' => $entry); call_hooks('directory_item', $arr); - + + unset($profile); + unset($location); + + if(! $arr['entry']) { + continue; + } + if($sort_order == '' && $suggest) { $entries[$addresses[$rr['address']]] = $arr['entry']; // Use the same indexes as originally to get the best suggestion first } + else { $entries[] = $arr['entry']; } - unset($profile); - unset($location); - - } ksort($entries); // Sort array by key so that foreach-constructs work as expected diff --git a/mod/help.php b/mod/help.php index 5cdeda58f..0081e54e7 100644 --- a/mod/help.php +++ b/mod/help.php @@ -37,20 +37,28 @@ function help_content(&$a) { $text = ''; if(argc() > 1) { - $text = load_doc_file('doc/' . $a->argv[1] . '.md'); - $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags(argv(1)))); + $path = ''; + for($x = 1; $x < argc(); $x ++) { + if(strlen($path)) + $path .= '/'; + $path .= argv($x); + } + $title = basename($path); + + $text = load_doc_file('doc/' . $path . '.md'); + $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags($title))); if(! $text) { - $text = load_doc_file('doc/' . $a->argv[1] . '.bb'); + $text = load_doc_file('doc/' . $path . '.bb'); if($text) $doctype = 'bbcode'; - $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('_',' ',notags(argv(1)))); + $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('_',' ',notags($title))); } if(! $text) { - $text = load_doc_file('doc/' . $a->argv[1] . '.html'); + $text = load_doc_file('doc/' . $path . '.html'); if($text) $doctype = 'html'; - $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags(argv(1)))); + $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags($title))); } } diff --git a/mod/poco.php b/mod/poco.php index 152f5a143..098c9a240 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -1,210 +1,7 @@ <?php -function poco_init(&$a) { - - $system_mode = false; - - if(intval(get_config('system','block_public')) && (! local_user()) && (! remote_user())) { - logger('mod_poco: block_public'); - http_status_exit(401); - } - - $observer = $a->get_observer(); - - if(argc() > 1) { - $user = notags(trim(argv(1))); - } - if(! x($user)) { - $c = q("select * from pconfig where cat = 'system' and k = 'suggestme' and v = '1'"); - if(! $c) { - logger('mod_poco: system mode. No candidates.', LOGGER_DEBUG); - http_status_exit(404); - } - $system_mode = true; - } - - - $format = (($_REQUEST['format']) ? $_REQUEST['format'] : 'json'); - - $justme = false; - - if(argc() > 2 && argv(2) === '@me') - $justme = true; - if(argc() > 3) { - if(argv(3) === '@all') - $justme = false; - elseif(argv(3) === '@self') - $justme = true; - } - if(argc() > 4 && intval(argv(4)) && $justme == false) - $cid = intval(argv(4)); - - if(! $system_mode) { - - $r = q("SELECT channel_id from channel where channel_address = '%s' limit 1", - dbesc($user) - ); - if(! $r) { - logger('mod_poco: user mode. Account not found. ' . $user); - http_status_exit(404); - } - - $channel_id = $r[0]['channel_id']; - $ohash = (($observer) ? $observer['xchan_hash'] : ''); - - if(! perm_is_allowed($channel_id,$ohash,'view_contacts')) { - logger('mod_poco: user mode. Permission denied for ' . $ohash . ' user: ' . $user); - http_status_exit(401); - } - - } - - if($justme) - $sql_extra = " and ( abook_flags & " . ABOOK_FLAG_SELF . " )>0 "; - else - $sql_extra = " and abook_flags = 0 "; - - if($cid) - $sql_extra = sprintf(" and abook_id = %d ",intval($cid)); - - if($system_mode) { - $r = q("SELECT count(*) as `total` from abook where ( abook_flags & " . ABOOK_FLAG_SELF . - " )>0 and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') "); - } - else { - $r = q("SELECT count(*) as `total` from abook where abook_channel = %d - $sql_extra ", - intval($channel_id) - ); - $rooms = q("select * from menu_item where ( mitem_flags & " . intval(MENU_ITEM_CHATROOM) . " )>0 and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d", - intval($channel_id) - ); - } - if($r) - $totalResults = intval($r[0]['total']); - else - $totalResults = 0; +require_once('include/socgraph.php'); - $startIndex = intval($_GET['startIndex']); - if(! $startIndex) - $startIndex = 0; - $itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults); - - - if($system_mode) { - $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where ( abook_flags & " . ABOOK_FLAG_SELF . - " )>0 and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') limit %d offset %d ", - intval($itemsPerPage), - intval($startIndex) - ); - } - else { - $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d - $sql_extra LIMIT %d OFFSET %d", - intval($channel_id), - intval($itemsPerPage), - intval($startIndex) - ); - } - - $ret = array(); - if(x($_GET,'sorted')) - $ret['sorted'] = 'false'; - if(x($_GET,'filtered')) - $ret['filtered'] = 'false'; - if(x($_GET,'updatedSince')) - $ret['updateSince'] = 'false'; - - $ret['startIndex'] = (string) $startIndex; - $ret['itemsPerPage'] = (string) $itemsPerPage; - $ret['totalResults'] = (string) $totalResults; - - if($rooms) { - $ret['chatrooms'] = array(); - foreach($rooms as $room) { - $ret['chatrooms'][] = array('url' => $room['mitem_link'], 'desc' => $room['mitem_desc']); - } - } - - $ret['entry'] = array(); - - - $fields_ret = array( - 'id' => false, - 'guid' => false, - 'guid_sig' => false, - 'hash' => false, - 'displayName' => false, - 'urls' => false, - 'preferredUsername' => false, - 'photos' => false, - 'rating' => false - ); - - if((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) - foreach($fields_ret as $k => $v) - $fields_ret[$k] = true; - else { - $fields_req = explode(',',$_GET['fields']); - foreach($fields_req as $f) - $fields_ret[trim($f)] = true; - } - - if(is_array($r)) { - if(count($r)) { - foreach($r as $rr) { - $entry = array(); - if($fields_ret['id']) - $entry['id'] = $rr['abook_id']; - if($fields_ret['guid']) - $entry['guid'] = $rr['xchan_guid']; - if($fields_ret['guid_sig']) - $entry['guid_sig'] = $rr['xchan_guid_sig']; - if($fields_ret['hash']) - $entry['hash'] = $rr['xchan_hash']; - - if($fields_ret['displayName']) - $entry['displayName'] = $rr['xchan_name']; - if($fields_ret['urls']) { - $entry['urls'] = array(array('value' => $rr['xchan_url'], 'type' => 'profile')); - $network = $rr['xchan_network']; - if(strpos($network,'friendica') !== false) - $network = 'friendica'; - if($rr['xchan_addr']) - $entry['urls'][] = array('value' => 'acct:' . $rr['xchan_addr'], 'type' => $network); - } - if($fields_ret['preferredUsername']) - $entry['preferredUsername'] = substr($rr['xchan_addr'],0,strpos($rr['xchan_addr'],'@')); - if($fields_ret['photos']) - $entry['photos'] = array(array('value' => $rr['xchan_photo_l'], 'mimetype' => $rr['xchan_photo_mimetype'], 'type' => 'profile')); - if($fields_ret['rating']) { - $entry['rating'] = ((array_key_exists('abook_rating',$rr)) ? intval($rr['abook_rating']) : 0); - $entry['rating_text'] = ((array_key_exists('abook_rating_text',$rr)) ? $rr['abook_rating_text'] : ''); - // maybe this should be a composite calculated rating in $system_mode - if($system_mode) - $entry['rating'] = 0; - } - $ret['entry'][] = $entry; - } - } - else - $ret['entry'][] = array(); - } - else - http_status_exit(500); - - if($format === 'xml') { - header('Content-type: text/xml'); - echo replace_macros(get_markup_template('poco_xml.tpl'),array_xmlify(array('$response' => $ret))); - http_status_exit(500); - } - if($format === 'json') { - header('Content-type: application/json'); - echo json_encode($ret); - killme(); - } - else - http_status_exit(500); - - -}
\ No newline at end of file +function poco_init(&$a) { + poco($a,false); +} diff --git a/mod/search.php b/mod/search.php index 2ea6ad86f..5b15b0593 100644 --- a/mod/search.php +++ b/mod/search.php @@ -21,6 +21,10 @@ function search_content(&$a,$update = 0, $load = false) { require_once('include/conversation.php'); require_once('include/items.php'); + $format = (($_REQUEST['format']) ? $_REQUEST['format'] : ''); + if($format !== '') { + $update = $load = 1; + } $observer = $a->get_observer(); $observer_hash = (($observer) ? $observer['xchan_hash'] : ''); @@ -179,6 +183,19 @@ function search_content(&$a,$update = 0, $load = false) { $items = array(); } + + if($format == 'json') { + $result = array(); + require_once('include/conversation.php'); + foreach($items as $item) { + $item['html'] = bbcode($item['body']); + $x = encode_item($item); + $x['html'] = prepare_text($item['body'],$item['mimetype']); + $result[] = $x; + } + json_return_and_die(array('success' => true,'messages' => $result)); + } + if($tag) $o .= '<h2>Items tagged with: ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') . '</h2>'; else diff --git a/mod/share.php b/mod/share.php index 78a25ee10..d70336ed1 100644 --- a/mod/share.php +++ b/mod/share.php @@ -53,7 +53,7 @@ function share_init(&$a) { "' avatar='".$r[0]['author']['xchan_photo_s']. "' link='".$r[0]['plink']. "' posted='".$r[0]['created']. - "' message_id='".$r[0]['mid']."']\n"; + "' message_id='".$r[0]['mid']."']"; if($r[0]['title']) $o .= '[b]'.$r[0]['title'].'[/b]'."\n"; $o .= $r[0]['body']; diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php index 8b7d2661c..56cbc35ec 100644 --- a/mod/sharedwithme.php +++ b/mod/sharedwithme.php @@ -73,27 +73,37 @@ function sharedwithme_content(&$a) { dbesc($channel['channel_hash']) ); - $o = profile_tabs($a, $is_owner, $channel['channel_address']); - - $o .= '<div class="section-title-wrapper">'; - - $o .= '<a href="/sharedwithme/dropall" onclick="return confirmDelete();" class="btn btn-xs btn-default pull-right"><i class="icon-trash"></i> ' . t('Remove all entries') . '</a>'; - - $o .= '<h2>' . t('Files shared with me') . '</h2>'; - - $o .= '</div>'; - - $o .= '<div class="section-content-wrapper">'; + $items =array(); if($r) { foreach($r as $rr) { $object = json_decode($rr['object'],true); - $url = rawurldecode(get_rel_link($object['link'],'alternate')); - $o .= '<a href="' . $url . '?f=&zid=' . $channel['xchan_addr'] . '">' . $url . '</a> <a href="/sharedwithme/' . $rr['id'] . '/drop" onclick="return confirmDelete();"><i class="icon-trash drop-icons"></i></a><br><br>'; + + $item = array(); + $item['id'] = $rr['id']; + $item['objfiletype'] = $object['filetype']; + $item['objfiletypeclass'] = getIconFromType($object['filetype']); + $item['objurl'] = rawurldecode(get_rel_link($object['link'],'alternate')) . '?f=&zid=' . $channel['xchan_addr']; + $item['objfilename'] = $object['filename']; + $item['objfilesize'] = userReadableSize($object['filesize']); + $item['objedited'] = $object['edited']; + + $items[] = $item; + } } - $o .= '</div>'; + $o = profile_tabs($a, $is_owner, $channel['channel_address']); + + $o .= replace_macros(get_markup_template('sharedwithme.tpl'), array( + '$header' => t('Files: shared with me'), + '$name' => t('Name'), + '$size' => t('Size'), + '$lastmod' => t('Last Modified'), + '$dropall' => t('Remove all files'), + '$drop' => t('Remove this file'), + '$items' => $items + )); return $o; diff --git a/mod/xpoco.php b/mod/xpoco.php new file mode 100644 index 000000000..560966750 --- /dev/null +++ b/mod/xpoco.php @@ -0,0 +1,7 @@ +<?php + +require_once('include/socgraph.php'); + +function xpoco_init(&$a) { + poco($a,true); +} |