Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSR2 Cleanup: /html edition #4117

Merged
merged 3 commits into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 0 additions & 3 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@


$finder = Symfony\CS\Finder\DefaultFinder::create()
->exclude('html/includes/geshi')
->exclude('html/includes/jpgraph')
->exclude('html/includes/Slim')
->exclude('html/lib')
->exclude('lib')
->exclude('logs')
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ matrix:
- php: 5.6
env:
PHP_L=1
PHPCS=0
PHP_CS=1
EXECUTE_BUILD_DOCS=true
- php: hhvm
env:
Expand All @@ -46,5 +46,5 @@ after_success:
script:
- if [[ $PHP_L == 1 ]]; then find . -path './vendor' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1; fi
- if [[ $PHP_L_OLD == 1 ]]; then find . -regextype posix-extended -regex "\./(lib/influxdb-php|vendor)" -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1; fi
- if [[ $PHP_CS == 1 ]]; then vendor/bin/phpcs -n -p --colors --extensions=php --standard=PSR2 --ignore=html/lib/* .; fi
- if [[ $PHP_CS == 1 ]]; then vendor/bin/phpcs -n -p --colors --extensions=php --standard=PSR2 --ignore=html/lib/* html; fi
- phpunit
2 changes: 1 addition & 1 deletion doc/Developing/Dynamic-Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ echo '
<form class="form-horizontal" role="form" action="" method="post">
';

echo generate_dynamic_config_panel('Email transport',true,$config_groups,$mail_conf,'mail');
echo generate_dynamic_config_panel('Email transport',$config_groups,$mail_conf,'mail');

echo '
</form>
Expand Down
12 changes: 5 additions & 7 deletions html/ajax_dash.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@
$output = "<span style='text-align:left;'><br><h3>Click on the Edit Dashboard button (next to the list of dashboards) to add widgets</h3><br><h4><strong>Remember:</strong> You can only move & resize widgets when you're in <strong>Edit Mode</strong>.</h4><span>";
$status = 'ok';
$title = 'Placeholder';
}
elseif (is_file('includes/common/'.$type.'.inc.php')) {

} elseif (is_file('includes/common/'.$type.'.inc.php')) {
$results_limit = 10;
$typeahead_limit = $config['webui']['global_search_result_limit'];
$no_form = true;
$title = ucfirst($type);
$unique_id = str_replace(array("-","."),"_",uniqid($type,true));
$unique_id = str_replace(array("-","."), "_", uniqid($type, true));
$widget_id = mres($_POST['id']);
$widget_settings = json_decode(dbFetchCell('select settings from users_widgets where user_widget_id = ?',array($widget_id)),true);
$widget_settings = json_decode(dbFetchCell('select settings from users_widgets where user_widget_id = ?', array($widget_id)), true);
$widget_dimensions = $_POST['dimensions'];
if( !empty($_POST['settings']) ) {
define('show_settings',true);
if (!empty($_POST['settings'])) {
define('SHOW_SETTINGS', true);
}
include 'includes/common/'.$type.'.inc.php';
$output = implode('', $common_output);
Expand Down
13 changes: 5 additions & 8 deletions html/ajax_rulesuggest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
* @param array $obj Object to sort
* @return array
*/
function levsort($base, $obj) {
function levsort($base, $obj)
{
$ret = array();
foreach ($obj as $elem) {
$lev = levenshtein($base, $elem, 1, 10, 10);
if ($lev == 0) {
return array(array('name' => $elem));
}
else {
} else {
while (isset($ret["$lev"])) {
$lev += 0.1;
}
Expand All @@ -59,7 +59,6 @@ function levsort($base, $obj) {

ksort($ret);
return $ret;

}

header('Content-type: application/json');
Expand All @@ -76,8 +75,7 @@ function levsort($base, $obj) {
foreach ($config['alert']['macros']['rule'] as $macro => $v) {
$chk[] = 'macros.'.$macro;
}
}
else {
} else {
$tmp = dbFetchRows('SHOW COLUMNS FROM '.$term[0]);
foreach ($tmp as $tst) {
if (isset($tst['Field'])) {
Expand All @@ -87,8 +85,7 @@ function levsort($base, $obj) {
}

$current = true;
}
else {
} else {
$tmp = dbFetchRows("SELECT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'device_id'");
foreach ($tmp as $tst) {
$chk[] = $tst['TABLE_NAME'].'.';
Expand Down
99 changes: 33 additions & 66 deletions html/ajax_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,23 @@
'name' => 'g:'.$group['name'],
'group_id' => $group['id'],
);
}
else {
} else {
$results[] = array('name' => $group['name']);
}
}

die(json_encode($results));
}
else if ($_REQUEST['type'] == 'alert-rules') {
} elseif ($_REQUEST['type'] == 'alert-rules') {
foreach (dbFetchRows("SELECT name FROM alert_rules WHERE name LIKE '%".$search."%'") as $rules) {
$results[] = array('name' => $rules['name']);
}

die(json_encode($results));
}
else if ($_REQUEST['type'] == 'device') {
} elseif ($_REQUEST['type'] == 'device') {
// Device search
if (is_admin() === true || is_read() === true) {
$results = dbFetchRows("SELECT * FROM `devices` WHERE `hostname` LIKE '%".$search."%' OR `location` LIKE '%".$search."%' OR `sysName` LIKE '%".$search."%' ORDER BY hostname LIMIT ".$limit);
}
else {
} else {
$results = dbFetchRows("SELECT * FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND (`hostname` LIKE '%".$search."%' OR `location` LIKE '%".$search."%') ORDER BY hostname LIMIT ".$limit, array($_SESSION['user_id']));
}

Expand All @@ -67,21 +63,17 @@
}
if ($result['disabled'] == 1) {
$highlight_colour = '#808080';
}
else if ($result['ignored'] == 1 && $result['disabled'] == 0) {
} elseif ($result['ignored'] == 1 && $result['disabled'] == 0) {
$highlight_colour = '#000000';
}
else if ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
} elseif ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#ff0000';
}
else if ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
} elseif ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#008000';
}

if (is_admin() === true || is_read() === true) {
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE device_id = ?', array($result['device_id']));
}
else {
} else {
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `I`.`device_id` = `D`.`device_id` AND device_id = ?', array($_SESSION['user_id'], $result['device_id']));
}

Expand All @@ -102,13 +94,11 @@

$json = json_encode($device);
die($json);
}
else if ($_REQUEST['type'] == 'ports') {
} elseif ($_REQUEST['type'] == 'ports') {
// Search ports
if (is_admin() === true || is_read() === true) {
$results = dbFetchRows("SELECT `ports`.*,`devices`.* FROM `ports` LEFT JOIN `devices` ON `ports`.`device_id` = `devices`.`device_id` WHERE `ifAlias` LIKE '%".$search."%' OR `ifDescr` LIKE '%".$search."%' OR `ifName` LIKE '%".$search."%' ORDER BY ifDescr LIMIT ".$limit);
}
else {
} else {
$results = dbFetchRows("SELECT DISTINCT(`I`.`port_id`), `I`.*, `D`.`hostname` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` AND (`ifAlias` LIKE '%".$search."%' OR `ifDescr` LIKE '%".$search."%' OR `ifName` LIKE '%".$search."%') ORDER BY ifDescr LIMIT ".$limit, array($_SESSION['user_id'], $_SESSION['user_id']));
}

Expand All @@ -122,20 +112,16 @@
if ($result['deleted'] == 0 && ($result['ignore'] == 0 || $result['ignore'] == 0) && ($result['ifInErrors_delta'] > 0 || $result['ifOutErrors_delta'] > 0)) {
// Errored ports
$port_colour = '#ffa500';
}
else if ($result['deleted'] == 0 && ($result['ignore'] == 1 || $result['ignore'] == 1)) {
} elseif ($result['deleted'] == 0 && ($result['ignore'] == 1 || $result['ignore'] == 1)) {
// Ignored ports
$port_colour = '#000000';
}
else if ($result['deleted'] == 0 && $result['ifAdminStatus'] == 'down' && $result['ignore'] == 0 && $result['ignore'] == 0) {
} elseif ($result['deleted'] == 0 && $result['ifAdminStatus'] == 'down' && $result['ignore'] == 0 && $result['ignore'] == 0) {
// Shutdown ports
$port_colour = '#808080';
}
else if ($result['deleted'] == 0 && $result['ifOperStatus'] == 'down' && $result['ifAdminStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0) {
} elseif ($result['deleted'] == 0 && $result['ifOperStatus'] == 'down' && $result['ifAdminStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0) {
// Down ports
$port_colour = '#ff0000';
}
else if ($result['deleted'] == 0 && $result['ifOperStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0) {
} elseif ($result['deleted'] == 0 && $result['ifOperStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0) {
// Up ports
$port_colour = '#008000';
}//end if
Expand All @@ -154,13 +140,11 @@

$json = json_encode($ports);
die($json);
}
else if ($_REQUEST['type'] == 'bgp') {
} elseif ($_REQUEST['type'] == 'bgp') {
// Search bgp peers
if (is_admin() === true || is_read() === true) {
$results = dbFetchRows("SELECT `bgpPeers`.*,`devices`.* FROM `bgpPeers` LEFT JOIN `devices` ON `bgpPeers`.`device_id` = `devices`.`device_id` WHERE `astext` LIKE '%".$search."%' OR `bgpPeerIdentifier` LIKE '%".$search."%' OR `bgpPeerRemoteAs` LIKE '%".$search."%' ORDER BY `astext` LIMIT ".$limit);
}
else {
} else {
$results = dbFetchRows("SELECT `bgpPeers`.*,`D`.* FROM `bgpPeers`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `bgpPeers`.`device_id`=`D`.`device_id` AND (`astext` LIKE '%".$search."%' OR `bgpPeerIdentifier` LIKE '%".$search."%' OR `bgpPeerRemoteAs` LIKE '%".$search."%') ORDER BY `astext` LIMIT ".$limit, array($_SESSION['user_id']));
}

Expand All @@ -176,20 +160,17 @@
if ($result['bgpPeerAdminStatus'] == 'start' && $result['bgpPeerState'] != 'established') {
// Session active but errored
$port_colour = '#ffa500';
}
else if ($result['bgpPeerAdminStatus'] != 'start') {
} elseif ($result['bgpPeerAdminStatus'] != 'start') {
// Session inactive
$port_colour = '#000000';
}
else if ($result['bgpPeerAdminStatus'] == 'start' && $result['bgpPeerState'] == 'established') {
} elseif ($result['bgpPeerAdminStatus'] == 'start' && $result['bgpPeerState'] == 'established') {
// Session Up
$port_colour = '#008000';
}

if ($result['bgpPeerRemoteAs'] == $result['bgpLocalAs']) {
$bgp_image = 'images/16/brick_link.png';
}
else {
} else {
$bgp_image = 'images/16/world_link.png';
}

Expand All @@ -209,13 +190,11 @@

$json = json_encode($bgp);
die($json);
}
else if ($_REQUEST['type'] == 'applications') {
} elseif ($_REQUEST['type'] == 'applications') {
// Device search
if (is_admin() === true || is_read() === true) {
$results = dbFetchRows("SELECT * FROM `applications` INNER JOIN `devices` ON devices.device_id = applications.device_id WHERE `app_type` LIKE '%".$search."%' OR `hostname` LIKE '%".$search."%' ORDER BY hostname LIMIT ".$limit);
}
else {
} else {
$results = dbFetchRows("SELECT * FROM `applications` INNER JOIN `devices` AS `D` ON `D`.`device_id` = `applications`.`device_id` INNER JOIN `devices_perms` AS `P` ON `P`.`device_id` = `D`.`device_id` WHERE `P`.`user_id` = ? AND (`app_type` LIKE '%".$search."%' OR `hostname` LIKE '%".$search."%') ORDER BY hostname LIMIT ".$limit, array($_SESSION['user_id']));
}

Expand All @@ -227,14 +206,11 @@
$name = $result['app_type'];
if ($result['disabled'] == 1) {
$highlight_colour = '#808080';
}
else if ($result['ignored'] == 1 && $result['disabled'] == 0) {
} elseif ($result['ignored'] == 1 && $result['disabled'] == 0) {
$highlight_colour = '#000000';
}
else if ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
} elseif ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#ff0000';
}
else if ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
} elseif ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#008000';
}

Expand All @@ -255,13 +231,11 @@

$json = json_encode($device);
die($json);
}
else if ($_REQUEST['type'] == 'munin') {
} elseif ($_REQUEST['type'] == 'munin') {
// Device search
if (is_admin() === true || is_read() === true) {
$results = dbFetchRows("SELECT * FROM `munin_plugins` INNER JOIN `devices` ON devices.device_id = munin_plugins.device_id WHERE `mplug_type` LIKE '%".$search."%' OR `mplug_title` LIKE '%".$search."%' OR `hostname` LIKE '%".$search."%' ORDER BY hostname LIMIT ".$limit);
}
else {
} else {
$results = dbFetchRows("SELECT * FROM `munin_plugins` INNER JOIN `devices` AS `D` ON `D`.`device_id` = `munin_plugins`.`device_id` INNER JOIN `devices_perms` AS `P` ON `P`.`device_id` = `D`.`device_id` WHERE `P`.`user_id` = ? AND (`mplug_type` LIKE '%".$search."%' OR `mplug_title` LIKE '%".$search."%' OR `hostname` LIKE '%".$search."%') ORDER BY hostname LIMIT ".$limit, array($_SESSION['user_id']));
}

Expand All @@ -273,14 +247,11 @@
$name = $result['mplug_title'];
if ($result['disabled'] == 1) {
$highlight_colour = '#808080';
}
else if ($result['ignored'] == 1 && $result['disabled'] == 0) {
} elseif ($result['ignored'] == 1 && $result['disabled'] == 0) {
$highlight_colour = '#000000';
}
else if ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
} elseif ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#ff0000';
}
else if ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
} elseif ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#008000';
}

Expand All @@ -301,13 +272,11 @@

$json = json_encode($device);
die($json);
}
else if ($_REQUEST['type'] == 'iftype') {
} elseif ($_REQUEST['type'] == 'iftype') {
// Device search
if (is_admin() === true || is_read() === true) {
$results = dbFetchRows("SELECT `ports`.ifType FROM `ports` WHERE `ifType` LIKE '%".$search."%' GROUP BY ifType ORDER BY ifType LIMIT ".$limit);
}
else {
} else {
$results = dbFetchRows("SELECT `I`.ifType FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` AND (`ifType` LIKE '%".$search."%') GROUP BY ifType ORDER BY ifType LIMIT ".$limit, array($_SESSION['user_id'], $_SESSION['user_id']));
}
if (count($results)) {
Expand All @@ -323,13 +292,11 @@

$json = json_encode($device);
die($json);
}
else if ($_REQUEST['type'] == 'bill') {
} elseif ($_REQUEST['type'] == 'bill') {
// Device search
if (is_admin() === true || is_read() === true) {
$results = dbFetchRows("SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` WHERE `bill_name` LIKE '%".$search."%' OR `bill_notes` LIKE '%".$search."%' LIMIT ".$limit);
}
else {
} else {
$results = dbFetchRows("SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` INNER JOIN `bill_perms` ON `bills`.bill_id = `bill_perms`.bill_id WHERE `bill_perms`.user_id = ? AND (`bill_name` LIKE '%".$search."%' OR `bill_notes` LIKE '%".$search."%') LIMIT ".$limit, array($_SESSION['user_id']));
}
$json = json_encode($results);
Expand Down
2 changes: 1 addition & 1 deletion html/ajax_setresolution.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
session_start();
if(isset($_REQUEST['width']) AND isset($_REQUEST['height'])) {
if (isset($_REQUEST['width']) and isset($_REQUEST['height'])) {
$_SESSION['screen_width'] = $_REQUEST['width'];
$_SESSION['screen_height'] = $_REQUEST['height'];
}
Expand Down
2 changes: 1 addition & 1 deletion html/api_v0.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function () use ($app) {
);
}
);
// End Routing
// End Routing
// Resources section
$app->group(
'/resources',
Expand Down
Loading