1
0
Fork 0
mirror of synced 2024-06-24 01:00:35 +12:00

Merge branch '0.7.x' of github.com:appwrite/appwrite into feat-511-jwt-support

This commit is contained in:
Eldad Fux 2020-10-27 01:51:38 +02:00
commit 9c6138308c
38 changed files with 813 additions and 474 deletions

5
.env
View file

@ -21,6 +21,9 @@ _APP_STATSD_HOST=telegraf
_APP_STATSD_PORT=8125
_APP_SMTP_HOST=maildev
_APP_SMTP_PORT=25
_APP_SMTP_SECURE=
_APP_SMTP_USERNAME=
_APP_SMTP_PASSWORD=
_APP_STORAGE_LIMIT=100000000
_APP_FUNCTIONS_TIMEOUT=900
_APP_FUNCTIONS_CONTAINERS=10
_APP_FUNCTIONS_CONTAINERS=10

View file

@ -32,10 +32,11 @@ before_install:
install:
- docker --version
- docker-compose up -d
- sleep 90
- sleep 15
script:
- docker ps
- docker-compose logs appwrite
- docker exec appwrite doctor
- docker exec appwrite vars
- docker exec appwrite test

View file

@ -237,7 +237,7 @@ docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t appwrite/
To run tests manually, use the Appwrite Docker CLI from your terminal:
```bash
docker exec appwrite test
docker-compose exec appwrite test
```
## Benchmarking

View file

@ -16,7 +16,7 @@ FROM php:7.4-cli-alpine as step1
ENV TZ=Asia/Tel_Aviv \
PHP_REDIS_VERSION=5.3.0 \
PHP_SWOOLE_VERSION=4.5.5 \
PHP_SWOOLE_VERSION=4.5.6 \
PHP_XDEBUG_VERSION=sdebug_2_9-beta
RUN \
@ -30,7 +30,8 @@ RUN \
wget \
git \
zlib-dev \
brotli-dev
brotli-dev \
libmaxminddb-dev
RUN docker-php-ext-install sockets
@ -50,7 +51,14 @@ RUN \
phpize && \
./configure --enable-sockets --enable-http2 && \
make && make install && \
cd ..
cd .. && \
## 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 ../..
FROM php:7.4-cli-alpine as final
@ -109,6 +117,9 @@ RUN \
imagemagick-dev \
certbot \
docker-cli \
docker-compose \
libmaxminddb \
libmaxminddb-dev \
&& pecl install imagick yaml \
&& docker-php-ext-enable imagick yaml \
&& docker-php-ext-install sockets opcache pdo_mysql \
@ -120,6 +131,7 @@ WORKDIR /usr/src/code
COPY --from=step0 /usr/local/src/vendor /usr/src/code/vendor
COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/
COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/
COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/maxminddb.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/
# Add Source Code
COPY ./app /usr/src/code/app
@ -165,6 +177,7 @@ RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/
# Enable Extensions
RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini
RUN echo extension=redis.so >> /usr/local/etc/php/conf.d/redis.ini
RUN echo extension=maxminddb.so >> /usr/local/etc/php/conf.d/maxminddb.ini
RUN echo "opcache.preload_user=www-data" >> /usr/local/etc/php/conf.d/appwrite.ini
RUN echo "opcache.preload=/usr/src/code/app/preload.php" >> /usr/local/etc/php/conf.d/appwrite.ini

View file

@ -8,7 +8,7 @@
</p>
[![Hacktoberfest](https://badgen.net/badge/hacktoberfest/friendly/pink)](CONTRIBUTING.md)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://discord.gg/GSeTUeA)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)
[![Docker Pulls](https://badgen.net/docker/pulls/appwrite/appwrite)](https://travis-ci.org/appwrite/appwrite)
[![Travis CI](https://badgen.net/travis/appwrite/appwrite?label=build)](https://travis-ci.com/appwrite/appwrite)
[![Twitter Account](https://badgen.net/twitter/follow/appwrite_io?label=twitter)](https://twitter.com/appwrite_io)

View file

@ -12,6 +12,7 @@ return [
'de', // German
'en', // English
'es', // Spanish
'fa', // Farsi/Persian
'fi', // Finnish
'fo', // Faroese
'fr', // French

View file

@ -30,8 +30,4 @@ $list = [
'SE', // Sweden
];
if (\time() < \strtotime('2020-01-31')) { // @see https://en.wikipedia.org/wiki/Brexit
$list[] = 'GB'; // // United Kingdom
}
return $list;

View file

@ -9,7 +9,7 @@ return [
'account.emails.team' => 'Equipo %s',
'account.emails.verification.title' => 'Confirmación de la cuenta',
'account.emails.verification.body' => 'es.email.auth.confirm.tpl',
'account.emails.recovery.title' => 'Reestablecer contraseña',
'account.emails.recovery.title' => 'Restablecer contraseña',
'account.emails.recovery.body' => 'es.email.auth.recovery.tpl',
'account.emails.invitation.title' => 'Invitación al Equipo %s en %s',
'account.emails.invitation.body' => 'es.email.auth.invitation.tpl',

View file

@ -0,0 +1,11 @@
<?php
return [
'AF' => 'آفریقا',
'AN' => 'قطب جنوب',
'AS' => 'آسیا',
'EU' => 'اروپا',
'NA' => 'آمریکای شمالی',
'OC' => 'اقیانوسیه',
'SA' => 'آمریکای جنوبی',
];

View file

@ -0,0 +1,198 @@
<?php
return [
'AF' => 'افقانستان',
'AO' => 'آنگولا',
'AL' => 'آلبانی',
'AD' => 'آندورا',
'AE' => 'امارات متحده عربی',
'AR' => 'آرژانتین',
'AM' => 'ارمنستان',
'AG' => 'آنتیگوا و باربودا',
'AU' => 'استرالیا',
'AT' => 'اتریش',
'AZ' => 'آذربایجان',
'BI' => 'بوروندی',
'BE' => 'بلژیک',
'BJ' => 'بنین',
'BF' => 'بورکینافاسو',
'BD' => 'بنگلادش',
'BG' => 'بلغارستان',
'BH' => 'بحرین',
'BS' => 'باهاما',
'BA' => 'بوسنی و هرزگوین',
'BY' => 'بلاروس',
'BZ' => 'بلیز',
'BO' => 'بولیوی',
'BR' => 'برزیل',
'BB' => 'باربادوس',
'BN' => 'برونئی',
'BT' => 'بوتان',
'BW' => 'بوتسوانا',
'CF' => 'جمهوری آفریقای مرکزی',
'CA' => 'کانادا',
'CH' => 'سوئیس',
'CL' => 'شیلی',
'CN' => 'چین',
'CI' => 'ساحل عاج',
'CM' => 'کامرون',
'CD' => 'کنگو',
'CG' => 'جمهوری کنگو',
'CO' => 'کلمبیا',
'KM' => 'کومور',
'CV' => 'کیپ ورد',
'CR' => 'کاستاریکا',
'CU' => 'کوبا',
'CY' => 'قبرس',
'CZ' => 'جمهوری چک',
'DE' => 'آلمان',
'DJ' => 'جیبوتی',
'DM' => 'دومینیکا',
'DK' => 'دانمارک',
'DO' => 'جمهوری دومینیکا',
'DZ' => 'الجزیره',
'EC' => 'اکوادور',
'EG' => 'مصر',
'ER' => 'اریتره',
'ES' => 'اسپانیا',
'EE' => 'استونی',
'ET' => 'اتیوپی',
'FI' => 'فنلاند',
'FJ' => 'فیجی',
'FR' => 'فرانسه',
'FM' => 'میکرونزی',
'GA' => 'گابن',
'GB' => 'انگلستان',
'GE' => 'گرجستان',
'GH' => 'غنا',
'GN' => 'گینه',
'GM' => 'گامبیا',
'GW' => 'گینه بیسائو',
'GQ' => 'گینه استوایی',
'GR' => 'یونان',
'GD' => 'گرنادا',
'GT' => 'گواتمالا',
'GY' => 'گویان',
'HN' => 'هندوراس',
'HR' => 'کرواسی',
'HT' => 'هائیتی',
'HU' => 'مجارستان',
'ID' => 'اندونزی',
'IN' => 'هند',
'IE' => 'ایرلند',
'IR' => 'ایران',
'IQ' => 'عراث',
'IS' => 'ایسلند',
'IL' => 'اسرائیل',
'IT' => 'ایتالیا',
'JM' => 'جاماییکا',
'JO' => 'اردن',
'JP' => 'جاپن',
'KZ' => 'قزاقستان',
'KE' => 'کنیا',
'KG' => 'قرقیزستان',
'KH' => 'کامبوج',
'KI' => 'کیریباتی',
'KN' => 'سنت کیتس و نویس',
'KR' => 'کرخ جنوبی',
'KW' => 'کویت',
'LA' => 'لائوس',
'LB' => 'لبنان',
'LR' => 'لیبریا',
'LY' => 'لیبی',
'LC' => 'سنت لوسیا',
'LI' => 'لیختن اشتاین',
'LK' => 'سریلانکا',
'LS' => 'لسوتو',
'LT' => 'لیتوانی',
'LU' => 'لوکزامبورگ',
'LV' => 'لتونی',
'MA' => 'مراکش',
'MC' => 'موناکو',
'MD' => 'مولداوی',
'MG' => 'ماداگاسکار',
'MV' => 'مالدیو',
'MX' => 'مکزیک',
'MH' => 'جزایر مارشال',
'MK' => 'مقدونیه',
'ML' => 'مالی',
'MT' => 'مالتا',
'MM' => 'میانمار',
'ME' => 'مونته نگرو',
'MN' => 'مغولستان',
'MZ' => 'موزامبیک',
'MR' => 'موریتانی',
'MU' => 'موریس',
'MW' => 'مالاوی',
'MY' => 'مالزی',
'NA' => 'نامیبیا',
'NE' => 'نیجر',
'NG' => 'نیجریه',
'NI' => 'نیکاراگوئه',
'NL' => 'هلند',
'NO' => 'نروژ',
'NP' => 'نپال',
'NR' => 'نائورو',
'NZ' => 'نیوزلند',
'OM' => 'عمان',
'PK' => 'پاکستان',
'PA' => 'پاناما',
'PE' => 'پرو',
'PH' => 'فیلیپین',
'PW' => 'پالائو',
'PG' => 'پاپوآ گینه نو',
'PL' => 'لهستان',
'KP' => 'کره شمالی',
'PT' => 'پرتغال',
'PY' => 'پاراگوئه',
'QA' => 'قطر',
'RO' => 'رومانی',
'RU' => 'روسیه',
'RW' => 'رواندا',
'SA' => 'عربستان سعودی',
'SD' => 'سودان',
'SN' => 'سنگال',
'SG' => 'سنگاپور',
'SB' => 'جزایر سلیمان',
'SL' => 'سیرا لئون',
'SV' => 'السالوادور',
'SM' => 'سان مارینو',
'SO' => 'سومالی',
'RS' => 'صربستان',
'SS' => 'سودان جنوبی',
'ST' => 'سائو تومه و پرنسیپ',
'SR' => 'سورینام',
'SK' => 'اسلواکی',
'SI' => 'اسلوونی',
'SE' => 'سوئد',
'SZ' => 'سوئیس',
'SC' => 'سیشل',
'SY' => 'سوریه',
'TD' => 'چاد',
'TG' => 'توگپ',
'TH' => 'تایلند',
'TJ' => 'تاجیکستان',
'TM' => 'ترکمنستان',
'TL' => 'تیمور-لسته',
'TO' => 'تونگا',
'TT' => 'ترینیداد و توباگو',
'TN' => 'تونس',
'TR' => 'ترکیه',
'TV' => 'تووالو',
'TZ' => 'تانزانیا',
'UG' => 'اوگاندا',
'UA' => 'اوکراین',
'UY' => 'اوگوئه',
'US' => 'ایالات متحده آمریکا',
'UZ' => 'ازبکستان',
'VA' => 'شهر واتیکان',
'VC' => 'سنت وینسنت و گرنادین ها',
'VE' => 'ونزوئلا',
'VN' => 'ویتنام',
'VU' => 'وانواتو',
'WS' => 'ساموآ',
'YE' => 'یمن',
'ZA' => 'آفریقای جنوبی',
'ZM' => 'زامبیا',
'ZW' => 'زیمباوه',
];

View file

@ -0,0 +1,21 @@
<?php
return [
'settings.inspire' => '"هنر خردمند بودن، هنر دانستن چیزی است که باید از آن غافل شد."', // This is the line printed in the homepage and console 'view-source'
'settings.locale' => 'fa',
'settings.direction' => 'rtl',
// Service - Users
'account.emails.team' => 'تیم %s',
'account.emails.verification.title' => 'تایید حساب کاربری',
'account.emails.verification.body' => 'fa.email.auth.confirm.tpl',
'account.emails.recovery.title' => 'بازیابی رمز عبور',
'account.emails.recovery.body' => 'fa.email.auth.recovery.tpl',
'account.emails.invitation.title' => 'دعوتنامه به تیم %s در %s',
'account.emails.invitation.body' => 'fa.email.auth.invitation.tpl',
'locale.country.unknown' => 'ناشناخته',
'countries' => include 'fa.countries.php',
'continents' => include 'fa.continents.php',
];

View file

@ -2,7 +2,7 @@
Hola,
</p>
<p>
Te hemos enviamos este correo porque <b>{{owner}}</b> quiere invitarte a formar parte del equipo <b>{{team}}</b> en {{project}}.
Te hemos enviado este correo porque <b>{{owner}}</b> quiere invitarte a formar parte del equipo <b>{{team}}</b> en {{project}}.
</p>
<p>
Sigue este enlace para unirte al equipo <b>{{team}}</b>:

View file

@ -2,11 +2,11 @@
Hola {{name}},
</p>
<p>
Sigue este enlace para reestablecer tu contraseña de {{project}}.
Sigue este enlace para restablecer tu contraseña de {{project}}.
</p>
{{cta}}
<p>
Si no has pedido reestablecer tu contraseña, puedes ignorar este mensaje.
Si no solicitaste restablecer tu contraseña, puedes ignorar este mensaje.
</p>
<p>
Gracias,

View file

@ -0,0 +1,16 @@
<p>
سلام {{name}}،
</p>
<p>
برای تأیید آدرس ایمیل خود، روی این لینک کلیک کنید.
</p>
{{cta}}
<p>
اگر از شما خواسته نشده است این آدرس ایمیل را تأیید کنید، می توانید این پیام را نادیده بگیرید.
</p>
<p>
متشکریم,
<br />
تیم {{project}}
</p>

View file

@ -0,0 +1,18 @@
<p>
سلام،
</p>
<p>
این نامه برای شما ارسال شد زیرا <b>{{owner}}</b> می‌خواهد شما را به عضویت تیم <b>{{team}}</b> در {{project}} دعوت کند.
</p>
<p>
برای عضویت در تیم <b>{{team}}</b> بر روی لینک زیر کلیک کنید :
</p>
{{cta}}
<p>
اگر علاقه‌ای ندارید، می توانید این پیام را نادیده بگیرید.
</p>
<p>
متشکریم,
<br />
{{project}} تیم
</p>

View file

@ -0,0 +1,15 @@
<p>
سلام {{name}}،
</p>
<p>
لینک زیر را کلیک کنید تا رمز عبور {{project}} را بازیابی کنید.
</p>
{{cta}}
<p>
اگر علاقه‌ای ندارید، می توانید این پیام را نادیده بگیرید.
</p>
<p>
متشکریم،
<br />
تیم {{project}}
</p>

View file

@ -634,7 +634,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 = [];
@ -669,9 +669,17 @@ App::get('/v1/account/sessions')
];
try {
$record = $geodb->country($token->getAttribute('ip', ''));
$sessions[$index]['geo']['isoCode'] = \strtolower($record->country->isoCode);
$sessions[$index]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : $locale->getText('locale.country.unknown');
$record = $geodb->get($token->getAttribute('ip', ''));
if ($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 {
$sessions[$index]['geo']['isoCode'] = '--';
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
}
} catch (\Exception $e) {
$sessions[$index]['geo']['isoCode'] = '--';
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
@ -696,7 +704,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());
@ -746,10 +754,17 @@ App::get('/v1/account/logs')
];
try {
$record = $geodb->country($log['ip']);
$output[$i]['geo']['isoCode'] = \strtolower($record->country->isoCode);
$output[$i]['geo']['country'] = $record->country->name;
$output[$i]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : $locale->getText('locale.country.unknown');
$record = $geodb->get($log['ip']);
if(isset($record)){
$output[$i]['geo']['isoCode'] = \strtolower($record['country']['iso_code']);
$output[$i]['geo']['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown');
}
else{
$output[$i]['geo']['isoCode'] = '--';
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');
}
} catch (\Exception $e) {
$output[$i]['geo']['isoCode'] = '--';
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');

View file

@ -11,12 +11,10 @@ use Utopia\Cache\Cache;
use Utopia\Cache\Adapter\Filesystem;
use Appwrite\Resize\Resize;
use Appwrite\URL\URL as URLParse;
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
use Utopia\Config\Config;
use Utopia\Validator\HexColor;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
$avatarCallback = function ($type, $code, $width, $height, $quality, $response) {
/** @var Utopia\Response $response */
@ -365,13 +363,11 @@ App::get('/v1/avatars/qr')
/** @var Utopia\Response $response */
$download = ($download === '1' || $download === 'true' || $download === 1 || $download === true);
$renderer = new ImageRenderer(
new RendererStyle($size, $margin),
new ImagickImageBackEnd('png', 100)
);
$writer = new Writer($renderer);
$qropts = new QROptions([
'quietzone' => $size,
'outputType' => QRCode::OUTPUT_IMAGICK
]);
$qrcode = new QRCode($qropts);
if ($download) {
$response->addHeader('Content-Disposition', 'attachment; filename="qr.png"');
@ -380,7 +376,7 @@ App::get('/v1/avatars/qr')
$response
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT') // 45 days cache
->setContentType('image/png')
->send($writer->writeString($text))
->send($qrcode->render($text))
;
}, ['response']);
@ -460,4 +456,4 @@ App::get('/v1/avatars/initials')
->setContentType('image/png')
->send($image->getImageBlob())
;
}, ['response', 'user']);
}, ['response', 'user']);

View file

@ -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');
@ -29,23 +29,23 @@ App::get('/v1/locale')
$currency = null;
try {
$record = $geodb->country($ip);
$output['countryCode'] = $record->country->isoCode;
$output['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : $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->isoCode, $eu)) ? true : false;
$record = $geodb->get($ip);
if($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['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;
foreach ($currencies as $code => $element) {
if (isset($element['locations']) && isset($element['code']) && \in_array($record->country->isoCode, $element['locations'])) {
if (isset($element['locations']) && isset($element['code']) && \in_array($record['country']['iso_code'], $element['locations'])) {
$currency = $element['code'];
}
}
$output['currency'] = $currency;
} catch (\Exception $e) {
} else {
$output['countryCode'] = '--';
$output['country'] = $locale->getText('locale.country.unknown');
$output['continent'] = $locale->getText('locale.country.unknown');

View file

@ -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);
@ -270,9 +270,16 @@ App::get('/v1/users/:userId/sessions')
];
try {
$record = $geodb->country($token->getAttribute('ip', ''));
$sessions[$index]['geo']['isoCode'] = \strtolower($record->country->isoCode);
$sessions[$index]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : $locale->getText('locale.country.unknown');
$record = $geodb->get($token->getAttribute('ip', ''));
if ($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 {
$sessions[$index]['geo']['isoCode'] = '--';
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
}
} catch (\Exception $e) {
$sessions[$index]['geo']['isoCode'] = '--';
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
@ -299,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);
@ -356,10 +363,17 @@ App::get('/v1/users/:userId/logs')
];
try {
$record = $geodb->country($log['ip']);
$output[$i]['geo']['isoCode'] = \strtolower($record->country->isoCode);
$output[$i]['geo']['country'] = $record->country->name;
$output[$i]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : $locale->getText('locale.country.unknown');
$record = $geodb->get($log['ip']);
if(isset($record)){
$output[$i]['geo']['isoCode'] = \strtolower($record['country']['iso_code']);
$output[$i]['geo']['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown');
}
else{
$output[$i]['geo']['isoCode'] = '--';
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');
}
} catch (\Exception $e) {
$output[$i]['geo']['isoCode'] = '--';
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');

View file

@ -98,11 +98,12 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo
try {
$app->run($request, $response);
} catch (\Throwable $th) {
Console::error('[Error] Type: '.get_class($th));
Console::error('[Error] Message: '.$th->getMessage());
Console::error('[Error] File: '.$th->getFile());
Console::error('[Error] Line: '.$th->getLine());
if(App::isDevelopment()) {
var_dump(get_class($th));
var_dump($th->getMessage());
var_dump($th->getFile());
var_dump($th->getLine());
$swooleResponse->end('error: '.$th->getMessage());
}

View file

@ -25,7 +25,7 @@ use Utopia\View;
use Utopia\Config\Config;
use Utopia\Locale\Locale;
use Utopia\Registry\Registry;
use GeoIp2\Database\Reader;
use MaxMind\Db\Reader;
use PHPMailer\PHPMailer\PHPMailer;
use PDO as PDONative;
@ -233,6 +233,7 @@ Locale::setLanguage('cz', include __DIR__.'/config/locale/translations/cz.php');
Locale::setLanguage('de', include __DIR__.'/config/locale/translations/de.php');
Locale::setLanguage('en', include __DIR__.'/config/locale/translations/en.php');
Locale::setLanguage('es', include __DIR__.'/config/locale/translations/es.php');
Locale::setLanguage('fa', include __DIR__.'/config/locale/translations/fa.php');
Locale::setLanguage('fi', include __DIR__.'/config/locale/translations/fi.php');
Locale::setLanguage('fo', include __DIR__.'/config/locale/translations/fo.php');
Locale::setLanguage('fr', include __DIR__.'/config/locale/translations/fr.php');

View file

@ -23,9 +23,6 @@ include __DIR__.'/controllers/general.php';
$preloader = new Preloader();
foreach ([
realpath(__DIR__ . '/../app/config'),
realpath(__DIR__ . '/../app/controllers'),
realpath(__DIR__ . '/../src'),
realpath(__DIR__ . '/../vendor/twig/twig'),
realpath(__DIR__ . '/../vendor/guzzlehttp/guzzle'),
realpath(__DIR__ . '/../vendor/domnikl'),

View file

@ -142,10 +142,14 @@ $cli
$stdout = '';
$stderr = '';
Console::log("Running \"docker-compose -f {$path}/docker-compose.yml up -d --remove-orphans\"");
$exit = Console::execute("docker-compose -f {$path}/docker-compose.yml up -d --remove-orphans", null, $stdout, $stderr);
if ($exit !== 0) {
Console::error("Failed to install Appwrite dockers");
Console::error($stderr);
exit($exit);
} else {
Console::success("Appwrite installed successfully");

View file

@ -8,13 +8,12 @@ use Appwrite\Database\Database;
use Appwrite\Database\Document;
use Appwrite\Database\Validator\Authorization;
$db = $register->get('db');
$callbacks = [
'0.4.0' => function() {
Console::log('I got nothing to do.');
},
'0.5.0' => function($project) use ($db, $projectDB, $requset) {
'0.5.0' => function($project) use ($register, $projectDB, $requset) {
$db = $register->get('db');
Console::log('Migrating project: '.$project->getId());

View file

@ -298,7 +298,7 @@
<span data-ls-bind="{{log.client.name}} {{log.client.version}} on {{log.model}} {{log.OS.name}} {{log.OS.version}}"></span>
</td>
<td data-title="Location: ">
<img onerror="this.onerror=null;this.src='/images/unknown.svg'" data-ls-attrs="src={{env.API}}/avatars/flags/{{log.geo.isoCode}}?width=80&height=80&project={{env.PROJECT}}" class="avatar xxs inline margin-end-small" style="margin-top: 10px;" />
<img onerror="this.onerror=null;this.src='/images/unknown.svg'" data-ls-attrs="src={{env.API}}/avatars/flags/{{log.geo.isoCode}}?width=80&height=80&project={{env.PROJECT}}" class="avatar xxs inline margin-end-small" />
<span data-ls-bind="{{log.geo.country}}"></span>
</td>
<td data-title="IP: "><span data-ls-bind="{{log.ip}}"></span></td>

View file

@ -47,8 +47,8 @@ $environments = $this->getParam('environments', []);
<span data-ls-bind="{{function.name}}"></span>
<div class="text-fade" data-ls-if="({{function.events.length}})" style="margin-top: 10px;"><span data-ls-bind="{{function.events.length}}"></span> events assigned</div>
<div class="text-fade" data-ls-if="(!{{function.events.length}})" style="margin-top: 10px;">&nbsp;</div>
<div class="text-fade" data-ls-if="({{function.events.length}})"><span data-ls-bind="{{function.events.length}}"></span> events assigned</div>
<div class="text-fade" data-ls-if="(!{{function.events.length}})">&nbsp;</div>
</li>
</ul>
</div>

View file

@ -135,7 +135,7 @@ $graph = $this->getParam('graph', false);
<span data-ls-bind="{{platform.name}}"></span>
</div>
<p class="margin-bottom-no" style="margin-top: 10px;"><small data-ls-bind="{{platform.hostname}}{{platform.key}}"></small></p>
<p class="margin-bottom-no"><small data-ls-bind="{{platform.hostname}}{{platform.key}}"></small></p>
<div class="phones-only-inline tablets-only-inline margin-top-tiny">
<button class="link" data-ls-ui-trigger="platform-update-{{platform.$id}}">Update</button>

View file

@ -270,9 +270,9 @@ services:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=rootsecretpassword
- MYSQL_DATABASE=appwrite
- MYSQL_USER=user
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=${_APP_DB_SCHEMA}
- MYSQL_USER=${_APP_DB_USER}
- MYSQL_PASSWORD=${_APP_DB_PASS}
command: 'mysqld --innodb-flush-method=fsync'
smtp:
@ -295,7 +295,7 @@ services:
- appwrite-redis:/data:rw
clamav:
image: appwrite/clamav:1.0.12
image: appwrite/clamav:1.2.0
container_name: appwrite-clamav
restart: unless-stopped
networks:

View file

@ -66,7 +66,7 @@ class CertificatesV1
}
if(!$domain->isKnown() || $domain->isTest()) {
throw new Exception('Unkown public suffix for domain');
throw new Exception('Unknown public suffix for domain');
}
if($validateTarget) {

View file

@ -26,6 +26,7 @@
"ext-yaml": "*",
"ext-dom": "*",
"ext-redis": "*",
"ext-swoole": "*",
"ext-pdo": "*",
"ext-openssl": "*",
"ext-zlib": "*",
@ -45,17 +46,15 @@
"utopia-php/domains": "1.1.*",
"resque/php-resque": "1.3.6",
"geoip2/geoip2": "2.10.0",
"piwik/device-detector": "3.13.0",
"dragonmantank/cron-expression": "3.0.1",
"domnikl/statsd": "3.0.*",
"influxdb/influxdb-php": "1.15.*",
"bacon/bacon-qr-code": "2.0.2",
"phpmailer/phpmailer": "6.1.7",
"adhocore/jwt": "1.1.0"
"chillerlan/php-qrcode": "^4.2"
},
"require-dev": {
"swoole/ide-helper": "4.5.4",
"swoole/ide-helper": "4.5.5",
"appwrite/sdk-generator": "master",
"phpunit/phpunit": "^9.3"
},
@ -74,4 +73,4 @@
"php": "7.4"
}
}
}
}

666
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -133,7 +133,7 @@ services:
- appwrite-redis:/data:rw
clamav:
image: appwrite/clamav:1.0.12
image: appwrite/clamav:1.2.0
container_name: appwrite-clamav
restart: unless-stopped
networks:

View file

@ -266,6 +266,9 @@ services:
- _APP_REDIS_PORT
- _APP_SMTP_HOST
- _APP_SMTP_PORT
- _APP_SMTP_SECURE
- _APP_SMTP_USERNAME
- _APP_SMTP_PASSWORD
appwrite-schedule:
entrypoint: schedule
@ -293,10 +296,10 @@ services:
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=rootsecretpassword
- MYSQL_DATABASE=appwrite
- MYSQL_USER=user
- MYSQL_PASSWORD=password
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=${_APP_DB_SCHEMA}
- MYSQL_USER=${_APP_DB_USER}
- MYSQL_PASSWORD=${_APP_DB_PASS}
command: 'mysqld --innodb-flush-method=fsync'
# command: mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0.bu && mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1.bu
@ -331,7 +334,7 @@ services:
- appwrite-redis:/data:rw
clamav:
image: appwrite/clamav:1.0.12
image: appwrite/clamav:1.2.0
container_name: appwrite-clamav
restart: unless-stopped
networks:

View file

@ -26,7 +26,7 @@ Maximum file size allowed for file upload. The default value is 100MB limitation
### _APP_STORAGE_ANTIVIRUS
This variable allows you to disable the internal anti-virus scans. By default, this value is set to 'enabled' to cancel the scans, set the value to 'disabled'. When disabled, it's recommended to turn off the ClamAV container for better resource usage.
This variable allows you to disable the internal anti-virus scans. This value is set to 'enabled' by default, to cancel the scans set the value to 'disabled'. When disabled, it's recommended to turn off the ClamAV container for better resource usage.
### _APP_CONSOLE_WHITELIST_EMAILS

View file

@ -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

View file

@ -320,7 +320,7 @@ services:
- appwrite-redis:/data:rw
clamav:
image: appwrite/clamav:1.0.12
image: appwrite/clamav:1.2.0
container_name: appwrite-clamav
restart: unless-stopped
networks:

View file

@ -0,0 +1,117 @@
<?php
namespace Appwrite\Tests;
use Appwrite\Network\Validator\CNAME;
use PHPUnit\Framework\TestCase;
class ExtensionsTest extends TestCase
{
public function setUp(): void
{
// Core
// ctype
// curl
// date
// fileinfo
// filter
// ftp
// hash
// iconv
// libxml
// mysqlnd
// pcre
// pdo_mysql
// pdo_sqlite
// Phar
// posix
// readline
// Reflection
// session
// SimpleXML
// sockets
// sodium
// SPL
// sqlite3
// standard
// tokenizer
// xml
// xmlreader
// xmlwriter
// zlib
}
public function tearDown(): void
{
}
public function testPHPRedis()
{
$this->assertEquals(true, extension_loaded('redis'));
}
public function testSwoole()
{
$this->assertEquals(true, extension_loaded('swoole'));
}
public function testYAML()
{
$this->assertEquals(true, extension_loaded('yaml'));
}
public function testOPCache()
{
$this->assertEquals(true, extension_loaded('Zend OPcache'));
}
public function testDOM()
{
$this->assertEquals(true, extension_loaded('dom'));
}
public function testPDO()
{
$this->assertEquals(true, extension_loaded('PDO'));
}
public function testImagick()
{
$this->assertEquals(true, extension_loaded('imagick'));
}
public function testJSON()
{
$this->assertEquals(true, extension_loaded('json'));
}
public function testCURL()
{
$this->assertEquals(true, extension_loaded('curl'));
}
public function testMBString()
{
$this->assertEquals(true, extension_loaded('mbstring'));
}
public function testOPENSSL()
{
$this->assertEquals(true, extension_loaded('openssl'));
}
public function testZLIB()
{
$this->assertEquals(true, extension_loaded('zlib'));
}
public function testSockets()
{
$this->assertEquals(true, extension_loaded('sockets'));
}
public function testMaxminddb()
{
$this->assertEquals(true, extension_loaded('maxminddb'));
}
}