Add header.inc and footer.inc
This commit is contained in:
		@@ -1,22 +1,11 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
require "format.inc";
 | 
					require "format.inc";
 | 
				
			||||||
 | 
					include "credentials.inc";
 | 
				
			||||||
 | 
					$TITLE = 'Mandanten';
 | 
				
			||||||
 | 
					$CREDENTIALS ??= [];
 | 
				
			||||||
 | 
					$clients = array_keys($CREDENTIALS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$format = get_fmt();
 | 
					$format = get_fmt();
 | 
				
			||||||
$cred_file_name = 'credentials.txt';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
$clients = [];
 | 
					 | 
				
			||||||
$names = [];
 | 
					 | 
				
			||||||
$passwords = [];
 | 
					 | 
				
			||||||
foreach (scandir('.clients/') as $file) {
 | 
					 | 
				
			||||||
    if ($file === '.' || $file === '..') continue;
 | 
					 | 
				
			||||||
    array_push($clients, $file);
 | 
					 | 
				
			||||||
    $content = file_get_contents(".clients/$file/$cred_file_name");
 | 
					 | 
				
			||||||
    if ($content) {
 | 
					 | 
				
			||||||
        $creds = explode(":", explode("\n", $content)[0]);
 | 
					 | 
				
			||||||
        $names[$file] = $creds[0];
 | 
					 | 
				
			||||||
        $passwords[$file] = $creds[1];
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
$path = $_SERVER['PATH_INFO'];
 | 
					$path = $_SERVER['PATH_INFO'];
 | 
				
			||||||
if ($path == '') {
 | 
					if ($path == '') {
 | 
				
			||||||
@@ -36,7 +25,7 @@ if ($path == '') {
 | 
				
			|||||||
        exit();
 | 
					        exit();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ($format === 'text' || $format === 'html') {
 | 
					    if ($format === 'text') {
 | 
				
			||||||
        header('Content-Type: text/plain; charset=UTF-8');
 | 
					        header('Content-Type: text/plain; charset=UTF-8');
 | 
				
			||||||
        foreach ($clients as $c)
 | 
					        foreach ($clients as $c)
 | 
				
			||||||
            echo "$c\n";
 | 
					            echo "$c\n";
 | 
				
			||||||
@@ -52,7 +41,18 @@ if ($path == '') {
 | 
				
			|||||||
        echo "\n]}\n";
 | 
					        echo "\n]}\n";
 | 
				
			||||||
    } else if ($format === 'html') {
 | 
					    } else if ($format === 'html') {
 | 
				
			||||||
        header('Content-Type: text/html; charset=UTF-8');
 | 
					        header('Content-Type: text/html; charset=UTF-8');
 | 
				
			||||||
        // TODO
 | 
					        require "header.inc"; ?>
 | 
				
			||||||
 | 
					    <h1>Mandanten</h1>
 | 
				
			||||||
 | 
					    <table>
 | 
				
			||||||
 | 
					        <thead><tr><th>Name</th></tr></thead>
 | 
				
			||||||
 | 
					        <tbody>
 | 
				
			||||||
 | 
					<?php foreach ($clients as $c) {
 | 
				
			||||||
 | 
					            echo "            <tr><td><a href='clients/$c'>$c</a></td></tr>\n";
 | 
				
			||||||
 | 
					        } ?>
 | 
				
			||||||
 | 
					        </tbody>
 | 
				
			||||||
 | 
					    </table>
 | 
				
			||||||
 | 
					    <p><a href="clients?format=json">JSON-Format</a></p>
 | 
				
			||||||
 | 
					<?php require "footer.inc";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    exit();
 | 
					    exit();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -63,7 +63,9 @@ foreach ($clients as $c) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    header('Content-Type: text/plain; charset=UTF-8');
 | 
					    header('Content-Type: text/plain; charset=UTF-8');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_USER'] !== $names[$c] || $_SERVER['PHP_AUTH_PW'] !== $passwords[$c]) {
 | 
					    if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
 | 
				
			||||||
 | 
					        !array_key_exists($_SERVER['PHP_AUTH_USER'], $CREDENTIALS[$c]) || $_SERVER['PHP_AUTH_PW'] !== $CREDENTIALS[$c][$_SERVER['PHP_AUTH_USER']])
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        header('Status: 401');
 | 
					        header('Status: 401');
 | 
				
			||||||
        header('WWW-Authenticate: Basic realm="Elwig"');
 | 
					        header('WWW-Authenticate: Basic realm="Elwig"');
 | 
				
			||||||
        exit("401 Unauthorized :(\n");
 | 
					        exit("401 Unauthorized :(\n");
 | 
				
			||||||
@@ -77,7 +79,7 @@ foreach ($clients as $c) {
 | 
				
			|||||||
            header("Allow: GET");
 | 
					            header("Allow: GET");
 | 
				
			||||||
            exit("405 Method Not Allowed :(\n");
 | 
					            exit("405 Method Not Allowed :(\n");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        system("ls -Al .clients/$c/");
 | 
					        system("ls -Al .data/clients/$c/");
 | 
				
			||||||
        exit();
 | 
					        exit();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    $file = substr($path, strlen("/$c/"));
 | 
					    $file = substr($path, strlen("/$c/"));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
require "../format.inc";
 | 
					require "../format.inc";
 | 
				
			||||||
 | 
					$TITLE = 'Downloads';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ($_SERVER['PATH_INFO'] !== '') {
 | 
					if ($_SERVER['PATH_INFO'] !== '') {
 | 
				
			||||||
    header('Status: 404');
 | 
					    header('Status: 404');
 | 
				
			||||||
@@ -37,33 +38,15 @@ if ($format === 'json') {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
} else if ($format === 'html') {
 | 
					} else if ($format === 'html') {
 | 
				
			||||||
    header('Content-Type: text/html; charset=UTF-8');
 | 
					    header('Content-Type: text/html; charset=UTF-8');
 | 
				
			||||||
?>
 | 
					    require "../header.inc"; ?>
 | 
				
			||||||
<!DOCTYPE html>
 | 
					 | 
				
			||||||
<html lang="de">
 | 
					 | 
				
			||||||
<head>
 | 
					 | 
				
			||||||
    <title>Downloads - Elwig - Elektronische Winzergenossenschaftsverwaltung</title>
 | 
					 | 
				
			||||||
    <meta charset="UTF-8"/>
 | 
					 | 
				
			||||||
    <link rel="icon" sizes="16x16 20x20 24x24 30x30 32x32 36x36 40x40 48x48 60x60 64x64 72x72 80x80 96x96 128x128 256x256" href="../res/elwig.ico"/>
 | 
					 | 
				
			||||||
    <link rel="stylesheet" href="../res/style.css"/>
 | 
					 | 
				
			||||||
</head>
 | 
					 | 
				
			||||||
<body>
 | 
					 | 
				
			||||||
    <h1>Downloads</h1>
 | 
					    <h1>Downloads</h1>
 | 
				
			||||||
    <table>
 | 
					    <table>
 | 
				
			||||||
        <thead>
 | 
					        <thead><tr><th>Name</th><th>Größe</th></tr></thead>
 | 
				
			||||||
            <tr>
 | 
					 | 
				
			||||||
                <th>Name</th>
 | 
					 | 
				
			||||||
                <th>Größe</th>
 | 
					 | 
				
			||||||
            </tr>
 | 
					 | 
				
			||||||
        </thead>
 | 
					 | 
				
			||||||
        <tbody>
 | 
					        <tbody>
 | 
				
			||||||
<?php
 | 
					<?php foreach ($files as $name => [$size, $mtime, $ctime]) {
 | 
				
			||||||
foreach ($files as $name => [$size, $mtime, $ctime]) {
 | 
					        echo "            <tr><td><a href='$name'>$name</a></td><td>" . number_format($size / 1024 / 1024, 1) . " MB</td></tr>\n";
 | 
				
			||||||
    echo "            <tr><td><a href='$name'>$name</a></td><td>" . number_format($size / 1024 / 1024, 1) . " MB</td></tr>\n";
 | 
					    } ?>
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
?>
 | 
					 | 
				
			||||||
        </tbody>
 | 
					        </tbody>
 | 
				
			||||||
    </table>
 | 
					    </table>
 | 
				
			||||||
    <p><a href="?format=json">JSON-Format</a></p>
 | 
					    <p><a href="files?format=json">JSON-Format</a></p>
 | 
				
			||||||
</body>
 | 
					<?php require "../footer.inc"; }
 | 
				
			||||||
</html>
 | 
					 | 
				
			||||||
<?php }
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								www/footer.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								www/footer.inc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					</body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
@@ -1,15 +1,10 @@
 | 
				
			|||||||
<!DOCTYPE html>
 | 
					<!DOCTYPE html>
 | 
				
			||||||
<html lang="de">
 | 
					<html lang="de">
 | 
				
			||||||
<head>
 | 
					<head>
 | 
				
			||||||
    <title>Elwig - Elektronische Winzergenossenschaftsverwaltung</title>
 | 
					    <base href="/elwig/"/>
 | 
				
			||||||
 | 
					    <title><?php if (!empty($TITLE)) echo "$TITLE - "; ?>Elwig - Elektronische Winzergenossenschaftsverwaltung</title>
 | 
				
			||||||
    <meta charset="UTF-8"/>
 | 
					    <meta charset="UTF-8"/>
 | 
				
			||||||
    <link rel="icon" sizes="16x16 20x20 24x24 30x30 32x32 36x36 40x40 48x48 60x60 64x64 72x72 80x80 96x96 128x128 256x256" href="res/elwig.ico"/>
 | 
					    <link rel="icon" sizes="16x16 20x20 24x24 30x30 32x32 36x36 40x40 48x48 60x60 64x64 72x72 80x80 96x96 128x128 256x256" href="res/elwig.ico"/>
 | 
				
			||||||
    <link rel="stylesheet" href="res/style.css"/>
 | 
					    <link rel="stylesheet" href="res/style.css"/>
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
    <h1>Elwig</h1>
 | 
					 | 
				
			||||||
    <h2>Elektronische Winzergenossenschaftsverwaltung</h2>
 | 
					 | 
				
			||||||
    <a href="https://git.necronda.net/winzer">Source</a>
 | 
					 | 
				
			||||||
    <a href="files/">Downloads</a>
 | 
					 | 
				
			||||||
</body>
 | 
					 | 
				
			||||||
</html>
 | 
					 | 
				
			||||||
							
								
								
									
										7
									
								
								www/index.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								www/index.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					<?php require "header.inc"; ?>
 | 
				
			||||||
 | 
					    <h1>Elwig</h1>
 | 
				
			||||||
 | 
					    <h2>Elektronische Winzergenossenschaftsverwaltung</h2>
 | 
				
			||||||
 | 
					    <a href="https://git.necronda.net/winzer">Source</a><br/>
 | 
				
			||||||
 | 
					    <a href="files/">Downloads</a><br/>
 | 
				
			||||||
 | 
					    <a href="clients">Mandanten</a>
 | 
				
			||||||
 | 
					<?php require "footer.inc"; ?>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user