aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/DReport.php55
-rw-r--r--Zotlabs/Lib/ProtoDriver.php19
-rw-r--r--Zotlabs/Lib/Verify.php63
-rw-r--r--Zotlabs/Lib/ZotDriver.php30
4 files changed, 118 insertions, 49 deletions
diff --git a/Zotlabs/Lib/DReport.php b/Zotlabs/Lib/DReport.php
new file mode 100644
index 000000000..a68d6c18f
--- /dev/null
+++ b/Zotlabs/Lib/DReport.php
@@ -0,0 +1,55 @@
+<?php
+namespace Zotlabs\Lib;
+
+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/Lib/ProtoDriver.php b/Zotlabs/Lib/ProtoDriver.php
deleted file mode 100644
index daf887dbb..000000000
--- a/Zotlabs/Lib/ProtoDriver.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php /** @file */
-
-namespace Zotlabs\Lib;
-
-/*
- * Abstraction class for dealing with alternate networks (which of course do not exist, hence the abstraction)
- */
-
-
-abstract class ProtoDriver {
- abstract protected function discover($channel,$location);
- abstract protected function deliver($item,$channel,$recipients);
- abstract protected function collect($channel,$connection);
- abstract protected function change_permissions($permissions,$channel,$recipient);
- abstract protected function acknowledge_permissions($permissions,$channel,$recipient);
- abstract protected function deliver_private($item,$channel,$recipients);
- abstract protected function collect_private($channel,$connection);
-
-}
diff --git a/Zotlabs/Lib/Verify.php b/Zotlabs/Lib/Verify.php
new file mode 100644
index 000000000..8703e29e6
--- /dev/null
+++ b/Zotlabs/Lib/Verify.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace Zotlabs\Lib;
+
+
+class Verify {
+
+ function create($type,$channel_id,$token,$meta) {
+ return q("insert into verify ( vtype, 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 vtype = '%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 get_meta($type,$channel_id,$token) {
+ $r = q("select id, meta from verify where vtype = '%s' and channel = %d and token = '%s' limit 1",
+ dbesc($type),
+ intval($channel_id),
+ dbesc($token)
+ );
+ if($r) {
+ q("delete from verify where id = %d",
+ intval($r[0]['id'])
+ );
+ return $r[0]['meta'];
+ }
+ return false;
+ }
+
+ /**
+ * @brief Purge entries of a verify-type older than interval.
+ *
+ * @param string $type Verify type
+ * @param string $interval SQL compatible time interval
+ */
+ function purge($type, $interval) {
+ q("delete from verify where vtype = '%s' and created < %s - INTERVAL %s",
+ dbesc($type),
+ db_utcnow(),
+ db_quoteinterval($interval)
+ );
+ }
+
+} \ No newline at end of file
diff --git a/Zotlabs/Lib/ZotDriver.php b/Zotlabs/Lib/ZotDriver.php
deleted file mode 100644
index e14cc7f35..000000000
--- a/Zotlabs/Lib/ZotDriver.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php /** @file */
-
-namespace Zotlabs\Lib;
-
-
-class ZotDriver extends ProtoDriver {
-
- protected function discover($channel,$location) {
-
- }
- protected function deliver($item,$channel,$recipients) {
-
- }
- protected function collect($channel,$connection) {
-
- }
- protected function change_permissions($permissions,$channel,$recipient) {
-
- }
- protected function acknowledge_permissions($permissions,$channel,$recipient) {
-
- }
- protected function deliver_private($item,$channel,$recipients) {
-
- }
- protected function collect_private($channel,$connection) {
-
- }
-
-}