diff options
author | Charlie Root <root@pfsense.localdomain> | 2012-06-16 17:58:51 +0000 |
---|---|---|
committer | Charlie Root <root@pfsense.localdomain> | 2012-06-16 17:58:51 +0000 |
commit | 4e8854c66ae2e4e40d46a1b2c33c27538b6d2f4c (patch) | |
tree | d98ec5039fc4a217fbe6efde91fcf8065aaba679 /usr/local/www | |
parent | 2229d94e840239fee85c8583081c17aa74bf8425 (diff) | |
download | pfsense-4e8854c66ae2e4e40d46a1b2c33c27538b6d2f4c.zip pfsense-4e8854c66ae2e4e40d46a1b2c33c27538b6d2f4c.tar.gz |
improve alias popup in firewall_rules
include url_table list up to 10000 items
read alias only on mouseover
use table to list columns
show edit shortcut
show total items value on popup description
Diffstat (limited to 'usr/local/www')
-rwxr-xr-x | usr/local/www/firewall_rules.php | 17 | ||||
-rwxr-xr-x | usr/local/www/guiconfig.inc | 154 | ||||
-rwxr-xr-x | usr/local/www/index.php | 5 | ||||
-rwxr-xr-x | usr/local/www/javascript/ticker.js | 16 |
4 files changed, 118 insertions, 74 deletions
diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php index 5656de8..dd6c90f 100755 --- a/usr/local/www/firewall_rules.php +++ b/usr/local/www/firewall_rules.php @@ -294,11 +294,6 @@ if (isset($_POST['del_x'])) { $closehead = false; include("head.inc"); - -echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>"; -echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>"; -echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>"; -echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>"; ?> <link rel="stylesheet" href="/javascript/chosen/chosen.css" /> </head> @@ -410,7 +405,7 @@ if($_REQUEST['undodrag']) { <tr valign="top" id="antilockout"> <td class="list"> </td> <td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11" border="0"></td> - <td class="listlr" style="background-color: #E0E0E0"></td> + <td class="listlr" style="background-color: #E0E0E0"> </td> <?php pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tr_antilockout"); ?> @@ -421,7 +416,7 @@ if($_REQUEST['undodrag']) { <td class="listr" style="background-color: #E0E0E0"><?= $alports ?></td> <td class="listr" style="background-color: #E0E0E0">*</td> <td class="listr" style="background-color: #E0E0E0">*</td> - <td class="listr" style="background-color: #E0E0E0"></td> + <td class="listr" style="background-color: #E0E0E0"> </td> <td class="listbg"><?=gettext("Anti-Lockout Rule");?></td> <td valign="middle" nowrap class="list"> <table border="0" cellspacing="0" cellpadding="1"> @@ -442,7 +437,7 @@ if($_REQUEST['undodrag']) { <tr valign="top" id="frrfc1918"> <td class="list"> </td> <td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td> - <td class="listlr" style="background-color: #E0E0E0"></td> + <td class="listlr" style="background-color: #E0E0E0"> </td> <td class="listr" style="background-color: #E0E0E0">*</td> <td class="listr" style="background-color: #E0E0E0"><?=gettext("RFC 1918 networks");?></td> <td class="listr" style="background-color: #E0E0E0">*</td> @@ -450,7 +445,7 @@ if($_REQUEST['undodrag']) { <td class="listr" style="background-color: #E0E0E0">*</td> <td class="listr" style="background-color: #E0E0E0">*</td> <td class="listr" style="background-color: #E0E0E0">*</td> - <td class="listr" style="background-color: #E0E0E0"></td> + <td class="listr" style="background-color: #E0E0E0"> </td> <td class="listbg"><?=gettext("Block private networks");?></td> <td valign="middle" nowrap class="list"> <table border="0" cellspacing="0" cellpadding="1"> @@ -470,7 +465,7 @@ if($_REQUEST['undodrag']) { <tr valign="top" id="frrfc1918"> <td class="list"> </td> <td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11" border="0"></td> - <td class="listlr" style="background-color: #E0E0E0"></td> + <td class="listlr" style="background-color: #E0E0E0"> </td> <td class="listr" style="background-color: #E0E0E0">*</td> <td class="listr" style="background-color: #E0E0E0"><?=gettext("Reserved/not assigned by IANA");?></td> <td class="listr" style="background-color: #E0E0E0">*</td> @@ -697,7 +692,7 @@ if($_REQUEST['undodrag']) { } ?> <td class="listlr" onClick="fr_toggle(<?=$nrules;?>)" id="frd<?=$nrules;?>" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';"> - <?=$textss;?><?php if (isset($filterent['id'])) echo $filterent['id']; else echo ""; ?><?=$textse;?> + <?=$textss;?><?php if (isset($filterent['id'])) echo $filterent['id']." "; else echo " "; ?><?=$textse;?> </td> <?php pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_id_tr"); diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index eb91962..3d750f3 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -1014,70 +1014,102 @@ function add_package_tabs($tabgroup, & $tab_array) { } } -function rule_popup($src,$srcport,$dst,$dstport){ +function alias_info_popup($alias_id){ global $config; + $maxlength = 60; + $close_title="title='".gettext('move mouse out this alias to hide')."'"; + if (is_array($config['aliases']['alias'][$alias_id])){ + $alias_name=$config['aliases']['alias'][$alias_id]; + $alias_objects_with_details = "<table width='100%' border='0' cellpadding='2' cellspacing='0'>"; + if ($alias_name['url']) { + exec("/sbin/pfctl -t {$alias_name['name']} -T show | wc -l", $total_entries); + $counter=preg_replace("/\D/","",$total_entries[0]); + exec("/sbin/pfctl -t {$alias_name['name']} -T show | head -10002", $alias_addresses); + $alias_objects_with_details .= "<tr><td colspan='3' $close_title class='vncell'>{$alias_name['url']}</td></tr>"; + $x=0; + foreach ($alias_addresses as $alias_ports_address ){ + switch ($x){ + case 0: + $x++; + $alias_objects_with_details .= "<tr><td $close_title class='vncell' width='33%' style='background: #FFFFFF;color: #000000;'>{$alias_ports_address}</td>"; + break; + case 1: + $x++; + $alias_objects_with_details .= "<td $close_title class='vncell' width='33%' style='background: #FFFFFF;color: #000000;'>{$alias_ports_address}</td>"; + break; + default: + $x=0; + $alias_objects_with_details .= "<td $close_title class='vncell' width='33%' style='background: #FFFFFF;color: #000000;'>{$alias_ports_address}</td><tr>"; + break; + } + } + for ($y=$x;$y<=$x;$y++){ + $alias_objects_with_details .= "<td $close_title class='vncell' width='33%'> </td>"; + } + if ($x > 0) + $alias_objects_with_details .= "</tr>"; + if ($counter > 10002){ + $alias_objects_with_details .= "<tr><td colspan='3'> listing only first 10k items</td><tr>"; + } + } + else{ + $alias_addresses = explode (" ", $alias_name['address']); + $alias_details = explode ("||", $alias_name['detail']); + $counter=0; + foreach($alias_addresses as $alias_ports_address) + { + $alias_objects_with_details .= "<tr><td $close_title width='5%' class='vncell' style='background: #FFFFFF;color: #000000;'>{$alias_addresses[$counter]}</td>"; + $alias_detail_default = strpos ($alias_details[$counter],"Entry added"); + if ($alias_details[$counter] != "" && $alias_detail_default === False) + $alias_objects_with_details .="<td $close_title width='95%' class='vncell' style='background: #FFFFFF;color: #000000;'>{$alias_details[$counter]}</td>"; + else + $alias_objects_with_details .="<td $close_title width='95%' class='vncell' style='background: #FFFFFF;color: #000000;'> </td>"; + $alias_objects_with_details .= "</tr>"; + $counter++; + } + + } + $alias_objects_with_details .="</table>"; + } + $alias_descr_substr = $alias_name['descr']; + if ($strlength >= $maxlength) + $alias_descr_substr = substr($alias_descr_substr, 0, $maxlength) . "..."; + $item_text=($counter > 1 ? "items" : "item"); + $alias_caption = "{$alias_descr_substr} - {$counter} {$item_text}<a href='/firewall_aliases_edit.php?id={$alias_id}' title='".gettext('edit this alias')."'> edit </a>"; + $strlength = strlen ($alias_caption); + print "<h1>{$alias_caption}</h1>".$alias_objects_with_details; +} + +function rule_popup($src,$srcport,$dst,$dstport){ + global $config,$g; $aliases_array = array(); if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias'])) - { - $span_begin = ""; - $alias_src_span_begin = ""; - $alias_src_span_end = ""; - $alias_src_port_span_begin = ""; - $alias_src_port_span_end = ""; - $alias_dst_span_begin = ""; - $alias_dst_span_end = ""; - $alias_dst_port_span_begin = ""; - $alias_dst_port_span_end = ""; - $alias_content_text = ""; - foreach($config['aliases']['alias'] as $alias_name) - { - $alias_addresses = explode (" ", $alias_name['address']); - $alias_details = explode ("||", $alias_name['detail']); - $alias_objects_with_details = ""; - $counter = 0; - if ($alias_name['url']) { - $alias_objects_with_details .= $alias_name['url'] . "<br/>"; - } - foreach($alias_addresses as $alias_ports_address) - { - $alias_objects_with_details .= $alias_addresses[$counter]; - $alias_detail_default = strpos ($alias_details[$counter],"Entry added"); - if ($alias_details[$counter] != "" && $alias_detail_default === False){ - $alias_objects_with_details .=" - " . $alias_details[$counter]; - } - $alias_objects_with_details .= "<br>"; - $counter++; - } - //max character length for caption field - $maxlength = 60; - - $alias_descr_substr = $alias_name['descr']; - $alias_content_text = htmlspecialchars($alias_objects_with_details); - $alias_caption = htmlspecialchars($alias_descr_substr . ":"); - $strlength = strlen ($alias_caption); - if ($strlength >= $maxlength) - $alias_caption = substr($alias_caption, 0, $maxlength) . "..."; - - $alias_caption_escaped = str_replace("'", "\'", $alias_caption); - $alias_content_escaped = str_replace("'", "\'", $alias_content_text); - $span_begin = "<span style=\"cursor: help;\" onmouseover=\"domTT_activate(this, event, 'content', '<h1>$alias_caption_escaped</h1><p>$alias_content_escaped</p>', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><U>"; - - if ($alias_name['name'] == $src) - $alias_src_span_begin = $span_begin; - if ($alias_name['name'] == $srcport) - $alias_src_port_span_begin = $span_begin; - if ($alias_name['name'] == $dst) - $alias_dst_span_begin = $span_begin; - if ($alias_name['name'] == $dstport) - $alias_dst_port_span_begin = $span_begin; - } - $descriptions = array (); - $descriptions['src'] = $alias_src_span_begin; - $descriptions['srcport'] = $alias_src_port_span_begin; - $descriptions['dst'] = $alias_dst_span_begin; - $descriptions['dstport'] = $alias_dst_port_span_begin; - - return $descriptions; + { + $descriptions = array (); + foreach($config['aliases']['alias'] as $alias_id=>$alias_name){ + $loading_image="<a><img src=\'/themes/{$g['theme']}/images/misc/loader.gif\'> " .gettext("loading...")."</a>"; + switch ($alias_name['type']){ + case "port": + $width="250"; + break; + case "urltable": + $width="500"; + break; + default: + $width="350"; + break; + } + $span_begin = "<span style=\"cursor: help;\" onmouseover=\"var response_html=domTT_activate(this, event, 'id','ttalias_{$alias_id}','content','{$loading_image}', 'trail', true, 'delay', 300, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle','type','velcro','width',{$width});alias_popup('{$alias_id}','{$g["theme"]}','".gettext('loading...')."');\" domTT_mouseout(this, close);\"><U>"; + if ($alias_name['name'] == $src) + $descriptions['src']= $span_begin; + if ($alias_name['name'] == $srcport) + $descriptions['srcport'] = $span_begin; + if ($alias_name['name'] == $dst ) + $descriptions['dst'] = $span_begin; + if ($alias_name['name'] == $dstport) + $descriptions['dstport'] = $span_begin; + } + return $descriptions; } } diff --git a/usr/local/www/index.php b/usr/local/www/index.php index 9b19a48..1287672 100755 --- a/usr/local/www/index.php +++ b/usr/local/www/index.php @@ -58,11 +58,14 @@ require_once('guiconfig.inc'); require_once('notices.inc'); if(isset($_REQUEST['closenotice'])){ - include("functions.inc"); close_notice($_REQUEST['closenotice']); echo get_menu_messages(); exit; } +if ($_REQUEST['act'] == 'alias_info_popup' && !preg_match("/\D/",$_REQUEST['aliasid'])){ + alias_info_popup($_REQUEST['aliasid']); + exit; +} if($g['disablecrashreporter'] != true) { // Check to see if we have a crash report diff --git a/usr/local/www/javascript/ticker.js b/usr/local/www/javascript/ticker.js index 3c8b6cc..defb1d8 100755 --- a/usr/local/www/javascript/ticker.js +++ b/usr/local/www/javascript/ticker.js @@ -1,6 +1,6 @@ /* $Id$ */ /* - functions.inc + ticker.js Copyright (C) 2012 Marcello Coutinho Copyright (C) 2012 Carlos Cesario - carloscesario@gmail.com All rights reserved. @@ -57,3 +57,17 @@ jQuery(document).ready(function() { jQuery(this).css('cursor','pointer'); }); }); + +function alias_popup(alias_id,theme,loading) { + domTT_update('ttalias_'+alias_id,"<a><img src='/themes/"+theme+"/images/misc/loader.gif'>"+loading+"</a>"); + jQuery.ajax({ + type: 'post', + cache: false, + url: "/index.php", + data: {aliasid:alias_id, act:'alias_info_popup'}, + success: function(response) { + //alert('<div>'+response.match(/<h1>.*<\/table>/i)+'<div>'); + domTT_update('ttalias_'+alias_id,'<div>'+response.match(/<h1>.*<\/table>/i)+'<div>'); + } + }); +}
\ No newline at end of file |