Skip to content

Commit

Permalink
coding standard updates
Browse files Browse the repository at this point in the history
  • Loading branch information
detain committed Apr 4, 2019
1 parent b799d18 commit 9cbd489
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 49 deletions.
8 changes: 4 additions & 4 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public static function getMenu(GenericEvent $event)
*/
public static function getRequirements(GenericEvent $event)
{
/**
* @var \MyAdmin\Plugins\Loader $this->loader
*/
$loader = $event->getSubject();
/**
* @var \MyAdmin\Plugins\Loader $this->loader
*/
$loader = $event->getSubject();
$loader->add_page_requirement('add_ips', '/../vendor/detain/ip_vlan_manager/src/add_ips.php');
$loader->add_page_requirement('add_ips_to_server', '/../vendor/detain/ip_vlan_manager/src/add_ips_to_server.php');
$loader->add_page_requirement('add_vlan', '/../vendor/detain/ip_vlan_manager/src/add_vlan.php');
Expand Down
4 changes: 3 additions & 1 deletion src/add_ips.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ function_requirements('has_acl');
if ($GLOBALS['tf']->accounts->data['demo'] == 1) {
add_output('No Updates In Demo Mode');
} else {
$db->query(make_insert_query('ips', [
$db->query(make_insert_query(
'ips',
[
'ips_ip' => $ipAddress,
'ips_serverid' => 0,
'ips_group' => $groupinfo['account_id']
Expand Down
8 changes: 6 additions & 2 deletions src/add_vlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ function_requirements('has_acl');
}
$comment = $GLOBALS['tf']->variables->request['comment'];
$ports = ':'.implode(':', $ports).':';
$db->query(make_insert_query('vlans', [
$db->query(make_insert_query(
'vlans',
[
'vlans_id' => null,
'vlans_block' => $block,
'vlans_networks' => ':'.$ipaddress.'/'.$blocksize.':',
Expand All @@ -179,7 +181,9 @@ function_requirements('has_acl');
if (in_array($ips[$x], $ips2)) {
$query = "update ips set ips_vlan='{$vlan}', ips_serverid=0, ips_group=0, ips_reserved='{$reserved}' where ips_ip='$ips[$x]'";
} else {
$query = make_insert_query('ips', [
$query = make_insert_query(
'ips',
[
'ips_ip' => $ips[$x],
'ips_vlan' => $vlan,
'ips_serverid' => 0,
Expand Down
4 changes: 3 additions & 1 deletion src/switch_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function_requirements('has_acl');
if (isset($GLOBALS['tf']->variables->request['name']) && isset($GLOBALS['tf']->variables->request['ports'])) {
$name = $GLOBALS['tf']->variables->request['name'];
$ports = $GLOBALS['tf']->variables->request['ports'];
$db->query(make_insert_query('switchmanager', [
$db->query(make_insert_query(
'switchmanager',
[
'id' => null,
'name' => $name,
'ports' => $ports
Expand Down
80 changes: 40 additions & 40 deletions src/update_switch_ports.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,44 +100,44 @@ function update_switch_ports($verbose = false, $pullServerMap = true)
add_output("$graph_id ");
}
}
/*
//$query = "select * from vlans where vlans_ports like '%:{$switchManager['id']}/{$justport}:%' or vlans_ports like '%:{$switchManager['id']}/{$port}:%'";
$query = "select * from vlans where vlans_ports like '%:{$switchManager['id']}/{$port}:%'";
//echo "$query\n";
$db->query($query, __LINE__, __FILE__);
$vlans = [];
$asset_id = 0;
while ($db->next_record(MYSQL_ASSOC)) {
$vlans[] = $db->Record['vlans_id'];
unset($vlan_ids[$db->Record['vlans_id']]);
$hostname = str_replace('append ', '', $db->Record['vlans_comment']);
$db2->query("select assets.id from assets, servers where server_id=assets.order_id and server_hostname='{$hostname}'", __LINE__, __FILE__);
if ($db2->num_rows() > 0) {
$db2->next_record();
//echo "Got assets {$db2->Record['id']} for vlan {$db->Record['vlans_id']}\n";
$asset_id = $db2->Record['id'];
} else {
$db2->query("select * from assets where hostname='{$hostname}'");
if ($db2->num_rows() > 0) {
$db2->next_record();
//echo "Got assets {$db2->Record['id']} for vlan {$db->Record['vlans_id']}\n";
$asset_id = $db2->Record['id'];
}
}
}
if (count($vlans) > 0) {
if ($verbose == true) {
add_output('('.count($vlans).' Vlans)');
}
$vlantext = implode(',', $vlans);
$db->query("update switchports set vlans='{$vlantext}', asset_id='{$asset_id}' where switch='{$switchManager['id']}' and port='{$port}'", __LINE__, __FILE__);
if ($db->affectedRows()) {
if ($verbose == true) {
add_output(", Update Vlan".PHP_EOL);
}
}
}
*/
/*
//$query = "select * from vlans where vlans_ports like '%:{$switchManager['id']}/{$justport}:%' or vlans_ports like '%:{$switchManager['id']}/{$port}:%'";
$query = "select * from vlans where vlans_ports like '%:{$switchManager['id']}/{$port}:%'";
//echo "$query\n";
$db->query($query, __LINE__, __FILE__);
$vlans = [];
$asset_id = 0;
while ($db->next_record(MYSQL_ASSOC)) {
$vlans[] = $db->Record['vlans_id'];
unset($vlan_ids[$db->Record['vlans_id']]);
$hostname = str_replace('append ', '', $db->Record['vlans_comment']);
$db2->query("select assets.id from assets, servers where server_id=assets.order_id and server_hostname='{$hostname}'", __LINE__, __FILE__);
if ($db2->num_rows() > 0) {
$db2->next_record();
//echo "Got assets {$db2->Record['id']} for vlan {$db->Record['vlans_id']}\n";
$asset_id = $db2->Record['id'];
} else {
$db2->query("select * from assets where hostname='{$hostname}'");
if ($db2->num_rows() > 0) {
$db2->next_record();
//echo "Got assets {$db2->Record['id']} for vlan {$db->Record['vlans_id']}\n";
$asset_id = $db2->Record['id'];
}
}
}
if (count($vlans) > 0) {
if ($verbose == true) {
add_output('('.count($vlans).' Vlans)');
}
$vlantext = implode(',', $vlans);
$db->query("update switchports set vlans='{$vlantext}', asset_id='{$asset_id}' where switch='{$switchManager['id']}' and port='{$port}'", __LINE__, __FILE__);
if ($db->affectedRows()) {
if ($verbose == true) {
add_output(", Update Vlan".PHP_EOL);
}
}
}
*/
if ($verbose == true) {
add_output(',');
}
Expand All @@ -148,7 +148,7 @@ function update_switch_ports($verbose = false, $pullServerMap = true)
}
add_output(sizeof(array_keys($vlan_ids)).' Unmatched VLANs'.PHP_EOL);
}
/*
/*
function_requirements('parse_vlan_ports');
$db->query("select * from vlans", __LINE__, __FILE__);
$portData = [];
Expand Down Expand Up @@ -287,7 +287,7 @@ function_requirements('parse_vlan_ports');
}
echo "Updated ".sizeof($portData)." Switchports".PHP_EOL;
//print_r($switches);
*/
*/
global $output;
echo str_replace("\n", "<br>\n", $output);
$output = '';
Expand Down
4 changes: 3 additions & 1 deletion src/vlan_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ function_requirements('update_switch_ports');
$table->add_field(
$table->make_link('choice=ip.ipblock_viewer&amp;ipblock='.$network, '<i class="icon-analyze" style="width: 20px; height: 20px;"><svg><use xlink:href="/images/myadmin/MyAdmin-Icons.min.svg#icon-analyze"></use></svg></i>', false, 'title="View"')
. $table->make_link('choice=ip.add_ips_to_server&amp;ipblock='.$network, '<i class="icon-plus" style="width: 20px; height: 20px;"><svg><use xlink:href="/images/myadmin/MyAdmin-Icons.min.svg#icon-plus"></use></svg></i>', false, 'title="Add IPs"')
. $table->make_link('choice=ip.delete_vlan&amp;ipblock='.$network, '<i class="icon-delete" style="width: 20px; height: 20px;"><svg><use xlink:href="/images/myadmin/MyAdmin-Icons.min.svg#icon-delete"></use></svg></i>', false, 'title="Delete"'), 'c');
. $table->make_link('choice=ip.delete_vlan&amp;ipblock='.$network, '<i class="icon-delete" style="width: 20px; height: 20px;"><svg><use xlink:href="/images/myadmin/MyAdmin-Icons.min.svg#icon-delete"></use></svg></i>', false, 'title="Delete"'),
'c'
);
if (isset($GLOBALS['tf']->variables->request['ipblock']) && $GLOBALS['tf']->variables->request['ipblock'] == $network) {
if (isset($GLOBALS['tf']->variables->request['edit_server'])) {
if ($ports[0] != '--') {
Expand Down

0 comments on commit 9cbd489

Please sign in to comment.