| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
$getvars = array('action', 'keyword', 'value'); |
|---|
| 4 |
foreach ($getvars as $v){ |
|---|
| 5 |
$var[$v] = isset($_POST[$v]) ? $_POST[$v] : 0; |
|---|
| 6 |
} |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
// change to json so we can send back info like what it was updated to |
|---|
| 10 |
// and other useful stuff |
|---|
| 11 |
// |
|---|
| 12 |
if($var['action'] === 'setkey') { |
|---|
| 13 |
header("Content-type: application/json"); |
|---|
| 14 |
$keyword = $var['keyword']; |
|---|
| 15 |
if ($freepbx_conf->conf_setting_exists($keyword)) { |
|---|
| 16 |
$freepbx_conf->set_conf_values(array($keyword => trim($var['value'])),true); |
|---|
| 17 |
$status = $freepbx_conf->get_last_update_status(); |
|---|
| 18 |
|
|---|
| 19 |
echo json_encode($status[$keyword]); |
|---|
| 20 |
} |
|---|
| 21 |
exit; |
|---|
| 22 |
} |
|---|
| 23 |
$amportal_canwrite = $freepbx_conf->amportal_canwrite() ? 'true' : 'false'; |
|---|
| 24 |
echo '<script type="text/javascript">'; |
|---|
| 25 |
echo 'can_write_amportalconf = ' . $amportal_canwrite . '; '; |
|---|
| 26 |
echo 'amportalconf_error ="' . _("You must run 'amportal restart' from the Linux command line before you can save setting here.") . '"'; |
|---|
| 27 |
echo '</script>'; |
|---|
| 28 |
|
|---|
| 29 |
echo '<div id="main_page">'; |
|---|
| 30 |
echo "<h2>"._("FreePBX Advanced Settings")."</h2>"; |
|---|
| 31 |
echo '<p>'._("<b>IMPORTANT:</b> Use extreme caution when making changes!").'</p>'._("Some of these settings can render your system inoperable. You are urged to backup before making any changes. There may be more settings available then are currently shown. You can increase the of visible settings by changing the AS_DISPLAY_DETAIL_LEVEL under Advanced Settings Details. The settings shown at higher levels are less commonly use and can be more risky to change. Once you have made a change you must save it by checking the green check box that appears. You can restore to default settings by clicking on the icon to the right of the values."); |
|---|
| 32 |
|
|---|
| 33 |
$conf = $freepbx_conf->get_conf_settings(); |
|---|
| 34 |
|
|---|
| 35 |
$display_level = $conf['AS_DISPLAY_DETAIL_LEVEL']['value']; |
|---|
| 36 |
$display_hidden = $conf['AS_DISPLAY_HIDDEN_SETTINGS']['value']; |
|---|
| 37 |
$display_readonly = $conf['AS_DISPLAY_READONLY_SETTINGS']['value']; |
|---|
| 38 |
$current_category = ''; |
|---|
| 39 |
$row = 0; |
|---|
| 40 |
|
|---|
| 41 |
echo '<input type="image" src="images/spinner.gif" style="display:none">'; |
|---|
| 42 |
echo '<table id="set_table">'; |
|---|
| 43 |
foreach ($conf as $c){ |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
// |
|---|
| 47 |
if ($c['level'] > $display_level || $c['hidden'] && !$display_hidden || $c['readonly'] && !$display_readonly) { |
|---|
| 48 |
continue; |
|---|
| 49 |
} |
|---|
| 50 |
if ($current_category != $c['category']) { |
|---|
| 51 |
$current_category = $c['category']; |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
// it's only purpose is to get the headings so they are not shaded and so the stripped shading |
|---|
| 55 |
// starts consistent for each section. |
|---|
| 56 |
// |
|---|
| 57 |
if ($row % 2) { |
|---|
| 58 |
|
|---|
| 59 |
echo '<tr></tr>'; |
|---|
| 60 |
$row++; |
|---|
| 61 |
} |
|---|
| 62 |
if ($c['module'] && extension_loaded('gettext') && is_dir("modules/".$c['module']."/i18n")) { |
|---|
| 63 |
bindtextdomain($c['module'],"modules/".$c['module']."/i18n"); |
|---|
| 64 |
bind_textdomain_codeset($c['module'], 'utf8'); |
|---|
| 65 |
$current_category_loc = dgettext($c['module'],$current_category); |
|---|
| 66 |
if ($current_category_loc == $current_category) { |
|---|
| 67 |
$current_cateogry_loc = _($current_category); |
|---|
| 68 |
} |
|---|
| 69 |
} else { |
|---|
| 70 |
$current_category_loc = _($current_category); |
|---|
| 71 |
} |
|---|
| 72 |
echo '<tr><td colspan="3"><br><h4 class="category">'._("$current_category_loc").'</h4></td></tr>'; |
|---|
| 73 |
$row++; |
|---|
| 74 |
} |
|---|
| 75 |
$row++; |
|---|
| 76 |
$dv = $c['type'] == CONF_TYPE_BOOL ? ($c['defaultval'] ? _("True") : _("False")) : $c['defaultval']; |
|---|
| 77 |
$default_val = $dv == '' ? _("No Default Provided") : sprintf(_("Default Value: %s"),$dv); |
|---|
| 78 |
if ($c['emptyok'] && $c['type'] != CONF_TYPE_BOOL && $c['type'] != CONF_TYPE_SELECT) { |
|---|
| 79 |
$default_val.= ', '._("field can be left blank"); |
|---|
| 80 |
} |
|---|
| 81 |
if ($c['type'] == CONF_TYPE_INT && $c['options']) { |
|---|
| 82 |
$range = explode(',',$c['options']); |
|---|
| 83 |
$default_val .= '<br />'.sprintf(_("Acceptable Values: %s - %s"),$range[0],$range[1]); |
|---|
| 84 |
} |
|---|
| 85 |
echo '<tr><td><a href="javascript:void(null)" class="info">'.$c['keyword'].'<span>'.$c['description'].'<br /><br >'.$default_val.'</span></a></td>'; |
|---|
| 86 |
echo '<td>'; |
|---|
| 87 |
switch ($c['type']) { |
|---|
| 88 |
case CONF_TYPE_TEXT: |
|---|
| 89 |
case CONF_TYPE_DIR: |
|---|
| 90 |
case CONF_TYPE_INT: |
|---|
| 91 |
$readonly = $c['readonly'] ? 'readonly="readonly"' : ''; |
|---|
| 92 |
echo '<input class="valueinput" id="'.$c['keyword'].'" type="text" size="60" value="'.$amp_conf[$c['keyword']].'" data-valueinput-orig="'.$amp_conf[$c['keyword']].'" '.$readonly.'/>'; |
|---|
| 93 |
break; |
|---|
| 94 |
case CONF_TYPE_SELECT: |
|---|
| 95 |
echo '<select class="valueinput" id="'.$c['keyword'].'" data-valueinput-orig="'.$amp_conf[$c['keyword']].'">'; |
|---|
| 96 |
$opt = explode(',',$c['options']); |
|---|
| 97 |
foreach($opt as $o) { |
|---|
| 98 |
$selected = ($amp_conf[$c['keyword']] == $o) ? ' selected ' : ''; |
|---|
| 99 |
echo '<option value="'.$o.'"'.$selected.'>'.$o.'</option>'; |
|---|
| 100 |
} |
|---|
| 101 |
echo '</select>'; |
|---|
| 102 |
break; |
|---|
| 103 |
case CONF_TYPE_BOOL: |
|---|
| 104 |
?> |
|---|
| 105 |
<input class="valueinput" data-valueinput-orig="<?php echo $amp_conf[$c['keyword']] ? 1 : 0 ?>" id="<?php echo $c['keyword'] ?>-true" type="radio" name="<?php echo $c['keyword'] ?>" value="1" <?php echo $amp_conf[$c['keyword']]?"checked=\"yes\"":""?>/> |
|---|
| 106 |
<label for="<?php echo $c['keyword'] ?>-true"><?php echo _("True") ?></label> |
|---|
| 107 |
<input class="valueinput" data-valueinput-orig="<?php echo $amp_conf[$c['keyword']] ? 1 : 0 ?>" id="<?php echo $c['keyword'] ?>-false" type="radio" name="<?php echo $c['keyword'] ?>" value="0" <?php echo !$amp_conf[$c['keyword']]?"checked=\"yes\"":""?>/> |
|---|
| 108 |
<label for="<?php echo $c['keyword'] ?>-false"><?php echo _("False") ?></label> |
|---|
| 109 |
<?php |
|---|
| 110 |
break; |
|---|
| 111 |
} |
|---|
| 112 |
echo '</td>'; |
|---|
| 113 |
if(!$c['readonly']){ |
|---|
| 114 |
|
|---|
| 115 |
echo '<td><input type="image" class="adv_set_default" src="images/default-option.png" data-key="'.$c['keyword'].'" data-default="'.$c['defaultval'].'" title="'._('Revert to Default').'"' |
|---|
| 116 |
. 'data-type="' . (($c['type'] == CONF_TYPE_BOOL) ? 'BOOL' : '') . '" ' |
|---|
| 117 |
.'"></td>'; |
|---|
| 118 |
echo '<td class="savetd"><input type="image" class="save" src="images/accept.png" data-key="' |
|---|
| 119 |
. $c['keyword'] |
|---|
| 120 |
. '" title="' . _('Save') . '"' |
|---|
| 121 |
. 'data-type="' . (($c['type'] == CONF_TYPE_BOOL) ? 'BOOL' : '') . '" ' |
|---|
| 122 |
. '></td>'; |
|---|
| 123 |
} |
|---|
| 124 |
echo '</tr>'; |
|---|
| 125 |
} |
|---|
| 126 |
echo '</table>'; |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
echo "<br><br><br><br></div>"; |
|---|
| 130 |
|
|---|
| 131 |
?> |
|---|
| 132 |
|
|---|