forked from FreePBX/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libfreepbx.install.php
executable file
·2599 lines (2340 loc) · 104 KB
/
libfreepbx.install.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
// License for all code of this FreePBX module can be found in the license file inside the module directory
// Copyright 2013 Schmooze Com Inc.
//
/********************************************************************************************************************/
/* freepbxlib.install.php
*
* These are used by install_amp and the framework install script to run updates
*
* These variables are required to be defined outside of this library. The purpose
* of this is to allow the library to be used by both install_amp as well as the
* framework which would potentially be accessing these from different locations.
*
* Examples:
*
* UPGRADE_DIR dirname(__FILE__)."/upgrades"
* MODULE_DIR dirname(__FILE__)."/amp_conf/htdocs/admin/modules/"
*
* or (in framework for instance)
*
* MODULE_DIR dirname(__FILE__)."/htdocs/admin/modules/"
*
* $debug = false;
* $dryrun = false;
*/
function upgrade_all($version) {
// **** Read upgrades/ directory
outn("Checking for upgrades..");
// read versions list from upgrades/
$versions = array();
$dir = opendir(UPGRADE_DIR);
while ($file = readdir($dir)) {
if (($file[0] != ".") && is_dir(UPGRADE_DIR."/".$file)) {
$versions[] = $file;
}
}
closedir($dir);
// callback to use php's version_compare() to sort
usort($versions, "version_compare_freepbx");
// find versions that are higher than the current version
$starting_version = false;
foreach ($versions as $check_version) {
if (version_compare_freepbx($check_version, $version) > 0) { // if check_version < version
$starting_version = $check_version;
break;
}
}
// run all upgrades from the list of higher versions
if ($starting_version) {
$pos = array_search($starting_version, $versions);
$upgrades = array_slice($versions, $pos); // grab the list of versions, starting at $starting_version
out(count($upgrades)." found");
run_upgrade($upgrades);
/* Set the base version of key modules, currently core and framework, to the
* Version packaged with this tarball, if any. The expectation is that the
* packaging scripts will make these module version numbers the same as the
* release plus a '.0' which can be incremented for bug fixes delivered through
* the online system between main releases.
*
* added if function_exists because if this is being run from framework there is no
* need to reset the base version.
*/
if (function_exists('set_base_version')) {
set_base_version();
}
} else {
out("No further upgrades necessary");
}
}
//----------------------------------
// dependencies for upgrade_all
/** Invoke upgrades
* @param $versions array The version upgrade scripts to run
*/
function run_upgrade($versions) {
global $dryrun;
foreach ($versions as $version) {
out("Upgrading to ".$version."..");
install_upgrade($version);
if (!$dryrun) {
setversion($version);
}
out("Upgrading to ".$version."..OK");
}
}
//get the version number
function install_getversion() {
global $db;
$sql = "SELECT value FROM admin WHERE variable = 'version'";
$results = $db->getAll($sql);
if(DB::IsError($results)) {
return false;
}
return $results[0][0];
}
//set the version number
function setversion($version) {
global $db;
$sql = "UPDATE admin SET value = '".$version."' WHERE variable = 'version'";
debug($sql);
$result = $db->query($sql);
if(DB::IsError($result)) {
die($result->getMessage());
}
}
/** Install a particular version
*/
function install_upgrade($version) {
global $db;
global $dryrun;
global $amp_conf;
$db_engine = $amp_conf["AMPDBENGINE"];
if (is_dir(UPGRADE_DIR."/".$version)) {
// sql scripts first
$dir = opendir(UPGRADE_DIR."/".$version);
while ($file = readdir($dir)) {
if (($file[0] != ".") && is_file(UPGRADE_DIR."/".$version."/".$file)) {
if ( (strtolower(substr($file,-4)) == ".sqlite") && ($db_engine == "sqlite") ) {
install_sqlupdate( $version, $file );
}
elseif ((strtolower(substr($file,-4)) == ".sql") &&
( ($db_engine == "mysql") || ($db_engine == "pgsql") || ($db_engine == "sqlite3") ) ) {
install_sqlupdate( $version, $file );
}
}
}
// now non sql scripts
$dir = opendir(UPGRADE_DIR."/".$version);
while ($file = readdir($dir)) {
if (($file[0] != ".") && is_file(UPGRADE_DIR."/".$version."/".$file)) {
if ((strtolower(substr($file,-4)) == ".sql") || (strtolower(substr($file,-7)) == ".sqlite")) {
// sql scripts were dealt with first
} else if (strtolower(substr($file,-4)) == ".php") {
out("-> Running PHP script ".UPGRADE_DIR."/".$version."/".$file);
if (!$dryrun) {
run_included(UPGRADE_DIR."/".$version."/".$file);
}
} else if (is_executable(UPGRADE_DIR."/".$version."/".$file)) {
out("-> Executing ".UPGRADE_DIR."/".$version."/".$file);
if (!$dryrun) {
exec(UPGRADE_DIR."/".$version."/".$file);
}
} else {
error("-> Don't know what to do with ".UPGRADE_DIR."/".$version."/".$file);
}
}
}
}
}
function checkDiff($file1, $file2) {
// diff, ignore whitespace and be quiet
exec("diff -wq ".escapeshellarg($file2)." ".escapeshellarg($file1), $output, $retVal);
return ($retVal != 0);
}
function amp_mkdir($directory, $mode = "0755", $recursive = false) {
global $runas_uid;
global $runas_gid;
debug("mkdir ".$directory.", ".$mode);
$ntmp = sscanf($mode,"%o",$modenum); //assumes all inputs are octal
if (version_compare(phpversion(), '5.0') < 0) {
// php <5 can't recursively create directories
if ($recursive) {
$output = false;
$return_value = false;
exec("mkdir -m ".$mode." -p ".$directory, $output, $return_value);
exec("chown -R $runas_uid:$runas_gid $directory");
return ($return_value == 0);
} else {
$ret=mkdir($directory, $modenum);
exec("chown -R $runas_uid:$runas_gid $directory");
return $ret;
}
} else {
$ret=mkdir($directory, $modenum, $recursive);
exec("chown -R $runas_uid:$runas_gid $directory");
return $ret;
}
}
/**
* Recursive Read Links
*
* This function is used to recursively read symlink until we reach a real directory
*
* @params string $source - The original file we are replacing
* @returns array of the original source we read in and the real directory for it
*/
function recursive_readlink($source){
$dir = dirname($source);
$links = array();
$ldir = null;
while (!in_array($dir,array('.','..','','/')) && strpos('.git',$dir) == false) {
if ($dir == $ldir) {
break;
}
if (is_link($dir)) {
$ldir = readlink($dir);
$file = str_replace($dir, $ldir, $source);
if (!is_link($ldir) && file_exists($file)) {
$links[$source] = $file;
}
} else {
if (file_exists($source) && !is_link(dirname($source))) {
break;
}
$ldir = dirname($dir);
$file = str_replace($dir, $ldir, $source);
if (!is_link($ldir) && file_exists($file)) {
$links[$source] = $file;
}
}
$ldir = $dir;
$dir = dirname($dir);
}
return $links;
}
/**
* Substitute Read Links
*
* This function is used to substitute symlinks, to real directories where information is stored
*
* @params string $source - The original file we are replacing
* @params array $links - A list of possible replacements
* @return string of the real file path to the given source
*/
function substitute_readlinks($source,$links) {
foreach ($links as $key => $value) {
if (strpos($source, $key) !== false) {
$source = str_replace($key, $value, $source);
return $source;
}
}
}
/** Recursively copy a directory
*/
function recursive_copy($dirsourceparent, $dirdest, &$md5sums, $dirsource = "") {
global $dryrun;
global $check_md5s;
global $amp_conf;
global $asterisk_conf;
global $install_moh;
global $make_links;
$overwrite = false;
$moh_subdir = isset($amp_conf['MOHDIR']) ? trim(trim($amp_conf['MOHDIR']),'/') : 'mohmp3';
// total # files, # actually copied
$num_files = $num_copied = 0;
if ($dirsource && ($dirsource[0] != "/")) $dirsource = "/".$dirsource;
if (is_dir($dirsourceparent.$dirsource)) $dir_handle = opendir($dirsourceparent.$dirsource);
/*
echo "dirsourceparent: "; var_dump($dirsourceparent);
echo "dirsource: "; var_dump($dirsource);
echo "dirdest: "; var_dump($dirdest);
*/
while (isset($dir_handle) && ($file = readdir($dir_handle))) {
if (($file!=".") && ($file!="..") && ($file != "CVS") && ($file != ".svn") && ($file != ".git")) {
$source = $dirsourceparent.$dirsource."/".$file;
$destination = $dirdest.$dirsource."/".$file;
if ($dirsource == "" && $file == "moh" && !$install_moh) {
// skip to the next dir
continue;
}
// configurable in amportal.conf
$destination=preg_replace("/^\/htdocs\//i",trim($amp_conf["AMPWEBROOT"])."/",$destination);
if(strpos($dirsource, 'modules') === false) $destination=str_replace("/bin",trim($amp_conf["AMPBIN"]),$destination);
$destination=str_replace("/sbin",trim($amp_conf["AMPSBIN"]),$destination);
// the following are configurable in asterisk.conf
$destination=str_replace("/astetc",trim($asterisk_conf["astetcdir"]),$destination);
$destination=str_replace("/moh",trim($asterisk_conf["astvarlibdir"])."/$moh_subdir",$destination);
$destination=str_replace("/astvarlib",trim($asterisk_conf["astvarlibdir"]),$destination);
if(strpos($dirsource, 'modules') === false) $destination=str_replace("/agi-bin",trim($asterisk_conf["astagidir"]),$destination);
if(strpos($dirsource, 'modules') === false) $destination=str_replace("/sounds",trim($asterisk_conf["astvarlibdir"])."/sounds",$destination);
// if this is a directory, ensure destination exists
if (is_dir($source)) {
if (!file_exists($destination)) {
if ((!$dryrun) && ($destination != "")) {
amp_mkdir($destination, "0750", true);
}
}
}
//var_dump($md5sums);
if (!is_dir($source)) {
$md5_source = preg_replace("|^/?amp_conf/|", "/", $source);
if ($check_md5s && file_exists($destination) && isset($md5sums[$md5_source]) && (md5_file($destination) != $md5sums[$md5_source])) {
// double check using diff utility (and ignoring whitespace)
// This is a somewhat edge case (eg, the file doesn't match
// it's md5 sum from the previous version, but no substantial
// changes exist compared to the current version), but it
// prevents a useless prompt to the user.
if (checkDiff($source, $destination)) {
$overwrite = ask_overwrite($source, $destination);
} else {
debug("NOTE: MD5 for ".$destination." was different, but `diff` did not detect any (non-whitespace) changes: overwriting");
$overwrite = true;
}
} else {
$overwrite = true;
}
// These are modified by apply_conf.sh, there may be others that fit in this category also. This keeps these from
// being symlinked and then developers inadvertently checking in the changes when they should not have.
//
$never_symlink = array("cdr_mysql.conf", "manager.conf", "vm_email.inc", "modules.conf");
$num_files++;
if ($overwrite) {
debug(($make_links ? "link" : "copy")." ".$source." -> ".$destination);
if (!$dryrun) {
if ($make_links && !in_array(basename($source),$never_symlink)) {
// symlink, unlike copy, doesn't overwrite - have to delete first
if (is_link($destination) || file_exists($destination)) {
unlink($destination);
}
$links = recursive_readlink($source);
if (!empty($links)) {
@symlink(substitute_readlinks($source,$links), $destination);
} else {
if(file_exists(dirname(__FILE__)."/".$source)) {
@symlink(dirname(__FILE__)."/".$source, $destination);
}
}
} else {
$ow = false;
if(file_exists($destination)) {
if (checkDiff($source, $destination) && !$make_links) {
$ow = ask_overwrite($source, $destination);
} elseif($make_links) {
$ow = false;
}
} else {
$ow = true;
}
//ask_overwrite
if($ow) {
//Copy will not overwrite a symlink, phpnesssss
if(file_exists($destination) && is_link($destination)) {
unlink($destination);
}
copy($source, $destination);
} else {
continue;
}
}
$num_copied++;
}
} else {
debug("not overwriting ".$destination);
}
} else {
list($tmp_num_files, $tmp_num_copied) = recursive_copy($dirsourceparent, $dirdest, $md5sums, $dirsource."/".$file);
$num_files += $tmp_num_files;
$num_copied += $tmp_num_copied;
}
}
}
if (isset($dir_handle)) closedir($dir_handle);
return array($num_files, $num_copied);
}
function read_md5_file($filename) {
$md5 = array();
if (file_exists($filename)) {
foreach (file($filename) as $line) {
if (preg_match("/^([a-f0-9]{32})\s+(.*)$/", $line, $matches)) {
$md5[ "/".$matches[2] ] = $matches[1];
}
}
}
return $md5;
}
/** Include a .php file
* This is a function just to keep a separate context
*/
function run_included($file) {
global $db;
global $amp_conf;
include($file);
}
function install_sqlupdate( $version, $file )
{
global $db;
global $dryrun;
out("-> Running SQL script ".UPGRADE_DIR."/".$version."/".$file);
// run sql script
$fd = fopen(UPGRADE_DIR."/".$version."/".$file, "r");
$data = "";
while (!feof($fd)) {
$data .= fread($fd, 1024);
}
fclose($fd);
preg_match_all("/((SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER).*);\s*\n/Us", $data, $matches);
foreach ($matches[1] as $sql) {
debug($sql);
if (!$dryrun) {
$result = $db->query($sql);
if(DB::IsError($result)) {
fatal($result->getDebugInfo()."\" while running ".$file."\n");
}
}
}
}
/********************************************************************************************************************/
/* FREEPBX SETTINGS (AMPORTAL.CONF) DEFINED HERE */
/********************************************************************************************************************/
//
// TODO: find a good way to extract the required localization strings for the tools to pickup
//
// freepbx_settings_init()
// this is where we initialize all the freepbx_settings (amportal.conf). This will be run with install_amp and every
// time we run the framework installer, so new settings can be added here that are framework wide. It may make sense to
// break this out separately but for now we'll keep it here since this is already part of the infrastructure that is
// used by both install_amp and the framework install/upgrade script.
//
function freepbx_settings_init($commit_to_db = false) {
global $amp_conf;
if (!class_exists('freepbx_conf')) {
include_once ($amp_conf['AMPWEBROOT'].'/admin/libraries/freepbx_conf.class.php');
}
$freepbx_conf =& freepbx_conf::create();
$set['value'] = '';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 0;
$set['module'] = '';
$set['emptyok'] = 0;
//
// CATEGORY: Advanced Settings Display
//
$set['category'] = 'Advanced Settings Details';
/* This was too confusing, will remove for now and re-evaluate if needed
// AS_DISPLAY_DETAIL_LEVEL
$set['value'] = '0';
$set['options'] = '0,1,2,3,4,5,6,7,8,9,10';
$set['name'] = 'Display Detail Level';
$set['description'] = 'This will filter which settings that are displayed on this Advanced Settings page. The higher the level, the more obscure settings will be shown. Settings at higher levels are unlikely to be of interest to most users and could be more volatile to breaking your system if set wrong.';
$set['emptyok'] = 0;
$set['level'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_SELECT;
$freepbx_conf->define_conf_setting('AS_DISPLAY_DETAIL_LEVEL',$set);
$set['readonly'] = 0;
$set['level'] = 0;
*/
// Make this hidden, has proven to confusing since users can't change them. This could be turned on programatically for dev purposes.
// AS_DISPLAY_HIDDEN_SETTINGS
//
$set['value'] = false;
$set['options'] = '';
$set['name'] = 'Display Hidden Settings';
$set['description'] = 'This will display settings that are normally hidden by the system. These settings are often internally used settings that are not of interest to most users.';
$set['emptyok'] = 0;
$set['level'] = 0;
$set['readonly'] = 1;
$set['hidden'] = 1;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('AS_DISPLAY_HIDDEN_SETTINGS',$set);
$set['readonly'] = 0;
$set['level'] = 0;
$set['hidden'] = 0;
// AS_DISPLAY_READONLY_SETTINGS
$set['value'] = false;
$set['options'] = '';
$set['name'] = 'Display Readonly Settings';
$set['description'] = 'This will display settings that are readonly. These settings are often internally used settings that are not of interest to most users. Since they are readonly they can only be viewed.';
$set['emptyok'] = 0;
$set['level'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('AS_DISPLAY_READONLY_SETTINGS',$set);
$set['readonly'] = 0;
$set['level'] = 0;
// AS_OVERRIDE_READONLY
$set['value'] = false;
$set['options'] = '';
$set['name'] = 'Override Readonly Settings';
$set['description'] = 'Setting this to true will allow you to override un-hidden readonly setting to change them. Settings that are readonly may be extremely volatile and have a high chance of breaking your system if you change them. Take extreme caution when electing to make such changes.';
$set['emptyok'] = 0;
$set['level'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('AS_OVERRIDE_READONLY',$set);
$set['readonly'] = 0;
$set['level'] = 0;
// AS_DISPLAY_FRIENDLY_NAME
$set['value'] = true;
$set['options'] = '';
$set['name'] = 'Display Friendly Name';
$set['description'] = 'Normally the friendly names will be displayed on this page and the internal freepbx_conf configuration names are shown in the tooltip. If you prefer to view the configuration variables, and the friendly name in the tooltip, set this to false..';
$set['emptyok'] = 0;
$set['level'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('AS_DISPLAY_FRIENDLY_NAME',$set);
$set['readonly'] = 0;
$set['level'] = 0;
//
// CATEGORY: System Setup
//
$set['category'] = 'System Setup';
// AMPSYSLOGLEVEL
$set['value'] = 'FILE';
$set['options'] = 'FILE, LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG';
// LOG_SQL, SQL are discontinued, they are removed during migration if the slipped in and in core if it were to persist because amportal.conf was not
// writeable for a while.
//
if (isset($amp_conf['AMPSYSLOGLEVEL']) && (strtoupper($amp_conf['AMPSYSLOGLEVEL']) == 'SQL' || strtoupper($amp_conf['AMPSYSLOGLEVEL']) == 'LOG_SQL')) {
$set['options'] .= ', LOG_SQL, SQL';
}
$set['name'] = 'FreePBX Log Routing';
$set['description'] = "Determine where to send log information if the log is enabled ('Disable FreePBX Log' (AMPDISABLELOG) false. There are two places to route the log messages. 'FILE' will send all log messages to the defined 'FreePBX Log File' (FPBX_LOG_FILE). All the other settings will route the log messages to your System Logging subsystem (syslog) using the specified log level. Syslog can be configured to route different levels to different locations. See 'syslog' documentation (man syslog) on your system for more details.";
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['sortorder'] = -190;
$set['type'] = CONF_TYPE_SELECT;
$freepbx_conf->define_conf_setting('AMPSYSLOGLEVEL',$set);
// AMPDISABLELOG
$set['value'] = false;
$set['options'] = '';
$set['name'] = 'Disable FreePBX Log';
$set['description'] = 'Whether or not to invoke the FreePBX log facility.';
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['sortorder'] = -180;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('AMPDISABLELOG',$set);
// LOG_OUT_MESSAGES
$set['value'] = true;
$set['options'] = '';
$set['name'] = 'Log Verbose Messages';
$set['description'] = 'FreePBX has many verbose and useful messages displayed to users during module installation, system installations, loading configurations and other places. In order to accumulate these messages in the log files as well as the on screen display, set this to true.';
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['sortorder'] = -170;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('LOG_OUT_MESSAGES',$set);
// LOG_NOTIFICATIONS
$set['value'] = true;
$set['options'] = '';
$set['name'] = 'Send Dashboard Notifications to Log';
$set['description'] = 'When enabled all notification updates to the Dashboard notification panel will also be logged into the specified log file when enabled.';
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['sortorder'] = -160;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('LOG_NOTIFICATIONS',$set);
// FPBX_LOG_FILE
$set['value'] = $amp_conf['ASTLOGDIR'] . '/freepbx.log';
$set['options'] = '';
$set['name'] = 'FreePBX Log File';
$set['description'] = 'Full path and name of the FreePBX Log File used in conjunction with the Syslog Level (AMPSYSLOGLEVEL) being set to FILE, not used otherwise. Initial installs may have some early logging sent to /tmp/freepbx_pre_install.log when it is first bootstrapping the installer.';
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['sortorder'] = -150;
$set['type'] = CONF_TYPE_TEXT;
$freepbx_conf->define_conf_setting('FPBX_LOG_FILE',$set);
// PHP_ERROR_HANDLER_OUTPUT
$set['value'] = 'freepbxlog';
$set['options'] = array('dbug','freepbxlog','off');
$set['name'] = 'PHP Error Log Output';
$set['description'] = "Where to send PHP errors, warnings and notices by the FreePBX PHP error handler. Set to 'dbug', they will go to the Debug File regardless of whether dbug Loggin is disabled or not. Set to 'freepbxlog' will send them to the FreePBX Log. Set to 'off' and they will be ignored.";
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['sortorder'] = -140;
$set['type'] = CONF_TYPE_SELECT;
$freepbx_conf->define_conf_setting('PHP_ERROR_HANDLER_OUTPUT',$set);
// AGGRESSIVE_DUPLICATE_CHECK
$set['value'] = false;
$set['options'] = '';
$set['name'] = 'Aggresively Check for Duplicate Extensions';
$set['description'] = "When set to true FreePBX will update its extension map every page load. This is used to check for duplicate extension numbers in the client side javascript validation. Normally the extension map is only created when Apply Configuration Settings is pressed and retrieve_conf is run.";
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['sortorder'] = -137;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('AGGRESSIVE_DUPLICATE_CHECK',$set);
// AMPEXTENSIONS
$set['value'] = 'extensions';
$set['options'] = 'extensions,deviceanduser';
$set['name'] = 'User & Devices Mode';
$set['description'] = 'Sets the extension behavior in FreePBX. If set to <b>extensions</b>, Devices and Users are administered together as a unified Extension, and appear on a single page. If set to <b>deviceanduser</b>, Devices and Users will be administered separately. Devices (e.g. each individual line on a SIP phone) and Users (e.g. <b>101</b>) will be configured independent of each other, allowing association of one User to many Devices, or allowing Users to login and logout of Devices.';
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['sortorder'] = -135;
$set['type'] = CONF_TYPE_SELECT;
$freepbx_conf->define_conf_setting('AMPEXTENSIONS',$set);
// AUTHTYPE
$set['value'] = 'database';
$set['options'] = 'database,none,webserver';
$set['name'] = 'Authorization Type';
$set['description'] = 'Authentication type to use for web admin. If type set to <b>database</b>, the primary AMP admin credentials will be the AMPDBUSER/AMPDBPASS above. When using database you can create users that are restricted to only certain module pages. When set to none, you should make sure you have provided security at the apache level. When set to webserver, FreePBX will expect authentication to happen at the apache level, but will take the user credentials and apply any restrictions as if it were in database mode.';
$set['emptyok'] = 0;
$set['level'] = 3;
$set['readonly'] = 1;
$set['sortorder'] = -130;
$set['type'] = CONF_TYPE_SELECT;
$freepbx_conf->define_conf_setting('AUTHTYPE',$set);
$set['level'] = 0;
// AMP_ACCESS_DB_CREDS
$set['value'] = false;
$set['options'] = '';
$set['name'] = 'Allow Login With DB Credentials';
$set['description'] = "When Set to True, admin access to the FreePBX GUI will be allowed using the FreePBX configured AMPDBUSER and AMPDBPASS credentials. This only applies when Authorization Type is 'database' mode.";
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['sortorder'] = -126;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('AMP_ACCESS_DB_CREDS',$set);
// FORCED_ASTVERSION
$set['value'] = '';
$set['options'] = '';
$set['name'] = 'Force Asterisk Version';
$set['description'] = 'Normally FreePBX gets the current Asterisk version directly from Asterisk. This is required to generate proper dialplan for a given version. When using some custom Asterisk builds, the version may not be properly parsed and improper dialplan generated. Setting this to an equivalent Asterisk version will override what is read from Asterisk. This SHOULD be left blank unless you know what you are doing.';
$set['emptyok'] = 1;
$set['readonly'] = 1;
$set['sortorder'] = -100;
$set['type'] = CONF_TYPE_TEXT;
$set['level'] = 4;
$freepbx_conf->define_conf_setting('FORCED_ASTVERSION',$set);
$set['level'] = 0;
// AMPENGINE
$set['value'] = 'asterisk';
$set['options'] = 'asterisk';
$set['name'] = 'Telephony Engine';
$set['description'] = 'The telephony backend engine being used, asterisk is the only option currently.';
$set['emptyok'] = 0;
$set['level'] = 3;
$set['readonly'] = 1;
$set['type'] = CONF_TYPE_SELECT;
$freepbx_conf->define_conf_setting('AMPENGINE',$set);
$set['level'] = 0;
// AMPVMUMASK
$set['value'] = '007';
$set['options'] = '';
$set['name'] = 'Asterisk VMU Mask';
$set['description'] = 'Defaults to 077 allowing only the asterisk user to have any permission on VM files. If set to something like 007, it would allow the group to have permissions. This can be used if setting apache to a different user then asterisk, so that the apache user can have access to read/write/delete the voicemail files. If changed, some of the voicemail directory structures may have to be manually changed.';
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_TEXT;
$set['level'] = 4;
$freepbx_conf->define_conf_setting('AMPVMUMASK',$set);
$set['level'] = 0;
// AMPWEBADDRESS
$set['value'] = '';
$set['options'] = '';
$set['name'] = 'FreePBX Web Address';
$set['description'] = 'This is the address of your Web Server. It is mostly obsolete and derived when not supplied and will be phased out, but there are still some areas expecting a variable to be set and if you are using it this will migrate your value.';
$set['emptyok'] = 1;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_TEXT;
$set['level'] = 4;
$freepbx_conf->define_conf_setting('AMPWEBADDRESS',$set);
$set['level'] = 0;
// AMPASTERISKUSER
$set['value'] = 'asterisk';
$set['options'] = '';
$set['name'] = 'System Asterisk User';
$set['description'] = 'The user Asterisk should be running as, used by freepbx_engine. Most systems should not change this.';
$set['emptyok'] = 0;
$set['type'] = CONF_TYPE_TEXT;
$set['level'] = 4;
$set['readonly'] = 1;
$freepbx_conf->define_conf_setting('AMPASTERISKUSER',$set);
$set['level'] = 0;
// AMPASTERISKGROUP
$set['value'] = 'asterisk';
$set['options'] = '';
$set['name'] = 'System Asterisk Group';
$set['description'] = 'The user group Asterisk should be running as, used by freepbx_engine. Most systems should not change this.';
$set['emptyok'] = 0;
$set['type'] = CONF_TYPE_TEXT;
$set['level'] = 4;
$set['readonly'] = 1;
$freepbx_conf->define_conf_setting('AMPASTERISKGROUP',$set);
$set['level'] = 0;
// AMPASTERISKWEBUSER
$set['value'] = 'asterisk';
$set['options'] = '';
$set['name'] = 'System Web User';
$set['description'] = 'The user your httpd should be running as, used by freepbx_engine. Most systems should not change this.';
$set['emptyok'] = 0;
$set['type'] = CONF_TYPE_TEXT;
$set['level'] = 4;
$set['readonly'] = 1;
$freepbx_conf->define_conf_setting('AMPASTERISKWEBUSER',$set);
$set['level'] = 0;
// AMPASTERISKWEBGROUP
$set['value'] = 'asterisk';
$set['options'] = '';
$set['name'] = 'System Web Group';
$set['description'] = 'The user group your httpd should be running as, used by freepbx_engine. Most systems should not change this.';
$set['emptyok'] = 0;
$set['type'] = CONF_TYPE_TEXT;
$set['level'] = 4;
$set['readonly'] = 1;
$freepbx_conf->define_conf_setting('AMPASTERISKWEBGROUP',$set);
$set['level'] = 0;
// AMPDEVUSER
$set['value'] = 'asterisk';
$set['options'] = '';
$set['name'] = 'System Device User';
$set['description'] = 'The user that various device directories should be set to, used by freepbx_engine. Examples include /dev/zap, /dev/dahdi, /dev/misdn, /dev/mISDN and /dev/dsp. Most systems should not change this.';
$set['emptyok'] = 0;
$set['type'] = CONF_TYPE_TEXT;
$set['level'] = 4;
$set['readonly'] = 1;
$freepbx_conf->define_conf_setting('AMPDEVUSER',$set);
$set['level'] = 0;
// AMPDEVGROUP
$set['value'] = 'asterisk';
$set['options'] = '';
$set['name'] = 'System Device Group';
$set['description'] = 'The user group that various device directories should be set to, used by freepbx_engine. Examples include /dev/zap, /dev/dahdi, /dev/misdn, /dev/mISDN and /dev/dsp. Most systems should not change this.';
$set['emptyok'] = 0;
$set['readonly'] = 1;
$set['type'] = CONF_TYPE_TEXT;
$set['level'] = 4;
$freepbx_conf->define_conf_setting('AMPDEVGROUP',$set);
$set['level'] = 0;
// BROWSER_STATS
$set['value'] = true;
$set['options'] = '';
$set['name'] = 'Browser Stats';
$set['description'] = 'Setting this to true will allow the development team to use google analytics to anonymously analyze browser information to help make better development decisions.';
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('BROWSER_STATS',$set);
// USE_GOOGLE_CDN_JS
$set['value'] = false;
$set['options'] = '';
$set['name'] = 'Use Google Distribution Network for js Downloads';
$set['description'] = 'Setting this to true will fetch system javascript libraries such as jQuery and jQuery-ui from ajax.googleapis.com. This can be advantageous if accessing remote or multiple different FreePBX systems since the libraries are only cached once in your browser. If external internet connections are problematic, setting this true could result in slow systems. FreePBX will always fallback to the locally available libraries if the CDN is not available.';
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('USE_GOOGLE_CDN_JS',$set);
//JQUERY_VER
$set['value'] = '1.11.1';
$set['options'] = '';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 1;
$set['hidden'] = 1;
$set['level'] = 0;
$set['module'] = '';
$set['category'] = 'System Setup';
$set['emptyok'] = 0;
$set['name'] = 'jQuery Version';
$set['description'] = 'The version of jQuery that we wish to use.';
$set['type'] = CONF_TYPE_TEXT;
$freepbx_conf->define_conf_setting('JQUERY_VER', $set);
//only for jquery, bootstrap and jqueryUI
if($freepbx_conf->conf_setting_exists('JQUERY_VER')) {
$freepbx_conf->set_conf_values(array('JQUERY_VER' => $set['value']), true, true);
}
$set['hidden'] = 0;
//JQUERYUI_VER
$set['value'] = '1.10.3';
$set['options'] = '';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 1;
$set['hidden'] = 1;
$set['level'] = 0;
$set['module'] = '';
$set['category'] = 'System Setup';
$set['emptyok'] = 0;
$set['name'] = 'jQuery UI Version';
$set['description'] = 'The version of jQuery UI that we wish to use.';
$set['type'] = CONF_TYPE_TEXT;
$freepbx_conf->define_conf_setting('JQUERYUI_VER', $set);
//only for jquery, bootstrap and jqueryUI
if($freepbx_conf->conf_setting_exists('JQUERYUI_VER')) {
$freepbx_conf->set_conf_values(array('JQUERYUI_VER' => $set['value']), true, true);
}
$set['hidden'] = 0;
//BOOTSTRAP_VER
$set['value'] = '3.0.2';
$set['options'] = '';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 1;
$set['hidden'] = 1;
$set['level'] = 0;
$set['module'] = '';
$set['category'] = 'System Setup';
$set['emptyok'] = 0;
$set['name'] = 'Bootstrap Version';
$set['description'] = 'The version of Bootstrap that we wish to use.';
$set['type'] = CONF_TYPE_TEXT;
$freepbx_conf->define_conf_setting('BOOTSTRAP_VER', $set);
//only for jquery, bootstrap and jqueryUI
if($freepbx_conf->conf_setting_exists('BOOTSTRAP_VER')) {
$freepbx_conf->set_conf_values(array('BOOTSTRAP_VER' => $set['value']), true, true);
}
$set['hidden'] = 0;
//JQMIGRATE
$set['value'] = true;
$set['options'] = '';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 0;
$set['module'] = '';
$set['category'] = 'Developer and Customization';
$set['emptyok'] = 0;
$set['name'] = 'Enable jQuery Migrate';
$set['description'] = 'This plugin can be used to detect and restore APIs or features that have been deprecated in jQuery and removed as of version 1.9';
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('JQMIGRATE',$set);
// CRONMAN_UPDATES_CHECK
$set['value'] = true;
$set['options'] = '';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 1;
$set['hidden'] = 0;
$set['level'] = 0;
$set['module'] = '';
$set['emptyok'] = 0;
$set['name'] = 'Update Notifications';
$set['description'] = 'FreePBX allows you to automatically check for updates online. The updates will NOT be automatically installed. It is STRONGYLY advised that you keep this enabled and keep updated of these important notificaions to avoid costly security issues.';
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('CRONMAN_UPDATES_CHECK',$set);
$set['hidden'] = 0;
// SIGNATURECHECK
$set['value'] = true;
$set['options'] = '';
$set['defaultval'] =& $set['value'];
$set['name'] = 'Enable Module Signature Checking';
$set['description'] = 'Checks to make sure modules and their files are validly signed. Will display a notice on any module page that is not correctly verified.';
$set['level'] = 0;
$set['emptyok'] = 0;
$set['module'] = '';
$set['hidden'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('SIGNATURECHECK',$set);
//AMPTRACKENABLE
$set['value'] = true;
$set['options'] = '';
$set['defaultval'] =& $set['value'];
$set['name'] = 'Enable Module Tracks';
$set['description'] = 'This enables the setting of module tracks (sub repositories of modules). Whereas a user could select a beta release track of a module or keep it on standard. Disabling this will force all modules into the stable track and disallow users to change the tracks';
$set['level'] = 2;
$set['emptyok'] = 0;
$set['module'] = '';
$set['hidden'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('AMPTRACKENABLE',$set);
$set['value'] = false;
$set['options'] = '';
$set['defaultval'] =& $set['value'];
$set['name'] = 'Enable Remote Unlocking';
$set['description'] = 'Enabling this option will allow a remote user to automatically authenticate as an admin via use of a one-time key generated by "amportal a genunlockkey"';
$set['level'] = 2;
$set['emptyok'] = 0;
$set['module'] = '';
$set['hidden'] = 0;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('REMOTEUNLOCK',$set);
//
// CATEGORY: Dialplan and Operational
//
$set['category'] = 'Dialplan and Operational';
// AMPBADNUMBER
$set['value'] = true;
$set['options'] = '';
$set['name'] = 'Use bad-number Context';
$set['description'] = 'Generate the bad-number context which traps any bogus number or feature code and plays a message to the effect. If you use the Early Dial feature on some Grandstream phones, you will want to set this to false.';
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_BOOL;
$set['level'] = 2;
$freepbx_conf->define_conf_setting('AMPBADNUMBER',$set);
$set['level'] = 0;
// CWINUSEBUSY
$set['value'] = true;
$set['options'] = '';
$set['name'] = 'Occupied Lines CW Busy';
$set['description'] = 'For extensions that have CW enabled, report unanswered CW calls as <b>busy</b> (resulting in busy voicemail greeting). If set to no, unanswered CW calls simply report as <b>no-answer</b>.';
$set['emptyok'] = 0;
$set['readonly'] = 0;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('CWINUSEBUSY',$set);
// ZAP2DAHDICOMPAT
$set['value'] = false;
$set['options'] = '';
$set['name'] = 'Convert ZAP Settings to DAHDi';
$set['description'] = 'If set to true, FreePBX will check if you have chan_dahdi installed. If so, it will automatically use all your ZAP configuration settings (devices and trunks) and silently convert them, under the covers, to DAHDi so no changes are needed. The GUI will continue to refer to these as ZAP but it will use the proper DAHDi channels. This will also keep Zap Channel DIDs working.';
$set['emptyok'] = 0;
$set['readonly'] = 1;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('ZAP2DAHDICOMPAT',$set);
// DYNAMICHINTS
$set['value'] = false;
$set['options'] = '';
$set['name'] = 'Dynamically Generate Hints';
$set['description'] = 'If true, Core will not statically generate hints, but instead make a call to the AMPBIN php script, and generate_hints.php through an Asterisk #exec call. This requires asterisk.conf to be configured with <b>execincludes=yes<b> set in the [options] section.';
$set['emptyok'] = 0;
$set['readonly'] = 1;
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('DYNAMICHINTS',$set);