Browse code

Changed majority of files.

DoubleBastionAdmin authored on 30/11/2024 06:56:40
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,123 @@
1
+<?php
2
+/**
3
+ *  Copyright (C) 2021  Double Bastion LLC
4
+ *
5
+ *  This file is part of Roundpin, which is licensed under the
6
+ *  GNU Affero General Public License Version 3.0. The license terms
7
+ *  are detailed in the "LICENSE.txt" file located in the root directory.
8
+ */
9
+
10
+session_start();
11
+ // header('Set-Cookie: PHPSESSID= ' . session_id() . '; SameSite=strict; Secure=true; HttpOnly=true;');
12
+
13
+if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access']) && isset($_POST['sipusername']) && $_POST['sipusername'] != '' &&
14
+    isset($_POST['sipuserrole']) && $_POST['sipuserrole'] != '') {
15
+
16
+    $sipUser = $_POST['sipusername'];
17
+    $sipUserRole = $_POST['sipuserrole'];
18
+
19
+    if (isset($_POST['vidconfextension']) && $_POST['vidconfextension'] != '') {
20
+
21
+        $vidConfExtensionList = $_POST['vidconfextension'];
22
+        $vidConfExtensionArr = explode(",", $vidConfExtensionList);
23
+
24
+    } else { $vidConfExtensionArr = []; }
25
+
26
+    if (isset($_POST['textconfextension']) && $_POST['textconfextension'] != '') {
27
+
28
+        $textConfExtensionList = $_POST['textconfextension'];
29
+        $textConfExtensionArr = explode(",", $textConfExtensionList);
30
+
31
+    } else { $textConfExtensionArr = []; }
32
+
33
+    if ($sipUserRole == 'regular_user' || $sipUserRole == 'admin') {
34
+
35
+        if (is_dir('../textchat/' . $sipUser . '/uploads')) {
36
+
37
+            try { 
38
+              array_map('unlink', glob('../textchat/' . $sipUser . '/uploads/*'));
39
+              if (glob('../textchat/' . $sipUser . '/uploads/*')) { throw new Exception('Directory not empty'); } else { throw new Exception(''); }
40
+            } catch (Exception $e) { if ($e->getMessage() == '') { $cmessage = 'success'; } else { $cmessage = 'failure'; } }
41
+
42
+        } else { $cmessage = 'success'; }
43
+
44
+        if (is_dir('../textchat/' . $sipUser . 'vconf' . '/uploads')) {
45
+
46
+            try { 
47
+              array_map('unlink', glob('../textchat/' . $sipUser . 'vconf' . '/uploads/*'));
48
+              if (glob('../textchat/' . $sipUser . 'vconf' . '/uploads/*')) { throw new Exception('Directory not empty'); } else { throw new Exception(''); }
49
+            } catch (Exception $e) { if ($e->getMessage() == '') { $cmessage = 'success'; } else { $cmessage = 'failure'; } }
50
+
51
+        } else { $cmessage = 'success'; }
52
+
53
+    } elseif ($sipUserRole == 'superadmin') {
54
+
55
+        if (is_dir('../textchat/' . $sipUser . '/uploads')) {
56
+
57
+            try { 
58
+              array_map('unlink', glob('../textchat/' . $sipUser . '/uploads/*'));
59
+              if (glob('../textchat/' . $sipUser . '/uploads/*')) { throw new Exception('Directory not empty'); } else { throw new Exception(''); }
60
+            } catch (Exception $e) { if ($e->getMessage() == '') { $partcmessage = 'success'; } else { $partcmessage = 'failure'; } }
61
+
62
+        } else { $partcmessage = 'success'; }
63
+
64
+        if (is_dir('../textchat/' . $sipUser . 'vconf' . '/uploads')) {
65
+
66
+            try { 
67
+              array_map('unlink', glob('../textchat/' . $sipUser . 'vconf' . '/uploads/*'));
68
+              if (glob('../textchat/' . $sipUser . 'vconf' . '/uploads/*')) { throw new Exception('Directory not empty'); } else { throw new Exception(''); }
69
+            } catch (Exception $e) { if ($e->getMessage() == '') { $partcmessage = 'success'; } else { $partcmessage = 'failure'; } }
70
+
71
+        } else { $partcmessage = 'success'; }
72
+
73
+        if (!empty($vidConfExtensionArr)) {
74
+
75
+            $vidcmessagecheck = 0;
76
+
77
+            for ($i = 0; $i < count($vidConfExtensionArr); $i++) {
78
+
79
+                 if (is_dir('../textchat/' . $vidConfExtensionArr[$i] . '/uploads')) {
80
+
81
+		     try {
82
+		       array_map('unlink', glob('../textchat/' . $vidConfExtensionArr[$i] . '/uploads/*'));
83
+		       if (glob('../textchat/' . $vidConfExtensionArr[$i] . '/uploads/*')) { throw new Exception('Directory not empty'); } else { throw new Exception(''); }
84
+		     } catch (Exception $e) { if ($e->getMessage() != '') { ++$vidcmessagecheck; } }
85
+                 }
86
+            }
87
+
88
+            if ($vidcmessagecheck == 0) { $vidcmessage = 'success'; } else { $vidcmessage = 'failure'; }
89
+
90
+        } else { $vidcmessage = 'success'; }
91
+
92
+        if (!empty($textConfExtensionArr)) {
93
+
94
+            $textcmessagecheck = 0;
95
+
96
+            for ($k = 0; $k < count($textConfExtensionArr); $k++) {
97
+
98
+                 if (is_dir('../textchat/' . $textConfExtensionArr[$k] . '/uploads')) {
99
+
100
+                     try { 
101
+                       array_map('unlink', glob('../textchat/' . $textConfExtensionArr[$k] . '/uploads/*'));
102
+                       if (glob('../textchat/' . $textConfExtensionArr[$k] . '/uploads/*')) { throw new Exception('Directory not empty'); } else { throw new Exception(''); }
103
+                     } catch (Exception $e) { if ($e->getMessage() != '') { ++$textcmessagecheck; } }
104
+                 }
105
+            }
106
+
107
+            if ($textcmessagecheck == 0) { $textcmessage = 'success'; } else { $textcmessage = 'failure'; }
108
+
109
+        } else { $textcmessage = 'success'; }
110
+
111
+        if ($partcmessage == 'success' && $vidcmessage == 'success' && $textcmessage == 'success') { $cmessage = 'success'; } else { $cmessage = 'failure'; }
112
+
113
+    } else { $cmessage = 'failure'; }
114
+
115
+    $resresult = ["note" => $cmessage];
116
+
117
+    echo json_encode($resresult);
118
+
119
+} else {
120
+       header("Location: ../login.php");
121
+}
122
+
123
+?>