From 4179c0d3411746fcbfc072fddc23b90e0841c6c0 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Thu, 8 Nov 2018 10:20:22 +0100 Subject: [PATCH 1/4] fixed user edit update bug: not able to empty email and phone number fields and console errors. Also added validation to email and phone number inputs --- pandora_console/operation/users/user_edit.php | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 1520b2e942..b960e9805f 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -74,9 +74,9 @@ if (isset ($_GET["modified"]) && !$view_mode) { $upd_info["lastname"] = get_parameter_post ("lastname", $user_info["lastname"]); $password_new = get_parameter_post ("password_new", ""); $password_confirm = get_parameter_post ("password_conf", ""); - $upd_info["email"] = get_parameter_post ("email", $user_info["email"]); - $upd_info["phone"] = get_parameter_post ("phone", $user_info["phone"]); - $upd_info["comments"] = get_parameter_post ("comments", $user_info["comments"]); + $upd_info["email"] = get_parameter_post ("email", ""); + $upd_info["phone"] = get_parameter_post ("phone", ""); + $upd_info["comments"] = get_parameter_post ("comments", ""); $upd_info["language"] = get_parameter_post ("language", $user_info["language"]); $upd_info["timezone"] = get_parameter_post ("timezone", ""); $upd_info["id_skin"] = get_parameter ("skin", $user_info["id_skin"]); @@ -151,12 +151,20 @@ if (isset ($_GET["modified"]) && !$view_mode) { // No need to display "error" here, because when no update is needed (no changes in data) // SQL function returns 0 (FALSE), but is not an error, just no change. Previous error // message could be confussing to the user. - - $return = update_user ($id, $upd_info); - if ($return > 0) { - ui_print_result_message ($return, - __('User info successfully updated'), - __('Error updating user info')); + + if ((filter_var($upd_info["email"], FILTER_VALIDATE_EMAIL) || $upd_info["email"]=="") && (preg_match('/^[0-9- ]+$/D', $upd_info["phone"]) || $upd_info["phone"]=="")) { + $return = update_user ($id, $upd_info); + if ($return > 0) { + ui_print_result_message ($return, + __('User info successfully updated'), + __('Error updating user info')); + } + } + else if (!filter_var($upd_info["email"], FILTER_VALIDATE_EMAIL)) { + ui_print_error_message (__('Please enter a valid email')); + } + else if (!preg_match('/^[0-9- ]+$/D', $upd_info["phone"])) { + ui_print_error_message (__('Please enter a valid phone number')); } $user_info = $upd_info; @@ -188,7 +196,7 @@ $data = array(); $data[0] = '' . __('User ID') . ''; $data[0] .= $jump . '' . $id . ''; $data[1] = '' . __('Full (display) name') . ''; -$data[1] .= $jump . '' . html_print_input_text_extended ("fullname", $user_info["fullname"], '', '', 20, 100, $view_mode, '', 'class="input"', true).''; +$data[1] .= $jump . '' . html_print_input_text_extended ("fullname", $user_info["fullname"], 'fullname', '', 20, 100, $view_mode, '', 'class="input"', true).''; // Show "Picture" (in future versions, why not, allow users to upload it's own avatar here. if (is_user_admin ($id)) { @@ -210,9 +218,9 @@ $table->data[] = $data; $data = array(); $data[0] = ''.__('E-mail').''; -$data[0] .= $jump .''. html_print_input_text_extended ("email", $user_info["email"], '', '', '25', '100', $view_mode, '', 'class="input"', true).''; +$data[0] .= $jump .''. html_print_input_text_extended ("email", $user_info["email"], 'email', '', '25', '100', $view_mode, '', 'class="input"', true).''; $data[1] = ''.__('Phone number').''; -$data[1] .= $jump . '
'.html_print_input_text_extended ("phone", $user_info["phone"], '', '', '20', '30', $view_mode, '', 'class="input"', true).'
'; +$data[1] .= $jump . '
'.html_print_input_text_extended ("phone", $user_info["phone"], 'phone', '', '20', '30', $view_mode, '', 'class="input"', true).'
'; $table->rowclass[] = ''; $table->rowstyle[] = 'font-weight: bold;'; $table->data[] = $data; @@ -221,9 +229,9 @@ if ($view_mode === false) { if ($config["user_can_update_password"]) { $data = array(); $data[0] = ''.__('New Password').''; - $data[0] .= $jump .''.html_print_input_text_extended ("password_new", "", '', '', '25', '45', $view_mode, '', 'class="input"', true, true).''; + $data[0] .= $jump .''.html_print_input_text_extended ("password_new", "", 'password_new', '', '25', '45', $view_mode, '', 'class="input"', true, true).''; $data[1] = ''.__('Password confirmation').''; - $data[1] .= $jump . ''.html_print_input_text_extended ("password_conf", "", '', '', '20', '45', $view_mode, '', 'class="input"', true, true).''; + $data[1] .= $jump . ''.html_print_input_text_extended ("password_conf", "", 'password_conf', '', '20', '45', $view_mode, '', 'class="input"', true, true).''; $table->rowclass[] = ''; $table->rowstyle[] = 'font-weight: bold;'; $table->data[] = $data; From ee7ff52a04c2889871cb61bd8c3739cdcd39ee6d Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 24 Dec 2018 14:25:19 +0100 Subject: [PATCH 2/4] fixed error widgets wux Former-commit-id: 149cfea6dc0d427b57f05594214374d220111031 --- pandora_console/include/graphs/pandora.d3.js | 70 +++++++++++++++++--- 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index 29728984e1..f33a3b5e68 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -1332,7 +1332,7 @@ function print_phases_donut (recipient, phases) { var svg = d3.select(recipient) .append("svg") .attr("width", 800) - .attr("height", 400) + .attr("height", 500) .append("g"); svg.append("g") @@ -1361,7 +1361,7 @@ function print_phases_donut (recipient, phases) { .outerRadius(radius * 0.9); width = 800; - height = 400; + height = 500; svg.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); var key = function(d){ return d.data.label; }; @@ -1440,6 +1440,8 @@ function print_phases_donut (recipient, phases) { return d.startAngle + (d.endAngle - d.startAngle)/2; } + var ex = 1; + var sum = 0; text.transition().duration(0) .attrTween("transform", function(d) { this._current = this._current || d; @@ -1447,8 +1449,26 @@ function print_phases_donut (recipient, phases) { this._current = interpolate(0); return function(t) { var d2 = interpolate(t); - var pos = outerArc.centroid(d2); - pos[0] = radius * (midAngle(d2) < Math.PI ? 1 : -1); + + //fix for labels of a very small portion increase the + //height of the label so that they do not overlap + if( ( d2.endAngle - d2.startAngle ) < 0.1){ + var pos = outerArc.centroid(d2); + if (ex%2==0){ + pos[0] = 150; + } + else{ + pos[0] = -150; + sum++; + } + pos[1] = pos[1] - (35*sum); + ex++; + } + else{ + var pos = outerArc.centroid(d2); + pos[0] = radius * (midAngle(d2) < Math.PI ? 1 : -1); + } + return "translate("+ pos +")"; }; }) @@ -1458,6 +1478,17 @@ function print_phases_donut (recipient, phases) { this._current = interpolate(0); return function(t) { var d2 = interpolate(t); + + //fix for labels of a very small portion increase the + //height of the label so that they do not overlap + if( ( d2.endAngle - d2.startAngle ) < 0.1){ + if (ex%2==0){ + return "start"; + } + else{ + return "end"; + } + } return midAngle(d2) < Math.PI ? "start":"end"; }; }); @@ -1468,10 +1499,12 @@ function print_phases_donut (recipient, phases) { /* ------- SLICE TO TEXT POLYLINES -------*/ var polyline = svg.select(".lines").selectAll("polyline") .data(pie(data), key); - + polyline.enter() .append("polyline"); + var ex2 = 1; + var sum2 = 0; polyline.transition().duration(0) .attrTween("points", function(d){ this._current = this._current || d; @@ -1479,16 +1512,33 @@ function print_phases_donut (recipient, phases) { this._current = interpolate(0); return function(t) { var d2 = interpolate(t); - var pos = outerArc.centroid(d2); - pos[0] = radius * 0.95 * (midAngle(d2) < Math.PI ? 1 : -1); + + //fix for labels of a very small portion increase the + //height of the label so that they do not overlap + if( ( d2.endAngle - d2.startAngle ) < 0.1){ + var pos = outerArc.centroid(d2); + if (ex2%2==0){ + pos[0] = 150 * 0.95; + } + else{ + pos[0] = -150 * 0.95; + sum2++; + } + pos[1] = pos[1] - (30*sum2); + ex2++; + } + else{ + var pos = outerArc.centroid(d2); + pos[0] = radius * 0.95 * (midAngle(d2) < Math.PI ? 1 : -1); + } return [arc.centroid(d2), outerArc.centroid(d2), pos]; - }; + }; }) .style("stroke", "black") .style("opacity", ".3") .style("stroke-width", "2px") .style("fill", "none"); - + polyline.exit() .remove(); } @@ -2331,4 +2381,4 @@ var digitPattern = [ setTimeout(tick, 1000 - now % 1000); })(); -} \ No newline at end of file +} From 6bf6fd19d6cdf370fcaac65b88dfa532764fae17 Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 17 Jan 2019 00:01:26 +0100 Subject: [PATCH 3/4] Auto-updated build strings. Former-commit-id: f9fe79ec45febec900d21f62269f4352cc1a97a2 --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 758ee6811a..622cc7270c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.730-190116 +Version: 7.0NG.730-190117 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 4e5706c7cf..a72de2c8c4 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.730-190116" +pandora_version="7.0NG.730-190117" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 9646cee020..f6989c43ca 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.730'; -use constant AGENT_BUILD => '190116'; +use constant AGENT_BUILD => '190117'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index bd1b569af4..c2a9a68636 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.730 -%define release 190116 +%define release 190117 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 1156c6297a..4a83112001 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.730 -%define release 190116 +%define release 190117 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index b4c3b66bab..85826b4ba3 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.730" -PI_BUILD="190116" +PI_BUILD="190117" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 3c639031de..3139d0cccd 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190116} +{190117} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 87cec0dbac..c12964790f 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.730(Build 190116)") +#define PANDORA_VERSION ("7.0NG.730(Build 190117)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 91df373d23..537951418e 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.730(Build 190116))" + VALUE "ProductVersion", "(7.0NG.730(Build 190117))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index d7e1669bf6..bab938db18 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.730-190116 +Version: 7.0NG.730-190117 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index af3a24ea27..305f752fbe 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.730-190116" +pandora_version="7.0NG.730-190117" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 280aba46a5..f805ec33d8 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC190116'; +$build_version = 'PC190117'; $pandora_version = 'v7.0NG.730'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index a82dfc4ca6..f3e5073da0 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -116,7 +116,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 87903a3efb..456fa04c0f 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.730 -%define release 190116 +%define release 190117 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 1f46908e02..6185c86068 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.730 -%define release 190116 +%define release 190117 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 636984f6b0..603f9fe2c7 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.730" -PI_BUILD="190116" +PI_BUILD="190117" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index da655fa933..b456f59405 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.730 PS190116"; +my $version = "7.0NG.730 PS190117"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 85e8ce85f6..891653efc6 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.730 PS190116"; +my $version = "7.0NG.730 PS190117"; # save program name for logging my $progname = basename($0); From 1c8d846574652f392f4a33c98550443df97a53c0 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 17 Jan 2019 15:49:41 +0100 Subject: [PATCH 4/4] WIP IPAM Supernet Former-commit-id: 9da8df381292bc79a49c1416fc6d2820f4b814ac --- pandora_console/include/functions.php | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index f2056f058e..e8130b6e4d 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3435,4 +3435,60 @@ function pandora_xhprof_display_result($key = "", $method = "link") { } } + +/** + * From a network with a mask remove the smallest ip and the highest + * + * @param string address to identify the network. + * @param string mask to identify the mask network + * @return array or false with smallest ip and highest ip + */ +function range_ips_for_network($address, $mask) { + if(!isset($address) || !isset($mask)){ + return false; + } + + //convert ip addresses to long form + $address_long = ip2long($address); + $mask_long = ip2long($mask); + + //caculate first usable address + $ip_host_first = ((~$mask_long) & $address_long); + $ip_first = ($address_long ^ $ip_host_first) + 1; + + //caculate last usable address + $ip_broadcast_invert = ~$mask_long; + $ip_last = ($address_long | $ip_broadcast_invert) - 1; + + $range = array( + 'first' => long2ip($ip_first), + 'last' => long2ip($ip_last) + ); + + return $range; +} + +/** + * from two ips find out if there is such an ip + * + * @param string ip ip wont validate + * @param string ip_lower + * @param string ip_upper + * @return bool true or false if the ip is between the two ips + */ +function is_in_network ($ip, $ip_lower, $ip_upper) { + if(!isset($ip) || !isset($ip_lower) || !isset($ip_upper)){ + return false; + } + + $ip = (float)sprintf("%u",ip2long($ip)); + $ip_lower = (float)sprintf("%u",ip2long($ip_lower)); + $ip_upper = (float)sprintf("%u",ip2long($ip_upper)); + + if ($ip >= $ip_lower && $ip <= $ip_upper){ + return true; + } else { + return false; + } +} ?>