From d14b81bc0242cfb49229571f38eb26fa7de43b2b Mon Sep 17 00:00:00 2001 From: Olaf Bohlen <olbohlen@eenfach.de> Date: Fri, 16 Jun 2023 13:01:28 +0200 Subject: [PATCH] init vars to empty value --- index.php | 44 ++++++++++++++++++++++++++++++++++++++------ 1 files changed, 38 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index e2f3c54..f1b6ebd 100644 --- a/index.php +++ b/index.php @@ -5,17 +5,49 @@ <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>' - $filename = '/secretstore/filesecret'; - - if (file_exists($filename)) { + 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 "no additional secrets found!"; } - echo '</p>' + 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 = ""; + $user = ""; + $pass = ""; + $db = ""; + + $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> -- Gitblit v1.9.3