update db

This commit is contained in:
themohooks 2024-07-22 00:36:36 +03:00
parent 7f1ea48e44
commit 486c55b7d7
2 changed files with 3 additions and 17 deletions

View file

@ -9,9 +9,9 @@ class DB {
public static function connect() {
if (self::$pdoInstance === null) {
$dsn = 'mysql:host=127.127.126.50;dbname=ngallery;charset=utf8mb4';
$username = 'root';
$password = '';
$dsn = 'mysql:host='.NGALLERY['root']['db']['host'].';dbname='.NGALLERY['root']['db']['name'].';charset=utf8mb4';
$username = NGALLERY['root']['db']['login'];
$password = NGALLERY['root']['db']['password'];
try {
self::$pdoInstance = new PDO($dsn, $username, $password);

View file

@ -20,20 +20,6 @@ class App
}
try {
if (NGALLERY['root']['maintenance'] === false) {
$userIP = $_SERVER['REMOTE_ADDR'];
function getCountryCodeByIP($ip)
{
$url = "http://ip-api.com/json/{$ip}?fields=countryCode";
$response = file_get_contents($url);
$data = json_decode($response, true);
return $data['countryCode'] ?? null;
}
$countryCode = getCountryCodeByIP($userIP);
if (in_array(strtolower($countryCode), explode(',', NGALLERY['root']['access']['countries']))) {
die(Page::set('Errors/ForbiddenCountry'));
}
DB::connect();
Routes::init();
} else {