aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/admin.php4
-rw-r--r--mod/allfriends.php60
-rw-r--r--mod/authtest.php7
-rw-r--r--mod/common.php8
-rw-r--r--mod/connections.php336
-rw-r--r--mod/connedit.php515
-rw-r--r--mod/crepair.php171
-rw-r--r--mod/directory.php10
-rw-r--r--mod/display.php11
-rw-r--r--mod/editblock.php2
-rw-r--r--mod/editlayout.php2
-rw-r--r--mod/editpost.php2
-rw-r--r--mod/editwebpage.php2
-rw-r--r--mod/follow.php2
-rw-r--r--mod/hcard.php53
-rw-r--r--mod/home.php100
-rw-r--r--mod/magic.php37
-rw-r--r--mod/message.php59
-rw-r--r--mod/network.php27
-rw-r--r--mod/notes.php4
-rw-r--r--mod/photos.php5
-rw-r--r--mod/post.php2
-rw-r--r--mod/profile_photo.php10
-rw-r--r--mod/profiles.php11
-rw-r--r--mod/profperm.php9
-rw-r--r--mod/search.php6
-rw-r--r--mod/settings.php6
-rwxr-xr-xmod/setup.php4
-rw-r--r--mod/sources.php21
-rw-r--r--mod/toggle_safesearch.php2
-rw-r--r--mod/viewconnections.php22
-rw-r--r--mod/zfinger.php32
32 files changed, 691 insertions, 851 deletions
diff --git a/mod/admin.php b/mod/admin.php
index 9a6aea35a..91dd0b56e 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -425,7 +425,7 @@ function admin_page_site(&$a) {
'$baseurl' => $a->get_baseurl(true),
// name, label, value, help string, extra data...
- '$sitename' => array('sitename', t("Site name"), htmlentities(get_config('system','sitename'), ENT_QUOTES), ""),
+ '$sitename' => array('sitename', t("Site name"), htmlspecialchars(get_config('system','sitename'), ENT_QUOTES, 'UTF-8'),''),
'$banner' => array('banner', t("Banner/Logo"), $banner, ""),
'$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
'$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
@@ -436,7 +436,7 @@ function admin_page_site(&$a) {
'$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
'$register_policy' => array('register_policy', t("Register policy"), get_config('system','register_policy'), "", $register_choices),
'$access_policy' => array('access_policy', t("Access policy"), get_config('system','access_policy'), "", $access_choices),
- '$register_text' => array('register_text', t("Register text"), htmlentities(get_config('system','register_text'), ENT_QUOTES, 'UTF-8'), t("Will be displayed prominently on the registration page.")),
+ '$register_text' => array('register_text', t("Register text"), htmlspecialchars(get_config('system','register_text'), ENT_QUOTES, 'UTF-8'), t("Will be displayed prominently on the registration page.")),
'$abandon_days' => array('abandon_days', t('Accounts abandoned after x days'), get_config('system','account_abandon_days'), t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')),
'$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")),
'$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")),
diff --git a/mod/allfriends.php b/mod/allfriends.php
deleted file mode 100644
index bb4df30be..000000000
--- a/mod/allfriends.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-require_once('include/socgraph.php');
-
-function allfriends_content(&$a) {
-
- $o = '';
-
- if(! local_user()) {
- notice( t('Permission denied.') . EOL);
- return;
- }
-
- if(argc() > 1)
- $cid = intval(argv(1));
- if(! $cid)
- return;
-
- $c = q("select name, url, photo from contact where id = %d and uid = %d limit 1",
- intval($cid),
- intval(local_user())
- );
-
- $a->page['aside'] .= '<div class="vcard">'
- . '<div class="fn label">' . $c[0]['name'] . '</div>'
- . '<div id="profile-photo-wrapper">'
- . '<a href="/contacts/' . $cid . '"><img class="photo" width="175" height="175"
- src="' . $c[0]['photo'] . '" alt="' . $c[0]['name'] . '" /></div>'
- . '</div>';
-
-
- if(! count($c))
- return;
-
- $o .= '<h2>' . sprintf( t('Friends of %s'), $c[0]['name']) . '</h2>';
-
-
- $r = all_friends(local_user(),$cid);
-
- if(! count($r)) {
- $o .= t('No friends to display.');
- return $o;
- }
-
- $tpl = get_markup_template('common_friends.tpl');
-
- foreach($r as $rr) {
-
- $o .= replace_macros($tpl,array(
- '$url' => $rr['url'],
- '$name' => $rr['name'],
- '$photo' => $rr['photo'],
- '$tags' => ''
- ));
- }
-
- $o .= cleardiv();
-// $o .= paginate($a);
- return $o;
-}
diff --git a/mod/authtest.php b/mod/authtest.php
index 2c8d7b4b4..7747ea504 100644
--- a/mod/authtest.php
+++ b/mod/authtest.php
@@ -6,7 +6,7 @@ require_once('mod/magic.php');
function authtest_content(&$a) {
-
+ $auth_success = false;
$o .= '<h3>Magic-Auth Diagnostic</h3>';
if(! local_user()) {
@@ -34,11 +34,16 @@ function authtest_content(&$a) {
if(! $j)
$o .= 'json_decode failure from remote site. ' . print_r($z['body'],true);
$o .= 'Remote site responded: ' . print_r($j,true);
+ if(strpos($j,'Authentication Success'))
+ $auth_success = true;
}
else {
$o .= 'fetch url failure.' . print_r($z,true);
}
}
+
+ if(! $auth_success)
+ $o .= 'Authentication Failed!' . EOL;
}
return str_replace("\n",'<br />',$o);
diff --git a/mod/common.php b/mod/common.php
index 4afaf37eb..e19a9d3a9 100644
--- a/mod/common.php
+++ b/mod/common.php
@@ -21,14 +21,6 @@ function common_init(&$a) {
}
-function common_aside(&$a) {
- if(! $a->profile['profile_uid'])
- return;
-
- profile_create_sidebar($a);
-}
-
-
function common_content(&$a) {
$o = '';
diff --git a/mod/connections.php b/mod/connections.php
index d1bb33748..10f0468b6 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -13,18 +13,6 @@ function connections_init(&$a) {
if(! local_user())
return;
- if((argc() == 2) && intval(argv(1))) {
- $r = q("SELECT abook.*, xchan.*
- FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel = %d and abook_id = %d LIMIT 1",
- intval(local_user()),
- intval(argv(1))
- );
- if($r) {
- $a->data['abook'] = $r[0];
- }
- }
-
$channel = $a->get_channel();
if($channel)
head_set_icon($channel['xchan_photo_s']);
@@ -37,13 +25,8 @@ function connections_aside(&$a) {
if (! local_user())
return;
- if(x($a->data,'abook')) {
- $a->set_widget('vcard',vcard_from_xchan($a->data['abook'],$a->get_observer()));
- }
- else {
- $a->set_widget('follow', widget_follow(array()));
- $a->set_widget('collections', group_side('connections','group',false,0,((array_key_exists('abook',$a->data)) ? $a->data['abook']['abook_xchan'] : '')));
- }
+
+ $a->set_widget('follow', widget_follow(array()));
$a->set_widget('suggest',widget_suggestions(array()));
@@ -202,319 +185,6 @@ function connections_content(&$a) {
return login();
}
- if(argc() == 3) {
-
- $contact_id = intval(argv(1));
- if(! $contact_id)
- return;
-
- $cmd = argv(2);
-
- $orig_record = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_id = %d AND abook_channel = %d AND NOT ( abook_flags & %d ) and not ( abook_flags & %d ) LIMIT 1",
- intval($contact_id),
- intval(local_user()),
- intval(ABOOK_FLAG_SELF),
- // allow drop even if pending, just duplicate the self query
- intval(($cmd === 'drop') ? ABOOK_FLAG_SELF : ABOOK_FLAG_PENDING)
- );
-
- if(! count($orig_record)) {
- notice( t('Could not access address book record.') . EOL);
- goaway($a->get_baseurl(true) . '/connections');
- }
-
- if($cmd === 'update') {
-
- // pull feed and consume it, which should subscribe to the hub.
- proc_run('php',"include/poller.php","$contact_id");
- goaway($a->get_baseurl(true) . '/connections/' . $contact_id);
-
- }
-
- if($cmd === 'refresh') {
- if(! zot_refresh($orig_record[0],get_app()->get_channel()))
- notice( t('Refresh failed - channel is currently unavailable.') );
- goaway($a->get_baseurl(true) . '/connections/' . $contact_id);
- }
-
- if($cmd === 'block') {
- if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_BLOCKED)) {
- info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_BLOCKED)
- ? t('Channel has been unblocked')
- : t('Channel has been blocked')) . EOL );
- connections_clone($a);
- }
- else
- notice(t('Unable to set address book parameters.') . EOL);
- goaway($a->get_baseurl(true) . '/connections/' . $contact_id);
- }
-
- if($cmd === 'ignore') {
- if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_IGNORED)) {
- info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_IGNORED)
- ? t('Channel has been unignored')
- : t('Channel has been ignored')) . EOL );
- connections_clone($a);
- }
- else
- notice(t('Unable to set address book parameters.') . EOL);
- goaway($a->get_baseurl(true) . '/connections/' . $contact_id);
- }
-
- if($cmd === 'archive') {
- if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_ARCHIVED)) {
- info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_ARCHIVED)
- ? t('Channel has been unarchived')
- : t('Channel has been archived')) . EOL );
- connections_clone($a);
- }
- else
- notice(t('Unable to set address book parameters.') . EOL);
- goaway($a->get_baseurl(true) . '/connections/' . $contact_id);
- }
-
- if($cmd === 'hide') {
- if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_HIDDEN)) {
- info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_HIDDEN)
- ? t('Channel has been unhidden')
- : t('Channel has been hidden')) . EOL );
- connections_clone($a);
- }
- else
- notice(t('Unable to set address book parameters.') . EOL);
- goaway($a->get_baseurl(true) . '/connections/' . $contact_id);
- }
-
- // We'll prevent somebody from unapproving a contact.
-
- if($cmd === 'approve') {
- if($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING) {
- if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_PENDING)) {
- info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING)
- ? t('Channel has been approved')
- : t('Channel has been unapproved')) . EOL );
- connections_clone($a);
- }
- else
- notice(t('Unable to set address book parameters.') . EOL);
- }
- goaway($a->get_baseurl(true) . '/connections/' . $contact_id);
- }
-
-
- if($cmd === 'drop') {
-
- require_once('include/Contact.php');
-// FIXME
-// terminate_friendship($a->get_channel(),$orig_record[0]);
-
- contact_remove(local_user(), $orig_record[0]['abook_id']);
-// FIXME - send to clones
- info( t('Contact has been removed.') . EOL );
- if(x($_SESSION,'return_url'))
- goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
- goaway($a->get_baseurl(true) . '/contacts');
-
- }
- }
-
- if((x($a->data,'abook')) && (is_array($a->data['abook']))) {
-
- $contact_id = $a->data['abook']['abook_id'];
- $contact = $a->data['abook'];
-
-
- $tabs = array(
-
- array(
- 'label' => t('View Profile'),
- 'url' => $a->get_baseurl(true) . '/chanview/?f=&cid=' . $contact['abook_id'],
- 'sel' => '',
- 'title' => sprintf( t('View %s\'s profile'), $contact['xchan_name']),
- ),
-
- array(
- 'label' => t('Refresh Permissions'),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/refresh',
- 'sel' => '',
- 'title' => t('Fetch updated permissions'),
- ),
-
- array(
- 'label' => t('Recent Activity'),
- 'url' => $a->get_baseurl(true) . '/network/?f=&cid=' . $contact['abook_id'],
- 'sel' => '',
- 'title' => t('View recent posts and comments'),
- ),
-
- array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? t('Unblock') : t('Block')),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/block',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? 'active' : ''),
- 'title' => t('Block or Unblock this connection'),
- ),
-
- array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? t('Unignore') : t('Ignore')),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/ignore',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? 'active' : ''),
- 'title' => t('Ignore or Unignore this connection'),
- ),
- array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? t('Unarchive') : t('Archive')),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/archive',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'active' : ''),
- 'title' => t('Archive or Unarchive this connection'),
- ),
- array(
- 'label' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? t('Unhide') : t('Hide')),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/hide',
- 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? 'active' : ''),
- 'title' => t('Hide or Unhide this connection'),
- ),
-
- array(
- 'label' => t('Delete'),
- 'url' => $a->get_baseurl(true) . '/connections/' . $contact['abook_id'] . '/drop',
- 'sel' => '',
- 'title' => t('Delete this connection'),
- ),
-
- );
-
- $self = false;
-
- if(! ($contact['abook_flags'] & ABOOK_FLAG_SELF)) {
- $tab_tpl = get_markup_template('common_tabs.tpl');
- $t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
- }
- else
- $self = true;
-
- $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array(
- '$baseurl' => $a->get_baseurl(true),
- '$editselect' => $editselect
- ));
-
- require_once('include/contact_selectors.php');
-
- $tpl = get_markup_template("abook_edit.tpl");
-
- if(feature_enabled(local_user(),'affinity')) {
-
- $slider_tpl = get_markup_template('contact_slider.tpl');
- $slide = replace_macros($slider_tpl,array(
- '$me' => t('Me'),
- '$val' => (($contact['abook_closeness']) ? $contact['abook_closeness'] : 99),
- '$intimate' => t('Best Friends'),
- '$friends' => t('Friends'),
- '$oldfriends' => t('Former Friends'),
- '$acquaintances' => t('Acquaintances'),
- '$world' => t('Unknown')
- ));
- }
-
- $perms = array();
- $channel = $a->get_channel();
-
- $global_perms = get_perms();
- $existing = get_all_perms(local_user(),$contact['abook_xchan']);
-
- $unapproved = array('pending', t('Approve this connection'), '', t('Accept connection to allow communication'));
-
- foreach($global_perms as $k => $v) {
- $thisperm = (($contact['abook_my_perms'] & $v[1]) ? "1" : '');
-
- // For auto permissions (when $self is true) we don't want to look at existing
- // permissions because they are enabled for the channel owner
-
- if((! $self) && ($existing[$k]))
- $thisperm = "1";
-
- $perms[] = array('perms_' . $k, $v[3], (($contact['abook_their_perms'] & $v[1]) ? "1" : ""),$thisperm, $v[1], (($channel[$v[0]] == PERMS_SPECIFIC) ? '' : '1'), $v[4]);
- }
-
- $o .= replace_macros($tpl,array(
-
- '$header' => (($self) ? t('Automatic Permissions Settings') : sprintf( t('Connections: settings for %s'),$contact['xchan_name'])),
- '$addr' => $contact['xchan_addr'],
- '$notself' => (($self) ? '' : '1'),
- '$self' => (($self) ? '1' : ''),
- '$autolbl' => t('When receiving a channel introduction, any permissions provided here will be applied to the new connection automatically and the introduction approved. Leave this page if you do not wish to use this feature.'),
- '$viewprof' => t('View Profile'),
- '$lbl_slider' => t('Slide to adjust your degree of friendship'),
- '$slide' => $slide,
- '$tabs' => $t,
- '$tab_str' => $tab_str,
- '$is_pending' => (($contact['abook_flags'] & ABOOK_FLAG_PENDING) ? 1 : ''),
- '$unapproved' => $unapproved,
- '$inherited' => t('inherited'),
- '$approve' => t('Approve this connection'),
- '$noperms' => (((! $self) && (! $contact['abook_my_perms'])) ? t('Connection has no individual permissions!') : ''),
- '$noperm_desc' => (((! $self) && (! $contact['abook_my_perms'])) ? t('This may be appropriate based on your <a href="settings">privacy settings</a>, though you may wish to review the "Advanced Permissions".') : ''),
- '$submit' => t('Submit'),
- '$lbl_vis1' => t('Profile Visibility'),
- '$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['xchan_name']),
- '$lbl_info1' => t('Contact Information / Notes'),
- '$infedit' => t('Edit contact notes'),
- '$close' => $contact['abook_closeness'],
- '$them' => t('Their Settings'),
- '$me' => t('My Settings'),
- '$perms' => $perms,
- '$forum' => t('Forum Members'),
- '$soapbox' => t('Soapbox'),
- '$full' => t('Full Sharing'),
- '$cautious' => t('Cautious Sharing'),
- '$follow' => t('Follow Only'),
- '$permlbl' => t('Individual Permissions'),
- '$permnote' => t('Some permissions may be inherited from your channel <a href="settings">privacy settings</a>, which have higher priority. Changing those inherited settings on this page will have no effect.'),
- '$advanced' => t('Advanced Permissions'),
- '$quick' => t('Quick Links'),
- '$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
- '$all_friends' => $all_friends,
- '$relation_text' => $relation_text,
- '$visit' => sprintf( t('Visit %s\'s profile - %s'),$contact['xchan_name'],$contact['xchan_url']),
- '$blockunblock' => t('Block/Unblock contact'),
- '$ignorecont' => t('Ignore contact'),
- '$lblcrepair' => t("Repair URL settings"),
- '$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:'),
- '$lost_contact' => $lost_contact,
- '$updpub' => t('Update public posts'),
- '$last_update' => $last_update,
- '$udnow' => t('Update now'),
- '$profile_select' => contact_profile_assign($contact['abook_profile']),
- '$multiprofs' => feature_enabled(local_user(),'multi_profiles'),
- '$contact_id' => $contact['abook_id'],
- '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
- '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
- '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''),
- '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
- '$archived' => (($contact['archive']) ? t('Currently archived') : ''),
- '$pending' => (($contact['archive']) ? t('Currently pending') : ''),
- '$hidden' => array('hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts <strong>may</strong> still be visible')),
- '$photo' => $contact['photo'],
- '$name' => $contact['name'],
- '$dir_icon' => $dir_icon,
- '$alt_text' => $alt_text,
- '$sparkle' => $sparkle,
- '$url' => $url
-
- ));
-
- $arr = array('contact' => $contact,'output' => $o);
-
- call_hooks('contact_edit', $arr);
-
- return $arr['output'];
-
- }
-
$blocked = false;
$hidden = false;
$ignored = false;
@@ -680,7 +350,7 @@ function connections_content(&$a) {
'name' => $rr['xchan_name'],
'username' => $rr['xchan_name'],
'sparkle' => $sparkle,
- 'link' => z_root() . '/connections/' . $rr['abook_id'],
+ 'link' => z_root() . '/connedit/' . $rr['abook_id'],
'url' => $rr['xchan_url'],
'network' => network_to_name($rr['network']),
);
diff --git a/mod/connedit.php b/mod/connedit.php
new file mode 100644
index 000000000..7fc4bfaf8
--- /dev/null
+++ b/mod/connedit.php
@@ -0,0 +1,515 @@
+<?php
+
+require_once('include/Contact.php');
+require_once('include/socgraph.php');
+require_once('include/contact_selectors.php');
+require_once('include/group.php');
+require_once('include/contact_widgets.php');
+require_once('include/zot.php');
+require_once('include/widgets.php');
+
+function connedit_init(&$a) {
+
+ if(! local_user())
+ return;
+
+ if((argc() == 2) && intval(argv(1))) {
+ $r = q("SELECT abook.*, xchan.*
+ FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_channel = %d and abook_id = %d LIMIT 1",
+ intval(local_user()),
+ intval(argv(1))
+ );
+ if($r) {
+ $a->data['abook'] = $r[0];
+ }
+ }
+
+ $channel = $a->get_channel();
+ if($channel)
+ head_set_icon($channel['xchan_photo_s']);
+
+}
+
+function connedit_aside(&$a) {
+
+
+ if (! local_user())
+ return;
+
+ if(x($a->data,'abook')) {
+ $a->set_widget('vcard',vcard_from_xchan($a->data['abook'],$a->get_observer()));
+ $a->set_widget('collections', group_side('connections','group',false,0,$a->data['abook']['abook_xchan']));
+ }
+
+ $a->set_widget('suggest',widget_suggestions(array()));
+ $a->set_widget('findpeople',findpeople_widget());
+
+}
+
+
+
+function connedit_post(&$a) {
+
+ if(! local_user())
+ return;
+
+ $contact_id = intval(argv(1));
+ if(! $contact_id)
+ return;
+
+ $orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1",
+ intval($contact_id),
+ intval(local_user())
+ );
+
+ if(! $orig_record) {
+ notice( t('Could not access contact record.') . EOL);
+ goaway($a->get_baseurl(true) . '/connections');
+ return; // NOTREACHED
+ }
+
+ call_hooks('contact_edit_post', $_POST);
+
+ $profile_id = $_POST['profile-assign'];
+ if($profile_id) {
+ $r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($profile_id),
+ intval(local_user())
+ );
+ if(! count($r)) {
+ notice( t('Could not locate selected profile.') . EOL);
+ return;
+ }
+ }
+
+ $hidden = intval($_POST['hidden']);
+
+ $priority = intval($_POST['poll']);
+ if($priority > 5 || $priority < 0)
+ $priority = 0;
+
+ $closeness = intval($_POST['closeness']);
+ if($closeness < 0)
+ $closeness = 99;
+
+ $abook_my_perms = 0;
+
+ foreach($_POST as $k => $v) {
+ if(strpos($k,'perms_') === 0) {
+ $abook_my_perms += $v;
+ }
+ }
+
+ $abook_flags = $orig_record[0]['abook_flags'];
+ $new_friend = false;
+
+ 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_flags = %d
+ where abook_id = %d AND abook_channel = %d LIMIT 1",
+ dbesc($profile_id),
+ intval($abook_my_perms),
+ intval($closeness),
+ intval($abook_flags),
+ intval($contact_id),
+ intval(local_user())
+ );
+ if($r)
+ info( t('Connection updated.') . EOL);
+ else
+ notice( t('Failed to update connection record.') . EOL);
+
+ if((x($a->data,'abook')) && $a->data['abook']['abook_my_perms'] != $abook_my_perms
+ && (! ($a->data['abook']['abook_flags'] & ABOOK_FLAG_SELF))) {
+ proc_run('php', 'include/notifier.php', 'permission_update', $contact_id);
+ }
+
+ if($new_friend) {
+ $channel = $a->get_channel();
+ $default_group = $channel['channel_default_group'];
+ if($default_group) {
+ require_once('include/group.php');
+ $g = group_rec_byhash(local_user(),$default_group);
+ if($g)
+ group_add_member(local_user(),'',$a->data['abook_xchan'],$g['id']);
+ }
+
+
+
+ // Check if settings permit ("post new friend activity" is allowed, and
+ // friends in general or this friend in particular aren't hidden)
+ // and send out a new friend activity
+ // TODO
+
+ // pull in a bit of content if there is any to pull in
+ proc_run('php','include/onepoll.php',$contact_id);
+
+ }
+
+ // Refresh the structure in memory with the new data
+
+ $r = q("SELECT abook.*, xchan.*
+ FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_channel = %d and abook_id = %d LIMIT 1",
+ intval(local_user()),
+ intval($contact_id)
+ );
+ if($r) {
+ $a->data['abook'] = $r[0];
+ }
+
+ if($new_friend) {
+ $arr = array('channel_id' => local_user(), 'abook' => $a->data['abook']);
+ call_hooks('accept_follow', $arr);
+ }
+
+ connedit_clone($a);
+
+ return;
+
+}
+
+function connedit_clone(&$a) {
+
+ if(! array_key_exists('abook',$a->data))
+ return;
+ $clone = $a->data['abook'];
+
+ unset($clone['abook_id']);
+ unset($clone['abook_account']);
+ unset($clone['abook_channel']);
+
+ build_sync_packet(0 /* use the current local_user */, array('abook' => array($clone)));
+}
+
+
+function connedit_content(&$a) {
+
+ $sort_type = 0;
+ $o = '';
+
+
+ if(! local_user()) {
+ notice( t('Permission denied.') . EOL);
+ return login();
+ }
+
+ if(argc() == 3) {
+
+ $contact_id = intval(argv(1));
+ if(! $contact_id)
+ return;
+
+ $cmd = argv(2);
+
+ $orig_record = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_id = %d AND abook_channel = %d AND NOT ( abook_flags & %d ) and not ( abook_flags & %d ) LIMIT 1",
+ intval($contact_id),
+ intval(local_user()),
+ intval(ABOOK_FLAG_SELF),
+ // allow drop even if pending, just duplicate the self query
+ intval(($cmd === 'drop') ? ABOOK_FLAG_SELF : ABOOK_FLAG_PENDING)
+ );
+
+ if(! count($orig_record)) {
+ notice( t('Could not access address book record.') . EOL);
+ goaway($a->get_baseurl(true) . '/connections');
+ }
+
+ if($cmd === 'update') {
+
+ // pull feed and consume it, which should subscribe to the hub.
+ proc_run('php',"include/poller.php","$contact_id");
+ goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+
+ }
+
+ if($cmd === 'refresh') {
+ if(! zot_refresh($orig_record[0],get_app()->get_channel()))
+ notice( t('Refresh failed - channel is currently unavailable.') );
+ goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ }
+
+ if($cmd === 'block') {
+ if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_BLOCKED)) {
+ info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_BLOCKED)
+ ? t('Channel has been unblocked')
+ : t('Channel has been blocked')) . EOL );
+ connedit_clone($a);
+ }
+ else
+ notice(t('Unable to set address book parameters.') . EOL);
+ goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ }
+
+ if($cmd === 'ignore') {
+ if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_IGNORED)) {
+ info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_IGNORED)
+ ? t('Channel has been unignored')
+ : t('Channel has been ignored')) . EOL );
+ connedit_clone($a);
+ }
+ else
+ notice(t('Unable to set address book parameters.') . EOL);
+ goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ }
+
+ if($cmd === 'archive') {
+ if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_ARCHIVED)) {
+ info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_ARCHIVED)
+ ? t('Channel has been unarchived')
+ : t('Channel has been archived')) . EOL );
+ connedit_clone($a);
+ }
+ else
+ notice(t('Unable to set address book parameters.') . EOL);
+ goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ }
+
+ if($cmd === 'hide') {
+ if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_HIDDEN)) {
+ info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_HIDDEN)
+ ? t('Channel has been unhidden')
+ : t('Channel has been hidden')) . EOL );
+ connedit_clone($a);
+ }
+ else
+ notice(t('Unable to set address book parameters.') . EOL);
+ goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ }
+
+ // We'll prevent somebody from unapproving a contact.
+
+ if($cmd === 'approve') {
+ if($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING) {
+ if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_PENDING)) {
+ info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING)
+ ? t('Channel has been approved')
+ : t('Channel has been unapproved')) . EOL );
+ connedit_clone($a);
+ }
+ else
+ notice(t('Unable to set address book parameters.') . EOL);
+ }
+ goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
+ }
+
+
+ if($cmd === 'drop') {
+
+ require_once('include/Contact.php');
+// FIXME
+// terminate_friendship($a->get_channel(),$orig_record[0]);
+
+ contact_remove(local_user(), $orig_record[0]['abook_id']);
+// FIXME - send to clones
+ info( t('Contact has been removed.') . EOL );
+ if(x($_SESSION,'return_url'))
+ goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
+ goaway($a->get_baseurl(true) . '/contacts');
+
+ }
+ }
+
+ if((x($a->data,'abook')) && (is_array($a->data['abook']))) {
+
+ $contact_id = $a->data['abook']['abook_id'];
+ $contact = $a->data['abook'];
+
+
+ $tabs = array(
+
+ array(
+ 'label' => t('View Profile'),
+ 'url' => $a->get_baseurl(true) . '/chanview/?f=&cid=' . $contact['abook_id'],
+ 'sel' => '',
+ 'title' => sprintf( t('View %s\'s profile'), $contact['xchan_name']),
+ ),
+
+ array(
+ 'label' => t('Refresh Permissions'),
+ 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/refresh',
+ 'sel' => '',
+ 'title' => t('Fetch updated permissions'),
+ ),
+
+ array(
+ 'label' => t('Recent Activity'),
+ 'url' => $a->get_baseurl(true) . '/network/?f=&cid=' . $contact['abook_id'],
+ 'sel' => '',
+ 'title' => t('View recent posts and comments'),
+ ),
+
+ array(
+ 'label' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? t('Unblock') : t('Block')),
+ 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/block',
+ 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? 'active' : ''),
+ 'title' => t('Block or Unblock this connection'),
+ ),
+
+ array(
+ 'label' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? t('Unignore') : t('Ignore')),
+ 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/ignore',
+ 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? 'active' : ''),
+ 'title' => t('Ignore or Unignore this connection'),
+ ),
+ array(
+ 'label' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? t('Unarchive') : t('Archive')),
+ 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/archive',
+ 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'active' : ''),
+ 'title' => t('Archive or Unarchive this connection'),
+ ),
+ array(
+ 'label' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? t('Unhide') : t('Hide')),
+ 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/hide',
+ 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? 'active' : ''),
+ 'title' => t('Hide or Unhide this connection'),
+ ),
+
+ array(
+ 'label' => t('Delete'),
+ 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/drop',
+ 'sel' => '',
+ 'title' => t('Delete this connection'),
+ ),
+
+ );
+
+ $self = false;
+
+ if(! ($contact['abook_flags'] & ABOOK_FLAG_SELF)) {
+ $tab_tpl = get_markup_template('common_tabs.tpl');
+ $t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
+ }
+ else
+ $self = true;
+
+ $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array(
+ '$baseurl' => $a->get_baseurl(true),
+ '$editselect' => $editselect
+ ));
+
+ require_once('include/contact_selectors.php');
+
+ $tpl = get_markup_template("abook_edit.tpl");
+
+ if(feature_enabled(local_user(),'affinity')) {
+
+ $slider_tpl = get_markup_template('contact_slider.tpl');
+ $slide = replace_macros($slider_tpl,array(
+ '$me' => t('Me'),
+ '$val' => (($contact['abook_closeness']) ? $contact['abook_closeness'] : 99),
+ '$intimate' => t('Best Friends'),
+ '$friends' => t('Friends'),
+ '$oldfriends' => t('Former Friends'),
+ '$acquaintances' => t('Acquaintances'),
+ '$world' => t('Unknown')
+ ));
+ }
+
+ $perms = array();
+ $channel = $a->get_channel();
+
+ $global_perms = get_perms();
+ $existing = get_all_perms(local_user(),$contact['abook_xchan']);
+
+ $unapproved = array('pending', t('Approve this connection'), '', t('Accept connection to allow communication'));
+
+ foreach($global_perms as $k => $v) {
+ $thisperm = (($contact['abook_my_perms'] & $v[1]) ? "1" : '');
+
+ // For auto permissions (when $self is true) we don't want to look at existing
+ // permissions because they are enabled for the channel owner
+
+ if((! $self) && ($existing[$k]))
+ $thisperm = "1";
+
+ $perms[] = array('perms_' . $k, $v[3], (($contact['abook_their_perms'] & $v[1]) ? "1" : ""),$thisperm, $v[1], (($channel[$v[0]] == PERMS_SPECIFIC) ? '' : '1'), $v[4]);
+ }
+
+ $o .= replace_macros($tpl,array(
+
+ '$header' => (($self) ? t('Automatic Permissions Settings') : sprintf( t('Connections: settings for %s'),$contact['xchan_name'])),
+ '$addr' => $contact['xchan_addr'],
+ '$notself' => (($self) ? '' : '1'),
+ '$self' => (($self) ? '1' : ''),
+ '$autolbl' => t('When receiving a channel introduction, any permissions provided here will be applied to the new connection automatically and the introduction approved. Leave this page if you do not wish to use this feature.'),
+ '$viewprof' => t('View Profile'),
+ '$lbl_slider' => t('Slide to adjust your degree of friendship'),
+ '$slide' => $slide,
+ '$tabs' => $t,
+ '$tab_str' => $tab_str,
+ '$is_pending' => (($contact['abook_flags'] & ABOOK_FLAG_PENDING) ? 1 : ''),
+ '$unapproved' => $unapproved,
+ '$inherited' => t('inherited'),
+ '$approve' => t('Approve this connection'),
+ '$noperms' => (((! $self) && (! $contact['abook_my_perms'])) ? t('Connection has no individual permissions!') : ''),
+ '$noperm_desc' => (((! $self) && (! $contact['abook_my_perms'])) ? t('This may be appropriate based on your <a href="settings">privacy settings</a>, though you may wish to review the "Advanced Permissions".') : ''),
+ '$submit' => t('Submit'),
+ '$lbl_vis1' => t('Profile Visibility'),
+ '$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['xchan_name']),
+ '$lbl_info1' => t('Contact Information / Notes'),
+ '$infedit' => t('Edit contact notes'),
+ '$close' => $contact['abook_closeness'],
+ '$them' => t('Their Settings'),
+ '$me' => t('My Settings'),
+ '$perms' => $perms,
+ '$forum' => t('Forum Members'),
+ '$soapbox' => t('Soapbox'),
+ '$full' => t('Full Sharing'),
+ '$cautious' => t('Cautious Sharing'),
+ '$follow' => t('Follow Only'),
+ '$permlbl' => t('Individual Permissions'),
+ '$permnote' => t('Some permissions may be inherited from your channel <a href="settings">privacy settings</a>, which have higher priority. Changing those inherited settings on this page will have no effect.'),
+ '$advanced' => t('Advanced Permissions'),
+ '$quick' => t('Quick Links'),
+ '$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
+ '$all_friends' => $all_friends,
+ '$relation_text' => $relation_text,
+ '$visit' => sprintf( t('Visit %s\'s profile - %s'),$contact['xchan_name'],$contact['xchan_url']),
+ '$blockunblock' => t('Block/Unblock contact'),
+ '$ignorecont' => t('Ignore contact'),
+ '$lblcrepair' => t("Repair URL settings"),
+ '$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:'),
+ '$lost_contact' => $lost_contact,
+ '$updpub' => t('Update public posts'),
+ '$last_update' => $last_update,
+ '$udnow' => t('Update now'),
+ '$profile_select' => contact_profile_assign($contact['abook_profile']),
+ '$multiprofs' => feature_enabled(local_user(),'multi_profiles'),
+ '$contact_id' => $contact['abook_id'],
+ '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
+ '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
+ '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''),
+ '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
+ '$archived' => (($contact['archive']) ? t('Currently archived') : ''),
+ '$pending' => (($contact['archive']) ? t('Currently pending') : ''),
+ '$hidden' => array('hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts <strong>may</strong> still be visible')),
+ '$photo' => $contact['photo'],
+ '$name' => $contact['name'],
+ '$dir_icon' => $dir_icon,
+ '$alt_text' => $alt_text,
+ '$sparkle' => $sparkle,
+ '$url' => $url
+
+ ));
+
+ $arr = array('contact' => $contact,'output' => $o);
+
+ call_hooks('contact_edit', $arr);
+
+ return $arr['output'];
+
+ }
+
+
+}
diff --git a/mod/crepair.php b/mod/crepair.php
deleted file mode 100644
index f749fac0e..000000000
--- a/mod/crepair.php
+++ /dev/null
@@ -1,171 +0,0 @@
-<?php
-
-function crepair_init(&$a) {
- if(! local_user())
- return;
-
- $contact_id = 0;
-
- if(($a->argc == 2) && intval($a->argv[1])) {
- $contact_id = intval($a->argv[1]);
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
- intval(local_user()),
- intval($contact_id)
- );
- if(! count($r)) {
- $contact_id = 0;
- }
- }
-
- if(! x($a->page,'aside'))
- $a->page['aside'] = '';
-
- if($contact_id) {
- $a->data['contact'] = $r[0];
- $o .= '<div class="vcard">';
- $o .= '<div class="fn">' . $a->data['contact']['name'] . '</div>';
- $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->data['contact']['photo'] . '" alt="' . $a->data['contact']['name'] . '" /></div>';
- $o .= '</div>';
- $a->page['aside'] .= $o;
-
- }
-}
-
-
-function crepair_post(&$a) {
- if(! local_user())
- return;
-
- $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
-
- if($cid) {
- $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($cid),
- intval(local_user())
- );
- }
-
- if(! count($r))
- return;
-
- $contact = $r[0];
-
- $name = ((x($_POST,'name')) ? $_POST['name'] : $contact['name']);
- $nick = ((x($_POST,'nick')) ? $_POST['nick'] : '');
- $url = ((x($_POST,'url')) ? $_POST['url'] : '');
- $request = ((x($_POST,'request')) ? $_POST['request'] : '');
- $confirm = ((x($_POST,'confirm')) ? $_POST['confirm'] : '');
- $notify = ((x($_POST,'notify')) ? $_POST['notify'] : '');
- $poll = ((x($_POST,'poll')) ? $_POST['poll'] : '');
- $attag = ((x($_POST,'attag')) ? $_POST['attag'] : '');
- $photo = ((x($_POST,'photo')) ? $_POST['photo'] : '');
-
- $r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s', `attag` = '%s'
- WHERE `id` = %d AND `uid` = %d LIMIT 1",
- dbesc($name),
- dbesc($nick),
- dbesc($url),
- dbesc($request),
- dbesc($confirm),
- dbesc($notify),
- dbesc($poll),
- dbesc($attag),
- intval($contact['id']),
- local_user()
- );
-
- if($photo) {
- logger('mod-crepair: updating photo from ' . $photo);
- require_once('include/photo/photo_driver.php');
-
- $photos = import_profile_photo($photo,local_user(),$contact['id']);
-
- $x = q("UPDATE `contact` SET `photo` = '%s',
- `thumb` = '%s',
- `micro` = '%s',
- `name_date` = '%s',
- `uri_date` = '%s',
- `avatar_date` = '%s'
- WHERE `id` = %d LIMIT 1
- ",
- dbesc($photos[0]),
- dbesc($photos[1]),
- dbesc($photos[2]),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($contact['id'])
- );
- }
-
- if($r)
- info( t('Contact settings applied.') . EOL);
- else
- notice( t('Contact update failed.') . EOL);
-
-
- return;
-}
-
-
-
-function crepair_content(&$a) {
-
- if(! local_user()) {
- notice( t('Permission denied.') . EOL);
- return;
- }
-
- $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
-
- if($cid) {
- $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($cid),
- intval(local_user())
- );
- }
-
- if(! count($r)) {
- notice( t('Contact not found.') . EOL);
- return;
- }
-
- $contact = $r[0];
-
- $msg1 = t('Repair Contact Settings');
-
- $msg2 = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.');
- $msg3 = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
-
- $o .= '<h2>' . $msg1 . '</h2>';
-
- $o .= '<div class="error-message">' . $msg2 . EOL . EOL. $msg3 . '</div>';
-
- $o .= EOL . '<a href="contacts/' . $cid . '">' . t('Return to contact editor') . '</a>' . EOL;
-
- $tpl = get_markup_template('crepair.tpl');
- $o .= replace_macros($tpl, array(
- '$label_name' => t('Name'),
- '$label_nick' => t('Account Nickname'),
- '$label_attag' => t('@Tagname - overrides Name/Nickname'),
- '$label_url' => t('Account URL'),
- '$label_request' => t('Friend Request URL'),
- '$label_confirm' => t('Friend Confirm URL'),
- '$label_notify' => t('Notification Endpoint URL'),
- '$label_poll' => t('Poll/Feed URL'),
- '$label_photo' => t('New photo from this URL'),
- '$contact_name' => $contact['name'],
- '$contact_nick' => $contact['nick'],
- '$contact_id' => $contact['id'],
- '$contact_url' => $contact['url'],
- '$request' => $contact['request'],
- '$confirm' => $contact['confirm'],
- '$notify' => $contact['notify'],
- '$poll' => $contact['poll'],
- '$contact_attag' => $contact['attag'],
- '$lbl_submit' => t('Submit')
- ));
-
- return $o;
-
-}
diff --git a/mod/directory.php b/mod/directory.php
index 616035339..92fb36ea7 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -11,15 +11,13 @@ function directory_init(&$a) {
function directory_aside(&$a) {
- if(local_user()) {
- require_once('include/contact_widgets.php');
- $a->set_widget('find_people',findpeople_widget());
- }
-
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
-
+
+ require_once('include/contact_widgets.php');
+ $a->set_widget('find_people',findpeople_widget());
+
$a->set_widget('safe_search',dir_safe_mode());
$a->set_widget('dir_sort_order',dir_sort_links());
diff --git a/mod/display.php b/mod/display.php
index 9aafec8c3..65114272a 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -139,13 +139,13 @@ function display_content(&$a, $update = 0, $load = false) {
$sql_extra = public_permissions_sql(get_observer_hash());
- if($update && $load) {
+ if(($update && $load) || ($_COOKIE['jsAvailable'] != 1)) {
$updateable = false;
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
- if($load) {
+ if($load || ($_COOKIE['jsAvailable'] != 1)) {
$r = null;
if(local_user()) {
$r = q("SELECT * from item
@@ -202,8 +202,11 @@ function display_content(&$a, $update = 0, $load = false) {
}
-
- $o .= conversation($a, $items, 'display', $update, 'client');
+ if ($_COOKIE['jsAvailable'] == 1) {
+ $o .= conversation($a, $items, 'display', $update, 'client');
+ } else {
+ $o .= conversation($a, $items, 'display', $update, 'traditional');
+ }
if($updateable) {
$x = q("UPDATE item SET item_flags = ( item_flags ^ %d )
diff --git a/mod/editblock.php b/mod/editblock.php
index 9c691640b..8b5b2d16c 100644
--- a/mod/editblock.php
+++ b/mod/editblock.php
@@ -132,7 +132,7 @@ function editblock_content(&$a) {
'$pvisit' => 'none',
'$public' => t('Public post'),
'$jotnets' => $jotnets,
- '$title' => htmlspecialchars($itm[0]['title']),
+ '$title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'),
'$placeholdertitle' => t('Set title'),
'$category' => '',
'$placeholdercategory' => t('Categories (comma-separated list)'),
diff --git a/mod/editlayout.php b/mod/editlayout.php
index f8906d981..542bb8357 100644
--- a/mod/editlayout.php
+++ b/mod/editlayout.php
@@ -117,7 +117,7 @@ function editlayout_content(&$a) {
'$pvisit' => 'none',
'$public' => t('Public post'),
'$jotnets' => $jotnets,
- '$title' => htmlspecialchars($itm[0]['title']),
+ '$title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'),
'$placeholdertitle' => t('Set title'),
'$category' => '',
'$placeholdercategory' => t('Categories (comma-separated list)'),
diff --git a/mod/editpost.php b/mod/editpost.php
index f25d6d21d..e731c04fe 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -114,7 +114,7 @@ function editpost_content(&$a) {
'$pvisit' => 'none',
'$public' => t('Public post'),
'$jotnets' => $jotnets,
- '$title' => htmlspecialchars($itm[0]['title']),
+ '$title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'),
'$placeholdertitle' => t('Set title'),
'$category' => $category,
'$placeholdercategory' => t('Categories (comma-separated list)'),
diff --git a/mod/editwebpage.php b/mod/editwebpage.php
index 840bda336..85bd9e918 100644
--- a/mod/editwebpage.php
+++ b/mod/editwebpage.php
@@ -164,7 +164,7 @@ function editwebpage_content(&$a) {
'$jotnets' => $jotnets,
'$mimeselect' => $mimeselect,
'$layoutselect' => $layoutselect,
- '$title' => htmlspecialchars($itm[0]['title']),
+ '$title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'),
'$placeholdertitle' => t('Set title'),
'$category' => '',
'$placeholdercategory' => t('Categories (comma-separated list)'),
diff --git a/mod/follow.php b/mod/follow.php
index 364fe76b9..962bb71a7 100644
--- a/mod/follow.php
+++ b/mod/follow.php
@@ -30,7 +30,7 @@ function follow_init(&$a) {
proc_run('php','include/onepoll.php',$result['abook']['abook_id']);
- goaway(z_root() . '/connections/' . $result['abook']['abook_id']);
+ goaway(z_root() . '/connedit/' . $result['abook']['abook_id']);
}
diff --git a/mod/hcard.php b/mod/hcard.php
deleted file mode 100644
index ab2fa88a1..000000000
--- a/mod/hcard.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-function hcard_init(&$a) {
-
- $blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
-
- if($a->argc > 1)
- $which = $a->argv[1];
- else {
- notice( t('No profile') . EOL );
- $a->error = 404;
- return;
- }
-
- $profile = 0;
- if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
- $which = $a->user['nickname'];
- $profile = $a->argv[1];
- }
-
- profile_load($a,$which,$profile);
-
- if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
- $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
- }
- if(x($a->profile,'openidserver'))
- $a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
- if(x($a->profile,'openid')) {
- $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
- $a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
- }
-
- if(! $blocked) {
- $keywords = ((x($a->profile,'keywords')) ? $a->profile['keywords'] : '');
- $keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
- if(strlen($keywords))
- $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
- }
-
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
- $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
- $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
- header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
-
- $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
- foreach($dfrn_pages as $dfrn)
- $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
-
-}
-
-function hcard_aside(&$a) {
- profile_create_sidebar($a);
-}
diff --git a/mod/home.php b/mod/home.php
index edcaa938d..05626dcb5 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -1,6 +1,9 @@
<?php
-if(! function_exists('home_init')) {
+require_once('include/items.php');
+require_once('include/conversation.php');
+
+
function home_init(&$a) {
$ret = array();
@@ -20,10 +23,9 @@ function home_init(&$a) {
goaway(z_root() . '/new_channel');
}
-}}
+}
-if(! function_exists('home_content')) {
function home_content(&$a) {
$o = '';
@@ -33,56 +35,62 @@ function home_content(&$a) {
if(x($_SESSION,'mobile_theme'))
unset($_SESSION['mobile_theme']);
-$channel_address = get_config("system", "site_channel" );
+ $channel_address = get_config("system", "site_channel" );
if ($channel_address){
-require_once('include/items.php');
-require_once('include/conversation.php');
-
-
-//We can do better, but until we figure out auto-linkification, let's keep things simple
- $page_id = 'home';
-
- $u = q("select channel_id from channel where channel_address = '%s' limit 1",
- dbesc($channel_address)
- );
+ // We can do better, but until we figure out auto-linkification, let's keep things simple
+
+ $page_id = 'home';
+
+ $u = q("select channel_id from channel where channel_address = '%s' limit 1",
+ dbesc($channel_address)
+ );
+
+ if(! $u) {
+ notice( t('Channel not found.') . EOL);
+ return;
+ }
+
+ $r = q("select item.* from item left join item_id on item.id = item_id.iid
+ where item.uid = %d and sid = '%s' and service = 'WEBPAGE' and
+ item_restrict = %d limit 1",
+ intval($u[0]['channel_id']),
+ dbesc($page_id),
+ intval(ITEM_WEBPAGE)
+ );
+
+ if(! $r) {
+ notice( t('Item not found.') . EOL);
+ return;
+ }
+
+ xchan_query($r);
+ $r = fetch_post_tags($r,true);
+ $a->profile = array('profile_uid' => $u[0]['channel_id']);
+ $o .= prepare_page($r[0]);
+ return $o;
+ }
- if(! $u) {
- notice( t('Channel not found.') . EOL);
- return;
+ if(get_config('system','projecthome')) {
+ $o .= file_get_contents('assets/home.html');
+ $a->page['template'] = 'full';
+ return $o;
}
- $r = q("select item.* from item left join item_id on item.id = item_id.iid
- where item.uid = %d and sid = '%s' and service = 'WEBPAGE' and
- item_restrict = %d limit 1",
- intval($u[0]['channel_id']),
- dbesc($page_id),
- intval(ITEM_WEBPAGE)
- );
-
- if(! $r) {
- notice( t('Item not found.') . EOL);
- return;
+ if(file_exists('home.html')) {
+ $o .= file_get_contents('home.html');
}
+ else {
- xchan_query($r);
- $r = fetch_post_tags($r,true);
- $a->profile = array('profile_uid' => $u[0]['channel_id']);
- $o .= prepare_page($r[0]);
+ // If there's no site channel or home contents configured, fallback to the old behaviour
-}
-
-// If there's no site channel specified, fallback to the old behaviour
- else { $o .= '<h1>' . ((x($a->config,'sitename')) ? sprintf( t("Welcome to %s") ,$a->config['sitename']) : "" ) . '</h1>';
- if(file_exists('home.html'))
- $o .= file_get_contents('home.html');
-}
-
- if (!$a->config['system']['no_login_on_homepage'])
- $o .= login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
-
- call_hooks("home_content",$o);
- return $o;
-}
+ $sitename = get_config('system','sitename');
+ if($sitename)
+ $o .= '<h1>' . sprintf( t("Welcome to %s") ,$sitename) . '</h1>';
+ if (! $a->config['system']['no_login_on_homepage'])
+ $o .= login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
+ }
+ call_hooks('home_content',$o);
+ return $o;
}
diff --git a/mod/magic.php b/mod/magic.php
index 03d09e70d..aead559a7 100644
--- a/mod/magic.php
+++ b/mod/magic.php
@@ -33,21 +33,28 @@ function magic_init(&$a) {
if(! $x) {
- // Somebody new? Finger them if they've never been seen here before
-
- if($addr) {
- $ret = zot_finger($addr,null);
- if($ret['success']) {
- $j = json_decode($ret['body'],true);
- if($j)
- import_xchan($j);
-
- // Now try again
-
- $x = q("select * from hubloc where hubloc_url = '%s' order by hubloc_connected desc limit 1",
- dbesc($basepath)
- );
- }
+ /*
+ * We have no records for, or prior communications with this hub.
+ * If an address was supplied, let's finger them to create a hub record.
+ * Otherwise we'll use the special address '[system]' which will return
+ * either a system channel or the first available normal channel. We don't
+ * really care about what channel is returned - we need the hub information
+ * from that response so that we can create signed auth packets destined
+ * for that hub.
+ *
+ */
+
+ $ret = zot_finger((($addr) ? $addr : '[system]@' . $parsed['host']),null);
+ if($ret['success']) {
+ $j = json_decode($ret['body'],true);
+ if($j)
+ import_xchan($j);
+
+ // Now try again
+
+ $x = q("select * from hubloc where hubloc_url = '%s' order by hubloc_connected desc limit 1",
+ dbesc($basepath)
+ );
}
}
diff --git a/mod/message.php b/mod/message.php
index a0382f63d..6a33f1db7 100644
--- a/mod/message.php
+++ b/mod/message.php
@@ -7,29 +7,6 @@ require_once("include/bbcode.php");
require_once('include/Contact.php');
-function message_aside(&$a) {
-
- if (! local_user())
- return;
-
- $a->set_widget('msgaside',replace_macros(get_markup_template('message_side.tpl'), array(
- '$tabs'=> array(),
-
- '$check'=>array(
- 'label' => t('Check Mail'),
- 'url' => $a->get_baseurl(true) . '/message',
- 'sel' => (argv(1) == ''),
- ),
- '$new'=>array(
- 'label' => t('New Message'),
- 'url' => $a->get_baseurl(true) . '/message/new',
- 'sel'=> (argv(1) == 'new'),
- )
-
- )));
-
-}
-
function message_post(&$a) {
if(! local_user())
@@ -321,7 +298,7 @@ function message_content(&$a) {
'$preid' => $preid,
'$subject' => t('Subject:'),
'$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''),
- '$text' => ((x($_REQUEST,'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''),
+ '$text' => ((x($_REQUEST,'body')) ? htmlspecialchars($_REQUEST['body'], ENT_COMPAT, 'UTF-8') : ''),
'$readonly' => '',
'$yourmessage' => t('Your message:'),
'$select' => $select,
@@ -425,39 +402,7 @@ function message_content(&$a) {
foreach($messages as $message) {
- $s = $arr = '';
-
- if($message['attach'])
- $arr = json_decode_plus($message['attach']);
- if($arr) {
- $s .= '<div class="body-attach">';
- foreach($arr as $r) {
- $matches = false;
- $icon = '';
- $icontype = substr($r['type'],0,strpos($r['type'],'/'));
-
- switch($icontype) {
- case 'video':
- case 'audio':
- case 'image':
- case 'text':
- $icon = '<div class="attachtype icon s22 type-' . $icontype . '"></div>';
- break;
- default:
- $icon = '<div class="attachtype icon s22 type-unkn"></div>';
- break;
- }
-
- $title = htmlentities($r['title'], ENT_COMPAT,'UTF-8');
- if(! $title)
- $title = t('unknown.???');
- $title .= ' ' . $r['length'] . ' ' . t('bytes');
-
- $url = $a->get_baseurl() . '/magic?f=&hash=' . $message['from_xchan'] . '&dest=' . $r['href'] . '/' . $r['revision'];
- $s .= '<a href="' . $url . '" title="' . $title . '" class="attachlink" >' . $icon . '</a>';
- }
- $s .= '<div class="clear"></div></div>';
- }
+ $s = theme_attachments($message);
$mails[] = array(
'id' => $message['id'],
diff --git a/mod/network.php b/mod/network.php
index 754978949..072f718ec 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -111,36 +111,11 @@ function network_content(&$a, $update = 0, $load = false) {
if(! $update) {
-
- if(feature_enabled(local_user(),'affinity')) {
- $tpl = get_markup_template('main_slider.tpl');
- $x = replace_macros($tpl,array(
- '$val' => intval($cmin) . ';' . intval($cmax),
- '$refresh' => t('Refresh'),
- '$me' => t('Me'),
- '$intimate' => t('Best Friends'),
- '$friends' => t('Friends'),
- '$coworkers' => t('Co-workers'),
- '$oldfriends' => t('Former Friends'),
- '$acquaintances' => t('Acquaintances'),
- '$world' => t('Everybody')
- ));
- $arr = array('html' => $x);
- call_hooks('main_slider',$arr);
- $o .= $arr['html'];
- }
-
-
$o .= network_tabs();
- // --- end item filter tabs
-
-
-
-
// search terms header
if($search)
- $o .= '<h2>' . t('Search Results For:') . ' ' . htmlspecialchars($search) . '</h2>';
+ $o .= '<h2>' . t('Search Results For:') . ' ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') . '</h2>';
nav_set_selected('network');
diff --git a/mod/notes.php b/mod/notes.php
index ce3460aa4..468b4ef26 100644
--- a/mod/notes.php
+++ b/mod/notes.php
@@ -6,11 +6,11 @@ function notes_init(&$a) {
logger('mod_notes: ' . print_r($_REQUEST,true));
$ret = array('success' => true);
- if($_REQUEST['note_text']) {
+ if($_REQUEST['note_text'] || $_REQUEST['note_text'] == '') {
$body = escape_tags($_REQUEST['note_text']);
set_pconfig(local_user(),'notes','text',$body);
}
logger('notes saved.');
json_return_and_die($ret);
-} \ No newline at end of file
+}
diff --git a/mod/photos.php b/mod/photos.php
index 64ca86941..0e23aa5bf 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -19,6 +19,9 @@ function photos_init(&$a) {
if(argc() > 1) {
$nick = argv(1);
+
+ profile_load($a,$nick);
+
$channelx = channelx_by_nick($nick);
if(! $channelx)
@@ -35,7 +38,7 @@ function photos_init(&$a) {
- $a->set_widget('vcard',vcard_from_xchan($a->data['channel'],$observer));
+ $a->set_widget('vcard',vcard_from_xchan('',$observer));
head_set_icon($a->data['channel']['xchan_photo_s']);
if($a->data['perms']['view_photos']) {
$a->data['albums'] = photos_albums_list($a->data['channel'],$observer);
diff --git a/mod/post.php b/mod/post.php
index 73345c4e9..7f495140e 100644
--- a/mod/post.php
+++ b/mod/post.php
@@ -232,7 +232,7 @@ function post_init(&$a) {
if($test) {
$ret['success'] = true;
- $ret['message'] .= 'Success' . EOL;
+ $ret['message'] .= 'Authentication Success!' . EOL;
json_return_and_die($ret);
}
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index e86e2a828..876e3a931 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -14,16 +14,6 @@ function profile_photo_init(&$a) {
}
-function profile_photo_aside(&$a) {
-
- if(! local_user()) {
- return;
- }
-
- profile_create_sidebar($a);
-}
-
-
function profile_photo_post(&$a) {
if(! local_user()) {
diff --git a/mod/profiles.php b/mod/profiles.php
index 173d97138..4625a8805 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -146,17 +146,6 @@ function profiles_init(&$a) {
}
}
-function profiles_aside(&$a) {
-
- if(! local_user()) {
- return;
- }
-
- if((argc() > 1) && (intval(argv(1)))) {
- profile_create_sidebar($a);
- }
-}
-
function profiles_post(&$a) {
if(! local_user()) {
diff --git a/mod/profperm.php b/mod/profperm.php
index 8054851e8..b31dfc128 100644
--- a/mod/profperm.php
+++ b/mod/profperm.php
@@ -13,15 +13,6 @@ function profperm_init(&$a) {
}
-function profperm_aside(&$a) {
-
- if(! local_user())
- return;
-
- profile_create_sidebar($a);
-}
-
-
function profperm_content(&$a) {
if(! local_user()) {
diff --git a/mod/search.php b/mod/search.php
index 7651b3a4e..2b31002fa 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -17,7 +17,7 @@ function search_saved_searches() {
$o .= '<h3>' . t('Saved Searches') . '</h3>' . "\r\n";
$o .= '<ul id="saved-search-ul">' . "\r\n";
foreach($r as $rr) {
- $o .= '<li class="saved-search-li clear"><a href="search/?f=&remove=1&search=' . rawurlencode($rr['term']) . '" title="' . t('Remove term') . '" onclick="return confirmDelete();"><i class="icon-remove drop-icons"></i></a> <a href="search/?f=&search=' . $rr['term'] . '" class="savedsearchterm" >' . htmlspecialchars($rr['term']) . '</a></li>' . "\r\n";
+ $o .= '<li class="saved-search-li clear"><a href="search/?f=&remove=1&search=' . rawurlencode($rr['term']) . '" title="' . t('Remove term') . '" onclick="return confirmDelete();"><i class="icon-remove drop-icons"></i></a> <a href="search/?f=&search=' . $rr['term'] . '" class="savedsearchterm" >' . htmlspecialchars($rr['term'], ENT_COMPAT,'UTF-8') . '</a></li>' . "\r\n";
}
$o .= '</ul><div class="clear"></div></div>' . "\r\n";
}
@@ -272,9 +272,9 @@ function search_content(&$a,$update = 0, $load = false) {
if($tag)
- $o .= '<h2>Items tagged with: ' . htmlspecialchars($search) . '</h2>';
+ $o .= '<h2>Items tagged with: ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') . '</h2>';
else
- $o .= '<h2>Search results for: ' . htmlspecialchars($search) . '</h2>';
+ $o .= '<h2>Search results for: ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') . '</h2>';
$o .= conversation($a,$items,'search',$update,'client');
diff --git a/mod/settings.php b/mod/settings.php
index 4d95f75b3..7fb6f8317 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -32,7 +32,7 @@ if (! local_user())
$a->argc = 2;
$a->argv[] = 'channel';
}
-
+/*
$channel = $a->get_channel();
$abook_self_id = 0;
@@ -99,7 +99,7 @@ if (! local_user())
array(
'label' => t('Automatic Permissions (Advanced)'),
- 'url' => $a->get_baseurl(true) . '/connections/' . $abook_self_id,
+ 'url' => $a->get_baseurl(true) . '/connedit/' . $abook_self_id,
'selected' => ''
),
@@ -132,7 +132,7 @@ if (! local_user())
'$class' => 'settings-widget',
'$items' => $tabs,
));
-
+*/
}
diff --git a/mod/setup.php b/mod/setup.php
index 429be43af..245508683 100755
--- a/mod/setup.php
+++ b/mod/setup.php
@@ -543,7 +543,7 @@ function check_htaccess(&$checks) {
function manual_config(&$a) {
- $data = htmlentities($a->data['txt']);
+ $data = htmlspecialchars($a->data['txt'],ENT_COMPAT,'UTF-8');
$o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.');
$o .= "<textarea rows=\"24\" cols=\"80\" >$data</textarea>";
return $o;
@@ -577,6 +577,8 @@ function load_database($db) {
function what_next() {
$a = get_app();
+ // install the standard theme
+ set_config('system','allowed_themes','redbasic');
$baseurl = $a->get_baseurl();
return
t('<h1>What next</h1>')
diff --git a/mod/sources.php b/mod/sources.php
index 125184d47..87bab60df 100644
--- a/mod/sources.php
+++ b/mod/sources.php
@@ -9,11 +9,25 @@ function sources_post(&$a) {
$source = intval($_REQUEST['source']);
$xchan = $_REQUEST['xchan'];
+ $abook = intval($_REQUEST['abook']);
$words = $_REQUEST['words'];
$frequency = $_REQUEST['frequency'];
$channel = $a->get_channel();
+ if($abook) {
+ $r = q("select abook_xchan from abook where abook_id = %d and abook_channel = %d limit 1",
+ intval($abook),
+ intval(local_user())
+ );
+ if($r)
+ $xchan = $r[0]['abook_xchan'];
+ }
+
+ if(! $xchan) {
+ notice ( t('Failed to create source. No channel selected.') . EOL);
+ return;
+ }
if(! $source) {
$r = q("insert into source ( src_channel_id, src_channel_xchan, src_xchan, src_patt )
@@ -92,6 +106,12 @@ function sources_content(&$a) {
intval(argv(1)),
intval(local_user())
);
+ if($r) {
+ $x = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
+ dbesc($r[0]['src_xchan']),
+ intval(local_user())
+ );
+ }
if(! $r) {
notice( t('Source not found.') . EOL);
return '';
@@ -106,6 +126,7 @@ function sources_content(&$a) {
'$desc' => t('Import all or selected content from the following channel into this channel and distribute it according to your channel settings.'),
'$words' => array( 'words', t('Only import content with these words (one per line)'),$r[0]['src_patt'],t('Leave blank to import all public content')),
'$xchan' => $r[0]['src_xchan'],
+ '$abook' => $x[0]['abook_id'],
'$name' => array( 'name', t('Channel Name'), $r[0]['xchan_name'], ''),
'$submit' => t('Submit')
));
diff --git a/mod/toggle_safesearch.php b/mod/toggle_safesearch.php
index 5fb18f694..3c800c4f3 100644
--- a/mod/toggle_safesearch.php
+++ b/mod/toggle_safesearch.php
@@ -3,6 +3,8 @@
function toggle_safesearch_init(&$a) {
$observer = get_observer_hash();
+if (! $observer)
+ return;
if($observer)
$safe_mode = get_xconfig($observer,'directory','safe_mode');
diff --git a/mod/viewconnections.php b/mod/viewconnections.php
index 9c85d63b6..4f6f81d82 100644
--- a/mod/viewconnections.php
+++ b/mod/viewconnections.php
@@ -11,17 +11,6 @@ function viewconnections_init(&$a) {
profile_load($a,argv(1));
}
-
-function viewconnections_aside(&$a) {
-
- if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
- return;
- }
-
- profile_create_sidebar($a);
-}
-
-
function viewconnections_content(&$a) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
@@ -41,14 +30,11 @@ function viewconnections_content(&$a) {
- $r = q("SELECT COUNT(abook_id) as total FROM abook WHERE abook_channel = %d AND abook_flags = 0 ",
- intval($a->profile['uid'])
- );
- if($r)
- $a->set_pager_total($r[0]['total']);
-
- $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_flags = 0 order by xchan_name LIMIT %d , %d ",
+ $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_flags = 0 and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) order by xchan_name LIMIT %d , %d ",
intval($a->profile['uid']),
+ intval(XCHAN_FLAGS_HIDDEN),
+ intval(XCHAN_FLAGS_ORPHAN),
+ intval(XCHAN_FLAGS_DELETED),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
diff --git a/mod/zfinger.php b/mod/zfinger.php
index 0827f3424..aad8e224d 100644
--- a/mod/zfinger.php
+++ b/mod/zfinger.php
@@ -52,11 +52,33 @@ function zfinger_init(&$a) {
);
}
elseif(strlen($zaddr)) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
- where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1",
- dbesc($zaddr),
- dbesc($zaddr)
- );
+ if(strpos($zaddr,'[system]') === false) { /* normal address lookup */
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
+ where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1",
+ dbesc($zaddr),
+ dbesc($zaddr)
+ );
+ }
+
+ else {
+
+ /**
+ * The special address '[system]' will return a system channel if one has been defined,
+ * Or the first valid channel we find if there are no system channels.
+ *
+ * This is used by magic-auth if we have no prior communications with this site - and
+ * returns an identity on this site which we can use to create a valid hub record so that
+ * we can exchange signed messages. The precise identity is irrelevant. It's the hub
+ * information that we really need at the other end - and this will return it.
+ *
+ */
+
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash
+ where (( channel_pageflags & %d ) or not ( channel_pageflags & %d )) order by channel_id limit 1",
+ intval(PAGE_SYSTEM),
+ intval(PAGE_REMOVED)
+ );
+ }
}
else {
$ret['message'] = 'Invalid request';