You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dafl_music/Sources/php_script/script/config.php

36 lines
1.2 KiB

<?php
function connection(): bool|int|mysqli
{
$username = $_ENV["USER"]; //Get the username
$host = $_ENV["HOST"]; //Get the url of the database
$password = $_ENV["PASSWORD"]; //Get the password for the user selected
$db_name = $_ENV["DATABASE"]; //Get the name of the database
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
echo "AH";
echo $ip;
try { //Try to connect to the database
return mysqli_connect($host, $username, $password,$db_name); //Connecting to database
}catch (mysqli_sql_exception) { //If the connection failed
return -1; //Send a return code as -1, so insertAndMakeListUser.php can know if the connection is successful
}
}