fixing some bugs

This commit is contained in:
Janis Steiner
2024-06-18 09:53:25 +01:00
parent 0d7038c4b6
commit 1d798ea3ce
13 changed files with 108 additions and 59 deletions

View File

@@ -1,3 +1,4 @@
1) git clone
2) install docker
3) docker volume create --name=sys0-db
4) open /install/create_db.php

View File

@@ -1,3 +1,11 @@
#!/bin/bash
chmod 777 sys0-code/log
mkdir -p sys0-code/user_files
mkdir -p sys0-code/user_files/public
chmod 777 sys0-code/user_files
chmod 777 sys0-code/user_files/public
touch sys0-code/log/sys0.log
touch sys0-code/log/log.txt
chmod 777 sys0-code/log/sys0.log
chmod 777 sys0-code/log/log.txt
docker volume create sys0-db

View File

@@ -901,7 +901,7 @@ default_socket_timeout = 60
;
; For example:
;
; extension=mysqli
extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:

View File

@@ -1,16 +1,4 @@
# Extend the official PHP image
FROM php:apache
# Install the mysqli extension
RUN docker-php-ext-install mysqli
#RUN a2enmod ssl
RUN service apache2 restart
#COPY ./cyberhex-code /var/www/html
#RUN mkdir -p /var/www/html/install/
#RUN mkdir -p /var/www/html/database_srv
#RUN mkdir -p /var/www/html/export
#RUN mkdir -p /var/www/html/import
#RUN chown -R www-data:www-data /var/www/html/export/
#RUN chown -R www-data:www-data /var/www/html/import/
#RUN chown -R www-data:www-data /var/www/html/install/
#RUN chown -R www-data:www-data /var/www/html/database_srv/

View File

@@ -36,7 +36,8 @@
else
$sql="Select id,apikey,printer_url from printer where id=$print_on and free=1";
//echo $sql;
$stmt = mysqli_prepare($link, $sql)mysqli_stmt_execute($stmt);
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $id,$papikey,$purl);
mysqli_stmt_fetch($stmt);

View File

@@ -6,7 +6,6 @@ include "../config/config.php";
?>
<script src="/assets/js/load_page.js"></script>
<script>
function load_user()
@@ -17,13 +16,10 @@ function load_user()
}
</script>
<?php
echo "<script type='text/javascript' >load_user()</script>";
?>
<?php
$color=$_SESSION["color"];
<?php
$color=$_SESSION["color"];
include "../assets/components.php";
if(isset($_POST["printer"])){
$color=htmlspecialchars($_GET["color"]);
@@ -32,7 +28,6 @@ function load_user()
//echo($sql);
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
}
?>
<div id="content"></div>

View File

@@ -4,8 +4,6 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Footer</title>
<link href="system0/html/php/login/v3/components.php" rel="stylesheet">
<style>
hr {
margin-top: 1rem;

View File

@@ -2,32 +2,31 @@
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="system0/html/php/login/v3/components.php" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script>
function load_footer() {
$(document).ready(function(){
$('#footer').load("/system0/html/php/login/v3/html/footer.html");
$('#footer').load("/assets/html/footer.html");
});
}
load_footer();
function update_telegram_id(){
var a=document.getElementById("telegram_id");
var tel_id=a.value;
fetch("update_settings.php?telegram_id="+tel_id);
fetch("/api/update_settings.php?telegram_id="+tel_id);
}
function update_notification(div_id){
var a=document.getElementById(div_id);
var tel_id=a.checked;
fetch("update_settings.php?"+div_id+"="+tel_id);
}
fetch("/api/update_settings.php?"+div_id+"="+tel_id);
}
</script>
<style>
.green {
color: #ffffff;
text-decoration: none;
}
}
.green:hover,
.green:active {
color: #e2e2e2;
@@ -40,8 +39,8 @@
<nav class="navbar navbar-expand-lg navbar-light bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="/system0/html/index.php">
<img src="/system0/html/php/login/v3/css/MicrosoftTeams-image (16).png" width="auto" height="30" alt="Logo">
<a class="navbar-brand" href="/index.php">
<img src="/assets/images/ksw_logo.png" width="auto" height="30" alt="Logo">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@@ -55,36 +54,36 @@
if($_SESSION["role"][0]==="1")
echo('
<li class="nav-item">
<a class="btn btn-link green" href="/system0/html/php/login/v3/php/print.php">Datei drucken</a>
<a class="btn btn-link green" href="/app/print.php">Datei drucken</a>
</li>
');
if($_SESSION["role"][1]==="1")
echo('
<li class="nav-item">
<a class="btn btn-link green" href="/system0/html/php/login/v3/php/cloud.php">Deine Dateien</a>
<a class="btn btn-link green" href="/app/cloud.php">Deine Dateien</a>
</li>
');
if($_SESSION["role"][2]==="1")
echo('
<li class="nav-item">
<a class="btn btn-link green" href="/system0/html/php/login/v3/php/public_cloud.php">Öffentliche Dateien</a>
<a class="btn btn-link green" href="/app/public_cloud.php">Öffentliche Dateien</a>
</li>
');
echo('
<li class="nav-item">
<a class="btn btn-link green" href="/system0/html/php/login/v3/php/bugreport.php">Fehler melden</a>
<a class="btn btn-link green" href="/app/bugreport.php">Fehler melden</a>
</li>
');
echo('
<li class="nav-item">
<a class="btn btn-link green" href="/system0/html/user_files/sys0_autonomous/anleitung.pdf">Anleitung</a>
<a class="btn btn-link green" href="/user_files/sys0_autonomous/anleitung.pdf">Anleitung</a>
</li>
');
?>
<li class="nav-item">
<a class="btn green" role="button" data-bs-toggle="modal" data-bs-target="#account"><i class="fa-solid fa-gear"></i></a>
<a href="/system0/html/php/login/v3/logout.php" class="btn me-2 green" role="button"><i class="fa-solid fa-right-from-bracket"></i></a>
<a href="/login/logout.php" class="btn me-2 green" role="button"><i class="fa-solid fa-right-from-bracket"></i></a>
</li>
</ul>
</div>
@@ -120,7 +119,7 @@
<div class="card-body">
<h5 class="card-title">Passwort zurücksetzen</h5>
<p class="card-text">Hier kannst du dein Passwort ändern</p>
<a href="/system0/html/php/login/v3/reset-password.php" class="stretched-link"></a>
<a href="/login/reset-password.php" class="stretched-link"></a>
</div>
</div>
@@ -135,7 +134,7 @@
<div class="card-body">
<h5 class="card-title">Neuer Admin erstellen</h5>
<p class="card-text">Erstellen Sie ein neues Administratorkonto, um Systemeinstellungen und Benutzer zu verwalten.</p>
<a href="/system0/html/php/login/v3/php/create_admin.php" class="stretched-link"></a>
<a href="/app/create_admin.php" class="stretched-link"></a>
</div>
</div>
@@ -151,7 +150,7 @@
<div class="card-body">
<h5 class="card-title">Benutzer verwalten</h5>
<p class="card-text">Entfernen/bearbeiten Sie ein Benutzerkonto aus dem System.</p>
<a href="/system0/html/php/login/v3/php/remove_user.php" class="stretched-link"></a>
<a href="/app/remove_user.php" class="stretched-link"></a>
</div>
</div>
@@ -164,7 +163,7 @@
<div class="card-body">
<h5 class="card-title">Account löschen</h5>
<p class="card-text">Konto und alle damit verbundenen Daten dauerhaft löschen.</p>
<a href="/system0/html/php/login/v3/delete-account.php" class="stretched-link"></a>
<a href="/app/delete-account.php" class="stretched-link"></a>
</div>
</div>
@@ -178,7 +177,7 @@
<div class="card-body">
<h5 class="card-title">Datenschutzrichtlinie</h5>
<p class="card-text">Lesen Sie unsere Datenschutzrichtlinie, um zu erfahren, wie wir mit Ihren Daten umgehen.</p>
<a href="/system0/html/php/login/v3/php/privacy-policy.php" class="stretched-link"></a>
<a href="/app/privacy-policy.php" class="stretched-link"></a>
</div>
</div>
@@ -192,7 +191,7 @@
<div class="card-body">
<h5 class="card-title">Disclaimer</h5>
<p class="card-text">Lesen Sie unseren Haftungsausschluss für wichtige Informationen zur Nutzung unserer Dienste.</p>
<a href="/system0/html/php/login/v3/php/disclaimer.php" class="stretched-link"></a>
<a href="/app/disclaimer.php" class="stretched-link"></a>
</div>
</div>
@@ -208,7 +207,7 @@
<div class="card-body">
<h5 class="card-title">View system0 Log</h5>
<p class="card-text">Zeigen Sie das Protokoll der Systemaktivitäten und -ereignisse an.</p>
<a href="/system0/html/php/login/v3/php/view_log.php" class="stretched-link"></a>
<a href="/app/view_log.php" class="stretched-link"></a>
</div>
</div>
@@ -223,7 +222,7 @@
<div class="card-body">
<h5 class="card-title">View the system0 API Key</h5>
<p class="card-text">Zeigen Sie den API-Schlüssel an, der für den Zugriff auf die Systemfunktionalitäten verwendet wird.</p>
<a href="/system0/html/php/login/v3/php/view_apikey.php" class="stretched-link"></a>
<a href="/app/view_apikey.php" class="stretched-link"></a>
</div>
</div>
@@ -238,7 +237,7 @@
<div class="card-body">
<h5 class="card-title">Drucker Einstellungen</h5>
<p class="card-text">Hier findest du das Debug-Tool und die Einstellungen.</p>
<a href="/system0/html/php/login/v3/php/debug.php" class="stretched-link"></a>
<a href="/app/debug.php" class="stretched-link"></a>
</div>
</div>
@@ -253,7 +252,7 @@
<div class="card-body">
<h5 class="card-title">Drucker Reservieren</h5>
<p class="card-text">Hier kannst du Drucker Reservieren.</p>
<a href="/system0/html/php/login/v3/php/reservations.php" class="stretched-link"></a>
<a href="/app/reservations.php" class="stretched-link"></a>
</div>
</div>
@@ -267,7 +266,7 @@
<div class="card-body">
<h5 class="card-title">Druckschlüssel erstellen</h5>
<p class="card-text">Hier kannst du Druckschlüssel erstellen.</p>
<a href="/system0/html/php/login/v3/php/create_key.php" class="stretched-link"></a>
<a href="/app/create_key.php" class="stretched-link"></a>
</div>
</div>

View File

@@ -1,8 +1,8 @@
<?php
define('DB_SERVER', '');
define('DB_USERNAME', '');
define('DB_PASSWORD', '');
define('DB_NAME', '');
define('DB_SERVER', 'sys0-db');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '1234');
define('DB_NAME', 'sys0_db');
$api=""; //the telegram api key for jakach notification system
$SENDGRID_API_KEY=""; //our new api key, for the new mail address
$sendgrid_email=""; //our new email

View File

@@ -1,5 +1,5 @@
<?php
phpinfo();
//header('LOCATION:/system0/html/php/login/v3/login.php');
//phpinfo();
header('LOCATION:/login/login.php');
//echo("<br><br><center>Due to some security concerns we are running scans on our entire network.<br>The jakach sites have been disabled temporarly. please come back later;<br></center>");
?>

View File

@@ -30,4 +30,64 @@ $sql = "CREATE TABLE IF NOT EXISTS users (
notification_telegram INT
)";
$link->query($sql);
//printer table
$sql = "CREATE TABLE IF NOT EXISTS printer (
id INT AUTO_INCREMENT PRIMARY KEY,
printing INT,
free INT,
used_by_userid INT,
printer_url VARCHAR(255),
apikey VARCHAR(255),
cancel INT,
system_status INT,
mail_sent INT,
rotation INT,
color VARCHAR(255)
)";
$link->query($sql);
//queue table
$sql = "CREATE TABLE IF NOT EXISTS queue (
id INT AUTO_INCREMENT PRIMARY KEY,
from_userid INT,
filepath VARCHAR(255),
print_on INT
)";
$link->query($sql);
//api table
$sql = "CREATE TABLE IF NOT EXISTS api (
id INT AUTO_INCREMENT PRIMARY KEY,
apikey VARCHAR(255)
)";
$link->query($sql);
//print key table
$sql = "CREATE TABLE IF NOT EXISTS print_key (
id INT AUTO_INCREMENT PRIMARY KEY,
print_key VARCHAR(255)
)";
$link->query($sql);
//reservations table
$sql = "CREATE TABLE IF NOT EXISTS reservations (
id INT AUTO_INCREMENT PRIMARY KEY,
set_by_userid INT,
time_from VARCHAR(255),
time_to VARCHAR(255),
day VARCHAR(255)
)";
$link->query($sql);
//filament table
$sql = "CREATE TABLE IF NOT EXISTS filament (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
internal_id INT
)";
$link->query($sql);
echo("db creation finished, you can now close this tab.");
?>

View File

@@ -11,8 +11,7 @@
else {
$ip = $_SERVER['REMOTE_ADDR'];
}
//echo($ip);
$fp=fopen("log.txt","a");
$fp=fopen("/var/www/html/log/log.txt","a");
fwrite($fp,date(DATE_RFC2822));
fwrite($fp," ");
fwrite($fp,$ip);
@@ -35,7 +34,7 @@
}
//echo($ip);
$fp=fopen("sys0.log","a");
$fp=fopen("/var/www/html/log/sys0.log","a");
fwrite($fp,date(DATE_RFC2822));
fwrite($fp,";");
fwrite($fp,$ip);

View File

@@ -258,7 +258,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST" and $_GET["action"]=="create_user"){
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
// Redirect to login page
if(!is_dir("../user_files/$username"))
if(!is_dir("/var/www/html/user_files/$username"))
mkdir("/var/www/html/user_files/$username");
//create session token, which has account creation token inisde it.
$_SESSION["creation_token"]= urlencode(bin2hex(random_bytes(24/2)));