Skip to content

Commit

Permalink
use new .env type and esc()
Browse files Browse the repository at this point in the history
  • Loading branch information
hostbrook committed Feb 28, 2024
1 parent b3c1372 commit b7c78fe
Show file tree
Hide file tree
Showing 17 changed files with 146 additions and 180 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ logs/*
!logs/.gitkeep

# Ignore file containing environment variables
App/configs/env.php
App/configs/.env
storage/*.key

# Ignore IDE specific files
.vscode/git
Expand Down
6 changes: 3 additions & 3 deletions App/Controllers/WebApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function actionPrivacyPolicy()
public function actionGoogleAccount($createAccount = false)
{
$params = array(
'client_id' => Config::get('google')['client_id'],
'client_secret' => Config::get('google')['client_secret'],
'redirect_uri' => Config::get('google')['redirect_uri'],
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
'redirect_uri' => env('GOOGLE_REDIRECT_URI'),
'grant_type' => 'authorization_code'
);

Expand Down
6 changes: 3 additions & 3 deletions App/Views/admin/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<nav class="uk-navbar uk-light" data-uk-navbar="mode:click; duration: 250">
<div class="uk-navbar-left">
<div class="uk-navbar-item uk-hidden@m">
<a class="uk-logo" title="Videna" href="<?= URL_ABS ?>"><img src="/img/videna-logo-white.png"
<a class="uk-logo" title="Videna" href="<?= env('APP_URL') ?>"><img src="/img/videna-logo-white.png"
alt="Videna"></a>
</div>
<ul class="uk-navbar-nav uk-visible@m">
Expand Down Expand Up @@ -86,14 +86,14 @@
<!-- LEFT BAR -->
<aside id="left-col" class="uk-light uk-visible@m">
<div class="left-logo uk-flex uk-flex-middle uk-flex-center">
<a class="uk-logo" title="Videna" href="<?= URL_ABS ?>"><img src="/img/videna-logo-white.png"
<a class="uk-logo" title="Videna" href="<?= env('APP_URL') ?>"><img src="/img/videna-logo-white.png"
alt="Videna"></a>
</div>
<div class="left-content-box content-box-dark">
<img src="https://www.gravatar.com/avatar/<?= md5($user->email) ?>" alt=""
class="uk-border-circle profile-img">
<h4 class="uk-text-center uk-margin-remove-vertical text-light">
<?= $user->name ?>
<?= esc($user->name) ?>
</h4>

<div class="uk-position-relative uk-text-center uk-display-block">
Expand Down
6 changes: 3 additions & 3 deletions App/Views/error.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include PATH_VIEWS . 'inc/header.php' ?>
<?php include 'inc/header.php' ?>

<!-- CONTENT -->
<div class="uk-container uk-container-small uk-flex-auto uk-text-center" data-uk-scrollspy="target: > .animate; cls: uk-animation-slide-bottom-small uk-invisible; delay: 300">
Expand All @@ -7,9 +7,9 @@
<p class="lead"><?= $view->description ?></p>
</div>
<div class="uk-margin-medium-top animate uk-invisible" data-uk-margin data-uk-scrollspy-class="uk-animation-fade uk-invisible">
<a class="uk-button uk-button-default uk-button-large uk-width-2-3 uk-width-auto@s" href="<?= URL_ABS ?>" title="Back to home"> <?= $_['home'] ?></a>
<a class="uk-button uk-button-default uk-button-large uk-width-2-3 uk-width-auto@s" href="<?= env('APP_URL') ?>" title="Back to home"> <?= $_['home'] ?></a>
</div>
</div>
<!-- /CONTENT -->

<?php include PATH_VIEWS . 'inc/footer.php' ?>
<?php include 'inc/footer.php' ?>
6 changes: 3 additions & 3 deletions App/Views/inc/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<div class="uk-navbar-left">
<div class="uk-navbar-item">
<a class="uk-logo" title="Videna" href="<?= URL_ABS ?>"><img src="/img/videna-logo-white.png" alt="Videna"></a>
<a class="uk-logo" title="Videna" href="<?= env('APP_URL') ?>"><img src="/img/videna-logo-white.png" alt="Videna"></a>
</div>
</div>

Expand All @@ -57,7 +57,7 @@
<li><a href="https://github.com/hostbrook/videna/wiki/"><?= $_['docs'] ?></a></li>
<?php if ($user->account > USR_UNREG) : ?>
<li>
<a href="#" data-uk-icon="chevron-down"><span class="uk-icon" data-uk-icon="icon: user"></span> <?= $user->name ?></a>
<a href="#" data-uk-icon="chevron-down"><span class="uk-icon" data-uk-icon="icon: user"></span> <?= esc($user->name) ?></a>
<div class="uk-navbar-dropdown">
<ul class="uk-nav uk-navbar-dropdown-nav">
<li><a href="/dashboard"><span uk-icon="icon: nut"></span> <?= $_['dashboard'] ?></a></li>
Expand Down Expand Up @@ -91,7 +91,7 @@
<button class="uk-offcanvas-close uk-close uk-icon" type="button" data-uk-close></button>
<h3>Videna</h3>
<ul class="uk-nav uk-nav-default">
<li><a href="<?= URL_ABS ?>"><span class="uk-margin-small-right uk-icon" data-uk-icon="icon: home"></span> <?= $_['home'] ?></a></li>
<li><a href="<?= env('APP_URL') ?>"><span class="uk-margin-small-right uk-icon" data-uk-icon="icon: home"></span> <?= $_['home'] ?></a></li>
<li><a href="https://github.com/hostbrook/videna"><span class="uk-margin-small-right uk-icon" data-uk-icon="icon: github"></span> GitHub</a></li>
<li><a href="https://github.com/hostbrook/videna/wiki/"><span class="uk-margin-small-right uk-icon" data-uk-icon="icon: file-text"></span> <?= $_['docs'] ?></a></li>

Expand Down
4 changes: 2 additions & 2 deletions App/Views/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include PATH_VIEWS . 'inc/header.php' ?>
<?php include 'inc/header.php' ?>

<!-- CONTENT -->
<div class="uk-container uk-container-small uk-flex-auto uk-text-center" data-uk-scrollspy="target: > .animate; cls: uk-animation-slide-bottom-small uk-invisible; delay: 300">
Expand All @@ -13,4 +13,4 @@
</div>
<!-- /CONTENT -->

<?php include PATH_VIEWS . 'inc/footer.php' ?>
<?php include 'inc/footer.php' ?>
10 changes: 5 additions & 5 deletions App/Views/login.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php include PATH_VIEWS . 'inc/header.php' ?>
<?php include 'inc/header.php' ?>

<!-- CONTENT -->
<div class="uk-container uk-container-small uk-flex-auto uk-text-center" data-uk-scrollspy="target: > .animate; cls: uk-animation-slide-bottom-small uk-invisible; delay: 300">
Expand Down Expand Up @@ -37,11 +37,11 @@ class="fb-login-button"
<script>
const config = {
"google": {
"client_id": "<?= $config['google']['client_id'] ?>"
"client_id": "<?= env('GOOGLE_CLIENT_ID') ?>"
},
"facebook": {
"appId": "<?= $config['facebook']['appId'] ?>",
"appVersion": "<?= $config['facebook']['appVersion'] ?>",
"appId": "<?= env('FACEBOOK_APP_ID') ?>",
"appVersion": "<?= env('FACEBOOK_APP_VERSION') ?>",
},
"lang": {
"redirection_to_dashboard": "<?= $_['redirection to dashboard'] ?>",
Expand All @@ -52,4 +52,4 @@ class="fb-login-button"
</script>
<script src="/js/videna-social.js" ></script> <!-- ?ver=<?= rand(1, 999999) ?> -->

<?php include PATH_VIEWS . 'inc/footer.php' ?>
<?php include 'inc/footer.php' ?>
24 changes: 12 additions & 12 deletions App/configs/app.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
*/


// PHP config settings:
ini_set('error_reporting', E_ALL);
ini_set('session.cookie_lifetime', 0);
ini_set('session.use_strict_mode', 1);
ini_set('display_errors', 1);


// Server settings
date_default_timezone_set('America/Edmonton');


/*-------------------------------------------------------
Section: Custom Application constants
-------------------------------------------------------*/
Expand Down Expand Up @@ -38,16 +49,5 @@
Section: Custom Application settings
-------------------------------------------------------*/

// Google Identity Service (GIS) settings
'google' => [
'client_id' => '478936046715-jtejjvl2nefkng5l4ja97qruhm7sfunq.apps.googleusercontent.com',
'client_secret' => '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',
'redirect_uri' => 'https://videna.hostbrook.com'
],

// Facebook API settings
'facebook' => [
'appId' => '1282007215635462',
'appVersion' => 'v15.0'
],

);
50 changes: 0 additions & 50 deletions App/configs/env.localhost.example.php

This file was deleted.

50 changes: 0 additions & 50 deletions App/configs/env.production.example.php

This file was deleted.

42 changes: 42 additions & 0 deletions App/configs/localhost.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Application settings
APP_DEBUG=true
APP_URL='https://videna'

# Database setting
DB_NAME='videna'
DB_USER='root'
DB_PASSWORD='root'
DB_HOST='localhost'

# PHPMailer server settings
# Enable SMTP debugging
# 0 = off (for production use)
# 1 = client messages
# 2 = client and server messages
MAIL_SMTP_DEBUG=2
MAIL_HOST="sandbox.smtp.mailtrap.io"
MAIL_PORT=2525
MAIL_USERNAME='{username}'
MAIL_PASSWORD='{secret_password}'
MAIL_ENCRYPTION='tls'
MAIL_SMTP_AUTH=true
MAIL_FROM_ADDRESS='email@domain.com'
MAIL_FROM_NAME='videna'

# DKIM settings
# Keys are generated here: https://tools.socketlabs.com/dkim/generator
# Check DKIM here: https://dmarcly.com/tools/dkim-record-checker
# Check mail here: https://www.mail-tester.com/
DKIM_SELECTOR='selector123'
DKIM_DOMAIN='domain.com'
DKIM_IDENTITY='email@domain.com'
DKIM_PRIVATE_KEY="/storage/dkim/private_key.txt"

# Login via Google
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=

# Login via Facebook
FACEBOOK_APP_ID=
FACEBOOK_APP_VERSION=
35 changes: 7 additions & 28 deletions App/configs/mail.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,22 @@
*/


/*-------------------------------------------------------
Section: Default mail settings
-------------------------------------------------------*/

define('DEF_EMAIL_FROM', 'mail@domain.com');
define('DEF_NAME_FROM', 'Name Lastname');


/*-------------------------------------------------------
Section: PHPMailer properties
-------------------------------------------------------*/
return array(

//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
'SMTPDebug' => 0,

// Mail server settings
'Host' => 'domain.com',
'Port' => 587,
'SMTPAuth' => true,
'Username' => DEF_EMAIL_FROM,
'Password' => '',
'SMTPSecure' => 'SSL',
'CharSet' => 'UTF-8',
'Encoding' => 'base64',

// DKIM settings
// DKIM settings (overrided in .env)
// Keys are generated here: https://tools.socketlabs.com/dkim/generator
// Check DKIM here: https://dmarcly.com/tools/dkim-record-checker
// Check mail here: https://www.mail-tester.com/
'DKIM_domain' => 'domain.com',
'DKIM_selector' => 'selector',
'DKIM_identity' => DEF_EMAIL_FROM,
//'DKIM_private' => 'path/to/your/private.key',
'DKIM_private_string' => '-----BEGIN RSA PRIVATE KEY-----
/*
'DKIM_private_string' =>
'-----BEGIN RSA PRIVATE KEY-----
... s o m e p r i v a t e k e y ...
-----END RSA PRIVATE KEY-----'

*/
);
Loading

0 comments on commit b7c78fe

Please sign in to comment.