@@ -29,49 +29,49 @@ discard block |
||
29 | 29 | |
30 | 30 | # get record |
31 | 31 | if($_POST['action']!="add") { |
32 | - $record = $PowerDNS->fetch_record ($_POST['id']); |
|
33 | - $record!==false ? : $Result->show("danger", _("Invalid ID"), true, true); |
|
32 | + $record = $PowerDNS->fetch_record ($_POST['id']); |
|
33 | + $record!==false ? : $Result->show("danger", _("Invalid ID"), true, true); |
|
34 | 34 | } |
35 | 35 | # new record |
36 | 36 | else { |
37 | - // from IP table |
|
38 | - // we provide record hostname and strip domain from it |
|
39 | - if (!is_numeric($_POST['domain_id']) && !is_numeric($_POST['id'])) { |
|
40 | - // fetch all domains |
|
41 | - $all_domains = $PowerDNS->fetch_all_domains (); |
|
42 | - if ($all_domains!==false) { |
|
43 | - foreach($all_domains as $dk=>$domain_s) { |
|
44 | - // loop through and find all matches |
|
45 | - if (strpos($_POST['domain_id'],$domain_s->name) !== false) { |
|
46 | - // check best match to avoid for example a.example.net.nz1 added to example.net.nz |
|
47 | - if (substr($_POST['domain_id'], -strlen($domain_s->name)) === $domain_s->name) { |
|
48 | - $matches[$dk] = $domain_s; |
|
49 | - } |
|
50 | - } |
|
51 | - } |
|
52 | - // match found ? |
|
53 | - if (isset($matches)) { |
|
54 | - foreach($matches as $k=>$m){ |
|
55 | - $length = strlen($m->name); |
|
56 | - if($length > $max){ $max = $length; $element_id = $k; } |
|
57 | - } |
|
58 | - // save longest match id |
|
59 | - $_POST['domain_id'] = $all_domains[$element_id]->id; |
|
60 | - } |
|
61 | - } |
|
62 | - // die if not existing |
|
63 | - if (!is_numeric($_POST['domain_id'])) { |
|
64 | - # admin? |
|
65 | - if ($User->is_admin()) { $Result->show("danger", _("Domain")." <strong>".$_POST['domain_id']."</strong><span class='ip_dns_addr hidden'>".$_POST['id']."</span> "._("does not exist")."!"."<hr><button class='btn btn-sm btn-default editDomain2 editDomain' data-action='add' data-id='0'><i class='fa fa-plus'></i> "._('Create domain')."</button>", true, true); } |
|
66 | - else { $Result->show("danger", _("Domain")." <strong>".$_POST['domain_id']."</strong> "._("does not exist")."!", true, true); } |
|
67 | - } |
|
68 | - else { |
|
69 | - $record = new StdClass (); |
|
70 | - $record->ttl = 3600; |
|
71 | - $record->name = $post['domain_id']; |
|
72 | - $record->content = $_POST['id']; |
|
73 | - } |
|
74 | - } |
|
37 | + // from IP table |
|
38 | + // we provide record hostname and strip domain from it |
|
39 | + if (!is_numeric($_POST['domain_id']) && !is_numeric($_POST['id'])) { |
|
40 | + // fetch all domains |
|
41 | + $all_domains = $PowerDNS->fetch_all_domains (); |
|
42 | + if ($all_domains!==false) { |
|
43 | + foreach($all_domains as $dk=>$domain_s) { |
|
44 | + // loop through and find all matches |
|
45 | + if (strpos($_POST['domain_id'],$domain_s->name) !== false) { |
|
46 | + // check best match to avoid for example a.example.net.nz1 added to example.net.nz |
|
47 | + if (substr($_POST['domain_id'], -strlen($domain_s->name)) === $domain_s->name) { |
|
48 | + $matches[$dk] = $domain_s; |
|
49 | + } |
|
50 | + } |
|
51 | + } |
|
52 | + // match found ? |
|
53 | + if (isset($matches)) { |
|
54 | + foreach($matches as $k=>$m){ |
|
55 | + $length = strlen($m->name); |
|
56 | + if($length > $max){ $max = $length; $element_id = $k; } |
|
57 | + } |
|
58 | + // save longest match id |
|
59 | + $_POST['domain_id'] = $all_domains[$element_id]->id; |
|
60 | + } |
|
61 | + } |
|
62 | + // die if not existing |
|
63 | + if (!is_numeric($_POST['domain_id'])) { |
|
64 | + # admin? |
|
65 | + if ($User->is_admin()) { $Result->show("danger", _("Domain")." <strong>".$_POST['domain_id']."</strong><span class='ip_dns_addr hidden'>".$_POST['id']."</span> "._("does not exist")."!"."<hr><button class='btn btn-sm btn-default editDomain2 editDomain' data-action='add' data-id='0'><i class='fa fa-plus'></i> "._('Create domain')."</button>", true, true); } |
|
66 | + else { $Result->show("danger", _("Domain")." <strong>".$_POST['domain_id']."</strong> "._("does not exist")."!", true, true); } |
|
67 | + } |
|
68 | + else { |
|
69 | + $record = new StdClass (); |
|
70 | + $record->ttl = 3600; |
|
71 | + $record->name = $post['domain_id']; |
|
72 | + $record->content = $_POST['id']; |
|
73 | + } |
|
74 | + } |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // get domain |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | |
81 | 81 | // default |
82 | 82 | if (!isset($record)) { |
83 | - $record = new StdClass (); |
|
84 | - $record->ttl = 3600; |
|
85 | - $record->name = $domain->name; |
|
83 | + $record = new StdClass (); |
|
84 | + $record->ttl = 3600; |
|
85 | + $record->name = $domain->name; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // if IPv6 automaticall add AAAA record! |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | <td> |
123 | 123 | <select name="type" class="form-control input-w-auto input-sm" <?php print $readonly; ?>> |
124 | 124 | <?php |
125 | - // loop |
|
126 | - foreach($PowerDNS->record_types as $type) { |
|
127 | - // active |
|
128 | - if ($type == @$record->type) { $selected = "selected"; } |
|
129 | - else { $selected = ""; } |
|
130 | ||
131 | - print "<option value='$type' $selected>$type</option>"; |
|
132 | - } |
|
133 | - ?> |
|
125 | + // loop |
|
126 | + foreach($PowerDNS->record_types as $type) { |
|
127 | + // active |
|
128 | + if ($type == @$record->type) { $selected = "selected"; } |
|
129 | + else { $selected = ""; } |
|
130 | ||
131 | + print "<option value='$type' $selected>$type</option>"; |
|
132 | + } |
|
133 | + ?> |
|
134 | 134 | </select> |
135 | 135 | </td> |
136 | 136 | </tr> |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | <td> |
151 | 151 | <select name="ttl" class="form-control input-w-auto input-sm" <?php print $readonly; ?>> |
152 | 152 | <?php |
153 | - // loop |
|
154 | - foreach($PowerDNS->ttl as $k=>$type) { |
|
155 | - // active |
|
156 | - if ($k == @$record->ttl) { $selected = "selected"; } |
|
157 | - else { $selected = ""; } |
|
158 | ||
159 | - print "<option value='$k' $selected>$type</option>"; |
|
160 | - } |
|
161 | - ?> |
|
153 | + // loop |
|
154 | + foreach($PowerDNS->ttl as $k=>$type) { |
|
155 | + // active |
|
156 | + if ($k == @$record->ttl) { $selected = "selected"; } |
|
157 | + else { $selected = ""; } |
|
158 | ||
159 | + print "<option value='$k' $selected>$type</option>"; |
|
160 | + } |
|
161 | + ?> |
|
162 | 162 | </select> |
163 | 163 | </td> |
164 | 164 | </tr> |
@@ -25,27 +25,27 @@ |
||
25 | 25 | |
26 | 26 | # fetch old record |
27 | 27 | if($_POST['action']!="add") { |
28 | - $record = $PowerDNS->fetch_record ($_POST['id']); |
|
29 | - $record!==false ? : $Result->show("danger", _("Invalid ID"), true, true); |
|
28 | + $record = $PowerDNS->fetch_record ($_POST['id']); |
|
29 | + $record!==false ? : $Result->show("danger", _("Invalid ID"), true, true); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | # edit and add - check that smth is in name and content! |
33 | 33 | if ($_POST['action']!="delete") { |
34 | - if (strlen($_POST['name'])<2) { $Result->show ("danger", _("Invalid name"), true); } |
|
35 | - if (strlen($_POST['content'])<2) { $Result->show ("danger", _("Invalid content"), true); } |
|
34 | + if (strlen($_POST['name'])<2) { $Result->show ("danger", _("Invalid name"), true); } |
|
35 | + if (strlen($_POST['content'])<2) { $Result->show ("danger", _("Invalid content"), true); } |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | # validate and set values |
40 | 40 | if($_POST['action']=="edit") { |
41 | - $values = $PowerDNS->formulate_update_record ($_POST['name'], $_POST['type'], $_POST['content'], $_POST['ttl'], $_POST['prio'], $_POST['disabled'], $record->change_date); |
|
42 | - $values['domain_id'] = $_POST['domain_id']; |
|
41 | + $values = $PowerDNS->formulate_update_record ($_POST['name'], $_POST['type'], $_POST['content'], $_POST['ttl'], $_POST['prio'], $_POST['disabled'], $record->change_date); |
|
42 | + $values['domain_id'] = $_POST['domain_id']; |
|
43 | 43 | } |
44 | 44 | elseif($_POST['action']=="add") { |
45 | - $values = $PowerDNS->formulate_new_record ($_POST['domain_id'], $_POST['name'], $_POST['type'], $_POST['content'], $_POST['ttl'], $_POST['prio'], $_POST['disabled']); |
|
45 | + $values = $PowerDNS->formulate_new_record ($_POST['domain_id'], $_POST['name'], $_POST['type'], $_POST['content'], $_POST['ttl'], $_POST['prio'], $_POST['disabled']); |
|
46 | 46 | } |
47 | 47 | elseif($_POST['action']=="delete") { |
48 | - $values['domain_id'] = $_POST['domain_id']; |
|
48 | + $values['domain_id'] = $_POST['domain_id']; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | # add id |
@@ -34,43 +34,43 @@ |
||
34 | 34 | |
35 | 35 | # ok, lets get results form post array! |
36 | 36 | foreach($_POST as $key=>$line) { |
37 | - // IP address |
|
38 | - if(substr($key, 0,2)=="rd") { $res[substr($key, 2)]['rd'] = $line; } |
|
39 | - // mac |
|
40 | - elseif(substr($key, 0,4)=="name") { $res[substr($key, 4)]['name'] = $line; } |
|
41 | - // description |
|
42 | - elseif(substr($key, 0,11)=="description") { $res[substr($key, 11)]['description'] = $line; } |
|
43 | - // custom fields |
|
44 | - elseif (isset($required_fields)) { |
|
45 | - foreach ($required_fields as $k=>$f) { |
|
46 | - if((strpos($key, $f['name'])) !== false) { |
|
37 | + // IP address |
|
38 | + if(substr($key, 0,2)=="rd") { $res[substr($key, 2)]['rd'] = $line; } |
|
39 | + // mac |
|
40 | + elseif(substr($key, 0,4)=="name") { $res[substr($key, 4)]['name'] = $line; } |
|
41 | + // description |
|
42 | + elseif(substr($key, 0,11)=="description") { $res[substr($key, 11)]['description'] = $line; } |
|
43 | + // custom fields |
|
44 | + elseif (isset($required_fields)) { |
|
45 | + foreach ($required_fields as $k=>$f) { |
|
46 | + if((strpos($key, $f['name'])) !== false) { |
|
47 | 47 | { $res[substr($key, strlen($f['name']))][$f['name']] = $line; } |
48 | - } |
|
49 | - } |
|
50 | - } |
|
48 | + } |
|
49 | + } |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | # insert entries |
54 | 54 | if(sizeof($res)>0) { |
55 | - $errors = 0; |
|
56 | - foreach($res as $r) { |
|
57 | - # set insert values |
|
58 | - $values = array("rd"=>$r['rd'], |
|
59 | - "name"=>$r['name'], |
|
60 | - "description"=>$r['description'] |
|
61 | - ); |
|
55 | + $errors = 0; |
|
56 | + foreach($res as $r) { |
|
57 | + # set insert values |
|
58 | + $values = array("rd"=>$r['rd'], |
|
59 | + "name"=>$r['name'], |
|
60 | + "description"=>$r['description'] |
|
61 | + ); |
|
62 | 62 | # custom fields |
63 | - if (isset($required_fields)) { |
|
64 | - foreach ($required_fields as $k=>$f) { |
|
65 | - $values[$f['name']] = $r[$f['name']]; |
|
66 | - } |
|
67 | - } |
|
63 | + if (isset($required_fields)) { |
|
64 | + foreach ($required_fields as $k=>$f) { |
|
65 | + $values[$f['name']] = $r[$f['name']]; |
|
66 | + } |
|
67 | + } |
|
68 | 68 | # insert vrfs |
69 | 69 | if(!$Admin->object_modify("vrf", "add", "vrfId", $values)) { $Result->show("danger", _("Failed to import entry")." ".$r['number']." ".$r['name'], false); $errors++; } |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | - # success if no errors |
|
73 | - if($errors==0) { $Result->show("success", _("Scan results added to database")."!", true); } |
|
72 | + # success if no errors |
|
73 | + if($errors==0) { $Result->show("success", _("Scan results added to database")."!", true); } |
|
74 | 74 | } |
75 | 75 | # error |
76 | 76 | else { $Result->show("danger", _("No entries available"), true); } |
@@ -40,95 +40,95 @@ |
||
40 | 40 | # first check if they exist! |
41 | 41 | if($all_vrfs===false) { $Result->show("info", _("No VRFs configured")."!", false);} |
42 | 42 | else { |
43 | - print '<table id="vrfManagement" class="table sorted table-striped table-top table-hover">'. "\n"; |
|
44 | - |
|
45 | - # headers |
|
46 | - print "<thead>"; |
|
47 | - print '<tr>'. "\n"; |
|
48 | - print ' <th>'._('Name').'</th>'. "\n"; |
|
49 | - print ' <th>'._('RD').'</th>'. "\n"; |
|
50 | - print ' <th>'._('Sections').'</th>'. "\n"; |
|
51 | - print ' <th>'._('Description').'</th>'. "\n"; |
|
52 | - if(sizeof($custom) > 0) { |
|
53 | - foreach($custom as $field) { |
|
54 | - if(!in_array($field['name'], $hidden_fields)) { |
|
55 | - print "<th class='customField hidden-xs hidden-sm'>$field[name]</th>"; |
|
56 | - } |
|
57 | - } |
|
58 | - } |
|
59 | - print ' <th></th>'. "\n"; |
|
60 | - print '</tr>'. "\n"; |
|
61 | - print "</thead>"; |
|
43 | + print '<table id="vrfManagement" class="table sorted table-striped table-top table-hover">'. "\n"; |
|
44 | + |
|
45 | + # headers |
|
46 | + print "<thead>"; |
|
47 | + print '<tr>'. "\n"; |
|
48 | + print ' <th>'._('Name').'</th>'. "\n"; |
|
49 | + print ' <th>'._('RD').'</th>'. "\n"; |
|
50 | + print ' <th>'._('Sections').'</th>'. "\n"; |
|
51 | + print ' <th>'._('Description').'</th>'. "\n"; |
|
52 | + if(sizeof($custom) > 0) { |
|
53 | + foreach($custom as $field) { |
|
54 | + if(!in_array($field['name'], $hidden_fields)) { |
|
55 | + print "<th class='customField hidden-xs hidden-sm'>$field[name]</th>"; |
|
56 | + } |
|
57 | + } |
|
58 | + } |
|
59 | + print ' <th></th>'. "\n"; |
|
60 | + print '</tr>'. "\n"; |
|
61 | + print "</thead>"; |
|
62 | 62 | |
63 | 63 | print "<tbody>"; |
64 | - # loop |
|
65 | - foreach ($all_vrfs as $vrf) { |
|
66 | - //cast |
|
67 | - $vrf = (array) $vrf; |
|
68 | - |
|
69 | - // format sections |
|
70 | - if(strlen($vrf['sections'])==0) { |
|
71 | - $sections = "All sections"; |
|
72 | - } |
|
73 | - else { |
|
74 | - //explode |
|
75 | - unset($sec); |
|
76 | - $sections_tmp = explode(";", $vrf['sections']); |
|
77 | - foreach($sections_tmp as $t) { |
|
78 | - //fetch section |
|
79 | - $tmp_section = $Sections->fetch_section(null, $t); |
|
80 | - $sec[] = " · ".$tmp_section->name; |
|
81 | - } |
|
82 | - //implode |
|
83 | - $sections = implode("<br>", $sec); |
|
84 | - } |
|
85 | - |
|
86 | - //print details |
|
87 | - print '<tr class="text-top">'. "\n"; |
|
88 | - print ' <td class="name">'. $vrf['name'] .'</td>'. "\n"; |
|
89 | - print ' <td class="rd">'. $vrf['rd'] .'</td>'. "\n"; |
|
90 | - print " <td><span class='text-muted'>$sections</span></td>"; |
|
91 | - print ' <td class="description">'. $vrf['description'] .'</td>'. "\n"; |
|
92 | - |
|
93 | - // custom fields |
|
94 | - if(sizeof($custom) > 0) { |
|
95 | - foreach($custom as $field) { |
|
96 | - if(!in_array($field['name'], $hidden_fields)) { |
|
97 | - |
|
98 | - print "<td class='customField hidden-xs hidden-sm'>"; |
|
99 | - |
|
100 | - // create links |
|
101 | - $vrf[$field['name']] = $Result->create_links ($vrf[$field['name']], $field['type']); |
|
102 | - |
|
103 | - //booleans |
|
104 | - if($field['type']=="tinyint(1)") { |
|
105 | - if($vrf[$field['name']] == "0") { print _("No"); } |
|
106 | - elseif($vrf[$field['name']] == "1") { print _("Yes"); } |
|
107 | - } |
|
108 | - //text |
|
109 | - elseif($field['type']=="text") { |
|
110 | - if(strlen($vrf[$field['name']])>0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $vrf[$field['name']])."'>"; } |
|
111 | - else { print ""; } |
|
112 | - } |
|
113 | - else { |
|
114 | - print $vrf[$field['name']]; |
|
115 | - |
|
116 | - } |
|
117 | - print "</td>"; |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - print " <td class='actions'>"; |
|
123 | - print " <div class='btn-group'>"; |
|
124 | - print " <button class='btn btn-xs btn-default vrfManagement' data-action='edit' data-vrfid='$vrf[vrfId]'><i class='fa fa-pencil'></i></button>"; |
|
125 | - print " <button class='btn btn-xs btn-default vrfManagement' data-action='delete' data-vrfid='$vrf[vrfId]'><i class='fa fa-times'></i></button>"; |
|
126 | - print " </div>"; |
|
127 | - print " </td>"; |
|
128 | - print '</tr>'. "\n"; |
|
129 | - } |
|
130 | - print "</tbody>"; |
|
131 | - print '</table>'. "\n"; |
|
64 | + # loop |
|
65 | + foreach ($all_vrfs as $vrf) { |
|
66 | + //cast |
|
67 | + $vrf = (array) $vrf; |
|
68 | + |
|
69 | + // format sections |
|
70 | + if(strlen($vrf['sections'])==0) { |
|
71 | + $sections = "All sections"; |
|
72 | + } |
|
73 | + else { |
|
74 | + //explode |
|
75 | + unset($sec); |
|
76 | + $sections_tmp = explode(";", $vrf['sections']); |
|
77 | + foreach($sections_tmp as $t) { |
|
78 | + //fetch section |
|
79 | + $tmp_section = $Sections->fetch_section(null, $t); |
|
80 | + $sec[] = " · ".$tmp_section->name; |
|
81 | + } |
|
82 | + //implode |
|
83 | + $sections = implode("<br>", $sec); |
|
84 | + } |
|
85 | + |
|
86 | + //print details |
|
87 | + print '<tr class="text-top">'. "\n"; |
|
88 | + print ' <td class="name">'. $vrf['name'] .'</td>'. "\n"; |
|
89 | + print ' <td class="rd">'. $vrf['rd'] .'</td>'. "\n"; |
|
90 | + print " <td><span class='text-muted'>$sections</span></td>"; |
|
91 | + print ' <td class="description">'. $vrf['description'] .'</td>'. "\n"; |
|
92 | + |
|
93 | + // custom fields |
|
94 | + if(sizeof($custom) > 0) { |
|
95 | + foreach($custom as $field) { |
|
96 | + if(!in_array($field['name'], $hidden_fields)) { |
|
97 | + |
|
98 | + print "<td class='customField hidden-xs hidden-sm'>"; |
|
99 | + |
|
100 | + // create links |
|
101 | + $vrf[$field['name']] = $Result->create_links ($vrf[$field['name']], $field['type']); |
|
102 | + |
|
103 | + //booleans |
|
104 | + if($field['type']=="tinyint(1)") { |
|
105 | + if($vrf[$field['name']] == "0") { print _("No"); } |
|
106 | + elseif($vrf[$field['name']] == "1") { print _("Yes"); } |
|
107 | + } |
|
108 | + //text |
|
109 | + elseif($field['type']=="text") { |
|
110 | + if(strlen($vrf[$field['name']])>0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $vrf[$field['name']])."'>"; } |
|
111 | + else { print ""; } |
|
112 | + } |
|
113 | + else { |
|
114 | + print $vrf[$field['name']]; |
|
115 | + |
|
116 | + } |
|
117 | + print "</td>"; |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + print " <td class='actions'>"; |
|
123 | + print " <div class='btn-group'>"; |
|
124 | + print " <button class='btn btn-xs btn-default vrfManagement' data-action='edit' data-vrfid='$vrf[vrfId]'><i class='fa fa-pencil'></i></button>"; |
|
125 | + print " <button class='btn btn-xs btn-default vrfManagement' data-action='delete' data-vrfid='$vrf[vrfId]'><i class='fa fa-times'></i></button>"; |
|
126 | + print " </div>"; |
|
127 | + print " </td>"; |
|
128 | + print '</tr>'. "\n"; |
|
129 | + } |
|
130 | + print "</tbody>"; |
|
131 | + print '</table>'. "\n"; |
|
132 | 132 | } |
133 | 133 | ?> |
134 | 134 |
@@ -65,20 +65,20 @@ discard block |
||
65 | 65 | $res = $Snmp->get_query("get_vrf_table"); |
66 | 66 | // remove those not in subnet |
67 | 67 | if (sizeof($res)>0) { |
68 | - // save for debug |
|
69 | - $debug[$d->hostname]["get_vrf_table"] = $res; |
|
70 | - // loop and save |
|
71 | - foreach ($res as $k=>$r) { |
|
72 | - if (!array_key_exists($k, $new_vrfs) && !array_key_exists($k, $ex_vrfs) ) { |
|
73 | - $new_vrfs[$k] = $r; |
|
74 | - } |
|
75 | - } |
|
68 | + // save for debug |
|
69 | + $debug[$d->hostname]["get_vrf_table"] = $res; |
|
70 | + // loop and save |
|
71 | + foreach ($res as $k=>$r) { |
|
72 | + if (!array_key_exists($k, $new_vrfs) && !array_key_exists($k, $ex_vrfs) ) { |
|
73 | + $new_vrfs[$k] = $r; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | } |
77 | - } catch (Exception $e) { |
|
78 | - // save for debug |
|
79 | - $debug[$d->hostname]["get_vrf_table"] = $res; |
|
80 | - $errors[] = $e->getMessage(); |
|
81 | - } |
|
77 | + } catch (Exception $e) { |
|
78 | + // save for debug |
|
79 | + $debug[$d->hostname]["get_vrf_table"] = $res; |
|
80 | + $errors[] = $e->getMessage(); |
|
81 | + } |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | # none and errors |
@@ -101,129 +101,129 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | // calculate colspan |
104 | - $colspan = 4 + sizeof(@$required_fields); |
|
104 | + $colspan = 4 + sizeof(@$required_fields); |
|
105 | 105 | |
106 | 106 | |
107 | - //form |
|
108 | - print "<form name='scan-snmp-vrf-form' class='scan-snmp-arp-form' id='scan-snmp-vrf-form'>"; |
|
109 | - print "<table class='table table-striped table-top table-condensed'>"; |
|
107 | + //form |
|
108 | + print "<form name='scan-snmp-vrf-form' class='scan-snmp-arp-form' id='scan-snmp-vrf-form'>"; |
|
109 | + print "<table class='table table-striped table-top table-condensed'>"; |
|
110 | 110 | |
111 | - // titles |
|
112 | - print "<tr>"; |
|
113 | - print " <th>"._("Name")."</th>"; |
|
114 | - print " <th>"._("RD")."</th>"; |
|
115 | - print " <th>"._("Description")."</th>"; |
|
111 | + // titles |
|
112 | + print "<tr>"; |
|
113 | + print " <th>"._("Name")."</th>"; |
|
114 | + print " <th>"._("RD")."</th>"; |
|
115 | + print " <th>"._("Description")."</th>"; |
|
116 | 116 | // custom |
117 | - if (isset($required_fields)) { |
|
118 | - foreach ($required_fields as $field) { |
|
117 | + if (isset($required_fields)) { |
|
118 | + foreach ($required_fields as $field) { |
|
119 | 119 | print "<th>"._($field['name'])."</th>"; |
120 | - } |
|
120 | + } |
|
121 | 121 | } |
122 | - print " <th></th>"; |
|
123 | - print "</tr>"; |
|
122 | + print " <th></th>"; |
|
123 | + print "</tr>"; |
|
124 | 124 | |
125 | - // alive |
|
126 | - $m=0; |
|
127 | - foreach ($new_vrfs as $name=>$rd ) { |
|
125 | + // alive |
|
126 | + $m=0; |
|
127 | + foreach ($new_vrfs as $name=>$rd ) { |
|
128 | 128 | print "<tr class='result$m'>"; |
129 | - //name |
|
130 | - print "<td>$name</td>"; |
|
131 | - //rd |
|
132 | - print "<td>"; |
|
133 | - print " <input type='text' class='form-control input-sm' name='rd$m' value='$rd'>"; |
|
134 | - print " <input type='hidden' name='name$m' value='$name'>"; |
|
135 | - print "</td>"; |
|
136 | - //description |
|
137 | - print "<td>"; |
|
138 | - print " <input type='text' class='form-control input-sm' name='description$m'>"; |
|
139 | - print "</td>"; |
|
140 | - // custom |
|
141 | - if (isset($required_fields)) { |
|
142 | - foreach ($required_fields as $field) { |
|
143 | - # replace spaces with | |
|
144 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
145 | - |
|
146 | - print ' <td>'. "\n"; |
|
147 | - |
|
148 | - //set type |
|
149 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
150 | - //parse values |
|
151 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
152 | - //null |
|
153 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
154 | - |
|
155 | - print "<select name='$field[nameNew]$m' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
156 | - foreach($tmp as $v) { |
|
157 | - if($v==@$address[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
158 | - else { print "<option value='$v'>$v</option>"; } |
|
159 | - } |
|
160 | - print "</select>"; |
|
161 | - } |
|
162 | - //date and time picker |
|
163 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
164 | - // just for first |
|
165 | - if($timeP==0) { |
|
166 | - print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
167 | - print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
168 | - print '<script type="text/javascript">'; |
|
169 | - print '$(document).ready(function() {'; |
|
170 | - //date only |
|
171 | - print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
172 | - //date + time |
|
173 | - print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
174 | - |
|
175 | - print '})'; |
|
176 | - print '</script>'; |
|
177 | - } |
|
178 | - $timeP++; |
|
179 | - |
|
180 | - //set size |
|
181 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
182 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
183 | - |
|
184 | - //field |
|
185 | - if(!isset($address[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'].$m .'" maxlength="'.$size.'" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
186 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'].$m .'" maxlength="'.$size.'" value="'. $address[$field['name']]. '" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
187 | - } |
|
188 | - //boolean |
|
189 | - elseif($field['type'] == "tinyint(1)") { |
|
190 | - print "<select name='$field[nameNew]$m' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
191 | - $tmp = array(0=>"No",1=>"Yes"); |
|
192 | - //null |
|
193 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
194 | - |
|
195 | - foreach($tmp as $k=>$v) { |
|
196 | - if(strlen(@$address[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
197 | - elseif($k==@$address[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
198 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
199 | - } |
|
200 | - print "</select>"; |
|
201 | - } |
|
202 | - //default - input field |
|
203 | - else { |
|
204 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'].$m .'" placeholder="'. $field['name'] .'" value="'. @$address[$field['name']]. '" size="30" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
205 | - } |
|
129 | + //name |
|
130 | + print "<td>$name</td>"; |
|
131 | + //rd |
|
132 | + print "<td>"; |
|
133 | + print " <input type='text' class='form-control input-sm' name='rd$m' value='$rd'>"; |
|
134 | + print " <input type='hidden' name='name$m' value='$name'>"; |
|
135 | + print "</td>"; |
|
136 | + //description |
|
137 | + print "<td>"; |
|
138 | + print " <input type='text' class='form-control input-sm' name='description$m'>"; |
|
139 | + print "</td>"; |
|
140 | + // custom |
|
141 | + if (isset($required_fields)) { |
|
142 | + foreach ($required_fields as $field) { |
|
143 | + # replace spaces with | |
|
144 | + $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
145 | + |
|
146 | + print ' <td>'. "\n"; |
|
147 | + |
|
148 | + //set type |
|
149 | + if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
150 | + //parse values |
|
151 | + $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
152 | + //null |
|
153 | + if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
154 | + |
|
155 | + print "<select name='$field[nameNew]$m' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
156 | + foreach($tmp as $v) { |
|
157 | + if($v==@$address[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
158 | + else { print "<option value='$v'>$v</option>"; } |
|
159 | + } |
|
160 | + print "</select>"; |
|
161 | + } |
|
162 | + //date and time picker |
|
163 | + elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
164 | + // just for first |
|
165 | + if($timeP==0) { |
|
166 | + print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
167 | + print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
168 | + print '<script type="text/javascript">'; |
|
169 | + print '$(document).ready(function() {'; |
|
170 | + //date only |
|
171 | + print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
172 | + //date + time |
|
173 | + print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
174 | + |
|
175 | + print '})'; |
|
176 | + print '</script>'; |
|
177 | + } |
|
178 | + $timeP++; |
|
179 | + |
|
180 | + //set size |
|
181 | + if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
182 | + else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
183 | + |
|
184 | + //field |
|
185 | + if(!isset($address[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'].$m .'" maxlength="'.$size.'" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
186 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'].$m .'" maxlength="'.$size.'" value="'. $address[$field['name']]. '" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
187 | + } |
|
188 | + //boolean |
|
189 | + elseif($field['type'] == "tinyint(1)") { |
|
190 | + print "<select name='$field[nameNew]$m' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
191 | + $tmp = array(0=>"No",1=>"Yes"); |
|
192 | + //null |
|
193 | + if($field['Null']!="NO") { $tmp[2] = ""; } |
|
194 | + |
|
195 | + foreach($tmp as $k=>$v) { |
|
196 | + if(strlen(@$address[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
197 | + elseif($k==@$address[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
198 | + else { print "<option value='$k'>"._($v)."</option>"; } |
|
199 | + } |
|
200 | + print "</select>"; |
|
201 | + } |
|
202 | + //default - input field |
|
203 | + else { |
|
204 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'].$m .'" placeholder="'. $field['name'] .'" value="'. @$address[$field['name']]. '" size="30" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
205 | + } |
|
206 | 206 | |
207 | 207 | print " </td>"; |
208 | - } |
|
209 | - } |
|
210 | - //remove button |
|
211 | - print "<td><a href='' class='btn btn-xs btn-danger resultRemove' data-target='result$m'><i class='fa fa-times'></i></a></td>"; |
|
212 | - print "</tr>"; |
|
213 | - |
|
214 | - $m++; |
|
215 | - } |
|
216 | - |
|
217 | - //submit |
|
218 | - print "<tr>"; |
|
219 | - print " <td colspan='$colspan'>"; |
|
220 | - print " <div id='vrfScanAddResult'></div>"; |
|
221 | - print " <a href='' class='btn btn-sm btn-success pull-right' id='saveVrfScanResults'><i class='fa fa-plus'></i> "._("Add discovered vrfs")."</a>"; |
|
222 | - print " </td>"; |
|
223 | - print "</tr>"; |
|
224 | - |
|
225 | - print "</table>"; |
|
226 | - print "</form>"; |
|
208 | + } |
|
209 | + } |
|
210 | + //remove button |
|
211 | + print "<td><a href='' class='btn btn-xs btn-danger resultRemove' data-target='result$m'><i class='fa fa-times'></i></a></td>"; |
|
212 | + print "</tr>"; |
|
213 | + |
|
214 | + $m++; |
|
215 | + } |
|
216 | + |
|
217 | + //submit |
|
218 | + print "<tr>"; |
|
219 | + print " <td colspan='$colspan'>"; |
|
220 | + print " <div id='vrfScanAddResult'></div>"; |
|
221 | + print " <a href='' class='btn btn-sm btn-success pull-right' id='saveVrfScanResults'><i class='fa fa-plus'></i> "._("Add discovered vrfs")."</a>"; |
|
222 | + print " </td>"; |
|
223 | + print "</tr>"; |
|
224 | + |
|
225 | + print "</table>"; |
|
226 | + print "</form>"; |
|
227 | 227 | |
228 | 228 | // print errors |
229 | 229 | if (isset($errors)) { |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | |
33 | 33 | // set sections |
34 | 34 | foreach($_POST as $key=>$line) { |
35 | - if (strlen(strstr($key,"section-"))>0) { |
|
36 | - $key2 = str_replace("section-", "", $key); |
|
37 | - $temp[] = $key2; |
|
38 | - unset($_POST[$key]); |
|
39 | - } |
|
35 | + if (strlen(strstr($key,"section-"))>0) { |
|
36 | + $key2 = str_replace("section-", "", $key); |
|
37 | + $temp[] = $key2; |
|
38 | + unset($_POST[$key]); |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | # glue sections together |
42 | 42 | $_POST['sections'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
@@ -45,18 +45,18 @@ discard block |
||
45 | 45 | |
46 | 46 | # set update array |
47 | 47 | $values = array("vrfId"=>@$_POST['vrfId'], |
48 | - "name"=>$_POST['name'], |
|
49 | - "rd"=>$_POST['rd'], |
|
50 | - "sections"=>$_POST['sections'], |
|
51 | - "description"=>$_POST['description'] |
|
52 | - ); |
|
48 | + "name"=>$_POST['name'], |
|
49 | + "rd"=>$_POST['rd'], |
|
50 | + "sections"=>$_POST['sections'], |
|
51 | + "description"=>$_POST['description'] |
|
52 | + ); |
|
53 | 53 | # append custom |
54 | 54 | if(sizeof($custom) > 0) { |
55 | - foreach($custom as $myField) { |
|
56 | - # replace possible ___ back to spaces! |
|
57 | - $myField['nameTest'] = str_replace(" ", "___", $myField['name']); |
|
58 | - if(isset($_POST[$myField['nameTest']])) { $values[$myField['name']] = @$_POST[$myField['nameTest']];} |
|
59 | - } |
|
55 | + foreach($custom as $myField) { |
|
56 | + # replace possible ___ back to spaces! |
|
57 | + $myField['nameTest'] = str_replace(" ", "___", $myField['name']); |
|
58 | + if(isset($_POST[$myField['nameTest']])) { $values[$myField['name']] = @$_POST[$myField['nameTest']];} |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | # update |
@@ -33,33 +33,33 @@ |
||
33 | 33 | |
34 | 34 | # loop |
35 | 35 | if ($all_types!==false) { |
36 | - // cast |
|
37 | - $all_types = (array) $all_types; |
|
38 | - // loop |
|
39 | - foreach ($all_types as $type) { |
|
40 | - //cast |
|
41 | - $type = (array) $type; |
|
36 | + // cast |
|
37 | + $all_types = (array) $all_types; |
|
38 | + // loop |
|
39 | + foreach ($all_types as $type) { |
|
40 | + //cast |
|
41 | + $type = (array) $type; |
|
42 | 42 | |
43 | - //format type |
|
44 | - $showtag = $type['showtag']==1 ? "Yes" : "No"; |
|
43 | + //format type |
|
44 | + $showtag = $type['showtag']==1 ? "Yes" : "No"; |
|
45 | 45 | |
46 | - //print details |
|
47 | - print '<tr>'. "\n"; |
|
48 | - print ' <td>'. $type['type'] .'</td>'. "\n"; |
|
49 | - print ' <td>'.$showtag.'</td>'. "\n"; |
|
50 | - print ' <td style="background-color:'.$type['bgcolor'].'">'. $type['bgcolor'] .'</td>'. "\n"; |
|
51 | - print ' <td style="background-color:'.$type['fgcolor'].'">'. $type['fgcolor'] .'</td>'. "\n"; |
|
52 | - print ' <td>'. $type['compress'] .'</td>'. "\n"; |
|
53 | - print ' <td>'. $type['locked'] .'</td>'. "\n"; |
|
46 | + //print details |
|
47 | + print '<tr>'. "\n"; |
|
48 | + print ' <td>'. $type['type'] .'</td>'. "\n"; |
|
49 | + print ' <td>'.$showtag.'</td>'. "\n"; |
|
50 | + print ' <td style="background-color:'.$type['bgcolor'].'">'. $type['bgcolor'] .'</td>'. "\n"; |
|
51 | + print ' <td style="background-color:'.$type['fgcolor'].'">'. $type['fgcolor'] .'</td>'. "\n"; |
|
52 | + print ' <td>'. $type['compress'] .'</td>'. "\n"; |
|
53 | + print ' <td>'. $type['locked'] .'</td>'. "\n"; |
|
54 | 54 | |
55 | - print " <td class='actions'>"; |
|
56 | - print " <div class='btn-group'>"; |
|
57 | - print " <button class='btn btn-xs btn-default editType' data-action='edit' data-id='$type[id]'><i class='fa fa-pencil'></i></button>"; |
|
58 | - print " <button class='btn btn-xs btn-default editType' data-action='delete' data-id='$type[id]'><i class='fa fa-times'></i></button>"; |
|
59 | - print " </div>"; |
|
60 | - print " </td>"; |
|
61 | - print '</tr>'. "\n"; |
|
62 | - } |
|
55 | + print " <td class='actions'>"; |
|
56 | + print " <div class='btn-group'>"; |
|
57 | + print " <button class='btn btn-xs btn-default editType' data-action='edit' data-id='$type[id]'><i class='fa fa-pencil'></i></button>"; |
|
58 | + print " <button class='btn btn-xs btn-default editType' data-action='delete' data-id='$type[id]'><i class='fa fa-times'></i></button>"; |
|
59 | + print " </div>"; |
|
60 | + print " </td>"; |
|
61 | + print '</tr>'. "\n"; |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | print '</table>'. "\n"; |
65 | 65 | ?> |
@@ -24,28 +24,28 @@ discard block |
||
24 | 24 | |
25 | 25 | # fetch old values |
26 | 26 | if($_POST['action']=="delete") { |
27 | - $old_tag = $Admin->fetch_object ("ipTags", "id", $_POST['id']); |
|
27 | + $old_tag = $Admin->fetch_object ("ipTags", "id", $_POST['id']); |
|
28 | 28 | } |
29 | 29 | else { |
30 | - $old_tag = new StdClass (); |
|
30 | + $old_tag = new StdClass (); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /* checks */ |
34 | 34 | if($_POST['action']=="delete" && $old_tag->locked!="No") { $Result->show("danger", _("Cannot delete locked tag"), true); } |
35 | 35 | if($_POST['action']!="delete") { |
36 | - if(strlen($_POST['type'])<3) { $Result->show("danger", _("Invalid tag name"), true); } |
|
37 | - if(strlen($_POST['bgcolor'])<4) { $Result->show("danger", _("Invalid bg color"), true); } |
|
38 | - if(strlen($_POST['fgcolor'])<4) { $Result->show("danger", _("Invalid fg color"), true); } |
|
36 | + if(strlen($_POST['type'])<3) { $Result->show("danger", _("Invalid tag name"), true); } |
|
37 | + if(strlen($_POST['bgcolor'])<4) { $Result->show("danger", _("Invalid bg color"), true); } |
|
38 | + if(strlen($_POST['fgcolor'])<4) { $Result->show("danger", _("Invalid fg color"), true); } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | # create array of values for modification |
42 | 42 | $values = array("id"=>@$_POST['id'], |
43 | - "type"=>$_POST['type'], |
|
44 | - "bgcolor"=>@$_POST['bgcolor'], |
|
45 | - "fgcolor"=>@$_POST['fgcolor'], |
|
46 | - "showtag"=>@$_POST['showtag'], |
|
47 | - "compress"=>@$_POST['compress'] |
|
48 | - ); |
|
43 | + "type"=>$_POST['type'], |
|
44 | + "bgcolor"=>@$_POST['bgcolor'], |
|
45 | + "fgcolor"=>@$_POST['fgcolor'], |
|
46 | + "showtag"=>@$_POST['showtag'], |
|
47 | + "compress"=>@$_POST['compress'] |
|
48 | + ); |
|
49 | 49 | |
50 | 50 | # execute |
51 | 51 | if(!$Admin->object_modify("ipTags", $_POST['action'], "id", $values)) { $Result->show("danger", _("Tag $_POST[action] error"), true); } |
@@ -53,6 +53,6 @@ discard block |
||
53 | 53 | |
54 | 54 | # reset if delete to online |
55 | 55 | if($_POST['action']=="delete") { |
56 | - $Admin->update_object_references ("ipaddresses", "state", $old_tag->id, 0); |
|
56 | + $Admin->update_object_references ("ipaddresses", "state", $old_tag->id, 0); |
|
57 | 57 | } |
58 | 58 | ?> |
59 | 59 | \ No newline at end of file |
@@ -24,10 +24,10 @@ |
||
24 | 24 | |
25 | 25 | # fetch api for edit / add |
26 | 26 | if($_POST['action']!="add") { |
27 | - # fetch api details |
|
28 | - $tag = $Admin->fetch_object ("ipTags", "id", $_POST['id']); |
|
29 | - # null ? |
|
30 | - $tag===false ? $Result->show("danger", _("Invalid ID"), true, true) : null; |
|
27 | + # fetch api details |
|
28 | + $tag = $Admin->fetch_object ("ipTags", "id", $_POST['id']); |
|
29 | + # null ? |
|
30 | + $tag===false ? $Result->show("danger", _("Invalid ID"), true, true) : null; |
|
31 | 31 | } |
32 | 32 | ?> |
33 | 33 |