Olaf Bohlen
2023-03-01 4d8bfd9942fc5801e048487a9cde91a64326e4d3
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
<html>
 <head>
  <title>hello php</title>
 </head>
 <body>
   <?php 
    echo '<p>hello world from ' .$_ENV["HOSTNAME"] . '</p>';
    echo '<p>the current php version is ' . phpversion() . '</p>';
    echo '<p>TEXT = ' .$_ENV["TEXT"] . '</p>';
    echo '<p>PASSWORD = ' .$_ENV["PASSWORD"] . '</p>';
    echo '<p>';
    if (file_exists('/secretstore/filesecret')) {
      echo "secret file contains: ";
      echo nl2br(file_get_contents( "/secretstore/filesecret" )); 
    } else {
      echo "no additional secrets found!";
    }
    echo '</p>';
    echo '<p>';
    if (file_exists('/pvcmount/pfile')) {
      echo "file contains: ";
      echo nl2br(file_get_contents( "/pvcmount/pfile" )); 
    } else {
      echo "no other file found!";
    }
    echo '</p>';
 
    $host = $_ENV["DBHOST"]; 
    $user = $_ENV["DBUSER"]; 
    $pass = $_ENV["DBPASS"]; 
    $db = $_ENV["DBNAME"]; 
    echo '<p>Connecting to database at ' .$host . '</p>';
    $con = pg_connect("host=$host dbname=$db user=$user password=$pass")
        or die ("Could not connect to server\n"); 
 
    $query = "SELECT * FROM foo LIMIT 5"; 
 
    $rs = pg_query($con, $query) or die("Cannot execute query: $query\n");
 
    echo '<p>Database results:<hr>';
    while ($row = pg_fetch_row($rs)) {
      echo "$row[0]\n";
    }
    echo "</p>";
    pg_close($con); 
?>
 </body>
</html>