summaryrefslogtreecommitdiff
path: root/public/app/config/app_constants.php
diff options
context:
space:
mode:
Diffstat (limited to 'public/app/config/app_constants.php')
-rw-r--r--public/app/config/app_constants.php207
1 files changed, 188 insertions, 19 deletions
diff --git a/public/app/config/app_constants.php b/public/app/config/app_constants.php
index cabd0b8..6974bd8 100644
--- a/public/app/config/app_constants.php
+++ b/public/app/config/app_constants.php
@@ -2,23 +2,39 @@
/** Custom Application Constants
* -----------------------------------------------------------------------------
*
- * Constants defined for your own application
+ * Constants defined for your current application:
*
- * Here you may fing
+ * 1. Main constants (Names, Labels, securoty defaults, etc)
*
- * It is rec
+ * 2. Credentials and sub-configuration of main services
+ *
+ * 3. Other custom constants
*
* -----------------------------------------------------------------------------
*/
-
-// read ini file if exist
-// --- -- -- - - -
+/** Preload environmental file
+ * Setting up main constants via en envoronment file is HIGHLY RECOMMENDED;
+ *
+ * read ini file if exist
+ */
if (file_exists("../core/auth/.env")) {
$env = parse_ini_file("../core/auth/.env");
}
+
+
+
+## -----------------------------------------------------------------------------
+##
+## - - - -- -- --- M A I N C O N S T A N T S --- -- -- - - -
+## Main constants (names, labels, default roles, security defaults, etc
+##
+## -----------------------------------------------------------------------------
+
+
+
/** Main default constants / strings / names / etc
* -----------------------------------------------------------------------------
*/
@@ -31,7 +47,6 @@ define('SITE_TITLE', 'schoolGov'); // Site Title (the end-users' title)
* -----------------------------------------------------------------------------
*
* CLASSPATHS : array of paths where classes are saved
- * Needed only when the custom autoloader is used
*
* NOTE:
* if the custom autoloader is used (instead of composer's)
@@ -42,34 +57,188 @@ define('SITE_TITLE', 'schoolGov'); // Site Title (the end-users' title)
*
* -----------------------------------------------------------------------------
*/
-
# define('CLASSPATHS', array(
-# '/../core/classes/',
-# '/app/controllers/',
-# '/app/models/',
-# '/../vendor/'
+# '/../core/classes/', // core classes
+# '/app/controllers/', // controller classes
+# '/app/models/', // model classes
+# '/app/extends/', // extending core classes
+# '/../vendor/' // vendor/dependency classes
# )
# );
-// if FileSession is selected, a path for session-files is needed
-#define('FILESESSION_PATH', '../storage/session');
+/** FileSession Path
+ * --- -- -- - - -
+ * if FileSession is selected, a path for session-files is needed
+ *
+ * TODO:
+ * also, the hybrid sessioning (in progress) will need this setting
+ *
+ * NOTE:
+ * DefaultSession is also file-based but to not need a file-path setting
+ * (php will handle any file-needed actions to the file-system)
+ */
+
+# define('FILESESSION_PATH', '../storage/session');
-
-// Session and cookie names
-// --- -- -- - - -
+/** Session and cookie names
+ * --- -- -- - - -
+ */
define('SESSION_NAME', 'offticket'); // cookie for session (office ticket)
define('CONNECTION_COOKIE', 'con'); // cookie for connection
define('MAX_SESSION_LIFE', 2*60*60); // maximum session lifetime (2 hours)
+/** SECURITY SETTINGS ///////////////////////////////////////////////////////////
+ * -----------------------------------------------------------------------------
+ *
+ * Cross Site Request Forgery
+ * ---
+ * Enables a CSRF cookie token to be set. When set to TRUE, token will be
+ * checked on a submitted form. If you are accepting user data, it is strongly
+ * recommended CSRF protection be enabled.
+ * -----------------------------------------------------------------------------
+ */
+
+define('CSRF_PROTECTION', false);
-// email setup
-// --- -- -- - - -
+define('CSRF_TOKEN_NAME', 'csrf_test_name'); // token name
+
+define('CSRF_COOKIE_NAME', 'csrf_cookie_name'); // cookie name
+
+define('CSRF_EXPIRE', 7200); // The number in seconds the token should expire.
+
+define('CSRF_REGENERATE', TRUE); // Regenerate token on every submission
+
+define('CSRF_EXCLUDE_URIS', array()); // Array of URIs which ignore CSRF checks
+
+
+
+
+## -----------------------------------------------------------------------------
+##
+## - - - -- -- --- C O N N E C T I O N C R E D E N T I A L S --- -- -- - - -
+##
+## -----------------------------------------------------------------------------
+
+
+
+/** SERVICE PARAMETRES
+ * -----------------------------------------------------------------------------
+ *
+ * Connection parametres and credentials for accssing services
+ * needed by the application; Such services may be..
+ *
+ * - RDBMS
+ * -- MySQL
+ * -- PotgresSQL
+ *
+ * - Caching services
+ * -- Redis
+ * -- MemCached
+ *
+ * Edit only the constants needed by the application;
+ * Comment those you do not need;
+ *
+ * /////////////////////////////////////////////////////////////////////////////
+ */
+
+/** DATABASE CONNECTION PARAMETRES
+ * -----------------------------------------------------------------------------
+ * Production and staging environments may use different databases.
+ *
+ * A safe practice is to keep credentials outside plain files like this one
+ * in environmental variable or other secret file etc.
+ *
+ * Uncomment/enable each group of definitions suits your case to define
+ * the credentials needed for accessing the database
+ */
+
+define('DB_NAME', $ini['DB_NAME']);
+
+define('DB_USER', $ini['DB_USER']);
+
+define('DB_PASS', $ini['DB_PASS']);
+
+/** NOTE:
+ * PDO_HOST can be a hostname/port combination -or- a unix socket
+ *
+ * ...examples:
+ * define('PDO_HOST', 'host=/localhost') ## hostname case
+ * define('PDO_HOST', 'host=/localhost;port=3456') ## hostname/port case
+ * define('PDO_HOST', 'unix_socket=/sql/ex123:europe:some-db'); ## unix socket
+ * define('PDO_HOST', 'unix_socket=/cloudsql/name-123456:europe-west4:name-db-eu');
+ */
+
+define('PDO_HOST', $ini['PDO_HOST']);
+
+define('DB_TIMEZONE', "SET time_zone = 'Europe/Athens'");
+
+
+
+
+/** CACHED SERVICES
+ *
+ * impemented services:
+ *
+ * - File Cache
+ * - Redis
+ * - Memcached
+ *
+ * NOTE:
+ * Both Redis and Memcached configurations are given as a template to work on;
+ * In most cases the default values should do the job -- of course you need to
+ * read the README file (check the project's root);
+ * As these caching services are not fully tested you may need to ochestrate
+ * the services in detail or edit the connection strings into the core classes
+ * (hosted under the '/core/classes/cacher' folder)
+ */
+
+ define('FILECACHE_PATH', APP_ROOT.'/../storage/cache/'); // if CACHE_DRIVER is set to 'FileCache'
+
+ define('MEDIA_STORAGE_ROOT', APP_ROOT.'/../storage/uploads/'); // Media files root directory
+
+
+
+ # define('MEMCAHCED_SERVER', '127.0.0.1'); // if CACHE_DRIVER is set to 'MemCached'
+
+/** REDIS SERVICE
+ * -----------------------------------------------------------------------------
+ * Most of the times Redis is running on 'localhost' (host = '127.0.0.1')
+ * When implemented via anom's docker-composer (redis via bridge) then you need
+ * do declare the hostname as 'redis'
+ */
+
+# define('REDIS_HOST', '127.0.0.1'); // if CACHE_DRIVER is set to 'RedisCache'
+# if (!defined('REDIS_HOST')) define('REDIS_HOST', 'redis');
+#
+# if (!defined('REDIS_PORT')) define('REDIS_PORT', 6379);
+#
+# if (!defined('REDIS_PASS')) define('REDIS_PASS', null);
+
+
+/** MEMCACHED
+ * -----------------------------------------------------------------------------
+ * Memcached looks very much like Redis (plus, both are serving from RAM)
+ * Usualy Memcashed is running localy so host is 'localhost' ('127.0.0.1')
+ * If you use the framework's docker-composer implementation then
+ * the hostname is 'anomemcached'
+ */
+
+# if (!defined('MEMCACHE_HOST')) define('MEMCACHE_HOST', 'anomemcached');
+
+
+
+
+
+
+/** email setup
+ * --- -- -- - - -
+ */
// SMTP
define('MAIL_MAILER', $env['MAIL_MAILER']);
define('MAIL_HOST', $env['MAIL_HOST']);