From c206934099895568c722fa96949c293f83412368 Mon Sep 17 00:00:00 2001 From: Aldarien Date: Wed, 22 Apr 2020 21:39:15 -0400 Subject: [PATCH] Cambio para independizar de servidor --- bootstrap/app.php | 6 +++--- bootstrap/common/config.php | 3 ++- bootstrap/web/config.php | 7 +++---- bootstrap/web/setup.php | 8 +++++++- common/Controller/Web/Admin/Clave.php | 5 +---- common/Controller/Web/Admin/Login.php | 5 +---- common/Controller/Web/Contacto.php | 13 ++++++++++--- resources/views/admin/layout/footer.blade.php | 4 ++-- resources/views/admin/layout/menu.blade.php | 6 +++--- 9 files changed, 32 insertions(+), 25 deletions(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index 4a84fe0..28adaec 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -3,6 +3,9 @@ use DI\Bridge\Slim\Bridge; include_once 'composer.php'; +$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__)); +$dotenv->load(); + $container_builder = new DI\ContainerBuilder(); $folders = [ @@ -42,7 +45,4 @@ foreach ($folders as $folder) { } } -$dotenv = Dotenv\Dotenv::createImmutable($container->get('folders.base')); -$dotenv->load(); - include_once implode(DIRECTORY_SEPARATOR, [$app->getContainer()->get('folders.routes'), 'router.php']); diff --git a/bootstrap/common/config.php b/bootstrap/common/config.php index 3733c15..78301bc 100644 --- a/bootstrap/common/config.php +++ b/bootstrap/common/config.php @@ -9,5 +9,6 @@ return [ '{folders.resources}', 'routes' ])), - 'urls.base' => '/provm/raby' + 'base_url' => getenv('BASE_URL'), + 'urls.base' => getenv('URLS_BASE') ]; diff --git a/bootstrap/web/config.php b/bootstrap/web/config.php index 4084fa6..d014272 100644 --- a/bootstrap/web/config.php +++ b/bootstrap/web/config.php @@ -77,10 +77,9 @@ return [ 'email.recepcion' => 'recepcion@notariaraby.cl', 'email.administrativo' => 'vwielandt@notariaraby.cl', 'email' => [ - 'host' => 'smtp.notariaraby.cl', - 'username' => '', - 'password' => '', - 'secure' => 'ssl' + 'host' => 'mail.notariaraby.cl', + 'username' => 'contacto@notariaraby.cl', + 'password' => 'ntrco2020' ], 'scripts' => [ 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js', diff --git a/bootstrap/web/setup.php b/bootstrap/web/setup.php index 799af8c..5776ba5 100644 --- a/bootstrap/web/setup.php +++ b/bootstrap/web/setup.php @@ -11,7 +11,7 @@ return [ null, [ 'urls' => (object) [ - 'base' => $container->get('urls.base'), + 'base' => $container->get('base_url'), 'assets' => (object) [ 'images' => $container->get('urls.images'), 'styles' => $container->get('urls.styles'), @@ -60,5 +60,11 @@ return [ Nette\Mail\SmtpMailer::class => function(Container $c) { return new Nette\Mail\SmtpMailer($c->get('email')); }, + Nette\Mail\FallbackMailer::class => function(Container $c) { + return new Nette\Mail\FallbackMailer([ + $c->get(Nette\Mail\SmtpMailer::class), + $c->get(Nette\Mail\SendmailMailer::class) + ]); + }, Nette\Mail\Message::class => DI\create() ]; diff --git a/common/Controller/Web/Admin/Clave.php b/common/Controller/Web/Admin/Clave.php index 8abff9a..3ad4923 100644 --- a/common/Controller/Web/Admin/Clave.php +++ b/common/Controller/Web/Admin/Clave.php @@ -35,10 +35,7 @@ class Clave { ]); file_put_contents($filename, implode(PHP_EOL, $vars)); return $response - ->withHeader('Location', implode('/', [ - $container->get('urls.base'), - 'admin' - ])) + ->withHeader('Location', $container->get('urls.admin')) ->withStatus(301); } } diff --git a/common/Controller/Web/Admin/Login.php b/common/Controller/Web/Admin/Login.php index 1b15142..03b5f0d 100644 --- a/common/Controller/Web/Admin/Login.php +++ b/common/Controller/Web/Admin/Login.php @@ -14,10 +14,7 @@ class Login { public function do_login(Request $request, Response $response, Service $login, Container $container): Response { $login->login($request); return $response - ->withHeader('Location', implode('/', [ - $container->get('urls.base'), - 'admin' - ])) + ->withHeader('Location', $container->get('urls.admin')) ->withStatus(302); } public function logout(Request $request, Response $response, Service $login, Container $container): Response { diff --git a/common/Controller/Web/Contacto.php b/common/Controller/Web/Contacto.php index 7bec709..80ca4d1 100644 --- a/common/Controller/Web/Contacto.php +++ b/common/Controller/Web/Contacto.php @@ -5,7 +5,7 @@ use Psr\Container\ContainerInterface as Container; use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ResponseInterface as Response; use Slim\Views\Blade as View; -use Nette\Mail\SendmailMailer as Mailer; +use Nette\Mail\FallbackMailer as Mailer; use Nette\Mail\Message; class Contacto { @@ -24,17 +24,24 @@ class Contacto { $subject = 'Contacto Web - ' . $post['nombre']; $message = $container->make(Message::class) - ->setFrom($post['email'], $post['nombre']) + ->setFrom($container->get('email')['username']) ->addTo($container->get('email.recepcion')) ->addCc($container->get('email.administrativo')) ->setSubject($subject) ->setBody($body) ->setHTMLBody(nl2br($body)); - //$mailer->send($message); + $mailer->send($message); + $message = $container->make(Message::class) + ->setFrom($container->get('email')['username']) + ->addTo($post['email'], $post['nombre']) + ->setSubject($subject) + ->setBody('Su correo a NotarĂ­a Patricio Raby ha sido recibido.'); + $mailer->send($message); $output = [ 'informacion' => $post, 'mail' => [ + 'from' => $post['email'], 'to' => $container->get('email.recepcion'), 'cc' => $container->get('email.administrativo'), 'asunto' => $subject, diff --git a/resources/views/admin/layout/footer.blade.php b/resources/views/admin/layout/footer.blade.php index 212da97..12fb484 100644 --- a/resources/views/admin/layout/footer.blade.php +++ b/resources/views/admin/layout/footer.blade.php @@ -4,8 +4,8 @@
diff --git a/resources/views/admin/layout/menu.blade.php b/resources/views/admin/layout/menu.blade.php index 44fb11b..5bb61af 100644 --- a/resources/views/admin/layout/menu.blade.php +++ b/resources/views/admin/layout/menu.blade.php @@ -1,7 +1,7 @@