adding add_client to server

This commit is contained in:
jakani24
2024-02-17 10:24:34 +01:00
parent a5763ca271
commit 9d407e5b60
32 changed files with 235 additions and 9 deletions

View File

@@ -29,4 +29,34 @@ function check_apikey(){
}
}
}
function load_secret(){
include "../../../config.php";
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
if ($conn->connect_error) {
$success=0;
die("Connection failed: " . $conn->connect_error);
}
if(!isset($_GET["apikey"]) or !isset($_GET["machineid"])){
return false;
}
else{
$apikey=$_GET["apikey"];
$machineid=$_GET["machineid"];
$sql = "SELECT * FROM secrets machineid = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s",$machineid);
// Execute the statement
$stmt->execute();
// Get the result
$result = $stmt->get_result();
$row = $result->fetch_assoc();
if($row!==null){
return $row["cert"];
}
}
}
?>

View File

@@ -24,12 +24,14 @@ if(isset($_GET["settings"])){
rtp_folder_scan:status on
*/
load_settings();
echo(load_secret());
echo("virus_ctrl:virus_found:action ".$setting_virus_ctrl_virus_found_action."\n");
echo("server:server_url ".$setting_server_server_url."\n");
echo("rtp_folder_scan:status ".$setting_rtp_folder_scan_status."\n");
echo("rtp_process_scan:status ".$setting_rtp_process_scan_status."\n");
}
if(isset($_GET["rtp_included"])){
echo(load_secret());
//load all the entrys from a db table
$sql = "SELECT path,id FROM rtp_included ORDER BY id";
$stmt = $conn->prepare($sql);
@@ -44,6 +46,7 @@ if(isset($_GET["rtp_included"])){
}
if(isset($_GET["rtp_excluded"])){
echo(load_secret());
//load all the entrys from a db table
$sql = "SELECT path,id FROM rtp_excluded ORDER BY id";
$stmt = $conn->prepare($sql);
@@ -58,6 +61,7 @@ if(isset($_GET["rtp_excluded"])){
}
if(isset($_GET["sched"])){
echo(load_secret());
//load all the entrys from a db table
$sql = "SELECT task,id FROM user_tasks ORDER BY id";
$stmt = $conn->prepare($sql);

View File

@@ -0,0 +1,49 @@
<?php
session_start();
// Check if the user is logged in
if (!isset($_SESSION['username']) or !isset($_SESSION["login"])) {
// Redirect to the login page or handle unauthorized access
header("Location: /login.php");
exit();
}
$username = $_SESSION['username'];
$perms = $_SESSION["perms"];
$email = $_SESSION["email"];
if($perms[7]!=="1"){
header("location:/system/insecure_zone/php/no_access.php");
$block=1;
exit();
}else{
$block=0;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<title>Change Password</title>
</head>
<body>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h4>Add a machine</h4>
</div>
<div class="card-body">
<form action="add_client.php?add=true" method="post">
<button type="submit" class="btn btn-primary btn-block">Add Machine</button>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>