aboutsummaryrefslogtreecommitdiffstats
path: root/managing-ui/lib/xmpp/xmpp.util.php
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2017-05-27 20:33:11 +0200
committersteckbrief <steckbrief@chefmail.de>2017-05-27 20:34:06 +0200
commitb7515c5d9c5fc3c622376818570c05a03c74fe17 (patch)
tree38ebba18eb38d16f94afd821430ced2bcf63a739 /managing-ui/lib/xmpp/xmpp.util.php
parent6bd2862f8f6b37f145097767ebbbedbc5e243443 (diff)
managing-ui: initial commit0.2
added possibility to manage uploaded files simple php ui to delete uploaded files
Diffstat (limited to 'managing-ui/lib/xmpp/xmpp.util.php')
-rw-r--r--managing-ui/lib/xmpp/xmpp.util.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/managing-ui/lib/xmpp/xmpp.util.php b/managing-ui/lib/xmpp/xmpp.util.php
new file mode 100644
index 0000000..5bde0c0
--- /dev/null
+++ b/managing-ui/lib/xmpp/xmpp.util.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);
+ }
+} \ No newline at end of file