-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathdtmf.php
executable file
·367 lines (298 loc) · 14.6 KB
/
dtmf.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<?php
// --------------------------------------------------------
// SESSION CHECK TO SEE IF USER IS LOGGED IN.
session_start();
if ((!isset($_SESSION['username'])) || (!isset($_SESSION['userID']))){
header('location: index.php'); // If they aren't logged in, send them to login page.
} elseif (!isset($_SESSION['callsign'])) {
header('location: wizard/index.php'); // If they are logged in, but they haven't set a callsign then send them to setup wizard.
} else { // If they are logged in and have set a callsign, show the page.
// --------------------------------------------------------
function dtmf($inputString) {
$characters = str_split($inputString);
$html_code = '<ul class="dtmf-interface js-dtmf-interface">';
foreach($characters as $currChar) {
if($currChar=='*') {
$html_code .= '<li class="star">' . $currChar . '</li>';
} else if($currChar=='+' || $currChar=='&') {
$html_code .= '<li class="non-btn">' . $currChar . '</li>';
} else {
$html_code .= '<li>' . $currChar . '</li>';
}
}
$html_code .= '</ul>';
return $html_code;
}
?>
<?php
$customJS = 'page-dtmf.js'; // 'file1.js, file2.js, ... '
$customCSS = 'page-dtmf.css'; // 'file1.css, file2.css, ... '
include('includes/header.php');
$portList = $Database->get_ports();
$macroList = $Database->get_macros();
$ModulesClass = new Modules();
$moduleList = $ModulesClass->getModulesJSON();
?>
<?php
$portOpitonList = '';
$base_path = '/usr/share/svxlink/orp_pty/';
foreach ($portList as $key => $val) {
if ($val['portEnabled'] == 1) {
switch ($val['portDuplex']) {
case 'full':
$curOptionVal = $base_path . 'ORP_FullDuplexLogic_Port' . $val['portNum'] . '/dtmf_ctrl';
break;
case 'half':
$curOptionVal = $base_path . 'ORP_HalfDuplexLogic_Port' . $val['portNum'] . '/dtmf_ctrl';
break;
}
$curOptionName = 'PORT ' . $val['portNum'] . ': ' . $val['portLabel'];
$portOpitonList .= '<option value="' . $curOptionVal . '">' . $curOptionName . '</option>';
}
}
?>
<!-- page content -->
<div class="right_col" role="main">
<div class="">
<div class="page-title">
<div class="title_full">
<h3><i class="fa fa-tty"></i> <?=_('DTMF Reference')?></h3>
</div>
</div>
<div class="clearfix"></div>
<div class="alert alert-warning">
<h4><i class="fa fa-warning"></i> Warning!</h4> This page is still in early development. So, there may be things that don't function as one might expect.
</div>
<?= '<pre>' . $portOpitonList . '</pre>'?>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h4 class="navbar-left"><?=_('Commands')?></h4>
<div class="nav navbar-right">
<button type="button" id="dialPadBtn" class="btn btn-success"><i class="fa fa-th"></i> <?=_('Dial Pad')?></button>
<button type="button" class="btn btn-success" onclick="window.print();return false;"><i class="fa fa-print"></i> <?=_('Print')?></button>
</div>
<div class="clearfix"></div>
</div>
<div class="x_content">
<!-- start accordion -->
<div class="accordion" id="accordion" role="tablist" aria-multiselectable="false">
<? ################################################################################ ?>
<? # FORCE ID SECTION ?>
<div class="panel">
<a class="panel-heading" role="tab" data-parent="#accordion" href="#collapse1" aria-expanded="false" aria-controls="collapse1">
<div class="col-md-12 col-sm-12 col-xs-12">
<h4 class="panel-title dtmf-title"><?php echo dtmf('*'); ?><?=_('Force ID')?></h4>
</div>
<div class="clearfix"></div>
</a>
</div>
<? ################################################################################ ?>
<? # REMOTE DTMF DISABLE SECTION ?>
<?php $tempDisableCode = '1234'; ?>
<?php if(isset($tempDisableCode)) { ?>
<div class="panel">
<a class="panel-heading collapsed" role="tab" id="heading2" data-toggle="collapse" data-parent="#accordion" href="#collapse2" aria-expanded="false" aria-controls="collapse2">
<div class="col-md-10 col-sm-10 col-xs-10">
<h4 class="panel-title dtmf-title"><?=_('Remote DMTF Disable')?></h4>
</div>
<div class="col-md-2 col-sm-2 col-xs-2 right">
<span class="right">
</span>
</div>
<div class="clearfix"></div>
</a>
<div id="collapse2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading2">
<div class="panel-body">
<p><?=_('You have chosen to enable the ability to remotely disable the transmitter via DTMF commands. This is useful for control operators to stop system abuse or to simply make the system inactive. Note that the pin code that you selected is part of the full codes below.')?></p>
<div class="spacer height20"></div>
<?php
$cur_mod_html = '';
$cur_mod_html .= '<div class="col-lg-4 col-md-5 col-sm-6 col-xs-12 col-print-5">' . dtmf( $tempDisableCode . '+0#' ) . '</div>';
$cur_mod_html .= '<div class="col-lg-8 col-md-7 col-sm-6 col-xs-12 col-print-7"><p><span style="color:red;">' . _('Disable Transmitter ') . '</span></p></div>';
$cur_mod_html .= '<div class="clearfix"></div>';
$cur_mod_html .= '<div class="col-lg-4 col-md-5 col-sm-6 col-xs-12 col-print-5">' . dtmf( $tempDisableCode . '+1#' ) . '</div>';
$cur_mod_html .= '<div class="col-lg-8 col-md-7 col-sm-6 col-xs-12 col-print-7"><p><span style="color:green;">' . _('Enable Transmitter') . '</span></p></div>';
$cur_mod_html .= '<div class="clearfix"></div>';
echo $cur_mod_html;
?>
<div class="spacer height20"></div>
<p><?=_('NOTE: If a module is running while you wish to disable the transmitter, you must first disable the module OR force the disable command by prefixing with a star (*). So, the disable command would become:')?> <strong>* + <?=$tempDisableCode?> + 0#</strong></p>
<div class="spacer height20"></div>
</div>
</div>
</div>
<?php } ?>
<? ################################################################################ ?>
<? # MACROS SECTION ?>
<?php if(isset($macroList)) { ?>
<div class="panel">
<a class="panel-heading collapsed" role="tab" id="heading2" data-toggle="collapse" data-parent="#accordion" href="#dtmf_macros" aria-expanded="false" aria-controls="dtmf_macros">
<div class="col-md-10 col-sm-10 col-xs-10">
<h4 class="panel-title dtmf-title">Macros</h4>
</div>
<div class="col-md-2 col-sm-2 col-xs-2 right">
<span class="right">
</span>
</div>
<div class="clearfix"></div>
</a>
<div id="dtmf_macros" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading2">
<div class="panel-body">
<?php
$cur_mod_html = '';
foreach($macroList as $cur_macro) {
if ($cur_macro['macroEnabled'] == '1') {
$cur_mod_html .= '<div class="col-lg-4 col-md-5 col-sm-6 col-xs-12 col-print-5">' . dtmf( 'D' . $cur_macro['macroNum'] . '#' ) . '</div>';
$cur_mod_html .= '<div class="col-lg-8 col-md-7 col-sm-6 col-xs-12 col-print-7"><p>' . $cur_macro['macroLabel'] . '</p></div>';
$cur_mod_html .= '<div class="clearfix"></div>';
}
}
$cur_mod_html .= '<div class="spacer height20"></div>';
echo $cur_mod_html;
?>
</div>
</div>
</div>
<?php } ?>
<?php
echo '<pre>';
print_r($macroList);
echo '</pre>';
?>
<?php
echo '<pre>';
print_r($portList);
echo '</pre>';
?>
<? ################################################################################ ?>
<? # HELP MODULE SECTION ?>
<?php
# HELP MODULE
if($fakeModules['1']['moduleEnabled'] == '1') {
$help_mod_html = '
<div class="panel">
<a class="panel-heading collapsed" role="tab" id="Help" data-toggle="collapse" data-parent="#accordion" href="#collapse-Help" aria-expanded="false" aria-controls="collapse-Help">
<div class="col-md-10 col-sm-10 col-xs-10">
<h4 class="panel-title dtmf-title">' . dtmf('0#') . ' ' . _('Help Module') .'</h4>
</div>
<div class="col-md-2 col-sm-2 col-xs-2 right">
<span class="right">
</span>
</div>
<div class="clearfix"></div>
</a>
<div id="collapse-Help" class="panel-collapse collapse" role="tabpanel" aria-labelledby="Help">
<div class="panel-body">';
$help_mod_html .= '
<div class="col-md-12 col-sm-12 col-xs-12">
<p>Pressing 0# will enable the Help module.</p>
</div>';
$help_mod_html .= '
<div class="col-md-12 col-sm-12 col-xs-12">
<h4>Sub Commands:</h4>
</div>';
$help_mod_html .= '<div class="col-lg-4 col-md-5 col-sm-6 col-xs-12 col-print-5">' . dtmf('0#') . '</div>';
$help_mod_html .= '<div class="col-lg-8 col-md-7 col-sm-6 col-xs-12 col-print-7"><p>' . _('Overview of the Help Module') . '</p></div>';
$help_mod_html .= '<div class="clearfix"></div>';
$help_mod_html .= '<div class="spacer height10 visible-xs-block"></div>';
foreach($fakeModules as $cur_mod) {
if ( $cur_mod['moduleEnabled'] == '1' && $cur_mod['svxlinkID'] > 0 ) {
$help_mod_html .= '<div class="col-lg-4 col-md-5 col-sm-6 col-xs-12 col-print-5">' . dtmf($cur_mod['svxlinkID'] . '#') . '</div>';
$help_mod_html .= '<div class="col-lg-8 col-md-7 col-sm-6 col-xs-12 col-print-7"><p>' . _('Help on') . ' ' . $cur_mod['displayName'] . ' ' . _('Module') . '</p></div>';
$help_mod_html .= '<div class="clearfix"></div>';
$help_mod_html .= '<div class="spacer height10 visible-xs-block"></div>';
}
}
$help_mod_html .= '<div class="col-lg-4 col-md-5 col-sm-6 col-xs-12 col-print-5">' . dtmf('#') . '</div>';
$help_mod_html .= '<div class="col-lg-8 col-md-7 col-sm-6 col-xs-12 col-print-7"><p>' . _('Exit Help') . '</p></div>';
$help_mod_html .= '<div class="clearfix"></div>';
$help_mod_html .= '<div class="spacer height10 visible-xs-block"></div>';
$help_mod_html .= '<div class="spacer height20"></div>';
$help_mod_html .= '
</div>
</div>
</div>';
echo $help_mod_html;
}
?>
<? ################################################################################ ?>
<? # LOOP THROUGH MODULE SECTIONS ?>
<?php
$moduleList = json_decode($moduleList, true);
foreach($moduleList as $cur_mod) {
if($cur_mod['moduleEnabled'] == '1' && $cur_mod['svxlinkID'] > 0 && $cur_mod['dtmf'] == true) {
$cur_mod_html = '
<div class="panel">
<a class="panel-heading collapsed" role="tab" id="' . $cur_mod['svxlinkName'] . '" data-toggle="collapse" data-parent="#accordion" href="#collapse-' . $cur_mod['svxlinkName'] . '" aria-expanded="false" aria-controls="collapse-' . $cur_mod['svxlinkName'] . '">
<div class="col-md-10 col-sm-10 col-xs-10">
<h4 class="panel-title dtmf-title">' . dtmf($cur_mod['svxlinkID'] . '#') . $cur_mod['displayName'] . ' ' . _('Module') .'</h4>
</div>
<div class="col-md-2 col-sm-2 col-xs-2 right">
<span class="right">
</span>
</div>
<div class="clearfix"></div>
</a>
<div id="collapse-' . $cur_mod['svxlinkName'] . '" class="panel-collapse collapse" role="tabpanel" aria-labelledby="' . $cur_mod['svxlinkName'] . '">
<div class="panel-body">';
$cur_mod_html .= '
<div class="col-md-12 col-sm-12 col-xs-12">
<p>Pressing ' . $cur_mod['svxlinkID'] . '# will enable the ' . $cur_mod['displayName'] . ' module.</p>
</div>';
if (isset($cur_mod['tempSubCommands'])) {
$cur_mod_html .= '
<div class="col-md-12 col-sm-12 col-xs-12">
<h4>Sub Commands:</h4>
</div>';
foreach($cur_mod['tempSubCommands'] as $cur_sub_cmd => $cur_sub_cmd_desc) {
if (substr($cur_sub_cmd, 0, 7) == 'divider') {
$cur_mod_html .= '<div class="col-md-12 col-sm-12 col-xs-12"><hr></div>';
} else if (substr($cur_sub_cmd, 0, 7) == 'heading') {
$cur_mod_html .= '<div class="col-md-12 col-sm-12 col-xs-12"><h5>' . $cur_sub_cmd_desc . '</h5></div>';
} else {
$cur_mod_html .= '<div class="col-lg-4 col-md-5 col-sm-6 col-xs-12 col-print-5">' . dtmf($cur_sub_cmd) . '</div>';
$cur_mod_html .= '<div class="col-lg-8 col-md-7 col-sm-6 col-xs-12 col-print-7"><p>' . $cur_sub_cmd_desc . '</p></div>';
}
$cur_mod_html .= '<div class="clearfix"></div>';
$cur_mod_html .= '<div class="spacer height10 visible-xs-block"></div>';
}
$cur_mod_html .= '<div class="spacer height20"></div>';
}
$cur_mod_html .= '
</div>
</div>
</div>';
echo $cur_mod_html;
}
}
?>
<?php
/*
echo '<pre>';
print_r($moduleList);
echo '</pre>';
*/
?>
<? ################################################################################ ?>
</div>
<!-- end of accordion -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->
<script>
var portOpitonList = '<?= $portOpitonList ?>';
console.log(portOpitonList);
</script>
<?php include('includes/footer.php'); ?>
<?php
// --------------------------------------------------------
// SESSION CHECK TO SEE IF USER IS LOGGED IN.
} // close ELSE to end login check from top of page
// --------------------------------------------------------
?>