aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/admin.php30
-rw-r--r--mod/connections.php7
-rw-r--r--mod/dirsearch.php41
-rw-r--r--mod/display.php4
-rw-r--r--mod/item.php22
-rw-r--r--mod/magic.php2
-rw-r--r--mod/network.php6
-rw-r--r--mod/post.php24
-rw-r--r--mod/pubsites.php2
-rw-r--r--mod/search.php62
-rw-r--r--mod/settings.php77
-rw-r--r--mod/sources.php140
-rw-r--r--mod/zfinger.php12
13 files changed, 338 insertions, 91 deletions
diff --git a/mod/admin.php b/mod/admin.php
index e9a456b52..fad03e34a 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -49,6 +49,7 @@ function admin_post(&$a){
if(is_ajax()) return;
goaway($a->get_baseurl(true) . '/admin/themes/' . $theme );
+
return;
break;
case 'logs':
@@ -458,6 +459,25 @@ function admin_page_hubloc_post(&$a){
function admin_page_hubloc(&$a) {
$o = '';
+ $hubloc = q("SELECT hubloc_id, hubloc_addr, hubloc_host, hubloc_status FROM hubloc");
+
+
+ if(! $hubloc){
+ notice( t('No server found') . EOL);
+ goaway($a->get_baseurl(true) . '/admin/hubloc');
+ }
+
+ $t = get_markup_template("admin_hubloc.tpl");
+ return replace_macros($t, array(
+ '$hubloc' => $hubloc,
+ '$th_hubloc' => array(t('ID'), t('for channel'), t('on server'), t('Status')),
+ '$title' => t('Administration'),
+ '$page' => t('Server'),
+ '$queues' => $queues,
+ '$accounts' => $accounts,
+ '$pending' => Array( t('Pending registrations'), $pending),
+ '$plugins' => Array( t('Active plugins'), $a->plugins )
+ ));
return $o;
}
@@ -731,12 +751,16 @@ function admin_page_plugins(&$a){
}
$admin_form="";
+
if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){
@require_once("addon/$plugin/$plugin.php");
- $func = $plugin.'_plugin_admin';
- $func($a, $admin_form);
+ if(function_exists($plugin.'_plugin_admin')) {
+ $func = $plugin.'_plugin_admin';
+ $func($a, $admin_form);
+ }
}
-
+
+
$t = get_markup_template("admin_plugins_details.tpl");
return replace_macros($t, array(
'$title' => t('Administration'),
diff --git a/mod/connections.php b/mod/connections.php
index 47c8d9c44..95fc18174 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -315,6 +315,13 @@ function connections_content(&$a) {
),
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' : ''),
diff --git a/mod/dirsearch.php b/mod/dirsearch.php
index fc0ac4fe3..14307f274 100644
--- a/mod/dirsearch.php
+++ b/mod/dirsearch.php
@@ -45,7 +45,16 @@ function dirsearch_content(&$a) {
// by default use a safe search
$safe = ((x($_REQUEST,'safe')) ? intval($_REQUEST['safe']) : 1 );
- $sync = ((x($_REQUEST,'sync')) ? datetime_convert('UTC','UTC',$_REQUEST['sync']) : '');
+
+ if(array_key_exists('sync',$_REQUEST)) {
+ if($_REQUEST['sync'])
+ $sync = datetime_convert('UTC','UTC',$_REQUEST['sync']);
+ else
+ $sync = datetime_convert('UTC','UTC','2010-01-01 01:01:00');
+ }
+ else
+ $sync = false;
+
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : '');
// TODO - a meta search which joins all of these things to one search string
@@ -102,9 +111,9 @@ function dirsearch_content(&$a) {
$logic = ((strlen($sql_extra)) ? 0 : 1);
- $safesql = (($safe > 0) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED) . " ) " : '');
+ $safesql = (($safe > 0) ? " and not ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " ) " : '');
if($safe < 0)
- $safesql = " and ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED) . " ) ";
+ $safesql = " and ( xchan_flags & " . intval(XCHAN_FLAGS_CENSORED|XCHAN_FLAGS_SELFCENSORED) . " ) ";
if($limit)
$qlimit = " LIMIT $limit ";
@@ -121,13 +130,9 @@ function dirsearch_content(&$a) {
}
}
- if($mtime) {
- $qlimit = '';
-// $sql_extra .= " and xchan_hash in ( select ud_hash from updates where ud_date > '" . dbesc($mtime) . "' ) ";
- }
if($sort_order == 'date')
- $order = ""; // " order by ud_date desc ";
+ $order = ""; // Not currently implemented
elseif($sort_order == 'reverse')
$order = " order by xchan_name desc ";
else
@@ -135,11 +140,23 @@ function dirsearch_content(&$a) {
if($sync) {
-
- $r = q("select xchan.*, updates.* from xchan left join updates on ud_hash = xchan_hash where ud_date >= '%s' and ud_guid != '' order by ud_date desc",
+ $spkt = array('transactions' => array());
+ $r = q("select * from updates where ud_date >= '%s' and ud_guid != '' order by ud_date desc",
dbesc($sync)
);
-
+ if($r) {
+ foreach($r as $rr) {
+ $flags = (($rr['ud_flags'] & UPDATE_FLAGS_DELETED) ? array('deleted') : array());
+ $spkt['transactions'][] = array(
+ 'hash' => $rr['ud_hash'],
+ 'address' => $rr['ud_addr'],
+ 'transaction_id' => $rr['ud_guid'],
+ 'timestamp' => $rr['ud_date'],
+ 'flags' => $flags
+ );
+ }
+ }
+ json_return_and_die($spkt);
}
else {
$r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) $safesql $order $qlimit ",
@@ -183,7 +200,7 @@ function dirsearch_content(&$a) {
}
$ret['results'] = $entries;
- if(($kw) && (! $sync)) {
+ if($kw) {
$k = dir_tagadelic($kw);
if($k) {
$ret['keywords'] = array();
diff --git a/mod/display.php b/mod/display.php
index d19502eb1..c9f6595c6 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -113,16 +113,18 @@ function display_content(&$a, $update = 0, $load = false) {
}
}
if($r === null) {
+
$r = q("SELECT * from item
WHERE item_restrict = 0
and mid = '%s'
AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
AND `item`.`deny_gid` = '' AND item_private = 0 )
- and uid in ( " . stream_perms_api_uids() . " ))
+ and owner_xchan in ( " . stream_perms_xchans(($observer) ? PERMS_NETWORK : PERMS_PUBLIC) . " ))
$sql_extra )
group by mid limit 1",
dbesc($target_item['parent_mid'])
);
+
}
}
diff --git a/mod/item.php b/mod/item.php
index 813bcf283..f1fbd53b3 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -161,20 +161,26 @@ function item_post(&$a) {
if($parent) {
logger('mod_item: item_post parent=' . $parent);
- if(! can_comment_on_post($observer['xchan_hash'],$parent_item)) {
+ $can_comment = false;
+ if((array_key_exists('owner',$parent_item)) && ($parent_item['owner']['abook_flags'] & ABOOK_FLAG_SELF))
+ $can_comment = perm_is_allowed($profile_uid,$observer['xchan_hash'],'post_comments');
+ else
+ $can_comment = can_comment_on_post($observer['xchan_hash'],$parent_item);
+
+ if(! $can_comment) {
notice( t('Permission denied.') . EOL) ;
if(x($_REQUEST,'return'))
goaway($a->get_baseurl() . "/" . $return_path );
killme();
}
}
-
-
- if(! perm_is_allowed($profile_uid,$observer['xchan_hash'],(($parent) ? 'post_comments' : 'post_wall'))) {
- notice( t('Permission denied.') . EOL) ;
- if(x($_REQUEST,'return'))
- goaway($a->get_baseurl() . "/" . $return_path );
- killme();
+ else {
+ if(! perm_is_allowed($profile_uid,$observer['xchan_hash'],'post_wall')) {
+ notice( t('Permission denied.') . EOL) ;
+ if(x($_REQUEST,'return'))
+ goaway($a->get_baseurl() . "/" . $return_path );
+ killme();
+ }
}
diff --git a/mod/magic.php b/mod/magic.php
index 09a2e8a51..44aa19ead 100644
--- a/mod/magic.php
+++ b/mod/magic.php
@@ -4,6 +4,8 @@
function magic_init(&$a) {
+ logger('mod_magic: invoked', LOGGER_DEBUG);
+
$addr = ((x($_REQUEST,'addr')) ? $_REQUEST['addr'] : '');
$hash = ((x($_REQUEST,'hash')) ? $_REQUEST['hash'] : '');
$dest = ((x($_REQUEST,'dest')) ? $_REQUEST['dest'] : '');
diff --git a/mod/network.php b/mod/network.php
index ac8c38290..72391497b 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -452,16 +452,16 @@ function network_content(&$a, $update = 0, $load = false) {
elseif($cid) {
- $r = q("SELECT * from abook where abook_id = %d and abook_channel = %d and not ( abook_flags & " . intval(ABOOK_FLAG_BLOCKED) . ") limit 1",
+ $r = 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 & " . intval(ABOOK_FLAG_BLOCKED) . ") limit 1",
intval($cid),
intval(local_user())
);
if($r) {
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_user()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) and item_restrict = 0 ) ";
- $o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
+ $o = '<h2>' . t('Connection: ') . $r[0]['xchan_name'] . '</h2>' . $o;
}
else {
- notice( t('Invalid contact.') . EOL);
+ notice( t('Invalid connection.') . EOL);
goaway($a->get_baseurl(true) . '/network');
}
}
diff --git a/mod/post.php b/mod/post.php
index 378192cbf..92d810356 100644
--- a/mod/post.php
+++ b/mod/post.php
@@ -174,18 +174,30 @@ function post_post(&$a) {
if(array_key_exists('iv',$data)) {
$data = aes_unencapsulate($data,get_config('system','prvkey'));
logger('mod_zot: decrypt1: ' . $data, LOGGER_DATA);
- if(! $data) {
- $ret['message'] = 'Decryption failed.';
- json_return_and_die($ret);
- }
+
+// susceptible to Bleichenbacher's attack
+// if(! $data) {
+// $ret['message'] = 'Decryption failed.';
+// json_return_and_die($ret);
+// }
$data = json_decode($data,true);
}
if(! $data) {
- $ret['message'] = 'No data received.';
- json_return_and_die($ret);
+
+ // possible Bleichenbacher's attack, just treat it as a
+ // message we have no handler for. It should fail a bit
+ // further along with "no hub". Our public key is public
+ // knowledge. There's no reason why anybody should get the
+ // encryption wrong unless they're fishing or hacking. If
+ // they're developing and made a goof, this can be discovered
+ // in the logs of the destination site. If they're fishing or
+ // hacking, the bottom line is we can't verify their hub.
+ // That's all we're going to tell them.
+
+ $data = array('type' => 'bogus');
}
logger('mod_zot: decoded data: ' . print_r($data,true), LOGGER_DATA);
diff --git a/mod/pubsites.php b/mod/pubsites.php
index b9f7510fc..9728d0704 100644
--- a/mod/pubsites.php
+++ b/mod/pubsites.php
@@ -1,7 +1,7 @@
<?php
function pubsites_content(&$a) {
-
+ require_once('include/dir_fns.php');
$dirmode = intval(get_config('system','directory_mode'));
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
diff --git a/mod/search.php b/mod/search.php
index 38131f63f..9930db288 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -183,23 +183,37 @@ function search_content(&$a,$update = 0, $load = false) {
}
-
+ $pub_sql = public_permissions_sql(get_observer_hash());
if(($update) && ($load)) {
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
-dbg(1);
+
if($load) {
- $r = q("SELECT distinct mid, id as item_id from item
- WHERE item_restrict = 0
- AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 )
- OR ( `item`.`uid` = %d ))
- $sql_extra
- group by mid ORDER BY created DESC $pager_sql ",
- intval(local_user()),
- intval(ABOOK_FLAG_BLOCKED)
+ $r = null;
+
+ if(local_user()) {
+ $r = q("SELECT distinct mid, item.* from item
+ WHERE item_restrict = 0
+ AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 )
+ OR ( `item`.`uid` = %d ))
+ $sql_extra
+ group by mid ORDER BY created DESC $pager_sql ",
+ intval(local_user()),
+ intval(ABOOK_FLAG_BLOCKED)
- );
-dbg(0);
+ );
+ }
+ if($r === null) {
+ $r = q("SELECT distinct mid, item.* from item
+ WHERE item_restrict = 0
+ AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
+ AND `item`.`deny_gid` = '' AND item_private = 0 )
+ and owner_xchan in ( " . stream_perms_xchans(($observer) ? PERMS_NETWORK : PERMS_PUBLIC) . " ))
+ $pub_sql )
+ $sql_extra
+ group by mid ORDER BY created DESC $pager_sql"
+ );
+ }
}
else {
$r = array();
@@ -208,19 +222,17 @@ dbg(0);
if($r) {
- $parents_str = ids_to_querystr($r,'item_id');
-dbg(1);
- $items = q("SELECT `item`.*, `item`.`id` AS `item_id`
- FROM `item`
- WHERE item_restrict = 0
- $sql_extra and parent in ( $parents_str ) "
-// intval($a->profile['profile_uid']),
-// dbesc($parents_str)
- );
-dbg(0);
- xchan_query($items);
- $items = fetch_post_tags($items,true);
- $items = conv_sort($items,'created');
+// $parents_str = ids_to_querystr($r,'item_id');
+
+// $items = q("SELECT `item`.*, `item`.`id` AS `item_id`
+// FROM `item`
+// WHERE item_restrict = 0
+// $sql_extra and parent in ( $parents_str ) "
+// );
+
+ xchan_query($r);
+ $items = fetch_post_tags($r,true);
+// $items = conv_sort($items,'created');
} else {
$items = array();
diff --git a/mod/settings.php b/mod/settings.php
index fea9c9f72..5f1106be5 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -113,6 +113,15 @@ function settings_aside(&$a) {
}
+ if(feature_enabled(local_user(),'channel_sources')) {
+ $tabs[] = array(
+ 'label' => t('Channel Sources'),
+ 'url' => $a->get_baseurl(true) . '/sources',
+ 'selected' => ''
+ );
+
+ }
+
$tabtpl = get_markup_template("generic_links_widget.tpl");
@@ -154,10 +163,17 @@ function settings_post(&$a) {
$secret = ((x($_POST,'secret')) ? $_POST['secret'] : '');
$redirect = ((x($_POST,'redirect')) ? $_POST['redirect'] : '');
$icon = ((x($_POST,'icon')) ? $_POST['icon'] : '');
- if ($name=="" || $key=="" || $secret==""){
- notice(t("Missing some important data!"));
-
- } else {
+ $ok = true;
+ if($name == '') {
+ $ok = false;
+ notice( t('Name is required') . EOL);
+ }
+ if($key == '' || $secret == '') {
+ $ok = false;
+ notice( t('Key and Secret are required') . EOL);
+ }
+
+ if($ok) {
if ($_POST['submit']==t("Update")){
$r = q("UPDATE clients SET
client_id='%s',
@@ -361,26 +377,33 @@ function settings_post(&$a) {
$post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0);
$post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0);
$post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0);
+ $adult = (($_POST['adult'] == 1) ? 1 : 0);
+ $channel = $a->get_channel();
+ $pageflags = $channel['channel_pageflags'];
+ $existing_adult = (($pageflags & PAGE_ADULT) ? 1 : 0);
+ if($adult != $existing_adult)
+ $pageflags = ($pageflags ^ PAGE_ADULT);
$arr = array();
- $arr['channel_r_stream'] = (($_POST['view_stream']) ? $_POST['view_stream'] : 0);
- $arr['channel_r_profile'] = (($_POST['view_profile']) ? $_POST['view_profile'] : 0);
- $arr['channel_r_photos'] = (($_POST['view_photos']) ? $_POST['view_photos'] : 0);
- $arr['channel_r_abook'] = (($_POST['view_contacts']) ? $_POST['view_contacts'] : 0);
- $arr['channel_w_stream'] = (($_POST['send_stream']) ? $_POST['send_stream'] : 0);
- $arr['channel_w_wall'] = (($_POST['post_wall']) ? $_POST['post_wall'] : 0);
- $arr['channel_w_tagwall'] = (($_POST['tag_deliver']) ? $_POST['tag_deliver'] : 0);
- $arr['channel_w_comment'] = (($_POST['post_comments']) ? $_POST['post_comments'] : 0);
- $arr['channel_w_mail'] = (($_POST['post_mail']) ? $_POST['post_mail'] : 0);
- $arr['channel_w_photos'] = (($_POST['post_photos']) ? $_POST['post_photos'] : 0);
- $arr['channel_w_chat'] = (($_POST['chat']) ? $_POST['chat'] : 0);
- $arr['channel_a_delegate'] = (($_POST['delegate']) ? $_POST['delegate'] : 0);
- $arr['channel_r_storage'] = (($_POST['view_storage']) ? $_POST['view_storage'] : 0);
- $arr['channel_w_storage'] = (($_POST['write_storage']) ? $_POST['write_storage'] : 0);
- $arr['channel_r_pages'] = (($_POST['view_pages']) ? $_POST['view_pages'] : 0);
- $arr['channel_w_pages'] = (($_POST['write_pages']) ? $_POST['write_pages'] : 0);
-
+ $arr['channel_r_stream'] = (($_POST['view_stream']) ? $_POST['view_stream'] : 0);
+ $arr['channel_r_profile'] = (($_POST['view_profile']) ? $_POST['view_profile'] : 0);
+ $arr['channel_r_photos'] = (($_POST['view_photos']) ? $_POST['view_photos'] : 0);
+ $arr['channel_r_abook'] = (($_POST['view_contacts']) ? $_POST['view_contacts'] : 0);
+ $arr['channel_w_stream'] = (($_POST['send_stream']) ? $_POST['send_stream'] : 0);
+ $arr['channel_w_wall'] = (($_POST['post_wall']) ? $_POST['post_wall'] : 0);
+ $arr['channel_w_tagwall'] = (($_POST['tag_deliver']) ? $_POST['tag_deliver'] : 0);
+ $arr['channel_w_comment'] = (($_POST['post_comments']) ? $_POST['post_comments'] : 0);
+ $arr['channel_w_mail'] = (($_POST['post_mail']) ? $_POST['post_mail'] : 0);
+ $arr['channel_w_photos'] = (($_POST['post_photos']) ? $_POST['post_photos'] : 0);
+ $arr['channel_w_chat'] = (($_POST['chat']) ? $_POST['chat'] : 0);
+ $arr['channel_a_delegate'] = (($_POST['delegate']) ? $_POST['delegate'] : 0);
+ $arr['channel_r_storage'] = (($_POST['view_storage']) ? $_POST['view_storage'] : 0);
+ $arr['channel_w_storage'] = (($_POST['write_storage']) ? $_POST['write_storage'] : 0);
+ $arr['channel_r_pages'] = (($_POST['view_pages']) ? $_POST['view_pages'] : 0);
+ $arr['channel_w_pages'] = (($_POST['write_pages']) ? $_POST['write_pages'] : 0);
+ $arr['channel_a_republish'] = (($_POST['republish']) ? $_POST['republish'] : 0);
+
$defperms = 0;
if(x($_POST['def_view_stream']))
$defperms += $_POST['def_view_stream'];
@@ -414,6 +437,8 @@ function settings_post(&$a) {
$defperms += $_POST['def_view_pages'];
if(x($_POST['def_write_pages']))
$defperms += $_POST['def_write_pages'];
+ if(x($_POST['def_republish']))
+ $defperms += $_POST['def_republish'];
$notify = 0;
@@ -518,8 +543,9 @@ function settings_post(&$a) {
);
*/
- $r = q("update channel set channel_name = '%s', channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d, channel_r_stream = %d, channel_r_profile = %d, channel_r_photos = %d, channel_r_abook = %d, channel_w_stream = %d, channel_w_wall = %d, channel_w_tagwall = %d, channel_w_comment = %d, channel_w_mail = %d, channel_w_photos = %d, channel_w_chat = %d, channel_a_delegate = %d, channel_r_storage = %d, channel_w_storage = %d, channel_r_pages = %d, channel_w_pages = %d where channel_id = %d limit 1",
+ $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d, channel_r_stream = %d, channel_r_profile = %d, channel_r_photos = %d, channel_r_abook = %d, channel_w_stream = %d, channel_w_wall = %d, channel_w_tagwall = %d, channel_w_comment = %d, channel_w_mail = %d, channel_w_photos = %d, channel_w_chat = %d, channel_a_delegate = %d, channel_r_storage = %d, channel_w_storage = %d, channel_r_pages = %d, channel_w_pages = %d, channel_a_republish = %d where channel_id = %d limit 1",
dbesc($username),
+ intval($pageflags),
dbesc($timezone),
dbesc($defloc),
intval($notify),
@@ -542,6 +568,7 @@ function settings_post(&$a) {
intval($arr['channel_w_storage']),
intval($arr['channel_r_pages']),
intval($arr['channel_w_pages']),
+ intval($arr['channel_a_republish']),
intval(local_user())
);
@@ -621,8 +648,8 @@ function settings_content(&$a) {
'$submit' => t('Submit'),
'$cancel' => t('Cancel'),
'$name' => array('name', t('Name'), '', t('Name of application')),
- '$key' => array('key', t('Consumer Key'), random_string(16), t('Automatically generated - change if desired')),
- '$secret' => array('secret', t('Consumer Secret'), random_string(16), t('Automatically generated - change if desired')),
+ '$key' => array('key', t('Consumer Key'), random_string(16), t('Automatically generated - change if desired. Max length 20')),
+ '$secret' => array('secret', t('Consumer Secret'), random_string(16), t('Automatically generated - change if desired. Max length 20')),
'$redirect' => array('redirect', t('Redirect'), '', t('Redirect URI - leave blank unless your application specifically requires this')),
'$icon' => array('icon', t('Icon url'), '', t('Optional')),
));
@@ -929,6 +956,7 @@ function settings_content(&$a) {
$maxreq = $channel['channel_max_friend_req'];
$expire = $channel['channel_expire_days'];
+ $adult_flag = intval($channel['channel_pageflags'] & PAGE_ADULT);
$blockwall = $a->user['blockwall'];
$unkmail = $a->user['unkmail'];
@@ -1034,6 +1062,7 @@ function settings_content(&$a) {
'$defloc' => array('defloc', t('Default Post Location:'), $defloc, ''),
'$allowloc' => array('allow_location', t('Use Browser Location:'), ((get_pconfig(local_user(),'system','use_browser_location')) ? 1 : ''), ''),
+ '$adult' => array('adult', t('Adult Content'), $adult_flag, t('This channel publishes adult content.')),
'$h_prv' => t('Security and Privacy Settings'),
diff --git a/mod/sources.php b/mod/sources.php
new file mode 100644
index 000000000..125184d47
--- /dev/null
+++ b/mod/sources.php
@@ -0,0 +1,140 @@
+<?php /** @file */
+
+function sources_post(&$a) {
+ if(! local_user())
+ return;
+
+ if(! feature_enabled(local_user(),'channel_sources'))
+ return '';
+
+ $source = intval($_REQUEST['source']);
+ $xchan = $_REQUEST['xchan'];
+ $words = $_REQUEST['words'];
+ $frequency = $_REQUEST['frequency'];
+
+ $channel = $a->get_channel();
+
+
+ if(! $source) {
+ $r = q("insert into source ( src_channel_id, src_channel_xchan, src_xchan, src_patt )
+ values ( %d, '%s', '%s', '%s' ) ",
+ intval(local_user()),
+ dbesc($channel['channel_hash']),
+ dbesc($xchan),
+ dbesc($words)
+ );
+ if($r) {
+ info( t('Source created.') . EOL);
+ }
+ goaway(z_root() . '/sources');
+ }
+ else {
+ $r = q("update source set src_xchan = '%s', src_patt = '%s' where src_channel_id = %d and src_id = %d limit 1",
+ dbesc($xchan),
+ dbesc($words),
+ intval(local_user()),
+ intval($source)
+ );
+ if($r) {
+ info( t('Source updated.') . EOL);
+ }
+
+ }
+}
+
+
+function sources_content(&$a) {
+ if(! local_user()) {
+ notice( t('Permission denied.') . EOL);
+ return '';
+ }
+
+ if(! feature_enabled(local_user(),'channel_sources')) {
+ return '';
+ }
+
+ // list sources
+ if(argc() == 1) {
+ $r = q("select source.*, xchan.* from source left join xchan on src_xchan = xchan_hash where src_channel_id = %d",
+ intval(local_user())
+ );
+ if($r) {
+ for($x = 0; $x < count($r); $x ++) {
+ $r[$x]['src_patt'] = htmlspecialchars($r[$x]['src_patt'], ENT_COMPAT,'UTF-8');
+ }
+ }
+ $o = replace_macros(get_markup_template('sources_list.tpl'), array(
+ '$title' => t('Channel Sources'),
+ '$desc' => t('Manage remote sources of content for your channel.'),
+ '$new' => t('New Source'),
+ '$sources' => $r
+ ));
+ return $o;
+ }
+
+ if(argc() == 2 && argv(1) === 'new') {
+ // TODO add the words 'or RSS feed' and corresponding code to manage feeds and frequency
+
+ $o = replace_macros(get_markup_template('sources_new.tpl'), array(
+ '$title' => t('New Source'),
+ '$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)'),'',t('Leave blank to import all public content')),
+ '$name' => array( 'name', t('Channel Name'), '', ''),
+ '$submit' => t('Submit')
+ ));
+ return $o;
+
+ }
+
+ if(argc() == 2 && intval(argv(1))) {
+ // edit source
+ $r = q("select source.*, xchan.* from source left join xchan on src_xchan = xchan_hash where src_id = %d and src_channel_id = %d limit 1",
+ intval(argv(1)),
+ intval(local_user())
+ );
+ if(! $r) {
+ notice( t('Source not found.') . EOL);
+ return '';
+ }
+
+ $r[0]['src_patt'] = htmlspecialchars($r[0]['src_patt'], ENT_QUOTES,'UTF-8');
+
+ $o = replace_macros(get_markup_template('sources_edit.tpl'), array(
+ '$title' => t('Edit Source'),
+ '$drop' => t('Delete Source'),
+ '$id' => $r[0]['src_id'],
+ '$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'],
+ '$name' => array( 'name', t('Channel Name'), $r[0]['xchan_name'], ''),
+ '$submit' => t('Submit')
+ ));
+ return $o;
+
+ }
+
+ if(argc() == 3 && intval(argv(1)) && argv(2) === 'drop') {
+ $r = q("select * from source where src_id = %d and src_channel_id = %d limit 1",
+ intval(argv(1)),
+ intval(local_user())
+ );
+ if(! $r) {
+ notice( t('Source not found.') . EOL);
+ return '';
+ }
+ $r = q("delete from source where src_id = %d and src_channel_id = %d limit 1",
+ intval(argv(1)),
+ intval(local_user())
+ );
+ if($r)
+ info( t('Source removed') . EOL);
+ else
+ notice( t('Unable to remove source.') . EOL);
+
+ goaway(z_root() . '/sources');
+
+ }
+
+ // shouldn't get here.
+
+} \ No newline at end of file
diff --git a/mod/zfinger.php b/mod/zfinger.php
index e1e19054e..3671da56e 100644
--- a/mod/zfinger.php
+++ b/mod/zfinger.php
@@ -72,8 +72,8 @@ function zfinger_init(&$a) {
$id = $e['channel_id'];
$special_channel = (($e['channel_pageflags'] & PAGE_PREMIUM) ? true : false);
-
- $searchable = (($e['channel_pageflags'] & PAGE_HIDDEN) ? false : true);
+ $adult_channel = (($e['channel_pageflags'] & PAGE_ADULT) ? true : false);
+ $searchable = (($e['channel_pageflags'] & PAGE_HIDDEN) ? false : true);
if($e['xchan_flags'] & XCHAN_FLAGS_HIDDEN)
$searchable = false;
@@ -136,7 +136,8 @@ function zfinger_init(&$a) {
$ret['target'] = $ztarget;
$ret['target_sig'] = $zsig;
$ret['searchable'] = $searchable;
-
+ $ret['adult_content'] = $adult_channel;
+
// premium or other channel desiring some contact with potential followers before connecting.
// This is a template - %s will be replaced with the follow_url we discover for the return channel.
@@ -163,11 +164,6 @@ function zfinger_init(&$a) {
$ret['locations'] = array();
-
-
-
-
-
$x = zot_get_hubloc(array($e['channel_hash']));
if($x && count($x)) {
foreach($x as $hub) {