-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
173 lines (142 loc) · 6.3 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <[email protected]>
Portions created by the Initial Developer are Copyright (C) 2008-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <[email protected]>
KonradSC <[email protected]>
*/
if (strpos($_SERVER['REQUEST_URI'],'.appinstaller') !== false) {
require_once "appinstaller.php";
exit;
}
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/functions/functions.php";
//check permissions
if (permission_exists('sessiontalk_view') or permission_exists('sessiontalk_view_all')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//verify the id is a uuid then set as a variable
if (is_uuid($_GET['id'])) {
$extension_uuid = $_GET['id'];
}
//get the extension(s)
if (permission_exists('sessiontalk_view_all')) {
//admin user
$sql = "SELECT e.extension_uuid, e.extension, e.description, e.number_alias ";
$sql .= "FROM v_extensions AS e ";
$sql .= "WHERE e.domain_uuid = :domain_uuid ";
$sql .= "AND e.enabled = 'true' ";
$sql .= "order by e.extension asc ";
}
else {
//normal user
$sql = "SELECT e.extension_uuid, e.extension, e.description, e.number_alias ";
$sql .= "FROM v_extensions AS e, v_extension_users AS eu, v_users AS u ";
$sql .= "WHERE e.domain_uuid = :domain_uuid ";
$sql .= "AND eu.user_uuid = :user_uuid ";
$sql .= "AND e.extension_uuid = eu.extension_uuid ";
$sql .= "AND eu.user_uuid = u.user_uuid ";
$sql .= "order by e.extension asc ";
$parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
}
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$extensions = $database->select($sql, $parameters, 'all');
//echo $sql;
//exit;
unset($sql, $parameters);
if (is_uuid($extension_uuid) && is_array($extensions) && @sizeof($extensions) != 0) {
//loop through get selected extension
if (is_array($extensions) && @sizeof($extensions) != 0) {
foreach ($extensions as $extension) {
if ($extension['extension_uuid'] == $extension_uuid) {
$field = $extension;
break;
}
}
}
$app_details = new sessiontalk;
$app_details->settings = $_SESSION['sessiontalk'];
$app_details->set_extension($field, $_SESSION['domain_uuid'], $_SESSION['domain_name']);
$credentials = $app_details->get_credentials();
}
//debian
//apt install qrencode
//include the header
$document['title'] = $text['title-sessiontalk'];
require_once "resources/header.php";
//show the content
echo "<form name='frm' id='frm' method='get'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-sessiontalk']."</b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('default_setting_view')) {
echo button::create(['type'=>'button','label'=>$text['button-settings'],'icon'=>$_SESSION['theme']['button_icon_settings'],'name'=>'btn_settings','style'=>'margin-right: 2px;','link'=>PROJECT_PATH.'/core/default_settings/default_settings.php?default_setting_category=sessiontalk']);
}
if (permission_exists('device_view')) {
echo button::create(['type'=>'button','label'=>$text['label-devices'],'icon'=>'mobile','name'=>'btn_devices','style'=>'margin-right: 2px;','link'=>PROJECT_PATH.'/app/devices/devices.php?search=sessiontalk']);
}
if (permission_exists('ring_group_edit') && $ring_groups) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'name'=>'btn_toggle','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['title_description-sessiontalk']."\n";
echo "<br /><br />\n";
echo "<div style='text-align: center; white-space: nowrap;'>";
echo "<br /><br />\n";
//echo "QR Content:".$credentials['mobile']."<br />\n "; //enable for debugging
//Activation Link for Windows Softphone
if ($_SESSION['sessiontalk']['windows_softphone']['boolean'] && is_uuid($extension_uuid)) {
$windows_credentials = $app_details->get_credentials();
echo "<a href=\"".$windows_credentials['windows']."\"/><img src='/app/sessiontalk/resources/images/windows_10.png' alt='".$text['label-windows-softphone']."' style='width: auto; height: 30px;' /></a>";
}
echo " <a href='".$_SESSION['sessiontalk']['android_url']['text']."' target='_blank'><img src='/app/sessiontalk/resources/images/google_play.png' style='width: auto; height: 30px;' /></a>";
echo " <a href='".$_SESSION['sessiontalk']['apple_url']['text']."' target='_blank'><img src='/app/sessiontalk/resources/images/apple_app_store.png' style='width: auto; height: 30px;' /></a>";
echo "<div style='text-align: center; white-space: nowrap; margin: 10px 0 40px 0;'>";
echo $text['label-extension']."<br />\n";
echo "<select name='id' class='formfld' onchange='this.form.submit();'>\n";
echo " <option value='' >".$text['label-select']."...</option>\n";
if (is_array($extensions) && @sizeof($extensions) != 0) {
foreach ($extensions as $row) {
$selected = $row['extension_uuid'] == $extension_uuid ? "selected='selected'" : null;
echo " <option value='".escape($row['extension_uuid'])."' ".$selected.">".escape($row['extension'])." ".escape($row['number_alias'])." ".escape($row['description'])."</option>\n";
}
}
echo "</select>\n";
echo "</form>\n";
echo "<br />\n";
//html image
if (is_uuid($extension_uuid)) {
echo "<img src=\"data:image/jpeg;base64,".base64_encode($credentials['qr_image'])."\" style='margin-top: 30px; padding: 5px; background: white; max-width: 100%;'/>\n";
}
echo "</div>\n";
echo "</div>\n";
//add the footer
require_once "resources/footer.php";
?>