diff options
Diffstat (limited to 'Zotlabs')
51 files changed, 200 insertions, 113 deletions
diff --git a/Zotlabs/Daemon/Cron_weekly.php b/Zotlabs/Daemon/Cron_weekly.php index dc781ad73..1d8420947 100644 --- a/Zotlabs/Daemon/Cron_weekly.php +++ b/Zotlabs/Daemon/Cron_weekly.php @@ -21,7 +21,6 @@ class Cron_weekly { require_once('include/hubloc.php'); prune_hub_reinstalls(); - require_once('include/Contact.php'); mark_orphan_hubsxchans(); diff --git a/Zotlabs/Daemon/Externals.php b/Zotlabs/Daemon/Externals.php index 167b0524f..24cfe64ec 100644 --- a/Zotlabs/Daemon/Externals.php +++ b/Zotlabs/Daemon/Externals.php @@ -3,7 +3,7 @@ namespace Zotlabs\Daemon; require_once('include/zot.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); class Externals { diff --git a/Zotlabs/Daemon/Gprobe.php b/Zotlabs/Daemon/Gprobe.php index 8141739be..43cce93c3 100644 --- a/Zotlabs/Daemon/Gprobe.php +++ b/Zotlabs/Daemon/Gprobe.php @@ -22,9 +22,8 @@ class Gprobe { ); if(! $r) { - $x = zot_finger($url,null); - if($x['success']) { - $j = json_decode($x['body'],true); + $j = \Zotlabs\Zot\Finger::run($url,null); + if($j['success']) { $y = import_xchan($j); } } diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 65690f8ce..590be31ee 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -72,8 +72,7 @@ require_once('include/queue_fn.php'); require_once('include/datetime.php'); require_once('include/items.php'); require_once('include/bbcode.php'); -require_once('include/identity.php'); -require_once('include/Contact.php'); +require_once('include/channel.php'); class Notifier { diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php index 2610ad151..036a4991b 100644 --- a/Zotlabs/Daemon/Onepoll.php +++ b/Zotlabs/Daemon/Onepoll.php @@ -4,7 +4,7 @@ namespace Zotlabs\Daemon; require_once('include/zot.php'); require_once('include/socgraph.php'); -require_once('include/Contact.php'); + class Onepoll { diff --git a/Zotlabs/Daemon/Ratenotif.php b/Zotlabs/Daemon/Ratenotif.php index a404273e2..1cba5e26d 100644 --- a/Zotlabs/Daemon/Ratenotif.php +++ b/Zotlabs/Daemon/Ratenotif.php @@ -12,7 +12,6 @@ class Ratenotif { require_once("datetime.php"); require_once('include/items.php'); - require_once('include/Contact.php'); if($argc < 3) return; diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 2bcf167e9..a6d4f8517 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -165,7 +165,7 @@ class ThreadStream { $item->set_commentable(can_comment_on_post($this->observer['xchan_hash'],$item->data)); } } - require_once('include/identity.php'); + require_once('include/channel.php'); $item->set_conversation($this); $this->threads[] = $item; diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index cd6e45e9f..172b109c8 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -902,7 +902,6 @@ class Admin extends \Zotlabs\Web\Controller { } // account delete button was submitted if (x($_POST, 'page_users_delete')) { - require_once('include/Contact.php'); foreach ($users as $uid){ account_remove($uid, true, false); } @@ -951,7 +950,6 @@ class Admin extends \Zotlabs\Web\Controller { switch (argv(2)){ case 'delete': // delete user - require_once('include/Contact.php'); account_remove($uid,true,false); notice( sprintf(t("Account '%s' deleted"), $account[0]['account_email']) . EOL); @@ -1096,7 +1094,6 @@ class Admin extends \Zotlabs\Web\Controller { notice( sprintf( tt("%s channel code allowed/disallowed", "%s channels code allowed/disallowed", count($channels)), count($channels)) ); } if (x($_POST,'page_channels_delete')){ - require_once("include/Contact.php"); foreach($channels as $uid){ channel_remove($uid,true); } @@ -1128,7 +1125,6 @@ class Admin extends \Zotlabs\Web\Controller { case "delete":{ check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't'); // delete channel - require_once("include/Contact.php"); channel_remove($uid,true); notice( sprintf(t("Channel '%s' deleted"), $channel[0]['channel_name']) . EOL); diff --git a/Zotlabs/Module/Blocks.php b/Zotlabs/Module/Blocks.php index ed702befb..32650a090 100644 --- a/Zotlabs/Module/Blocks.php +++ b/Zotlabs/Module/Blocks.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); diff --git a/Zotlabs/Module/Cal.php b/Zotlabs/Module/Cal.php index 958ce5aa6..602a2b5ab 100644 --- a/Zotlabs/Module/Cal.php +++ b/Zotlabs/Module/Cal.php @@ -6,8 +6,6 @@ require_once('include/bbcode.php'); require_once('include/datetime.php'); require_once('include/event.php'); require_once('include/items.php'); -require_once('include/Contact.php'); - class Cal extends \Zotlabs\Web\Controller { diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php index f70444816..c6dd07eb7 100644 --- a/Zotlabs/Module/Chanview.php +++ b/Zotlabs/Module/Chanview.php @@ -1,10 +1,8 @@ <?php namespace Zotlabs\Module; -require_once('include/Contact.php'); require_once('include/zot.php'); - class Chanview extends \Zotlabs\Web\Controller { function get() { @@ -62,18 +60,15 @@ class Chanview extends \Zotlabs\Web\Controller { } if($_REQUEST['address']) { - $ret = zot_finger($_REQUEST['address'],null); - if($ret['success']) { - $j = json_decode($ret['body'],true); - if($j) - import_xchan($j); + $j = \Zotlabs\Zot\Finger::run($_REQUEST['address'],null); + if($j['success']) { + import_xchan($j); $r = q("select * from xchan where xchan_addr = '%s' limit 1", dbesc($_REQUEST['address']) ); if($r) \App::$poi = $r[0]; } - } } diff --git a/Zotlabs/Module/Connect.php b/Zotlabs/Module/Connect.php index 382abf370..f68e0baac 100644 --- a/Zotlabs/Module/Connect.php +++ b/Zotlabs/Module/Connect.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; /** @file */ -require_once('include/Contact.php'); + require_once('include/contact_widgets.php'); require_once('include/items.php'); diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index ebf8ff8e6..a412d16ae 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/Contact.php'); + require_once('include/socgraph.php'); require_once('include/selectors.php'); require_once('include/group.php'); diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 8bf4ac9b4..c9b20ae14 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -7,7 +7,7 @@ namespace Zotlabs\Module; * */ -require_once('include/Contact.php'); + require_once('include/socgraph.php'); require_once('include/selectors.php'); require_once('include/group.php'); @@ -485,7 +485,6 @@ class Connedit extends \Zotlabs\Web\Controller { if($cmd === 'drop') { - require_once('include/Contact.php'); // FIXME // We need to send either a purge or a refresh packet to the other side (the channel being unfriended). diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index aafc1bdb0..2e53696ff 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -8,7 +8,7 @@ namespace Zotlabs\Module; */ require_once('include/photo/photo_driver.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 2a5a04a2a..6e880cbb4 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -185,7 +185,7 @@ class Display extends \Zotlabs\Web\Controller { if($load || ($checkjs->disabled())) { $r = null; - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); $sysid = $sys['channel_id']; @@ -233,7 +233,7 @@ class Display extends \Zotlabs\Web\Controller { elseif($update && !$load) { $r = null; - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); $sysid = $sys['channel_id']; diff --git a/Zotlabs/Module/Editblock.php b/Zotlabs/Module/Editblock.php index a79962033..fb86557f2 100644 --- a/Zotlabs/Module/Editblock.php +++ b/Zotlabs/Module/Editblock.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/acl_selectors.php'); require_once('include/conversation.php'); diff --git a/Zotlabs/Module/Editlayout.php b/Zotlabs/Module/Editlayout.php index c5b50235a..5028882d2 100644 --- a/Zotlabs/Module/Editlayout.php +++ b/Zotlabs/Module/Editlayout.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/acl_selectors.php'); require_once('include/conversation.php'); diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index c2346c53b..1b5c320a0 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/acl_selectors.php'); require_once('include/conversation.php'); require_once('include/PermissionDescription.php'); diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php index 6999e77e8..09d761887 100644 --- a/Zotlabs/Module/Getfile.php +++ b/Zotlabs/Module/Getfile.php @@ -21,7 +21,6 @@ namespace Zotlabs\Module; -require_once('include/Contact.php'); require_once('include/attach.php'); diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 4e99155fb..57ced22a3 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -4,9 +4,9 @@ namespace Zotlabs\Module; // Import a channel, either by direct file upload or via // connection to original server. -require_once('include/Contact.php'); + require_once('include/zot.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/import.php'); diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index ff8510ade..b4f493e5b 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -56,7 +56,7 @@ class Item extends \Zotlabs\Web\Controller { $remote_xchan = $remote_observer = false; $profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0); - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); if($sys && $profile_uid && ($sys['channel_id'] == $profile_uid) && is_site_admin()) { $uid = intval($sys['channel_id']); diff --git a/Zotlabs/Module/Layouts.php b/Zotlabs/Module/Layouts.php index 8a7207fc2..9b9fc22f3 100644 --- a/Zotlabs/Module/Layouts.php +++ b/Zotlabs/Module/Layouts.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index 63db4a317..6798f72a9 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -47,11 +47,9 @@ class Magic extends \Zotlabs\Web\Controller { * */ - $ret = zot_finger((($addr) ? $addr : '[system]@' . $parsed['host']),null); - if($ret['success']) { - $j = json_decode($ret['body'],true); - if($j) - import_xchan($j); + $j = \Zotlabs\Zot\Finger::run((($addr) ? $addr : '[system]@' . $parsed['host']),null); + if($j['success']) { + import_xchan($j); // Now try again diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index e6487d681..aae7585c4 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -5,7 +5,7 @@ require_once('include/acl_selectors.php'); require_once('include/message.php'); require_once('include/zot.php'); require_once("include/bbcode.php"); -require_once('include/Contact.php'); + @@ -32,17 +32,16 @@ class Mail extends \Zotlabs\Web\Controller { if(! $recipient) { $channel = \App::get_channel(); - $ret = zot_finger($rstr,$channel); + $j = \Zotlabs\Zot\Finger::run($rstr,$channel); - if(! $ret['success']) { + if(! $j['success']) { notice( t('Unable to lookup recipient.') . EOL); return; } - $j = json_decode($ret['body'],true); logger('message_post: lookup: ' . $url . ' ' . print_r($j,true)); - if(! ($j['success'] && $j['guid'])) { + if(! $j['guid']) { notice( t('Unable to communicate with requested channel.')); return; } @@ -306,11 +305,6 @@ class Mail extends \Zotlabs\Web\Controller { else \App::$poi = $messages[0]['to']; - // require_once('include/Contact.php'); - - // \App::set_widget('mail_conversant',vcard_from_xchan(\App::$poi,$get_observer_hash,'mail')); - - $tpl = get_markup_template('msg-header.tpl'); \App::$page['htmlhead'] .= replace_macros($tpl, array( diff --git a/Zotlabs/Module/Menu.php b/Zotlabs/Module/Menu.php index 9ada63911..e98053f8c 100644 --- a/Zotlabs/Module/Menu.php +++ b/Zotlabs/Module/Menu.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; require_once('include/menu.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); class Menu extends \Zotlabs\Web\Controller { diff --git a/Zotlabs/Module/Message.php b/Zotlabs/Module/Message.php index 58a138899..ea2127a1d 100644 --- a/Zotlabs/Module/Message.php +++ b/Zotlabs/Module/Message.php @@ -5,8 +5,6 @@ require_once('include/acl_selectors.php'); require_once('include/message.php'); require_once('include/zot.php'); require_once("include/bbcode.php"); -require_once('include/Contact.php'); - class Message extends \Zotlabs\Web\Controller { diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index c88258a78..238df3593 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -385,7 +385,7 @@ class Network extends \Zotlabs\Web\Controller { $abook_uids = " and abook.abook_channel = " . local_channel() . " "; if($firehose && (! get_config('system','disable_discover_tab'))) { - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); $uids = " and item.uid = " . intval($sys['channel_id']) . " "; \App::$data['firehose'] = intval($sys['channel_id']); diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php index 3dca1b0b4..30d7c83c6 100644 --- a/Zotlabs/Module/New_channel.php +++ b/Zotlabs/Module/New_channel.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/permissions.php'); diff --git a/Zotlabs/Module/Oep.php b/Zotlabs/Module/Oep.php index 638ea7e2d..89824fc7e 100644 --- a/Zotlabs/Module/Oep.php +++ b/Zotlabs/Module/Oep.php @@ -181,8 +181,8 @@ class Oep extends \Zotlabs\Web\Controller { function oep_profile_reply($args) { - require_once('include/identity.php'); - require_once('include/Contact.php'); + require_once('include/channel.php'); + $url = $args['url']; if(preg_match('#//(.*?)/(.*?)/(.*?)(/|\?|&|$)#',$url,$matches)) { diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 1659350a5..266ac05e0 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -1,12 +1,12 @@ <?php namespace Zotlabs\Module; + require_once('include/photo/photo_driver.php'); require_once('include/photos.php'); require_once('include/items.php'); require_once('include/acl_selectors.php'); require_once('include/bbcode.php'); require_once('include/security.php'); -require_once('include/Contact.php'); require_once('include/attach.php'); require_once('include/text.php'); require_once('include/PermissionDescription.php'); diff --git a/Zotlabs/Module/Probe.php b/Zotlabs/Module/Probe.php index 79abe9819..dda792131 100644 --- a/Zotlabs/Module/Probe.php +++ b/Zotlabs/Module/Probe.php @@ -20,17 +20,17 @@ class Probe extends \Zotlabs\Web\Controller { $channel = \App::get_channel(); $addr = trim($_GET['addr']); $do_import = ((intval($_GET['import']) && is_site_admin()) ? true : false); - $res = zot_finger($addr,$channel,false); + + $j = \Zotlabs\Zot\Finger::run($addr,$channel,false); + + // $res = zot_finger($addr,$channel,false); + $o .= '<pre>'; - if($res['success']) - $j = json_decode($res['body'],true); - else { + if(! $j['success']) { $o .= sprintf( t('Fetching URL returns error: %1$s'),$res['error'] . "\r\n\r\n"); $o .= "<strong>https connection failed. Trying again with auto failover to http.</strong>\r\n\r\n"; - $res = zot_finger($addr,$channel,true); - if($res['success']) - $j = json_decode($res['body'],true); - else + $j = \Zotlabs\Zot\Finger::run($addr,$channel,true); + if(! $j['success']) $o .= sprintf( t('Fetching URL returns error: %1$s'),$res['error'] . "\r\n\r\n"); } diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index efcc7bece..a8cf3cbee 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -9,7 +9,7 @@ namespace Zotlabs\Module; require_once('include/photo/photo_driver.php'); require_once('include/photos.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); /* @brief Function for sync'ing permissions of profile-photos and their profile * diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index e899abb3f..54780499b 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/selectors.php'); @@ -602,7 +602,7 @@ class Profiles extends \Zotlabs\Web\Controller { return; } - require_once('include/identity.php'); + require_once('include/channel.php'); $profile_fields_basic = get_profile_fields_basic(); $profile_fields_advanced = get_profile_fields_advanced(); diff --git a/Zotlabs/Module/Profperm.php b/Zotlabs/Module/Profperm.php index 94267aaac..33e9d1ece 100644 --- a/Zotlabs/Module/Profperm.php +++ b/Zotlabs/Module/Profperm.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/Contact.php'); + require_once('include/photos.php'); diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index adc16e6e6..c25e04312 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -71,7 +71,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); } - require_once('include/identity.php'); + require_once('include/channel.php'); require_once('include/security.php'); if(get_config('system','site_firehose')) { diff --git a/Zotlabs/Module/Randprof.php b/Zotlabs/Module/Randprof.php index 86b25c22a..dc2e925fe 100644 --- a/Zotlabs/Module/Randprof.php +++ b/Zotlabs/Module/Randprof.php @@ -6,7 +6,6 @@ namespace Zotlabs\Module; class Randprof extends \Zotlabs\Web\Controller { function init() { - require_once('include/Contact.php'); $x = random_profile(); if($x) goaway(chanlink_url($x)); diff --git a/Zotlabs/Module/Regdir.php b/Zotlabs/Module/Regdir.php index 65f8daf67..48a7cc16d 100644 --- a/Zotlabs/Module/Regdir.php +++ b/Zotlabs/Module/Regdir.php @@ -60,14 +60,11 @@ class Regdir extends \Zotlabs\Web\Controller { json_return_and_die($result); } - $f = zot_finger('[system]@' . $m['host']); - if($f['success']) { - $j = json_decode($f['body'],true); - if($j['success'] && $j['guid']) { - $x = import_xchan($j); - if($x['success']) { - $result['success'] = true; - } + $j = \Zotlabs\Zot\Finger::run('[system]@' . $m['host']); + if($j['success'] && $j['guid']) { + $x = import_xchan($j); + if($x['success']) { + $result['success'] = true; } } diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index ca3f33238..7cd1ee501 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); class Register extends \Zotlabs\Web\Controller { diff --git a/Zotlabs/Module/Removeaccount.php b/Zotlabs/Module/Removeaccount.php index da496dfad..39e06bb7f 100644 --- a/Zotlabs/Module/Removeaccount.php +++ b/Zotlabs/Module/Removeaccount.php @@ -36,17 +36,12 @@ class Removeaccount extends \Zotlabs\Web\Controller { } } - require_once('include/Contact.php'); - $global_remove = intval($_POST['global']); - account_remove($account_id,true); - + account_remove($account_id, 1 - $global_remove); } - - - - function get() { + + function get() { if(! local_channel()) goaway(z_root()); diff --git a/Zotlabs/Module/Removeme.php b/Zotlabs/Module/Removeme.php index 9b634672a..e611d8112 100644 --- a/Zotlabs/Module/Removeme.php +++ b/Zotlabs/Module/Removeme.php @@ -35,8 +35,6 @@ class Removeme extends \Zotlabs\Web\Controller { } } - require_once('include/Contact.php'); - $global_remove = intval($_POST['global']); channel_remove(local_channel(),1 - $global_remove,true); @@ -44,8 +42,7 @@ class Removeme extends \Zotlabs\Web\Controller { } - - function get() { + function get() { if(! local_channel()) goaway(z_root()); diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 9941ebbd2..fcc2506fc 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -139,7 +139,7 @@ class Search extends \Zotlabs\Web\Controller { $item_normal = item_normal(); $pub_sql = public_permissions_sql($observer_hash); - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); diff --git a/Zotlabs/Module/Settings.php b/Zotlabs/Module/Settings.php index 32ef89f68..5687ce84b 100644 --- a/Zotlabs/Module/Settings.php +++ b/Zotlabs/Module/Settings.php @@ -483,7 +483,7 @@ class Settings extends \Zotlabs\Web\Controller { if($username != $channel['channel_name']) { $name_change = true; - require_once('include/identity.php'); + require_once('include/channel.php'); $err = validate_channelname($username); if($err) { notice($err); diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index f8c14951b..462ccced6 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -734,7 +734,7 @@ class Setup extends \Zotlabs\Web\Controller { set_config('system','curl_ssl_ciphers','ALL:!eNULL'); // Create a system channel - require_once ('include/identity.php'); + require_once ('include/channel.php'); create_sys_channel(); $baseurl = z_root(); diff --git a/Zotlabs/Module/Uexport.php b/Zotlabs/Module/Uexport.php index ada7e0986..d48f96d76 100644 --- a/Zotlabs/Module/Uexport.php +++ b/Zotlabs/Module/Uexport.php @@ -11,7 +11,7 @@ class Uexport extends \Zotlabs\Web\Controller { if(argc() > 1) { $channel = \App::get_channel(); - require_once('include/identity.php'); + require_once('include/channel.php'); if(argc() > 1 && intval(argv(1)) > 1900) { $year = intval(argv(1)); diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php index a9445cdeb..d58c431e5 100644 --- a/Zotlabs/Module/Viewconnections.php +++ b/Zotlabs/Module/Viewconnections.php @@ -2,8 +2,6 @@ namespace Zotlabs\Module; require_once('include/selectors.php'); -require_once('include/Contact.php'); - class Viewconnections extends \Zotlabs\Web\Controller { @@ -16,7 +14,7 @@ class Viewconnections extends \Zotlabs\Web\Controller { profile_load($a,argv(1)); } - function get() { + function get() { if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { notice( t('Public access denied.') . EOL); diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php index 5bdecfa75..9a1019ddb 100644 --- a/Zotlabs/Module/Wall_attach.php +++ b/Zotlabs/Module/Wall_attach.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; require_once('include/attach.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/photos.php'); diff --git a/Zotlabs/Module/Wall_upload.php b/Zotlabs/Module/Wall_upload.php index fff3ed03a..3868cb14e 100644 --- a/Zotlabs/Module/Wall_upload.php +++ b/Zotlabs/Module/Wall_upload.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; require_once('include/photo/photo_driver.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/photos.php'); diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index d8adb55b2..bb8d454c8 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -1,7 +1,7 @@ <?php namespace Zotlabs\Module; -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); require_once('include/PermissionDescription.php'); diff --git a/Zotlabs/Zot/Auth.php b/Zotlabs/Zot/Auth.php index f764172fa..0837be21a 100644 --- a/Zotlabs/Zot/Auth.php +++ b/Zotlabs/Zot/Auth.php @@ -80,11 +80,9 @@ class Auth { if(! $x) { // finger them if they can't be found. - $ret = zot_finger($address, null); - if ($ret['success']) { - $j = json_decode($ret['body'], true); - if($j) - import_xchan($j); + $j = Finger::run($address, null); + if ($j['success']) { + import_xchan($j); $x = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash where hubloc_addr = '%s' order by hubloc_id desc", dbesc($address) diff --git a/Zotlabs/Zot/Finger.php b/Zotlabs/Zot/Finger.php new file mode 100644 index 000000000..63fdd4a4c --- /dev/null +++ b/Zotlabs/Zot/Finger.php @@ -0,0 +1,130 @@ +<?php + +namespace Zotlabs\Zot; + + +class Finger { + + static private $token; + + /** + * @brief Look up information about channel. + * + * @param string $webbie + * does not have to be host qualified e.g. 'foo' is treated as 'foo\@thishub' + * @param array $channel + * (optional), if supplied permissions will be enumerated specifically for $channel + * @param boolean $autofallback + * fallback/failover to http if https connection cannot be established. Default is true. + * + * @return zotinfo array (with 'success' => true) or array('success' => false); + */ + + static public function run($webbie, $channel = null, $autofallback = true) { + + $ret = array('success' => false); + + self::$token = random_string(); + + if (strpos($webbie,'@') === false) { + $address = $webbie; + $host = App::get_hostname(); + } else { + $address = substr($webbie,0,strpos($webbie,'@')); + $host = substr($webbie,strpos($webbie,'@')+1); + } + + $xchan_addr = $address . '@' . $host; + + if ((! $address) || (! $xchan_addr)) { + logger('zot_finger: no address :' . $webbie); + return $ret; + } + + logger('using xchan_addr: ' . $xchan_addr, LOGGER_DATA, LOG_DEBUG); + + // potential issue here; the xchan_addr points to the primary hub. + // The webbie we were called with may not, so it might not be found + // unless we query for hubloc_addr instead of xchan_addr + + $r = q("select xchan.*, hubloc.* from xchan + left join hubloc on xchan_hash = hubloc_hash + where xchan_addr = '%s' and hubloc_primary = 1 limit 1", + dbesc($xchan_addr) + ); + + if ($r) { + $url = $r[0]['hubloc_url']; + + if ($r[0]['hubloc_network'] && $r[0]['hubloc_network'] !== 'zot') { + logger('zot_finger: alternate network: ' . $webbie); + logger('url: '.$url.', net: '.var_export($r[0]['hubloc_network'],true), LOGGER_DATA, LOG_DEBUG); + return $ret; + } + } + else { + $url = 'https://' . $host; + } + + $rhs = '/.well-known/zot-info'; + $https = ((strpos($url,'https://') === 0) ? true : false); + + logger('zot_finger: ' . $address . ' at ' . $url, LOGGER_DEBUG); + + if ($channel) { + $postvars = array( + 'address' => $address, + 'target' => $channel['channel_guid'], + 'target_sig' => $channel['channel_guid_sig'], + 'key' => $channel['channel_pubkey'], + 'token' => self::$token + ); + + $result = z_post_url($url . $rhs,$postvars); + + if ((! $result['success']) && ($autofallback)) { + if ($https) { + logger('zot_finger: https failed. falling back to http'); + $result = z_post_url('http://' . $host . $rhs,$postvars); + } + } + } + else { + $rhs .= '?f=&address=' . urlencode($address) . '&token=' . self::$token; + + $result = z_fetch_url($url . $rhs); + if ((! $result['success']) && ($autofallback)) { + if ($https) { + logger('zot_finger: https failed. falling back to http'); + $result = z_fetch_url('http://' . $host . $rhs); + } + } + } + + if(! $result['success']) { + logger('zot_finger: no results'); + return $ret; + } + + $x = json_decode($result['body'],true); + if($x) { + $signed_token = ((is_array($x) && array_key_exists('signed_token',$x)) ? $x['signed_token'] : null); + if($signed_token) { + $valid = rsa_verify(self::$token,base64url_decode($signed_token),$x['key']); + if(! $valid) { + logger('invalid signed token: ' . $url . $rhs, LOGGER_NORMAL, LOG_WARN); + return $ret; + } + } + else { + logger('No signed token from ' . $url . $rhs, LOGGER_NORMAL, LOG_WARN); + // after 2017-01-01 this will be a hard error unless you over-ride it. + if((time() > 1483228800) && (! get_config('system','allow_unsigned_zotfinger'))) + return $ret; + } + } + + return $x; + } + +}
\ No newline at end of file |