-
Notifications
You must be signed in to change notification settings - Fork 19
/
Sccp_manager.class.php
2380 lines (2209 loc) · 98.3 KB
/
Sccp_manager.class.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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
//namespace FreePBX\modules;
// License for all code of this FreePBX module can be found in the license file inside the module directory
// Copyright 2015 Sangoma Technologies.
// https://github.com/chan-sccp/chan-sccp/wiki/Setup-FreePBX
// http://chan-sccp-b.sourceforge.net/doc/setup_sccp.xhtml
// https://github.com/chan-sccp/chan-sccp/wiki/Conferencing
// https://github.com/chan-sccp/chan-sccp/wiki/Frequently-Asked-Questions
// http://chan-sccp-b.sourceforge.net/doc/_howto.xhtml#nf_adhoc_plar
// https://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cuipph/all_models/xsi/9-1-1/CUIP_BK_P82B3B16_00_phones-services-application-development-notes/CUIP_BK_P82B3B16_00_phones-services-application-development-notes_chapter_011.html
// https://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cuipph/7960g_7940g/sip/4_4/english/administration/guide/ver4_4/sipins44.html
// http://usecallmanager.nz/
/* !TODO!:
* + Cisco Format Mac
* + Model Information
* + Device Right Menu
* - Dial Templates are not really needed for skinny, skinny get's direct feed back from asterisk per digit -->
* - If your dialplan is finite (completely fixed length (depends on your country dialplan) dialplan, then dial templates are not required) -->
* - As far as i know FreePBX does also attempt to build a finite dialplan -->
* - Having to maintain both an asterisk dialplan and these skinny dial templates is annoying -->
* + Dial Templates + Configuration
* + Dial Templates in Global Configuration ( Enabled / Disabled ; default template )
* ? Dial Templates - Howto IT Include in XML.Config ???????
* + Dial Templates - SIP Device
* - Dial Templates in device Configuration ( Enabled / inheret / Disabled ; template )
* - WiFi Config (Bulk Deployment Utility for Cisco 7921, 7925, 7926)?????
* + Change internal use Field to _Field (new feature in chan_sccp (added for Sccp_manager))
* + Delete phone XML
* + Change Installer ?? (test )
* + Installer Realtime config update
* + Installer Adaptive DB reconfig.
* + Add system info page
* + Change Cisco Language data
* + Make DB Acces from separate class
* + Make System Acces from separate class
* + Make Var elements from separate class
* + To make creating XML files in a separate class
* + Add Switch to select XML schema (display)
* + SRST Config
* + secondary_dialtone_digits = "" line config
* + secondary_dialtone_tone = 0x22 line config
* - deviceSecurityMode http://usecallmanager.nz//itl-file-tlv.html
* - transportLayerProtocol http://usecallmanager.nz//itl-file-tlv.html
* - Check Time zone ....
* - Failover config
* + Auto Addons!
* + DND Mode
* - support kv-store ?????
* + Shared Line
* - bug Soft key set (empty keysets )
* - bug Fix ...(K no w bug? no fix)
* - restore default Value on page
* - restore default Value on sccp.class
* - 'Device SEP ID.[XXXXXXXXXXXX]=MAC'
* + ATA's start with ATAXXXXXXXXXXXX.
* + Create ATADefault.cnf.xml
* - Create Second line Use MAC AABBCCDDEEFF rotation MAC BBCCDDEEFF01 (ATA 187 )
* + Add SEP, ATA, VG prefix.
* + Add Cisco SIP device Tftp config.
* - VG248 ports start with VGXXXXXXXXXXXX0.
* * I think this file should be split in 3 parts (as in Model-View-Controller(MVC))
* * XML/Database Parts -> Model directory
* * Processing parts -> Controller directory
* * Ajax Handler Parts -> Controller directory
* * Result parts -> View directory
* + Support TFTP rewrite :
* + dir "settings"
* + dir "templates"
* + dir "firmware"
* + dir "locales"
* + Create Simple User Interface
* + sccpsimple.xml
* + Add error information on the server information page (critical display error - the system can not work correctly)
* - Add Warning Information on Server Info Page
* - ADD Reload Line
* - Add Call Map (show Current call Information)
* ---TODO ---
* <vendorConfig>
* <autoSelectLineEnable>0</autoSelectLineEnable>
* <autoCallSelect>0</autoCallSelect>
* </vendorConfig>
*/
namespace FreePBX\modules;
class Sccp_manager extends \FreePBX_Helpers implements \BMO {
/* Field Values for type seq */
// const General - sccp.conf = '0';
// const General - sccp.conf[general] = '0';
// const General - sccp.conf[%keyset%] = '5'; NAME space
// const General - sccp.conf[%keyset%] = '6'; data
// const General - default.xml = '10';
// const General - template.xml = '20';
// const General - system_path = '2';
// const General - don't store = '99';
// private $SCCP_LANG_DICTIONARY = 'SCCP-dictionary.xml'; // CISCO LANG file search in /tftp-path
private $SCCP_LANG_DICTIONARY = 'be-sccp.jar'; // CISCO LANG file search in /tftp-path
private $pagedata = null;
private $sccp_driver_ver = '11.4'; // Ver fore SCCP.CLASS.PHP
public $sccp_manager_ver = '14.0.0.2';
public $sccp_branch = 'm'; // Ver fore SCCP.CLASS.PHP
private $tftpLang = array();
// private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!!
private $hint_context = array('default' => '@ext-local'); /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!!
private $val_null = 'NONE'; /// REPLACE to null Field
public $sccp_model_list = array();
public $sccp_metainfo = array();
private $cnf_wr = null;
public $sccppath = array();
public $sccpvalues = array();
public $sccp_conf_init = array();
public $xml_data;
public $class_error; //error construct
public $info_warning;
public function __construct($freepbx = null) {
if ($freepbx == null) {
throw new Exception("Not given a FreePBX Object");
}
$this->class_error = array();
$this->FreePBX = $freepbx;
$this->db = $freepbx->Database;
$this->cnf_wr = \FreePBX::WriteConfig();
$this->cnf_read = \FreePBX::LoadConfig();
// $this->v = new \Respect\Validation\Validator();
$driverNamespace = "\\FreePBX\\Modules\\Sccp_manager";
if (class_exists($driverNamespace, false)) {
foreach (glob(__DIR__ . "/Sccp_manager.inc/*.class.php") as $driver) {
if (preg_match("/\/([a-z1-9]*)\.class\.php$/i", $driver, $matches)) {
$name = $matches[1];
$class = $driverNamespace . "\\" . $name;
if (!class_exists($class, false)) {
include($driver);
}
if (class_exists($class, false)) {
$this->$name = new $class($this);
} else {
throw new \Exception("Invalid Class inside in the include folder" . print_r($freepbx));
}
}
}
} else {
return;
}
$this->getSccpSettingFromDB(); // Overwrite Exist
// $this->getSccpSetingINI(false); // get from sccep.ini
$this->initializeSccpPath();
$this->initVarfromDefs();
$this->initTftpLang();
if (!empty($this->sccpvalues['SccpDBmodel'])) {
if ($this->sccpvalues['sccp_compatible']['data'] > $this->sccpvalues['SccpDBmodel']['data']) {
$this->sccpvalues['sccp_compatible']['data'] = $this->sccpvalues['SccpDBmodel']['data'];
}
}
// Load Advanced Form Constructor Data
if (empty($this->sccpvalues['displayconfig'])) {
$xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v' . $this->sccpvalues['sccp_compatible']['data'];
} else {
$xml_vars = __DIR__ . '/conf/' . $this->sccpvalues['displayconfig']['data'] . '.xml.v' . $this->sccpvalues['sccp_compatible']['data'];
}
if (!file_exists($xml_vars)) {
$xml_vars = __DIR__ . '/conf/sccpgeneral.xml';
}
if (file_exists($xml_vars)) {
$this->xml_data = simplexml_load_file($xml_vars);
$this->initVarfromXml(); // Overwrite Exist
}
}
/*
* Generate Input elements in Html Code from sccpgeneral.xml
*/
public function showGroup($grup_name, $heder_show, $form_prefix = 'sccp', $form_values = null) {
$htmlret = "";
if (empty($form_values)) {
$form_values = $this->sccpvalues;
}
if ((array) $this->xml_data) {
foreach ($this->xml_data->xpath('//page_group[@name="' . $grup_name . '"]') as $item) {
$htmlret .= load_view(__DIR__ . '/views/formShow.php', array(
'itm' => $item, 'h_show' => $heder_show,
'form_prefix' => $form_prefix, 'fvalues' => $form_values,
'tftp_lang' => $this->getTftpLang(), 'metainfo' => $this->sccp_metainfo));
}
} else {
$htmlret .= load_view(__DIR__ . '/views/formShowError.php');
}
return $htmlret;
}
/*
* Load config vars from base array
*/
public function initVarfromDefs() {
foreach ($this->extconfigs->getextConfig('sccpDefaults') as $key => $value) {
if (empty($this->sccpvalues[$key])) {
$this->sccpvalues[$key] = array('keyword' => $key, 'data' => $value, 'type' => '0', 'seq' => '0');
}
}
}
/*
* Load config vars from xml
*/
public function initVarfromXml() {
if ((array) $this->xml_data) {
foreach ($this->xml_data->xpath('//page_group') as $item) {
foreach ($item->children() as $child) {
$seq = 0;
if (!empty($child['seq'])) {
$seq = (string) $child['seq'];
}
if ($seq < 99) {
if ($child['type'] == 'IE') {
foreach ($child->xpath('input') as $value) {
$tp = 0;
if (empty($value->value)) {
$datav = (string) $value->default;
} else {
$datav = (string) $value->value;
}
if (strtolower($value->type) == 'number') {
$tp = 1;
}
if (empty($this->sccpvalues[(string) $value->name])) {
$this->sccpvalues[(string) $value->name] = array('keyword' => (string) $value->name, 'data' => $datav, 'type' => $tp, 'seq' => $seq);
}
}
}
if ($child['type'] == 'IS' || $child['type'] == 'IED') {
if (empty($child->value)) {
$datav = (string) $child->default;
} else {
$datav = (string) $child->value;
}
if (empty($this->sccpvalues[(string) $child->name])) {
$this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq);
}
}
if (in_array($child['type'], array('SLD', 'SLS', 'SLT', 'SL', 'SLM', 'SLZ', 'SLTZN', 'SLA'))) {
if (empty($child->value)) {
$datav = (string) $child->default;
} else {
$datav = (string) $child->value;
}
if (empty($this->sccpvalues[(string) $child->name])) {
$this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq);
}
}
}
}
}
}
}
/* unused but FPBX API requires it */
public function doConfigPageInit($page) {
$this->doGeneralPost();
}
/* unused but FPBX API requires it */
public function install() {
}
/* unused but FPBX API requires it */
public function uninstall() {
}
/* unused but FPBX API requires it */
public function backup() {
}
/* unused but FPBX API requires it */
public function restore($backup) {
}
public function getActionBar($request) {
$buttons = array();
switch ($request['display']) {
case 'sccp_adv':
if (empty($request['tech_hardware'])) {
break;
}
$buttons = array(
'submit' => array(
'name' => 'ajaxsubmit',
'id' => 'ajaxsubmit',
'value' => _("Save")
),
'Save' => array(
'name' => 'ajaxsubmit2',
'id' => 'ajaxsubmit2',
'stayonpage' => 'yes',
'value' => _("Save + Continue")
),
'cancel' => array(
'name' => 'cancel',
'id' => 'ajaxcancel',
'data-search' => '?display=sccp_adv',
'data-hash' => 'sccpdialplan',
'value' => _("Cancel")
),
);
break;
case 'sccp_phone':
if (empty($request['tech_hardware'])) {
break;
}
$buttons = array(
'submit' => array(
'name' => 'ajaxsubmit',
'id' => 'ajaxsubmit',
'value' => _("Save")
),
'Save' => array(
'name' => 'ajaxsubmit2',
'id' => 'ajaxsubmit2',
'stayonpage' => 'yes',
'value' => _("Save + Continue")
),
'cancel' => array(
'name' => 'cancel',
'id' => 'ajaxcancel',
'data-search' => '?display=sccp_phone',
'data-hash' => 'sccpdevice',
'value' => _("Cancel")
),
);
break;
case 'sccpsettings':
$buttons = array(
'submit' => array(
'name' => 'ajaxsubmit',
'id' => 'ajaxsubmit',
'value' => _("Submit")
),
'reset' => array(
'name' => 'reset',
'id' => 'ajaxcancel',
'data-reload' => 'reload',
'value' => _("Reset")
),
);
break;
}
return $buttons;
}
/*
* Show form information - General
*/
public function myShowPage() {
$request = $_REQUEST;
$action = !empty($request['action']) ? $request['action'] : '';
/*
if ($this->sccpvalues['sccp_compatible']['data'] >= '433') {
$this->sccp_metainfo = $this->srvinterface->getGlobalsFromMetaData('general');
}
*/
if (!empty($this->sccpvalues['displayconfig'])) {
if (!empty($this->sccpvalues['displayconfig']['data']) && ($this->sccpvalues['displayconfig']['data'] == 'sccpsimple')) {
$this->pagedata = array(
"general" => array(
"name" => _("General SCCP Settings"),
"page" => 'views/server.setting.php'
),
"sccpdevice" => array(
"name" => _("SCCP Device"),
"page" => 'views/server.device.php'
),
"sccpurl" => array(
"name" => _("SCCP Device URL"),
"page" => 'views/server.url.php'
),
"sccpinfo" => array(
"name" => _("SCCP info"),
"page" => 'views/server.info.php'
),
);
}
}
if (empty($this->pagedata)) {
//$driver = $this->FreePBX->Config->get_conf_setting('ASTSIPDRIVER');
$this->pagedata = array(
"general" => array(
"name" => _("General SCCP Settings"),
"page" => 'views/server.setting.php'
),
"sccpdevice" => array(
"name" => _("SCCP Device"),
"page" => 'views/server.device.php'
),
"sccpurl" => array(
"name" => _("SCCP Device URL"),
"page" => 'views/server.url.php'
),
"sccpntp" => array(
"name" => _("SCCP Time"),
"page" => 'views/server.datetime.php'
),
"sccpcodec" => array(
"name" => _("SCCP Codec"),
"page" => 'views/server.codec.php'
),
"sccpadv" => array(
"name" => _("Advanced SCCP Settings"),
"page" => 'views/server.advanced.php'
),
"sccpinfo" => array(
"name" => _("SCCP info"),
"page" => 'views/server.info.php'
),
);
}
if (!empty($this->pagedata)) {
foreach ($this->pagedata as &$page) {
ob_start();
include($page['page']);
$page['content'] = ob_get_contents();
ob_end_clean();
}
}
return $this->pagedata;
}
public function infoServerShowPage() {
$request = $_REQUEST;
$action = !empty($request['action']) ? $request['action'] : '';
$this->pagedata = array(
"general" => array(
"name" => _("General SCCP Settings"),
"page" => 'views/server.info.php'
),
);
foreach ($this->pagedata as &$page) {
ob_start();
include($page['page']);
$page['content'] = ob_get_contents();
ob_end_clean();
}
return $this->pagedata;
}
public function advServerShowPage() {
$request = $_REQUEST;
$action = !empty($request['action']) ? $request['action'] : '';
$inputform = !empty($request['tech_hardware']) ? $request['tech_hardware'] : '';
if (empty($this->pagedata)) {
switch ($inputform) {
case 'dialplan':
$this->pagedata = array(
"general" => array(
"name" => _("SCCP Dial Plan information"),
"page" => 'views/form.dptemplate.php'
)
);
break;
default:
$this->pagedata = array(
"general" => array(
"name" => _("SCCP Model information"),
"page" => 'views/advserver.model.php'
),
"sccpkeyset" => array(
"name" => _("SCCP Device Keyset"),
"page" => 'views/advserver.keyset.php'
)
);
if ($this->sccpvalues['siptftp']['data'] == 'on') {
$this->pagedata["sccpdialplan"] = array(
"name" => _("SIP Dial Plan information"),
"page" => 'views/advserver.dialtemplate.php'
);
}
break;
}
foreach ($this->pagedata as &$page) {
ob_start();
include($page['page']);
$page['content'] = ob_get_contents();
ob_end_clean();
}
}
return $this->pagedata;
}
public function phoneShowPage() {
$request = $_REQUEST;
$action = !empty($request['action']) ? $request['action'] : '';
$inputform = !empty($request['tech_hardware']) ? $request['tech_hardware'] : '';
/*
if ($this->sccpvalues['sccp_compatible']['data'] >= '433') {
$this->sccp_metainfo = $this->srvinterface->getGlobalsFromMetaData('device');
}
*/
if (empty($this->pagedata)) {
switch ($inputform) {
case "cisco":
$this->pagedata = array(
"general" => array(
"name" => _("Device configuration"),
"page" => 'views/form.adddevice.php'
),
"buttons" => array(
"name" => _("Device Buttons"),
"page" => 'views/form.buttons.php'
));
if ($this->sccpvalues['sccp_compatible']['data'] < '433') {
$this->pagedata["sccpcodec"] = array(
"name" => _("Device SCCP Codec"),
"page" => 'views/server.codec.php'
);
}
if ($this->sccpvalues['sccp_compatible']['data'] >= '433') {
$this->pagedata["advanced"] = array(
"name" => _("Device SCCP Advanced"),
"page" => 'views/form.devadvanced.php'
);
}
break;
case "cisco-sip":
$this->pagedata = array(
"general" => array(
"name" => _("Sip device configuration"),
"page" => 'views/form.addsdevice.php'
),
"buttons" => array(
"name" => _("Sip device Buttons"),
"page" => 'views/form.sbuttons.php'
));
/*
if ($this->sccpvalues['sccp_compatible']['data'] < '433') {
$this->pagedata["sccpcodec"] = array(
"name" => _("Device SCCP Codec"),
"page" => 'views/server.codec.php'
);
}
*/
break;
case "r_user":
$this->pagedata = array(
"general" => array(
"name" => _("Roaming User configuration"),
"page" => 'views/form.addruser.php'
),
"buttons" => array(
"name" => _("Device Buttons"),
"page" => 'views/form.buttons.php'
),
);
break;
default:
$this->pagedata = array(
"general" => array(
"name" => _("SCCP Extension"),
"page" => 'views/hardware.extension.php'
),
"sccpdevice" => array(
"name" => _("SCCP Phone"),
"page" => 'views/hardware.phone.php'
)
);
if ($this->sccpvalues['siptftp']['data'] == 'on') {
$this->pagedata["sipdevice"] = array(
"name" => _("SIP CISCO Phone"),
"page" => 'views/hardware.sphone.php'
);
}
break;
}
foreach ($this->pagedata as &$page) {
ob_start();
include($page['page']);
$page['content'] = ob_get_contents();
ob_end_clean();
}
}
return $this->pagedata;
}
public function formShowPage() {
$request = $_REQUEST;
$action = !empty($request['action']) ? $request['action'] : '';
if (empty($this->pagedata)) {
//$driver = $this->FreePBX->Config->get_conf_setting('ASTSIPDRIVER');
$this->pagedata = array(
"general" => array(
"name" => _("SCCP Extension"),
"page" => 'views/extension.page.php'
)
);
$this->pagedata['sccpdevice'] = array(
"name" => _("SCCP Phone"),
"page" => 'views/phone.page.php'
);
foreach ($this->pagedata as &$page) {
ob_start();
include($page['page']);
$page['content'] = ob_get_contents();
ob_end_clean();
}
}
return $this->pagedata;
}
public function getRightNav($request) {
if (isset($request['tech_hardware']) && ($request['tech_hardware'] == 'cisco')) {
return load_view(__DIR__ . "/views/hardware.rnav.php", array('request' => $request));
}
}
public function ajaxRequest($req, &$setting) {
switch ($req) {
case 'backupsettings':
case 'savesettings':
case 'save_hardware':
case 'save_sip_hardware':
case 'save_ruser':
case 'save_dialplan_template':
case 'delete_hardware':
case 'getPhoneGrid':
case 'getExtensionGrid':
case 'getDeviceModel':
case 'getUserGrid':
case 'getSoftKey':
case 'getDialTemplate':
case 'create_hw_tftp':
case 'reset_dev':
case 'reset_token':
case 'model_enabled':
case 'model_disabled':
case 'model_update':
case 'model_add':
case 'model_delete':
case 'update_button_label':
case 'updateSoftKey':
case 'deleteSoftKey':
case 'delete_dialplan':
return true;
break;
}
return false;
}
// !TODO!: this should go into it's only ajam.html.php file (see: dahdiconfig)
public function ajaxHandler() {
$request = $_REQUEST;
$msg = array();
$cmd_id = $request['command'];
switch ($cmd_id) {
case 'savesettings':
$action = isset($request['sccp_createlangdir']) ? $request['sccp_createlangdir'] : '';
if ($action == 'yes') {
$this->initializeTFtpLanguagePath();
}
$this->handleSubmit($request);
// $this->saveSccpSettings();
//$this->createDefaultSccpConfig();
$this->createDefaultSccpXml();
$res = $this->srvinterface->sccp_reload();
// $msg [] = 'Config Saved: ' . $res['Response'];
$msg [] = 'Config Saved: Sucsess ';
$msg [] = 'Info :' . $res['data'];
// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg)
return array('status' => true, 'message' => $msg, 'reload' => true);
break;
case 'save_sip_hardware':
case 'save_hardware':
$this->saveSccpDevice($request);
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'sccpdevice');
break;
case 'save_ruser':
//$res = $request;
$res = $this->handleRoamingUsers($request);
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'general');
break;
case 'save_dialplan_template':
/* !TODO!: -TODO-: dialplan templates should be removed (only required for very old devices (like ATA) */
// ------------------------------- Old + Sip device support - In the development---
$res = $this->saveDialPlan($request);
//public
if (empty($res)) {
return array('status' => true, 'search' => '?display=sccp_adv', 'hash' => 'sccpdialplan');
} else {
return array('status' => false, 'message' => print_r($res));
}
break;
case 'delete_dialplan':
if (!empty($request['dialplan'])) {
$get_file = $request['dialplan'];
$res = $this->deleteDialPlan($get_file);
return array('status' => true, 'message' => 'Dial Template has been deleted ! ', 'table_reload' => true);
} else {
return array('status' => false, 'message' => print_r($res));
}
break;
// ------------------------------- Old device support - In the development---
case 'delete_hardware':
if (!empty($request['idn'])) {
foreach ($request['idn'] as $idv) {
if ($this->strpos_array($idv, array('SEP', 'ATA', 'VG')) !== false) {
$this->dbinterface->write('sccpdevice', array('name' => $idv), 'delete', "name");
$this->dbinterface->write("sccpbuttons", array(), 'delete', '', $idv);
$this->deleteSccpDeviceXML($idv); // Концы в вводу !!
$this->srvinterface->sccpDeviceReset($idv);
}
}
return array('status' => true, 'table_reload' => true, 'message' => 'HW is Delete ! ');
}
break;
case 'create_hw_tftp':
$ver_id = ' Test !';
if (!empty($request['idn'])) {
$models = array();
foreach ($request['idn'] as $idv) {
$this->deleteSccpDeviceXML($idv);
$models [] = array('name' => $idv);
}
} else {
$this->deleteSccpDeviceXML('all');
$models = $this->dbinterface->HWextension_db_SccpTableData("SccpDevice");
}
$this->createDefaultSccpXml(); // Default XML
$ver_id = ' on found active model !';
foreach ($models as $data) {
$ver_id = $this->createSccpDeviceXML($data['name']);
if ($ver_id == -1) {
return array('status' => false, 'message' => 'Error Create Configuration Divice :' . $data['name']);
}
};
if ($this->sccpvalues['siptftp']['data'] == 'on') { // Check SIP Support Enabled
$this->createSccpXmlSoftkey(); // Create Softkey Sets for SIP
}
// !TODO!: -TODO-: Do these returned message strings work with i18n ?
return array('status' => true, 'message' => 'Create new config files (version:' . $ver_id . ')');
break;
case 'reset_token':
case 'reset_dev':
$msg = '';
$msgr = array();
$msgr[] = 'Reset command send';
if (!empty($request['name'])) {
foreach ($request['name'] as $idv) {
$msg = strpos($idv, 'SEP-');
if (!(strpos($idv, 'SEP') === false)) {
if ($cmd_id == 'reset_token') {
$res = $this->srvinterface->sccp_reset_token($idv);
$msgr[] = $msg . ' ' . $res['Response'] . ' ' . $res['data'];
} else {
$res = $this->srvinterface->sccpDeviceReset($idv);
$msgr[] = $msg . ' ' . $res['Response'] . ' ' . $res['data'];
}
}
if ($idv == 'all') {
$dev_list = $this->srvinterface->sccp_get_active_device();
foreach ($dev_list as $key => $data) {
if ($cmd_id == 'reset_token') {
if (($data['token'] == 'Rej') || ($data['status'] == 'Token ')) {
$res = $this->srvinterface->sccp_reset_token($idv);
$msgr[] = 'Send Token reset to :' . $key;
}
} else {
$res = $this->srvinterface->sccpDeviceReset($idv);
$msgr[] = $res['Response'] . ' ' . $res['data'];
}
}
}
}
}
return array('status' => true, 'message' => $msgr, 'reload' => true);
break;
case 'update_button_label':
$msg = '';
$hw_list = array();
if (!empty($request['name'])) {
foreach ($request['name'] as $idv) {
if (!(strpos($idv, 'SEP') === false)) {
$hw_list[] = array('name' => $idv);
}
if ($idv == 'all') {
}
}
}
$res = $this->updateSccpButtons($hw_list);
$msg .= $res['Response'] . ' raw: ' . $res['data'] . ' ';
return array('status' => true, 'message' => 'Update Butons Labels Complite ' . $msg, 'reload' => true);
case 'model_add':
$save_settings = array();
$key_name = array('model', 'vendor', 'dns', 'buttons', 'loadimage', 'loadinformationid', 'nametemplate');
$upd_mode = 'replace';
case 'model_update':
if ($request['command'] == 'model_update') {
$key_name = array('model', 'loadimage', 'nametemplate');
$upd_mode = 'update';
}
if (!empty($request['model'])) {
foreach ($key_name as $key => $value) {
if (!empty($request[$value])) {
$save_settings[$value] = $request[$value];
} else {
$save_settings[$value] = $this->val_null; // null
}
}
$this->dbinterface->write('sccpdevmodel', $save_settings, $upd_mode, "model");
return array('status' => true, 'table_reload' => true);
}
return $save_settings;
break;
case 'model_enabled':
$model_set = '1';
case 'model_disabled':
if ($request['command'] == 'model_disabled') {
$model_set = '0';
}
$msg = '';
$save_settings = array();
if (!empty($request['model'])) {
foreach ($request['model'] as $idv) {
$this->dbinterface->write('sccpdevmodel', array('model' => $idv, 'enabled' => $model_set), 'update', "model");
}
}
return array('status' => true, 'table_reload' => true);
break;
case 'model_delete':
if (!empty($request['model'])) {
$this->dbinterface->write('sccpdevmodel', array('model' => $request['model']), 'delete', "model");
return array('status' => true, 'table_reload' => true);
}
break;
case 'getDeviceModel':
switch ($request['type']) {
case 'all':
case 'extension':
case 'enabled':
$devices = $this->getSccpModelInformation($request['type'], $validate = true);
break;
}
if (empty($devices)) {
return array();
}
return $devices;
break;
case 'deleteSoftKey':
if (!empty($request['softkey'])) {
$id_name = $request['softkey'];
unset($this->sccp_conf_init[$id_name]);
$this->createDefaultSccpConfig();
$msg = print_r($this->srvinterface->sccp_reload(), 1);
return array('status' => true, 'table_reload' => true);
}
break;
case 'updateSoftKey':
if (!empty($request['id'])) {
$id_name = preg_replace('/[^A-Za-z0-9]/', '', $request['id']);
$this->sccp_conf_init[$id_name]['type'] = "softkeyset";
foreach ($this->extconfigs->getextConfig('keyset') as $keyl => $vall) {
if (!empty($request[$keyl])) {
$this->sccp_conf_init[$id_name][$keyl] = $request[$keyl];
}
}
$this->createDefaultSccpConfig();
// !TODO!: -TODO-: Check SIP Support Enabled
$this->createSccpXmlSoftkey();
$msg = print_r($this->srvinterface->sccp_reload(), 1);
return array('status' => true, 'table_reload' => true);
}
break;
case 'getSoftKey':
$result = array();
$i = 0;
$keyl = 'default';
foreach ($this->srvinterface->sccp_list_keysets() as $keyl => $vall) {
$result[$i]['softkeys'] = $keyl;
if ($keyl == 'default') {
foreach ($this->extconfigs->getextConfig('keyset') as $key => $value) {
$result[$i][$key] = str_replace(',', '<br>', $value);
}
} else {
foreach ($this->getMyConfig('softkeyset', $keyl) as $key => $value) {
$result[$i][$key] = str_replace(',', '<br>', $value);
}
}
$i++;
}
return $result;
break;
case 'getExtensionGrid':
$result = $this->dbinterface->HWextension_db_SccpTableData('SccpExtension');
if (empty($result)) {
return array();
}
/*
$res_info = $this->aminterface->core_list_all_exten('exten');
if (!empty($res_info)) {
foreach ($result as $key => $value) {
$tpm_info = $res_info[$value['name']];
if (!empty($tpm_info)) {
$result[$key]['line_status'] = $tpm_info['status'];
$result[$key]['line_statustext'] = $tpm_info['statustext'];
} else {
$result[$key]['line_status'] = '';
$result[$key]['line_statustext'] = '';
}
}
}
*
*/
return $result;
break;
case 'getPhoneGrid':
$cmd_type = !empty($request['type']) ? $request['type'] : '';
$result = $this->dbinterface->HWextension_db_SccpTableData('SccpDevice', array('type' => $cmd_type));
if ($cmd_type == 'cisco-sip') {
return $result;
}
$staus = $this->srvinterface->sccp_get_active_device();
if (empty($result)) {
$result = array();
} else {
foreach ($result as &$dev_id) {
$id_name = $dev_id['name'];
if (!empty($staus[$id_name])) {
$dev_id['description'] = $staus[$id_name]['descr'];
$dev_id['status'] = $staus[$id_name]['status'];
$dev_id['address'] = $staus[$id_name]['address'];
$dev_id['new_hw'] = 'N';
$staus[$id_name]['news'] = 'N';
} else {
$dev_id['description'] = '- -';
$dev_id['status'] = 'not connected';
$dev_id['address'] = '- -';
}
}
}
if (!empty($staus)) {
foreach ($staus as $dev_ids) {
$id_name = $dev_ids['name'];
if (empty($dev_ids['news'])) {
$dev_data = $this->srvinterface->sccp_getdevice_info($id_name);
if (!empty($dev_data['SCCP_Vendor']['model_id'])) {
$dev_addon = $dev_data['SCCP_Vendor']['model_addon'];
if (empty($dev_addon)) {
$dev_addon = null;
}
$dev_schema = $this->getSccpModelInformation('byciscoid', false, "all", array('model' => $dev_data['SCCP_Vendor']['model_id']));
if (empty($dev_schema)) {
$dev_schema[0]['model'] = "ERROR in Model Schema";
}
$result[] = array('name' => $id_name, 'mac' => $id_name, 'button' => '---', 'type' => $dev_schema[0]['model'], 'new_hw' => 'Y',
'description' => '*NEW* ' . $dev_ids['descr'], 'status' => '*NEW* ' . $dev_ids['status'], 'address' => $dev_ids['address'],
'addon' => $dev_addon);
}
}
}
}