From 6ab90cd01e3397f444d40ca5c4adaba42d044325 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 16 Dec 2019 21:35:33 +0200 Subject: [PATCH] Fixed paths --- app/app.php | 5 +++-- app/controllers/api/account.php | 2 +- app/controllers/api/auth.php | 8 +++---- app/controllers/api/avatars.php | 8 +++---- app/controllers/api/database.php | 2 +- app/controllers/api/keys.php | 2 +- app/controllers/api/locale.php | 14 ++++++------ app/controllers/api/platforms.php | 2 +- app/controllers/api/projects.php | 2 +- app/controllers/api/storage.php | 2 +- app/controllers/api/tasks.php | 2 +- app/controllers/api/teams.php | 6 +++--- app/controllers/api/users.php | 2 +- app/controllers/api/webhooks.php | 2 +- app/controllers/web/console.php | 36 +++++++++++++++---------------- app/controllers/web/home.php | 20 ++++++++--------- public/index.php | 4 ++-- 17 files changed, 60 insertions(+), 59 deletions(-) diff --git a/app/app.php b/app/app.php index d9acd72f7..f48a33fb0 100644 --- a/app/app.php +++ b/app/app.php @@ -436,7 +436,7 @@ $utopia->get('/v1/open-api-2.json') if (!$tests && !$service['sdk']) { continue; } - + /** @noinspection PhpIncludeInspection */ include_once $service['controller']; } @@ -722,7 +722,8 @@ $utopia->get('/v1/open-api-2.json') ksort($output['paths']); - $response->json($output); + $response + ->json($output); } ); diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 1bf8a68e3..b7b06638a 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -13,7 +13,7 @@ use Database\Validator\Authorization; use DeviceDetector\DeviceDetector; use GeoIp2\Database\Reader; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $utopia->get('/v1/account') ->desc('Get Account') diff --git a/app/controllers/api/auth.php b/app/controllers/api/auth.php index 0ebe40354..bc3b953d0 100644 --- a/app/controllers/api/auth.php +++ b/app/controllers/api/auth.php @@ -18,7 +18,7 @@ use Database\Validator\UID; use Template\Template; use OpenSSL\OpenSSL; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $utopia->post('/v1/auth/register') ->desc('Register') @@ -137,7 +137,7 @@ $utopia->post('/v1/auth/register') $confirm['query'] = Template::mergeQuery(((isset($confirm['query'])) ? $confirm['query'] : ''), ['userId' => $user->getUid(), 'token' => $confirmSecret]); $confirm = Template::unParseURL($confirm); - $body = new Template(__DIR__.'/../config/locales/templates/'.Locale::getText('auth.emails.confirm.body')); + $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('auth.emails.confirm.body')); $body ->setParam('{{direction}}', Locale::getText('settings.direction')) ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) @@ -275,7 +275,7 @@ $utopia->post('/v1/auth/register/confirm/resend') $confirm['query'] = Template::mergeQuery(((isset($confirm['query'])) ? $confirm['query'] : ''), ['userId' => $user->getUid(), 'token' => $secret]); $confirm = Template::unParseURL($confirm); - $body = new Template(__DIR__.'/../config/locales/templates/'.Locale::getText('auth.emails.confirm.body')); + $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('auth.emails.confirm.body')); $body ->setParam('{{direction}}', Locale::getText('settings.direction')) ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) @@ -731,7 +731,7 @@ $utopia->post('/v1/auth/recovery') $reset['query'] = Template::mergeQuery(((isset($reset['query'])) ? $reset['query'] : ''), ['userId' => $profile->getUid(), 'token' => $secret]); $reset = Template::unParseURL($reset); - $body = new Template(__DIR__.'/../config/locales/templates/'.Locale::getText('auth.emails.recovery.body')); + $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('auth.emails.recovery.body')); $body ->setParam('{{direction}}', Locale::getText('settings.direction')) ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index 3c5b99c75..017fa8acb 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -15,12 +15,12 @@ use BaconQrCode\Renderer\Image\ImagickImageBackEnd; use BaconQrCode\Renderer\RendererStyle\RendererStyle; use BaconQrCode\Writer; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $types = [ - 'browsers' => include __DIR__.'/../config/avatars/browsers.php', - 'credit-cards' => include __DIR__.'/../config/avatars/credit-cards.php', - 'flags' => include __DIR__.'/../config/avatars/flags.php', + 'browsers' => include __DIR__.'/../../config/avatars/browsers.php', + 'credit-cards' => include __DIR__.'/../../config/avatars/credit-cards.php', + 'flags' => include __DIR__.'/../../config/avatars/flags.php', ]; $avatarCallback = function ($type, $code, $width, $height, $quality) use ($types, $response, $request) { diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 955026425..62f7ef5ff 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -19,7 +19,7 @@ use Database\Validator\Authorization; use Database\Exception\Authorization as AuthorizationException; use Database\Exception\Structure as StructureException; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $isDev = (App::ENV_TYPE_PRODUCTION !== $utopia->getEnv()); diff --git a/app/controllers/api/keys.php b/app/controllers/api/keys.php index 63d60d98d..177b767a4 100644 --- a/app/controllers/api/keys.php +++ b/app/controllers/api/keys.php @@ -11,7 +11,7 @@ use Database\Database; use Database\Document; use Database\Validator\UID; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $scopes = include __DIR__.'/../../../app/config/scopes.php'; diff --git a/app/controllers/api/locale.php b/app/controllers/api/locale.php index 0d6826569..b220e3219 100644 --- a/app/controllers/api/locale.php +++ b/app/controllers/api/locale.php @@ -6,7 +6,7 @@ use Utopia\App; use Utopia\Locale\Locale; use GeoIp2\Database\Reader; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $utopia->get('/v1/locale') ->desc('Get User Locale') @@ -16,9 +16,9 @@ $utopia->get('/v1/locale') ->label('sdk.description', '/docs/references/locale/get-locale.md') ->action( function () use ($response, $request, $utopia) { - $eu = include __DIR__.'/../config/eu.php'; - $currencies = include __DIR__.'/../config/currencies.php'; - $reader = new Reader(__DIR__.'/../db/GeoLite2/GeoLite2-Country.mmdb'); + $eu = include __DIR__.'/../../config/eu.php'; + $currencies = include __DIR__.'/../../config/currencies.php'; + $reader = new Reader(__DIR__.'/../../db/GeoLite2/GeoLite2-Country.mmdb'); $output = []; $ip = $request->getIP(); $time = (60 * 60 * 24 * 45); // 45 days cache @@ -90,7 +90,7 @@ $utopia->get('/v1/locale/countries/eu') ->action( function () use ($response) { $countries = Locale::getText('countries'); /* @var $countries array */ - $eu = include __DIR__.'/../config/eu.php'; + $eu = include __DIR__.'/../../config/eu.php'; $list = []; foreach ($eu as $code) { @@ -113,7 +113,7 @@ $utopia->get('/v1/locale/countries/phones') ->label('sdk.description', '/docs/references/locale/get-countries-phones.md') ->action( function () use ($response) { - $list = include __DIR__.'/../config/phones.php'; /* @var $list array */ + $list = include __DIR__.'/../../config/phones.php'; /* @var $list array */ $countries = Locale::getText('countries'); /* @var $countries array */ @@ -154,7 +154,7 @@ $utopia->get('/v1/locale/currencies') ->label('sdk.description', '/docs/references/locale/get-currencies.md') ->action( function () use ($response) { - $currencies = include __DIR__.'/../config/currencies.php'; + $currencies = include __DIR__.'/../../config/currencies.php'; $response->json($currencies); } diff --git a/app/controllers/api/platforms.php b/app/controllers/api/platforms.php index 771a94844..ec0b97883 100644 --- a/app/controllers/api/platforms.php +++ b/app/controllers/api/platforms.php @@ -11,7 +11,7 @@ use Database\Database; use Database\Document; use Database\Validator\UID; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $utopia->get('/v1/platforms') ->desc('List Platforms') diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index cbb4bda64..8c1c003b6 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -13,7 +13,7 @@ use Database\Document; use Database\Validator\UID; use OpenSSL\OpenSSL; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $utopia->get('/v1/projects') ->desc('List Projects') diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index cc88d0751..2eb2f4986 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -22,7 +22,7 @@ use Storage\Compression\Algorithms\GZIP; use Resize\Resize; use OpenSSL\OpenSSL; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; Storage::addDevice('local', new Local('app-'.$project->getUid())); diff --git a/app/controllers/api/tasks.php b/app/controllers/api/tasks.php index 5d135f607..c7ea8c19b 100644 --- a/app/controllers/api/tasks.php +++ b/app/controllers/api/tasks.php @@ -16,7 +16,7 @@ use Database\Validator\UID; use OpenSSL\OpenSSL; use Cron\CronExpression; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $utopia->get('/v1/tasks') ->desc('List Tasks') diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 0b6ad0cb6..0fee00552 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -18,7 +18,7 @@ use Database\Validator\Authorization; use Template\Template; use Auth\Auth; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $utopia->get('/v1/teams') ->desc('List Teams') @@ -358,7 +358,7 @@ $utopia->post('/v1/teams/:teamId/memberships') $redirect['query'] = Template::mergeQuery(((isset($redirect['query'])) ? $redirect['query'] : ''), ['inviteId' => $membership->getUid(), 'teamId' => $team->getUid(), 'userId' => $invitee->getUid(), 'secret' => $secret]); $redirect = Template::unParseURL($redirect); - $body = new Template(__DIR__.'/../config/locales/templates/'.Locale::getText('auth.emails.invitation.body')); + $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('auth.emails.invitation.body')); $body ->setParam('{{direction}}', Locale::getText('settings.direction')) ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) @@ -437,7 +437,7 @@ $utopia->post('/v1/teams/:teamId/memberships/:inviteId/resend') $redirect['query'] = Template::mergeQuery(((isset($redirect['query'])) ? $redirect['query'] : ''), ['inviteId' => $membership->getUid(), 'userId' => $membership->getAttribute('userId'), 'secret' => $secret]); $redirect = Template::unParseURL($redirect); - $body = new Template(__DIR__.'/../config/locales/templates/'.Locale::getText('auth.emails.invitation.body')); + $body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('auth.emails.invitation.body')); $body ->setParam('{{direction}}', Locale::getText('settings.direction')) ->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]'])) diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index f13ca28a7..ec9452b3a 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -16,7 +16,7 @@ use Database\Validator\UID; use DeviceDetector\DeviceDetector; use GeoIp2\Database\Reader; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $utopia->get('/v1/users') ->desc('List Users') diff --git a/app/controllers/api/webhooks.php b/app/controllers/api/webhooks.php index 4c1ec59a3..78362e1a2 100644 --- a/app/controllers/api/webhooks.php +++ b/app/controllers/api/webhooks.php @@ -13,7 +13,7 @@ use Database\Document; use Database\Validator\UID; use OpenSSL\OpenSSL; -include_once '../shared/api.php'; +include_once __DIR__ . '/../shared/api.php'; $utopia->get('/v1/webhooks') ->desc('List Webhooks') diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index b61bbdf84..8470e5ba7 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -1,6 +1,6 @@ init(function () use ($layout, $utopia) { }); $utopia->shutdown(function () use ($utopia, $response, $request, $layout, $version) { - $header = new View(__DIR__.'/../views/console/comps/header.phtml'); - $footer = new View(__DIR__.'/../views/console/comps/footer.phtml'); + $header = new View(__DIR__.'/../../views/console/comps/header.phtml'); + $footer = new View(__DIR__.'/../../views/console/comps/footer.phtml'); $footer ->setParam('home', $request->getServer('_APP_HOME', '')) @@ -44,7 +44,7 @@ $utopia->get('/error/:code') ->label('scope', 'home') ->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false) ->action(function ($code) use ($layout) { - $page = new View(__DIR__.'/../views/error.phtml'); + $page = new View(__DIR__.'/../../views/error.phtml'); $page ->setParam('code', $code) @@ -59,7 +59,7 @@ $utopia->get('/console') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout, $request) { - $page = new View(__DIR__.'/../views/console/index.phtml'); + $page = new View(__DIR__.'/../../views/console/index.phtml'); $page ->setParam('home', $request->getServer('_APP_HOME', '')) @@ -74,9 +74,9 @@ $utopia->get('/console/account') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/account/index.phtml'); + $page = new View(__DIR__.'/../../views/console/account/index.phtml'); - $cc = new View(__DIR__.'/../views/console/forms/credit-card.phtml'); + $cc = new View(__DIR__.'/../../views/console/forms/credit-card.phtml'); $page ->setParam('cc', $cc) @@ -92,7 +92,7 @@ $utopia->get('/console/notifications') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/v1/console/notifications/index.phtml'); + $page = new View(__DIR__.'/../../views/v1/console/notifications/index.phtml'); $layout ->setParam('title', APP_NAME.' - Notifications') @@ -104,7 +104,7 @@ $utopia->get('/console/home') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/home/index.phtml'); + $page = new View(__DIR__.'/../../views/console/home/index.phtml'); $layout ->setParam('title', APP_NAME.' - Console') @@ -116,7 +116,7 @@ $utopia->get('/console/settings') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/settings/index.phtml'); + $page = new View(__DIR__.'/../../views/console/settings/index.phtml'); $layout ->setParam('title', APP_NAME.' - Settings') @@ -128,7 +128,7 @@ $utopia->get('/console/webhooks') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/webhooks/index.phtml'); + $page = new View(__DIR__.'/../../views/console/webhooks/index.phtml'); $layout ->setParam('title', APP_NAME.' - Webhooks') @@ -141,7 +141,7 @@ $utopia->get('/console/keys') ->label('scope', 'console') ->action(function () use ($layout) { $scopes = include __DIR__.'/../../../app/config/scopes.php'; - $page = new View(__DIR__.'/../views/console/keys/index.phtml'); + $page = new View(__DIR__.'/../../views/console/keys/index.phtml'); $page->setParam('scopes', $scopes); @@ -155,7 +155,7 @@ $utopia->get('/console/tasks') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/tasks/index.phtml'); + $page = new View(__DIR__.'/../../views/console/tasks/index.phtml'); $layout ->setParam('title', APP_NAME.' - Tasks') @@ -167,7 +167,7 @@ $utopia->get('/console/database') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/console/database/index.phtml'); + $page = new View(__DIR__.'/../../views/console/database/index.phtml'); $layout ->setParam('title', APP_NAME.' - Database') @@ -186,7 +186,7 @@ $utopia->get('/console/database/collection') throw new Exception('Collection not found', 404); } - $page = new View(__DIR__.'/../views/console/database/collection.phtml'); + $page = new View(__DIR__.'/../../views/console/database/collection.phtml'); $page ->setParam('collection', $collection->getArrayCopy()) @@ -202,7 +202,7 @@ $utopia->get('/console/storage') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($request, $layout) { - $page = new View(__DIR__.'/../views/console/storage/index.phtml'); + $page = new View(__DIR__.'/../../views/console/storage/index.phtml'); $page ->setParam('home', $request->getServer('_APP_HOME', '')) @@ -218,7 +218,7 @@ $utopia->get('/console/users') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout, $providers) { - $page = new View(__DIR__.'/../views/console/users/index.phtml'); + $page = new View(__DIR__.'/../../views/console/users/index.phtml'); $page->setParam('providers', $providers); @@ -232,7 +232,7 @@ $utopia->get('/console/users/view') ->label('permission', 'public') ->label('scope', 'console') ->action(function () use ($layout, $providers) { - $page = new View(__DIR__.'/../views/console/users/view.phtml'); + $page = new View(__DIR__.'/../../views/console/users/view.phtml'); $layout ->setParam('title', APP_NAME.' - View User') diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index dc29fe142..45e564b80 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -1,13 +1,13 @@ setParam('version', $version) @@ -39,7 +39,7 @@ $utopia->get('/auth/signin') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/home/auth/signin.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/signin.phtml'); $layout ->setParam('title', 'Sign In - '.APP_NAME) @@ -51,7 +51,7 @@ $utopia->get('/auth/signup') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/home/auth/signup.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/signup.phtml'); $layout ->setParam('title', 'Sign Up - '.APP_NAME) @@ -63,7 +63,7 @@ $utopia->get('/auth/recovery') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($request, $layout) { - $page = new View(__DIR__.'/../views/home/auth/recovery.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/recovery.phtml'); $layout ->setParam('title', 'Password Recovery - '.APP_NAME) @@ -75,7 +75,7 @@ $utopia->get('/auth/confirm') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/home/auth/confirm.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/confirm.phtml'); $layout ->setParam('title', 'Account Confirmation - '.APP_NAME) @@ -87,7 +87,7 @@ $utopia->get('/auth/join') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/home/auth/join.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/join.phtml'); $layout ->setParam('title', 'Invitation - '.APP_NAME) @@ -99,7 +99,7 @@ $utopia->get('/auth/recovery/reset') ->label('permission', 'public') ->label('scope', 'home') ->action(function () use ($layout) { - $page = new View(__DIR__.'/../views/home/auth/recovery/reset.phtml'); + $page = new View(__DIR__.'/../../views/home/auth/recovery/reset.phtml'); $layout ->setParam('title', 'Password Reset - '.APP_NAME) @@ -112,7 +112,7 @@ $utopia->get('/error/:code') ->label('scope', 'home') ->param('code', null, new \Utopia\Validator\Numeric(), 'Valid status code number', false) ->action(function ($code) use ($layout) { - $page = new View(__DIR__.'/../views/error.phtml'); + $page = new View(__DIR__.'/../../views/error.phtml'); $page ->setParam('code', $code) diff --git a/public/index.php b/public/index.php index b37cdb732..46e8b5305 100644 --- a/public/index.php +++ b/public/index.php @@ -25,9 +25,9 @@ switch ($version) { // Switch between API version case 'v1': $service = $version . '/' . array_shift($path); include __DIR__ . '/../app/app.php'; - break; + break; case 'console': - default: + default: $service = $version . '/'; include __DIR__ . '/../app/app.php'; break;