mirror of
https://github.com/claradex/nativegallery.git
synced 2024-12-23 00:50:55 +03:00
update db
This commit is contained in:
parent
7f1ea48e44
commit
486c55b7d7
2 changed files with 3 additions and 17 deletions
|
@ -9,9 +9,9 @@ class DB {
|
||||||
|
|
||||||
public static function connect() {
|
public static function connect() {
|
||||||
if (self::$pdoInstance === null) {
|
if (self::$pdoInstance === null) {
|
||||||
$dsn = 'mysql:host=127.127.126.50;dbname=ngallery;charset=utf8mb4';
|
$dsn = 'mysql:host='.NGALLERY['root']['db']['host'].';dbname='.NGALLERY['root']['db']['name'].';charset=utf8mb4';
|
||||||
$username = 'root';
|
$username = NGALLERY['root']['db']['login'];
|
||||||
$password = '';
|
$password = NGALLERY['root']['db']['password'];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
self::$pdoInstance = new PDO($dsn, $username, $password);
|
self::$pdoInstance = new PDO($dsn, $username, $password);
|
||||||
|
|
14
index.php
14
index.php
|
@ -20,20 +20,6 @@ class App
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (NGALLERY['root']['maintenance'] === false) {
|
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();
|
DB::connect();
|
||||||
Routes::init();
|
Routes::init();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue