blob: 70607ccb92dc3d25e8cdc8a1ab8b6b92233c6971 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<?php
if(isset($_GET['mode'])){
if($_GET['mode'] === 'config'){
# LASTE NED CONFIG
/*
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Length: ' . filesize('../files/' . $_GET['file']));
*/
$dbconn = pg_connect("host=localhost dbname=bootstrap user=bootstrap password=asdf")
or die('Could not connect: ' . pg_last_error());
// Performing SQL query
$query = 'SELECT * FROM switches WHERE hostname = \'' . $_GET['hostname'] . '\'';
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
if(pg_num_rows($result) == 1){
$c = pg_fetch_assoc($result);
include 'ex2200.template';
}else{
header("HTTP/1.0 404 Not Found");
die();
}
}elseif($_GET['mode'] === 'image'){
if(isset($_GET['file']) && is_readable('../files/' . $_GET['file'])){
# SEND IMAGE
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Length: ' . filesize('../files/' . $_GET['file']));
readfile('../files/' . $_GET['file']);
}else{
header("HTTP/1.1 404 Not Found");
die();
}
}
}
/*
if(substr($_SERVER['REQUEST_URI'], 0, 7 === '/files/'){
# Laste ned JunOS-fil
echo 'henter fil';
}elseif(substr($_SERVER['REQUEST_URI'], 0, 9 === '/tg-edge/'){
# Hente config fra Postgres
echo 'henter config';
}
*/
?>
|