diff options
-rw-r--r-- | config/haproxy-devel/haproxy.xml | 6 | ||||
-rw-r--r-- | config/haproxy-devel/pkg/haproxy.inc | 2 | ||||
-rw-r--r-- | config/haproxy-devel/pkg/haproxy_gui.inc | 95 | ||||
-rw-r--r-- | config/haproxy-devel/pkg/haproxy_htmllist.inc | 53 | ||||
-rw-r--r-- | config/haproxy-devel/www/haproxy_listeners.php | 63 | ||||
-rw-r--r-- | config/haproxy-devel/www/haproxy_listeners_edit.php | 25 | ||||
-rw-r--r-- | config/haproxy-devel/www/haproxy_pools.php | 39 | ||||
-rw-r--r-- | config/haproxy-devel/www/widgets/widgets/haproxy.widget.php | 128 | ||||
-rw-r--r-- | config/tftp2/tftp.inc | 17 | ||||
-rw-r--r-- | config/tftp2/tftp.xml | 2 | ||||
-rw-r--r-- | config/tftp2/tftp_files.php | 14 | ||||
-rw-r--r-- | pkg_config.10.xml | 4 | ||||
-rw-r--r-- | pkg_config.8.xml | 4 | ||||
-rw-r--r-- | pkg_config.8.xml.amd64 | 4 |
14 files changed, 321 insertions, 135 deletions
diff --git a/config/haproxy-devel/haproxy.xml b/config/haproxy-devel/haproxy.xml index a096b850..68637209 100644 --- a/config/haproxy-devel/haproxy.xml +++ b/config/haproxy-devel/haproxy.xml @@ -42,7 +42,7 @@ ]]> </copyright> <name>haproxy</name> - <version>0.35</version> + <version>0.36</version> <title>HAProxy</title> <aftersaveredirect>/pkg_edit.php?xml=haproxy_pools.php</aftersaveredirect> <include_file>/usr/local/pkg/haproxy.inc</include_file> @@ -111,6 +111,10 @@ </additional_files_needed> <additional_files_needed> <prefix>/usr/local/pkg/</prefix> + <item>https://packages.pfsense.org/packages/config/haproxy-devel/pkg/haproxy_gui.inc</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> <item>https://packages.pfsense.org/packages/config/haproxy-devel/pkg/haproxy_socketinfo.inc</item> </additional_files_needed> <additional_files_needed> diff --git a/config/haproxy-devel/pkg/haproxy.inc b/config/haproxy-devel/pkg/haproxy.inc index 8dce42ee..c8a225a3 100644 --- a/config/haproxy-devel/pkg/haproxy.inc +++ b/config/haproxy-devel/pkg/haproxy.inc @@ -253,7 +253,7 @@ $a_action["use_server"] = array('name' => "Use Server", 'mode' => '', 'syntax' = 'server' => array('name'=>"server",'columnheader'=>"Server",'type'=>"select",'size'=>"50",'mask'=>'server') )); // -$a_action["custom"] = array('name' => "Custom", 'mode' => '', +$a_action["custom"] = array('name' => "Custom", 'mode' => '', 'syntax' => '{customaction}', 'fields' => array( array('name'=>"customaction",'columnheader'=>"Custom action",'type'=>"textbox",'size'=>"50",'mask'=>'freetext') )); diff --git a/config/haproxy-devel/pkg/haproxy_gui.inc b/config/haproxy-devel/pkg/haproxy_gui.inc new file mode 100644 index 00000000..8fbc0dd0 --- /dev/null +++ b/config/haproxy-devel/pkg/haproxy_gui.inc @@ -0,0 +1,95 @@ +<?php + +$haproxy_icons = array( + 'moveup' => array( + "faicon" => "fa-arrow-up", + "icon" => "icon_up.gif", + "iconsize" => 17), + 'movedown' => array( + "faicon" => "fa-arrow-down", + "icon" => "icon_down.gif", + "iconsize" => 17), + 'add' => array( + "faicon" => "fa-level-down", + "icon" => "icon_plus.gif", + "iconsize" => 17), + 'delete' => array( + "faicon" => "fa-trash", + "icon" => "icon_x.gif", + "iconsize" => 17), + 'edit' => array( + "faicon" => "fa-pencil", + "icon" => "icon_e.gif", + "iconsize" => 17), + 'clone' => array( + "faicon" => "fa-clone", + "icon" => "icon_plus.gif"), + 'acl' => array( + "faicon" => "fa-random", + "icon" => "icon_ts_rule.gif", + "iconsize" => 11), + 'cert' => array( + "faicon" => "fa-lock", + "icon" => "icon_frmfld_cert.png", + "iconsize" => 11), + 'advanced' => array( + "faicon" => "fa-cog", + "icon" => "icon_advanced.gif", + "iconsize" => 11), + 'enabled' => array( + "faicon" => "fa-check", + "icon" => "icon_pass.gif", + "iconsize" => 11), + 'disabled' => array( + "faicon" => "fa-ban", + "icon" => "icon_reject.gif", + "iconsize" => 11), + 'stats' => array( + "faicon" => "fa-tasks", + "icon" => "icon_log_s.gif", + "iconsize" => 11), + 'stop' => array( + "faicon" => "fa-stop-circle-o", + "icon" => "icon_service_stop.gif", + "iconsize" => 17), + 'start' => array( + "faicon" => "fa-play-circle", + "icon" => "icon_service_start.gif", + "iconsize" => 17), + 'up' => array( + "faicon" => "fa-check-circle", + "icon" => "icon_interface_up.gif", + "iconsize" => 11), + 'down' => array( + "faicon" => "fa-times-circle", + "icon" => "icon_interface_down.gif", + "iconsize" => 11), + 'resolvedns' => array( + "faicon" => "fa-info ", + "icon" => "icon_log.gif", + "iconsize" => 11) +); + +global $pf_version; +$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); + +function pf_version() { + global $pf_version; + return $pf_version; +} + +function haproxyicon($iconname, $title) { + global $g, $haproxy_icons; + $title = htmlspecialchars($title); + $title = str_replace("'", "'", $title); + + $faicon = $haproxy_icons[$iconname]["faicon"]; + if (pf_version() < "2.3") { + $icon = $haproxy_icons[$iconname]["icon"]; + $iconsize = $haproxy_icons[$iconname]["iconsize"]; + return "<img src='/themes/{$g['theme']}/images/icons/$icon' title='$title' width='$iconsize' height='$iconsize' border='0' />"; + } else { + return "<i class='fa $faicon' title='$title'></i>"; + } + +} diff --git a/config/haproxy-devel/pkg/haproxy_htmllist.inc b/config/haproxy-devel/pkg/haproxy_htmllist.inc index 7eaad023..70a53c86 100644 --- a/config/haproxy-devel/pkg/haproxy_htmllist.inc +++ b/config/haproxy-devel/pkg/haproxy_htmllist.inc @@ -33,6 +33,7 @@ require_once("config.inc"); require_once("haproxy_utils.inc"); +require_once("haproxy_gui.inc"); class HaproxyHtmlList { @@ -42,8 +43,8 @@ class HaproxyHtmlList <tableId>_field_changed(tableId, rowNr, fieldId, field) */ - private $tablename = ""; - private $fields = array(); + public $tablename = ""; + public $fields = array(); public $editmode = false; public $fields_details = null; public $keyfield = ""; @@ -193,20 +194,20 @@ class HaproxyHtmlList <td class='list'> <table border='0' cellspacing='0' cellpadding='1'><tr> <td valign='middle'> - <img src='/themes/{$g['theme']}/images/icons/icon_e.gif' title='edit entry' width='17' height='17' border='0' onclick='editRow({$counter}); return false;' /> + <a onclick='editRow({$counter}); return false;'>".haproxyicon('edit','edit entry')."</a> </td> <td valign='middle'> - <img src='/themes/{$g['theme']}/images/icons/icon_x.gif' title='delete entry' width='17' height='17' border='0' onclick='deleteRow({$counter}, \"{$tablename}\"); return false;' /> + <a onclick='deleteRow({$counter}, \"{$tablename}\"); return false;'>".haproxyicon('delete','delete entry')."</a> </td> <td valign='middle'> - <img src='/themes/{$g['theme']}/images/icons/icon_plus.gif' title='duplicate entry' width='17' height='17' border='0' onclick='dupRow({$counter}, \"{$tablename}\"); return false;' /> + <a onclick='dupRow({$counter}, \"{$tablename}\"); return false;'>".haproxyicon('clone','duplicate entry')."</a> </td>"; if (empty($this->noindex)) { echo "<td valign='middle'> - <img src='/themes/{$g['theme']}/images/icons/icon_up.gif' title='move row up' width='17' height='17' border='0' onclick='moveRowUp({$counter}, \"{$tablename}\"); return false;' /> + <a onclick='moveRowUp({$counter}, \"{$tablename}\"); return false;'>".haproxyicon('moveup','move row up')."</a> </td> <td valign='middle'> - <img src='/themes/{$g['theme']}/images/icons/icon_down.gif' title='move row down' width='17' height='17' border='0' onclick='moveRowDown({$counter}, \"{$tablename}\"); return false;' /> + <a onclick='moveRowDown({$counter}, \"{$tablename}\"); return false;'>".haproxyicon('movedown','move row down')."</a> </td>"; } echo "</tr></table> @@ -232,17 +233,17 @@ class HaproxyHtmlList <table border='0' cellspacing='0' cellpadding='1'><tr> <td valign='middle'> <input name='{$tablename}_rowindex{$counter}' id='{$tablename}_rowindex{$counter}' type='hidden' value='{$counter}' /> - <img src='/themes/{$g['theme']}/images/icons/icon_x.gif' title='delete entry' width='17' height='17' border='0' onclick='deleteRow({$counter}, \"{$tablename}\"); return false;' /> + <a onclick='deleteRow({$counter}, \"{$tablename}\"); return false;' >".haproxyicon('delete','delete entry')."</a> </td> <td valign='middle'> - <img src='/themes/{$g['theme']}/images/icons/icon_plus.gif' title='duplicate entry' width='17' height='17' border='0' onclick='dupRow({$counter}, \"{$tablename}\"); return false;' /> + <a onclick='dupRow({$counter}, \"{$tablename}\"); return false;' />".haproxyicon('clone','duplicate entry')."</a> </td>"; if (empty($this->noindex)) { echo "<td valign='middle'> - <img src='/themes/{$g['theme']}/images/icons/icon_up.gif' title='move row up' width='17' height='17' border='0' onclick='moveRowUp({$counter}, \"{$tablename}\"); return false;' /> + <a onclick='moveRowUp({$counter}, \"{$tablename}\"); return false;' />".haproxyicon('moveup','move row up')."</a> </td> <td valign='middle'> - <img src='/themes/{$g['theme']}/images/icons/icon_down.gif' title='move row down' width='17' height='17' border='0' onclick='moveRowDown({$counter}, \"{$tablename}\"); return false;' /> + <a onclick='moveRowDown({$counter}, \"{$tablename}\"); return false;' />".haproxyicon('movedown','move row down')."</a> </td>"; } echo "</tr></table> @@ -269,7 +270,13 @@ class HaproxyHtmlList foreach($itemdetails as $item) { $itemname = $item['name']; $itemvalue = $value[$itemname]; - //TODO don't filter empty items, filter context un-related items through customizable function.. + if ($this->fields_details_showfieldfunction != null) { + // filter context un-related items through customizable function. + $fn = &$this->fields_details_showfieldfunction; + if ($fn($this, $itemname, $value) == false) { + continue; + } + } else if (empty($itemvalue)) { continue; } @@ -322,7 +329,7 @@ class HaproxyHtmlList echo "</tbody> </table> <a onclick='javascript:addRowTo(\"{$tablename}\"); return false;' href='#'> - <img border='0' src='/themes/{$g['theme']}/images/icons/icon_plus.gif' alt='' title='add another entry' /> + ".haproxyicon('add','add another entry')." </a>"; } } @@ -439,12 +446,12 @@ function haproxy_htmllist_js(){ btd.setAttribute("valign", "middle"); btd.innerHTML = '<input name="'+tableId+'_rowindex'+totalrows+'" id="'+tableId+'_rowindex'+totalrows+'" type="hidden" value="'+totalrows+'" />' + - '<img src="/themes/' + theme + '/images/icons/icon_x.gif" title="delete entry" width="17" height="17" border="0" onclick="deleteRow(' + totalrows + ", '" + tableId + "'); return false;\" />"; + '<a onclick="deleteRow(' + totalrows + ", '" + tableId + "'); return false;\" ><?=haproxyicon('delete','delete entry')?></a>"; btr.appendChild(btd); btd = document.createElement("td"); btd.setAttribute("valign", "middle"); - btd.innerHTML = '<img src="/themes/' + theme + "/images/icons/icon_plus.gif\" title=\"duplicate entry\" width=\"17\" height=\"17\" border=\"0\" onclick=\"dupRow(" + totalrows + ", '" + tableId + "'); return false;\" />"; + btd.innerHTML = '<a onclick=\"dupRow(' + totalrows + ", '" + tableId + "'); return false;\" ><?=haproxyicon('clone','duplicate entry')?></a>"; btr.appendChild(btd); @@ -452,12 +459,12 @@ function haproxy_htmllist_js(){ if (tabledefinition && tabledefinition['keyfield'] == "") { btd = document.createElement("td"); btd.setAttribute("valign", "middle"); - btd.innerHTML = '<img src="/themes/' + theme + "/images/icons/icon_up.gif\" title=\"move entry up\" width=\"17\" height=\"17\" border=\"0\" onclick=\"moveRowUp(" + totalrows + ", '" + tableId + "'); return false;\" />"; + btd.innerHTML = '<a onclick=\"moveRowUp(' + totalrows + ", '" + tableId + "'); return false;\" ><?=haproxyicon('moveup','move row up')?></a>"; btr.appendChild(btd); btd = document.createElement("td"); btd.setAttribute("valign", "middle"); - btd.innerHTML = '<img src="/themes/' + theme + "/images/icons/icon_down.gif\" title=\"move entry down\" width=\"17\" height=\"17\" border=\"0\" onclick=\"moveRowDown(" + totalrows + ", '" + tableId + "'); return false;\" />"; + btd.innerHTML = '<a onclick=\"moveRowDown(' + totalrows + ", '" + tableId + "'); return false;\" ><?=haproxyicon('movedown','move row down')?></a>"; btr.appendChild(btd); } @@ -488,7 +495,10 @@ function haproxy_htmllist_js(){ subtr.appendChild(subtd); subtd = d.createElement("td"); subtd.setAttribute("class","vncell"); - subtd.innerHTML = field['description'] + "<br/>" + fieldhtml; + if (field['description']) { + fieldhtml = field['description'] + "<br/>" + fieldhtml; + } + subtd.innerHTML = fieldhtml; subtr.appendChild(subtd); table.appendChild(subtr); } @@ -539,6 +549,13 @@ function haproxy_htmllist_js(){ if (typeof fn === 'function'){ fn(tableId, totalrows); } + + // show/hide conditional fields if applicable using a custom function. + javascript_event = tableId + "_listitem_change"; + var fn = window[javascript_event]; + if (typeof fn === 'function'){ + fn(tableId, "toggle_details", totalrows, null); + } } function editRow(num) { var trview = document.getElementById('tr_view_' + num); diff --git a/config/haproxy-devel/www/haproxy_listeners.php b/config/haproxy-devel/www/haproxy_listeners.php index c7288e7d..35d9ba54 100644 --- a/config/haproxy-devel/www/haproxy_listeners.php +++ b/config/haproxy-devel/www/haproxy_listeners.php @@ -35,6 +35,7 @@ require_once("haproxy.inc"); require_once("certs.inc"); require_once("haproxy_utils.inc"); require_once("pkg_haproxy_tabs.inc"); +require_once("haproxy_gui.inc"); $changedesc = "Services: HAProxy: Frontends"; @@ -85,7 +86,8 @@ if ($_GET['act'] == "del") { if (isset($a_frontend[$id])) { if (!$input_errors) { unset($a_frontend[$id]); - write_config(); + $changedesc .= " Frontend delete"; + write_config($changedesc); touch($d_haproxyconfdirty_path); } header("Location: haproxy_listeners.php"); @@ -132,23 +134,24 @@ echo "<br/></div>"; ?> <script type="text/javascript" language="javascript" src="/javascript/haproxy_geturl.js"></script> <script language="javascript"> -function toggle_on(button, image) { - var item = document.getElementById(button); - item.src = image; +function set_content(elementid, image) { + var item = document.getElementById(elementid); + item.innerHTML = image; } function js_callback(req) { showapplysettings.style.display = 'block'; + if(req.content != '') { var itemsplit = req.content.split("|"); buttonid = itemsplit[0]; enabled = itemsplit[1]; if (enabled == 1){ - img = 'pass'; + img = "<?=haproxyicon("enabled", gettext("click to toggle enable/disable this frontend"))?>"; } else { - img = 'reject'; + img = "<?=haproxyicon("disabled", gettext("click to toggle enable/disable this frontend"))?>"; } - toggle_on('btn_'+buttonid, './themes/<?=$g['theme'];?>/images/icons/icon_'+img+'.gif'); + set_content('btn_'+buttonid, img); } } </script> @@ -197,9 +200,6 @@ function js_callback(req) { } ksort($a_frontend_grouped); - $img_cert = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png"; - $img_adv = "/themes/{$g['theme']}/images/icons/icon_advanced.gif"; - $img_acl = "/themes/{$g['theme']}/images/icons/icon_ts_rule.gif"; $textgray = ""; $first = true; $last_frontend_shared = false; @@ -218,13 +218,12 @@ function js_callback(req) { <td class="listlr" ondblclick="document.location='haproxy_listeners_edit.php?id=<?=$frontendname;?>';"> <? if ($frontend['status']=='disabled'){ - $iconfn = "reject"; + $iconfn = "disabled"; } else { - $iconfn = "pass"; + $iconfn = "enabled"; }?> - <a href='javascript:getURL("?id=<?=$frontendname;?>&action=toggle&", js_callback);'> - <img id="btn_<?=$frontendname;?>" src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0" - title="<?=gettext("click to toggle enable/disable this frontend");?>" alt="icon" /> + <a id="btn_<?=$frontendname;?>" href='javascript:getURL("?id=<?=$frontendname;?>&action=toggle&", js_callback);'> + <?=haproxyicon($iconfn, gettext("click to toggle enable/disable this frontend"))?> </a> </td> <td class="listr" style="<?=$frontend['secondary']=='yes'?"visibility:hidden;":""?>" ondblclick="document.location='haproxy_listeners_edit.php?id=<?=$frontendname;?>';"> @@ -235,11 +234,12 @@ function js_callback(req) { $acls = get_frontend_acls($frontend); $isaclset = ""; foreach ($acls as $acl) { - $isaclset .= " " . htmlspecialchars($acl['descr']); + $isaclset .= "\n" . htmlspecialchars($acl['descr']); + } + if ($isaclset) { + echo haproxyicon("acl", gettext("acl's used") . ": {$isaclset}"); } - if ($isaclset) - echo "<img src=\"$img_acl\" title=\"" . gettext("acl's used") . ": {$isaclset}\" border=\"0\" />"; - + if (get_frontend_uses_ssl($frontend)) { $cert = lookup_cert($frontend['ssloffloadcert']); $descr = htmlspecialchars($cert['descr']); @@ -252,14 +252,15 @@ function js_callback(req) { } } } - echo '<img src="'.$img_cert.'" title="SSL offloading cert: '.$descr.'" alt="SSL offloading" border="0" height="16" width="16" />'; + echo haproxyicon("cert", "SSL offloading cert: {$descr}"); } $isadvset = ""; if ($frontend['advanced_bind']) $isadvset .= "Advanced bind: ".htmlspecialchars($frontend['advanced_bind'])."\r\n"; if ($frontend['advanced']) $isadvset .= "Advanced pass thru setting used\r\n"; - if ($isadvset) - echo "<img src=\"$img_adv\" title=\"" . gettext("Advanced settings set") . ": {$isadvset}\" border=\"0\" />"; + if ($isadvset) { + echo haproxyicon("advanced", gettext("Advanced settings set") . ": {$isadvset}"); + } ?> </td> <td class="listr" ondblclick="document.location='haproxy_listeners_edit.php?id=<?=$frontendname;?>';"> @@ -277,7 +278,7 @@ function js_callback(req) { print "<div style='white-space:nowrap;'>"; print "{$addr['addr']}:{$addr['port']}"; if ($addr['ssl'] == 'yes') { - echo '<img src="'.$img_cert.'" title="SSL offloading" alt="SSL" border="0" height="11" width="11" />'; + echo haproxyicon("cert", "SSL offloading"); } print "</div"; $first = false; @@ -327,9 +328,15 @@ function js_callback(req) { <td class="list" nowrap> <table border="0" cellspacing="0" cellpadding="1"> <tr> - <td valign="middle"><a href="haproxy_listeners_edit.php?id=<?=$frontendname;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit frontend");?>" width="17" height="17" border="0" /></a></td> - <td valign="middle"><a href="haproxy_listeners.php?act=del&id=<?=$frontendname;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete frontend");?>" width="17" height="17" border="0" /></a></td> - <td valign="middle"><a href="haproxy_listeners_edit.php?dup=<?=$frontendname;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("clone frontend");?>" width="17" height="17" border="0" /></a></td> + <td valign="middle"><a href="haproxy_listeners_edit.php?id=<?=$frontendname;?>"> + <?=haproxyicon("edit", gettext("edit frontend"))?> + </a></td> + <td valign="middle"><a href="haproxy_listeners.php?act=del&id=<?=$frontendname;?>" onclick="return confirm('Do you really want to delete this entry?')"> + <?=haproxyicon("delete", gettext("delete frontend"))?> + </a></td> + <td valign="middle"><a href="haproxy_listeners_edit.php?dup=<?=$frontendname;?>"> + <?=haproxyicon("clone", gettext("clone frontend"))?> + </a></td> </tr> </table> </td> @@ -342,7 +349,9 @@ function js_callback(req) { <td class="list"> <table border="0" cellspacing="0" cellpadding="1"> <tr> - <td valign="middle"><a href="haproxy_listeners_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add new frontend");?>" width="17" height="17" border="0" /></a></td> + <td valign="middle"><a href="haproxy_listeners_edit.php"> + <?=haproxyicon("add", gettext("add new frontend"))?> + </a></td> </tr> </table> </td> diff --git a/config/haproxy-devel/www/haproxy_listeners_edit.php b/config/haproxy-devel/www/haproxy_listeners_edit.php index f26341b2..8c37332e 100644 --- a/config/haproxy-devel/www/haproxy_listeners_edit.php +++ b/config/haproxy-devel/www/haproxy_listeners_edit.php @@ -251,14 +251,33 @@ function customdrawcell_actions($object, $item, $itemvalue, $editable, $itemname $htmllist_extaddr = new HaproxyHtmlList("table_extaddr", $fields_externalAddress); $htmllist_extaddr->editmode = true; +function fields_details_showfieldfunction($items, $action, $itemname) { + if (is_array($items[$action]) && is_array($items[$action]['fields'])) { + foreach($items[$action]['fields'] as $item) { + if ($action . "" . $item['name'] == $itemname) { + return true; + } + } + } + return false; +} +function fields_acls_details_showfieldfunction($htmltable, $itemname, $values) { + $items = $htmltable->fields[1]['items']; + $action = $values['expression']; + return fields_details_showfieldfunction($items, $action, $itemname); +} $htmllist_acls = new HaproxyHtmlList("table_acls", $fields_aclSelectionList); $htmllist_acls->fields_details = $fields_acl_details; -//$htmllist_acls->editmode = true; +$htmllist_acls->fields_details_showfieldfunction = fields_acls_details_showfieldfunction; +function fields_actions_details_showfieldfunction($htmltable, $itemname, $values) { + $items = $htmltable->fields[0]['items']; + $action = $values['action']; + return fields_details_showfieldfunction($items, $action, $itemname); +} $htmllist_actions = new HaproxyHtmlList("table_actions", $fields_actions); $htmllist_actions->fields_details = $fields_actions_details; -//$htmllist_actions->keyfield = "name"; -//$htmllist_actions->editmode = true; +$htmllist_actions->fields_details_showfieldfunction = fields_actions_details_showfieldfunction; $htmllist_sslCertificates = new HaproxyHtmlList("tbl_sslCerts", $fields_sslCertificates); $htmllist_caCertificates = new HaproxyHtmlList("tbl_caCerts", $fields_caCertificates ); diff --git a/config/haproxy-devel/www/haproxy_pools.php b/config/haproxy-devel/www/haproxy_pools.php index d98c7f41..ef1768db 100644 --- a/config/haproxy-devel/www/haproxy_pools.php +++ b/config/haproxy-devel/www/haproxy_pools.php @@ -33,7 +33,7 @@ $shortcut_section = "haproxy"; require_once("guiconfig.inc"); require_once("haproxy.inc"); require_once("pkg_haproxy_tabs.inc"); - +require_once("haproxy_gui.inc"); if (!is_array($config['installedpackages']['haproxy']['ha_pools']['item'])) { $config['installedpackages']['haproxy']['ha_pools']['item'] = array(); @@ -58,7 +58,7 @@ if ($_POST) { if ($_GET['act'] == "del") { if (isset($a_pools[$_GET['id']])) { unset($a_pools[$_GET['id']]); - write_config(); + write_config("Services: HAProxy: Backend delete"); touch($d_haproxyconfdirty_path); } header("Location: haproxy_pools.php"); @@ -97,7 +97,6 @@ haproxy_css(); <td width="10%" class="list"></td> </tr> <?php - $img_adv = "/themes/{$g['theme']}/images/icons/icon_advanced.gif"; $i = 0; foreach ($a_pools as $pool){ $fe_list = ""; @@ -131,14 +130,19 @@ haproxy_css(); <tr class="<?=$textgray?>"> <td class="listlr" ondblclick="document.location='haproxy_pool_edit.php?id=<?=$i;?>';"> <? - if ($pool['stats_enabled']=='yes'){ - echo "<img src=\"./themes/{$g['theme']}/images/icons/icon_log_s.gif\"" . ' title="stats enabled" width="11" height="15" border="0" />'; + if ($pool['stats_enabled']=='yes') { + echo haproxyicon("stats", gettext("stats enabled")); } $isadvset = ""; - if ($pool['advanced']) $isadvset .= "Per server pass thru\r\n"; - if ($pool['advanced_backend']) $isadvset .= "Backend pass thru\r\n"; - if ($isadvset) - echo "<img src=\"$img_adv\" title=\"" . gettext("advanced settings set") . ": {$isadvset}\" border=\"0\" />"; + if ($pool['advanced']) { + $isadvset .= "Per server pass thru\r\n"; + } + if ($pool['advanced_backend']) { + $isadvset .= "Backend pass thru\r\n"; + } + if ($isadvset) { + echo haproxyicon("advanced", gettext("advanced settings set") . ": {$isadvset}"); + } ?> </td> <td class="listlr" ondblclick="document.location='haproxy_pool_edit.php?id=<?=$i;?>';"> @@ -156,9 +160,15 @@ haproxy_css(); <td class="list" nowrap> <table border="0" cellspacing="0" cellpadding="1"> <tr> - <td valign="middle"><a href="haproxy_pool_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit backend");?>" width="17" height="17" border="0" /></a></td> - <td valign="middle"><a href="haproxy_pools.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete backend");?>" width="17" height="17" border="0" /></a></td> - <td valign="middle"><a href="haproxy_pool_edit.php?dup=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("clone backend");?>" width="17" height="17" border="0" /></a></td> + <td valign="middle"><a href="haproxy_pool_edit.php?id=<?=$i;?>"> + <?=haproxyicon("edit", gettext("edit backend"))?> + </a></td> + <td valign="middle"><a href="haproxy_pools.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"> + <?=haproxyicon("delete", gettext("delete backend"))?> + </a></td> + <td valign="middle"><a href="haproxy_pool_edit.php?dup=<?=$i;?>"> + <?=haproxyicon("clone", gettext("clone backend"))?> + </a></td> </tr> </table> </td> @@ -173,7 +183,10 @@ haproxy_css(); <td class="list"> <table border="0" cellspacing="0" cellpadding="1"> <tr> - <td valign="middle"><a href="haproxy_pool_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add new backend");?>" width="17" height="17" border="0" /></a></td> + <td valign="middle"> + <a href="haproxy_pool_edit.php"> + <?=haproxyicon("add", gettext("add new backend"))?> + </a></td> </tr> </table> </td> diff --git a/config/haproxy-devel/www/widgets/widgets/haproxy.widget.php b/config/haproxy-devel/www/widgets/widgets/haproxy.widget.php index 5d664e81..92fd9025 100644 --- a/config/haproxy-devel/www/widgets/widgets/haproxy.widget.php +++ b/config/haproxy-devel/www/widgets/widgets/haproxy.widget.php @@ -30,10 +30,15 @@ Some mods made from pfBlocker widget to make this for HAProxy on Pfsense Copyleft 2012 by jvorhees */ + +$nocsrf = true; + require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("functions.inc"); require_once("haproxy_socketinfo.inc"); +require_once("haproxy_gui.inc"); + $first_time = false; if (!is_array($config["widgets"]["haproxy"])) { $first_time = true; @@ -59,7 +64,7 @@ if ($_POST) { foreach($simplefields as $fieldname) $a_config[$fieldname] = $_POST[$fieldname]; - write_config("Updated traffic graph settings via dashboard."); + write_config("Services: HAProxy: Widget: Updated settings via dashboard."); header("Location: /"); exit(0); } @@ -77,13 +82,13 @@ $show_frontends = $a_config['haproxy_widget_showfrontends']=='yes'; $show_clients = $a_config['haproxy_widget_showclients']=='yes'; $show_clients_traffic = $a_config['haproxy_widget_showclienttraffic']=='yes'; -$out="<img src ='/themes/{$g['theme']}/images/icons/icon_interface_down.gif'>"; -$in="<img src ='/themes/{$g['theme']}/images/icons/icon_interface_up.gif'>"; -$running="<img src ='/themes/{$g['theme']}/images/icons/icon_pass.gif'>"; -$stopped="<img src ='/themes/{$g['theme']}/images/icons/icon_block.gif'>"; -$log="<img src ='/themes/{$g['theme']}/images/icons/icon_log.gif'>"; -$start="<img src ='/themes/{$g['theme']}/images/icons/icon_service_start.gif' title='Enable this backend/server'>"; -$stop="<img src ='/themes/{$g['theme']}/images/icons/icon_service_stop.gif' title='Disable this backend/server'>"; +$out = haproxyicon("down", ""); +$in = haproxyicon("up", ""); +$running = haproxyicon("enabled", ""); +$stopped = haproxyicon("disabled", ""); +$log = haproxyicon("resolvedns", ""); +$start = haproxyicon("start","Enable this backend/server"); +$stop = haproxyicon("stop","Disable this backend/server"); $clients=array(); $clientstraffic=array(); @@ -98,35 +103,11 @@ if ($show_clients == "YES") { } if (!$getupdatestatus) { ?> -<div id="haproxy-settings" name="haproxy-settings" class="widgetconfigdiv" style="display:none;"> -<form action="/widgets/widgets/haproxy.widget.php" method="post" name="iform" id="iform"> - <table> - <tr><td> - Refresh Interval:</td><td> - <input id="haproxy_widget_timer" name="haproxy_widget_timer" type="text" value="<?=$a_config['haproxy_widget_timer']?>"/></td> - </tr><tr> - <td>Show frontends:</td><td> - <input id="haproxy_widget_showfrontends" name="haproxy_widget_showfrontends" type="checkbox" value="yes" <?php if ($a_config['haproxy_widget_showfrontends']=='yes') echo "checked"; ?>/></td> - </tr><tr> - <td>Show clients:</td> - <td><input id="haproxy_widget_showclients" name="haproxy_widget_showclients" type="checkbox" value="yes" <?php if ($a_config['haproxy_widget_showclients']=='yes') echo "checked"; ?>/> - Note: showing clients increases CPU/memory usage. - </td> - </tr><tr> - <td>Show client traffic:</td> - <td><input id="haproxy_widget_showclienttraffic" name="haproxy_widget_showclienttraffic" type="checkbox" value="yes" <?php if ($a_config['haproxy_widget_showclienttraffic']=='yes') echo "checked"; ?>/> - Note: showing client traffic considerably increases CPU/memory usage. - </td> - </tr></table> - <br> - <input id="submit" name="submit" type="submit" onclick="return updatePref();" class="formbtn" value="Save Settings" /> -</form> -</div> -<div name="haproxy_content" id="haproxy_content"> +<div id="haproxy_content"> <? } -echo "<table style=\"padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\""; +echo "<table style=\"padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"; #Frontends if ($show_frontends == "YES") { print "<tr><td class=\"widgetsubheader\" colspan=\"4\"><strong>FrontEnd(s)</strong></td></tr>"; @@ -236,7 +217,17 @@ if (!$getupdatestatus) { echo "</div>"; ?> -<script language="javascript" type="text/javascript"> +<? +} + +if ($getupdatestatus) { + exit; +} +?> +</div> + +<script type="text/javascript" src="/javascript/haproxy_geturl.js"></script> +<script type="text/javascript"> d = document; selectIntLink = "haproxy-configure"; textlink = d.getElementById(selectIntLink); @@ -246,37 +237,54 @@ if (!$getupdatestatus) function getstatusgetupdate() { var url = "/widgets/widgets/haproxy.widget.php"; var pars = 'getupdatestatus=yes'; - var myAjax = new Ajax.Request( - url, - { - method: 'get', - parameters: pars, - onComplete: activitycallback_haproxy - }); + getURL(url+"?"+pars, activitycallback_haproxy); } function getstatus_haproxy() { + setTimeout(getstatus_haproxy, <?= $refresh_rate ?>); getstatusgetupdate(); - setTimeout('getstatus_haproxy()', <?= $refresh_rate ?>); + } function activitycallback_haproxy(transport) { - $('haproxy_content').innerHTML = transport.responseText; + if ($('haproxy_content').innerHTML) { + $('haproxy_content').innerHTML = transport.content; + } else { + $('#haproxy_content').html(transport.content); + } + } + setTimeout(getstatus_haproxy, <?= $refresh_rate ?>); + + function control_haproxy(act,be,srv) { + var url = "/widgets/widgets/haproxy.widget.php"; + var pars = 'act='+act+'&be='+be+'&srv='+srv; + getURL(url+"?"+pars, getstatusgetupdate); } - setTimeout('getstatus_haproxy()', <?= $refresh_rate ?>); -</script> -<script type="text/javascript"> - function control_haproxy(act,be,srv) { - var url = "/widgets/widgets/haproxy.widget.php"; - var pars = 'act='+act+'&be='+be+'&srv='+srv; - var myAjax = new Ajax.Request( - url, - { - method: 'get', - parameters: pars, - //onComplete: activitycallback_haproxy - onComplete: getstatusgetupdate - }); - } </script> <? +if (pf_version() < "2.3") { + echo '<div id="haproxy-settings" class="widgetconfigdiv" style="display:none;">'; +} else { + echo '<div id="widget-haproxy_panel-footer" class="panel-footer collapse">'; } -?>
\ No newline at end of file +?> +<form action="/widgets/widgets/haproxy.widget.php" method="post" name="iform" id="iform"> + <table> + <tr><td> + Refresh Interval:</td><td> + <input id="haproxy_widget_timer" name="haproxy_widget_timer" type="text" value="<?=$a_config['haproxy_widget_timer']?>"/></td> + </tr><tr> + <td>Show frontends:</td><td> + <input id="haproxy_widget_showfrontends" name="haproxy_widget_showfrontends" type="checkbox" value="yes" <?php if ($a_config['haproxy_widget_showfrontends']=='yes') echo "checked"; ?>/></td> + </tr><tr> + <td>Show clients:</td> + <td><input id="haproxy_widget_showclients" name="haproxy_widget_showclients" type="checkbox" value="yes" <?php if ($a_config['haproxy_widget_showclients']=='yes') echo "checked"; ?>/> + Note: showing clients increases CPU/memory usage. + </td> + </tr><tr> + <td>Show client traffic:</td> + <td><input id="haproxy_widget_showclienttraffic" name="haproxy_widget_showclienttraffic" type="checkbox" value="yes" <?php if ($a_config['haproxy_widget_showclienttraffic']=='yes') echo "checked"; ?>/> + Note: showing client traffic considerably increases CPU/memory usage. + </td> + </tr></table> + <br> + <input id="submit" name="submit" type="submit" onclick="return updatePref();" class="formbtn" value="Save Settings" /> +</form> diff --git a/config/tftp2/tftp.inc b/config/tftp2/tftp.inc index baf753c9..7ad4ab1b 100644 --- a/config/tftp2/tftp.inc +++ b/config/tftp2/tftp.inc @@ -41,6 +41,19 @@ function tftp_byte_convert($bytes) { return round($bytes/pow($convention, $e), 2) . ' ' . $s[$e]; } +function tftp_dir_contains_files($dir) { + if (!is_readable($dir)) { + return NULL; + } + $handle = opendir($dir); + while (false !== ($entry = readdir($handle))) { + if ($entry != "." && $entry != "..") { + return TRUE; + } + } + return FALSE; +} + function tftp_install_command() { global $config; @@ -54,7 +67,9 @@ function tftp_install_command() { // Restore backup if it exists if (file_exists($tftpbackup)) { mwexec("/usr/bin/tar xvpfz {$tftpbackup} -C /"); - mwexec("/bin/chmod -R 0744 {$tftpdir}/*"); + if (tftp_dir_contains_files($tftpdir)) { + mwexec("/bin/chmod -R 0744 {$tftpdir}/*"); + } } unset($tftpdir, $tftpbackup); } diff --git a/config/tftp2/tftp.xml b/config/tftp2/tftp.xml index 350999dd..7e5b9746 100644 --- a/config/tftp2/tftp.xml +++ b/config/tftp2/tftp.xml @@ -43,7 +43,7 @@ ]]> </copyright> <name>tftpsettings</name> - <version>2.2.4</version> + <version>2.2.5</version> <title>TFTP: Settings</title> <include_file>/usr/local/pkg/tftp.inc</include_file> <menu> diff --git a/config/tftp2/tftp_files.php b/config/tftp2/tftp_files.php index 4cb34024..cc2947bc 100644 --- a/config/tftp2/tftp_files.php +++ b/config/tftp2/tftp_files.php @@ -76,7 +76,9 @@ if ($_GET['a'] == "other") { //echo "The file $filename exists"; conf_mount_rw(); mwexec("/usr/bin/tar -xpzC / -f {$backup_path}"); - mwexec("/bin/chmod -R 744 {$files_dir}/*"); + if (tftp_dir_contains_files($files_dir)) { + mwexec("/bin/chmod -R 744 {$files_dir}/*"); + } header( 'Location: tftp_files.php?savemsg=Backup+has+been+restored.' ) ; conf_mount_ro(); } else { @@ -92,7 +94,9 @@ if ($_POST['submit'] == "Save") { write_config(); send_event("filter reload"); } else { - unset($config['installedpackages']['tftpd']['config'][0]['tftpdinterface']); + if (isset($config['installedpackages']['tftpd']['config'][0]['tftpdinterface'])) { + unset($config['installedpackages']['tftpd']['config'][0]['tftpdinterface']); + } write_config(); send_event("filter reload"); } @@ -102,7 +106,9 @@ if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_na conf_mount_rw(); move_uploaded_file($_FILES['ulfile']['tmp_name'], "{$files_dir}/{$_FILES['ulfile']['name']}"); $savemsg = "Uploaded file to {$files_dir}/" . htmlentities($_FILES['ulfile']['name']); - mwexec('/bin/chmod -R 744 {$files_dir}/*'); + if (tftp_dir_contains_files($files_dir)) { + mwexec('/bin/chmod -R 744 {$files_dir}/*'); + } unset($_POST['txtCommand']); conf_mount_ro(); } @@ -195,7 +201,7 @@ if ($savemsg) { <tr> <td width="25%" class="listhdrr">File Name (download)</td> <td width="50%" class="listhdr">Last Modified</td> - <td width="50%" class="listhdr">Size</td> + <td width="25%" class="listhdr">Size</td> </tr> <?php diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 980a529d..95f9d04a 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -172,7 +172,7 @@ </descr> <website>http://haproxy.1wt.eu/</website> <category>Services</category> - <version>0.35</version> + <version>0.36</version> <status>RELEASE</status> <required_version>2.2</required_version> <config_file>https://packages.pfsense.org/packages/config/haproxy-devel/haproxy.xml</config_file> @@ -337,7 +337,7 @@ <pkginfolink/> <port_category>ftp</port_category> <config_file>https://packages.pfsense.org/packages/config/tftp2/tftp.xml</config_file> - <version>2.2.4</version> + <version>2.2.5</version> <status>RELEASE</status> <required_version>2.2</required_version> <configurationfile>tftp.xml</configurationfile> diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 398d172b..3d5d803e 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -177,7 +177,7 @@ Supports ACLs for smart backend switching.]]></descr> <website>http://haproxy.1wt.eu/</website> <category>Services</category> - <version>1.5.3 pkg v 0.35</version> + <version>1.5.3 pkg v 0.36</version> <status>Release</status> <required_version>2.1</required_version> <config_file>https://packages.pfsense.org/packages/config/haproxy-devel/haproxy.xml</config_file> @@ -383,7 +383,7 @@ <pkginfolink/> <config_file>https://packages.pfsense.org/packages/config/tftp2/tftp.xml</config_file> <depends_on_package_base_url>https://files.pfsense.org/packages/8/All/</depends_on_package_base_url> - <version>2.2.4</version> + <version>2.2.5</version> <status>Stable</status> <required_version>2.0</required_version> <configurationfile>tftp.xml</configurationfile> diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 80d9d879..cfaf04ca 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -177,7 +177,7 @@ Supports ACLs for smart backend switching.]]></descr> <website>http://haproxy.1wt.eu/</website> <category>Services</category> - <version>1.5.3 pkg v 0.35</version> + <version>1.5.3 pkg v 0.36</version> <status>Release</status> <required_version>2.1</required_version> <config_file>https://packages.pfsense.org/packages/config/haproxy-devel/haproxy.xml</config_file> @@ -383,7 +383,7 @@ <pkginfolink/> <config_file>https://packages.pfsense.org/packages/config/tftp2/tftp.xml</config_file> <depends_on_package_base_url>https://files.pfsense.org/packages/amd64/8/All/</depends_on_package_base_url> - <version>2.2.4</version> + <version>2.2.5</version> <status>Stable</status> <required_version>2.0</required_version> <configurationfile>tftp.xml</configurationfile> |