| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
$getvars = array('action', 'keyword', 'value', 'send_reload'); |
|---|
| 4 |
foreach ($getvars as $v){ |
|---|
| 5 |
$var[$v] = isset($_POST[$v]) ? $_POST[$v] : 0; |
|---|
| 6 |
} |
|---|
| 7 |
|
|---|
| 8 |
if($var['action'] === 'setkey') { |
|---|
| 9 |
header("Content-type: application/json"); |
|---|
| 10 |
$keyword = $var['keyword']; |
|---|
| 11 |
if ($freepbx_conf->conf_setting_exists($keyword)) { |
|---|
| 12 |
$freepbx_conf->set_conf_values(array($keyword => trim($var['value'])),true); |
|---|
| 13 |
$status = $freepbx_conf->get_last_update_status(); |
|---|
| 14 |
if ($var['send_reload'] && $status[$keyword]['saved']) { |
|---|
| 15 |
ob_start(); |
|---|
| 16 |
include ('views/freepbx_reloadbar.php'); |
|---|
| 17 |
$status[$keyword]['reload_bar'] = ob_get_clean(); |
|---|
| 18 |
|
|---|
| 19 |
ob_start(); |
|---|
| 20 |
include ('views/freepbx_reload.php'); |
|---|
| 21 |
$status[$keyword]['reload_header'] = ob_get_clean(); |
|---|
| 22 |
} |
|---|
| 23 |
if ($status[$keyword]['saved']) { |
|---|
| 24 |
needreload(); |
|---|
| 25 |
} |
|---|
| 26 |
echo json_encode($status[$keyword]); |
|---|
| 27 |
} |
|---|
| 28 |
exit; |
|---|
| 29 |
} |
|---|
| 30 |
$amportal_canwrite = $freepbx_conf->amportal_canwrite() ? 'true' : 'false'; |
|---|
| 31 |
echo '<script type="text/javascript">'; |
|---|
| 32 |
echo 'can_write_amportalconf = ' . $amportal_canwrite . '; '; |
|---|
| 33 |
echo 'amportalconf_error = "' . _("You must run 'amportal restart' from the Linux command line before you can save setting here.") . '";'; |
|---|
| 34 |
echo 'msgUnsavedChanges = "' . _("You have un-saved changes, press OK to disregard changes and reload page or Cancel to abort.") . '";'; |
|---|
| 35 |
echo 'msgChangesRefresh = "' . _("Your Display settings have been changed, click on 'Refresh Page' to view the affects of your changes once you have saved other outstanding changes that are still un-confirmed.") . '";'; |
|---|
| 36 |
echo '</script>'; |
|---|
| 37 |
|
|---|
| 38 |
echo '<div id="main_page">'; |
|---|
| 39 |
echo "<h2>"._("FreePBX Advanced Settings")."</h2>"; |
|---|
| 40 |
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 'Display Detail Level' under Advanced Settings Details. The settings shown at higher levels are less commonly use and are more risky to change. Once changed you must save the setting by checking the green check box that appears. You can restore the default setting by clicking on the icon to the right of the values."); |
|---|
| 41 |
|
|---|
| 42 |
$conf = $freepbx_conf->get_conf_settings(); |
|---|
| 43 |
|
|---|
| 44 |
$display_level = $conf['AS_DISPLAY_DETAIL_LEVEL']['value']; |
|---|
| 45 |
$display_hidden = $conf['AS_DISPLAY_HIDDEN_SETTINGS']['value']; |
|---|
| 46 |
$display_readonly = $conf['AS_DISPLAY_READONLY_SETTINGS']['value']; |
|---|
| 47 |
$current_category = ''; |
|---|
| 48 |
$row = 0; |
|---|
| 49 |
|
|---|
| 50 |
echo '<input type="image" src="images/spinner.gif" style="display:none">'; |
|---|
| 51 |
echo '<table id="set_table">'; |
|---|
| 52 |
foreach ($conf as $c){ |
|---|
| 53 |
|
|---|
| 54 |
if ($c['level'] > $display_level || $c['hidden'] && !$display_hidden || $c['readonly'] && !$display_readonly) { |
|---|
| 55 |
continue; |
|---|
| 56 |
} |
|---|
| 57 |
if ($current_category != $c['category']) { |
|---|
| 58 |
$current_category = $c['category']; |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
// it's only purpose is to get the headings so they are not shaded and so the stripped shading |
|---|
| 62 |
// starts consistent for each section. |
|---|
| 63 |
// |
|---|
| 64 |
if ($row % 2) { |
|---|
| 65 |
|
|---|
| 66 |
echo '<tr></tr>'; |
|---|
| 67 |
$row++; |
|---|
| 68 |
} |
|---|
| 69 |
if ($c['module'] && extension_loaded('gettext') && is_dir("modules/".$c['module']."/i18n")) { |
|---|
| 70 |
bindtextdomain($c['module'],"modules/".$c['module']."/i18n"); |
|---|
| 71 |
bind_textdomain_codeset($c['module'], 'utf8'); |
|---|
| 72 |
$current_category_loc = dgettext($c['module'],$current_category); |
|---|
| 73 |
if ($current_category_loc == $current_category) { |
|---|
| 74 |
$current_cateogry_loc = _($current_category); |
|---|
| 75 |
} |
|---|
| 76 |
} else { |
|---|
| 77 |
$current_category_loc = _($current_category); |
|---|
| 78 |
} |
|---|
| 79 |
echo '<tr><td colspan="3"><br><h4 class="category">'._("$current_category_loc").'</h4></td></tr>'; |
|---|
| 80 |
$row++; |
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
$name_label_raw = $c['name']; |
|---|
| 84 |
if ($c['module'] && extension_loaded('gettext') && is_dir("modules/".$c['module']."/i18n")) { |
|---|
| 85 |
bindtextdomain($c['module'],"modules/".$c['module']."/i18n"); |
|---|
| 86 |
bind_textdomain_codeset($c['module'], 'utf8'); |
|---|
| 87 |
$name_label = dgettext($c['module'],$name_label_raw); |
|---|
| 88 |
if ($name_label == $name_label_raw) { |
|---|
| 89 |
$name_label = _($name_label_raw); |
|---|
| 90 |
} |
|---|
| 91 |
} else { |
|---|
| 92 |
$name_label = _($name_label_raw); |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
$row++; |
|---|
| 96 |
$dv = $c['type'] == CONF_TYPE_BOOL ? ($c['defaultval'] ? _("True") : _("False")) : $c['defaultval']; |
|---|
| 97 |
$default_val = $dv == '' ? _("No Default Provided") : sprintf(_("Default Value: %s"),$dv); |
|---|
| 98 |
if ($c['emptyok'] && $c['type'] != CONF_TYPE_BOOL && $c['type'] != CONF_TYPE_SELECT) { |
|---|
| 99 |
$default_val.= ', '._("field can be left blank"); |
|---|
| 100 |
} |
|---|
| 101 |
if ($c['type'] == CONF_TYPE_INT && $c['options']) { |
|---|
| 102 |
$range = explode(',',$c['options']); |
|---|
| 103 |
$default_val .= '<br />'.sprintf(_("Acceptable Values: %s - %s"),$range[0],$range[1]); |
|---|
| 104 |
} |
|---|
| 105 |
$default_val .= '<br />'.sprintf(_("Internal Name: %s"),$c['keyword']); |
|---|
| 106 |
echo '<tr><td><a href="javascript:void(null)" class="info">'.$name_label.'<span>'.$c['description'].'<br /><br >'.$default_val.'</span></a></td>'; |
|---|
| 107 |
echo '<td>'; |
|---|
| 108 |
switch ($c['type']) { |
|---|
| 109 |
case CONF_TYPE_TEXT: |
|---|
| 110 |
case CONF_TYPE_DIR: |
|---|
| 111 |
case CONF_TYPE_INT: |
|---|
| 112 |
$readonly = $c['readonly'] ? 'readonly="readonly"' : ''; |
|---|
| 113 |
echo '<input class="valueinput" id="'.$c['keyword'].'" type="text" size="60" value="'.$amp_conf[$c['keyword']].'" data-valueinput-orig="'.$amp_conf[$c['keyword']].'" '.$readonly.'/>'; |
|---|
| 114 |
break; |
|---|
| 115 |
case CONF_TYPE_SELECT: |
|---|
| 116 |
echo '<select class="valueinput" id="'.$c['keyword'].'" data-valueinput-orig="'.$amp_conf[$c['keyword']].'">'; |
|---|
| 117 |
$opt = explode(',',$c['options']); |
|---|
| 118 |
foreach($opt as $o) { |
|---|
| 119 |
$selected = ($amp_conf[$c['keyword']] == $o) ? ' selected ' : ''; |
|---|
| 120 |
echo '<option value="'.$o.'"'.$selected.'>'.$o.'</option>'; |
|---|
| 121 |
} |
|---|
| 122 |
echo '</select>'; |
|---|
| 123 |
break; |
|---|
| 124 |
case CONF_TYPE_BOOL: |
|---|
| 125 |
?> |
|---|
| 126 |
<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\"":""?>/> |
|---|
| 127 |
<label for="<?php echo $c['keyword'] ?>-true"><?php echo _("True") ?></label> |
|---|
| 128 |
<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\"":""?>/> |
|---|
| 129 |
<label for="<?php echo $c['keyword'] ?>-false"><?php echo _("False") ?></label> |
|---|
| 130 |
<?php |
|---|
| 131 |
break; |
|---|
| 132 |
} |
|---|
| 133 |
echo '</td>'; |
|---|
| 134 |
if(!$c['readonly']){ |
|---|
| 135 |
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').'"' |
|---|
| 136 |
. 'data-type="' . (($c['type'] == CONF_TYPE_BOOL) ? 'BOOL' : '') . '" ' |
|---|
| 137 |
.'"></td>'; |
|---|
| 138 |
echo '<td class="savetd"><input type="image" class="save" src="images/accept.png" data-key="' |
|---|
| 139 |
. $c['keyword'] |
|---|
| 140 |
. '" title="' . _('Save') . '"' |
|---|
| 141 |
. 'data-type="' . (($c['type'] == CONF_TYPE_BOOL) ? 'BOOL' : '') . '" ' |
|---|
| 142 |
. '></td>'; |
|---|
| 143 |
} |
|---|
| 144 |
echo '</tr>'; |
|---|
| 145 |
} |
|---|
| 146 |
echo '</table>'; |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
?> |
|---|
| 150 |
<br /><br /> <br /> |
|---|
| 151 |
<input type="button" id="page_reload" value="Refresh Page"/> |
|---|
| 152 |
<br /><br /><br /><br /></div> |
|---|
| 153 |
|
|---|
| 154 |
|
|---|