Revision 6c07db48
Added by Phil Davis about 10 years ago
usr/local/www/guiconfig.inc | ||
---|---|---|
37 | 37 |
if (!$nocsrf) { |
38 | 38 |
function csrf_startup() { |
39 | 39 |
csrf_conf('rewrite-js', '/csrf/csrf-magic.js'); |
40 |
$timeout_minutes = isset($config['system']['webgui']['session_timeout']) ? $config['system']['webgui']['session_timeout'] : 240;
|
|
40 |
$timeout_minutes = isset($config['system']['webgui']['session_timeout']) ? $config['system']['webgui']['session_timeout'] : 240; |
|
41 | 41 |
csrf_conf('expires', $timeout_minutes * 60); |
42 | 42 |
} |
43 | 43 |
require_once("csrf/csrf-magic.php"); |
... | ... | |
152 | 152 |
$ldap_templates = array( |
153 | 153 |
|
154 | 154 |
'open' => array( |
155 |
'desc' => "OpenLDAP",
|
|
156 |
'attr_user' => "cn",
|
|
157 |
'attr_group' => "cn",
|
|
158 |
'attr_member' => "member"),
|
|
155 |
'desc' => "OpenLDAP", |
|
156 |
'attr_user' => "cn", |
|
157 |
'attr_group' => "cn", |
|
158 |
'attr_member' => "member"), |
|
159 | 159 |
|
160 | 160 |
'msad' => array( |
161 |
'desc' => "Microsoft AD",
|
|
162 |
'attr_user' => "samAccountName",
|
|
163 |
'attr_group' => "cn",
|
|
164 |
'attr_member' => "memberOf"),
|
|
161 |
'desc' => "Microsoft AD", |
|
162 |
'attr_user' => "samAccountName", |
|
163 |
'attr_group' => "cn", |
|
164 |
'attr_member' => "memberOf"), |
|
165 | 165 |
|
166 | 166 |
'edir' => array( |
167 |
'desc' => "Novell eDirectory",
|
|
168 |
'attr_user' => "cn",
|
|
169 |
'attr_group' => "cn",
|
|
170 |
'attr_member' => "uniqueMember"));
|
|
167 |
'desc' => "Novell eDirectory", |
|
168 |
'attr_user' => "cn", |
|
169 |
'attr_group' => "cn", |
|
170 |
'attr_member' => "uniqueMember")); |
|
171 | 171 |
|
172 | 172 |
$radius_srvcs = array( |
173 | 173 |
'both' => "Authentication and Accounting", |
... | ... | |
307 | 307 |
} |
308 | 308 |
} |
309 | 309 |
|
310 |
function print_info_box_np($msg, $name="apply",$value="", $showapply=false) {
|
|
310 |
function print_info_box_np($msg, $name = "apply", $value = "", $showapply = false) {
|
|
311 | 311 |
global $g, $nifty_redbox, $nifty_blackbox, $nifty_background; |
312 | 312 |
|
313 | 313 |
if (empty($value)) { |
... | ... | |
325 | 325 |
if ($_POST['if']) { |
326 | 326 |
$savebutton .= "<input type=\"hidden\" name=\"if\" value=\"" . htmlspecialchars($_POST['if']) . "\" />"; |
327 | 327 |
} |
328 |
$savebutton.="</td>";
|
|
328 |
$savebutton .= "</td>";
|
|
329 | 329 |
} |
330 | 330 |
$nifty_redbox = "#990000"; |
331 | 331 |
$nifty_blackbox = "#000000"; |
... | ... | |
380 | 380 |
|
381 | 381 |
} |
382 | 382 |
|
383 |
function print_info_box_np_undo($msg, $name="apply",$value="Apply changes", $undo) {
|
|
383 |
function print_info_box_np_undo($msg, $name = "apply", $value = "Apply changes", $undo) {
|
|
384 | 384 |
global $g; |
385 | 385 |
|
386 | 386 |
if (stristr($msg, "apply") != false || stristr($msg, "save") != false || stristr($msg, "create") != false) { |
... | ... | |
678 | 678 |
echo "<tr valign=\"top\">\n"; |
679 | 679 |
if ($withorig) { |
680 | 680 |
if (isset($config['system']['usefifolog'])) { |
681 |
$entry_date_time = htmlspecialchars(date("F j, Y, g:i a","" . $logent[1] . "")); |
|
681 |
$entry_date_time = htmlspecialchars(date("F j, Y, g:i a", "" . $logent[1] . ""));
|
|
682 | 682 |
$entry_text = htmlspecialchars($logent[5]); |
683 | 683 |
} else { |
684 | 684 |
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3))); |
685 |
$entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " ";
|
|
685 |
$entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " "; |
|
686 | 686 |
$entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]); |
687 | 687 |
} |
688 | 688 |
echo "<td class=\"listlr nowrap\">{$entry_date_time}</td>\n"; |
... | ... | |
779 | 779 |
} |
780 | 780 |
} |
781 | 781 |
|
782 |
function pconfig_to_address(&$adr, $padr, $pmask, $pnot=false, $pbeginport=0, $pendport=0) {
|
|
782 |
function pconfig_to_address(&$adr, $padr, $pmask, $pnot = false, $pbeginport = 0, $pendport = 0) {
|
|
783 | 783 |
$adr = array(); |
784 | 784 |
|
785 | 785 |
if ($padr == "any") { |
... | ... | |
836 | 836 |
echo "<div id=\"tabs\">"; |
837 | 837 |
$tabscounter = 0; |
838 | 838 |
foreach ($tab_array as $ta) { |
839 |
$dashpos = strpos($ta[2],'-'); |
|
839 |
$dashpos = strpos($ta[2], '-');
|
|
840 | 840 |
$tabname = $ta[2] . "-tab"; |
841 |
$tabclass = substr($ta[2],0,$dashpos);
|
|
841 |
$tabclass = substr($ta[2], 0, $dashpos);
|
|
842 | 842 |
$tabclass = $tabclass . "-class"; |
843 | 843 |
if ($ta[1] == true) { |
844 | 844 |
$tabActive = "table-cell"; |
... | ... | |
978 | 978 |
} |
979 | 979 |
|
980 | 980 |
// Useful debugging function, much cleaner than print_r |
981 |
function echo_array($array,$return_me=false) {
|
|
981 |
function echo_array($array, $return_me = false) {
|
|
982 | 982 |
if (is_array($array) == false) { |
983 | 983 |
$return = "The provided variable is not an array."; |
984 | 984 |
} else { |
... | ... | |
986 | 986 |
if (is_array($value)) { |
987 | 987 |
$return .= ""; |
988 | 988 |
$return .= "['<b>$name</b>'] {<div style=\"margin-left:10px;\">\n"; |
989 |
$return .= echo_array($value,true); |
|
989 |
$return .= echo_array($value, true);
|
|
990 | 990 |
$return .= "</div>}"; |
991 | 991 |
$return .= "\n\n"; |
992 | 992 |
} else { |
... | ... | |
1073 | 1073 |
echo gettext("Currently viewing: "); |
1074 | 1074 |
echo "<select name=\"TabSelect\" onchange=\"tabs_will_go(this)\">\n"; |
1075 | 1075 |
foreach ($tab_array as $ta) { |
1076 |
if ($ta[1]=="true") {
|
|
1076 |
if ($ta[1] == "true") {
|
|
1077 | 1077 |
$selected = " selected=\"selected\""; |
1078 | 1078 |
} else { |
1079 | 1079 |
$selected = ""; |
... | ... | |
1120 | 1120 |
return; |
1121 | 1121 |
} |
1122 | 1122 |
|
1123 |
foreach($pkg_config['tabs']['tab'] as $tab) { |
|
1123 |
foreach ($pkg_config['tabs']['tab'] as $tab) {
|
|
1124 | 1124 |
$tab_entry = array(); |
1125 | 1125 |
if ($tab['name']) { |
1126 | 1126 |
$tab_entry[] = $tab['name']; |
... | ... | |
1136 | 1136 |
$maxlength = 60; |
1137 | 1137 |
$close_title="title='".gettext('move mouse out of this alias to hide')."'"; |
1138 | 1138 |
if (is_array($config['aliases']['alias'][$alias_id])) { |
1139 |
$alias_name=$config['aliases']['alias'][$alias_id];
|
|
1139 |
$alias_name = $config['aliases']['alias'][$alias_id];
|
|
1140 | 1140 |
$alias_objects_with_details = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" summary=\"alias info popup\">"; |
1141 | 1141 |
if ($alias_name['url']) { |
1142 | 1142 |
// TODO: Change it when pf supports tables with ports |
1143 | 1143 |
if ($alias_name['type'] == "urltable") { |
1144 | 1144 |
exec("/sbin/pfctl -t {$alias_name['name']} -T show | wc -l", $total_entries); |
1145 |
$counter=preg_replace("/\D/","",$total_entries[0]);
|
|
1145 |
$counter = preg_replace("/\D/", "", $total_entries[0]);
|
|
1146 | 1146 |
exec("/sbin/pfctl -t {$alias_name['name']} -T show | head -10002", $alias_addresses); |
1147 | 1147 |
} else { |
1148 | 1148 |
$urlfn = alias_expand_urltable($alias_name['name']); |
... | ... | |
1150 | 1150 |
$counter = count($alias_addresses); |
1151 | 1151 |
} |
1152 | 1152 |
$alias_objects_with_details .= "<tr><td colspan=\"3\" $close_title class=\"vncell\">{$alias_name['url']}</td></tr>"; |
1153 |
$x=0;
|
|
1154 |
foreach ($alias_addresses as $alias_ports_address ) {
|
|
1153 |
$x = 0;
|
|
1154 |
foreach ($alias_addresses as $alias_ports_address) { |
|
1155 | 1155 |
switch ($x) { |
1156 | 1156 |
case 0: |
1157 | 1157 |
$x++; |
... | ... | |
1162 | 1162 |
$alias_objects_with_details .= "<td $close_title class=\"vncell\" width=\"33%\" style=\"background: #FFFFFF;color: #000000;\">{$alias_ports_address}</td>"; |
1163 | 1163 |
break; |
1164 | 1164 |
default: |
1165 |
$x=0;
|
|
1166 |
$alias_objects_with_details .= "<td $close_title class=\"vncell\" width=\"33%\" style=\"background: #FFFFFF;color: #000000;\">{$alias_ports_address}</td><tr>";
|
|
1165 |
$x = 0;
|
|
1166 |
$alias_objects_with_details .= "<td $close_title class=\"vncell\" width=\"33%\" style=\"background: #FFFFFF;color: #000000;\">{$alias_ports_address}</td><tr>"; |
|
1167 | 1167 |
break; |
1168 | 1168 |
} |
1169 | 1169 |
} |
... | ... | |
1182 | 1182 |
$counter = 0; |
1183 | 1183 |
foreach ($alias_addresses as $alias_ports_address) { |
1184 | 1184 |
$alias_objects_with_details .= "<tr><td $close_title width=\"5%\" class=\"vncell\" style=\"background: #FFFFFF;color: #000000;\">{$alias_addresses[$counter]}</td>"; |
1185 |
$alias_detail_default = strpos ($alias_details[$counter],"Entry added"); |
|
1185 |
$alias_detail_default = strpos ($alias_details[$counter], "Entry added");
|
|
1186 | 1186 |
if ($alias_details[$counter] != "" && $alias_detail_default === False) { |
1187 | 1187 |
$alias_objects_with_details .="<td $close_title width=\"95%\" class=\"vncell\" style=\"background: #FFFFFF;color: #000000;\">{$alias_details[$counter]}</td>"; |
1188 | 1188 |
} else { |
... | ... | |
1204 | 1204 |
print "<h1>{$alias_caption}</h1>" . $alias_objects_with_details; |
1205 | 1205 |
} |
1206 | 1206 |
|
1207 |
function rule_popup($src,$srcport,$dst,$dstport) {
|
|
1208 |
global $config,$g; |
|
1207 |
function rule_popup($src, $srcport, $dst, $dstport) {
|
|
1208 |
global $config, $g;
|
|
1209 | 1209 |
$aliases_array = array(); |
1210 | 1210 |
if ($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias'])) { |
1211 | 1211 |
$descriptions = array (); |
... | ... | |
1232 | 1232 |
$descriptions['srcport'] = $span_begin; |
1233 | 1233 |
$descriptions['srcport_end'] = $span_end; |
1234 | 1234 |
} |
1235 |
if ($alias_name['name'] == $dst ) {
|
|
1235 |
if ($alias_name['name'] == $dst) { |
|
1236 | 1236 |
$descriptions['dst'] = $span_begin; |
1237 | 1237 |
$descriptions['dst_end'] = $span_end; |
1238 | 1238 |
} |
Also available in: Unified diff
Code spacing
and other random stuff I noticed.
I think this finishes messing with code style. The codebase should match
the developer style guide closely enough that 99.9% of changes will not
feel the need to also massage the formatting.