Skip to content

Instantly share code, notes, and snippets.

@saireddy2223
Last active June 5, 2025 12:04
Show Gist options
  • Save saireddy2223/cf860e527666c58bdbf362cd3495e696 to your computer and use it in GitHub Desktop.
Save saireddy2223/cf860e527666c58bdbf362cd3495e696 to your computer and use it in GitHub Desktop.
<?php
include 'node.php';
session_start();
include 'session_variables.php';
$company=$_SESSION['company'];
if ($_SESSION['clkSession'] == 1) {
$custID = $_SESSION['customer123'];
$branchId = $_SESSION['branch123'];
}
$companyname=$_SESSION['companyname'];
$path=GetRootPathFromMasterXml();
$file=$path."/companylist.xml";
$query="/company/company_".$company."/GatewayReg";
$gatewaykey=readDataFromXml($query, $file);
$compath=$path."/".$company; //Nervio
$xml= $compath."/services.xml";
// echo $compath." ".$custID." ".$branchId;
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 6000000)) {
session_unset($_SESSION['LAST_ACTIVITY']);
session_destroy();
header("Location: CDTLogout.php");
}
$companyname=$_SESSION['companyname'];
$client = $compath."/".$custID."/"."clientconnect.xml";
// echo $client;
$show = readDataFromXml("/Activity/ActivityNumber",$client);
$branchesxml = $compath."/".$custID."/Branches.xml";
// echo $productxml;
$numberofbranches = readDataFromXml("/branchInfo/NumOfBranches",$branchesxml);
// echo $productxml;
// Fetch selected product and system from cookies, if they exist
$selectedBranchId = isset($_COOKIE['selectedBranchId']) ? $_COOKIE['selectedBranchId'] : null;
$selectedBranchName = isset($_COOKIE['selectedBranchName']) ? $_COOKIE['selectedBranchName'] : null;
$selectedSystemID = isset($_COOKIE['selectedSystemID']) ? $_COOKIE['selectedSystemID'] : null;
// If no product is selected, select the first product by default
if (!$selectedBranchId) {
$selectedBranchId = readDataFromXml("/branchInfo/branch1_Info/branchid", $branchesxml);
$selectedBranchName = readDataFromXml("/branchInfo/branch1_Info/branchname", $branchesxml);
setcookie("selectedBranchId", $selectedBranchId, time() + 1200, "/");
setcookie("selectedBranchName", $selectedBranchName, time() + 1200, "/");
}
$configurevalue = readDataFromXml("/Activity/configure", $client);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
<link rel="stylesheet" href="./conf/global.css" />
<link rel="stylesheet" href="./conf/index.css" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"
/>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
.custom-dialog {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #fff;
border: 1px solid rgba(0, 0, 0, 0.1);
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
z-index: 1000;
padding: 20px;
font-family: "sans-serif";
color: #333;
min-width: 320px;
border-radius: 5px;
overflow: hidden;
transition: opacity 0.3s ease, transform 0.3s ease;
}
.custom-dialog i.dialog-close {
position: absolute;
top: 10px;
right: 10px;
font-size: 24px;
cursor: pointer;
}
/* Add a hover effect */
.custom-dialog:hover i.dialog-close {
color: #ff0000; /* Red color on hover */
}
.logo-container {
margin-left:40px;
margin-top:10px;
}
.logo-image {
width: 50px; /* Make the image fill the wrapper */
height: 50px;
object-fit: cover; /* Ensure the image covers the wrapper area */
border-radius: 50%; /* Make the image circular */
}
</style>
</head>
<body>
<div class="neridio-dashboard-cyber-tele">
<div class="neridio-dashboard-cyber-tele-child"></div>
<div class="neridio-dashboard-cyber-tele-item"></div>
<div class="topbar">
<div class="cyber-telemetry">
Add and Configure Automated Services
</div>
<div class="user-icon-container">
<div class="user-icon" onclick="showLogoutConfirmation()"><?php echo strtoupper(substr($companyname, 0, 1)); ?></div>
</div>
<!-- <img class="topbar-child" alt="" src="./public/ellipse-1@2x.png" /> -->
</div>
<!-- <div class="fault-and-threat-wrapper active" id="sqlserver" onclick="setActive(this)" data-initial-active="false">
<div class="fault-and-threat">Security Configuration For Site Control</div>
</div> -->
<?php
if (file_exists($branchesxml)) {
$xml = simplexml_load_file($branchesxml);
// Get the value of NumOfBranches
$numOfBranches = (int)$xml->NumOfBranches;
// Debugging in the browser: echo the number of branches
echo "<script>console.log('Number of branches: " . $numOfBranches . "');</script>";
// Check if NumOfBranches is 0
if ($numOfBranches === 0) {
// Display the message when no products are found
echo "
<div class='container'>
<img src='mImages/notfound.svg' alt='No Products Found' class='animated-img' />
<div class='animated-text'>Sorry!</div>
<div class='sub-text'>You Have Not Deployed Any Cluster Yet...</div>
</div>";
} else {
// Load the PHP file when branches are present
include 'conf_update.php'; // or require 'conf_update.php';
}
} else {
echo "Error: Could not load XML file.";
}
?>
<!-- <div class="contact-us"> -->
<!-- <button class="button-filled" onClick="newest()">
<i class="fa fa-download"></i>
Add New Cluster or New Instance
</button> -->
<br><br>
<!-- Side Menu bar -->
<div class="sidebar">
<div class="logo-container">
<a href="https://neridio.com" >
<img src="mImages/Neridio New Logo (1).png" class="logo-image">
</a>
</div>
<div class="sidebar-inner">
<div class="vector-parento">
<img class="vector-icon6" alt="" src="./public/vector3.svg" />
<div class="security-automation-configurat" id="overview">Overview</div>
</div>
</div>
<div class="sidebar-child">
<div class="vector-parent" id="firstside">
<img class="vector-icon7" alt="" src="./public/vectornew.svg" />
<div class="security-automation-configurat" >
Cyber Telemetry & Site Monitoring
</div>
</div>
</div>
<div class="vector-container" id="secondside">
<img class="vector-icon8" alt="" src="./public/vector5.svg" />
<div class="security-automation-configurat">
Add and Configure Automated Services
</div>
</div>
<div class="layer-169-parent" id="thirdside">
<img class="layer-169-icon" alt="" src="./public/layer-169.svg" />
<div class="security-automation-configurat" >
Manual Security Control
</div>
</div>
<div class="vector-parent1" id="fourthside">
<img class="vector-icon9" alt="" src="./public/vector6.svg" />
<div class="security-automation-configurat" >
Auditing, Reporting, and Logs
</div>
</div>
<div class="vector-parent2" id="fifthside">
<img class="vector-icon10" alt="" src="./public/vector7.svg" />
<div class="security-automation-configurat" >
Config and Software Update
</div>
</div>
<div class="contact-us-parent">
<div class="back" id="back">
<div class="risk-detention-response">Back</div>
</div>
<div class="contact-us1" id="contactus">
<div class="risk-detention-response">Contact Us</div>
</div>
<div id="contactDialog" class="custom-dialog">
<div class="dialog-content">
<h1 style="text-align: center;font-size:30px;">Contact Us</h1>
<p><b><i class="material-icons" style="vertical-align: bottom;">phone</i>+91-8042179002</b></p>
<p><b><i class="material-icons" style="vertical-align: bottom;">mail</i>support@neridio.com</b></p>
</div>
<i class="dialog-close material-icons" onclick="closeContactDialog()">close</i> <!-- Close button at top right -->
</div>
<div class="learn-more-about-us-parent">
<div class="risk-detention-response" onclick="redirectToNeridio()">Learn more about us</div>
<img class="vector-icon11" onclick="redirectToNeridio()" alt="" src="./public/vector8.svg" />
</div>
</div>
</div>
</div>
<!-- Side menu bar end -->
</body>
<style>
#overview{
cursor:pointer;
}
#selectOptionsPopup {
display: none;
position: fixed;
z-index: 1000;
inset: 0;
background-color: rgba(0, 0, 0, 0.4);
/* Dimmed overlay */
backdrop-filter: blur(6px);
/* Blur only the background */
font-family: 'Segoe UI', sans-serif;
}
#selectOptionsPopup .popup-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #111b1e;
/* Solid dark green background (no transparency) */
border-radius: 20px;
padding: 30px 25px;
width: 90%;
max-width: 400px;
text-align: center;
box-shadow: 0 6px 24px rgba(0, 255, 160, 0.1);
border: 1px solid rgba(255, 255, 255, 0.06);
}
#selectOptionsPopup .close {
position: absolute;
top: 18px;
right: 22px;
font-size: 24px;
color: #a1a1a1;
cursor: pointer;
font-weight: bold;
transition: color 0.3s ease;
}
#selectOptionsPopup .close:hover {
color: #fff;
}
#selectOptionsPopup h2 {
font-size: 22px;
font-weight: 600;
margin-bottom: 25px;
color: #d4f9dd;
}
#selectOptionsPopup select {
width: 100%;
padding: 14px 18px;
font-size: 16px;
color: #00ffcc;;
margin-bottom: 20px;
border-radius: 14px;
background: rgba(39, 49, 44, 0.8);
//background:white;
border: 1px solid rgba(255, 255, 255, 0.08);
outline: none;
appearance: none;
transition: background 0.3s;
}
#selectOptionsPopup select:focus {
background: rgba(45, 58, 50, 0.9);
}
#selectOptionsPopup button.btn {
width: 100%;
padding: 14px 0;
font-size: 18px;
font-weight: bold;
border-radius: 30px;
color: #fff;
border: none;
background: linear-gradient(to right, #27d995, #159a6f);
box-shadow: 0 4px 18px rgba(39, 217, 149, 0.4);
transition: all 0.3s ease-in-out;
}
#selectOptionsPopup button.btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 24px rgba(39, 217, 149, 0.6);
}
.fade-in {
animation: fadeIn 0.3s ease-in-out;
}
</style>
<div id="selectOptionsPopup" class="popup">
<div class="popup-content">
<span class="close" onclick="closeSelectOptionsPopup()">&times;</span>
<h2>Select Cluster</h2>
<select id="productSelectnew">
<option value="0">Select Cluster</option>
<?php
for ($k = 1; $k <= $numberofbranches; $k++) {
$branchName = readDataFromXml("/branchInfo/branch" . $k . "_Info/branchname", $branchesxml);
$branchvalue = readDataFromXml("/branchInfo/branch" . $k . "_Info/branchid", $branchesxml);
?>
<option value="<?php echo $branchvalue; ?>" ><?php echo $branchName; ?></option>
<?php } ?>
</select>
<h2>Select System</h2>
<select id="systemSelectnew">
<option value="0">Select Your System</option>
</select>
<button id="submitButton" class="btn waves-effect waves-light blue">Submit</button>
</div>
</div>
</html>
<script>
function showContactDialog() {
var dialog = document.getElementById('contactDialog');
dialog.style.display = 'block';
}
function closeContactDialog() {
var dialog = document.getElementById('contactDialog');
dialog.style.display = 'none';
}
var contactus = document.getElementById('contactus');
if (contactus) {
contactus.addEventListener('click', function(e) {
showContactDialog();
});
}
var back = document.getElementById('back');
if (back) {
back.addEventListener('click', function(e) {
window.location.href="index_login.php";
});
}
var overview = document.getElementById('overview');
if (overview) {
overview.addEventListener('click', function(e) {
window.location.href="index_login.php"
});
}
function redirectToNeridio() {
window.location.href = "https://neridio.com";
}
function showLogoutConfirmation()
{
Swal.fire({
title: 'Are you sure?',
text: 'You will be logged out of your account.',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, logout!',
cancelButtonText: 'Cancel'
}).then((result) => {
if (result.isConfirmed) {
window.location.href = 'CDTLogout.php'; // Redirect to logout page
}
});
}
var sqlserver = document.getElementById('storage');
if (sqlserver) {
sqlserver.addEventListener('click', function(e) {
window.location.href="newconfiguration.php?productid=9";
});
}
var cassandra = document.getElementById('cassandra');
if (cassandra) {
cassandra.addEventListener('click', function(e) {
window.location.href="newconfiguration_2.php?productid=8";
});
}
var mongo = document.getElementById('mongo');
if (mongo) {
mongo.addEventListener('click', function(e) {
window.location.href="newconfiguration_2.php?productid=7"; // Correct productid for MongoDB
});
}
// Handling click for Storage
var storage = document.getElementById('sqlserver');
if (storage) {
storage.addEventListener('click', function(e) {
window.location.href="newconfiguration_2.php?productid=4"; // Correct productid for Storage
});
}
var configureval = "<?php echo $configurevalue ?>";
//side navigation bar redirection
var firstside = document.getElementById("firstside");
if (firstside) {
firstside.addEventListener("click", function (e) {
if(configureval == "0")
{
Swal.fire({
icon:'warning',
title:'Please Configure Your Required Service First',
showConfirmButton: false,
timer:2000
});
}else
{
window.location.href = "firstdashboard.php";
}
});
}
var thirdside = document.getElementById("thirdside");
if (thirdside) {
thirdside.addEventListener("click", function (e) {
if(configureval == "0")
{
Swal.fire({
icon:'warning',
title:'Please Configure Your Required Service First',
showConfirmButton: false,
timer:2000
});
}
else{
showSelectOptionsPopup("supportLink");
}
});
}
var fourthside = document.getElementById("fourthside");
if (fourthside) {
fourthside.addEventListener("click", function (e) {
if(configureval == "0")
{
Swal.fire({
icon:'warning',
title:'Please Configure Your Required Service First',
showConfirmButton: false,
timer:2000
});
}else
{
window.location.href = "./newaudit.php";
}
});
}
var fifthside = document.getElementById("fifthside");
if (fifthside) {
fifthside.addEventListener("click", function (e) {
var showvalue = "<?php echo $show ?>";
if(showvalue == "0")
{
Swal.fire({
icon:'warning',
title:'Please Contact Administrator',
showConfirmButton: false,
timer:2000
});
}
else{
showSelectOptionsPopup("supportLink2");
}
});
}
</script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$("#productSelectnew").change(function() {
// var pid = $(this).val(); // Get selected product ID
var bid = $(this).val();
var cid = '<?php echo $custID ?>'; // Get customer ID
// Make AJAX request to fetch systems data
$.ajax({
type: "POST",
url: 'systemXML.php',
data: {
'bid': bid,
'cid': cid
},
dataType: "json", // Expect JSON response
success: function(systemsData) {
console.log("Systems data received:", systemsData);
// Clear and populate the select element with systems data
$('#systemSelectnew').empty();
systemsData.forEach(function(system) {
$('#systemSelectnew').append('<option>' + system + '</option>');
});
},
error: function(xhr, status, error) {
console.error('Error fetching systems data:', error);
}
});
});
$("#submitButton").click(function() {
submitOptions();
});
});
function submitOptions() {
var clickedButtonId = document.getElementById("submitButton").getAttribute("data-button-id");
var compath = "<?php echo $compath ?>";
var custID = "<?php echo $custID ?>";
var branchId = $("#productSelectnew").val();
// var selectedProductId = $("#productSelectnew").val();
var selectedSystemname = $("#systemSelectnew").val();
if (selectedSystemname === "0" || branchId === "0") {
alert("Please select both cluster and system before submitting.");
return;
}
var typeValue = 0; // 1 for Master, 2 for Worker
var kValue = ""; // The actual system label
if (selectedSystemname.includes("Master")) {
typeValue = 1;
kValue = selectedSystemname.split(": ")[1].split("(")[0];
} else if (selectedSystemname.includes("Worker")) {
typeValue = 2;
kValue = selectedSystemname.split(": ")[1].split("(")[0];
}
var systemxml = compath + "/" + custID + "/" + branchId + "/" + typeValue + "/Systems.xml";
// Make an AJAX request to retrieve the system ID
$.ajax({
type: "POST",
url: "getsystemid.php",
data: {
systemxml: systemxml,
selectedSystemname: kValue
},
success: function(response) {
console.log("System ID:", response);
var nextPage;
if (clickedButtonId === 'supportLink') {
nextPage = "CmdExcDisplay3.php";
} else if (clickedButtonId === 'supportLink2') {
nextPage = "configANDswUpdate_home.php";
}
var queryParams = "?productId=" + branchId + "&type=" + typeValue + "&j=" + response;
window.location.href = nextPage + queryParams;
},
error: function(xhr, status, error) {
console.error("Error calling getsystemid.php:", error);
}
});
}
function showSelectOptionsPopup(clickedButtonId) {
var popup = document.getElementById("selectOptionsPopup");
popup.style.display = "block";
var submitButton = document.getElementById("submitButton");
submitButton.setAttribute("data-button-id", clickedButtonId);
}
function closeSelectOptionsPopup() {
document.getElementById("selectOptionsPopup").style.display = "none";
}
function submitForm() {
var ww_files = document.getElementById("ww_files1");
if (ww_files && ww_files.checked) {
if (!commonvalidation(document.getElementById("ww_files_dir"), "directory","ww_files_error")) {
return false;
}
}
var remove_file_checkbox = document.getElementById("remove_file1");
if (remove_file_checkbox && remove_file_checkbox.checked) {
if (!commonvalidation(document.getElementById("remove_file_dir"), "directory","remove_file_error")) {
return false;
}
}
var largefile_checkbox = document.getElementById("largefile1");
if (largefile_checkbox && largefile_checkbox.checked) {
if (!commonvalidation(document.getElementById("largefile_dir"), "directory","largefile_error")) {
return false;
}
}
var ossec_checkbox = document.getElementById("ossec1");
if (ossec_checkbox && ossec_checkbox.checked) {
if (!commonvalidation(document.getElementById("ossec_dir"), "directory","ossec_error")) {
return false;
}
}
var tripwire_checkbox = document.getElementById("tripwire1");
if(tripwire_checkbox && tripwire_checkbox.checked){
if(!commonvalidation(document.getElementById("tripwire_dir"),"directory","tripwire_error")){
return false;
}
}
var realtime_monitor_checkbox = document.getElementById("realtime_monitor1");
if(realtime_monitor_checkbox && realtime_monitor_checkbox.checked){
if(!commonvalidation(document.getElementById("realtime_monitor_path"),"directory","realtime_monitor_error")){
return false;
}
}
var accesscheckbox = document.getElementById("Access_file1");
if(accesscheckbox && accesscheckbox.checked){
if(!commonvalidation(document.getElementById("Access_file_dir"),"directory","Access_file_error")){
return false;
}
}
var Modified_filecheckbox = document.getElementById("Modified_file1");
if(Modified_filecheckbox && Modified_filecheckbox.checked){
if(!commonvalidation(document.getElementById("Modified_file_dir"),"directory","Modified_file_error")){
return false;
}
}
var last8hourcheckbox = document.getElementById("last8hour1");
if(last8hourcheckbox && last8hourcheckbox.checked){
if(!commonvalidation(document.getElementById("last8hour_name"),"directory","last8hour_error")){
return false;
}
}
var lastonedaycheckbox = document.getElementById("lastoneday1");
if(lastonedaycheckbox && lastonedaycheckbox.checked){
if(!commonvalidation(document.getElementById("lastoneday_name"),"directory","lastoneday_error")){
return false;
}
}
var lastonehourcheckbox = document.getElementById("lastonehour1");
if(lastonehourcheckbox && lastonehourcheckbox.checked){
if(!commonvalidation(document.getElementById("lastonehour_name"),"directory","lastonehour_error")){
return false;
}
}
var Recentfileupdatecheckbox = document.getElementById("Recentfileupdate1");
if(Recentfileupdatecheckbox && Recentfileupdatecheckbox.checked){
if(!commonvalidation(document.getElementById("Recentfileupdate_name"),"directory","Recentfileupdate_error")){
return false;
}
}
var sshd_timeoutcheckbox = document.getElementById("sshd_timeout1");
if(sshd_timeoutcheckbox && sshd_timeoutcheckbox.checked){
if(!commonvalidation(document.getElementById("sshd_timeout_time"),"time","sshd_timeout_error")){
return false;
}
}
if(sshd_timeoutcheckbox && sshd_timeoutcheckbox.checked){
if(!commonvalidation(document.getElementById("sshd_timeout_count"),"Count","sshd_timeout_error")){
return false;
}
}
var suid_sgid_filescheckbox = document.getElementById("suid_sgid_files1");
if(suid_sgid_filescheckbox && suid_sgid_filescheckbox.checked){
if(!commonvalidation(document.getElementById("suid_sgid_files_name"),"directory","suid_sgid_files_error")){
return false;
}
}
var no_own_user_filescheckbox = document.getElementById("no_own_user_files1");
if(no_own_user_filescheckbox && no_own_user_filescheckbox.checked){
if(!commonvalidation(document.getElementById("no_own_user_files_name"),"directory","no_own_user_files_error")){
return false;
}
}
var antiviruscheckbox = document.getElementById("antivirus1");
if(antiviruscheckbox && antiviruscheckbox.checked){
if(!commonvalidation(document.getElementById("antivirus_Dir"),"directory","antivirus_error")){
return false;
}
}
var recoverycheckbox = document.getElementById("recovery1");
if(recoverycheckbox && recoverycheckbox.checked){
if(!commonvalidation(document.getElementById("recovery_device"),"device","recovery_error")){
return false;
}
}
if(recoverycheckbox && recoverycheckbox.checked){
if(!commonvalidation(document.getElementById("recovery_key"),"key","recovery_error")){
return false;
}
}
var selinuxcheckbox = document.getElementById("selinux1");
if (selinuxcheckbox && selinuxcheckbox.checked) {
var validationResult = validateRadioButtons("SeLinux Status", "selinux_dir", "selinux_error");
if (!validationResult) {
return false; // or handle the error in some other way
}
}
var datacheckbox = document.getElementById("backup1");
var datacheckbox2= document.getElementById("backup2");
if(datacheckbox && datacheckbox.checked){
if(!commonvalidation(document.getElementById("backupdevice"),"device","backup_error")){
return false;
}
}
if(datacheckbox && datacheckbox.checked){
if(!commonvalidation(document.getElementById("backupkey"),"key","backup_error")){
return false;
}
}
if(datacheckbox2 && datacheckbox2.checked){
if(!commonvalidation(document.getElementById("backupdevice"),"device","backup_error")){
return false;
}
if(!commonvalidation(document.getElementById("backupkey"),"key","backup_error")){
return false;
}
}
var policy1 = document.getElementById("policy1");
var policy2 = document.getElementById("policy2");
if(policy1 && policy1.checked){
if(!commonvalidation(document.getElementById("policyname"),"username","policy_error")){
return false;
}
var policy_load = validateRadioButtons("Policy Load", "policy_load", "policy_error");
if (!policy_load) {
return false;
}
var policy_mode = validateRadioButtons("Policy Mode", "policy_mode", "policy_error");
if (!policy_mode) {
return false;
}
}
if(policy2 && policy2.checked){
if(!commonvalidation(document.getElementById("policyname"),"username","policy_error")){
return false;
}
var policy_load = validateRadioButtons("Policy Load", "policy_load", "policy_error");
if (!policy_load) {
return false; // or handle the error in some other way
}
var policy_mode = validateRadioButtons("Policy Mode", "policy_mode", "policy_error");
if (!policy_mode) {
return false; // or handle the error in some other way
}
}
//var lastNtrans = document.getElementById("secop241");
//if(lastNtrans && lastNtrans.checked){
//if(!commonvalidation(document.getElementById("secop24_dir"),"Number of transaction","secop24_error")){
//return false;
//}
//}
var linux_acc_lock1 = document.getElementById("linux_acc_lock1");
var linux_acc_lock2 = document.getElementById("linux_acc_lock2");
if(linux_acc_lock1 && linux_acc_lock1.checked){
if(!commonvalidation(document.getElementById("linux_acc_lock_user"),"username","linux_acc_lock_error")){
return false;
}
}
if(linux_acc_lock2 && linux_acc_lock2.checked){
if(!commonvalidation(document.getElementById("linux_acc_lock_user"),"username","linux_acc_lock_error")){
return false;
}
}
var firewallport1 = document.getElementById("firewallport1");
var firewallport2 = document.getElementById("firewallport2");
if(firewallport1 && firewallport1.checked){
console.log("hello");
if(!commonvalidation(document.getElementById("firewallport_dir"),"port","firewallport_error")){
return false;
}
}
if(firewallport2 && firewallport2.checked){
if(!commonvalidation(document.getElementById("firewallport_dir"),"port","firewallport_error")){
return false;
}
}
if (!ramvalid(document.getElementById("ramthresh"))) {
return false;
}
if (!storagevalid(document.getElementById("storagethresh"))) {
return false;
}
// if (!processvalid(document.getElementById("processthresh"))) {
// return false;
// }
var secop1 = document.getElementById("secop11");
if(secop1 && secop1.checked){
if(!commonvalidation(document.getElementById("secop1_dir"),"directory","secop1_error")){
return false;
}
}
var secop2 = document.getElementById("secop21");
if(secop2 && secop2.checked){
if(!commonvalidation(document.getElementById("secop2_dir"),"directory","secop2_error")){
return false;
}
}
document.getElementById('sumbitDone').submit();
return true;
}
function commonvalidation(inputElement, fieldName, errorElementId) {
var errorElement = document.getElementById(errorElementId);
if (!errorElement) {
console.error("Error element with ID '" + errorElementId + "' not found.");
return false;
}
if (inputElement.value.trim() === "") {
console.log("Validation failed for " + fieldName); // Track validation status
errorElement.textContent = `Please fill in the ${fieldName} field.`;
errorElement.style.display = "block";
inputElement.focus(); // Set focus for correction
return false;
} else {
errorElement.textContent = "";
errorElement.style.display = "none";
return true;
}
}
function validateRadioButtons(fieldName, radioGroupName, errorElementId) {
var selectedRadioButton = document.querySelector('input[name="' + radioGroupName + '"]:checked');
var errorElement = document.getElementById(errorElementId);
if (!errorElement) {
console.error("Error element with ID '" + errorElementId + "' not found.");
return false;
}
if (!selectedRadioButton) {
console.log("No radio button selected with name '" + radioGroupName + "'");
errorElement.textContent = "Please select " + fieldName + ".";
errorElement.style.display = "block";
return false;
}
// If a radio button is selected, hide the error message
errorElement.textContent = "";
errorElement.style.display = "none";
return true;
}
function ramvalid(input) {
var error = document.getElementById('ramthresh_error');
var value = input.value;
if (value.trim() === "") {
error.textContent = ""; // Clear any existing error message
return true; // Skip validation if input is empty
}
var isValid = /^\d+$/.test(value) && parseInt(value) < 100;
if (!isValid) {
error.textContent = "Please enter a valid range.";
return false;
} else {
error.textContent = "";
return true;
}
}
function storagevalid(input) {
var error = document.getElementById('storagethresh_error');
var value = input.value;
if (value.trim() === "") {
error.textContent = ""; // Clear any existing error message
return true; // Skip validation if input is empty
}
var isValid = /^\d+$/.test(value) && parseInt(value) < 100;
if (!isValid) {
error.textContent = "Please enter a valid range.";
return false;
} else {
error.textContent = "";
return true;
}
}
var lastSelectedRadio = {};
function toggleRadio(radioId, groupName, textBoxId) {
if (!lastSelectedRadio[groupName]) {
lastSelectedRadio[groupName] = null;
}
var radio = document.getElementById(radioId);
console.log('Radio ID:', radioId);
console.log('Group Name:', groupName);
console.log('Last Selected Radio for Group:', lastSelectedRadio[groupName]);
console.log('Current Radio:', radio);
if (lastSelectedRadio[groupName] === radio) {
radio.checked = false;
lastSelectedRadio[groupName] = null;
console.log('Radio deselected:', radioId);
} else {
lastSelectedRadio[groupName] = radio;
console.log('Radio selected:', radioId);
}
console.log('Updated Last Selected Radio for Group:', lastSelectedRadio[groupName]);
showTextBox(textBoxId);
}
// Example function to show or hide the textbox and adjust button position
function showTextBox(directoryId) {
var directory = document.getElementById(directoryId);
if (directory.style.display === "none" || directory.style.display === "") {
directory.style.display = "block";
} else {
directory.style.display = "none";
}
}
function showTextBoxq(directoryId) {
var secop17 = "<?php echo $secop17; ?>";
if (secop17 === "DONE") {
alert("Please enable network anomaly first.");
// Uncheck the checkbox by name if secop17 is DONE
var checkboxes = document.getElementsByName(directoryId);
if (checkboxes.length > 0) {
checkboxes[0].checked = false; // Uncheck the first checkbox with this name
}
return; // Stop further execution if the condition is met
}
var directory = document.getElementById(directoryId);
if (directory.style.display === "none" || directory.style.display === "") {
directory.style.display = "block";
} else {
directory.style.display = "none";
}
}
function showTextBoxn(directoryId) {
var directory = document.getElementById(directoryId);
if (directory) {
// Show or hide the text box based on the current display state
directory.style.display = (directory.style.display === 'none' || directory.style.display === '') ? 'block' : 'none';
}
}
document.addEventListener('DOMContentLoaded', function() {
// Get the productid from the URL
const urlParams = new URLSearchParams(window.location.search);
const productId = urlParams.get('productid');
console.log(`Product ID from URL: ${productId}`);
if (productId) {
// Log all elements with data-product-id
document.querySelectorAll('[data-product-id]').forEach(el => {
console.log(`Element ID: ${el.id}, Product ID: ${el.getAttribute('data-product-id')}`);
});
// Find the element with the matching productid
const element = document.querySelector(`[data-product-id="${productId}"]`);
if (element) {
console.log(`Found element with matching productid: ${element.id}`);
// Set all elements' data-initial-active to false
document.querySelectorAll('[data-initial-active="true"]').forEach(el => {
console.log(`Setting data-initial-active to false for: ${el.id}`);
el.setAttribute('data-initial-active', 'false');
});
// Set the matching element's data-initial-active to true
console.log(`Setting data-initial-active to true for: ${element.id}`);
element.setAttribute('data-initial-active', 'true');
// Set the element as active
setActive(element);
} else {
console.log(`No element found with productid: ${productId}`);
}
} else {
// If no productid in URL, set the default active element
const initiallyActiveElement = document.querySelector('[data-initial-active="true"]');
if (initiallyActiveElement) {
console.log(`Setting default active element: ${initiallyActiveElement.id}`);
setActive(initiallyActiveElement);
} else {
console.log('No element with data-initial-active="true" found.');
}
}
});
function setActive(element) {
// Remove the active class from all elements
document.querySelectorAll('.fault-and-threat-wrapper, .risk-detention-response-wrapper, .storage, .detailed-telemetry-wrapper')
.forEach(el => el.classList.remove('active'));
// Add the active class to the clicked element
element.classList.add('active');
}
function newest() {
// Get the productId from the URL
const urlParams = new URLSearchParams(window.location.search);
const productId = urlParams.get('productid');
window.location.href = `download_page.php?product_id=${productId}`;
}
function toggleCheckbox(groupName, checkbox) {
var checkboxes = document.getElementsByName(groupName);
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i] !== checkbox) {
checkboxes[i].checked = false;
}
}
}
</script>
<script>
function showTextBox1(directoryId)
{
var directory = document.getElementById(directoryId);
if (directory.style.display === "none" || directory.style.display === "") {
directory.style.display = "block";
} else {
directory.style.display = "none";
}
}
function showTooltip(element, message) {
var tooltip = element.getElementsByClassName("newtooltiptext")[0];
if (typeof message === 'undefined' || message.trim() === '') {
message = "Default tooltip message"; // Set a default message if necessary
}
tooltip.innerText = message; // Set the tooltip text to the provided message
tooltip.style.display = "block";
tooltip.style.opacity = "1";
}
// Define hideTooltip function
function hideTooltip(element) {
var tooltip = element.getElementsByClassName("newtooltiptext")[0];
tooltip.style.display = "none";
tooltip.style.opacity = "0";
}
// Attach event listeners to elements with the newtooltip class
document.querySelectorAll('.newtooltip').forEach(item => {
item.addEventListener('mouseover', function() {
var message = this.dataset.message; // Get the message from the data-message attribute
showTooltip(this, message); // Pass the message to the showTooltip function
});
item.addEventListener('mouseout', function() {
hideTooltip(this);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment