diff --git a/Dockerfile b/Dockerfile index d605f696bf..949c7b0fa8 100755 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,6 @@ RUN docker-php-ext-install sockets RUN \ # Redis Extension - wget -q https://github.com/phpredis/phpredis/archive/$PHP_REDIS_VERSION.tar.gz && \ tar -xf $PHP_REDIS_VERSION.tar.gz && \ cd phpredis-$PHP_REDIS_VERSION && \ @@ -45,9 +44,7 @@ RUN \ ./configure && \ make && make install && \ cd .. && \ - ## Swoole Extension - git clone https://github.com/swoole/swoole-src.git && \ cd swoole-src && \ git checkout v$PHP_SWOOLE_VERSION && \ @@ -55,16 +52,13 @@ RUN \ ./configure --enable-sockets --enable-http2 && \ make && make install && \ cd .. && \ - - ## php reader extension - + ## Maxminddb extension git clone https://github.com/maxmind/MaxMind-DB-Reader-php.git && \ cd MaxMind-DB-Reader-php/ext && \ phpize && \ ./configure && \ make && make install && \ - cd .. - + cd ../.. FROM php:7.4-cli-alpine as final @@ -125,7 +119,6 @@ RUN \ docker-cli \ libmaxminddb \ libmaxminddb-dev \ - && pecl install imagick yaml \ && docker-php-ext-enable imagick yaml \ && docker-php-ext-install sockets opcache pdo_mysql \ diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 286463cd8e..00a3d944d7 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -604,7 +604,7 @@ App::get('/v1/account/sessions') /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Utopia\Locale\Locale $locale */ - /** @var GeoIp2\Database\Reader $geodb */ + /** @var MaxMind\Db\Reader $geodb */ $tokens = $user->getAttribute('tokens', []); $sessions = []; @@ -641,11 +641,11 @@ App::get('/v1/account/sessions') try { $record = $geodb->get($token->getAttribute('ip', '')); - if(isset($record)){ + if (isset($record)){ $sessions[$index]['geo']['isoCode'] = \strtolower($record['country']['iso_code']); $sessions[$index]['geo']['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); - } - else{ + } + else { $sessions[$index]['geo']['isoCode'] = '--'; $sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown'); } @@ -674,7 +674,7 @@ App::get('/v1/account/logs') /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ /** @var Utopia\Locale\Locale $locale */ - /** @var GeoIp2\Database\Reader $geodb */ + /** @var MaxMind\Db\Reader $geodb */ $adapter = new AuditAdapter($register->get('db')); $adapter->setNamespace('app_'.$project->getId()); diff --git a/app/controllers/api/locale.php b/app/controllers/api/locale.php index 04524abe5d..f1d1e0bc86 100644 --- a/app/controllers/api/locale.php +++ b/app/controllers/api/locale.php @@ -15,7 +15,7 @@ App::get('/v1/locale') /** @var Utopia\Request $request */ /** @var Utopia\Response $response */ /** @var Utopia\Locale\Locale $locale */ - /** @var GeoIp2\Database\Reader $geodb */ + /** @var MaxMind\Db\Reader $geodb */ $eu = Config::getParam('locale-eu'); $currencies = Config::getParam('locale-currencies'); @@ -31,9 +31,12 @@ App::get('/v1/locale') try { $record = $geodb->get($ip); + + var_dump('record'); + var_dump($record); + $output['countryCode'] = $record['country']['iso_code']; $output['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); - //$output['countryTimeZone'] = DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, $record->country->isoCode); $output['continent'] = (isset($continents[$record['continent']['code']])) ? $continents[$record['continent']['code']] : $locale->getText('locale.country.unknown'); $output['continentCode'] = $record['continent']['code']; $output['eu'] = (\in_array($record['country']['iso_code'], $eu)) ? true : false; diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 9de6f33569..6ea3b8f87c 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -231,7 +231,7 @@ App::get('/v1/users/:userId/sessions') /** @var Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Utopia\Locale\Locale $locale */ - /** @var GeoIp2\Database\Reader $geodb */ + /** @var MaxMind\Db\Reader $geodb */ $user = $projectDB->getDocument($userId); @@ -272,11 +272,10 @@ App::get('/v1/users/:userId/sessions') try { $record = $geodb->get($token->getAttribute('ip', '')); - if(isset($record)){ + if (isset($record)) { $sessions[$index]['geo']['isoCode'] = \strtolower($record['country']['iso_code']); $sessions[$index]['geo']['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); - } - else{ + } else { $sessions[$index]['geo']['isoCode'] = '--'; $sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown'); } @@ -307,7 +306,7 @@ App::get('/v1/users/:userId/logs') /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $projectDB */ /** @var Utopia\Locale\Locale $locale */ - /** @var GeoIp2\Database\Reader $geodb */ + /** @var MaxMind\Db\Reader $geodb */ $user = $projectDB->getDocument($userId); diff --git a/src/Appwrite/Extend/PDO.php b/src/Appwrite/Extend/PDO.php index fce9165b4e..384fc71be1 100644 --- a/src/Appwrite/Extend/PDO.php +++ b/src/Appwrite/Extend/PDO.php @@ -62,6 +62,8 @@ class PDO extends PDONative public function reconnect() { $this->pdo = new PDONative($this->dsn, $this->username, $this->passwd, $this->options); + + echo '[PDO] MySQL connection restarted'.PHP_EOL; // Connection settings $this->pdo->setAttribute(PDONative::ATTR_DEFAULT_FETCH_MODE, PDONative::FETCH_ASSOC); // Return arrays