diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8169015 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +constants.php \ No newline at end of file diff --git a/CheckForMostPlayedJob.php b/CheckForMostPlayedJob.php index f7eeb82..6b5e6e3 100644 --- a/CheckForMostPlayedJob.php +++ b/CheckForMostPlayedJob.php @@ -3,7 +3,7 @@ require("database.php"); require("GetUserMostPlayed.php"); -$database = new Database("localhost", "ScoreSniper", MARIAUSER, MARIAPASSWD); +$database = new Database("localhost", DATABASE, MARIAUSER, MARIAPASSWD); while(true) { diff --git a/CheckForScoreFetchJob.php b/CheckForScoreFetchJob.php index b410cc0..774e090 100644 --- a/CheckForScoreFetchJob.php +++ b/CheckForScoreFetchJob.php @@ -3,7 +3,7 @@ require("database.php"); require("RequestMutualScores.php"); -$database = new Database("localhost", "ScoreSniper", MARIAUSER, MARIAPASSWD); +$database = new Database("localhost", DATABASE, MARIAUSER, MARIAPASSWD); while(true) { diff --git a/CheckMutualMaps.php b/CheckMutualMaps.php index 0ae6b35..5b35ac9 100644 --- a/CheckMutualMaps.php +++ b/CheckMutualMaps.php @@ -3,7 +3,7 @@ if (!function_exists("CheckMutualMaps")) { function CheckMutualMaps($player1, $player2) { require("database.php"); - $database = new Database("localhost", "ScoreSniper", MARIAUSER, MARIAPASSWD); + $database = new Database("localhost", DATABASE, MARIAUSER, MARIAPASSWD); $query = "SELECT a.map_id FROM UserMostPlayed a diff --git a/GetComparableScores.php b/GetComparableScores.php index c3c862c..3f78143 100644 --- a/GetComparableScores.php +++ b/GetComparableScores.php @@ -4,7 +4,7 @@ require("database.php"); require("constants.php"); function getScore($player1, $player2, $random) { - $database = new Database("localhost", "ScoreSniper", MARIAUSER, MARIAPASSWD); + $database = new Database("localhost", DATABASE, MARIAUSER, MARIAPASSWD); $query = "SELECT a.map_id, diff --git a/GetUserMostPlayed.php b/GetUserMostPlayed.php index 6b5af89..77d1beb 100644 --- a/GetUserMostPlayed.php +++ b/GetUserMostPlayed.php @@ -2,7 +2,7 @@ require("database.php"); require("constants.php"); -$database = new Database("localhost", "ScoreSniper", MARIAUSER, MARIAPASSWD); +$database = new Database("localhost", DATABASE, MARIAUSER, MARIAPASSWD); if (!function_exists("getPlays")) { function getPlays() { diff --git a/database.php b/database.php index 39fc9b4..7dbac41 100644 --- a/database.php +++ b/database.php @@ -6,10 +6,11 @@ if(!class_exists("Database")) { private $rows; public function __construct($host, $dbname, $user, $psswd) { + try { $dsn = "mysql:host=$host;dbname=$dbname;charset=utf8mb4"; - $this->pdo = new PDO($dsn, $user, $psswd); + $this->pdo = new PDO($dsn, $user, (!isset($psswd)) ? "" : $psswd); $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { diff --git a/snipe.php b/snipe.php index 8b3906f..bfd769c 100644 --- a/snipe.php +++ b/snipe.php @@ -4,7 +4,7 @@ require("database.php"); require("constants.php"); require("GetComparableScores.php"); -$database = new Database("localhost", "ScoreSniper", MARIAUSER, MARIAPASSWD); +$database = new Database("localhost", DATABASE, MARIAUSER, MARIAPASSWD); $player1 = $_GET['target']; $player2 = $_GET['player'];