diff options
author | Paolo Tacconi <p.tacconi@giunti.it> | 2016-04-15 09:22:27 +0200 |
---|---|---|
committer | Paolo Tacconi <p.tacconi@giunti.it> | 2016-04-15 09:22:27 +0200 |
commit | c38c79d71c8ef70ef649f83e322f1984b75ee2dd (patch) | |
tree | 958fcd22f04546f40b6ac68bb58cfe1a1b1fb7f6 /Zotlabs/Zot | |
parent | 1806da0851dd5cf5978b19d12783ae3101a11257 (diff) | |
parent | 45a854762b451dafb882bc56efce054b64420627 (diff) | |
download | volse-hubzilla-c38c79d71c8ef70ef649f83e322f1984b75ee2dd.tar.gz volse-hubzilla-c38c79d71c8ef70ef649f83e322f1984b75ee2dd.tar.bz2 volse-hubzilla-c38c79d71c8ef70ef649f83e322f1984b75ee2dd.zip |
Merge branch 'redmatrix-master'
Diffstat (limited to 'Zotlabs/Zot')
-rw-r--r-- | Zotlabs/Zot/Auth.php | 8 | ||||
-rw-r--r-- | Zotlabs/Zot/DReport.php | 55 | ||||
-rw-r--r-- | Zotlabs/Zot/Receiver.php | 7 | ||||
-rw-r--r-- | Zotlabs/Zot/Verify.php | 42 | ||||
-rw-r--r-- | Zotlabs/Zot/ZotHandler.php | 3 |
5 files changed, 105 insertions, 10 deletions
diff --git a/Zotlabs/Zot/Auth.php b/Zotlabs/Zot/Auth.php index fed253923..f764172fa 100644 --- a/Zotlabs/Zot/Auth.php +++ b/Zotlabs/Zot/Auth.php @@ -132,7 +132,7 @@ class Auth { // tell them to logout if they're logged in locally as anything but the target remote account // in which case just shut up because they don't need to be doing this at all. - if (get_app()->channel['channel_hash'] == $hubloc['xchan_hash']) { + if (\App::$channel['channel_hash'] == $hubloc['xchan_hash']) { return true; } else { @@ -242,9 +242,9 @@ class Auth { $arr = array('xchan' => $hubloc, 'url' => $this->desturl, 'session' => $_SESSION); call_hooks('magic_auth_success',$arr); - get_app()->set_observer($hubloc); + \App::set_observer($hubloc); require_once('include/security.php'); - get_app()->set_groups(init_groups_visitor($_SESSION['visitor_id'])); + \App::set_groups(init_groups_visitor($_SESSION['visitor_id'])); info(sprintf( t('Welcome %s. Remote authentication successful.'),$hubloc['xchan_name'])); logger('mod_zot: auth success from ' . $hubloc['xchan_addr']); $this->success = true; @@ -341,5 +341,5 @@ class Auth { * Service_class can be used by cooperating sites to provide different access rights based on account rights and subscription plans. It is * a string whose contents are not defined by protocol. Example: "basic" or "gold". * - * @param[in,out] App &$a + * @param[in,out] \App &$a */ diff --git a/Zotlabs/Zot/DReport.php b/Zotlabs/Zot/DReport.php new file mode 100644 index 000000000..c90f4f670 --- /dev/null +++ b/Zotlabs/Zot/DReport.php @@ -0,0 +1,55 @@ +<?php +namespace Zotlabs\Zot; + +class DReport { + + private $location; + private $sender; + private $recipient; + private $message_id; + private $status; + private $date; + + function __construct($location,$sender,$recipient,$message_id,$status = 'deliver') { + $this->location = $location; + $this->sender = $sender; + $this->recipient = $recipient; + $this->message_id = $message_id; + $this->status = $status; + $this->date = datetime_convert(); + } + + function update($status) { + $this->status = $status; + $this->date = datetime_convert(); + } + + function addto_recipient($name) { + $this->recipient = $this->recipient . ' ' . $name; + } + + function addto_update($status) { + $this->status = $this->status . ' ' . $status; + } + + + function set($arr) { + $this->location = $arr['location']; + $this->sender = $arr['sender']; + $this->recipient = $arr['recipient']; + $this->message_id = $arr['message_id']; + $this->status = $arr['status']; + $this->date = $arr['date']; + } + + function get() { + return array( + 'location' => $this->location, + 'sender' => $this->sender, + 'recipient' => $this->recipient, + 'message_id' => $this->message_id, + 'status' => $this->status, + 'date' => $this->date + ); + } +} diff --git a/Zotlabs/Zot/Receiver.php b/Zotlabs/Zot/Receiver.php index 238de1332..71d57eb35 100644 --- a/Zotlabs/Zot/Receiver.php +++ b/Zotlabs/Zot/Receiver.php @@ -41,9 +41,10 @@ class Receiver { if(! $this->messagetype) $this->error = true; - $this->sender = ((array_key_exists('sender',$this->data)) ? $this->data['sender'] : null); - $this->recipients = ((array_key_exists('recipients',$this->data)) ? $this->data['recipients'] : null); - + if($this->data) { + $this->sender = ((array_key_exists('sender',$this->data)) ? $this->data['sender'] : null); + $this->recipients = ((array_key_exists('recipients',$this->data)) ? $this->data['recipients'] : null); + } if($this->sender) $this->ValidateSender(); diff --git a/Zotlabs/Zot/Verify.php b/Zotlabs/Zot/Verify.php new file mode 100644 index 000000000..1192202db --- /dev/null +++ b/Zotlabs/Zot/Verify.php @@ -0,0 +1,42 @@ +<?php + +namespace Zotlabs\Zot; + + +class Verify { + + function create($type,$channel_id,$token,$meta) { + return q("insert into verify ( type, channel, token, meta, created ) values ( '%s', %d, '%s', '%s', '%s' )", + dbesc($type), + intval($channel_id), + dbesc($token), + dbesc($meta), + dbesc(datetime_convert()) + ); + } + + function match($type,$channel_id,$token,$meta) { + $r = q("select id from verify where type = '%s' and channel = %d and token = '%s' and meta = '%s' limit 1", + dbesc($type), + intval($channel_id), + dbesc($token), + dbesc($meta) + ); + if($r) { + q("delete from verify where id = %d", + intval($r[0]['id']) + ); + return true; + } + return false; + } + + function purge($type,$interval) { + q("delete from verify where type = '%s' and created < %s - INTERVAL %s", + dbesc($type), + db_utcnow(), + db_quoteinterval($interval) + ); + } + +}
\ No newline at end of file diff --git a/Zotlabs/Zot/ZotHandler.php b/Zotlabs/Zot/ZotHandler.php index f9bb05410..aab336545 100644 --- a/Zotlabs/Zot/ZotHandler.php +++ b/Zotlabs/Zot/ZotHandler.php @@ -2,9 +2,6 @@ namespace Zotlabs\Zot; -require_once('Zotlabs/Zot/IHandler.php'); - - class ZotHandler implements IHandler { function Ping() { |