aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/connedit.php15
-rw-r--r--mod/dirsearch.php11
-rw-r--r--mod/filestorage.php7
-rw-r--r--mod/locs.php7
-rw-r--r--mod/ping.php2
-rw-r--r--mod/poco.php211
-rw-r--r--mod/search.php17
-rw-r--r--mod/sharedwithme.php71
-rw-r--r--mod/sitelist.php5
-rw-r--r--mod/viewconnections.php2
-rw-r--r--mod/xpoco.php7
11 files changed, 82 insertions, 273 deletions
diff --git a/mod/connedit.php b/mod/connedit.php
index f5dba8a02..34951f99d 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -131,6 +131,7 @@ function connedit_post(&$a) {
if(($_REQUEST['pending']) && ($abook_flags & ABOOK_FLAG_PENDING)) {
$abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING );
$new_friend = true;
+
}
$r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_rating = %d, abook_rating_text = '%s', abook_flags = %d
@@ -275,27 +276,19 @@ function connedit_content(&$a) {
$sort_type = 0;
$o = '';
- // this triggers some javascript to set Full Sharing by default after
- // completing a "follow" - which can be changed to something else before
- // form submission, but this gives us something useable
-
- if($_GET['follow'] == 1) {
- $o .= '<script>var after_following = 1;</script>';
- }
if(! local_user()) {
notice( t('Permission denied.') . EOL);
return login();
}
- $my_perms = 0;
+ $my_perms = get_channel_default_perms(local_user());
$role = get_pconfig(local_user(),'system','permissions_role');
if($role) {
$x = get_role_perms($role);
if($x['perms_accept'])
$my_perms = $x['perms_accept'];
- else
- $my_perms = get_channel_default_perms(local_user());
}
+
if($my_perms) {
$o .= "<script>function connectDefaultShare() {
\$('.abook-edit-me').each(function() {
@@ -582,6 +575,7 @@ function connedit_content(&$a) {
'$autolbl' => t('Apply the permissions indicated on this page to all new connections.'),
'$buttons' => (($self) ? '' : $buttons),
'$viewprof' => t('View Profile'),
+ '$clickme' => t('Click to open/close'),
'$lbl_slider' => t('Slide to adjust your degree of friendship'),
'$lbl_rating' => t('Rating (this information may be public)'),
'$lbl_rating_txt' => t('Optionally explain your rating (this information may be public)'),
@@ -629,6 +623,7 @@ function connedit_content(&$a) {
'$lblrecent' => t('View conversations'),
'$lblsuggest' => $lblsuggest,
'$delete' => t('Delete contact'),
+
'$poll_interval' => contact_poll_interval($contact['priority'],(! $poll_enabled)),
'$poll_enabled' => $poll_enabled,
'$lastupdtext' => t('Last update:'),
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index 947198466..f62320378 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -148,10 +148,10 @@ function dirsearch_content(&$a) {
// If &return_total=1, we count matching entries and return that as 'total_items' for use in pagination.
// By default we return one page (default 80 items maximum) and do not count total entries
- $logic = ((strlen($sql_extra)) ? 0 : 1);
+ $logic = ((strlen($sql_extra)) ? 'false' : 'true');
if($hash)
- $logic = 1;
+ $logic = 'true';
if($dirmode == DIRECTORY_MODE_STANDALONE) {
$sql_extra .= " and xchan_addr like '%%" . get_app()->get_hostname() . "' ";
@@ -165,7 +165,7 @@ function dirsearch_content(&$a) {
if($limit)
$qlimit = " LIMIT $limit ";
else {
- $qlimit = " LIMIT " . intval($startrec) . " , " . intval($perpage);
+ $qlimit = " LIMIT " . intval($perpage) . " OFFSET " . intval($startrec);
if($return_total) {
$r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and xchan_network = 'zot' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql ");
if($r) {
@@ -347,14 +347,15 @@ function dir_parse_query($s) {
function list_public_sites() {
+ $rand = db_getfunc('rand');
$realm = get_directory_realm();
if($realm == DIRECTORY_REALM) {
- $r = q("select * from site where site_access != 0 and site_register !=0 and ( site_realm = '%s' or site_realm = '') order by rand()",
+ $r = q("select * from site where site_access != 0 and site_register !=0 and ( site_realm = '%s' or site_realm = '') order by $rand",
dbesc($realm)
);
}
else {
- $r = q("select * from site where site_access != 0 and site_register !=0 and site_realm = '%s' order by rand()",
+ $r = q("select * from site where site_access != 0 and site_register !=0 and site_realm = '%s' order by $rand",
dbesc($realm)
);
}
diff --git a/mod/filestorage.php b/mod/filestorage.php
index 67abc2eab..05f6a79e6 100644
--- a/mod/filestorage.php
+++ b/mod/filestorage.php
@@ -21,7 +21,6 @@ function filestorage_post(&$a) {
$recurse = ((x($_POST, 'recurse')) ? intval($_POST['recurse']) : 0);
$resource = ((x($_POST, 'filehash')) ? notags($_POST['filehash']) : '');
-
$no_activity = ((x($_POST, 'no_activity')) ? intval($_POST['no_activity']) : 0);
if(! $resource) {
@@ -39,11 +38,9 @@ function filestorage_post(&$a) {
//Build directory tree and redirect
$channel = $a->get_channel();
$cloudPath = get_parent_cloudpath($channel_id, $channel['channel_address'], $resource);
+ $object = get_file_activity_object($channel_id, $resource, $cloudPath);
- $filename = find_filename_by_hash($channel_id, $resource);
- $url = $cloudPath . $filename;
-
- file_activity($channel_id, $resource, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, $url, 'post', $no_activity);
+ file_activity($channel_id, $object, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny, 'post', $no_activity);
goaway($cloudPath);
}
diff --git a/mod/locs.php b/mod/locs.php
index deb784100..d936ef5e4 100644
--- a/mod/locs.php
+++ b/mod/locs.php
@@ -11,14 +11,17 @@ function locs_post(&$a) {
if($_REQUEST['primary']) {
$hubloc_id = intval($_REQUEST['primary']);
if($hubloc_id) {
+
$r = q("select hubloc_id from hubloc where hubloc_id = %d and hubloc_hash = '%s' limit 1",
intval($hubloc_id),
dbesc($channel['channel_hash'])
);
+
if(! $r) {
notice( t('Location not found.') . EOL);
return;
}
+
$r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' ",
dbesc($channel['channel_hash'])
);
@@ -26,6 +29,7 @@ function locs_post(&$a) {
intval($hubloc_id),
dbesc($channel['channel_hash'])
);
+
proc_run('php','include/notifier.php','location',$channel['channel_id']);
return;
}
@@ -33,12 +37,14 @@ function locs_post(&$a) {
if($_REQUEST['drop']) {
$hubloc_id = intval($_REQUEST['drop']);
+
if($hubloc_id) {
$r = q("select * from hubloc where hubloc_id = %d and hubloc_url != '%s' and hubloc_hash = '%s' limit 1",
intval($hubloc_id),
dbesc(z_root()),
dbesc($channel['channel_hash'])
);
+
if(! $r) {
notice( t('Location not found.') . EOL);
return;
@@ -47,6 +53,7 @@ function locs_post(&$a) {
notice( t('Primary location cannot be removed.') . EOL);
return;
}
+
$r = q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d and hubloc_hash = '%s'",
intval($hubloc_id),
dbesc($channel['channel_hash'])
diff --git a/mod/ping.php b/mod/ping.php
index 62e8197df..e8d5636b8 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -223,7 +223,7 @@ function ping_init(&$a) {
foreach($z as $zz) {
$notifs[] = array(
'notify_link' => $a->get_baseurl() . '/notify/view/' . $zz['id'],
- 'name' => '', // not required here because the name is in the message
+ 'name' => $zz['name'],
'url' => $zz['url'],
'photo' => $zz['photo'],
'when' => relative_date($zz['date']),
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/sharedwithme.php b/mod/sharedwithme.php
index d4aa129ac..8b7d2661c 100644
--- a/mod/sharedwithme.php
+++ b/mod/sharedwithme.php
@@ -1,6 +1,6 @@
<?php
-require_once('include/text.php');
require_once('include/conversation.php');
+require_once('include/text.php');
function sharedwithme_content(&$a) {
if(! local_user()) {
@@ -12,41 +12,29 @@ function sharedwithme_content(&$a) {
$is_owner = (local_user() && (local_user() == $channel['channel_id']));
- $postverb = ACTIVITY_FILE . '/post/';
- $dropverb = ACTIVITY_FILE . '/drop/';
-
- //maintenance - see if a file got dropped and remove it systemwide
- $x = q("SELECT * FROM item WHERE verb LIKE '%s' AND uid = %d",
- dbesc($dropverb . '%'),
+ //maintenance - see if a file got dropped and remove it systemwide - this should possibly go to include/poller
+ $x = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d",
+ dbesc(ACTIVITY_UPDATE),
+ dbesc(ACTIVITY_OBJ_FILE),
intval(local_user())
);
-
- if($x) {
-
- foreach($x as $xx) {
- $hash = substr($xx['verb'], 39);
+ if($x) {
- $update = strpos($hash, '#');
+ foreach($x as $xx) {
- if($update === false) {
- q("DELETE FROM item WHERE verb = '%s' OR verb = '%s'",
- dbesc($postverb . $hash),
- dbesc($dropverb . $hash)
- );
- }
+ $object = json_decode($xx['object'],true);
- else {
-
- $arr = explode('#', $hash);
-
- q("DELETE FROM item WHERE mid != '%s' AND verb = '%s' OR verb = '%s'",
- dbesc($arr[1]),
- dbesc($postverb . $arr[0]),
- dbesc($dropverb . $hash)
- );
+ $d_mid = $object['d_mid'];
+ $u_mid = $xx['mid'];
- }
+ $y = q("DELETE FROM item WHERE obj_type = '%s' AND (verb = '%s' AND mid = '%s') OR (verb = '%s' AND mid = '%s')",
+ dbesc(ACTIVITY_OBJ_FILE),
+ dbesc(ACTIVITY_POST),
+ dbesc($d_mid),
+ dbesc(ACTIVITY_UPDATE),
+ dbesc($u_mid)
+ );
}
@@ -68,8 +56,9 @@ function sharedwithme_content(&$a) {
//drop all files - localuser
if((argc() > 1) && (argv(1) === 'dropall')) {
- q("DELETE FROM item WHERE verb LIKE '%s' AND uid = %d",
- dbesc($postverb . '%'),
+ q("DELETE FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d",
+ dbesc(ACTIVITY_POST),
+ dbesc(ACTIVITY_OBJ_FILE),
intval(local_user())
);
@@ -77,11 +66,13 @@ function sharedwithme_content(&$a) {
}
//list files
- $r = q("SELECT * FROM item WHERE verb LIKE '%s' AND uid = %d",
- dbesc($postverb . '%'),
- intval(local_user())
+ $r = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'",
+ dbesc(ACTIVITY_POST),
+ dbesc(ACTIVITY_OBJ_FILE),
+ intval(local_user()),
+ dbesc($channel['channel_hash'])
);
-
+
$o = profile_tabs($a, $is_owner, $channel['channel_address']);
$o .= '<div class="section-title-wrapper">';
@@ -96,19 +87,15 @@ function sharedwithme_content(&$a) {
if($r) {
foreach($r as $rr) {
- //don't display the files we shared with others
- if($rr['owner_xchan'] != $channel['channel_hash']) {
- unobscure($rr);
- $url = rawurldecode($rr['body']);
- $o .= '<a href="' . $url . '?f=&zid=' . $channel['xchan_addr'] . '">' . $url . '</a>&nbsp;<a href="/sharedwithme/' . $rr['id'] . '/drop" onclick="return confirmDelete();"><i class="icon-trash drop-icons"></i></a><br><br>';
- }
+ $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>&nbsp;<a href="/sharedwithme/' . $rr['id'] . '/drop" onclick="return confirmDelete();"><i class="icon-trash drop-icons"></i></a><br><br>';
}
}
$o .= '</div>';
return $o;
-
}
diff --git a/mod/sitelist.php b/mod/sitelist.php
index 95cf862df..95a53c9a4 100644
--- a/mod/sitelist.php
+++ b/mod/sitelist.php
@@ -9,10 +9,11 @@ function sitelist_init(&$a) {
$sql_order = " order by site_url ";
+ $rand = db_getfunc('rand');
if($order == 'random')
- $sql_order = " order by rand() ";
+ $sql_order = " order by $rand ";
- $sql_limit = " limit $start, $limit ";
+ $sql_limit = " LIMIT $limit OFFSET $start ";
$sql_extra = "";
if($open)
diff --git a/mod/viewconnections.php b/mod/viewconnections.php
index d4731d8c4..e97c77e76 100644
--- a/mod/viewconnections.php
+++ b/mod/viewconnections.php
@@ -82,7 +82,7 @@ function viewconnections_content(&$a) {
$tpl = get_markup_template("viewcontact_template.tpl");
$o .= replace_macros($tpl, array(
- '$title' => t('View Connnections'),
+ '$title' => t('View Connections'),
'$contacts' => $contacts,
'$paginate' => paginate($a),
));
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);
+}