aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Verify.php
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2018-02-22 15:10:20 -0500
committerAndrew Manning <tamanning@zoho.com>2018-02-22 15:10:20 -0500
commit70719c67d30810c8127707b0dd1fd7ed66aa4a9a (patch)
tree3dd9d547d2e15007689106cc26d60ba067b3a7b8 /Zotlabs/Lib/Verify.php
parent43fca182e3915734587abf389d819546ebade3a4 (diff)
parent80ce2def461705ebd0853e99ddfc0d1bc1de2915 (diff)
downloadvolse-hubzilla-70719c67d30810c8127707b0dd1fd7ed66aa4a9a.tar.gz
volse-hubzilla-70719c67d30810c8127707b0dd1fd7ed66aa4a9a.tar.bz2
volse-hubzilla-70719c67d30810c8127707b0dd1fd7ed66aa4a9a.zip
Merge branch 'dev' into oauth2
Diffstat (limited to 'Zotlabs/Lib/Verify.php')
-rw-r--r--Zotlabs/Lib/Verify.php63
1 files changed, 63 insertions, 0 deletions
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