parent
58a9314db3
commit
fd50796b4e
7 changed files with 80 additions and 0 deletions
@ -0,0 +1,16 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="de"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<link href="styles.css" rel="stylesheet"> |
||||
<title>UEM Elo Tracker</title> |
||||
</head> |
||||
<body> |
||||
<?php |
||||
require "../util/mysql_connect.php"; |
||||
$conn = new MySQLConnection(); |
||||
|
||||
?> |
||||
</body> |
||||
</html> |
||||
|
@ -0,0 +1,11 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="de"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<link href="styles.css" rel="stylesheet"> |
||||
<title>University eSports Mainz</title> |
||||
</head> |
||||
<body> |
||||
<a href="elotracker">Zum Elo Tracker</a> |
||||
</body> |
||||
</html> |
@ -0,0 +1,4 @@ |
||||
<?php |
||||
|
||||
foreach (parse_ini_file($_SERVER['DOCUMENT_ROOT']."/../.env") as $key => $value) |
||||
putenv("$key=$value"); |
@ -0,0 +1,47 @@ |
||||
<?php |
||||
|
||||
require_once "dotenv.php"; |
||||
|
||||
class MySQLConnection { |
||||
|
||||
private int $port; |
||||
private string $host; |
||||
private string $user; |
||||
private string $pass; |
||||
private string $dbName = "uem"; |
||||
private mysqli $mysqli; |
||||
|
||||
public function __construct() { |
||||
$this->host = 'localhost'; |
||||
$this->port = intval(getenv('MYSQL_PORT')); |
||||
$this->user = getenv('MYSQL_USER'); |
||||
$this->pass = getenv('MYSQL_PASSWORD'); |
||||
$this->createConn(); |
||||
} |
||||
|
||||
private function createConn(): void { |
||||
$this->mysqli = new mysqli($this->host . ":" . $this->port, $this->user, $this->pass, $this->dbName); |
||||
} |
||||
|
||||
public function query($sql): mysqli_result|bool { |
||||
return $this->mysqli->query($sql); |
||||
} |
||||
|
||||
public function prepare($sql): bool|mysqli_stmt { |
||||
return $this->mysqli->prepare($sql); |
||||
} |
||||
|
||||
public function changeDB($dbName): void { |
||||
$this->dbName = $dbName; |
||||
$this->mysqli->select_db($dbName); |
||||
} |
||||
|
||||
public function escape(string $string): string{ |
||||
return $this->mysqli->real_escape_string($string); |
||||
} |
||||
|
||||
public function __destruct() { |
||||
$this->mysqli->close(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,2 @@ |
||||
<?php |
||||
phpinfo(); |
Loading…
Reference in new issue