Browse code

added appinfo/info.xml appinfo/signature.json appinfo/routes.php CHANGELOG.txt lib/AppInfo/Application.php lib/Controller/SphoneController.php lib/Service/SphoneService.php js/settings.js js/launchphone.js phone/scripts/app.js

DoubleBastionAdmin authored on 10/03/2025 10:52:33
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,240 @@
1
+<?php
2
+/**
3
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
+ *
5
+ * @author Double Bastion LLC
6
+ *
7
+ * @license GNU AGPL version 3 or any later version
8
+ *
9
+ * This program is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
+ * License as published by the Free Software Foundation; either
12
+ * version 3 of the License, or any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
+ *
19
+ * You should have received a copy of the GNU Affero General Public
20
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+declare(strict_types=1);
25
+
26
+namespace OCA\SIPTripPhone\Service;
27
+
28
+use OCP\DB\QueryBuilder\IQueryBuilder;
29
+use OCP\IDBConnection;
30
+use OCP\Security\ICrypto;
31
+use function OCP\Log\logger;
32
+
33
+class SphoneService {
34
+
35
+    private $connection;
36
+    private $crypto;
37
+
38
+    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
+                $this->connection = $connection;
40
+                $this->crypto = $crypto;
41
+    }
42
+
43
+    /**
44
+     * @NoAdminRequired
45
+     *
46
+     */
47
+    public function getsettings($userId) {
48
+
49
+        $sql = $this->connection->prepare('
50
+                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`
51
+		    FROM  `*PREFIX*sip_trip_phone`
52
+		    WHERE `user_id` = ?');
53
+        $result = $sql->execute([$userId]);
54
+        $settingsdb = $result->fetch();
55
+        $result->closeCursor();
56
+
57
+        if ($settingsdb) {
58
+            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
59
+                $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
60
+            } else { $settingsdb['sipuserpassword'] = ''; }
61
+
62
+            return $settingsdb;
63
+        }
64
+    }
65
+
66
+    /**
67
+     * @NoAdminRequired
68
+     *
69
+     */
70
+    public function getsippass($userId) {
71
+
72
+        $sqlps = $this->connection->prepare('
73
+                    SELECT `id`, `user_id`, `sipuserpassword`
74
+		    FROM  `*PREFIX*sip_trip_phone`
75
+		    WHERE `user_id` = ?');
76
+        $resultps = $sqlps->execute([$userId]);
77
+        $settingsdb = $resultps->fetch();
78
+        $resultps->closeCursor();
79
+
80
+        if ($settingsdb) {
81
+            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
82
+                $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword']);
83
+                $sippassword = $sipuserpassworddecr;
84
+            }
85
+
86
+            return $sippassword;
87
+        }
88
+    }
89
+
90
+    /**
91
+     * @NoAdminRequired
92
+     */
93
+    public function getcontactsnmbrs($userId) {
94
+
95
+        // Get the phone numbers of regular contacts
96
+
97
+        $cardadd = "card_add_self";
98
+        $cntctsusr = $this->connection->prepare('
99
+                    SELECT `user`, `subject`, `subjectparams`
100
+		    FROM  `*PREFIX*activity`
101
+		    WHERE `user` = ? AND `subject` = ?');
102
+        $rescntcts = $cntctsusr->execute([$userId, $cardadd]);
103
+        $cnctsforuserinit = [];
104
+        while ($ctrow = $rescntcts->fetch()) {
105
+               $ctsperuserarr = json_decode($ctrow['subjectparams'], true);
106
+               $cnctsforuserinit[] = $ctsperuserarr['card']['id'];
107
+        }
108
+        $rescntcts->closeCursor();
109
+        $cnctsforuser = array_unique($cnctsforuserinit);
110
+
111
+        $contactData = [];
112
+        if ($cnctsforuser) {
113
+
114
+            foreach ($cnctsforuser as $ctkey => $ctid) {
115
+                 $ctdata = $this->connection->prepare('
116
+                           SELECT `carddata`, `uid`
117
+		           FROM  `*PREFIX*cards`
118
+		           WHERE `uid` = ?');
119
+                 $ctdatares = $ctdata->execute([$ctid]);
120
+                 $ctdatarow = $ctdatares->fetch();
121
+                 $ctdatares->closeCursor();
122
+                 $ctdatarr = preg_split('/\r\n|\r|\n/', $ctdatarow['carddata']);
123
+                 $contactNumbers = [];
124
+                 $contactRole = '';
125
+                 foreach ($ctdatarr as $cdkey => $cdata) {
126
+                          $telcheck = false;
127
+                          if (str_contains($cdata, "FN:")) {
128
+                              $cdnamearr = explode("FN:", $cdata);
129
+                              $contactName = $cdnamearr[1];
130
+                          } elseif (str_contains($cdata, "FN;")) {
131
+                              $cdnamearr = explode(":", $cdata);
132
+                              $contactName = $cdnamearr[1];
133
+                          } elseif (str_contains($cdata, "TITLE:")) {
134
+                              $cdtitlearr = explode("TITLE:", $cdata);
135
+                              $contactRole = $cdtitlearr[1];
136
+                          } elseif (str_contains($cdata, "TEL;")) {
137
+                              $cdtelarr = explode("TYPE=", $cdata);
138
+                              $cdteldatarr = explode(":", $cdtelarr[1]);
139
+                                  if (str_contains($cdteldatarr[0], 'CELL') || str_contains($cdteldatarr[0], 'VOICE') || str_contains($cdteldatarr[0], 'CAR')) {
140
+                                      $ctNumberType = $cdteldatarr[0];
141
+                                      $ctNumber = $cdteldatarr[1];
142
+                                      if ($ctNumber) { $telcheck = true; }
143
+                                  }
144
+                          }
145
+                          if ($telcheck) { $contactNumbers[] = [$ctNumberType, $ctNumber]; }
146
+                 }
147
+                 if ($contactNumbers) {
148
+                     $contactData[] = ['contact_name' => $contactName, 'contact_role' => $contactRole, 'contact_type' => 'regular_contact', 'contact_numbers' => $contactNumbers];
149
+                 }
150
+            }
151
+        }
152
+
153
+        // Get the (non-private) phone numbers of Nextcloud users
154
+
155
+        $ncusers = $this->connection->prepare('
156
+                    SELECT `uid`, `data`
157
+		    FROM  `*PREFIX*accounts`');
158
+        $ncusersres = $ncusers->execute();
159
+        $ncUserData = [];
160
+        while ($ncrow = $ncusersres->fetch()) {
161
+               $ncperuserarr = json_decode($ncrow['data'], true);
162
+               if ($ncperuserarr['phone']['value'] && ($ncperuserarr['phone']['scope'] == 'v2-local' || $ncperuserarr['phone']['scope'] == 'v2-federated' || $ncperuserarr['phone']['scope'] == 'v2-published')) {
163
+
164
+                   $ncdisplayname = $ncperuserarr['displayname']['value'];
165
+
166
+                   $nctelnumber = [['VOICE/CELL', $ncperuserarr['phone']['value']]];
167
+
168
+                   if ($ncperuserarr['role']['scope'] == 'v2-local' || $ncperuserarr['role']['scope'] == 'v2-federated' || $ncperuserarr['role']['scope'] == 'v2-published') {
169
+                       $ncuserrole = $ncperuserarr['role']['value'];
170
+                   } else { $ncuserrole = ''; }
171
+
172
+                   $ncUserData[] = ['contact_name' => $ncdisplayname, 'contact_role' => $ncuserrole, 'contact_type' => 'ncuser_contact', 'contact_numbers' => $nctelnumber];
173
+               }
174
+        }
175
+        $ncusersres->closeCursor();
176
+
177
+        $usersAndContacts = array_merge($contactData, $ncUserData);
178
+
179
+        return $usersAndContacts;
180
+    }
181
+
182
+    /**
183
+     * @NoAdminRequired
184
+     *
185
+     */
186
+    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber) {
187
+
188
+        // Validate the data entered in the fields on the settings page
189
+        if (mb_strlen($pdisplayname) > 128) { logger('sip_trip_phone')->error("The 'Display Name' cannot exceed 128 characters!"); exit(); }
190
+        if (!preg_match('/^[a-zA-Z0-9\*\#]+$/', $sipusername)) { logger('sip_trip_phone')->error("The 'SIP User' that you entered is not valid. The 'SIP User' must contain only alphanumeric characters, asterisks (*) and number signs (#).)"); exit(); }        
191
+        if (mb_strlen($sipuserpassword) > 300) { logger('sip_trip_phone')->error("The 'SIP User Password' cannot exceed 300 characters!"); exit(); }      
192
+        if (filter_var($stphwssurl, FILTER_VALIDATE_URL) == false) { logger('sip_trip_phone')->error("The 'WSS URL' that you entered is not valid."); exit(); }
193
+        if (filter_var($siprealm, FILTER_VALIDATE_IP) == false && filter_var($siprealm, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false) { logger('sip_trip_phone')->error("The 'SIP Realm' that you entered is not valid."); exit(); }
194
+        if ($stunserver != '') {
195
+            $stunIpDom = explode(":", $stunserver);
196
+            if ((filter_var($stunIpDom[0], FILTER_VALIDATE_IP) == false && filter_var($stunIpDom[0], FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false) || !preg_match('/^[0-9]+$/', $stunIpDom[1])) { logger('sip_trip_phone')->error("The 'STUN Server' that you entered is not valid."); exit(); }
197
+        }
198
+        if (!preg_match('/^[a-zA-Z0-9\040\+\,\:]*$/', $voicenumbers)) { logger('sip_trip_phone')->error("The 'Available phone numbers' that you entered are not valid. The 'Available phone numbers' must contain only alphanumeric characters, colons (:), spaces, plus signs (+), digits (0-9) and commas (,)."); exit(); }
199
+        if (!preg_match('/^[a-zA-Z0-9\040\+\:]*$/', $defaultvoicenumber)) { logger('sip_trip_phone')->error("The 'Default phone number for outgoing calls' that you entered is not valid. The 'Default phone number for outgoing calls' must contain only alphanumeric characters, a colon (:), a space, a plus sign (+) and digits (0-9)."); exit(); }
200
+
201
+        $sqlup = $this->connection->prepare('
202
+                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`
203
+		    FROM  `*PREFIX*sip_trip_phone`
204
+		    WHERE `user_id` = ?');
205
+        $resultup = $sqlup->execute([$userId]);
206
+        $row = $resultup->fetch();
207
+        $resultup->closeCursor();
208
+
209
+        if ($resultup && !$row) {
210
+
211
+            if ($sipuserpassword != '') {
212
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
213
+            } else { $sipuserpasswordenc = ''; }
214
+
215
+            $sqlins = $this->connection->prepare('
216
+				INSERT INTO `*PREFIX*sip_trip_phone`
217
+					(`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`)
218
+				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
219
+	    $sqlins->execute([$userId, $pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber]);
220
+
221
+        } elseif ($resultup && $row) {
222
+
223
+            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
224
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
225
+            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
226
+                $sipuserpasswordenc = $row['sipuserpassword'];
227
+            } elseif ($sipuserpassword == '') {
228
+                $sipuserpasswordenc = '';
229
+            }
230
+
231
+	    $sqlup = $this->connection->prepare('
232
+			UPDATE `*PREFIX*sip_trip_phone`
233
+			SET `pdisplayname` = ?, `sipusername` = ?, `sipuserpassword` = ?, `stphwssurl` = ?, `siprealm` = ?, `stunserver` = ?, `tracesipmsg` = ?, `voicenumbers` = ?, `defaultvoicenumber` = ?
234
+                        WHERE `user_id` = ?');
235
+	    $updateRes = $sqlup->execute([$pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber, $userId]);
236
+	    $updateRes->closeCursor();
237
+
238
+        }
239
+    }
240
+}
Browse code

removed appinfo/info.xml appinfo/signature.json appinfo/routes.php CHANGELOG.txt lib/AppInfo/Application.php lib/Controller/SphoneController.php lib/Service/SphoneService.php js/settings.js js/launchphone.js phone/scripts/app.js

DoubleBastionAdmin authored on 10/03/2025 10:43:29
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,240 +0,0 @@
1
-<?php
2
-/**
3
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
- *
5
- * @author Double Bastion LLC
6
- *
7
- * @license GNU AGPL version 3 or any later version
8
- *
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
- * License as published by the Free Software Foundation; either
12
- * version 3 of the License, or any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
- *
19
- * You should have received a copy of the GNU Affero General Public
20
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
- *
22
- */
23
-
24
-declare(strict_types=1);
25
-
26
-namespace OCA\SIPTripPhone\Service;
27
-
28
-use OCP\DB\QueryBuilder\IQueryBuilder;
29
-use OCP\IDBConnection;
30
-use OCP\Security\ICrypto;
31
-use function OCP\Log\logger;
32
-
33
-class SphoneService {
34
-
35
-    private $connection;
36
-    private $crypto;
37
-
38
-    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
-                $this->connection = $connection;
40
-                $this->crypto = $crypto;
41
-    }
42
-
43
-    /**
44
-     * @NoAdminRequired
45
-     *
46
-     */
47
-    public function getsettings($userId) {
48
-
49
-        $sql = $this->connection->prepare('
50
-                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`
51
-		    FROM  `*PREFIX*sip_trip_phone`
52
-		    WHERE `user_id` = ?');
53
-        $result = $sql->execute([$userId]);
54
-        $settingsdb = $result->fetch();
55
-        $result->closeCursor();
56
-
57
-        if ($settingsdb) {
58
-            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
59
-                $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
60
-            } else { $settingsdb['sipuserpassword'] = ''; }
61
-
62
-            return $settingsdb;
63
-        }
64
-    }
65
-
66
-    /**
67
-     * @NoAdminRequired
68
-     *
69
-     */
70
-    public function getsippass($userId) {
71
-
72
-        $sqlps = $this->connection->prepare('
73
-                    SELECT `id`, `user_id`, `sipuserpassword`
74
-		    FROM  `*PREFIX*sip_trip_phone`
75
-		    WHERE `user_id` = ?');
76
-        $resultps = $sqlps->execute([$userId]);
77
-        $settingsdb = $resultps->fetch();
78
-        $resultps->closeCursor();
79
-
80
-        if ($settingsdb) {
81
-            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
82
-                $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword']);
83
-                $sippassword = $sipuserpassworddecr;
84
-            }
85
-
86
-            return $sippassword;
87
-        }
88
-    }
89
-
90
-    /**
91
-     * @NoAdminRequired
92
-     */
93
-    public function getcontactsnmbrs($userId) {
94
-
95
-        // Get the phone numbers of regular contacts
96
-
97
-        $cardadd = "card_add_self";
98
-        $cntctsusr = $this->connection->prepare('
99
-                    SELECT `user`, `subject`, `subjectparams`
100
-		    FROM  `*PREFIX*activity`
101
-		    WHERE `user` = ? AND `subject` = ?');
102
-        $rescntcts = $cntctsusr->execute([$userId, $cardadd]);
103
-        $cnctsforuserinit = [];
104
-        while ($ctrow = $rescntcts->fetch()) {
105
-               $ctsperuserarr = json_decode($ctrow['subjectparams'], true);
106
-               $cnctsforuserinit[] = $ctsperuserarr['card']['id'];
107
-        }
108
-        $rescntcts->closeCursor();
109
-        $cnctsforuser = array_unique($cnctsforuserinit);
110
-
111
-        $contactData = [];
112
-        if ($cnctsforuser) {
113
-
114
-            foreach ($cnctsforuser as $ctkey => $ctid) {
115
-                 $ctdata = $this->connection->prepare('
116
-                           SELECT `carddata`, `uid`
117
-		           FROM  `*PREFIX*cards`
118
-		           WHERE `uid` = ?');
119
-                 $ctdatares = $ctdata->execute([$ctid]);
120
-                 $ctdatarow = $ctdatares->fetch();
121
-                 $ctdatares->closeCursor();
122
-                 $ctdatarr = preg_split('/\r\n|\r|\n/', $ctdatarow['carddata']);
123
-                 $contactNumbers = [];
124
-                 $contactRole = '';
125
-                 foreach ($ctdatarr as $cdkey => $cdata) {
126
-                          $telcheck = false;
127
-                          if (str_contains($cdata, "FN:")) {
128
-                              $cdnamearr = explode("FN:", $cdata);
129
-                              $contactName = $cdnamearr[1];
130
-                          } elseif (str_contains($cdata, "FN;")) {
131
-                              $cdnamearr = explode(":", $cdata);
132
-                              $contactName = $cdnamearr[1];
133
-                          } elseif (str_contains($cdata, "TITLE:")) {
134
-                              $cdtitlearr = explode("TITLE:", $cdata);
135
-                              $contactRole = $cdtitlearr[1];
136
-                          } elseif (str_contains($cdata, "TEL;")) {
137
-                              $cdtelarr = explode("TYPE=", $cdata);
138
-                              $cdteldatarr = explode(":", $cdtelarr[1]);
139
-                                  if (str_contains($cdteldatarr[0], 'CELL') || str_contains($cdteldatarr[0], 'VOICE') || str_contains($cdteldatarr[0], 'CAR')) {
140
-                                      $ctNumberType = $cdteldatarr[0];
141
-                                      $ctNumber = $cdteldatarr[1];
142
-                                      if ($ctNumber) { $telcheck = true; }
143
-                                  }
144
-                          }
145
-                          if ($telcheck) { $contactNumbers[] = [$ctNumberType, $ctNumber]; }
146
-                 }
147
-                 if ($contactNumbers) {
148
-                     $contactData[] = ['contact_name' => $contactName, 'contact_role' => $contactRole, 'contact_type' => 'regular_contact', 'contact_numbers' => $contactNumbers];
149
-                 }
150
-            }
151
-        }
152
-
153
-        // Get the (non-private) phone numbers of Nextcloud users
154
-
155
-        $ncusers = $this->connection->prepare('
156
-                    SELECT `uid`, `data`
157
-		    FROM  `*PREFIX*accounts`');
158
-        $ncusersres = $ncusers->execute();
159
-        $ncUserData = [];
160
-        while ($ncrow = $ncusersres->fetch()) {
161
-               $ncperuserarr = json_decode($ncrow['data'], true);
162
-               if ($ncperuserarr['phone']['value'] && ($ncperuserarr['phone']['scope'] == 'v2-local' || $ncperuserarr['phone']['scope'] == 'v2-federated' || $ncperuserarr['phone']['scope'] == 'v2-published')) {
163
-
164
-                   $ncdisplayname = $ncperuserarr['displayname']['value'];
165
-
166
-                   $nctelnumber = [['VOICE/CELL', $ncperuserarr['phone']['value']]];
167
-
168
-                   if ($ncperuserarr['role']['scope'] == 'v2-local' || $ncperuserarr['role']['scope'] == 'v2-federated' || $ncperuserarr['role']['scope'] == 'v2-published') {
169
-                       $ncuserrole = $ncperuserarr['role']['value'];
170
-                   } else { $ncuserrole = ''; }
171
-
172
-                   $ncUserData[] = ['contact_name' => $ncdisplayname, 'contact_role' => $ncuserrole, 'contact_type' => 'ncuser_contact', 'contact_numbers' => $nctelnumber];
173
-               }
174
-        }
175
-        $ncusersres->closeCursor();
176
-
177
-        $usersAndContacts = array_merge($contactData, $ncUserData);
178
-
179
-        return $usersAndContacts;
180
-    }
181
-
182
-    /**
183
-     * @NoAdminRequired
184
-     *
185
-     */
186
-    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber) {
187
-
188
-        // Validate the data entered in the fields on the settings page
189
-        if (mb_strlen($pdisplayname) > 128) { logger('sip_trip_phone')->error("The 'Display Name' cannot exceed 128 characters!"); exit(); }
190
-        if (!preg_match('/^[a-zA-Z0-9\*\#]+$/', $sipusername)) { logger('sip_trip_phone')->error("The 'SIP User' that you entered is not valid. The 'SIP User' must contain only alphanumeric characters, asterisks (*) and number signs (#).)"); exit(); }        
191
-        if (mb_strlen($sipuserpassword) > 300) { logger('sip_trip_phone')->error("The 'SIP User Password' cannot exceed 300 characters!"); exit(); }      
192
-        if (filter_var($stphwssurl, FILTER_VALIDATE_URL) == false) { logger('sip_trip_phone')->error("The 'WSS URL' that you entered is not valid."); exit(); }
193
-        if (filter_var($siprealm, FILTER_VALIDATE_IP) == false && filter_var($siprealm, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false) { logger('sip_trip_phone')->error("The 'SIP Realm' that you entered is not valid."); exit(); }
194
-        if ($stunserver != '') {
195
-            $stunIpDom = explode(":", $stunserver);
196
-            if ((filter_var($stunIpDom[0], FILTER_VALIDATE_IP) == false && filter_var($stunIpDom[0], FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false) || !preg_match('/^[0-9]+$/', $stunIpDom[1])) { logger('sip_trip_phone')->error("The 'STUN Server' that you entered is not valid."); exit(); }
197
-        }
198
-        if (!preg_match('/^[a-zA-Z0-9\040\+\,\:]*$/', $voicenumbers)) { logger('sip_trip_phone')->error("The 'Available phone numbers' that you entered are not valid. The 'Available phone numbers' must contain only alphanumeric characters, colons (:), spaces, plus signs (+), digits (0-9) and commas (,)."); exit(); }
199
-        if (!preg_match('/^[a-zA-Z0-9\040\+\:]*$/', $defaultvoicenumber)) { logger('sip_trip_phone')->error("The 'Default phone number for outgoing calls' that you entered is not valid. The 'Default phone number for outgoing calls' must contain only alphanumeric characters, a colon (:), a space, a plus sign (+) and digits (0-9)."); exit(); }
200
-
201
-        $sqlup = $this->connection->prepare('
202
-                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`
203
-		    FROM  `*PREFIX*sip_trip_phone`
204
-		    WHERE `user_id` = ?');
205
-        $resultup = $sqlup->execute([$userId]);
206
-        $row = $resultup->fetch();
207
-        $resultup->closeCursor();
208
-
209
-        if ($resultup && !$row) {
210
-
211
-            if ($sipuserpassword != '') {
212
-                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
213
-            } else { $sipuserpasswordenc = ''; }
214
-
215
-            $sqlins = $this->connection->prepare('
216
-				INSERT INTO `*PREFIX*sip_trip_phone`
217
-					(`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`)
218
-				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
219
-	    $sqlins->execute([$userId, $pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber]);
220
-
221
-        } elseif ($resultup && $row) {
222
-
223
-            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
224
-                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
225
-            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
226
-                $sipuserpasswordenc = $row['sipuserpassword'];
227
-            } elseif ($sipuserpassword == '') {
228
-                $sipuserpasswordenc = '';
229
-            }
230
-
231
-	    $sqlup = $this->connection->prepare('
232
-			UPDATE `*PREFIX*sip_trip_phone`
233
-			SET `pdisplayname` = ?, `sipusername` = ?, `sipuserpassword` = ?, `stphwssurl` = ?, `siprealm` = ?, `stunserver` = ?, `tracesipmsg` = ?, `voicenumbers` = ?, `defaultvoicenumber` = ?
234
-                        WHERE `user_id` = ?');
235
-	    $updateRes = $sqlup->execute([$pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber, $userId]);
236
-	    $updateRes->closeCursor();
237
-
238
-        }
239
-    }
240
-}
Browse code

changed appinfo/info.xml appinfo/signature.json CHANGELOG.txt README.md js/launchphone.js lib/Service/SphoneService.php phone/scripts/app.js

DoubleBastionAdmin authored on 07/12/2024 17:32:47
Showing 1 changed files
... ...
@@ -100,12 +100,13 @@ class SphoneService {
100 100
 		    FROM  `*PREFIX*activity`
101 101
 		    WHERE `user` = ? AND `subject` = ?');
102 102
         $rescntcts = $cntctsusr->execute([$userId, $cardadd]);
103
-        $cnctsforuser = [];
103
+        $cnctsforuserinit = [];
104 104
         while ($ctrow = $rescntcts->fetch()) {
105 105
                $ctsperuserarr = json_decode($ctrow['subjectparams'], true);
106
-               $cnctsforuser[] = $ctsperuserarr['card']['id'];
106
+               $cnctsforuserinit[] = $ctsperuserarr['card']['id'];
107 107
         }
108 108
         $rescntcts->closeCursor();
109
+        $cnctsforuser = array_unique($cnctsforuserinit);
109 110
 
110 111
         $contactData = [];
111 112
         if ($cnctsforuser) {
... ...
@@ -126,6 +127,9 @@ class SphoneService {
126 127
                           if (str_contains($cdata, "FN:")) {
127 128
                               $cdnamearr = explode("FN:", $cdata);
128 129
                               $contactName = $cdnamearr[1];
130
+                          } elseif (str_contains($cdata, "FN;")) {
131
+                              $cdnamearr = explode(":", $cdata);
132
+                              $contactName = $cdnamearr[1];
129 133
                           } elseif (str_contains($cdata, "TITLE:")) {
130 134
                               $cdtitlearr = explode("TITLE:", $cdata);
131 135
                               $contactRole = $cdtitlearr[1];
Browse code

added contacts list and call recording and upgraded SIP.js library

DoubleBastionAdmin authored on 21/05/2024 02:08:44
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,236 @@
1
+<?php
2
+/**
3
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
+ *
5
+ * @author Double Bastion LLC
6
+ *
7
+ * @license GNU AGPL version 3 or any later version
8
+ *
9
+ * This program is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
+ * License as published by the Free Software Foundation; either
12
+ * version 3 of the License, or any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
+ *
19
+ * You should have received a copy of the GNU Affero General Public
20
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+declare(strict_types=1);
25
+
26
+namespace OCA\SIPTripPhone\Service;
27
+
28
+use OCP\DB\QueryBuilder\IQueryBuilder;
29
+use OCP\IDBConnection;
30
+use OCP\Security\ICrypto;
31
+use function OCP\Log\logger;
32
+
33
+class SphoneService {
34
+
35
+    private $connection;
36
+    private $crypto;
37
+
38
+    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
+                $this->connection = $connection;
40
+                $this->crypto = $crypto;
41
+    }
42
+
43
+    /**
44
+     * @NoAdminRequired
45
+     *
46
+     */
47
+    public function getsettings($userId) {
48
+
49
+        $sql = $this->connection->prepare('
50
+                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`
51
+		    FROM  `*PREFIX*sip_trip_phone`
52
+		    WHERE `user_id` = ?');
53
+        $result = $sql->execute([$userId]);
54
+        $settingsdb = $result->fetch();
55
+        $result->closeCursor();
56
+
57
+        if ($settingsdb) {
58
+            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
59
+                $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
60
+            } else { $settingsdb['sipuserpassword'] = ''; }
61
+
62
+            return $settingsdb;
63
+        }
64
+    }
65
+
66
+    /**
67
+     * @NoAdminRequired
68
+     *
69
+     */
70
+    public function getsippass($userId) {
71
+
72
+        $sqlps = $this->connection->prepare('
73
+                    SELECT `id`, `user_id`, `sipuserpassword`
74
+		    FROM  `*PREFIX*sip_trip_phone`
75
+		    WHERE `user_id` = ?');
76
+        $resultps = $sqlps->execute([$userId]);
77
+        $settingsdb = $resultps->fetch();
78
+        $resultps->closeCursor();
79
+
80
+        if ($settingsdb) {
81
+            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
82
+                $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword']);
83
+                $sippassword = $sipuserpassworddecr;
84
+            }
85
+
86
+            return $sippassword;
87
+        }
88
+    }
89
+
90
+    /**
91
+     * @NoAdminRequired
92
+     */
93
+    public function getcontactsnmbrs($userId) {
94
+
95
+        // Get the phone numbers of regular contacts
96
+
97
+        $cardadd = "card_add_self";
98
+        $cntctsusr = $this->connection->prepare('
99
+                    SELECT `user`, `subject`, `subjectparams`
100
+		    FROM  `*PREFIX*activity`
101
+		    WHERE `user` = ? AND `subject` = ?');
102
+        $rescntcts = $cntctsusr->execute([$userId, $cardadd]);
103
+        $cnctsforuser = [];
104
+        while ($ctrow = $rescntcts->fetch()) {
105
+               $ctsperuserarr = json_decode($ctrow['subjectparams'], true);
106
+               $cnctsforuser[] = $ctsperuserarr['card']['id'];
107
+        }
108
+        $rescntcts->closeCursor();
109
+
110
+        $contactData = [];
111
+        if ($cnctsforuser) {
112
+
113
+            foreach ($cnctsforuser as $ctkey => $ctid) {
114
+                 $ctdata = $this->connection->prepare('
115
+                           SELECT `carddata`, `uid`
116
+		           FROM  `*PREFIX*cards`
117
+		           WHERE `uid` = ?');
118
+                 $ctdatares = $ctdata->execute([$ctid]);
119
+                 $ctdatarow = $ctdatares->fetch();
120
+                 $ctdatares->closeCursor();
121
+                 $ctdatarr = preg_split('/\r\n|\r|\n/', $ctdatarow['carddata']);
122
+                 $contactNumbers = [];
123
+                 $contactRole = '';
124
+                 foreach ($ctdatarr as $cdkey => $cdata) {
125
+                          $telcheck = false;
126
+                          if (str_contains($cdata, "FN:")) {
127
+                              $cdnamearr = explode("FN:", $cdata);
128
+                              $contactName = $cdnamearr[1];
129
+                          } elseif (str_contains($cdata, "TITLE:")) {
130
+                              $cdtitlearr = explode("TITLE:", $cdata);
131
+                              $contactRole = $cdtitlearr[1];
132
+                          } elseif (str_contains($cdata, "TEL;")) {
133
+                              $cdtelarr = explode("TYPE=", $cdata);
134
+                              $cdteldatarr = explode(":", $cdtelarr[1]);
135
+                                  if (str_contains($cdteldatarr[0], 'CELL') || str_contains($cdteldatarr[0], 'VOICE') || str_contains($cdteldatarr[0], 'CAR')) {
136
+                                      $ctNumberType = $cdteldatarr[0];
137
+                                      $ctNumber = $cdteldatarr[1];
138
+                                      if ($ctNumber) { $telcheck = true; }
139
+                                  }
140
+                          }
141
+                          if ($telcheck) { $contactNumbers[] = [$ctNumberType, $ctNumber]; }
142
+                 }
143
+                 if ($contactNumbers) {
144
+                     $contactData[] = ['contact_name' => $contactName, 'contact_role' => $contactRole, 'contact_type' => 'regular_contact', 'contact_numbers' => $contactNumbers];
145
+                 }
146
+            }
147
+        }
148
+
149
+        // Get the (non-private) phone numbers of Nextcloud users
150
+
151
+        $ncusers = $this->connection->prepare('
152
+                    SELECT `uid`, `data`
153
+		    FROM  `*PREFIX*accounts`');
154
+        $ncusersres = $ncusers->execute();
155
+        $ncUserData = [];
156
+        while ($ncrow = $ncusersres->fetch()) {
157
+               $ncperuserarr = json_decode($ncrow['data'], true);
158
+               if ($ncperuserarr['phone']['value'] && ($ncperuserarr['phone']['scope'] == 'v2-local' || $ncperuserarr['phone']['scope'] == 'v2-federated' || $ncperuserarr['phone']['scope'] == 'v2-published')) {
159
+
160
+                   $ncdisplayname = $ncperuserarr['displayname']['value'];
161
+
162
+                   $nctelnumber = [['VOICE/CELL', $ncperuserarr['phone']['value']]];
163
+
164
+                   if ($ncperuserarr['role']['scope'] == 'v2-local' || $ncperuserarr['role']['scope'] == 'v2-federated' || $ncperuserarr['role']['scope'] == 'v2-published') {
165
+                       $ncuserrole = $ncperuserarr['role']['value'];
166
+                   } else { $ncuserrole = ''; }
167
+
168
+                   $ncUserData[] = ['contact_name' => $ncdisplayname, 'contact_role' => $ncuserrole, 'contact_type' => 'ncuser_contact', 'contact_numbers' => $nctelnumber];
169
+               }
170
+        }
171
+        $ncusersres->closeCursor();
172
+
173
+        $usersAndContacts = array_merge($contactData, $ncUserData);
174
+
175
+        return $usersAndContacts;
176
+    }
177
+
178
+    /**
179
+     * @NoAdminRequired
180
+     *
181
+     */
182
+    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber) {
183
+
184
+        // Validate the data entered in the fields on the settings page
185
+        if (mb_strlen($pdisplayname) > 128) { logger('sip_trip_phone')->error("The 'Display Name' cannot exceed 128 characters!"); exit(); }
186
+        if (!preg_match('/^[a-zA-Z0-9\*\#]+$/', $sipusername)) { logger('sip_trip_phone')->error("The 'SIP User' that you entered is not valid. The 'SIP User' must contain only alphanumeric characters, asterisks (*) and number signs (#).)"); exit(); }        
187
+        if (mb_strlen($sipuserpassword) > 300) { logger('sip_trip_phone')->error("The 'SIP User Password' cannot exceed 300 characters!"); exit(); }      
188
+        if (filter_var($stphwssurl, FILTER_VALIDATE_URL) == false) { logger('sip_trip_phone')->error("The 'WSS URL' that you entered is not valid."); exit(); }
189
+        if (filter_var($siprealm, FILTER_VALIDATE_IP) == false && filter_var($siprealm, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false) { logger('sip_trip_phone')->error("The 'SIP Realm' that you entered is not valid."); exit(); }
190
+        if ($stunserver != '') {
191
+            $stunIpDom = explode(":", $stunserver);
192
+            if ((filter_var($stunIpDom[0], FILTER_VALIDATE_IP) == false && filter_var($stunIpDom[0], FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false) || !preg_match('/^[0-9]+$/', $stunIpDom[1])) { logger('sip_trip_phone')->error("The 'STUN Server' that you entered is not valid."); exit(); }
193
+        }
194
+        if (!preg_match('/^[a-zA-Z0-9\040\+\,\:]*$/', $voicenumbers)) { logger('sip_trip_phone')->error("The 'Available phone numbers' that you entered are not valid. The 'Available phone numbers' must contain only alphanumeric characters, colons (:), spaces, plus signs (+), digits (0-9) and commas (,)."); exit(); }
195
+        if (!preg_match('/^[a-zA-Z0-9\040\+\:]*$/', $defaultvoicenumber)) { logger('sip_trip_phone')->error("The 'Default phone number for outgoing calls' that you entered is not valid. The 'Default phone number for outgoing calls' must contain only alphanumeric characters, a colon (:), a space, a plus sign (+) and digits (0-9)."); exit(); }
196
+
197
+        $sqlup = $this->connection->prepare('
198
+                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`
199
+		    FROM  `*PREFIX*sip_trip_phone`
200
+		    WHERE `user_id` = ?');
201
+        $resultup = $sqlup->execute([$userId]);
202
+        $row = $resultup->fetch();
203
+        $resultup->closeCursor();
204
+
205
+        if ($resultup && !$row) {
206
+
207
+            if ($sipuserpassword != '') {
208
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
209
+            } else { $sipuserpasswordenc = ''; }
210
+
211
+            $sqlins = $this->connection->prepare('
212
+				INSERT INTO `*PREFIX*sip_trip_phone`
213
+					(`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`)
214
+				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
215
+	    $sqlins->execute([$userId, $pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber]);
216
+
217
+        } elseif ($resultup && $row) {
218
+
219
+            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
220
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
221
+            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
222
+                $sipuserpasswordenc = $row['sipuserpassword'];
223
+            } elseif ($sipuserpassword == '') {
224
+                $sipuserpasswordenc = '';
225
+            }
226
+
227
+	    $sqlup = $this->connection->prepare('
228
+			UPDATE `*PREFIX*sip_trip_phone`
229
+			SET `pdisplayname` = ?, `sipusername` = ?, `sipuserpassword` = ?, `stphwssurl` = ?, `siprealm` = ?, `stunserver` = ?, `tracesipmsg` = ?, `voicenumbers` = ?, `defaultvoicenumber` = ?
230
+                        WHERE `user_id` = ?');
231
+	    $updateRes = $sqlup->execute([$pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber, $userId]);
232
+	    $updateRes->closeCursor();
233
+
234
+        }
235
+    }
236
+}
Browse code

removed files to add contacts lits and recording and to upgrade the SIP.js library

DoubleBastionAdmin authored on 21/05/2024 01:25:05
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,148 +0,0 @@
1
-<?php
2
-/**
3
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
- *
5
- * @author Double Bastion LLC
6
- *
7
- * @license GNU AGPL version 3 or any later version
8
- *
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
- * License as published by the Free Software Foundation; either
12
- * version 3 of the License, or any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
- *
19
- * You should have received a copy of the GNU Affero General Public
20
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
- *
22
- */
23
-
24
-declare(strict_types=1);
25
-
26
-namespace OCA\SIPTripPhone\Service;
27
-
28
-use OCP\DB\QueryBuilder\IQueryBuilder;
29
-use OCP\IDBConnection;
30
-use OCP\Security\ICrypto;
31
-use function OCP\Log\logger;
32
-
33
-class SphoneService {
34
-
35
-    private $connection;
36
-    private $crypto;
37
-
38
-    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
-                $this->connection = $connection;
40
-                $this->crypto = $crypto;
41
-    }
42
-
43
-    /**
44
-     * @NoAdminRequired
45
-     *
46
-     */
47
-    public function getsettings($userId) {
48
-
49
-        $sql = $this->connection->prepare('
50
-                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`
51
-		    FROM  `*PREFIX*sip_trip_phone`
52
-		    WHERE `user_id` = ?');
53
-        $result = $sql->execute([$userId]);
54
-        $settingsdb = $result->fetch();
55
-        $result->closeCursor();
56
-
57
-        if ($settingsdb) {
58
-            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
59
-                $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
60
-            } else { $settingsdb['sipuserpassword'] = ''; }
61
-
62
-            return $settingsdb;
63
-        }
64
-    }
65
-
66
-    /**
67
-     * @NoAdminRequired
68
-     *
69
-     */
70
-    public function getsippass($userId) {
71
-
72
-        $sqlps = $this->connection->prepare('
73
-                    SELECT `id`, `user_id`, `sipuserpassword`
74
-		    FROM  `*PREFIX*sip_trip_phone`
75
-		    WHERE `user_id` = ?');
76
-        $resultps = $sqlps->execute([$userId]);
77
-        $settingsdb = $resultps->fetch();
78
-        $resultps->closeCursor();
79
-
80
-        if ($settingsdb) {
81
-            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
82
-                $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword']);
83
-                $sippassword = $sipuserpassworddecr;
84
-            }
85
-
86
-            return $sippassword;
87
-        }
88
-    }
89
-
90
-    /**
91
-     * @NoAdminRequired
92
-     *
93
-     */
94
-    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber) {
95
-
96
-        // Validate the data entered in the fields on the settings page
97
-        if (mb_strlen($pdisplayname) > 128) { logger('sip_trip_phone')->error("The 'Display Name' cannot exceed 128 characters!"); exit(); }
98
-        if (!preg_match('/^[a-zA-Z0-9\*\#]+$/', $sipusername)) { logger('sip_trip_phone')->error("The 'SIP User' that you entered is not valid. The 'SIP User' must contain only alphanumeric characters, asterisks (*) and number signs (#).)"); exit(); }        
99
-        if (mb_strlen($sipuserpassword) > 300) { logger('sip_trip_phone')->error("The 'SIP User Password' cannot exceed 300 characters!"); exit(); }      
100
-        if (filter_var($stphwssurl, FILTER_VALIDATE_URL) == false) { logger('sip_trip_phone')->error("The 'WSS URL' that you entered is not valid."); exit(); }
101
-        if (filter_var($siprealm, FILTER_VALIDATE_IP) == false && filter_var($siprealm, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false) { logger('sip_trip_phone')->error("The 'SIP Realm' that you entered is not valid."); exit(); }
102
-        if ($stunserver != '') {
103
-            $stunIpDom = explode(":", $stunserver);
104
-            if ((filter_var($stunIpDom[0], FILTER_VALIDATE_IP) == false && filter_var($stunIpDom[0], FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false) || !preg_match('/^[0-9]+$/', $stunIpDom[1])) { logger('sip_trip_phone')->error("The 'STUN Server' that you entered is not valid."); exit(); }
105
-        }
106
-        if (!preg_match('/^[a-zA-Z0-9\040\+\,\:]*$/', $voicenumbers)) { logger('sip_trip_phone')->error("The 'Available phone numbers' that you entered are not valid. The 'Available phone numbers' must contain only alphanumeric characters, colons (:), spaces, plus signs (+), digits (0-9) and commas (,)."); exit(); }
107
-        if (!preg_match('/^[a-zA-Z0-9\040\+\:]*$/', $defaultvoicenumber)) { logger('sip_trip_phone')->error("The 'Default phone number for outgoing calls' that you entered is not valid. The 'Default phone number for outgoing calls' must contain only alphanumeric characters, a colon (:), a space, a plus sign (+) and digits (0-9)."); exit(); }
108
-
109
-        $sqlup = $this->connection->prepare('
110
-                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`
111
-		    FROM  `*PREFIX*sip_trip_phone`
112
-		    WHERE `user_id` = ?');
113
-        $resultup = $sqlup->execute([$userId]);
114
-        $row = $resultup->fetch();
115
-        $resultup->closeCursor();
116
-
117
-        if ($resultup && !$row) {
118
-
119
-            if ($sipuserpassword != '') {
120
-                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
121
-            } else { $sipuserpasswordenc = ''; }
122
-
123
-            $sqlins = $this->connection->prepare('
124
-				INSERT INTO `*PREFIX*sip_trip_phone`
125
-					(`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`)
126
-				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
127
-	    $sqlins->execute([$userId, $pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber]);
128
-
129
-        } elseif ($resultup && $row) {
130
-
131
-            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
132
-                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
133
-            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
134
-                $sipuserpasswordenc = $row['sipuserpassword'];
135
-            } elseif ($sipuserpassword == '') {
136
-                $sipuserpasswordenc = '';
137
-            }
138
-
139
-	    $sqlup = $this->connection->prepare('
140
-			UPDATE `*PREFIX*sip_trip_phone`
141
-			SET `pdisplayname` = ?, `sipusername` = ?, `sipuserpassword` = ?, `stphwssurl` = ?, `siprealm` = ?, `stunserver` = ?, `tracesipmsg` = ?, `voicenumbers` = ?, `defaultvoicenumber` = ?
142
-                        WHERE `user_id` = ?');
143
-	    $updateRes = $sqlup->execute([$pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber, $userId]);
144
-	    $updateRes->closeCursor();
145
-
146
-        }
147
-    }
148
-}
Browse code

added changes to implement the From number drop-down list, the available numbers and default number fields and the debug logging checkbox, etc.

DoubleBastionAdmin authored on 08/01/2024 19:33:20
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,148 @@
1
+<?php
2
+/**
3
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
+ *
5
+ * @author Double Bastion LLC
6
+ *
7
+ * @license GNU AGPL version 3 or any later version
8
+ *
9
+ * This program is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
+ * License as published by the Free Software Foundation; either
12
+ * version 3 of the License, or any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
+ *
19
+ * You should have received a copy of the GNU Affero General Public
20
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+declare(strict_types=1);
25
+
26
+namespace OCA\SIPTripPhone\Service;
27
+
28
+use OCP\DB\QueryBuilder\IQueryBuilder;
29
+use OCP\IDBConnection;
30
+use OCP\Security\ICrypto;
31
+use function OCP\Log\logger;
32
+
33
+class SphoneService {
34
+
35
+    private $connection;
36
+    private $crypto;
37
+
38
+    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
+                $this->connection = $connection;
40
+                $this->crypto = $crypto;
41
+    }
42
+
43
+    /**
44
+     * @NoAdminRequired
45
+     *
46
+     */
47
+    public function getsettings($userId) {
48
+
49
+        $sql = $this->connection->prepare('
50
+                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`
51
+		    FROM  `*PREFIX*sip_trip_phone`
52
+		    WHERE `user_id` = ?');
53
+        $result = $sql->execute([$userId]);
54
+        $settingsdb = $result->fetch();
55
+        $result->closeCursor();
56
+
57
+        if ($settingsdb) {
58
+            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
59
+                $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
60
+            } else { $settingsdb['sipuserpassword'] = ''; }
61
+
62
+            return $settingsdb;
63
+        }
64
+    }
65
+
66
+    /**
67
+     * @NoAdminRequired
68
+     *
69
+     */
70
+    public function getsippass($userId) {
71
+
72
+        $sqlps = $this->connection->prepare('
73
+                    SELECT `id`, `user_id`, `sipuserpassword`
74
+		    FROM  `*PREFIX*sip_trip_phone`
75
+		    WHERE `user_id` = ?');
76
+        $resultps = $sqlps->execute([$userId]);
77
+        $settingsdb = $resultps->fetch();
78
+        $resultps->closeCursor();
79
+
80
+        if ($settingsdb) {
81
+            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
82
+                $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword']);
83
+                $sippassword = $sipuserpassworddecr;
84
+            }
85
+
86
+            return $sippassword;
87
+        }
88
+    }
89
+
90
+    /**
91
+     * @NoAdminRequired
92
+     *
93
+     */
94
+    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber) {
95
+
96
+        // Validate the data entered in the fields on the settings page
97
+        if (mb_strlen($pdisplayname) > 128) { logger('sip_trip_phone')->error("The 'Display Name' cannot exceed 128 characters!"); exit(); }
98
+        if (!preg_match('/^[a-zA-Z0-9\*\#]+$/', $sipusername)) { logger('sip_trip_phone')->error("The 'SIP User' that you entered is not valid. The 'SIP User' must contain only alphanumeric characters, asterisks (*) and number signs (#).)"); exit(); }        
99
+        if (mb_strlen($sipuserpassword) > 300) { logger('sip_trip_phone')->error("The 'SIP User Password' cannot exceed 300 characters!"); exit(); }      
100
+        if (filter_var($stphwssurl, FILTER_VALIDATE_URL) == false) { logger('sip_trip_phone')->error("The 'WSS URL' that you entered is not valid."); exit(); }
101
+        if (filter_var($siprealm, FILTER_VALIDATE_IP) == false && filter_var($siprealm, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false) { logger('sip_trip_phone')->error("The 'SIP Realm' that you entered is not valid."); exit(); }
102
+        if ($stunserver != '') {
103
+            $stunIpDom = explode(":", $stunserver);
104
+            if ((filter_var($stunIpDom[0], FILTER_VALIDATE_IP) == false && filter_var($stunIpDom[0], FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false) || !preg_match('/^[0-9]+$/', $stunIpDom[1])) { logger('sip_trip_phone')->error("The 'STUN Server' that you entered is not valid."); exit(); }
105
+        }
106
+        if (!preg_match('/^[a-zA-Z0-9\040\+\,\:]*$/', $voicenumbers)) { logger('sip_trip_phone')->error("The 'Available phone numbers' that you entered are not valid. The 'Available phone numbers' must contain only alphanumeric characters, colons (:), spaces, plus signs (+), digits (0-9) and commas (,)."); exit(); }
107
+        if (!preg_match('/^[a-zA-Z0-9\040\+\:]*$/', $defaultvoicenumber)) { logger('sip_trip_phone')->error("The 'Default phone number for outgoing calls' that you entered is not valid. The 'Default phone number for outgoing calls' must contain only alphanumeric characters, a colon (:), a space, a plus sign (+) and digits (0-9)."); exit(); }
108
+
109
+        $sqlup = $this->connection->prepare('
110
+                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`
111
+		    FROM  `*PREFIX*sip_trip_phone`
112
+		    WHERE `user_id` = ?');
113
+        $resultup = $sqlup->execute([$userId]);
114
+        $row = $resultup->fetch();
115
+        $resultup->closeCursor();
116
+
117
+        if ($resultup && !$row) {
118
+
119
+            if ($sipuserpassword != '') {
120
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
121
+            } else { $sipuserpasswordenc = ''; }
122
+
123
+            $sqlins = $this->connection->prepare('
124
+				INSERT INTO `*PREFIX*sip_trip_phone`
125
+					(`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`, `tracesipmsg`, `voicenumbers`, `defaultvoicenumber`)
126
+				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
127
+	    $sqlins->execute([$userId, $pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber]);
128
+
129
+        } elseif ($resultup && $row) {
130
+
131
+            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
132
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
133
+            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
134
+                $sipuserpasswordenc = $row['sipuserpassword'];
135
+            } elseif ($sipuserpassword == '') {
136
+                $sipuserpasswordenc = '';
137
+            }
138
+
139
+	    $sqlup = $this->connection->prepare('
140
+			UPDATE `*PREFIX*sip_trip_phone`
141
+			SET `pdisplayname` = ?, `sipusername` = ?, `sipuserpassword` = ?, `stphwssurl` = ?, `siprealm` = ?, `stunserver` = ?, `tracesipmsg` = ?, `voicenumbers` = ?, `defaultvoicenumber` = ?
142
+                        WHERE `user_id` = ?');
143
+	    $updateRes = $sqlup->execute([$pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $tracesipmsg, $voicenumbers, $defaultvoicenumber, $userId]);
144
+	    $updateRes->closeCursor();
145
+
146
+        }
147
+    }
148
+}
Browse code

removed appinfo/info.xml appinfo/signature.json CHANGELOG.txt README.md js/settings.js js/launchphone.js css/style.css phone/scripts/app.js templates/settings.php l10n/en_GB.js l10n/en_GB.json phone/css/ctxSip.css phone/index.html lib/Controller/SphoneController.php lib/Service/SphoneService.php phone/sounds/dtmf.mp3 phone/sounds/incoming.mp3 phone/sounds/outgoing.mp3 img/sip_trip_phone_screenshot.png img/sip_trip_phone_transfer_call.png img/sip_trip_phone_making_calls.png img/sip_trip_phone_initial_screen.png img/sip_trip_phone_dialpad.png

DoubleBastionAdmin authored on 08/01/2024 19:00:48
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,135 +0,0 @@
1
-<?php
2
-/**
3
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
- *
5
- * @author Double Bastion LLC
6
- *
7
- * @license GNU AGPL version 3 or any later version
8
- *
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
- * License as published by the Free Software Foundation; either
12
- * version 3 of the License, or any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
- *
19
- * You should have received a copy of the GNU Affero General Public
20
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
- *
22
- */
23
-
24
-declare(strict_types=1);
25
-
26
-namespace OCA\SIPTripPhone\Service;
27
-
28
-use OCP\DB\QueryBuilder\IQueryBuilder;
29
-use OCP\IDBConnection;
30
-use OCP\Security\ICrypto;
31
-
32
-
33
-class SphoneService {
34
-
35
-    private $connection;
36
-    private $crypto;
37
-
38
-    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
-                $this->connection = $connection;
40
-                $this->crypto = $crypto;
41
-    }
42
-
43
-    /**
44
-     * @NoAdminRequired
45
-     *
46
-     */
47
-    public function getsettings($userId) {
48
-
49
-        $sql = $this->connection->prepare('
50
-                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`
51
-		    FROM  `*PREFIX*sip_trip_phone`
52
-		    WHERE `user_id` = ?');
53
-        $result = $sql->execute([$userId]);
54
-        $settingsdb = $result->fetch();
55
-        $result->closeCursor();
56
-
57
-        if ($settingsdb) {
58
-            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
59
-                $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
60
-            } else { $settingsdb['sipuserpassword'] = ''; }
61
-
62
-            return $settingsdb;
63
-        }
64
-    }
65
-
66
-    /**
67
-     * @NoAdminRequired
68
-     *
69
-     */
70
-    public function getsippass($userId) {
71
-
72
-        $sqlps = $this->connection->prepare('
73
-                    SELECT `id`, `user_id`, `sipuserpassword`
74
-		    FROM  `*PREFIX*sip_trip_phone`
75
-		    WHERE `user_id` = ?');
76
-        $resultps = $sqlps->execute([$userId]);
77
-        $settingsdb = $resultps->fetch();
78
-        $resultps->closeCursor();
79
-
80
-        if ($settingsdb) {
81
-            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
82
-                $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword']);
83
-                $sippassword = $sipuserpassworddecr;
84
-            }
85
-
86
-            return $sippassword;
87
-        }
88
-    }
89
-
90
-    /**
91
-     * @NoAdminRequired
92
-     *
93
-     */
94
-    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver) {
95
-
96
-        $sqlup = $this->connection->prepare('
97
-                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`
98
-		    FROM  `*PREFIX*sip_trip_phone`
99
-		    WHERE `user_id` = ?');
100
-        $resultup = $sqlup->execute([$userId]);
101
-        $row = $resultup->fetch();
102
-        $resultup->closeCursor();
103
-
104
-        if ($resultup && !$row) {
105
-
106
-            if ($sipuserpassword != '') {
107
-                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
108
-            } else { $sipuserpasswordenc = ''; }
109
-
110
-            $sqlins = $this->connection->prepare('
111
-				INSERT INTO `*PREFIX*sip_trip_phone`
112
-					(`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`)
113
-				VALUES (?, ?, ?, ?, ?, ?, ?)');
114
-	    $sqlins->execute([$userId, $pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver]);
115
-
116
-        } elseif ($resultup && $row) {
117
-
118
-            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
119
-                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
120
-            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
121
-                $sipuserpasswordenc = $row['sipuserpassword'];
122
-            } elseif ($sipuserpassword == '') {
123
-                $sipuserpasswordenc = '';
124
-            }
125
-
126
-	    $sqlup = $this->connection->prepare('
127
-			UPDATE `*PREFIX*sip_trip_phone`
128
-			SET `pdisplayname` = ?, `sipusername` = ?, `sipuserpassword` = ?, `stphwssurl` = ?, `siprealm` = ?, `stunserver` = ?
129
-                        WHERE `user_id` = ?');
130
-	    $updateRes = $sqlup->execute([$pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $userId]);
131
-	    $updateRes->closeCursor();
132
-
133
-        }
134
-    }
135
-}
Browse code

added CHANGELOG.txt appinfo/info.xml appinfo/signature.json lib/Service/SphoneService.php lib/Migration/Version100Date20211106173528.php phone/index.html

DoubleBastionAdmin authored on 03/12/2022 16:44:41
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,135 @@
1
+<?php
2
+/**
3
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
+ *
5
+ * @author Double Bastion LLC
6
+ *
7
+ * @license GNU AGPL version 3 or any later version
8
+ *
9
+ * This program is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
+ * License as published by the Free Software Foundation; either
12
+ * version 3 of the License, or any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
+ *
19
+ * You should have received a copy of the GNU Affero General Public
20
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+declare(strict_types=1);
25
+
26
+namespace OCA\SIPTripPhone\Service;
27
+
28
+use OCP\DB\QueryBuilder\IQueryBuilder;
29
+use OCP\IDBConnection;
30
+use OCP\Security\ICrypto;
31
+
32
+
33
+class SphoneService {
34
+
35
+    private $connection;
36
+    private $crypto;
37
+
38
+    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
+                $this->connection = $connection;
40
+                $this->crypto = $crypto;
41
+    }
42
+
43
+    /**
44
+     * @NoAdminRequired
45
+     *
46
+     */
47
+    public function getsettings($userId) {
48
+
49
+        $sql = $this->connection->prepare('
50
+                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`
51
+		    FROM  `*PREFIX*sip_trip_phone`
52
+		    WHERE `user_id` = ?');
53
+        $result = $sql->execute([$userId]);
54
+        $settingsdb = $result->fetch();
55
+        $result->closeCursor();
56
+
57
+        if ($settingsdb) {
58
+            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
59
+                $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
60
+            } else { $settingsdb['sipuserpassword'] = ''; }
61
+
62
+            return $settingsdb;
63
+        }
64
+    }
65
+
66
+    /**
67
+     * @NoAdminRequired
68
+     *
69
+     */
70
+    public function getsippass($userId) {
71
+
72
+        $sqlps = $this->connection->prepare('
73
+                    SELECT `id`, `user_id`, `sipuserpassword`
74
+		    FROM  `*PREFIX*sip_trip_phone`
75
+		    WHERE `user_id` = ?');
76
+        $resultps = $sqlps->execute([$userId]);
77
+        $settingsdb = $resultps->fetch();
78
+        $resultps->closeCursor();
79
+
80
+        if ($settingsdb) {
81
+            if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
82
+                $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword']);
83
+                $sippassword = $sipuserpassworddecr;
84
+            }
85
+
86
+            return $sippassword;
87
+        }
88
+    }
89
+
90
+    /**
91
+     * @NoAdminRequired
92
+     *
93
+     */
94
+    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver) {
95
+
96
+        $sqlup = $this->connection->prepare('
97
+                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`
98
+		    FROM  `*PREFIX*sip_trip_phone`
99
+		    WHERE `user_id` = ?');
100
+        $resultup = $sqlup->execute([$userId]);
101
+        $row = $resultup->fetch();
102
+        $resultup->closeCursor();
103
+
104
+        if ($resultup && !$row) {
105
+
106
+            if ($sipuserpassword != '') {
107
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
108
+            } else { $sipuserpasswordenc = ''; }
109
+
110
+            $sqlins = $this->connection->prepare('
111
+				INSERT INTO `*PREFIX*sip_trip_phone`
112
+					(`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`)
113
+				VALUES (?, ?, ?, ?, ?, ?, ?)');
114
+	    $sqlins->execute([$userId, $pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver]);
115
+
116
+        } elseif ($resultup && $row) {
117
+
118
+            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
119
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
120
+            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
121
+                $sipuserpasswordenc = $row['sipuserpassword'];
122
+            } elseif ($sipuserpassword == '') {
123
+                $sipuserpasswordenc = '';
124
+            }
125
+
126
+	    $sqlup = $this->connection->prepare('
127
+			UPDATE `*PREFIX*sip_trip_phone`
128
+			SET `pdisplayname` = ?, `sipusername` = ?, `sipuserpassword` = ?, `stphwssurl` = ?, `siprealm` = ?, `stunserver` = ?
129
+                        WHERE `user_id` = ?');
130
+	    $updateRes = $sqlup->execute([$pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $userId]);
131
+	    $updateRes->closeCursor();
132
+
133
+        }
134
+    }
135
+}
Browse code

removed CHANGELOG.txt appinfo/info.xml appinfo/signature.json lib/Service/SphoneService.php lib/Migration/Version100Date20211106173528.php phone/index.html

DoubleBastionAdmin authored on 03/12/2022 16:41:06
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,131 +0,0 @@
1
-<?php
2
-/**
3
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
- *
5
- * @author Double Bastion LLC
6
- *
7
- * @license GNU AGPL version 3 or any later version
8
- *
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
- * License as published by the Free Software Foundation; either
12
- * version 3 of the License, or any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
- *
19
- * You should have received a copy of the GNU Affero General Public
20
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
- *
22
- */
23
-
24
-declare(strict_types=1);
25
-
26
-namespace OCA\SIPTripPhone\Service;
27
-
28
-use OCP\DB\QueryBuilder\IQueryBuilder;
29
-use OCP\IDBConnection;
30
-use OCP\Security\ICrypto;
31
-
32
-
33
-class SphoneService {
34
-
35
-    private $connection;
36
-    private $crypto;
37
-
38
-    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
-                $this->connection = $connection;
40
-                $this->crypto = $crypto;
41
-    }
42
-
43
-    /**
44
-     * @NoAdminRequired
45
-     *
46
-     */
47
-    public function getsettings($userId) {
48
-
49
-        $sql = $this->connection->prepare('
50
-                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`
51
-		    FROM  `*PREFIX*sip_trip_phone`
52
-		    WHERE `user_id` = ?');
53
-        $result = $sql->execute([$userId]);
54
-        $settingsdb = $result->fetch();
55
-        $result->closeCursor();
56
-
57
-        if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
58
-            $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
59
-        } else { $settingsdb['sipuserpassword'] = ''; }
60
-
61
-        return $settingsdb;
62
-    }
63
-
64
-    /**
65
-     * @NoAdminRequired
66
-     *
67
-     */
68
-    public function getsippass($userId) {
69
-
70
-        $sqlps = $this->connection->prepare('
71
-                    SELECT `id`, `user_id`, `sipuserpassword`
72
-		    FROM  `*PREFIX*sip_trip_phone`
73
-		    WHERE `user_id` = ?');
74
-        $resultps = $sqlps->execute([$userId]);
75
-        $settingsdb = $resultps->fetch();
76
-        $resultps->closeCursor();
77
-
78
-        if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
79
-            $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword']);
80
-            $sippassword = $sipuserpassworddecr;
81
-        }
82
-
83
-        return $sippassword;
84
-    }
85
-
86
-    /**
87
-     * @NoAdminRequired
88
-     *
89
-     */
90
-    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver) {
91
-
92
-        $sqlup = $this->connection->prepare('
93
-                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`
94
-		    FROM  `*PREFIX*sip_trip_phone`
95
-		    WHERE `user_id` = ?');
96
-        $resultup = $sqlup->execute([$userId]);
97
-        $row = $resultup->fetch();
98
-        $resultup->closeCursor();
99
-
100
-        if ($row['user_id'] == '' || $row['user_id'] == 'undefined' || $row['user_id'] == null) {
101
-
102
-            if ($sipuserpassword != '') {
103
-                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
104
-            } else { $sipuserpasswordenc = ''; }
105
-
106
-            $sqlins = $this->connection->prepare('
107
-				INSERT INTO `*PREFIX*sip_trip_phone`
108
-					(`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`)
109
-				VALUES (?, ?, ?, ?, ?, ?, ?)');
110
-	    $sqlins->execute([$userId, $pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver]);
111
-
112
-        } else {
113
-
114
-            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
115
-                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
116
-            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
117
-                $sipuserpasswordenc = $row['sipuserpassword'];
118
-            } elseif ($sipuserpassword == '') {
119
-                $sipuserpasswordenc = '';
120
-            }
121
-
122
-	    $sqlup = $this->connection->prepare('
123
-			UPDATE `*PREFIX*sip_trip_phone`
124
-			SET `pdisplayname` = ?, `sipusername` = ?, `sipuserpassword` = ?, `stphwssurl` = ?, `siprealm` = ?, `stunserver` = ?
125
-                        WHERE `user_id` = ?');
126
-	    $updateRes = $sqlup->execute([$pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $userId]);
127
-	    $updateRes->closeCursor();
128
-
129
-        }
130
-    }
131
-}
Browse code

added CHANGELOG.txt Contributors.txt README.md appinfo/info.xml appinfo/signature.json js/launchphone.js lib/Service/SphoneService.php

DoubleBastionAdmin authored on 09/05/2022 18:32:24
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,131 @@
1
+<?php
2
+/**
3
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
+ *
5
+ * @author Double Bastion LLC
6
+ *
7
+ * @license GNU AGPL version 3 or any later version
8
+ *
9
+ * This program is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
+ * License as published by the Free Software Foundation; either
12
+ * version 3 of the License, or any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
+ *
19
+ * You should have received a copy of the GNU Affero General Public
20
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+declare(strict_types=1);
25
+
26
+namespace OCA\SIPTripPhone\Service;
27
+
28
+use OCP\DB\QueryBuilder\IQueryBuilder;
29
+use OCP\IDBConnection;
30
+use OCP\Security\ICrypto;
31
+
32
+
33
+class SphoneService {
34
+
35
+    private $connection;
36
+    private $crypto;
37
+
38
+    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
+                $this->connection = $connection;
40
+                $this->crypto = $crypto;
41
+    }
42
+
43
+    /**
44
+     * @NoAdminRequired
45
+     *
46
+     */
47
+    public function getsettings($userId) {
48
+
49
+        $sql = $this->connection->prepare('
50
+                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`
51
+		    FROM  `*PREFIX*sip_trip_phone`
52
+		    WHERE `user_id` = ?');
53
+        $result = $sql->execute([$userId]);
54
+        $settingsdb = $result->fetch();
55
+        $result->closeCursor();
56
+
57
+        if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
58
+            $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
59
+        } else { $settingsdb['sipuserpassword'] = ''; }
60
+
61
+        return $settingsdb;
62
+    }
63
+
64
+    /**
65
+     * @NoAdminRequired
66
+     *
67
+     */
68
+    public function getsippass($userId) {
69
+
70
+        $sqlps = $this->connection->prepare('
71
+                    SELECT `id`, `user_id`, `sipuserpassword`
72
+		    FROM  `*PREFIX*sip_trip_phone`
73
+		    WHERE `user_id` = ?');
74
+        $resultps = $sqlps->execute([$userId]);
75
+        $settingsdb = $resultps->fetch();
76
+        $resultps->closeCursor();
77
+
78
+        if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
79
+            $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword']);
80
+            $sippassword = $sipuserpassworddecr;
81
+        }
82
+
83
+        return $sippassword;
84
+    }
85
+
86
+    /**
87
+     * @NoAdminRequired
88
+     *
89
+     */
90
+    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver) {
91
+
92
+        $sqlup = $this->connection->prepare('
93
+                    SELECT `id`, `user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`
94
+		    FROM  `*PREFIX*sip_trip_phone`
95
+		    WHERE `user_id` = ?');
96
+        $resultup = $sqlup->execute([$userId]);
97
+        $row = $resultup->fetch();
98
+        $resultup->closeCursor();
99
+
100
+        if ($row['user_id'] == '' || $row['user_id'] == 'undefined' || $row['user_id'] == null) {
101
+
102
+            if ($sipuserpassword != '') {
103
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
104
+            } else { $sipuserpasswordenc = ''; }
105
+
106
+            $sqlins = $this->connection->prepare('
107
+				INSERT INTO `*PREFIX*sip_trip_phone`
108
+					(`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`)
109
+				VALUES (?, ?, ?, ?, ?, ?, ?)');
110
+	    $sqlins->execute([$userId, $pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver]);
111
+
112
+        } else {
113
+
114
+            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
115
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword);
116
+            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
117
+                $sipuserpasswordenc = $row['sipuserpassword'];
118
+            } elseif ($sipuserpassword == '') {
119
+                $sipuserpasswordenc = '';
120
+            }
121
+
122
+	    $sqlup = $this->connection->prepare('
123
+			UPDATE `*PREFIX*sip_trip_phone`
124
+			SET `pdisplayname` = ?, `sipusername` = ?, `sipuserpassword` = ?, `stphwssurl` = ?, `siprealm` = ?, `stunserver` = ?
125
+                        WHERE `user_id` = ?');
126
+	    $updateRes = $sqlup->execute([$pdisplayname, $sipusername, $sipuserpasswordenc, $stphwssurl, $siprealm, $stunserver, $userId]);
127
+	    $updateRes->closeCursor();
128
+
129
+        }
130
+    }
131
+}
Browse code

removed CHANGELOG.txt Contributors.txt README.md appinfo/info.xml appinfo/signature.json js/launchphone.js lib/Service/SphoneService.php

DoubleBastionAdmin authored on 09/05/2022 18:29:08
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,126 +0,0 @@
1
-<?php
2
-/**
3
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
- *
5
- * @author Double Bastion LLC
6
- *
7
- * @license GNU AGPL version 3 or any later version
8
- *
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
- * License as published by the Free Software Foundation; either
12
- * version 3 of the License, or any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
- *
19
- * You should have received a copy of the GNU Affero General Public
20
- * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
- *
22
- */
23
-
24
-declare(strict_types=1);
25
-
26
-namespace OCA\SIPTripPhone\Service;
27
-
28
-use OCP\DB\QueryBuilder\IQueryBuilder;
29
-use OCP\IDBConnection;
30
-use OCP\Security\ICrypto;
31
-
32
-
33
-class SphoneService {
34
-
35
-    private $connection;
36
-    private $crypto;
37
-
38
-    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
-                $this->connection = $connection;
40
-                $this->crypto = $crypto;
41
-    }
42
-
43
-    /**
44
-     * @NoAdminRequired
45
-     *
46
-     */
47
-    public function getsettings($userId) {
48
-
49
-        $sql0 = "SELECT * FROM `*PREFIX*sip_trip_phone` WHERE `user_id` = '$userId'";
50
-
51
-        $res0 = $this->connection->prepare($sql0);
52
-        $res0->execute();
53
-
54
-        $settingsdb = $res0->fetch();
55
-
56
-        if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
57
-            $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
58
-        } else { $settingsdb['sipuserpassword'] = ''; }
59
-
60
-        $res0->closeCursor();
61
-
62
-        return $settingsdb;
63
-    }
64
-
65
-    /**
66
-     * @NoAdminRequired
67
-     *
68
-     */
69
-    public function getsippass($userId) {
70
-
71
-        $sql0 = "SELECT `id`, `user_id`, `sipuserpassword` FROM `*PREFIX*sip_trip_phone` WHERE `user_id` = '$userId'";
72
-
73
-        $res0 = $this->connection->prepare($sql0);
74
-        $res0->execute();
75
-
76
-        $settingsdb = $res0->fetch();
77
-        if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
78
-            $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword'], $password = '');
79
-            $sippassword = $sipuserpassworddecr;
80
-        }
81
-        $res0->closeCursor();
82
-
83
-        return $sippassword;
84
-    }
85
-
86
-    /**
87
-     * @NoAdminRequired
88
-     *
89
-     */
90
-    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver) {
91
-
92
-        $sql1 = "SELECT * FROM `*PREFIX*sip_trip_phone` WHERE `user_id` = '$userId'";
93
-        $res1 = $this->connection->prepare($sql1);
94
-        $res1->execute();
95
-
96
-        $row = $res1->fetch();
97
-        $res1->closeCursor();
98
-
99
-        if ($row['user_id'] == '' || $row['user_id'] == 'undefined' || $row['user_id'] == null) {
100
-
101
-            if ($sipuserpassword != '') {
102
-                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword, $password = '');                
103
-            } else { $sipuserpasswordenc = ''; }
104
-
105
-            $sql2 = "INSERT INTO `*PREFIX*sip_trip_phone` (`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`)
106
-                     VALUES ('$userId', '$pdisplayname', '$sipusername', '$sipuserpasswordenc', '$stphwssurl', '$siprealm', '$stunserver')";
107
-            $res2 = $this->connection->prepare($sql2);
108
-            $res2->execute();
109
-
110
-        } else {
111
-
112
-            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
113
-                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword, $password = '');                
114
-            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
115
-                $sipuserpasswordenc = $row['sipuserpassword'];
116
-            } elseif ($sipuserpassword == '') {
117
-                $sipuserpasswordenc = '';
118
-            }
119
-
120
-            $sql3 = "UPDATE `*PREFIX*sip_trip_phone` SET `pdisplayname` = '$pdisplayname', `sipusername` = '$sipusername', `sipuserpassword` = '$sipuserpasswordenc',
121
-                    `stphwssurl` = '$stphwssurl', `siprealm` = '$siprealm', `stunserver` = '$stunserver'  WHERE `user_id` = '$userId'";
122
-            $res3 = $this->connection->prepare($sql3);
123
-            $res3->execute();
124
-        }
125
-    }
126
-}
Browse code

Created repository.

DoubleBastionAdmin authored on 02/03/2022 00:26:46
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,126 @@
1
+<?php
2
+/**
3
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
+ *
5
+ * @author Double Bastion LLC
6
+ *
7
+ * @license GNU AGPL version 3 or any later version
8
+ *
9
+ * This program is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
+ * License as published by the Free Software Foundation; either
12
+ * version 3 of the License, or any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
+ *
19
+ * You should have received a copy of the GNU Affero General Public
20
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+declare(strict_types=1);
25
+
26
+namespace OCA\SIPTripPhone\Service;
27
+
28
+use OCP\DB\QueryBuilder\IQueryBuilder;
29
+use OCP\IDBConnection;
30
+use OCP\Security\ICrypto;
31
+
32
+
33
+class SphoneService {
34
+
35
+    private $connection;
36
+    private $crypto;
37
+
38
+    public function __construct(IDBConnection $connection, ICrypto $crypto) {
39
+                $this->connection = $connection;
40
+                $this->crypto = $crypto;
41
+    }
42
+
43
+    /**
44
+     * @NoAdminRequired
45
+     *
46
+     */
47
+    public function getsettings($userId) {
48
+
49
+        $sql0 = "SELECT * FROM `*PREFIX*sip_trip_phone` WHERE `user_id` = '$userId'";
50
+
51
+        $res0 = $this->connection->prepare($sql0);
52
+        $res0->execute();
53
+
54
+        $settingsdb = $res0->fetch();
55
+
56
+        if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
57
+            $settingsdb['sipuserpassword'] = "%20%20%20%20%20%20%20";
58
+        } else { $settingsdb['sipuserpassword'] = ''; }
59
+
60
+        $res0->closeCursor();
61
+
62
+        return $settingsdb;
63
+    }
64
+
65
+    /**
66
+     * @NoAdminRequired
67
+     *
68
+     */
69
+    public function getsippass($userId) {
70
+
71
+        $sql0 = "SELECT `id`, `user_id`, `sipuserpassword` FROM `*PREFIX*sip_trip_phone` WHERE `user_id` = '$userId'";
72
+
73
+        $res0 = $this->connection->prepare($sql0);
74
+        $res0->execute();
75
+
76
+        $settingsdb = $res0->fetch();
77
+        if ($settingsdb['sipuserpassword'] != '' && $settingsdb['sipuserpassword'] != null && $settingsdb['sipuserpassword'] != 'undefined') {
78
+            $sipuserpassworddecr = $this->crypto->decrypt($settingsdb['sipuserpassword'], $password = '');
79
+            $sippassword = $sipuserpassworddecr;
80
+        }
81
+        $res0->closeCursor();
82
+
83
+        return $sippassword;
84
+    }
85
+
86
+    /**
87
+     * @NoAdminRequired
88
+     *
89
+     */
90
+    public function updatesettings($userId, $pdisplayname, $sipusername, $sipuserpassword, $stphwssurl, $siprealm, $stunserver) {
91
+
92
+        $sql1 = "SELECT * FROM `*PREFIX*sip_trip_phone` WHERE `user_id` = '$userId'";
93
+        $res1 = $this->connection->prepare($sql1);
94
+        $res1->execute();
95
+
96
+        $row = $res1->fetch();
97
+        $res1->closeCursor();
98
+
99
+        if ($row['user_id'] == '' || $row['user_id'] == 'undefined' || $row['user_id'] == null) {
100
+
101
+            if ($sipuserpassword != '') {
102
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword, $password = '');                
103
+            } else { $sipuserpasswordenc = ''; }
104
+
105
+            $sql2 = "INSERT INTO `*PREFIX*sip_trip_phone` (`user_id`, `pdisplayname`, `sipusername`, `sipuserpassword`, `stphwssurl`, `siprealm`, `stunserver`)
106
+                     VALUES ('$userId', '$pdisplayname', '$sipusername', '$sipuserpasswordenc', '$stphwssurl', '$siprealm', '$stunserver')";
107
+            $res2 = $this->connection->prepare($sql2);
108
+            $res2->execute();
109
+
110
+        } else {
111
+
112
+            if ($sipuserpassword != '' && $sipuserpassword != "%20%20%20%20%20%20%20") {
113
+                $sipuserpasswordenc = $this->crypto->encrypt($sipuserpassword, $password = '');                
114
+            } elseif ($sipuserpassword == "%20%20%20%20%20%20%20") {
115
+                $sipuserpasswordenc = $row['sipuserpassword'];
116
+            } elseif ($sipuserpassword == '') {
117
+                $sipuserpasswordenc = '';
118
+            }
119
+
120
+            $sql3 = "UPDATE `*PREFIX*sip_trip_phone` SET `pdisplayname` = '$pdisplayname', `sipusername` = '$sipusername', `sipuserpassword` = '$sipuserpasswordenc',
121
+                    `stphwssurl` = '$stphwssurl', `siprealm` = '$siprealm', `stunserver` = '$stunserver'  WHERE `user_id` = '$userId'";
122
+            $res3 = $this->connection->prepare($sql3);
123
+            $res3->execute();
124
+        }
125
+    }
126
+}