Skip to content

Commit

Permalink
Feature Cacti#1588: Check that PHP can run a test file (Cacti#1722)
Browse files Browse the repository at this point in the history
* Feature Cacti#1588: Check that PHP can run a test file

* Feature Cacti#1628 - Allow the User to define a initial Network Discovery during Setup

* Fix QA issue with PHP 5.4

* Replace \n with PHP_EOL

* Minor changes to tabs vs. space and PHP_EOL

Will have to update packages based upon this too.

* Another minor pull where PHP_EOL was removed
  • Loading branch information
netniV authored and cigamit committed Jul 21, 2018
1 parent 0bd4fe4 commit da8b516
Show file tree
Hide file tree
Showing 9 changed files with 464 additions and 203 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ Cacti CHANGELOG
-feature#1580: Support Drag & Drop for Report Items
-feature#1581: Allow Mass Adding of Graphs to Reports
-feature#1584: Allow theme selection when installing
-feature#1588: Check that PHP can run a test file
-feature#1597: Ensure synchronised files have same attributes as originals
-feature#1593: Allow External links to auto refresh
-feature#1610: Script STDERR logging
-feature#1628: Allow the User to define a initial Network Discovery during Setup
-feature#1677: Default Tree nodes sorting to be inherited
-feature#1692: Separate option for logging Input Validation issues
-feature#1691: Add a 'Copy graph' option to context menu of graphs
Expand Down
34 changes: 34 additions & 0 deletions install/cli_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/php -q
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2018 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/

/* do NOT run this script through a web browser */
if (!isset($_SERVER['argv'][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
die('<br><strong>This script is only meant to run at the command line.</strong>');
}

if (sizeof($argv)) {
$value = intval($argv[1]);
print $value * $value;
}
14 changes: 7 additions & 7 deletions install/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function db_install_add_cache ($status, $sql) {
// add query to upgrade results array by version to the cli global session
$cache_file = read_config_option('install_cache_db');
if (!empty($cache_file)) {
file_put_contents($cache_file, '<[version]> ' . $cacti_upgrade_version . ' <[status]> ' . $status . ' <[sql]> ' . clean_up_lines($sql) . "\n", FILE_APPEND);
file_put_contents($cache_file, '<[version]> ' . $cacti_upgrade_version . ' <[status]> ' . $status . ' <[sql]> ' . clean_up_lines($sql) . PHP_EOL, FILE_APPEND);
}
}

Expand Down Expand Up @@ -280,28 +280,28 @@ function install_tool_path($name, $defaultPaths) {
'default' => ''
);

tmp_log('file.log', "$name: Locations ($os)\n" . var_export($defaultPaths, true) . "\n", FILE_APPEND);
log_install('file', "$name: Locations ($os)" . PHP_EOL . var_export($defaultPaths, true));
if (isset($settings) && isset($settings['path']) && isset($settings['path']['path_'.$name])) {
$tool = $settings['path']['path_'.$name];
}

$which_tool = '';
if (config_value_exists('path_'.$name)) {
$which_tool = read_config_option('path_'.$name, true);
tmp_log('file.log', "Using config location: $which_tool\n", FILE_APPEND);
log_install('file', "Using config location: $which_tool");
}

if (empty($which_tool) && isset($defaultPaths[$os])) {
$defaultPath = $defaultPaths[$config['cacti_server_os']];
$basename = basename($defaultPath);
tmp_log('file.log', "Searching best path with location: $defaultPath\n", FILE_APPEND);
log_install('file', "Searching best path with location: $defaultPath");
$which_tool = find_best_path($basename);
tmp_log('file.log', "Searching best path with location return: $which_tool\n", FILE_APPEND);
log_install('file', "Searching best path with location return: $which_tool");
}

if (empty($which_tool)) {
$which_tool = $defaultPath;
tmp_log('file.log', "Nothing found defaulting to $defaultPath\n", FILE_APPEND);
log_install('file', "Nothing found defaulting to $defaultPath");
}

$tool['default'] = $which_tool;
Expand Down Expand Up @@ -456,7 +456,7 @@ function remote_update_config_file() {
if (sizeof($file_array)) {
foreach($file_array as $line) {
if (strpos(trim($line), "\$poller_id") !== false) {
$newfile[] = "\$poller_id = $poller_id;\n";
$newfile[] = "\$poller_id = $poller_id;" . PHP_EOL;
} else {
$newfile[] = $line;
}
Expand Down
23 changes: 23 additions & 0 deletions install/install.css
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,26 @@ label {
.flag-icon {
float: right;
}

.cactiInstallSectionNote {
font-family: consolas;
font-family: courier-new;
font-family: monospace;
font-style: italic;
}

.cactiInstallSectionNoteTitle, .cactiInstallSectionWarningTitle, .cactiInstallSectionErrorTitle {
font-weight: bold;
}

.cactiInstallSectionNoteTitle {
color: #00ae42;
}

.cactiInstallSectionWarningTitle {
color: #ffae42;
}

.cactiInstallSectionErrorTitle {
color: #ff0000;
}
46 changes: 40 additions & 6 deletions install/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const STEP_CHECK_DEPENDENCIES = 2;
const STEP_INSTALL_TYPE = 3;
const STEP_PERMISSION_CHECK = 4;
const STEP_BINARY_LOCATIONS = 5;
const STEP_DEFAULT_PROFILE = 6;
const STEP_PROFILE_AND_AUTOMATION = 6;
const STEP_TEMPLATE_INSTALL = 7;
const STEP_CHECK_TABLES = 8;
const STEP_INSTALL_CONFIRM = 9;
Expand Down Expand Up @@ -206,10 +206,32 @@ function processStepInstallType(StepData) {

function processStepPermissionCheck(StepData) {
collapseHeadings(StepData.Sections);
}

function processStepBinaryLocations(StepData) {
var errors = StepData.Errors;
$(function () {
var focusedElement;
$(document).on('focus', 'input', function () {
if (focusedElement == this) return; //already focused, return so user can now place cursor at specific point in input.
focusedElement = this;
setTimeout(function () { focusedElement.select(); }, 50); //select all text in any field on focus for easy re-entry. Delay sightly to allow focus to "stick" before selecting.
});
});

for (var propName in errors) {
if (errors.hasOwnProperty(propName)) {
propValue = errors[propName];
if (propValue) {
element = $("#" + propName);
element.focus();
break;
}
}
}
}

function processStepDefaultProfile(StepData) {
function processStepProfileAndAutomation(StepData) {
}

function processStepTemplateInstall(StepData) {
Expand Down Expand Up @@ -351,7 +373,7 @@ function prepareInstallData(installStep) {
if (typeof installStep != 'undefined') {
if (step == STEP_INSTALL_TYPE) prepareStepInstallType(newData);
else if (step == STEP_BINARY_LOCATIONS) prepareStepBinaryLocations(newData);
else if (step == STEP_DEFAULT_PROFILE) prepareStepDefaultProfile(newData);
else if (step == STEP_PROFILE_AND_AUTOMATION) prepareStepProfileAndAutomation(newData);
else if (step == STEP_TEMPLATE_INSTALL) prepareStepTemplateInstall(newData);
else if (step == STEP_CHECK_TABLES) prepareStepCheckTables(newData);

Expand Down Expand Up @@ -398,11 +420,21 @@ function prepareStepBinaryLocations(installData) {
}
}

function prepareStepDefaultProfile(installData) {
function prepareStepProfileAndAutomation(installData) {
element = $('#default_profile');
if (element != null && element.length > 0) {
installData.Profile = element[0].value;
}

element = $('#automation_mode');
if (element != null && element.length > 0) {
installData.AutomationMode = element[0].value;
}

element = $('#automation_range');
if (element != null && element.length > 0) {
installData.AutomationRange = element[0].value;
}
}

function prepareStepCheckTables(installData) {
Expand Down Expand Up @@ -477,8 +509,10 @@ function performStep(installStep) {
processStepInstallType(data.StepData);
} else if (data.Step == STEP_PERMISSION_CHECK) {
processStepPermissionCheck(data.StepData);
} else if (data.Step == STEP_DEFAULT_PROFILE) {
processStepDefaultProfile(data.StepData);
} else if (data.Step == STEP_BINARY_LOCATIONS) {
processStepBinaryLocations(data.StepData);
} else if (data.Step == STEP_PROFILE_AND_AUTOMATION) {
processStepProfileAndAutomation(data.StepData);
} else if (data.Step == STEP_TEMPLATE_INSTALL) {
processStepTemplateInstall(data.StepData);
} else if (data.Step == STEP_CHECK_TABLES) {
Expand Down
4 changes: 2 additions & 2 deletions install/step_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
);
*/

tmp_log('step.log','Start: ' . clean_up_lines(get_request_var('data')) . "\n\n");
log_install('json','Start: ' . clean_up_lines(get_request_var('data')));
$json = json_encode($installer);
tmp_log('step.log',' End: ' . clean_up_lines($json) . "\n\n", FILE_APPEND);
log_install('json',' End: ' . clean_up_lines($json) . PHP_EOL);

header('Content-Type: application/json');
header('Content-Length: ' . strlen($json));
Expand Down
Loading

0 comments on commit da8b516

Please sign in to comment.