aboutsummaryrefslogtreecommitdiffstats
path: root/storage-backend/lib/xmpp.util.inc.php
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2017-05-04 16:23:36 +0200
committersteckbrief <steckbrief@chefmail.de>2017-05-04 16:26:11 +0200
commita564fd0a7a60990fc8bd31ffabb9a33cf9a42f32 (patch)
tree80a3b1a2e5a0c8377eb1d58374a3d68e337415e9 /storage-backend/lib/xmpp.util.inc.php
parentfd7ea5c319a3f7536bc67f81831c89edc82572f4 (diff)
storage-backend: Added json interface to list transferred files
Diffstat (limited to 'storage-backend/lib/xmpp.util.inc.php')
-rw-r--r--storage-backend/lib/xmpp.util.inc.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/storage-backend/lib/xmpp.util.inc.php b/storage-backend/lib/xmpp.util.inc.php
new file mode 100644
index 0000000..cdc90fb
--- /dev/null
+++ b/storage-backend/lib/xmpp.util.inc.php
@@ -0,0 +1,69 @@
+<?php
+/*
+ * xmpp jid util functions.
+ */
+
+function getJidDomain($jid) {
+ if (null == $jid) {
+ return null;
+ }
+
+ $atIndex = strpos($jid, '@');
+ $slashIndex = strpos($jid, '/');
+
+ if ($slashIndex !== false) {
+ if ($slashIndex > $atIndex) {// 'local@domain.foo/resource' and 'local@domain.foo/res@otherres' case
+ return substr($jid, $atIndex + 1, $slashIndex - $atIndex + 1);
+ } else {// 'domain.foo/res@otherres' case
+ return substr($jid, 0, $slashIndex);
+ }
+ } else {
+ return substr($jid, $atIndex + 1);
+ }
+}
+
+function getJidLocalPart($jid) {
+ if ($jid == null) {
+ return null;
+ }
+
+ $atIndex = strpos($jid, '@');
+ if ($atIndex === false || $atIndex == 0) {
+ return "";
+ }
+
+ $slashIndex = strpos($jid, '/');
+ if ($slashIndex !== false && $slashIndex < $atIndex) {
+ return "";
+ } else {
+ return substr($jid, 0, $atIndex);
+ }
+}
+
+function getBareJid($jid) {
+ if ($jid == null) {
+ return null;
+ }
+
+ $slashIndex = strpos($jid, '/');
+ if ($slashIndex === false) {
+ return $jid;
+ } else if ($slashIndex == 0) {
+ return "";
+ } else {
+ return substr($jid, 0, $slashIndex);
+ }
+}
+
+function getResource($jid) {
+ if ($jid == null) {
+ return null;
+ }
+
+ $slashIndex = strpos($jid, '/');
+ if ($slashIndex + 1 > strlen($jid) || $slashIndex === false) {
+ return "";
+ } else {
+ return substr($jid, $slashIndex + 1);
+ }
+}