diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/allfriends.php | 60 | ||||
-rw-r--r-- | mod/directory.php | 10 | ||||
-rw-r--r-- | mod/home.php | 100 | ||||
-rw-r--r-- | mod/magic.php | 37 | ||||
-rw-r--r-- | mod/message.php | 23 | ||||
-rw-r--r-- | mod/settings.php | 4 | ||||
-rwxr-xr-x | mod/setup.php | 2 | ||||
-rw-r--r-- | mod/sources.php | 21 | ||||
-rw-r--r-- | mod/zfinger.php | 32 |
9 files changed, 132 insertions, 157 deletions
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/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/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 b5420e5b3..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()) diff --git a/mod/settings.php b/mod/settings.php index 4d95f75b3..c2a540063 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; @@ -132,7 +132,7 @@ if (! local_user()) '$class' => 'settings-widget', '$items' => $tabs, )); - +*/ } diff --git a/mod/setup.php b/mod/setup.php index 0198f1f09..245508683 100755 --- a/mod/setup.php +++ b/mod/setup.php @@ -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/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'; |