1
0
Fork 0
mirror of synced 2024-06-29 03:30:34 +12:00

Merge branch 'master' of github.com:appwrite/appwrite

This commit is contained in:
Eldad Fux 2020-06-19 21:55:14 +03:00
commit 7495097390
8 changed files with 32 additions and 31 deletions

View file

@ -83,7 +83,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
* As recommended at:
* @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
*/
if ($request->getServer('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
if ($utopia->getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
if(Config::getParam('protocol') !== 'https') {
return $response->redirect('https://' . Config::getParam('domain').$request->getServer('REQUEST_URI'));
}
@ -292,7 +292,7 @@ $utopia->error(function ($error /* @var $error Exception */) use ($request, $res
$_SERVER = []; // Reset before reporting to error log to avoid keys being compromised
$output = ((App::ENV_TYPE_DEVELOPMENT == $env)) ? [
$output = ((App::MODE_TYPE_DEVELOPMENT == $env)) ? [
'message' => $error->getMessage(),
'code' => $error->getCode(),
'file' => $error->getFile(),

View file

@ -26,7 +26,7 @@ use GeoIp2\Database\Reader;
include_once __DIR__ . '/../shared/api.php';
$isDev = (App::ENV_TYPE_PRODUCTION !== $utopia->getEnv());
$isDev = (App::MODE_TYPE_PRODUCTION !== $utopia->getMode());
$utopia->post('/v1/database/collections')
->desc('Create Collection')

View file

@ -26,7 +26,7 @@ $utopia->get('/v1/locale')
$countries = Locale::getText('countries');
$continents = Locale::getText('continents');
if (App::ENV_TYPE_PRODUCTION !== $utopia->getEnv()) {
if (App::MODE_TYPE_PRODUCTION !== $utopia->getMode()) {
$ip = '79.177.241.94';
}

View file

@ -28,12 +28,12 @@ $layout
->setParam('class', 'unknown')
->setParam('icon', '/images/favicon.png')
->setParam('roles', $roles)
->setParam('env', $utopia->getEnv())
->setParam('env', $utopia->getMode())
;
$utopia->init(function () use ($utopia, $response, $request, $layout) {
$time = (60 * 60 * 24 * 45); // 45 days cache
$isDev = (\Utopia\App::ENV_TYPE_DEVELOPMENT == Config::getParam('env'));
$isDev = (\Utopia\App::MODE_TYPE_DEVELOPMENT == Config::getParam('env'));
$response
->addHeader('Cache-Control', 'public, max-age='.$time)

View file

@ -50,6 +50,9 @@ const APP_SOCIAL_DEV = 'https://dev.to/appwrite';
$register = new Registry();
$request = new Request();
$response = new Response();
$utopia = new App('Asia/Tel_Aviv');
$utopia->setMode($utopia->getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION));
/*
* ENV vars
@ -60,7 +63,7 @@ Config::load('platforms', __DIR__.'/../app/config/platforms.php');
Config::load('locales', __DIR__.'/../app/config/locales.php');
Config::load('collections', __DIR__.'/../app/config/collections.php');
Config::setParam('env', $request->getServer('_APP_ENV', App::ENV_TYPE_PRODUCTION));
Config::setParam('env', $utopia->getMode());
Config::setParam('domain', $request->getServer('HTTP_HOST', ''));
Config::setParam('domainVerification', false);
Config::setParam('version', $request->getServer('_APP_VERSION', 'UNKNOWN'));
@ -68,8 +71,6 @@ Config::setParam('protocol', $request->getServer('HTTP_X_FORWARDED_PROTO', $requ
Config::setParam('port', (string) parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_PORT));
Config::setParam('hostname', parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', null), PHP_URL_HOST));
$utopia = new App('Asia/Tel_Aviv', Config::getParam('env'));
Resque::setBackend($request->getServer('_APP_REDIS_HOST', '')
.':'.$request->getServer('_APP_REDIS_PORT', ''));
@ -165,7 +166,7 @@ $register->set('smtp', function () use ($request) {
/*
* Localization
*/
$locale = $request->getParam('locale', $request->getHeader('X-Appwrite-Locale', null));
$locale = $request->getParam('locale', $request->getHeader('X-Appwrite-Locale', ''));
Locale::$exceptions = false;
@ -242,7 +243,7 @@ $consoleDB->setNamespace('app_console'); // Should be replaced with param if we
$consoleDB->setMocks(Config::getParam('collections', []));
Authorization::disable();
$project = $consoleDB->getDocument($request->getParam('project', $request->getHeader('X-Appwrite-Project', null)));
$project = $consoleDB->getDocument($request->getParam('project', $request->getHeader('X-Appwrite-Project', '')));
Authorization::enable();
@ -266,7 +267,7 @@ $response->addHeader('X-Debug-Fallback', 'false');
if(empty($session['id']) && empty($session['secret'])) {
$response->addHeader('X-Debug-Fallback', 'true');
$fallback = $request->getHeader('X-Fallback-Cookies', null);
$fallback = $request->getHeader('X-Fallback-Cookies', '');
$fallback = json_decode($fallback, true);
$session = Auth::decodeSession(((isset($fallback[Auth::$cookieName])) ? $fallback[Auth::$cookieName] : ''));
}

View file

@ -105,7 +105,7 @@ class CertificatesV1
throw new Exception('Renew isn\'t required');
}
$staging = (Config::getParam('env') === App::ENV_TYPE_PRODUCTION) ? '' : ' --dry-run';
$staging = (Config::getParam('env') === App::MODE_TYPE_PRODUCTION) ? '' : ' --dry-run';
$response = shell_exec("certbot certonly --webroot --noninteractive --agree-tos{$staging} --email security@appwrite.io \
-w ".APP_STORAGE_CERTIFICATES." \

View file

@ -32,11 +32,11 @@
"appwrite/php-clamav": "1.0.*",
"utopia-php/framework": "0.2.*",
"utopia-php/framework": "0.3.4",
"utopia-php/abuse": "0.2.*",
"utopia-php/audit": "0.3.*",
"utopia-php/cache": "0.2.*",
"utopia-php/cli": "0.5.*",
"utopia-php/cli": "0.6.1",
"utopia-php/config": "0.2.*",
"utopia-php/locale": "0.2.*",
"utopia-php/registry": "0.2.*",

32
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e93c84ab77f0085004222c942dcba6f4",
"content-hash": "b40a5280315184407b21232e6c607b85",
"packages": [
{
"name": "appwrite/php-clamav",
@ -1452,21 +1452,21 @@
},
{
"name": "utopia-php/cli",
"version": "0.5.0",
"version": "0.6.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/cli.git",
"reference": "c66255fed87f00c5a8f7cc0c482cdb082260cd32"
"reference": "0e88da425122f81020e90d575cbe80232f364b68"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/cli/zipball/c66255fed87f00c5a8f7cc0c482cdb082260cd32",
"reference": "c66255fed87f00c5a8f7cc0c482cdb082260cd32",
"url": "https://api.github.com/repos/utopia-php/cli/zipball/0e88da425122f81020e90d575cbe80232f364b68",
"reference": "0e88da425122f81020e90d575cbe80232f364b68",
"shasum": ""
},
"require": {
"php": ">=7.1",
"utopia-php/framework": "0.2.*"
"utopia-php/framework": "0.*.*"
},
"require-dev": {
"phpunit/phpunit": "^7.0"
@ -1496,7 +1496,7 @@
"upf",
"utopia"
],
"time": "2020-05-05T09:02:10+00:00"
"time": "2020-06-18T23:00:19+00:00"
},
{
"name": "utopia-php/config",
@ -1596,16 +1596,16 @@
},
{
"name": "utopia-php/framework",
"version": "0.2.0",
"version": "0.3.3",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/framework.git",
"reference": "e3d88b794badbd5ededcf62d708b31009111f860"
"reference": "dae7464b257663cd250e58244b21781a996134c2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/e3d88b794badbd5ededcf62d708b31009111f860",
"reference": "e3d88b794badbd5ededcf62d708b31009111f860",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/dae7464b257663cd250e58244b21781a996134c2",
"reference": "dae7464b257663cd250e58244b21781a996134c2",
"shasum": ""
},
"require": {
@ -1636,7 +1636,7 @@
"php",
"upf"
],
"time": "2020-03-08T15:42:21+00:00"
"time": "2020-06-18T23:28:10+00:00"
},
{
"name": "utopia-php/locale",
@ -2141,12 +2141,12 @@
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e"
"reference": "5892a510fe31de9c4200e6f9ae30e91dc5cd5a41"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e",
"reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/5892a510fe31de9c4200e6f9ae30e91dc5cd5a41",
"reference": "5892a510fe31de9c4200e6f9ae30e91dc5cd5a41",
"shasum": ""
},
"require": {
@ -2186,7 +2186,7 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2020-02-22T12:28:44+00:00"
"time": "2020-06-18T20:57:11+00:00"
},
{
"name": "phpdocumentor/type-resolver",