Compare commits

...

6 Commits
3.0 ... 3.0.5

Author SHA1 Message Date
508c25c111 more changes to support composer usage 2024-08-09 02:24:28 -04:00
6cf4594622 composer updates 2024-08-09 01:25:21 -04:00
0aa1b52a6d code fixes to support composer 2024-08-09 01:05:20 -04:00
d48e77e78d update install script to make docker smoother 2024-08-09 00:47:45 -04:00
21ba74ab0a composer updates 2024-08-09 00:42:03 -04:00
840563e25c fixes to support composer / packagist 2024-08-09 00:30:45 -04:00
140 changed files with 642 additions and 8884 deletions

5
.gitignore vendored
View File

@ -54,14 +54,11 @@ Temporary Items
# TheTempusProject Specific # TheTempusProject Specific
.htaccess .htaccess
composer.lock
app/config/* app/config/*
!app/config/constants.php !app/config/constants.php
app/install.json
app/config.default.json
uploads/images/* uploads/images/*
.env
logs/* logs/*
.vscode/ .vscode/
mail.log mail.log
vendor/canary/logs/* vendor/canary/logs/*
docker/.env

View File

@ -1,41 +1,39 @@
# The Tempus Project # The Tempus Project
need to make a vs battle for dnd. someone makes a truly broken character, we take the base character and hand it to two people and give them some time to figure out how they would break it
need to track points once a week
a huge table tracks points day to day then we add and erase the old data, or move it to historical...
## Rapid Prototyping Framework ## Rapid Prototyping Framework
### Developer(s): Joey Kimsey ## Developer(s): Joey Kimsey
The aim of this project is to provide a simple and stable platform from which to easily add functionality. The goal being the ability to quickly build and test new projects with a lightweight ecosystem to help. The aim of this project is to provide a simple and stable platform from which to easily add functionality. The goal being the ability to quickly build and test new projects with a lightweight ecosystem to help.
**Notice: This code is in _still_ not production ready. This framework is provided as is, use at your own risk.** **Notice: This code is in _still_ not production ready. This framework is provided as is, use at your own risk.**
I am working very hard to ensure the system is safe and reliable enough for me to endorse its widespread use. Unfortunately, it still needs a lot of QA and improvements. I am working very hard to ensure the system is safe and reliable enough for me to endorse its widespread use. Unfortunately, it still needs a lot of QA and improvements.
Currently I am in the process of testing all the systems in preparation for the first production ready release. The beta is still on-going. If you would like to participate or stay up to date with the latest, you can find more information at: https://TheTempusProject.com/beta
## Features ## Features
A User management system with groups, permissions, preferences, registration, and recovery. (All Controlled dynamically via our plugin interface) - A Plugin system that allows plug-and-play functionality
A Plugin system that allows plug-and-play functionality for a huge number of features. - A User management system
Compatibility with both Apache and NGINX. - groups
Built with Bootstrap with a focus on mobile compatibility. - permissions
Incredibly easy to set-up, deploy, and develop with. - preferences
- registration and recovery
(All Controlled dynamically via our plugin interface)
- Compatibility with both Apache and NGINX
- Built with Bootstrap with a focus on mobile compatibility
- Incredibly easy to set-up, deploy, and develop
## Installation ## Installation
Preferred method for installation is using composer. Preferred method for installation is using composer. Special attention has been given to use without composer and more information is included below.
### Manually
### Docker
### Composer ### Composer
The simplest method to start a new project is to use composer to create a new project and automatically clone all the necessary files:
```
composer create-project thetempusproject/thetempusproject test-app
```
1. Clone the directory to wherever you want to install the framework. 1. Clone the directory to wherever you want to install the framework.
2. Open your terminal to the directory you previously cloned the repository. 2. Open your terminal to the directory you previously cloned the repository.
3. Install using composer: 3. Install using composer:
@ -43,6 +41,12 @@ Preferred method for installation is using composer.
4. Open your browser and navigate to install.php (it will be in the root directory of your installation) 4. Open your browser and navigate to install.php (it will be in the root directory of your installation)
5. When prompted, complete the forms and complete the process. 5. When prompted, complete the forms and complete the process.
### Manually
### Docker
#### Apache #### Apache
#### NGINX #### NGINX

View File

@ -12,7 +12,7 @@
namespace TheTempusProject\Classes; namespace TheTempusProject\Classes;
use TheTempusProject\Houdini\Classes\Forms; use TheTempusProject\Houdini\Classes\Forms;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Bedrock\Classes\Config as BedrockConfig; use TheTempusProject\Bedrock\Classes\Config as BedrockConfig;

View File

@ -13,10 +13,12 @@ namespace TheTempusProject\Classes;
use TheTempusProject\Bedrock\Classes\Controller as BedrockController; use TheTempusProject\Bedrock\Classes\Controller as BedrockController;
use TheTempusProject\Houdini\Classes\Template; use TheTempusProject\Houdini\Classes\Template;
use TheTempusProject\Houdini\Classes\Pagination; use TheTempusProject\Bedrock\Classes\Pagination;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Models\User; use TheTempusProject\Models\User;
use TheTempusProject\Models\Sessions; use TheTempusProject\Models\Sessions;
use TheTempusProject\Bedrock\Functions\Token;
use TheTempusProject\Houdini\Classes\Components;
class Controller extends BedrockController { class Controller extends BedrockController {
public static $user; public static $user;
@ -33,6 +35,7 @@ class Controller extends BedrockController {
} }
new Template; new Template;
Template::setTemplate( 'default' ); Template::setTemplate( 'default' );
Components::set( 'TOKEN', Token::generate() );
} }
public function __destruct() { public function __destruct() {

View File

@ -13,7 +13,7 @@ namespace TheTempusProject\Classes;
use TheTempusProject\Bedrock\Classes\DatabaseModel as BedrockDatabaseModel; use TheTempusProject\Bedrock\Classes\DatabaseModel as BedrockDatabaseModel;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Models\Log; use TheTempusProject\Models\Log;
class DatabaseModel extends BedrockDatabaseModel { class DatabaseModel extends BedrockDatabaseModel {

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Classes;
use TheTempusProject\Houdini\Classes\Template; use TheTempusProject\Houdini\Classes\Template;
use TheTempusProject\Houdini\Classes\Views; use TheTempusProject\Houdini\Classes\Views;
use TheTempusProject\Hermes\Functions\Route as Routes; use TheTempusProject\Hermes\Functions\Route as Routes;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
class Email { class Email {
private static $header = null; private static $header = null;

View File

@ -15,7 +15,7 @@
namespace TheTempusProject\Classes; namespace TheTempusProject\Classes;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
class Forms extends Check { class Forms extends Check {
private static $formHandlers = []; private static $formHandlers = [];

View File

@ -16,7 +16,7 @@ namespace TheTempusProject\Classes;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Code; use TheTempusProject\Bedrock\Functions\Code;
use TheTempusProject\Bedrock\Functions\Cookie; use TheTempusProject\Bedrock\Functions\Cookie;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Hermes\Functions\Redirect; use TheTempusProject\Hermes\Functions\Redirect;
use TheTempusProject\Hermes\Functions\Route as Routes; use TheTempusProject\Hermes\Functions\Route as Routes;
use TheTempusProject\Bedrock\Functions\Session; use TheTempusProject\Bedrock\Functions\Session;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Classes; namespace TheTempusProject\Classes;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Houdini\Classes\Forms; use TheTempusProject\Houdini\Classes\Forms;
use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Functions\Input;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Classes;
use TheTempusProject\Houdini\Classes\Navigation; use TheTempusProject\Houdini\Classes\Navigation;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Classes\Database; use TheTempusProject\Bedrock\Classes\Database;
class Plugin { class Plugin {

View File

@ -13,7 +13,7 @@ namespace TheTempusProject\Classes;
use TheTempusProject\Houdini\Classes\Issues; use TheTempusProject\Houdini\Classes\Issues;
use TheTempusProject\Houdini\Classes\Forms; use TheTempusProject\Houdini\Classes\Forms;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Upload; use TheTempusProject\Bedrock\Functions\Upload;
use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Functions\Input;

View File

@ -1,135 +1,135 @@
<?php <?php
if ( ! defined( 'APP_SPACE' ) ) {
define( 'APP_SPACE', 'TheTempusProject' ); define( 'APP_SPACE', 'TheTempusProject' );
}
if ( ! defined( 'APP_ROOT_DIRECTORY' ) ) { if ( ! defined( 'APP_ROOT_DIRECTORY' ) ) {
define( 'APP_ROOT_DIRECTORY', dirname( __DIR__ ) . DIRECTORY_SEPARATOR ); // need to verify define( 'APP_ROOT_DIRECTORY', dirname( __DIR__ ) . DIRECTORY_SEPARATOR ); // need to verify
} }
if ( ! defined( 'CONFIG_DIRECTORY' ) ) { define( 'APP_DIRECTORY', APP_ROOT_DIRECTORY . 'app' . DIRECTORY_SEPARATOR );
define( 'CONFIG_DIRECTORY', APP_ROOT_DIRECTORY . 'app' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR );
}
// Directories // Directories
define( 'APP_DIRECTORY', APP_ROOT_DIRECTORY . 'app' . DIRECTORY_SEPARATOR ); define( 'CSS_DIRECTORY', APP_ROOT_DIRECTORY . 'css' . DIRECTORY_SEPARATOR );
define( 'CSS_DIRECTORY', APP_ROOT_DIRECTORY . 'css' . DIRECTORY_SEPARATOR ); define( 'IMAGE_DIRECTORY', APP_ROOT_DIRECTORY . 'images' . DIRECTORY_SEPARATOR );
define( 'IMAGE_DIRECTORY', APP_ROOT_DIRECTORY . 'images' . DIRECTORY_SEPARATOR ); define( 'JAVASCRIPT_DIRECTORY', APP_ROOT_DIRECTORY . 'js' . DIRECTORY_SEPARATOR );
define( 'JAVASCRIPT_DIRECTORY', APP_ROOT_DIRECTORY . 'js' . DIRECTORY_SEPARATOR ); define( 'HTACCESS_LOCATION', APP_ROOT_DIRECTORY . '.htaccess' );
define( 'HTACCESS_LOCATION', APP_ROOT_DIRECTORY . '.htaccess' ); if ( ! defined( 'CONFIG_DIRECTORY' ) ) {
define( 'PLUGIN_DIRECTORY', APP_DIRECTORY . 'plugins' . DIRECTORY_SEPARATOR ); define( 'CONFIG_DIRECTORY', APP_DIRECTORY . 'config' . DIRECTORY_SEPARATOR );
define( 'MODEL_DIRECTORY', APP_DIRECTORY . 'models' . DIRECTORY_SEPARATOR ); }
define( 'CONTROLLER_DIRECTORY', APP_DIRECTORY . 'controllers' . DIRECTORY_SEPARATOR ); define( 'PLUGIN_DIRECTORY', APP_DIRECTORY . 'plugins' . DIRECTORY_SEPARATOR );
define( 'ADMIN_CONTROLLER_DIRECTORY', CONTROLLER_DIRECTORY. 'admin' . DIRECTORY_SEPARATOR ); define( 'MODEL_DIRECTORY', APP_DIRECTORY . 'models' . DIRECTORY_SEPARATOR );
define( 'API_CONTROLLER_DIRECTORY', CONTROLLER_DIRECTORY. 'api' . DIRECTORY_SEPARATOR ); define( 'CONTROLLER_DIRECTORY', APP_DIRECTORY . 'controllers' . DIRECTORY_SEPARATOR );
define( 'ADMIN_CONTROLLER_DIRECTORY', CONTROLLER_DIRECTORY. 'admin' . DIRECTORY_SEPARATOR );
define( 'API_CONTROLLER_DIRECTORY', CONTROLLER_DIRECTORY. 'api' . DIRECTORY_SEPARATOR );
// Files // Files
define( 'PERMISSIONS_JSON', CONFIG_DIRECTORY . 'permissions.json' ); define( 'PERMISSIONS_JSON', CONFIG_DIRECTORY . 'permissions.json' );
define( 'PREFERENCES_JSON', CONFIG_DIRECTORY . 'preferences.json' ); define( 'PREFERENCES_JSON', CONFIG_DIRECTORY . 'preferences.json' );
define( 'INSTALL_JSON_LOCATION', CONFIG_DIRECTORY . 'install.json' ); define( 'INSTALL_JSON_LOCATION', CONFIG_DIRECTORY . 'install.json' );
define( 'INSTALLER_LOCATION', APP_ROOT_DIRECTORY . 'install.php' ); define( 'INSTALLER_LOCATION', APP_ROOT_DIRECTORY . 'install.php' );
// Other // Other
define( 'PLUGINS_ENABLED', true ); define( 'PLUGINS_ENABLED', true );
define( 'INSTALL_STATUS_NOT_REQUIRED', 'Not Required' ); define( 'INSTALL_STATUS_NOT_REQUIRED', 'Not Required' );
define( 'INSTALL_STATUS_NOT_FOUND', 'Not Found' ); define( 'INSTALL_STATUS_NOT_FOUND', 'Not Found' );
define( 'INSTALL_STATUS_PARTIALLY_INSTALLED', 'Partially Installed' ); define( 'INSTALL_STATUS_PARTIALLY_INSTALLED', 'Partially Installed' );
define( 'INSTALL_STATUS_NOT_INSTALLED', 'Not Installed' ); define( 'INSTALL_STATUS_NOT_INSTALLED', 'Not Installed' );
define( 'INSTALL_STATUS_INSTALLED', 'Installed' ); define( 'INSTALL_STATUS_INSTALLED', 'Installed' );
define( 'INSTALL_STATUS_UNINSTALLED', 'Uninstalled' ); define( 'INSTALL_STATUS_UNINSTALLED', 'Uninstalled' );
define( 'INSTALL_STATUS_SUCCESS', 'Success' ); define( 'INSTALL_STATUS_SUCCESS', 'Success' );
define( 'INSTALL_STATUS_SKIPPED', 'Skipped' ); define( 'INSTALL_STATUS_SKIPPED', 'Skipped' );
define( 'INSTALL_STATUS_FAIL', 'Failed' ); define( 'INSTALL_STATUS_FAIL', 'Failed' );
define( 'MODEL_INSTALL_FLAGS', [ 'installTable', 'installPermissions', 'installConfigs', 'installResources', 'installPreferences' ] ); define( 'MODEL_INSTALL_FLAGS', [ 'installTable', 'installPermissions', 'installConfigs', 'installResources', 'installPreferences' ] );
define( 'PLUGIN_INSTALL_FLAGS', [ 'models_installed', 'permissions_installed', 'configs_installed', 'resources_installed', 'preferences_installed' ] ); define( 'PLUGIN_INSTALL_FLAGS', [ 'models_installed', 'permissions_installed', 'configs_installed', 'resources_installed', 'preferences_installed' ] );
# Tempus Debugger # Tempus Debugger
define( 'CANARY_SECURE_HASH', 'd73ed7591a30f0ca7d686a0e780f0d05' ); define( 'CANARY_SECURE_HASH', 'd73ed7591a30f0ca7d686a0e780f0d05' );
# Tempus Project Core # Tempus Project Core
// Check // Check
define( 'MINIMUM_PHP_VERSION', 8.1); define( 'MINIMUM_PHP_VERSION', 8.1);
// Cookies // Cookies
define( 'DEFAULT_COOKIE_PREFIX', 'TP_'); define( 'DEFAULT_COOKIE_PREFIX', 'TP_');
// Debug // Debug
define( 'CANARY_DEBUG_LEVEL_ERROR', 'error' ); define( 'CANARY_DEBUG_LEVEL_ERROR', 'error' );
define( 'CANARY_DEBUG_LEVEL_WARN', 'warn' ); define( 'CANARY_DEBUG_LEVEL_WARN', 'warn' );
define( 'CANARY_DEBUG_LEVEL_INFO', 'info' ); define( 'CANARY_DEBUG_LEVEL_INFO', 'info' );
define( 'CANARY_DEBUG_LEVEL_LOG', 'log' ); define( 'CANARY_DEBUG_LEVEL_LOG', 'log' );
define( 'CANARY_DEBUG_LEVEL_DEBUG', 'debug' ); define( 'CANARY_DEBUG_LEVEL_DEBUG', 'debug' );
define( 'CANARY_DEBUG_TO_FILE_LEVEL', CANARY_DEBUG_LEVEL_INFO ); define( 'CANARY_DEBUG_TO_FILE_LEVEL', CANARY_DEBUG_LEVEL_INFO );
define( 'CANARY_ENABLED', true ); define( 'CANARY_ENABLED', true );
define( 'DEBUG_EMAIL', 'webmaster@' . $_SERVER['HTTP_HOST'] ); define( 'DEBUG_EMAIL', 'webmaster@' . $_SERVER['HTTP_HOST'] );
define( 'HERMES_REDIRECTS_ENABLED', true ); define( 'HERMES_REDIRECTS_ENABLED', true );
define( 'RENDERING_ENABLED', true ); define( 'RENDERING_ENABLED', true );
define( 'CANARY_TRACE_ENABLED', false ); define( 'CANARY_TRACE_ENABLED', false );
define( 'CANARY_DEBUG_TO_CONSOLE', false ); define( 'CANARY_DEBUG_TO_CONSOLE', false );
define( 'CANARY_DEBUG_TO_FILE', true ); define( 'CANARY_DEBUG_TO_FILE', true );
// Directories // Directories
define( 'VENDOR_DIRECTORY', APP_ROOT_DIRECTORY . 'vendor' . DIRECTORY_SEPARATOR ); if ( ! defined( 'VENDOR_DIRECTORY' ) ) {
if ( is_dir( VENDOR_DIRECTORY . 'thetempusproject' )) { define( 'VENDOR_DIRECTORY', APP_ROOT_DIRECTORY . 'vendor' . DIRECTORY_SEPARATOR );
define( 'TP_VENDOR_DIRECTORY', VENDOR_DIRECTORY . 'thetempusproject' . DIRECTORY_SEPARATOR ); }
} elseif ( is_dir( VENDOR_DIRECTORY . 'TheTempusProject' )) { if ( is_dir( VENDOR_DIRECTORY . 'thetempusproject' )) {
define( 'TP_VENDOR_DIRECTORY', VENDOR_DIRECTORY . 'TheTempusProject' . DIRECTORY_SEPARATOR ); define( 'TP_VENDOR_DIRECTORY', VENDOR_DIRECTORY . 'thetempusproject' . DIRECTORY_SEPARATOR );
} else { } elseif ( is_dir( VENDOR_DIRECTORY . 'TheTempusProject' )) {
define( 'TP_VENDOR_DIRECTORY', VENDOR_DIRECTORY); define( 'TP_VENDOR_DIRECTORY', VENDOR_DIRECTORY . 'TheTempusProject' . DIRECTORY_SEPARATOR );
} } else {
# Bedrock define( 'TP_VENDOR_DIRECTORY', VENDOR_DIRECTORY);
if ( is_dir( TP_VENDOR_DIRECTORY . 'tempusprojectcore' )) { }
define( 'BEDROCK_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'tempusprojectcore' . DIRECTORY_SEPARATOR ); # Bedrock
} elseif ( is_dir( TP_VENDOR_DIRECTORY . 'TempusProjectCore' )) { if ( is_dir( TP_VENDOR_DIRECTORY . 'tempusprojectcore' )) {
define( 'BEDROCK_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'TempusProjectCore' . DIRECTORY_SEPARATOR ); define( 'BEDROCK_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'tempusprojectcore' . DIRECTORY_SEPARATOR );
} elseif ( is_dir( TP_VENDOR_DIRECTORY . 'bedrock' )) { } elseif ( is_dir( TP_VENDOR_DIRECTORY . 'TempusProjectCore' )) {
define( 'BEDROCK_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'bedrock' . DIRECTORY_SEPARATOR ); define( 'BEDROCK_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'TempusProjectCore' . DIRECTORY_SEPARATOR );
} elseif ( is_dir( TP_VENDOR_DIRECTORY . 'Bedrock' )) { } elseif ( is_dir( TP_VENDOR_DIRECTORY . 'bedrock' )) {
define( 'BEDROCK_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'Bedrock' . DIRECTORY_SEPARATOR ); define( 'BEDROCK_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'bedrock' . DIRECTORY_SEPARATOR );
} } elseif ( is_dir( TP_VENDOR_DIRECTORY . 'Bedrock' )) {
if ( is_dir( BEDROCK_ROOT_DIRECTORY . 'config' )) { define( 'BEDROCK_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'Bedrock' . DIRECTORY_SEPARATOR );
define( 'BEDROCK_CONFIG_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR ); }
} if ( is_dir( BEDROCK_ROOT_DIRECTORY . 'config' )) {
# Canary define( 'BEDROCK_CONFIG_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR );
if ( is_dir( TP_VENDOR_DIRECTORY . 'tempusdebugger' )) { }
define( 'CANARY_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'tempusdebugger' . DIRECTORY_SEPARATOR ); # Canary
} elseif ( is_dir( TP_VENDOR_DIRECTORY . 'TempusDebugger' )) { if ( is_dir( TP_VENDOR_DIRECTORY . 'tempusdebugger' )) {
define( 'CANARY_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'TempusDebugger' . DIRECTORY_SEPARATOR ); define( 'CANARY_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'tempusdebugger' . DIRECTORY_SEPARATOR );
} elseif ( is_dir( TP_VENDOR_DIRECTORY . 'canary' )) { } elseif ( is_dir( TP_VENDOR_DIRECTORY . 'TempusDebugger' )) {
define( 'CANARY_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'canary' . DIRECTORY_SEPARATOR ); define( 'CANARY_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'TempusDebugger' . DIRECTORY_SEPARATOR );
} elseif ( is_dir( TP_VENDOR_DIRECTORY . 'Canary' )) { } elseif ( is_dir( TP_VENDOR_DIRECTORY . 'canary' )) {
define( 'CANARY_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'Canary' . DIRECTORY_SEPARATOR ); define( 'CANARY_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'canary' . DIRECTORY_SEPARATOR );
} } elseif ( is_dir( TP_VENDOR_DIRECTORY . 'Canary' )) {
if ( is_dir( CANARY_ROOT_DIRECTORY . 'config' )) { define( 'CANARY_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'Canary' . DIRECTORY_SEPARATOR );
define( 'CANARY_CONFIG_DIRECTORY', CANARY_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR ); }
} if ( is_dir( CANARY_ROOT_DIRECTORY . 'config' )) {
# Hermes define( 'CANARY_CONFIG_DIRECTORY', CANARY_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR );
if ( is_dir( TP_VENDOR_DIRECTORY . 'hermes' )) { }
define( 'HERMES_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'hermes' . DIRECTORY_SEPARATOR ); # Hermes
} elseif ( is_dir( TP_VENDOR_DIRECTORY . 'Hermes' )) { if ( is_dir( TP_VENDOR_DIRECTORY . 'hermes' )) {
define( 'HERMES_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'Hermes' . DIRECTORY_SEPARATOR ); define( 'HERMES_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'hermes' . DIRECTORY_SEPARATOR );
} } elseif ( is_dir( TP_VENDOR_DIRECTORY . 'Hermes' )) {
if ( is_dir( HERMES_ROOT_DIRECTORY . 'config' )) { define( 'HERMES_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'Hermes' . DIRECTORY_SEPARATOR );
define( 'HERMES_CONFIG_DIRECTORY', HERMES_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR ); }
} if ( is_dir( HERMES_ROOT_DIRECTORY . 'config' )) {
# Houdini define( 'HERMES_CONFIG_DIRECTORY', HERMES_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR );
if ( is_dir( TP_VENDOR_DIRECTORY . 'houdini' )) { }
define( 'HOUDINI_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'houdini' . DIRECTORY_SEPARATOR ); # Houdini
} elseif ( is_dir( TP_VENDOR_DIRECTORY . 'Houdini' )) { if ( is_dir( TP_VENDOR_DIRECTORY . 'houdini' )) {
define( 'HOUDINI_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'Houdini' . DIRECTORY_SEPARATOR ); define( 'HOUDINI_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'houdini' . DIRECTORY_SEPARATOR );
} } elseif ( is_dir( TP_VENDOR_DIRECTORY . 'Houdini' )) {
if ( is_dir( HOUDINI_ROOT_DIRECTORY . 'config' )) { define( 'HOUDINI_ROOT_DIRECTORY', TP_VENDOR_DIRECTORY . 'Houdini' . DIRECTORY_SEPARATOR );
define( 'HOUDINI_CONFIG_DIRECTORY', HOUDINI_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR ); }
} if ( is_dir( HOUDINI_ROOT_DIRECTORY . 'config' )) {
// Shared Directories define( 'HOUDINI_CONFIG_DIRECTORY', HOUDINI_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR );
define( 'BIN_DIRECTORY', APP_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR ); }
define( 'VIEW_DIRECTORY', APP_DIRECTORY . 'views' . DIRECTORY_SEPARATOR ); // Shared Directories
define( 'ERRORS_DIRECTORY', VIEW_DIRECTORY . 'errors' . DIRECTORY_SEPARATOR ); define( 'BIN_DIRECTORY', APP_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR );
define( 'CLASSES_DIRECTORY', APP_DIRECTORY . 'classes' . DIRECTORY_SEPARATOR ); define( 'VIEW_DIRECTORY', APP_DIRECTORY . 'views' . DIRECTORY_SEPARATOR );
define( 'FUNCTIONS_DIRECTORY', APP_DIRECTORY . 'functions' . DIRECTORY_SEPARATOR ); define( 'ERRORS_DIRECTORY', VIEW_DIRECTORY . 'errors' . DIRECTORY_SEPARATOR );
define( 'RESOURCES_DIRECTORY', APP_DIRECTORY . 'resources' . DIRECTORY_SEPARATOR ); define( 'CLASSES_DIRECTORY', APP_DIRECTORY . 'classes' . DIRECTORY_SEPARATOR );
define( 'TEMPLATE_DIRECTORY', APP_DIRECTORY . 'templates' . DIRECTORY_SEPARATOR ); define( 'FUNCTIONS_DIRECTORY', APP_DIRECTORY . 'functions' . DIRECTORY_SEPARATOR );
define( 'UPLOAD_DIRECTORY', APP_ROOT_DIRECTORY . 'uploads' . DIRECTORY_SEPARATOR ); define( 'RESOURCES_DIRECTORY', APP_DIRECTORY . 'resources' . DIRECTORY_SEPARATOR );
define( 'IMAGE_UPLOAD_DIRECTORY', UPLOAD_DIRECTORY . 'images' . DIRECTORY_SEPARATOR ); define( 'TEMPLATE_DIRECTORY', APP_DIRECTORY . 'templates' . DIRECTORY_SEPARATOR );
// Files define( 'UPLOAD_DIRECTORY', APP_ROOT_DIRECTORY . 'uploads' . DIRECTORY_SEPARATOR );
define( 'COMPOSER_JSON_LOCATION', APP_ROOT_DIRECTORY . 'composer.json' ); define( 'IMAGE_UPLOAD_DIRECTORY', UPLOAD_DIRECTORY . 'images' . DIRECTORY_SEPARATOR );
define( 'COMPOSER_LOCK_LOCATION', APP_ROOT_DIRECTORY . 'composer.lock' ); // Files
define( 'CONFIG_JSON', CONFIG_DIRECTORY . 'config.json' ); define( 'COMPOSER_JSON_LOCATION', APP_ROOT_DIRECTORY . 'composer.json' );
// Other define( 'COMPOSER_LOCK_LOCATION', APP_ROOT_DIRECTORY . 'composer.lock' );
define( 'EMAIL_FROM_EMAIL', 'noreply@localohost.com' ); define( 'CONFIG_JSON', CONFIG_DIRECTORY . 'config.json' );
// Sessions // Other
define( 'DEFAULT_SESSION_PREFIX', 'TP_' ); define( 'EMAIL_FROM_EMAIL', 'noreply@localohost.com' );
// Token // Sessions
define( 'DEFAULT_TOKEN_NAME', 'TP_SESSION_TOKEN' ); define( 'DEFAULT_SESSION_PREFIX', 'TP_' );
// Token
define( 'DEFAULT_TOKEN_NAME', 'TP_SESSION_TOKEN' );
# Tell the app; all constants have been loaded # Tell the app; all constants have been loaded
define( 'TEMPUS_PROJECT_CONSTANTS_LOADED', true ); define( 'TEMPUS_PROJECT_CONSTANTS_LOADED', true );

View File

@ -12,7 +12,7 @@
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\Permissions; use TheTempusProject\Classes\Permissions;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Functions\Input;

View File

@ -16,7 +16,7 @@ use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
class Log extends DatabaseModel { class Log extends DatabaseModel {
public $tableName = 'logs'; public $tableName = 'logs';

View File

@ -12,7 +12,7 @@
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
class Routes extends DatabaseModel { class Routes extends DatabaseModel {

View File

@ -16,7 +16,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Code; use TheTempusProject\Bedrock\Functions\Code;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Session; use TheTempusProject\Bedrock\Functions\Session;
use TheTempusProject\Bedrock\Functions\Cookie; use TheTempusProject\Bedrock\Functions\Cookie;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;

View File

@ -16,7 +16,7 @@
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Hash; use TheTempusProject\Bedrock\Functions\Hash;
use TheTempusProject\Bedrock\Functions\Session; use TheTempusProject\Bedrock\Functions\Session;
use TheTempusProject\Bedrock\Functions\Code; use TheTempusProject\Bedrock\Functions\Code;

View File

@ -13,7 +13,7 @@
namespace TheTempusProject\Controllers; namespace TheTempusProject\Controllers;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Houdini\Classes\Components; use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Houdini\Classes\Issues; use TheTempusProject\Houdini\Classes\Issues;

View File

@ -12,7 +12,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Sanitize; use TheTempusProject\Bedrock\Functions\Sanitize;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Bugreport as Plugin; use TheTempusProject\Plugins\Bugreport as Plugin;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -15,7 +15,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Date; use TheTempusProject\Bedrock\Functions\Date;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;

View File

@ -14,14 +14,14 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;
use TheTempusProject\Models\Calendars; use TheTempusProject\Models\Calendars;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;
use TheTempusProject\Bedrock\Functions\Date; use TheTempusProject\Bedrock\Functions\Date;
use TheTempusProject\Houdini\Classes\Pagination; use TheTempusProject\Bedrock\Classes\Pagination;
class Events extends DatabaseModel { class Events extends DatabaseModel {
public $tableName = 'events'; public $tableName = 'events';

View File

@ -26,7 +26,7 @@ use TheTempusProject\Models\Upload as UploadModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Components; use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Houdini\Classes\Template; use TheTempusProject\Houdini\Classes\Template;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
class Chat extends Controller { class Chat extends Controller {
protected static $chat; protected static $chat;

View File

@ -16,7 +16,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;

View File

@ -14,7 +14,7 @@
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Houdini\Classes\Views; use TheTempusProject\Houdini\Classes\Views;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -12,7 +12,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;

View File

@ -16,7 +16,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Dashboards as Plugin; use TheTempusProject\Plugins\Dashboards as Plugin;

View File

@ -16,7 +16,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Feedback as Plugin; use TheTempusProject\Plugins\Feedback as Plugin;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Date; use TheTempusProject\Bedrock\Functions\Date;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -11,7 +11,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -16,7 +16,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Feedback as Plugin; use TheTempusProject\Plugins\Feedback as Plugin;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;

View File

@ -16,7 +16,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Feedback as Plugin; use TheTempusProject\Plugins\Feedback as Plugin;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -12,7 +12,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Sanitize; use TheTempusProject\Bedrock\Functions\Sanitize;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;

View File

@ -13,7 +13,7 @@
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Sanitize; use TheTempusProject\Bedrock\Functions\Sanitize;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;

View File

@ -12,7 +12,7 @@
*/ */
namespace TheTempusProject\Models; namespace TheTempusProject\Models;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Sanitize; use TheTempusProject\Bedrock\Functions\Sanitize;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Houdini\Classes\Components; use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Houdini\Classes\Views; use TheTempusProject\Houdini\Classes\Views;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Sanitize; use TheTempusProject\Bedrock\Functions\Sanitize;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;

View File

@ -16,7 +16,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Feedback as Plugin; use TheTempusProject\Plugins\Feedback as Plugin;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -30,7 +30,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Feedback as Plugin; use TheTempusProject\Plugins\Feedback as Plugin;

View File

@ -16,7 +16,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Feedback as Plugin; use TheTempusProject\Plugins\Feedback as Plugin;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Reviews as Plugin; use TheTempusProject\Plugins\Reviews as Plugin;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Reviews as Plugin; use TheTempusProject\Plugins\Reviews as Plugin;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Code; use TheTempusProject\Bedrock\Functions\Code;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
class Subscribe extends DatabaseModel { class Subscribe extends DatabaseModel {

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Tablefinder as Plugin; use TheTempusProject\Plugins\Tablefinder as Plugin;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Tablefinder as Plugin; use TheTempusProject\Plugins\Tablefinder as Plugin;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Houdini\Classes\Filters; use TheTempusProject\Houdini\Classes\Filters;

View File

@ -22,7 +22,7 @@ use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Houdini\Classes\Issues; use TheTempusProject\Houdini\Classes\Issues;
use TheTempusProject\Classes\Forms; use TheTempusProject\Classes\Forms;
use TheTempusProject\Houdini\Classes\Template; use TheTempusProject\Houdini\Classes\Template;
use TheTempusProject\Bedrock\Bedrock; use TheTempusProject\Bedrock\Bin\Bedrock;
class Timers extends Controller { class Timers extends Controller {
protected static $timers; protected static $timers;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Bugreport as Plugin; use TheTempusProject\Plugins\Bugreport as Plugin;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Classes\CustomException; use TheTempusProject\Bedrock\Classes\CustomException;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Bugreport as Plugin; use TheTempusProject\Plugins\Bugreport as Plugin;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Models;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Classes\DatabaseModel; use TheTempusProject\Classes\DatabaseModel;
use TheTempusProject\Plugins\Updates as Plugin; use TheTempusProject\Plugins\Updates as Plugin;
use TheTempusProject\TheTempusProject as App; use TheTempusProject\TheTempusProject as App;

View File

@ -14,7 +14,7 @@ namespace TheTempusProject\Controllers;
use TheTempusProject\Classes\Controller; use TheTempusProject\Classes\Controller;
use TheTempusProject\Houdini\Classes\Template; use TheTempusProject\Houdini\Classes\Template;
use TheTempusProject\Houdini\Classes\Views; use TheTempusProject\Houdini\Classes\Views;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
// The new controller must extend the default controller class or some functionality will be lost. // The new controller must extend the default controller class or some functionality will be lost.
class Example extends Controller { class Example extends Controller {

View File

@ -17,80 +17,21 @@ use TheTempusProject\Houdini\Classes\Template;
use TheTempusProject\Houdini\Classes\Views; use TheTempusProject\Houdini\Classes\Views;
// Basic constants needed for loading files // Basic constants needed for loading files
if ( ! defined( 'APP_SPACE' ) ) { define( 'APP_ROOT_DIRECTORY', dirname( __DIR__ ) . DIRECTORY_SEPARATOR );
define( 'APP_SPACE', __NAMESPACE__ ); define( 'CONFIG_DIRECTORY', APP_ROOT_DIRECTORY . 'app' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR );
}
if ( ! defined( 'APP_ROOT_DIRECTORY' ) ) {
define( 'APP_ROOT_DIRECTORY', dirname( __DIR__ ) . DIRECTORY_SEPARATOR );
}
if ( ! defined( 'CONFIG_DIRECTORY' ) ) {
define( 'CONFIG_DIRECTORY', APP_ROOT_DIRECTORY . 'app' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR );
}
// App Constants // App Constants
if ( ! defined( 'TEMPUS_PROJECT_CONSTANTS_LOADED' ) ) { if ( ! defined( 'TEMPUS_PROJECT_CONSTANTS_LOADED' ) ) {
require_once CONFIG_DIRECTORY . 'constants.php'; require_once CONFIG_DIRECTORY . 'constants.php';
} }
// Hermes Constants
if ( ! defined( 'HERMES_CONSTANTS_LOADED' ) ) {
if ( defined( 'HERMES_CONFIG_DIRECTORY' ) ) {
require_once HERMES_CONFIG_DIRECTORY . 'constants.php';
}
}
// Bedrock Constants
if ( ! defined( 'BEDROCK_CONSTANTS_LOADED' ) ) {
if ( defined( 'BEDROCK_CONFIG_DIRECTORY' ) ) {
require_once BEDROCK_CONFIG_DIRECTORY . 'constants.php';
}
}
// Canary Constants
if ( ! defined( 'CANARY_CONSTANTS_LOADED' ) ) {
if ( defined( 'CANARY_CONFIG_DIRECTORY' ) ) {
require_once CANARY_CONFIG_DIRECTORY . 'constants.php';
}
}
// Require common functions
require_once FUNCTIONS_DIRECTORY . 'common.php';
// Determine which autoloader to sue // Determine which autoloader to sue
if ( file_exists( VENDOR_DIRECTORY . 'autoload.php' ) ) { if ( file_exists( VENDOR_DIRECTORY . 'autoload.php' ) ) {
// Composer Autoloader // Composer Autoloader
require_once VENDOR_DIRECTORY . 'autoload.php'; require_once VENDOR_DIRECTORY . 'autoload.php';
define( 'VENDOR_AUTOLOADED', true ); define( 'VENDOR_AUTOLOADED', true );
} else { } else {
// Hermes Autoloader (Autoloader) sideLoad();
if ( ! defined( 'HERMES_AUTOLOADED' ) ) {
if ( defined( 'HERMES_ROOT_DIRECTORY' ) ) {
require_once HERMES_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php';
}
}
// Canary Autoloader (Debugging)
if ( ! defined( 'CANARY_AUTOLOADED' ) ) {
if ( defined( 'CANARY_ROOT_DIRECTORY' ) ) {
require_once CANARY_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php';
}
}
// Bedrock Autoloader (Core Functionality)
if ( ! defined( 'BEDROCK_AUTOLOADED' ) ) {
if ( defined( 'BEDROCK_ROOT_DIRECTORY' ) ) {
require_once BEDROCK_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php';
}
}
// Houdini Autoloader (Frontend Driver)
if ( ! defined( 'HOUDINI_AUTOLOADED' ) ) {
if ( defined( 'HOUDINI_ROOT_DIRECTORY' ) ) {
require_once HOUDINI_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php';
}
}
// App Autoloader
if ( file_exists( APP_DIRECTORY . 'autoload.php' ) ) {
require_once APP_DIRECTORY . 'autoload.php';
}
define( 'VENDOR_AUTOLOADED', false );
} }
if ( class_exists( 'TheTempusProject\Hermes\Classes\Autoloader' ) && TEMPUS_PROJECT_CONSTANTS_LOADED ) { if ( class_exists( 'TheTempusProject\Hermes\Classes\Autoloader' ) && TEMPUS_PROJECT_CONSTANTS_LOADED ) {
@ -164,7 +105,7 @@ function ttp_autoload() {
require_once( $currentFolder ); require_once( $currentFolder );
break; break;
case 'config': case 'config':
if (file_exists($currentFolder . 'constants.php')) { if ( file_exists( $currentFolder . 'constants.php' ) ) {
require_once( $currentFolder . 'constants.php' ); require_once( $currentFolder . 'constants.php' );
} }
break; break;
@ -175,4 +116,60 @@ function ttp_autoload() {
define('TEMPUS_PROJECT_AUTOLOADED', true); define('TEMPUS_PROJECT_AUTOLOADED', true);
} }
function sideLoad() {
// Hermes Constants
if ( ! defined( 'HERMES_CONSTANTS_LOADED' ) ) {
if ( defined( 'HERMES_CONFIG_DIRECTORY' ) ) {
require_once HERMES_CONFIG_DIRECTORY . 'constants.php';
}
}
// Bedrock Constants
if ( ! defined( 'BEDROCK_CONSTANTS_LOADED' ) ) {
if ( defined( 'BEDROCK_CONFIG_DIRECTORY' ) ) {
require_once BEDROCK_CONFIG_DIRECTORY . 'constants.php';
}
}
// Canary Constants
if ( ! defined( 'CANARY_CONSTANTS_LOADED' ) ) {
if ( defined( 'CANARY_CONFIG_DIRECTORY' ) ) {
require_once CANARY_CONFIG_DIRECTORY . 'constants.php';
}
}
// Require common functions
require_once FUNCTIONS_DIRECTORY . 'common.php';
// Hermes Autoloader (Autoloader)
if ( ! defined( 'HERMES_AUTOLOADED' ) ) {
if ( defined( 'HERMES_ROOT_DIRECTORY' ) ) {
require_once HERMES_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php';
}
}
// Canary Autoloader (Debugging)
if ( ! defined( 'CANARY_AUTOLOADED' ) ) {
if ( defined( 'CANARY_ROOT_DIRECTORY' ) ) {
require_once CANARY_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php';
}
}
// Bedrock Autoloader (Core Functionality)
if ( ! defined( 'BEDROCK_AUTOLOADED' ) ) {
if ( defined( 'BEDROCK_ROOT_DIRECTORY' ) ) {
require_once BEDROCK_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php';
}
}
// Houdini Autoloader (Frontend Driver)
if ( ! defined( 'HOUDINI_AUTOLOADED' ) ) {
if ( defined( 'HOUDINI_ROOT_DIRECTORY' ) ) {
require_once HOUDINI_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR . 'autoload.php';
}
}
define( 'VENDOR_AUTOLOADED', false );
}
require_once 'bin/tempus_project.php'; require_once 'bin/tempus_project.php';

View File

@ -13,13 +13,13 @@
*/ */
namespace TheTempusProject; namespace TheTempusProject;
use TheTempusProject\Bedrock\Bedrock; use TheTempusProject\Bedrock\Bin\Bedrock;
use TheTempusProject\Bedrock\Classes\Config; use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Bedrock\Functions\Session; use TheTempusProject\Bedrock\Functions\Session;
use TheTempusProject\Bedrock\Functions\Cookie; use TheTempusProject\Bedrock\Functions\Cookie;
use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Hermes\Functions\Redirect; use TheTempusProject\Hermes\Functions\Redirect;
use TheTempusProject\Hermes\Functions\Route as Routes; use TheTempusProject\Hermes\Functions\Route as Routes;

View File

@ -1,10 +1,16 @@
{ {
"name": "thetempusproject/thetempusproject", "name": "thetempusproject/thetempusproject",
"description": "The aim of this project is to provide a simple and stable platform for rapidly prototyping new web applications.",
"type": "project", "type": "project",
"description": "The aim of this project is to provide a simple and stable platform for rapidly prototyping new web applications.",
"keywords":
[
"thetempusproject",
"framework"
],
"license": "MIT", "license": "MIT",
"homepage": "https://TheTempusProject.com", "homepage": "https://TheTempusProject.com",
"authors": [ "authors":
[
{ {
"name": "Joey Kimsey", "name": "Joey Kimsey",
"email": "Joey@thetempusproject.com", "email": "Joey@thetempusproject.com",
@ -12,19 +18,46 @@
"role": "Lead Developer" "role": "Lead Developer"
} }
], ],
"minimum-stability": "dev", "require":
"require": { {
"fortawesome/font-awesome": "4.7", "fortawesome/font-awesome": "4.7",
"thetempusproject/bedrock": "1.0", "thetempusproject/bedrock": ">=1.0",
"thetempusproject/canary": "1.0", "thetempusproject/canary": ">=1.0",
"thetempusproject/houdini": "1.0", "thetempusproject/houdini": ">=1.0",
"twbs/bootstrap": "3.3.7" "twbs/bootstrap": "3.3.7"
}, },
"autoload": { "autoload":
"psr-4": { {
"files":
[
"app/functions/forms.php",
"app/functions/common.php"
],
"classmap":
[
"app/classes",
"app/models"
],
"psr-4":
{
"TheTempusProject\\Bedrock\\": "vendor/thetempusproject/bedrock", "TheTempusProject\\Bedrock\\": "vendor/thetempusproject/bedrock",
"TheTempusProject\\Canary\\": "vendor/thetempusproject/canary", "TheTempusProject\\Canary\\": "vendor/thetempusproject/canary",
"TheTempusProject\\Houdini\\": "vendor/thetempusproject/houdini" "TheTempusProject\\Houdini\\": "vendor/thetempusproject/houdini"
} }
} },
} "scripts":
{
"post-root-package-install":
[
"@php -r \"file_exists('docker/.env') || copy('docker/.env.example', '.env');\""
]
},
"config":
{
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}

301
composer.lock generated Normal file
View File

@ -0,0 +1,301 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "626435ee799589fce02b1a794a3d8347",
"packages": [
{
"name": "fortawesome/font-awesome",
"version": "v4.7.0",
"source": {
"type": "git",
"url": "https://github.com/FortAwesome/Font-Awesome.git",
"reference": "a8386aae19e200ddb0f6845b5feeee5eb7013687"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FortAwesome/Font-Awesome/zipball/a8386aae19e200ddb0f6845b5feeee5eb7013687",
"reference": "a8386aae19e200ddb0f6845b5feeee5eb7013687",
"shasum": ""
},
"require-dev": {
"jekyll": "1.0.2",
"lessc": "1.4.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.6.x-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"OFL-1.1",
"MIT"
],
"authors": [
{
"name": "Dave Gandy",
"email": "dave@fontawesome.io",
"homepage": "http://twitter.com/davegandy",
"role": "Developer"
}
],
"description": "The iconic font and CSS framework",
"homepage": "http://fontawesome.io/",
"keywords": [
"FontAwesome",
"awesome",
"bootstrap",
"font",
"icon"
],
"support": {
"issues": "https://github.com/FortAwesome/Font-Awesome/issues",
"source": "https://github.com/FortAwesome/Font-Awesome/tree/v4.7.0"
},
"time": "2016-10-24T15:52:54+00:00"
},
{
"name": "thetempusproject/bedrock",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/bedrock",
"reference": "f80f7bed6bb6c399ce8ea2426ebe1e118cc30a9c"
},
"require": {
"php": ">=8.1.0",
"thetempusproject/canary": ">=1.0",
"thetempusproject/hermes": ">=1.0",
"thetempusproject/houdini": ">=1.0"
},
"type": "library",
"autoload": {
"files": [
"Config/constants.php",
"Bin/Bedrock.php"
],
"psr-4": {
"TheTempusProject\\Bedroock\\Classes\\": "Classes",
"TheTempusProject\\Bedroock\\Functions\\": "Functions"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Joey Kimsey",
"email": "Joey@thetempusproject.com",
"homepage": "https://JoeyKimsey.com",
"role": "Lead Developer"
}
],
"description": "Bedrock is intended as the core functionality used by The Tempus Project: a rapid prototyping framework. This library utilizes the MVC architecture in addition to a custom templating engine designed to make building web applications simple.",
"homepage": "https://git.thetempusproject.com/the-tempus-project/bedrock",
"keywords": [
"framework",
"mvc"
],
"time": "2024-08-09T05:35:47+00:00"
},
{
"name": "thetempusproject/canary",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/canary",
"reference": "8dff31b4eefa3efeb9f81d2e6b6ef3e9f8c9f27b"
},
"require": {
"php": ">=8.1.0"
},
"type": "library",
"autoload": {
"files": [
"Config/constants.php",
"Bin/Canary.php"
],
"psr-4": {
"TheTempusProject\\Canary\\Classes\\": "Classes"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Joey Kimsey",
"email": "Joey@thetempusproject.com",
"homepage": "https://JoeyKimsey.com",
"role": "Lead Developer"
}
],
"description": "Functionality for tracking, logging, and sending log messages to chrome for debugging.",
"homepage": "https://git.thetempusproject.com/the-tempus-project/canary",
"keywords": [
"debugging",
"php",
"thetempusproject",
"tools"
],
"time": "2024-08-09T06:18:45+00:00"
},
{
"name": "thetempusproject/hermes",
"version": "1.0",
"source": {
"type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/hermes",
"reference": "9d6a79d80be98d0e598ce08c47a98d37814d1105"
},
"require": {
"php": ">=8.1.0"
},
"type": "library",
"autoload": {
"files": [
"config/constants.php"
],
"classmap": [
"classes",
"functions"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Joey Kimsey",
"email": "Joey@thetempusproject.com",
"homepage": "https://JoeyKimsey.com",
"role": "Lead Developer"
}
],
"description": "Php functions that aid in routing and redirecting; requests and responses.",
"homepage": "https://git.thetempusproject.com/the-tempus-project/hermes",
"keywords": [
"php",
"routing",
"thetempusproject",
"tools"
],
"time": "2024-08-08T05:24:32+00:00"
},
{
"name": "thetempusproject/houdini",
"version": "1.0.4",
"source": {
"type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/houdini",
"reference": "34babdb2dc508450d14a0764bf81b032a6861a58"
},
"require": {
"php": ">=8.1.0",
"thetempusproject/canary": ">=1.0",
"thetempusproject/hermes": ">=1.0"
},
"type": "library",
"autoload": {
"files": [
"config/constants.php"
],
"classmap": [
"classes"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Joey Kimsey",
"email": "Joey@thetempusproject.com",
"homepage": "https://JoeyKimsey.com",
"role": "Lead Developer"
}
],
"description": "Php functions that aid in creating, managing, and displaying frontend components.",
"homepage": "https://git.thetempusproject.com/the-tempus-project/houdini",
"keywords": [
"frontend",
"php",
"thetempusproject",
"tools"
],
"time": "2024-08-09T06:20:26+00:00"
},
{
"name": "twbs/bootstrap",
"version": "v3.3.7",
"source": {
"type": "git",
"url": "https://github.com/twbs/bootstrap.git",
"reference": "0b9c4a4007c44201dce9a6cc1a38407005c26c86"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/0b9c4a4007c44201dce9a6cc1a38407005c26c86",
"reference": "0b9c4a4007c44201dce9a6cc1a38407005c26c86",
"shasum": ""
},
"replace": {
"twitter/bootstrap": "self.version"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3.x-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jacob Thornton",
"email": "jacobthornton@gmail.com"
},
{
"name": "Mark Otto",
"email": "markdotto@gmail.com"
}
],
"description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
"homepage": "http://getbootstrap.com",
"keywords": [
"JS",
"css",
"framework",
"front-end",
"less",
"mobile-first",
"responsive",
"web"
],
"support": {
"issues": "https://github.com/twbs/bootstrap/issues",
"source": "https://github.com/twbs/bootstrap/tree/master"
},
"time": "2016-07-25T15:51:55+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": [],
"prefer-stable": true,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.3.0"
}

View File

@ -9,20 +9,28 @@ server {
sendfile off; sendfile off;
client_max_body_size 100m; client_max_body_size 100m;
location /images/ { location /js/ {
if (!-e $request_filename){
rewrite ^/images/(.*)$ /index.php?error=image404&url=$1 last;
}
access_log off; access_log off;
log_not_found off; log_not_found off;
try_files $uri /index.php?error=js404&file=$uri;
}
location /css/ {
access_log off;
log_not_found off;
try_files $uri /index.php?error=css404&file=$uri;
}
location /images/ {
try_files $uri /index.php?error=image404&url=$uri;
} }
location /uploads/ { location /uploads/ {
if (!-e $request_filename){ try_files $uri /index.php?error=upload404&url=$uri;
rewrite ^/uploads/(.*)$ /index.php?error=upload404&url=$1 last; }
}
access_log off; location /errors/ {
log_not_found off; try_files $uri /index.php?error=$uri;
} }
location ~* \.(?:js|css|png|jpg|gif|ico)$ { location ~* \.(?:js|css|png|jpg|gif|ico)$ {
@ -60,7 +68,6 @@ server {
} }
location / { location / {
rewrite ^/errors/(.*)$ /index.php?error=$1 last; rewrite ^/(.+)$ /index.php?url=$1&$args last;
rewrite ^(.+)$ /index.php?url=$1 last;
} }
} }

View File

@ -16,7 +16,7 @@ session_start();
require_once 'bin/autoload.php'; require_once 'bin/autoload.php';
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Hermes\Functions\Redirect; use TheTempusProject\Hermes\Functions\Redirect;
use TheTempusProject\Hermes\Functions\Route; use TheTempusProject\Hermes\Functions\Route;

View File

@ -34,7 +34,7 @@ use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Houdini\Classes\Template; use TheTempusProject\Houdini\Classes\Template;
use TheTempusProject\Hermes\Functions\Redirect; use TheTempusProject\Hermes\Functions\Redirect;
use TheTempusProject\Hermes\Functions\Route; use TheTempusProject\Hermes\Functions\Route;
use TheTempusProject\Canary\Canary as Debug; use TheTempusProject\Canary\Bin\Canary as Debug;
class Install extends Controller { class Install extends Controller {
private $installer; private $installer;

2
vendor/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -1,47 +0,0 @@
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# =========================
# Operating System Files
# =========================
# OSX
# =========================
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

View File

@ -1,46 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at webmaster@thetempusproject.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@ -1,87 +0,0 @@
# Contribution Guidelines for Bedrock
Contributing to Bedrock is completely voluntary and should follow all of the guidelines listed here in order to ensure the highest probability of acceptance. It is highly recommended to use a php linter to automate more of this process. The project is maintained on github and all contributions need to be submitted via pull request to their specific repository under the `dev` branch. In order to contribute, simply follow the instructions for [creating a pull request](#creating-a-pull-request) below.
## Pull Request Requirements
- All revisions must follow TTP naming conventions (see [Naming Conventions](#naming-conventions) Section)
- Include a clear and concise explanation of the features or changes included in your revision listed by file.
- All code must follow [PSR 2](http://www.php-fig.org/psr/psr-2/) standards
- prefer the use of [] for arrays over array()
- All functions must be documented with the exception of controller methods (see [Documentation](#documentation) Section)
- Controller methods may be doc-blocked when necessary for clarity (see [Documentation](#documentation) Section)
- All new Classes must include a class level doc-block (see [Documentation](#documentation) Section)
- Any new dependencies will have a longer validation process and should be accompanied by the required information (see [Dependencies](#dependencies) Section)
## Naming Conventions
- File names are to be lower case
- All class names must be upper case
- Any data being stored as a file must be saved in the app directory (with the exception of config which should be stored under config/)
- Controllers must have a constructor and destructor using the constructor and destructor methods found in resources/
- Views must be named using lowerCamelCase
## Dependencies
Whenever a dependency is updated or added, pull requests must include a section that answers the following questions.
- Why is this dependency required
- Could this be reasonably accomplished within the app by implementing new features in a later version? explain.
- What is the latest stable version that can be used
- What features are absolutely necessary for your feature or modification to work
## Documentation
### Classes
New classes must be prefaced with a doc-block following this style:
```
/**
* Controllers/admin.php
*
* This is the admin controller.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
```
From top to bottom:
- Filename on the second line
- A description for the file
- The TTP version this file was built for
`@version 1.0`
- The Authors name or alias and email
`@author first last <email@link.com>`
- A copy of the MIT license
`@license https://opensource.org/licenses/MIT [MIT LICENSE]`
- May include a link for more information
`@link http://link.com`
### Functions
Functions must be prefaced with a doc-block following this style:
```
/**
* Intended as a self-destruct session. If the specified session does not
* exist, it is created. If the specified session does exist, it will be
* destroyed and returned.
*
* @param string $name - Session name to be created or checked
* @param string $string - The string to be used if session needs to be
* created. (optional)
*
* @return bool|string - Returns bool if creating, and a string if the
* check is successful.
*/
```
From top to bottom:
- There must be a description of the functions intended usage on the second line
- All parameters should be documented like this
`@param [type] $name - description`
- Any function with a return statement must also be documented as such
`@return [type] - description`
## Creating a Pull Request
This is a simple explanation of how to create a pull request for changes to Bedrock. You can find a detailed walk-through on how to [create a pull request](https://help.github.com/articles/creating-a-pull-request/) on github.
1. First ensure you have followed all the contributing guidelines
2. Squash your merge into a single revision. This will make it easier to view the changes as a whole.
3. You can submit a pull request [here](https://github.com/TheTempusProject/Bedrock/compare)
4. Please submit all pull requests to the dev branch or they will be ignored.

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2023 Joey Kimsey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,31 +0,0 @@
# Tempus Project Core
###### Developer(s): Joey Kimsey
Bedrock is the core functionality used by [The Tempus Project](https://github.com/TheTempusProject/TheTempusProject) a rapid prototyping framework. This Library can be utilized outside of the TempusProject, but the functionality has not been tested well as a stand alone library.
This library utilizes the MVC architecture in addition to a custom templating engine designed to make building web applications fast and simple.
**Notice: This Library is provided as is, please use at your own risk.**
## Installation and Use
The easiest way to use Bedrock in your application is to install and initialize it via composer.
```
"require": {
"TheTempusProject/Bedrock": "*",
},
"autoload": {
"psr-4": {
"Bedrock\": "vendor/TheTempusProject/Bedrock"
}
}
```
If you prefer to handle auto-loading via other means, you can simply clone this repository wherever you need it. Please note, you will need to install and load the [TempusDebugger](https://github.com/thetempusproject/TempusDebugger) library in order to utilize the debug to console options.
### WIP:
- [ ] Expansion of PDO to allow different database types
- [ ] template stuff should really only be called from template/controllers
- [ ] Update installer to account for updates.
- [ ] Implement uniformity in terms of error reporting, exceptions, logging.

View File

@ -1,52 +0,0 @@
<?php
/**
* bin/autoload.php
*
* Handles the initial setup like autoloading, basic functions, constants, etc.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock;
use TheTempusProject\Hermes\Classes\Autoloader;
if ( ! defined('BEDROCK_ROOT_DIRECTORY' ) ) {
define('BEDROCK_ROOT_DIRECTORY', dirname(__DIR__) . DIRECTORY_SEPARATOR);
}
if ( ! defined('BEDROCK_CONFIG_DIRECTORY' ) ) {
define('BEDROCK_CONFIG_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR);
}
if ( ! defined('BEDROCK_CONSTANTS_LOADED' ) ) {
require_once BEDROCK_CONFIG_DIRECTORY . 'constants.php';
}
if ( ! class_exists( 'TheTempusProject\Bedrock\Classes\Autoloader' ) ) {
if ( file_exists( BEDROCK_CLASSES_DIRECTORY . 'autoloader.php' ) ) {
require_once BEDROCK_CLASSES_DIRECTORY . 'autoloader.php';
}
}
if ( ! class_exists( 'TheTempusProject\Bedrock\App' ) ) {
if ( file_exists( BEDROCK_ROOT_DIRECTORY . 'app.php' ) ) {
require_once BEDROCK_ROOT_DIRECTORY . 'app.php';
}
}
$autoloader = new Autoloader;
$autoloader->setRootFolder( BEDROCK_ROOT_DIRECTORY );
$autoloader->addNamespace(
'TheTempusProject\Bedrock',
'bin'
);
$autoloader->addNamespace(
'TheTempusProject\Bedrock\Classes',
'classes'
);
$autoloader->addNamespace(
'TheTempusProject\Bedrock\Functions',
'functions'
);
$autoloader->register();
define( 'BEDROCK_AUTOLOADED', true );

View File

@ -1,263 +0,0 @@
<?php
/**
* app.php
*
* This file parses any given url and separates it into controller,
* method, and data. This allows the application to direct the user
* to the desired location and provide the controller any additional
* information it may require to run.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock;
use TheTempusProject\Canary\Canary as Debug;
use TheTempusProject\Hermes\Functions\Route as Routes;
use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Token;
use TheTempusProject\Bedrock\Functions\Sanitize;
use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Hermes\Classes\Autoloader;
use TheTempusProject\Houdini\Classes\Template;
use TheTempusProject\Houdini\Classes\Components;
class Bedrock {
public static $controllerName = '';
public static $methodName = '';
public static $activeConfig = [];
protected $controllerObject = null;
protected $controllerClass = '';
protected $params = [];
/**
* The constructor handles the entire process of parsing the url,
* finding the controller/method, and calling the appropriate
* class/function for the application.
*
* @param string $url - A custom URL to be parsed to determine
* controller/method. (GET) url is used by
* default if none is provided
*/
public function __construct( $url = '' ) {
Debug::group( 'Bedrock Application' );
ob_start();
self::$activeConfig = new Config( CONFIG_JSON );
set_error_handler( [ 'TheTempusProject\\Canary\\Canary', 'handle_error' ] );
set_exception_handler( [ 'TheTempusProject\\Canary\\Canary', 'handle_exception' ] );
self::$controllerName = DEFAULT_CONTROLLER_CLASS;
self::$methodName = DEFAULT_CONTROLLER_METHOD;
$this->setUrl( $url );
}
public function setUrl( $url ) {
if ( empty( $url ) ) {
Debug::log( 'Using GET url.' );
$url = Input::get( 'url' );
}
$trimmedUrl = trim( $url, '/' );
$url = str_ireplace( '.php', '', $trimmedUrl );
$urlArray = explode( '/', Sanitize::url( $url ) );
$this->setVarsFromUrlArray( $urlArray );
}
public function load() {
$this->loadController();
$this->loadPage();
}
public static function getUrl() {
return Routes::getAddress() . Input::get( 'url' );
}
protected function loadPage() {
if ( !method_exists( $this->controllerClass, self::$methodName ) ) {
return false;
}
Components::set( 'META_IMAGE', Routes::getAddress() . Config::getValue( 'main/logoLarge' ) );
Components::set( 'CURRENT_URL', self::getCurrentUrl() );
Components::set( 'SITENAME', Config::getValue( 'main/name' ) );
Components::set( 'AUTHOR', '<meta name="author" content="' . Config::getValue( 'main/name' ) . '">' );
call_user_func_array( [ $this->controllerObject, self::$methodName ], $this->params );
Components::set( 'TITLE', Template::parse( $this->controllerObject::$title ) );
Components::set( 'PAGE_DESCRIPTION', Template::parse( $this->controllerObject::$pageDescription ) );
Template::render();
Debug::closeAllGroups();
// self::$session->updatePage( self::getUrl() ); // where did this method go?
}
protected function loadController() {
if ( empty( $this->controllerClass ) ) {
$this->controllerClass = (string) APP_SPACE . '\\Controllers\\' . self::$controllerName;
}
$this->controllerObject = new $this->controllerClass;
}
protected function setController( $name, $namespace ) {
$controllerClass = $namespace . ucfirst( $name );
if ( Autoloader::testLoad( $controllerClass ) ) {
$this->controllerClass = $controllerClass;
self::$controllerName = $name;
}
}
protected function setPage( $name ) {
$name = strtolower( $name );
if ( !method_exists( $this->controllerClass, $name ) ) {
Debug::info( 'setPage - Method not found: ' . $name );
return false;
}
self::$methodName = $name;
}
protected function setVarsFromUrlArray( $urlArray ) {
if ( !empty( $urlArray[0] ) ) {
$urlPart = array_shift( $urlArray );
if ( $urlPart == 'admin' ) {
$namespace = APP_SPACE . '\\Controllers\\Admin\\';
if ( empty( $urlArray[0] ) ) {
// if there is no second param, assume they want the home controller
$urlPart = 'home';
} else {
$urlPart = array_shift( $urlArray ); // to drop the admin
}
if ( $urlPart == 'index' ) {
// if its admin/index, again, assume the home controller
$urlPart = 'home';
}
} elseif ( $urlPart == 'api' ) {
$namespace = APP_SPACE . '\\Controllers\\Api\\';
if ( empty( $urlArray[0] ) ) {
// if there is no second param, assume they want the home controller
$urlPart = 'home';
} else {
$urlPart = array_shift( $urlArray ); // to drop the admin
}
if ( $urlPart == 'index' ) {
// if its admin/index, again, assume the home controller
$urlPart = 'home';
}
} else {
$namespace = APP_SPACE . '\\Controllers\\';
}
$this->setController( $urlPart, $namespace );
}
if ( !empty( $urlArray[0] ) ) {
$urlPart = array_shift( $urlArray );
$this->setPage( $urlPart );
}
if ( !empty( $urlArray ) ) {
$this->params = array_values( $urlArray );
}
}
public static function getCurrentUrl() {
return Sanitize::url( Input::get( 'url' ) );
}
protected function printDebug() {
echo '<div style="margin: 0 auto; padding-bottom: 25px; background: #eee; width: 1000px;">';
echo '<h1 style="text-align: center;">PHP Info</h1>';
echo '<table style="margin: 0 auto; padding-bottom: 25px; background: #eee; width: 950px;">';
echo '<tr><td>PHP version: </td><td><code>' . phpversion() . '</code><br></td></tr>';
echo '<tr><td>PDO Loaded version: </td><td><code>' . extension_loaded( 'pdo' ) . '</code><br></td></tr>';
echo '<tr><td>PHP extensions: </td><td><pre>';
foreach ( get_loaded_extensions() as $i => $ext ) {
echo $ext . ' => ' . phpversion( $ext ) . '<br/>';
}
echo '</pre><br></td></tr>';
echo '</table>';
echo '<h1 style="text-align: center;">Tempus Core Info</h1>';
echo '<table style="margin: 0 auto; padding-bottom: 25px; background: #eee; width: 950px;">';
// Just in case
echo '<tr><td>_SERVER: </td><td><pre>';
echo var_export( $_SERVER, true );
echo '</pre><br></td></tr>';
// Checks
echo '<tr><td style="text-align: center; padding-top: 25px; padding-bottom: 10px;" colspan="2"><h2>Checks</h2></td></tr>';
echo '<tr><td>Uploads work?: </td><td><code>' . var_export( Check::uploads(), true ) . '</code><br></td></tr>';
echo '<tr><td>PHP: </td><td><code>' . var_export( Check::php(), true ) . '</code><br></td></tr>';
echo '<tr><td>Mail works?: </td><td><code>' . var_export( Check::mail(), true ) . '</code><br></td></tr>';
echo '<tr><td>Is safe mode?: </td><td><code>' . var_export( Check::safe(), true ) . '</code><br></td></tr>';
echo '<tr><td>Sessions work?: </td><td><code>' . var_export( Check::sessions(), true ) . '</code><br></td></tr>';
echo '<tr><td>Cookies work?: </td><td><code>' . var_export( Check::cookies(), true ) . '</code><br></td></tr>';
echo '<tr><td>is Apache?: </td><td><code>' . var_export( Check::isApache(), true ) . '</code><br></td></tr>';
echo '<tr><td>is Nginx?: </td><td><code>' . var_export( Check::isNginx(), true ) . '</code><br></td></tr>';
echo '<tr><td>Is token enabled?: </td><td><code>' . var_export( Token::isTokenEnabled(), true ) . '</code><br></td></tr>';
// Routes
echo '<tr><td style="text-align: center; padding-top: 25px; padding-bottom: 10px;" colspan="2"><h2>Routes</h2></td></tr>';
echo '<tr><td>Root: </td><td><code>' . var_export( Routes::getRoot(), true ) . '</code><br></td></tr>';
echo '<tr><td>Address: </td><td><code>' . var_export( Routes::getAddress(), true ) . '</code><br></td></tr>';
echo '<tr><td>Protocol: </td><td><code>' . var_export( Routes::getProtocol(), true ) . '</code><br></td></tr>';
echo '<tr><td>App URL: </td><td><code>' . var_export( self::getUrl(), true ) . '</code><br></td></tr>';
// Debugging
echo '<tr><td style="text-align: center; padding-top: 25px; padding-bottom: 10px;" colspan="2"><h2>Debugging</h2></td></tr>';
echo '<tr><td>Console Debugging Enabled: </td><td><code>' . var_export( Debug::status( 'console' ), true ) . '</code><br></td></tr>';
echo '<tr><td>Debug Trace Enabled: </td><td><code>' . var_export( Debug::status( 'trace' ), true ) . '</code><br></td></tr>';
echo '<tr><td>Debugging Enabled: </td><td><code>' . var_export( Debug::status( 'debug' ), true ) . '</code><br></td></tr>';
echo '<tr><td>Rendering Enabled: </td><td><code>' . var_export( Debug::status( 'render' ), true ) . '</code><br></td></tr>';
// Main
echo '<tr><td style="text-align: center; padding-top: 25px; padding-bottom: 10px;" colspan="2"><h2>Main App Variables</h2></td></tr>';
echo '<tr><td>Template Location: </td><td><code>' . var_export( Template::getLocation(), true ) . '</code><br></td></tr>';
echo '<tr><td>Configuration: </td><td><pre>' . var_export( Config::$config, true ) . '</pre></td></tr>';
echo '<tr><td>Check Errors: </td><td><pre>' . var_export( Check::systemErrors(), true ) . '</pre></td></tr>';
echo '<tr><td>GET: </td><td><pre>' . var_export( $_GET, true ) . '</pre></td></tr>';
// Constants
echo '<tr><td style="text-align: center; padding-top: 25px; padding-bottom: 10px;" colspan="2"><h2>Constants</h2></td></tr>';
// Debugging
echo '<tr><td style="text-align: center;"><b>Debugging:</b></td><td></td></tr>';
echo '<tr><td>HERMES_REDIRECTS_ENABLED: </td><td><code>' . var_export( HERMES_REDIRECTS_ENABLED, true ) . '</code><br></td></tr>';
echo '<tr><td>CANARY_TRACE_ENABLED: </td><td><code>' . var_export( CANARY_TRACE_ENABLED, true ) . '</code><br></td></tr>';
echo '<tr><td>CANARY_ENABLED: </td><td><code>' . var_export( CANARY_ENABLED, true ) . '</code><br></td></tr>';
echo '<tr><td>CANARY_DEBUG_TO_CONSOLE: </td><td><code>' . var_export( CANARY_DEBUG_TO_CONSOLE, true ) . '</code><br></td></tr>';
echo '<tr><td>CANARY_DEBUG_TO_FILE: </td><td><code>' . var_export( CANARY_DEBUG_TO_FILE, true ) . '</code><br></td></tr>';
// Tempus Debugger
echo '<tr><td style="text-align: center;"><b>Tempus Debugger:</b></td><td></td></tr>';
echo '<tr><td>CANARY_SECURE_HASH: </td><td><code>' . var_export( CANARY_SECURE_HASH, true ) . '</code><br></td></tr>';
echo '<tr><td>CANARY_SHOW_LINES: </td><td><code>' . var_export( CANARY_SHOW_LINES, true ) . '</code><br></td></tr>';
// Tokens
echo '<tr><td style="text-align: center;"><b>Tokens:</b></td><td></td></tr>';
echo '<tr><td>DEFAULT_TOKEN_NAME: </td><td><code>' . var_export( DEFAULT_TOKEN_NAME, true ) . '</code><br></td></tr>';
echo '<tr><td>TOKEN_ENABLED: </td><td><code>' . var_export( TOKEN_ENABLED, true ) . '</code><br></td></tr>';
// Cookies
echo '<tr><td style="text-align: center;"><b>Cookies:</b></td><td></td></tr>';
echo '<tr><td>DEFAULT_COOKIE_EXPIRATION: </td><td><code>' . var_export( DEFAULT_COOKIE_EXPIRATION, true ) . '</code><br></td></tr>';
echo '<tr><td>DEFAULT_COOKIE_PREFIX: </td><td><code>' . var_export( DEFAULT_COOKIE_PREFIX, true ) . '</code><br></td></tr>';
// Directories
echo '<tr><td style="text-align: center;"><b>Directories:</b></td><td></td></tr>';
echo '<tr><td>APP_ROOT_DIRECTORY: </td><td><code>' . var_export( APP_ROOT_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>BIN_DIRECTORY: </td><td><code>' . var_export( BIN_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>UPLOAD_DIRECTORY: </td><td><code>' . var_export( UPLOAD_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>IMAGE_UPLOAD_DIRECTORY: </td><td><code>' . var_export( IMAGE_UPLOAD_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>CLASSES_DIRECTORY: </td><td><code>' . var_export( CLASSES_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>CONFIG_DIRECTORY: </td><td><code>' . var_export( CONFIG_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>FUNCTIONS_DIRECTORY: </td><td><code>' . var_export( FUNCTIONS_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>TEMPLATE_DIRECTORY: </td><td><code>' . var_export( TEMPLATE_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>VIEW_DIRECTORY: </td><td><code>' . var_export( VIEW_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>ERRORS_DIRECTORY: </td><td><code>' . var_export( ERRORS_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>RESOURCES_DIRECTORY: </td><td><code>' . var_export( RESOURCES_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>BEDROCK_ROOT_DIRECTORY: </td><td><code>' . var_export( BEDROCK_ROOT_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>BEDROCK_BIN_DIRECTORY: </td><td><code>' . var_export( BEDROCK_BIN_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>BEDROCK_CLASSES_DIRECTORY: </td><td><code>' . var_export( BEDROCK_CLASSES_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>BEDROCK_CONFIG_DIRECTORY: </td><td><code>' . var_export( BEDROCK_CONFIG_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>BEDROCK_FUNCTIONS_DIRECTORY: </td><td><code>' . var_export( BEDROCK_FUNCTIONS_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>BEDROCK_RESOURCES_DIRECTORY: </td><td><code>' . var_export( BEDROCK_RESOURCES_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>BEDROCK_VIEW_DIRECTORY: </td><td><code>' . var_export( BEDROCK_VIEW_DIRECTORY, true ) . '</code><br></td></tr>';
echo '<tr><td>BEDROCK_ERRORS_DIRECTORY: </td><td><code>' . var_export( BEDROCK_ERRORS_DIRECTORY, true ) . '</code><br></td></tr>';
// other
echo '<tr><td style="text-align: center;"><b>Other:</b></td><td></td></tr>';
echo '<tr><td>MINIMUM_PHP_VERSION: </td><td><code>' . var_export( MINIMUM_PHP_VERSION, true ) . '</code><br></td></tr>';
echo '<tr><td>DATA_TITLE_PREG: </td><td><code>' . var_export( DATA_TITLE_PREG, true ) . '</code><br></td></tr>';
echo '<tr><td>PATH_PREG_REQS: </td><td><code>' . var_export( PATH_PREG_REQS, true ) . '</code><br></td></tr>';
echo '<tr><td>SIMPLE_NAME_PREG: </td><td><code>' . var_export( SIMPLE_NAME_PREG, true ) . '</code><br></td></tr>';
echo '<tr><td>ALLOWED_IMAGE_UPLOAD_EXTENTIONS: </td><td><code>' . var_export( ALLOWED_IMAGE_UPLOAD_EXTENTIONS, true ) . '</code><br></td></tr>';
echo '<tr><td>MAX_RESULTS_PER_PAGE: </td><td><code>' . var_export( MAX_RESULTS_PER_PAGE, true ) . '</code><br></td></tr>';
echo '<tr><td>DEFAULT_RESULTS_PER_PAGE: </td><td><code>' . var_export( DEFAULT_RESULTS_PER_PAGE, true ) . '</code><br></td></tr>';
echo '<tr><td>DEFAULT_SESSION_PREFIX: </td><td><code>' . var_export( DEFAULT_SESSION_PREFIX, true ) . '</code><br></td></tr>';
echo '<tr><td>DEFAULT_CONTROLLER_CLASS: </td><td><code>' . var_export( DEFAULT_CONTROLLER_CLASS, true ) . '</code><br></td></tr>';
echo '</table></div>';
}
}

View File

@ -1,367 +0,0 @@
<?php
/**
* classes/config.php
*
* This class handles all the hard-coded configurations.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Classes;
use TheTempusProject\Canary\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Input;
class Config {
public static $config = false;
private static $location = false;
private static $initialized = false;
/**
* Default constructor which will attempt to load the config from the location specified.
*
* @param {string} [$location]
* @return {null|object}
*/
public function __construct( $location = '' ) {
if ( self::$initialized !== false ) {
Debug::log( 'Config already initialized.' );
return $this;
}
if ( empty( $location ) ) {
$location = CONFIG_JSON;
}
self::$initialized = $this->load( $location );
if ( self::$initialized !== false ) {
Debug::log( 'Config initialization succeeded.' );
return $this;
}
Debug::warn( 'Config initialization failed.' );
}
/**
* Attempts to retrieve then set the configuration from a file.
* @note This function will reset the config every time it is used.
*
* @param {string} $location
* @return {bool}
*/
public function load( $location ) {
self::$config = $this->getConfigFile( $location );
self::$location = $location;
if ( self::$config === false || empty( self::$config ) ) {
Debug::warn( 'Config load failed.' );
return false;
}
Debug::log( 'Config load succeeded.' );
return true;
}
/**
* Opens and decodes the config json from the location provided.
*
* @param {string} [$location]
* @return {bool|array}
*/
public function getConfigFile( $location ) {
if ( file_exists( $location ) ) {
Debug::debug( "Config json found: $location" );
return json_decode( file_get_contents( $location ), true );
} else {
Debug::warn( "Config json not found: $location" );
return false;
}
}
/**
* Add a new config option for the specified category.
*
* NOTE: Use a default option when using this function to
* aid in fail safe execution.
*
* @param {string} [$category] - The primary category to add the option to.
* @param {string} [$node] - The name of the new option.
* @param {wild} [$value] - The desired value for the new option.
* @param {bool} [$createMissing] - Whether or not to create missing options.
* @param {bool} [$save] - Whether or not to save the config.
* @param {bool} [$saveDefault] - Whether or not to save the default config.
* @return {bool}
*/
public function update( $category, $node, $value, $createMissing = false, $save = false, $saveDefault = false ) {
// @todo: createMissing is unused here
if ( self::$config === false ) {
Debug::warn( 'Config not loaded.' );
return false;
}
if ( !Check::simpleName( $category ) ) {
Debug::warn( "Category name invalid: $categoryName" );
return false;
}
if ( !isset( self::$config[$category] ) ) {
Debug::warn( "No such category: $category" );
return false;
}
if ( !Check::simpleName( $node ) ) {
Debug::warn( "Node name invalid: $categoryName" );
return false;
}
if ( !isset( self::$config[$category][$node] ) ) {
Debug::warn( 'Config not found.' );
return false;
}
if ( $value === 'true' ) {
$value = true;
}
if ( $value === 'false' ) {
$value = false;
}
self::$config[$category][$node]['value'] = $value;
if ( $save ) {
$this->save( $saveDefault );
}
return true;
}
public function updateFromForm( $save = false, $saveDefault = false ) {
if ( self::$config === false ) {
Debug::warn( 'Config not loaded.' );
return;
}
foreach ( self::$config as $category => $fields ) {
if ( empty( self::$config[ $category ] ) ) {
Debug::warn( "Config category not found: $category" );
continue;
}
foreach ( self::$config[ $category ] as $field => $node ) {
$name = $category . '/' . $field;
if ( empty( $node ) ) {
continue;
}
if ( !empty( $node['protected'] ) ) {
continue;
}
$fieldname = str_ireplace( '/', '-', $name );
if ( Input::exists( $fieldname ) ) {
$this->update( $category, $field, Input::post( $fieldname ) );
}
}
}
if ( $save ) {
return $this->save( $saveDefault );
}
return true;
}
/**
* Saves the current config.
*
* @param {bool} [$default] - Whether or not to save a default copy.
* @return {bool}
*/
public function save( $default = false ) {
if ( self::$config === false ) {
Debug::warn( 'Config not loaded.' );
return false;
}
if ( self::$location === false ) {
Debug::warn( 'Config location not set.' );
return false;
}
if ( $default ) {
$locationArray = explode( '.', self::$location );
$locationArray[] = 'bak';
$backupLoction = implode( '.', $locationArray );
if ( !file_put_contents( $backupLoction, json_encode( self::$config ) ) ) {
return false;
}
}
if ( file_put_contents( self::$location, json_encode( self::$config ) ) ) {
return true;
}
return false;
}
/**
* Adds a new category to the $config array.
*
* @param {string} [$categoryName]
* @return {bool}
*/
public function addCategory( $categoryName ) {
if ( self::$config === false ) {
self::$config = [];
}
if ( !Check::simpleName( $categoryName ) ) {
Debug::warn( "Category name invalid: $categoryName" );
return false;
}
if ( isset( self::$config[$categoryName] ) ) {
Debug::warn( "Category already exists: $categoryName" );
return false;
}
self::$config[$categoryName] = [];
return true;
}
/**
* Removes an existing category from the $config array.
*
* @param {string} [$categoryName]
* @param {string} [$save]
* @return {bool}
*/
public function removeCategory( $categoryName, $save = false, $saveDefault = true ) {
if ( self::$config === false ) {
Debug::warn( 'Config not loaded.' );
return;
}
if ( !isset( self::$config[$categoryName] ) ) {
Debug::warn( "Config does not have category: $categoryName" );
return true;
}
unset( self::$config[$categoryName] );
if ( $save ) {
$this->save( $saveDefault );
}
return true;
}
/**
* Add a new config node for the specified category.
*
* @param {string} [$category] - The primary category to add the option to.
* @param {string} [$node] - The name of the new option.
* @param {wild} [$value] - The desired value for the new option.
* @return {bool}
*/
public function add( $category, $node, $details, $updateExisting = false ) {
if ( self::$config === false ) {
Debug::warn( 'Config not loaded.' );
return false;
}
if ( !Check::simpleName( $category ) ) {
Debug::warn( "Category name invalid: $category" );
return false;
}
if ( !isset( self::$config[$category] ) ) {
Debug::warn( "No such category: $category" );
return false;
}
if ( !Check::simpleName( $node ) ) {
Debug::warn( "Category Node name invalid: $node" );
return false;
}
if ( isset( self::$config[$category][$node] ) ) {
if ( $updateExisting ) {
$details = array_replace(self::$config[$category][$node], $details );
} else {
Debug::warn( "Config already exists: $node" );
return false;
}
}
if ( !isset( $details['value'] ) ) {
$details['value'] = $details['default'];
}
self::$config[$category][$node] = $details;
return true;
}
public function generate( $location, $mods = [] ) {
self::$location = $location;
if ( !empty( $mods ) ) {
foreach ( $mods as $category => $node ) {
$this->addCategory( $category );
foreach ( $node as $name => $details ) {
$this->add( $category, $name, $details, true );
}
}
}
if ( $this->save( true ) ) {
Debug::info( 'config file generated successfully.' );
return true;
}
return false;
}
/**
* Retrieves the config option for $name.
*
* @param {string} [$name] - Must be in <category>/<option> format.
* @return {WILD}
*/
public static function get( $name ) {
$data = explode( '/', $name );
if ( count( $data ) != 2 ) {
Debug::warn( "Config not properly formatted: $name" );
return;
}
if ( self::$config === false ) {
Debug::warn( 'Config not loaded.' );
return;
}
$category = $data[0];
$field = $data[1];
if ( !isset( self::$config[$category][$field] ) ) {
Debug::warn( "Config not found: $name" );
return;
}
$node = self::$config[$category][$field];
if ( !isset( $node['type'] ) ) {
$node['type'] = 'text';
}
if ( !isset( $node['pretty'] ) ) {
$node['pretty'] = $node;
}
if ( !isset( $node['default'] ) ) {
$node['default'] = '';
}
if ( !isset( $node['value'] ) ) {
$node['value'] = $node['default'];
}
if ( !isset( $node['protected'] ) ) {
$node['protected'] = false;
}
return $node;
}
/**
* Retrieves the config option for $name and if the result is bool, converts it to a string.
*
* @param {string} [$name] - Must be in <category>/<option> format.
* @return {WILD}
*/
public static function getString( $name ) {
$result = self::getValue( $name );
if ( is_bool( $result ) ) {
$result = ( $result ? 'true' : 'false' );
}
return $result;
}
public static function getValue( $name ) {
$node = self::get( $name );
if ( empty( $node ) ) {
return;
}
if ( !isset( $node['value'] ) ) {
Debug::warn( 'Node Value not set.' );
return;
}
return $node['value'];
}
public static function getDefault( $name ) {
$node = self::get( $name );
if ( empty( $node ) ) {
return;
}
if ( !isset( $node['default'] ) ) {
Debug::warn( 'Node default not set.' );
return;
}
return $node['default'];
}
}

View File

@ -1,56 +0,0 @@
<?php
/**
* core/controller.php
*
* The controller handles our main template and provides the
* model and view functions which are the backbone of the tempus
* project. Used to hold and keep track of many of the variables
* that support the applications execution.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Classes;
use TheTempusProject\Canary\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Session;
use TheTempusProject\Houdini\Classes\Issues;
class Controller {
public static $title = null;
public static $pageDescription = null;
public static $template = null;
/**
* Check for issues stored in sessions and add them to current issues.
*/
public static function checkSessions() {
$success = Session::checkFlash( 'success' );
$notice = Session::checkFlash( 'notice' );
$error = Session::checkFlash( 'error' );
$info = Session::checkFlash( 'info' );
if ( !empty( $success ) ) {
Issues::add( 'success', $success );
}
if ( !empty( $notice ) ) {
Issues::add( 'notice', $notice );
}
if ( !empty( $error ) ) {
Issues::add( 'error', $error );
}
if ( !empty( $info ) ) {
Issues::add( 'info', $info );
}
}
public function __construct() {
Debug::log( 'Controller Constructing: ' . get_class( $this ) );
self::checkSessions();
}
public function __destruct() {
Debug::log( 'Controller Destructing: ' . get_class( $this ) );
}
}

View File

@ -1,78 +0,0 @@
<?php
/**
* classes/custom_exception.php
*
* This class is used exclusively when throwing predefined exceptions.
* It will intercept framework thrown exceptions and deal with them however
* you choose; in most cases by logging them and taking appropriate responses
* such as redirecting to error pages.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Classes;
use Exception;
use TheTempusProject\Hermes\Functions\Redirect;
use TheTempusProject\Canary\Canary as Debug;
class CustomException extends Exception {
private $originFunction = null;
private $exceptionName = null;
private $originClass = null;
private $data = null;
/**
* This function allows the application to deal with errors
* in a dynamic way by letting you customize the response
*
* @param string $type - The type of the exception being called/thrown.
* @param string $data - Any additional data being passed with the exception.
*
* @example - throw new CustomException('model'); - Calls the model-missing exception
*/
public function __construct( $type, $data = null ) {
$this->originFunction = debug_backtrace()[1]['function'];
$this->originClass = debug_backtrace()[1]['class'];
$this->exceptionName = $type;
$this->data = $data;
switch ( $type ) {
case 'model':
Debug::error( 'Model not found: ' . $data );
break;
case 'dbConnection':
Debug::error( 'Error Connecting to the database: ' . $data );
break;
case 'DB':
Debug::error( 'Unspecified database error: ' . $data );
break;
case 'view':
Debug::error( 'View not found: ' . $data );
break;
case 'controller':
Debug::error( 'Controller not found: ' . $data );
Redirect::to( 404 );
break;
case 'defaultController':
Debug::error( 'DEFAULT Controller not found: ' . $data );
Redirect::to( 404 );
break;
case 'method':
Debug::error( 'Method not found: ' . $data );
Redirect::to( 404 );
break;
case 'simpleView':
Debug::error( 'View not found: ' . $data );
break;
case 'defaultMethod':
Debug::error( 'DEFAULT Method not found: ' . $data );
Redirect::to( 404 );
break;
default:
Debug::error( 'Default exception: ' . $data );
break;
}
}
}

View File

@ -1,745 +0,0 @@
<?php
/**
* classes/database.php
*
* Defines all interactions with the database.
*
* @todo - Add more than just MySQL
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Classes;
use PDO;
use PDOException;
use TheTempusProject\Houdini\Classes\Pagination;
use TheTempusProject\Canary\Canary as Debug;
class Database {
public static $instance = null;
private $pdo = null;
private $query = null;
private $error = false;
private $results = null;
private $count = 0;
private $maxQuery = 0;
private $totalResults = 0;
private $errorMessage = null;
private $tableBuff = null;
private $fieldBuff = null;
private $queryStatus = false;
/**
* Checks the DB connection with the provided information.
*
* @param string $host - Database Host.
* @param string $db - Database Name.
* @param string $user - Database Username.
* @param string $pass - Database Password.
*
* @return bool
*/
public static function check( $host = null, $db = null, $user = null, $pass = null ) {
if ( empty( $host ) || empty( $db ) || empty( $user ) || empty( $pass ) ) {
Debug::error( 'check::db: one or more parameters are missing.' );
return false;
}
try {
Debug::log( 'Attempting to connect to DB with supplied credentials.' );
$test = new PDO( 'mysql:host=' . $host . ';dbname=' . $db, $user, $pass );
} catch ( PDOException $Exception ) {
Debug::error( 'Cannot connect to DB with provided credentials: ' . $Exception->getMessage() );
return false;
}
return true;
}
/**
* Checks the current database in the configuration file for version verification.
*
* @return boolean
*
* @todo - Update this function to be more effective.
*/
public static function mysql() {
self::connect();
$dbVersion = self::$db->version();
preg_match( '@[0-9]+\.[0-9]+\.[0-9]+@', $dbVersion, $version );
if ( version_compare( $version[0], '10.0.0', '>' ) ) {
return true;
}
self::addError( "MySQL Version is too low! Current version is $version[0]. Version 10.0.0 or higher is required." );
return false;
}
/**
* Automatically open the DB connection with settings from our global config.
*/
private function __construct( $host = null, $name = null, $user = null, $pass = null ) {
Debug::debug( 'Class initialized: ' . get_class( $this ) );
if ( isset( $host ) && isset( $name ) && isset( $user ) && isset( $pass ) ) {
try {
Debug::log( 'Attempting to connect to DB with supplied credentials.' );
$this->pdo = new PDO( 'mysql:host=' . $host . ';dbname=' . $name, $user, $pass );
} catch ( PDOException $Exception ) {
$this->error = true;
$this->errorMessage = $Exception->getMessage();
}
}
if ( !$this->enabled() ) {
$this->error = true;
$this->errorMessage = 'Database disabled in config.';
}
if ( $this->error === false ) {
try {
Debug::debug( 'Attempting to connect to DB with config credentials.' );
$this->pdo = new PDO( 'mysql:host=' . Config::getValue( 'database/dbHost' ) . ';dbname=' . Config::getValue( 'database/dbName' ), Config::getValue( 'database/dbUsername' ), Config::getValue( 'database/dbPassword' ) );
} catch ( PDOException $Exception ) {
$this->error = true;
$this->errorMessage = $Exception->getMessage();
}
}
if ( $this->error !== false ) {
new CustomException( 'dbConnection', $this->errorMessage );
return;
}
$this->maxQuery = Config::getValue( 'database/dbMaxQuery' );
// @TODO add a toggle for this
$this->pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
Debug::debug( 'DB connection successful' );
return;
}
/**
* Checks whether the DB is enabled via the config file.
*
* @return bool - whether the db module is enabled or not.
*/
public function enabled( $type = '' ) {
if ( Config::getValue( 'database/dbEnabled' ) === true ) {
return true;
}
return false;
}
public function lastId() {
return $this->pdo->lastInsertId();
}
/**
* Checks to see if there is already a DB instance open, and if not; create one.
*
* @return function - Returns the PDO DB connection.
*/
public static function getInstance( $host = null, $name = null, $user = null, $pass = null, $new = false ) {
// used to force a new connection
if ( !empty( $host ) && !empty( $name ) && !empty( $user ) && !empty( $pass ) ) {
self::$instance = new self( $host, $name, $user, $pass );
}
if ( empty( self::$instance ) || $new ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Returns the DB version.
*
* @return bool|string
*/
public function version() {
if ( !$this->enabled() ) {
$this->error = true;
$this->errorMessage = 'Database disabled';
return false;
}
$sql = 'select version()';
if ( $this->query = $this->pdo->prepare( $sql ) ) {
try {
$this->query->execute();
} catch ( PDOException $Exception ) {
$this->error = true;
$this->errorMessage = $Exception->getMessage();
Debug::error( 'DB Version Error' );
Debug::error( $this->errorMessage );
return false;
}
return $this->query->fetchColumn();
}
return false;
}
/**
* Checks the database to see if the specified table exists.
*
* @param string $name - The name of the table to check for.
*
* @return boolean
*/
protected function tableExists( $name ) {
$name = Config::getValue( 'database/dbPrefix' ) . $name;
$this->raw( "SHOW TABLES LIKE '$name'" );
if ( $this->error ) {
Debug::error( var_export( $this->errorMessage, true ) );
return false;
}
if ( $this->count === 0 ) {
return false;
}
return true;
}
/**
* Checks first that the table exists, then checks if the specified
* column exists in the table.
*
* @param string $table - The table to search.
* @param string $column - The column to look for.
*
* @return boolean
*
* @todo - Is it necessary to check the current $fields list too?
*/
protected function columnExists( $table, $column ) {
if ( !$this->tableExists( $table ) ) {
return false;
}
$table = Config::getValue( 'database/dbPrefix' ) . $table;
$this->raw( "SHOW COLUMNS FROM `$table` LIKE '$column'" );
if ( !$this->error && $this->count === 0 ) {
return false;
}
return true;
}
/**
* Execute a raw DB query.
*
* @param string $data the query to execute
*
* @return bool
*/
public function raw( $data ) {
$this->queryReset();
if ( !$this->enabled() ) {
$this->error = true;
$this->errorMessage = 'Database disabled';
return false;
}
$this->query = $this->pdo->prepare( $data );
try {
$this->query->execute();
} catch ( PDOException $Exception ) {
$this->error = true;
$this->errorMessage = $Exception->getMessage();
Debug::warn( 'DB Raw Query Error' );
Debug::warn( $this->errorMessage );
return false;
}
// @todo i think this will cause an error some circumstances
$this->count = $this->query->rowCount();
return true;
}
/**
* The actual Query function. This function takes our setup queries
* and send them to the database. it then properly sets our instance
* variables with the proper info from the DB, as secondary constructor
* for almost all objects in this class.
*
* @param string $sql - The SQL to execute.
* @param array $params - Any bound parameters for the query.
*
* @return object
*/
public function query( $sql, $params = [], $noFetch = false ) {
$this->queryReset();
if ( $this->pdo == false ) {
Debug::warn( 'DB::query - no database connection established' );
$this->error = true;
$this->errorMessage = 'DB::query - no database connection established';
return $this;
}
$this->query = $this->pdo->prepare( $sql );
if ( !empty( $params ) ) {
$x = 0;
foreach ( $params as $param ) {
$x++;
if ( is_array( $param ) ) {
dv( $param );
}
$this->query->bindValue( $x, $param );
}
}
try {
$this->query->execute();
} catch ( PDOException $Exception ) {
$this->error = true;
$this->errorMessage = $Exception->getMessage();
Debug::error( 'DB Query Error' );
Debug::error( $this->errorMessage );
return $this;
}
if ( $noFetch === true ) {
$this->results = null;
$this->count = 1;
} else {
$this->results = $this->query->fetchAll( PDO::FETCH_OBJ );
$this->count = $this->query->rowCount();
}
return $this;
}
/**
* This function resets the values used for creating or modifying tables.
* Essentially a cleaner function.
*/
public function queryReset( $includeBuffers = false ) {
$this->results = null;
$this->count = 0;
$this->error = false;
$this->errorMessage = null;
$this->query = null;
if ( $includeBuffers ) {
$this->tableBuff = null;
$this->fieldBuff = null;
$this->queryStatus = false;
}
}
/**
* The action function builds all of our SQL.
*
* @todo : Clean this up.
*
* @param string $action - The type of action being carried out.
* @param string $tableName - The table name being used.
* @param array $where - The parameters for the action
* @param string $by - The key to sort by.
* @param string $direction - The direction to sort the results.
* @param array $limit - The result limit of the query.
*
* @return bool
*/
public function action( $action, $tableName, $where, $by = null, $direction = 'DESC', $reqLimit = null ) {
$this->totalResults = 0; // since this is how we paginate, it can't be reset when we exceed the max
if ( !$this->enabled() ) {
$this->error = true;
$this->errorMessage = 'Database disabled';
return $this;
}
$whereCount = count( $where );
if ( $whereCount < 3 ) {
Debug::error( 'DB::action - Not enough arguments supplied for "where" clause' );
$this->error = true;
$this->errorMessage = 'DB::action - Not enough arguments supplied for "where" clause';
return $this;
}
if ( $action == 'DELETE' ) {
$noFetch = true;
}
$tableName = Config::getValue( 'database/dbPrefix' ) . $tableName;
$sql = "{$action} FROM `{$tableName}` WHERE ";
$validOperators = ['=', '!=', '>', '<', '>=', '<=', 'LIKE', 'IS'];
$validDelimiters = ['AND', 'OR'];
$values = [];
while ( $whereCount > 2 ) {
$whereCount = $whereCount - 3;
$field = array_shift( $where );
$operator = array_shift( $where );
array_push( $values, array_shift( $where ) );
if ( !in_array( $operator, $validOperators ) ) {
Debug::error( 'DB::action - Invalid operator.' );
$this->error = true;
$this->errorMessage = 'DB::action - Invalid operator.';
return $this;
}
$sql .= "{$field} {$operator} ?";
if ( $whereCount > 0 ) {
$delimiter = array_shift( $where );
if ( !in_array( $delimiter, $validDelimiters ) ) {
Debug::error( 'DB::action - Invalid delimiter.' );
$this->error = true;
$this->errorMessage = 'DB::action - Invalid delimiter.';
return $this;
}
$sql .= " {$delimiter} ";
$whereCount--;
}
}
if ( isset( $by ) ) {
$sql .= " ORDER BY {$by} {$direction}";
}
$sqlPreLimit = $sql;
if ( !empty( $reqLimit ) ) {
$lim = implode(',',$reqLimit);
$sql .= " LIMIT {$lim}";
}
if ( isset( $values ) ) {
if ( !empty( $noFetch ) ) {
$error = $this->query( $sql, $values, true )->error();
} else {
$error = $this->query( $sql, $values )->error();
}
} else {
$error = $this->query( $sql )->error();
}
if ( $error ) {
Debug::warn( 'DB Action Error: ' );
Debug::warn( $this->errorMessage );
return $this;
}
$this->totalResults = $this->count;
if ( $this->count <= $this->maxQuery ) {
return $this;
}
Debug::warn( 'Query exceeded maximum results. Maximum allowed is ' . $this->maxQuery );
if ( !empty( $limit ) ) {
$newLimit = ( $reqLimit[0] + Pagination::perPage() );
$limit = " LIMIT {$reqLimit[0]},{$newLimit}";
} else {
$limit = ' LIMIT 0,' .Pagination::perPage();
}
$sql = $sqlPreLimit . $limit;
if ( isset( $values ) ) {
$error = $this->query( $sql, $values )->error();
} else {
$error = $this->query( $sql )->error();
}
if ( $error ) {
Debug::warn( 'DB Action Error: ' );
Debug::warn( $this->errorMessage );
}
return $this;
}
/**
* Function to insert into the DB.
*
* @param string $table - The table you wish to insert into.
* @param array $fields - The array of fields you wish to insert.
*
* @return bool
*/
public function insert( $table, $fields = [] ) {
$keys = array_keys( $fields );
$valuesSQL = null;
$x = 0;
$keysSQL = implode( '`, `', $keys );
foreach ( $fields as $value ) {
$x++;
$valuesSQL .= '?';
if ( $x < count( $fields ) ) {
$valuesSQL .= ', ';
}
}
$table = Config::getValue( 'database/dbPrefix' ) . $table;
$sql = "INSERT INTO `{$table}` (`" . $keysSQL . "`) VALUES ({$valuesSQL})";
if ( !$this->query( $sql, $fields, true )->error() ) {
return true;
}
return false;
}
/**
* Function to duplicate a database entry.
*
* @param string $table - The table you wish to duplicate the entry in.
* @param int $id - The ID of the entry you wish to duplicate.
*
* @return bool
*/
public function duplicateEntry($table, $id) {
// Get the original entry
$originalEntry = $this->action('SELECT', $table, ['ID', '=', $id])->results();
// Exclude the ID field
unset($originalEntry->ID);
// Insert the duplicated entry
if ($this->insert($table, (array) $originalEntry)) {
return true;
}
return false;
}
/**
* Function to update the database.
*
* @param string $table - The table you wish to update in.
* @param int $id - The ID of the entry you wish to update.
* @param array $fields - the various fields you wish to update
*
* @return bool
*/
public function update( $table, $id, $fields = [] ) {
$updateSQL = null;
$x = 0;
foreach ( $fields as $name => $value ) {
$x++;
$updateSQL .= "{$name} = ?";
if ( $x < count( $fields ) ) {
$updateSQL .= ', ';
}
}
$table = Config::getValue( 'database/dbPrefix' ) . $table;
$sql = "UPDATE {$table} SET {$updateSQL} WHERE ID = {$id}";
if ( !$this->query( $sql, $fields, true )->error() ) {
return true;
}
return false;
}
/**
* Deletes a series of, or a single instance(s) in the database.
*
* @param string $table - The table you are deleting from.
* @param string $where - The criteria for deletion.
*
* @return function
*/
public function delete( $table, $where ) {
return $this->action( 'DELETE', $table, $where );
}
/**
* Starts the object to create a new table if none already exists.
*
* NOTE: All tables created with this function will automatically
* have an 11 digit integer called ID added as a primary key.
*
* @param string $name - The name of the table you wish to create.
*
* @return boolean
*
* @todo - add a check for the name.
*/
public function newTable( $name, $addID = true ) {
if ( $this->tableExists( $name ) ) {
$this->tableBuff = null;
Debug::error( "Table already exists: $name" );
return false;
}
$this->queryReset( true );
$this->tableBuff = $name;
if ( $addID === true ) {
$this->addField( 'ID', 'int', 11, false );
}
return true;
}
/**
* Builds and executes a database query to to create a table
* using the current object's table name and fields.
*
* NOTE: By default: All tables have an auto incrementing primary key named 'ID'.
*
* @todo - Come back and add more versatility here.
*/
public function createTable() {
if ( empty( $this->tableBuff ) ) {
Debug::info( 'No Table set.' );
return false;
}
$table = Config::getValue( 'database/dbPrefix' ) . $this->tableBuff;
if ( $this->tableExists( $this->tableBuff ) ) {
Debug::error( "Table already exists: $table" );
return false;
}
$queryBuff = "CREATE TABLE `$table` (";
$x = 0;
$y = count( $this->fieldBuff );
while ( $x < $y ) {
$queryBuff .= $this->fieldBuff[$x];
$x++;
$queryBuff .= ( $x < $y ) ? ',' : '';
}
$queryBuff .= ') ENGINE=InnoDB DEFAULT CHARSET=latin1; ALTER TABLE `' . $table . '` ADD PRIMARY KEY (`ID`); ';
$queryBuff .= 'ALTER TABLE `' . $table . "` MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Primary index value';";
$this->queryStatus = ( $this->raw( $queryBuff ) ? true : false );
return $this->queryStatus;
}
public function removeTable( $name ) {
if ( !$this->tableExists( $name ) ) {
Debug::error( "No table exists: $name" );
return false;
}
$table = Config::getValue( 'database/dbPrefix' ) . $name;
$this->queryStatus = ( $this->raw( 'DROP TABLE `' . $table . '`' ) ? true : false );
return $this->queryStatus;
}
/**
* This function allows you to add a new field to be
* added to a previously specified table.
*
* @param string $name - The name of the field to add
* @param string $type - The type of field.
* @param integer $length - The maximum length value for the field.
* @param boolean $null - Whether or not the field can be null
* @param string $default - The default value to use for new entries if any.
* @param string $comment - DB comment for this field.
*
* @return boolean
*
* @todo - add more error reporting and checks
* use switch/cases?
*/
public function addField( $name, $type, $length, $null = true, $default = null, $comment = '' ) {
if ( empty( $this->tableBuff ) ) {
Debug::info( 'No Table set.' );
return false;
}
if ( $this->columnExists( $this->tableBuff, $name ) ) {
Debug::error( "Column already exists: $this->tableBuff > $name" );
return false;
}
if ( $null === true ) {
$sDefault = ' DEFAULT NULL';
} else {
$sDefault = ' NOT NULL';
if ( !empty( $default ) ) {
$sDefault .= " DEFAULT '$default'";
}
}
if ( !empty( $length ) ) {
if ( is_int( $length ) ) {
$sType = $type . '(' . $length . ')';
} elseif ( is_string( $length ) && ctype_digit( $length ) ) {
$sType = $type . '(' . $length . ')';
} else {
$sType = $type;
}
} else {
$sType = $type;
}
if ( !empty( $comment ) ) {
$sComment = " COMMENT '$comment'";
} else {
$sComment = '';
}
$this->fieldBuff[] = ' `' . $name . '` ' . $sType . $sDefault . $sComment;
return true;
}
public function search( $table, $column, $param ) {
return $this->action( 'SELECT *', $table, [$column, 'LIKE', '%' . $param . '%'] );
}
/**
* Selects data from the database.
*
* @param string $table - The table we wish to select from.
* @param string $where - The criteria we wish to select.
* @param string $by - The key we wish to order by.
* @param string $direction - The direction we wish to order the results.
*
* @return function
*/
public function get( $table, $where, $by = 'ID', $direction = 'DESC', $limit = null ) {
if ( $where === '*' ) {
$where = ['ID', '>=', '0'];
}
return $this->action( 'SELECT *', $table, $where, $by, $direction, $limit );
}
/**
* Selects data from the database and automatically builds the pagination filter for the results array.
*
* @param string $table - The table we wish to select from.
* @param string $where - The criteria we wish to select.
* @param string $by - The key we wish to order by.
* @param string $direction - The direction we wish to order the results.
*
* @return function
*/
public function getPaginated( $table, $where, $by = 'ID', $direction = 'DESC', $limit = null ) {
if ( $where === '*' ) {
$where = ['ID', '>=', '0'];
}
$db = $this->action( 'SELECT ID', $table, $where, $by, $direction );
Pagination::updatePaginationTotal( $this->totalResults );
if ( ! is_array( $limit ) ) {
$limit = [ Pagination::getMin(), Pagination::getMax() ];
}
Pagination::paginate();
return $this->action( 'SELECT *', $table, $where, $by, $direction, $limit );
}
/**
* Function for returning the entire $results array.
*
* @return array - Returns the current query's results.
*/
public function results() {
return $this->results;
}
/**
* Function for returning the first result in the results array.
*
* @return array - Returns the current first member of the results array.
*/
public function first() {
if ( !empty( $this->results[0] ) ) {
return $this->results[0];
}
return false;
}
/**
* Function for returning current results' row count.
*
* @return int - Returns the current instance's SQL result count.
*/
public function count() {
return $this->count;
}
/**
* Returns if there are errors with the current query or not.
*
* @return bool
*/
public function error() {
return $this->error;
}
/**
* Returns if there are errors with the current query or not.
*
* @return bool
*/
public function errorMessage() {
//$this->query->errorInfo();
return $this->errorMessage;
}
/**
* Returns the boolean status of the most recently executed query.
*
* @return boolean
*/
public function getStatus() {
return $this->queryStatus;
}
}

View File

@ -1,193 +0,0 @@
<?php
/**
* core/database_model.php
*
* The class provides some basic functionality for models that interact
* with the database.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Classes;
use TheTempusProject\Canary\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Bedrock;
class DatabaseModel extends Model {
public $databaseMatrix;
public $tableName;
public function __construct() {
parent::__construct();
}
public function enabled() {
if ( empty( $this->enabled ) ) {
$this->enabled = self::$db->enabled();
}
return $this->enabled;
}
public function filter( $data, $params = [] ) {
return $data;
}
/**
* This method will remove all the installed model components.
*
* @return bool - If the uninstall was completed without error
*/
public function uninstall() {
parent::uninstall();
$this->uninstallTable();
return true;
}
public function rowMatrixToArray( $row_matrix ) {
$row_array = [];
$row_array['row_name'] = array_shift( $row_matrix );
$row_array['row_type'] = array_shift( $row_matrix );
$row_array['length'] = array_shift( $row_matrix );
if ( !empty( $row_matrix ) ) {
$row_array['is_null'] = array_shift( $row_matrix );
} else {
$row_array['is_null'] = true;
}
if ( !empty( $row_matrix ) ) {
$row_array['default_value'] = array_shift( $row_matrix );
} else {
$row_array['default_value'] = null;
}
if ( !empty( $row_matrix ) ) {
$row_array['comment'] = array_shift( $row_matrix );
} else {
$row_array['comment'] = '';
}
return $row_array;
}
/**
* Install db tables needed for the model.
*
* @return {bool}
*/
public function installTable() {
// should have some sort of DELTA functionality and safeguards
if ( empty( $this->tableName ) || empty( $this->databaseMatrix )) {
Debug::log( 'databaseMatrix is empty' );
return true;
}
if ( false === self::$db->newTable( $this->tableName ) ) {
return false;
}
Debug::log( 'adding a new table named: ' . $this->tableName );
foreach ( $this->databaseMatrix as $key => $row_matrix ) {
$row = $this->rowMatrixToArray( $row_matrix );
self::$db->addField(
$row['row_name'],
$row['row_type'],
$row['length'],
$row['is_null'],
$row['default_value'],
$row['comment'],
);
}
self::$db->createTable();
return self::$db->getStatus();
}
public function uninstallTable() {
if ( empty( $this->tableName ) ) {
return;
}
return self::$db->removeTable( $this->tableName );
}
/**
* Retrieves a row by its ID and filters it.
*
* @param {int} [$id]
* @return {object} - The filtered db entry.
*/
public function findById( $id ) {
if ( !Check::id( $id ) ) {
Debug::warn( "$this->tableName fingByID: illegal ID: $id" );
return false;
}
$data = self::$db->get( $this->tableName, ['ID', '=', $id] );
if ( !$data->count() ) {
Debug::info( 'No ' . $this->tableName . ' data found.' );
return false;
}
return $this->filter( $data->first() );
}
/**
* Function to delete the specified entry.
*
* @param int|array $ID the log ID or array of ID's to be deleted
* @return bool
*/
public function delete( $idArray ) {
if ( !is_array( $idArray ) ) {
$idArray = [ $idArray ];
}
foreach ( $idArray as $id ) {
if ( !Check::id( $id ) ) {
Debug::info( "invalid ID: $id." );
$error = true;
continue;
}
if ( self::$db->delete( $this->tableName, [ 'ID', '=', $id ] )->error() ) {
Debug::info( "Error Deleting id: $id" );
$error = true;
continue;
}
Debug::info( $this->tableName . " deleted: $id" );
}
if ( !empty( $error ) ) {
return false;
}
return true;
}
/**
* Function to clear entries of a defined type.
*
* @todo this is probably dumb
* @param string $data - The log type to be cleared
* @return bool
*/
public function empty() {
self::$db->delete( $this->tableName, ['ID', '>=', '0'] );
Debug::info( $this->tableName . ' Cleared' );
return true;
}
/**
* retrieves a list of paginated (limited) results.
*
* @param array $filter - A filter to be applied to the list.
* @return bool|object - Depending on success.
*/
public function listPaginated( $filter = null ) {
$data = self::$db->getPaginated( $this->tableName, '*' );
if ( !$data->count() ) {
Debug::info( $this->tableName . ' - No entries found' );
return false;
}
return $this->filter( $data->results() );
}
public function list( $filter = null ) {
$data = self::$db->get( $this->tableName, '*' );
if ( !$data->count() ) {
Debug::info( $this->tableName . ' - No entries found' );
return false;
}
return $this->filter( $data->results() );
}
}

View File

@ -1,124 +0,0 @@
<?php
/**
* core/model.php
*
* The class provides some basic functionality for models.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Classes;
use TheTempusProject\Canary\Canary as Debug;
use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Classes\Database;
class Model {
public static $db;
public $configName;
public $configMatrix = [];
public $resourceMatrix = [];
public $modelVersion;
public $enabled = false;
/**
* The model constructor.
*/
public function __construct() {
Debug::debug( 'Model Constructed: ' . get_class( $this ) );
self::$db = Database::getInstance();
$this->load();
}
/**
* This method will remove all the installed model components.
*
* @return bool - If the uninstall was completed without error
*/
public function uninstall() {
$this->uninstallResources();
$this->uninstallConfigs();
return true;
}
/**
* Install resources needed for the model.
*
* @return {bool}
*/
public function installResources() {
// should have some sort of DELTA functionality and safeguards
$ids = [];
if ( empty($this->resourceMatrix) ) {
return true;
}
foreach ( $this->resourceMatrix as $entry ) {
foreach ( $entry as $key => $value ) {
if ( '{time}' == $value ) {
$entry[$key] = time();
}
}
self::$db->insert( $this->tableName, $entry );
$id = self::$db->lastId();
if ( $id ) {
$ids[] = $id;
}
}
return $ids;
}
public function uninstallResources() {
// this one needs some work
// should probably save the created resource ID's or something and remove them.
// presumably this isn't a big issue because i would imagine the table is removed
// there may be future instances where you can create resources for other tables
return true;
}
/**
* Install configs needed for the model.
*
* @return {bool}
*/
public function installConfigs() {
$config = new Config( CONFIG_JSON );
// should have some sort of DELTA functionality and safeguards
$config->addCategory( $this->configName );
foreach ( $this->configMatrix as $name => $details ) {
$config->add( $this->configName, $name, $details );
}
return $config->save();
}
public function uninstallConfigs() {
if ( empty( $this->configName ) ) {
return true;
}
$config = new Config( CONFIG_JSON );
return $config->removeCategory( $this->configName, true, true );
}
/**
* Tells the installer which types of integrations your model needs to install.
*
* @return bool - if the model was loaded without error
*/
public function load() {
return true;
}
public function getModelVersion() {
return $this->modelVersion;
}
/**
* Checks if the model is enabled.
*
* @return bool - if the model is enabled or not
*/
public function enabled() {
return $this->enabled;
}
}

View File

@ -1,28 +0,0 @@
{
"name": "thetempusproject/bedrock",
"type": "library",
"description": "Tempus project core is intended as the core code used by The Tempus Project: a rapid prototyping framework. This library utilizes the MVC architecture in addition to a custom templating engine designed to make building web applications simple.",
"license": "MIT",
"minimum-stability": "dev",
"keywords": ["templating","mvc","framework"],
"homepage": "https://TheTempusProject.com/Core",
"authors": [
{
"name": "Joey Kimsey",
"email": "Joey@thetempusproject.com",
"homepage": "https://TheTempusProject.com",
"role": "Lead Developer"
}
],
"require": {
"php": ">=5.4.0",
"thetempusproject/tempusdebugger": "3.0"
},
"autoload": {
"classmap": [
"classes",
"core",
"functions"
]
}
}

View File

@ -1,105 +0,0 @@
{
"main": {
"logo": {
"type": "file",
"pretty": "Site Logo (Used mostly in emails)",
"default": "images/logo.png",
"value": "images/logo.png"
},
"name": {
"type": "text",
"pretty": "Site Name",
"default": "TTP Example",
"value": "TTP Example"
},
"template": {
"type": "text",
"pretty": "Default Site Template",
"default": "default",
"value": "default"
},
"tokenEnabled": {
"type": "radio",
"pretty": "Enable CSRF Token for all forms.",
"default": true,
"value": true
}
},
"uploads": {
"files": {
"type": "radio",
"pretty": "Enable File Uploads",
"default": true,
"value": true
},
"images": {
"type": "radio",
"pretty": "Enable Image Uploads",
"default": true,
"value": true
},
"maxFileSize": {
"type": "text",
"pretty": "Maximum File Size",
"default": 5000000,
"value": 5000000
},
"maxImageSize": {
"type": "text",
"pretty": "Maximum Image Size",
"default": 500000,
"value": 500000
}
},
"database": {
"dbEnabled": {
"type": "radio",
"pretty": "Database Enabled",
"default": true,
"protected": true,
"value": true
},
"dbHost": {
"type": "text",
"pretty": "Database Host (IE: http://localhost:3306)",
"default": "127.0.0.1",
"protected": true,
"value": "127.0.0.1"
},
"dbMaxQuery": {
"type": "text",
"pretty": "Maximum results per query",
"default": 100,
"protected": true,
"value": 100
},
"dbName": {
"type": "text",
"pretty": "Database Name",
"default": "ttp-example",
"protected": true,
"value": "ttp-example"
},
"dbPassword": {
"type": "text",
"pretty": "Database Password",
"default": "",
"protected": true,
"value": ""
},
"dbPrefix": {
"type": "text",
"pretty": "Database table Prefix",
"default": "TTP_",
"protected": true,
"value": "TTP_"
},
"dbUsername": {
"type": "text",
"pretty": "Database Username",
"default": "root",
"protected": true,
"value": "root"
}
}
}

View File

@ -1,205 +0,0 @@
<?php
// Check
if (!defined('MINIMUM_PHP_VERSION')) {
define('MINIMUM_PHP_VERSION', 8.2);
}
if (!defined('DATA_TITLE_PREG')) {
define('DATA_TITLE_PREG', '#^[a-z 0-9\-\_ ]+$#mi');
}
if (!defined('REDIRECT_PREG_REQS')) {
define('REDIRECT_PREG_REQS', '#^[a-zA-Z0-9\-\_\./]+$#mi');
}
if (!defined('PATH_PREG_REQS')) {
define('PATH_PREG_REQS', '#^[^/?*:;\\{}]+$#mi');
}
if (!defined('SIMPLE_NAME_PREG')) {
define('SIMPLE_NAME_PREG', '#^[a-zA-Z0-9\-\_]+$#mi');
}
if (!defined('ALLOWED_IMAGE_UPLOAD_EXTENTIONS')) {
define('ALLOWED_IMAGE_UPLOAD_EXTENTIONS', [".jpg",".jpeg",".gif",".png"]);
}
if (!defined('MINIMUM_PASSWORD_LENGTH')) {
define('MINIMUM_PASSWORD_LENGTH', 8);
}
if (!defined('MAXIMUM_PASSWORD_LENGTH')) {
define('MAXIMUM_PASSWORD_LENGTH', 24);
}
if (!defined('ADDITIONAL_PASSWORD_REGEX')) {
// define('ADDITIONAL_PASSWORD_REGEX', '#^[a-z 0-9\-\_ ]+$#mi');
define('ADDITIONAL_PASSWORD_REGEX', '#^[a-z0-9\~\_\+\=\.\,\<\>\(\)\#\?\!\@\$\%\^\&\*\-\ ]+$#mi');
}
if (!defined('SESSION_NAME_REGEX')) {
define('SESSION_NAME_REGEX', '#^[a-zA-Z0-9\_\-]+$#mi');
}
// Cookies
if (!defined('DEFAULT_COOKIE_EXPIRATION')) {
define('DEFAULT_COOKIE_EXPIRATION', 604800);
}
if (!defined('DEFAULT_COOKIE_PREFIX')) {
define('DEFAULT_COOKIE_PREFIX', 'TTP_BEDROCK_');
}
// Database
if (!defined('MAX_RESULTS_PER_PAGE')) {
define('MAX_RESULTS_PER_PAGE', 50);
}
if (!defined('DEFAULT_RESULTS_PER_PAGE')) {
define('DEFAULT_RESULTS_PER_PAGE', 10);
}
// Debug
// Log Levels
if ( ! defined('CANARY_DEBUG_LEVEL_ERROR' ) ) {
define( 'CANARY_DEBUG_LEVEL_ERROR', 'error' );
}
if ( ! defined('CANARY_DEBUG_LEVEL_WARN' ) ) {
define( 'CANARY_DEBUG_LEVEL_WARN', 'warn' );
}
if ( ! defined('CANARY_DEBUG_LEVEL_INFO' ) ) {
define( 'CANARY_DEBUG_LEVEL_INFO', 'info' );
}
if ( ! defined('CANARY_DEBUG_LEVEL_LOG' ) ) {
define( 'CANARY_DEBUG_LEVEL_LOG', 'log' );
}
if ( ! defined('CANARY_DEBUG_LEVEL_DEBUG' ) ) {
define( 'CANARY_DEBUG_LEVEL_DEBUG', 'debug' );
}
if (!defined('CANARY_ENABLED')) {
define('CANARY_ENABLED', false);
}
if (!defined('DEBUG_EMAIL')) {
define('DEBUG_EMAIL', 'webmaster@' . $_SERVER['HTTP_HOST']);
}
if (!defined('HERMES_REDIRECTS_ENABLED')) {
define('HERMES_REDIRECTS_ENABLED', true);
}
if (!defined('RENDERING_ENABLED')) {
define('RENDERING_ENABLED', true);
}
if (!defined('CANARY_TRACE_ENABLED')) {
define('CANARY_TRACE_ENABLED', false);
}
if (!defined('CANARY_DEBUG_TO_CONSOLE')) {
define('CANARY_DEBUG_TO_CONSOLE', false);
}
if (!defined('CANARY_DEBUG_TO_FILE')) {
define('CANARY_DEBUG_TO_FILE', false);
}
if (!defined('CANARY_DEBUG_TO_FILE_LEVEL')) {
define('CANARY_DEBUG_TO_FILE_LEVEL', CANARY_DEBUG_LEVEL_ERROR);
}
// Directories
if (!defined('BEDROCK_ROOT_DIRECTORY')) {
define('BEDROCK_ROOT_DIRECTORY', dirname(__DIR__) . DIRECTORY_SEPARATOR);
}
if (!defined('BEDROCK_CONFIG_DIRECTORY')) {
define('BEDROCK_CONFIG_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR);
}
if (!defined('BEDROCK_BIN_DIRECTORY')) {
define('BEDROCK_BIN_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'bin' . DIRECTORY_SEPARATOR);
}
if (!defined('BEDROCK_RESOURCES_DIRECTORY')) {
define('BEDROCK_RESOURCES_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'resources' . DIRECTORY_SEPARATOR);
}
if (!defined('BEDROCK_VIEW_DIRECTORY')) {
define('BEDROCK_VIEW_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'views' . DIRECTORY_SEPARATOR);
}
if (!defined('BEDROCK_ERRORS_DIRECTORY')) {
define('BEDROCK_ERRORS_DIRECTORY', BEDROCK_VIEW_DIRECTORY . 'errors' . DIRECTORY_SEPARATOR);
}
if (!defined('BEDROCK_CLASSES_DIRECTORY')) {
define('BEDROCK_CLASSES_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'classes' . DIRECTORY_SEPARATOR);
}
if (!defined('BEDROCK_FUNCTIONS_DIRECTORY')) {
define('BEDROCK_FUNCTIONS_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'functions' . DIRECTORY_SEPARATOR);
}
if (!defined('BEDROCK_CONFIG_JSON')) {
define('BEDROCK_CONFIG_JSON', BEDROCK_CONFIG_DIRECTORY . 'config.json');
}
// Shared Directories
if (!defined('APP_ROOT_DIRECTORY')) {
define('APP_ROOT_DIRECTORY', BEDROCK_ROOT_DIRECTORY);
}
if (!defined('CONFIG_DIRECTORY')) {
define('CONFIG_DIRECTORY', BEDROCK_CONFIG_DIRECTORY);
}
if (!defined('BIN_DIRECTORY')) {
define('BIN_DIRECTORY', BEDROCK_BIN_DIRECTORY);
}
if (!defined('VIEW_DIRECTORY')) {
define('VIEW_DIRECTORY', BEDROCK_VIEW_DIRECTORY);
}
if (!defined('ERRORS_DIRECTORY')) {
define('ERRORS_DIRECTORY', BEDROCK_ERRORS_DIRECTORY);
}
if (!defined('CLASSES_DIRECTORY')) {
define('CLASSES_DIRECTORY', BEDROCK_CLASSES_DIRECTORY);
}
if (!defined('FUNCTIONS_DIRECTORY')) {
define('FUNCTIONS_DIRECTORY', BEDROCK_FUNCTIONS_DIRECTORY);
}
if (!defined('RESOURCES_DIRECTORY')) {
define('RESOURCES_DIRECTORY', BEDROCK_RESOURCES_DIRECTORY);
}
if (!defined('TEMPLATE_DIRECTORY')) {
define('TEMPLATE_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'templates' . DIRECTORY_SEPARATOR);
}
if (!defined('UPLOAD_DIRECTORY')) {
define('UPLOAD_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'uploads' . DIRECTORY_SEPARATOR);
}
if (!defined('IMAGE_UPLOAD_DIRECTORY')) {
define('IMAGE_UPLOAD_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'images' . DIRECTORY_SEPARATOR);
}
// Files
if (!defined('COMPOSER_JSON_LOCATION')) {
define('COMPOSER_JSON_LOCATION', APP_ROOT_DIRECTORY . 'composer.json');
}
if (!defined('COMPOSER_LOCK_LOCATION')) {
define('COMPOSER_LOCK_LOCATION', APP_ROOT_DIRECTORY . 'composer.lock');
}
if (!defined('CONFIG_JSON')) {
define('CONFIG_JSON', CONFIG_DIRECTORY . 'config.json');
}
// Other
if (!defined('DEFAULT_CONTROLLER_CLASS')) {
define('DEFAULT_CONTROLLER_CLASS', 'Home');
}
if (!defined('DEFAULT_CONTROLLER_METHOD')) {
define('DEFAULT_CONTROLLER_METHOD', 'index');
}
if (!defined('EMAIL_FROM_EMAIL')) {
define('EMAIL_FROM_EMAIL', 'noreply@' . $_SERVER['HTTP_HOST']);
}
if (!defined('DEFAULT_TIMEZONE')) {
define('DEFAULT_TIMEZONE', "America/New_York");
}
if (!defined('DEFAULT_DATE_FORMAT')) {
define('DEFAULT_DATE_FORMAT', "F j, Y");
}
if (!defined('DEFAULT_TIME_FORMAT')) {
define('DEFAULT_TIME_FORMAT', "g:i:s A");
}
// Random
if (!defined('KB')) {
define('KB', 1024);
}
if (!defined('MB')) {
define('MB', 1048576);
}
if (!defined('GB')) {
define('GB', 1073741824);
}
if (!defined('TB')) {
define('TB', 1099511627776);
}
// Sessions
if (!defined('DEFAULT_SESSION_PREFIX')) {
define('DEFAULT_SESSION_PREFIX', 'TTP_BEDROCK_');
}
// Token
if (!defined('DEFAULT_TOKEN_NAME')) {
define('DEFAULT_TOKEN_NAME', 'TTP_BEDROCK_SESSION_TOKEN');
}
if (!defined('TOKEN_ENABLED')) {
define('TOKEN_ENABLED', true);
}
# Tell the app all constants have been loaded.
define( 'BEDROCK_CONSTANTS_LOADED', true );

View File

@ -1,541 +0,0 @@
<?php
/**
* functions/check.php
*
* This class is used to test various inputs.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Functions;
use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Canary\Canary as Debug;
class Check {
private static $formValidator = null;
private static $errorLog = [];
private static $errorLogFull = [];
private static $errorLogUser = [];
/**
* This function only logs an error for the user-error-log.
* Primarily used for providing generalized form feedback
*
* @param {string} [$error] - The error information to be added to the list.
*/
public static function addUserError( $error, $data = false ) {
if ( false !== $data ) {
$error .= ' Data: ' . var_export( $data, true );
}
self::$errorLogUser[] = $error;
}
/**
* Function to properly document and handle any errors we encounter in the check.
*
* @param {string} [$error] - The error information to be added to the list, and used in debug info.
* @param string|array $data - Any additional variables or information.
*/
public static function addError( $error, $data = null ) {
/**
* If an array is provided for $error, it is split into
* 2 separate errors for the logging.
*/
if ( is_array( $error ) ) {
$userError = $error[1];
$error = $error[0];
}
Debug::info( "Check error: $error" );
if ( !empty( $data ) ) {
Debug::info( 'Additional error information:' );
Debug::v( $data );
}
self::$errorLog[] = ['errorInfo' => $error, 'errorData' => $data];
if ( isset( $userError ) ) {
self::$errorLogUser[] = $userError;
}
}
/**
* Function for returning the system error array.
*
* @param $full - Flag for returning the full error log.
* @return array - Returns an Array of all the failed checks up until this point.
*/
public static function systemErrors( $full = false ) {
if ( $full ) {
return self::$errorLogFull;
}
return self::$errorLog;
}
/**
* Function for returning the user error array.
*
* @return array - Returns an Array of all the recorded user errors.
*/
public static function userErrors() {
return self::$errorLogUser;
}
/**
* Function for resetting the current error logs and adding the old log
* to the complete error log.
*/
public static function errorReset() {
self::$errorLogFull = array_merge( self::$errorLogFull, self::$errorLog );
self::$errorLog = [];
self::$errorLogUser = [];
}
/**
* Checks an uploaded image for proper size, formatting, and lack of errors in the upload.
*
* @param string $data - The name of the upload field.
* @return {bool}
*/
public static function imageUpload( $imageName ) {
if ( !Config::getValue( 'uploads/images' ) ) {
self::addError( 'Image uploads are disabled.' );
return false;
}
if ( !isset( $_FILES[$imageName] ) ) {
self::addError( 'File not found.', $imageName );
return false;
}
if ( $_FILES[$imageName]['error'] != 0 ) {
self::addError( 'File error:' . $_FILES[$imageName]['error'] );
return false;
}
if ( $_FILES[$imageName]['size'] > Config::getValue( 'uploads/maxImageSize' ) ) {
self::addError( 'Image is too large.' );
return false;
}
$fileType = strrchr( $_FILES[$imageName]['name'], '.' );
if ( !( in_array( $fileType, ALLOWED_IMAGE_UPLOAD_EXTENTIONS ) ) ) {
self::addError( 'Invalid image type', $fileType );
return false;
}
return true;
}
/**
* Checks a string for a boolean string value.
*
* @param string $data - The data being checked.
* @return {bool}
*/
public static function tf( $data ) {
if ( true === $data || '1' === $data || 1 === $data || strtolower( $data ) === 'true' ) {
return true;
}
if ( false === $data || '0' === $data || 0 === $data || strtolower( $data ) === 'false' ) {
return true;
}
self::addError( 'Invalid true-false: ', $data );
return false;
}
/**
* Checks for alpha-numeric type.
*
* @param string $data - The data being checked.
* @return {bool}
*/
public static function alnum( $data ) {
if ( ctype_alpha( $data ) ) {
return true;
}
self::addError( 'Invalid alpha-numeric.', $data );
return false;
}
/**
* Checks an input for spaces.
*
* @param string $data - The data being checked.
* @return {bool}
*/
public static function nospace( $data ) {
if ( !stripos( $data, ' ' ) ) {
return true;
}
self::addError( 'Invalid no-space input.', $data );
return false;
}
/**
* Checks the data to see if it is a digit.
*
* @param mixed $data - Data being checked.
* @return {bool}
*/
public static function id( $data ) {
if ( is_numeric( $data ) ) {
return true;
}
self::addError( 'Invalid ID.', $data );
return false;
}
/**
* Checks the data to see if it is a valid data string. It can
* only contain letters, numbers, space, underscore, and dashes.
*
* @param mixed $data - Data being checked.
* @return {bool}
*/
public static function dataTitle( $data ) {
if ( preg_match( DATA_TITLE_PREG, $data ) ) {
return true;
}
self::addError( 'Invalid data title.', $data );
return false;
}
/**
* Checks the data to see if there are any illegal characters
* in the filename.
*
* @param {string} [$data]
* @return {bool}
*/
public static function path( $data = null ) {
if ( preg_match( REDIRECT_PREG_REQS, $data ) ) {
return true;
}
self::addError( 'Invalid path.', $data );
return false;
}
/**
* Checks the form token.
*
* @param {string|null} - String to check for the token. (Post Token assumed)
* @return {bool}
*/
public static function token( $data = null ) {
if ( false === Token::isTokenEnabled() ) {
return true;
}
if ( empty( $data ) ) {
$data = Input::post( 'token' );
}
$result = Token::check( $data );
if ( $result === false ) {
self::addUserError( 'Invalid Token.', $data );
}
return $result;
}
/**
* Checks for proper url formatting.
*
* @param {string} [$data] The input being checked
* @return {bool}
*/
public static function url( $data ) {
$url = filter_var( $data, FILTER_SANITIZE_URL );
if ( filter_var( $url, FILTER_VALIDATE_URL ) === false ) {
self::addError( 'Invalid Url' );
return false;
}
return true;
}
/**
* Checks email formatting.
*
* @param {string} [$data] - The string being tested.
* @return {bool}
*/
public static function email( $data ) {
$sanitizedEmail = filter_var( $data, FILTER_SANITIZE_EMAIL );
if ( !filter_var( $sanitizedEmail, FILTER_VALIDATE_EMAIL ) ) {
self::addError( 'Email is not properly formatted.' );
return false;
}
return true;
}
/**
* Checks password formatting.
*
* @param {string} [$password] - The string being tested.
* @param {string} [$secondaryPassword] - The string it is being compared to.
* @return {bool}
*/
public static function password( $password, $secondaryPassword = null ) {
if ( strlen( $password ) < MINIMUM_PASSWORD_LENGTH ) {
self::addError([
'Password is too short.',
'Password must be longer than ' . MINIMUM_PASSWORD_LENGTH . ' characters.',
]);
return false;
}
if ( strlen( $password ) > MAXIMUM_PASSWORD_LENGTH ) {
self::addError([
'Password is too long.',
'Password must not be longer than ' . MAXIMUM_PASSWORD_LENGTH . ' characters.',
]);
return false;
}
if ( defined( 'ADDITIONAL_PASSWORD_REGEX' ) ) {
if ( !preg_match( ADDITIONAL_PASSWORD_REGEX, $password ) ) {
self::addError([
'Password does not pass requirements.',
]);
return false;
}
}
if ( isset( $secondaryPassword ) && $password !== $secondaryPassword ) {
self::addError( 'Passwords do not match.' );
return false;
}
return true;
}
/**
* Checks name formatting.
*
* Requirements:
* - 2 - 20 characters long
* - must only contain letters: [A-Z] , [a-z]
*
* @param {string} [$data] - The string being tested.
* @return {bool}
*/
public static function name( $data ) {
if ( strlen( $data ) > 20 ) {
self::addError( 'Name is too long.', $data );
return false;
}
if ( strlen( $data ) < 2 ) {
self::addError( 'Name is too short.', $data );
return false;
}
if ( !ctype_alpha( str_replace( ' ', '', $data ) ) ) {
self::addError( 'Name is not properly formatted.', $data );
return false;
}
return true;
}
/**
* Checks for alpha-numeric type.
*
* @param {string} [$data] - The data being checked.
* @return {bool}
*/
public static function uploads() {
if ( ini_get( 'file_uploads' ) == 1 ) {
return true;
}
self::addError( 'Uploads are disabled.' );
return false;
}
/**
* Checks the PHP version.
*
* @return {bool}
*/
public static function php() {
$phpVersion = phpversion();
if ( version_compare( $phpVersion, MINIMUM_PHP_VERSION, '>=' ) ) {
return true;
}
self::addError( 'PHP version is too old.', $phpVersion );
return false;
}
/**
* Checks PHP's mail function.
*
* @return {bool}
*/
public static function mail() {
if ( function_exists( 'mail' ) ) {
return true;
}
self::addError( 'PHP Mail function is not enabled.' );
return false;
}
/**
* Checks if PHP's Safe mode is enabled.
*
* @return {bool}
*/
public static function safe() {
if ( !ini_get( 'safe_mode' ) ) {
return true;
}
self::addError( 'PHP Safe Mode is enabled.' );
return false;
}
/**
* Checks if PHP's Safe mode is enabled.
* @todo - come back and make this more variable
* pdo_firebird
* pdo_informix
* pdo_mssql
* pdo_oci
* pdo_oci8
* pdo_odbc
* pdo_pgsql
* @return {bool}
*/
public static function phpExtensions() {
if ( !extension_loaded( 'pdo' ) ) {
self::addError( 'PHP PDO is not enabled.' );
return false;
}
if ( extension_loaded( 'pdo_mysql' ) ) {
return true;
} elseif ( extension_loaded( 'pdo_sqlite' ) ) {
return true;
}
self::addError( 'No usable PDO extension is loaded.' );
return false;
}
/**
* Checks to make sure sessions are working properly.
*
* @return {bool}
*/
public static function sessions() {
$_SESSION['sessionTest'] = 1;
if ( !empty( $_SESSION['sessionTest'] ) ) {
unset( $_SESSION['sessionTest'] );
return true;
}
self::addError( 'There is an error with saving sessions.' );
return false;
}
/**
* Checks to see if cookies are enabled.
*
* @return {bool}
*/
public static function cookies() {
Cookie::put( 'test', 'test' );
if ( count( $_COOKIE ) > 0 ) {
Cookie::delete( 'test' );
return true;
}
self::addError( 'Cookies are not enabled.' );
return false;
}
/**
* Checks to see if $data contains only numbers, letters, underscores, and dashes
*
* @return {bool}
*/
public static function simpleName( $data ) {
if ( empty( $data ) ) {
self::addError( 'Empty simple name.', $data );
return false;
}
if ( preg_match( SIMPLE_NAME_PREG, $data ) ) {
return true;
}
self::addError( 'Invalid simple name.', $data );
return false;
}
/**
* Checks to see if the server is running an Nginx configuration.
*
* @return {bool}
*/
public static function isApache() {
if ( isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
if ( false !== stripos( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) ) {
return true;
}
}
return false;
}
/**
* Checks to see if the Apache server has the appropriate modules enabled.
*
* @return {bool}
*/
public static function apacheMods() {
if ( !self::isApache() ) {
self::addError( 'Server is not Apache.' );
return false;
}
$error_log = count( self::$errorLog );
$mods = apache_get_modules();
if ( !in_array( 'mod_rewrite', $mods ) ) {
self::addError( 'The Apache "rewrite" module is disabled.', $data );
}
if ( !in_array( 'mod_buffer', $mods ) ) {
self::addError( 'The Apache "buffer" module is disabled.', $data );
}
if ( !in_array( 'mod_headers', $mods ) ) {
self::addError( 'The Apache "header" module is disabled.', $data );
}
if ( !in_array( 'mod_alias', $mods ) ) {
self::addError( 'The Apache "alias" module is disabled.', $data );
}
if ( !in_array( 'mod_dir', $mods ) ) {
self::addError( 'The Apache "dir" module is disabled.', $data );
}
if ( !in_array( 'mod_expires', $mods ) ) {
self::addError( 'The Apache "expires" module is disabled.', $data );
}
if ( count( self::$errorLog ) > $error_log ) {
return false;
}
return true;
}
/**
* Checks to see if the server is running an Apache configuration.
*
* @return {bool}
*/
public static function isNginx() {
if ( isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
if ( false !== stripos( $_SERVER['SERVER_SOFTWARE'], 'Nginx' ) ) {
return true;
}
}
return false;
}
/**
* Checks the data to see if it is a valid data string. It can
* only contain letters, numbers, space, underscore, and dashes.
*
* @param mixed $data - Data being checked.
* @return {bool}
*/
public static function sessionName( $data ) {
if ( preg_match( SESSION_NAME_REGEX, $data ) ) {
return true;
}
self::addError( 'Invalid session title.', $data );
return false;
}
}

View File

@ -1,51 +0,0 @@
<?php
/**
* functions/code.php
*
* This class is used for creation of custom codes used by the application.
*
* @todo Better code generation.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Functions;
use TheTempusProject\Canary\Canary as Debug;
class Code {
/**
* Generates a new confirmation code.
*
* @return string
*/
public static function genConfirmation() {
$code = md5( uniqid() );
Debug::log( "Code Generated: Confirmation: $code" );
return $code;
}
/**
* Generates a new install hash.
*
* @return string
*/
public static function genInstall() {
$code = md5( uniqid() );
Debug::log( "Code Generated: Token: $code" );
return $code;
}
/**
* Generates a new token code.
*
* @return string
*/
public static function genToken() {
$code = md5( uniqid() );
Debug::log( "Code Generated: Token: $code" );
return $code;
}
}

View File

@ -1,95 +0,0 @@
<?php
/**
* functions/cookie.php
*
* This class is used for manipulation of cookies.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Functions;
use TheTempusProject\Canary\Canary as Debug;
class Cookie {
/**
* Checks whether $data is a valid saved cookie or not.
*
* @param {string} [$data] - Name of the cookie to check for.
* @return {bool}
*/
public static function exists( $data ) {
if ( !Check::dataTitle( $data ) ) {
return false;
}
$cookieName = DEFAULT_COOKIE_PREFIX . $data;
if ( isset( $_COOKIE[$cookieName] ) ) {
Debug::log( "Cookie found: $data" );
return true;
}
Debug::info( "Cookie not found: $data" );
return false;
}
/**
* Returns a specific cookie if it exists.
*
* @param {string} [$data] - Cookie to retrieve data from.
* @return {bool|string} - String from the requested cookie, or false if the cookie does not exist.
*/
public static function get( $data ) {
if ( !Check::dataTitle( $data ) ) {
return false;
}
if ( self::exists( $data ) ) {
$cookieName = DEFAULT_COOKIE_PREFIX . $data;
return $_COOKIE[$cookieName];
}
return false;
}
/**
* Create cookie function.
*
* @param {string} [$name] - Cookie name.
* @param {string} [$value] - Cookie value.
* @param {int} [$expiry] - How long (in seconds) until the cookie should expire.
* @return {bool}
*/
public static function put( $name, $value, $expire = null ) {
if ( ! Check::dataTitle( $name ) ) {
return false;
}
if ( ! $expire ) {
$expire = time() + DEFAULT_COOKIE_EXPIRATION;
}
if ( ! Check::ID( $expire ) ) {
return false;
}
$cookieName = DEFAULT_COOKIE_PREFIX . $name;
$test = setcookie( $cookieName, $value, $expire, '/' );
if ( ! $test ) {
Debug::error( "Cookie not created: '$name', until: $expire" );
return false;
}
Debug::debug( "Cookie Created: $name till $expire" );
return true;
}
/**
* Delete cookie function.
*
* @param {string} [$name] - Name of cookie to be deleted.
*/
public static function delete( $name ) {
if ( !Check::dataTitle( $name ) ) {
return false;
}
$cookieName = DEFAULT_COOKIE_PREFIX . $name;
setcookie( $cookieName, '', ( time() - 1 ), '/' );
Debug::log( "Cookie deleted: $name" );
return true;
}
}

View File

@ -1,408 +0,0 @@
<?php
/**
* functions/date.php
*
* This class is used to manage date inputs in a site-wide repeatable way.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Functions;
use DateTime;
use DateTimeZone;
class Date {
private static $date = null;
private static $errorLog = [];
private static $errorLogFull = [];
private static $errorLogUser = [];
public static function formatTimestamp( $type, $timestamp ) {
if ( stripos( $type, 'date' ) ) {
$dateFormat = self::getDateFormat();
} elseif ( stripos( $type, 'time' ) ) {
$dateFormat = self::getTimeFormat();
} else {
$dateFormat = self::getDateFormat() . ' ' . self::getTimeFormat();
}
$time = intval( $timestamp );
$dt = new DateTime( self::getTimezone() );
$dt->setTimestamp( $time );
return $dt->format( $dateFormat );
}
public static function applyTimezoneToTimestamp( $timestamp ) {
$timestamp = intval( $timestamp );
$date = new DateTime();
$date->setTimestamp( $timestamp );
$timezone = new DateTimeZone( self::getTimezone() );
$date->setTimezone( $timezone );
$formattedDate = $date->format('Y-m-d H:i:s');
return $formattedDate;
}
public static function applyUtcToDate( $date ) {
$timestamp = intval( strtotime( $date ) );
$startDate = new DateTime( $date, new DateTimeZone( self::getTimezone() ) );
$startDate->setTimezone( new DateTimeZone( 'UTC' ) );
$firstSecond = $startDate->getTimestamp();
return $firstSecond;
}
public static function getReadableDate( $timestamp, $with_timezone = false ) {
if ( $with_timezone ) {
$date = new DateTime();
$date->setTimestamp( $timestamp );
$timezone = new DateTimeZone( self::getTimezone() );
$date->setTimezone( $timezone );
$formattedDate = $date->format('Y-m-d H:i:s');
return $formattedDate;
}
return date( 'Y-m-d H:i:s', $timestamp );
}
public static function convertToTimestampWithTimezone( $dateString, $timeString, $timezoneString ) {
$datetimeString = $dateString . ' ' . $timeString;
$date = new DateTime($datetimeString, new DateTimeZone($timezoneString));
$timestamp = $date->getTimestamp();
return $timestamp;
}
public static function getDateBreakdown( $timestamp, $with_timezone = false ) {
$timestamp = intval( $timestamp );
$init = date('Y-m-d H:i:s', $timestamp);
if ( true === $with_timezone ) {
$readableDate = self::applyTimezoneToTimestamp( $timestamp );
} else {
$readableDate = date('Y-m-d H:i:s', $timestamp);
}
$date = date( 'Y-m-d', strtotime( $readableDate ) );
$time = date( 'H:i', strtotime( $readableDate ) );
return [
'time' => $time,
'date' => $date,
];
}
public static function determineDateInput( $with_timezone = false) {
$currentTimestamp = time();
$currentDateString = date( 'F d, Y', $currentTimestamp );
// Prioritize inputs: Post > Get > defaults
if ( Input::exists('time') ) {
$time = Input::post('time') ? Input::post('time') : Input::get('time');
} else {
$time = '00:00';
}
if ( Input::exists('date') ) {
$date = Input::post('date') ? Input::post('date') : Input::get('date');
} else {
$date = $currentDateString;
}
if ( Input::exists('hour') ) {
$hour = Input::post('hour') ? Input::post('hour') : Input::get('hour');
} else {
$hour = '00';
}
if ( Input::exists('minute') ) {
$minute = Input::post('minute') ? Input::post('minute') : Input::get('minute');
} else {
$minute = '00';
}
if ( Input::exists('day') ) {
$day = Input::post('day') ? Input::post('day') : Input::get('day');
} else {
$day = date( 'd', $currentTimestamp );
}
if ( Input::exists('month') ) {
$month = Input::post('month') ? Input::post('month') : Input::get('month');
} else {
$month = date( 'M', $currentTimestamp );
}
if ( Input::exists('year') ) {
$year = Input::post('year') ? Input::post('year') : Input::get('year');
} else {
$year = date( 'Y', $currentTimestamp );
}
// prioritize a time input over individual hours and minutes
if ( '00:00' == $time ) {
$time = $hour . ':' . $minute;
}
// prioritize a date input over individual day, month, year
if ( $currentDateString == $date ) {
$inputTimestamp = strtotime( $time. ' ' . $month . ' ' . $day . ', ' . $year );
/**
* Its possible to select IE: 31, Feb; in navigation.
* This will back the day down until it finds an acceptable date.
*/
$intDay = intval( $day );
$intMonth = intval( date( 'm', $inputTimestamp ) );
$intYear = intval( $year );
// 29
if ( ! checkdate( $intMonth, $intDay, $intYear ) ) {
$day = $intDay - 1;
}
// 30
if ( ! checkdate( $intMonth, $intDay, $intYear ) ) {
$day = $intDay - 1;
}
// 31
if ( ! checkdate( $intMonth, $intDay, $intYear ) ) {
$day = $intDay - 1;
}
$inputTimestamp = strtotime( $time. ' ' . $month . ' ' . $day . ', ' . $year );
} else {
$inputTimestamp = strtotime( $time . ' ' . $date );
}
$timestamp = self::getReadableDate( $inputTimestamp, $with_timezone );
return $timestamp;
}
/**
* Application getters
*/
public static function getDateFormat() {
$format = DEFAULT_DATE_FORMAT;
if ( !empty( self::$activePrefs ) && !empty( self::$activePrefs['dateFormat'] ) ) {
$format = self::$activePrefs['dateFormat'];
}
return $format;
}
public static function getTimeFormat() {
$format = DEFAULT_TIME_FORMAT;
if ( !empty( self::$activePrefs ) && !empty( self::$activePrefs['timeFormat'] ) ) {
$format = self::$activePrefs['timeFormat'];
}
return $format;
}
public static function getTimezone() {
$format = DEFAULT_TIMEZONE;
if ( !empty( self::$activePrefs ) && !empty( self::$activePrefs['timezone'] ) ) {
$format = self::$activePrefs['timezone'];
}
return $format;
}
/**
* Current getters
*/
public static function getCurrentDay() {
$date = new DateTime();
$date->setTimestamp( time() );
$timezone = new DateTimeZone( self::getTimezone() );
$date->setTimezone( $timezone );
$hourNow = $date->format('d');
return $hourNow;
}
public static function getCurrentMonth() {
$date = new DateTime();
$date->setTimestamp( time() );
$timezone = new DateTimeZone( self::getTimezone() );
$date->setTimezone( $timezone );
$hourNow = $date->format('M');
return $hourNow;
}
public static function getCurrentYear() {
$date = new DateTime();
$date->setTimestamp( time() );
$timezone = new DateTimeZone( self::getTimezone() );
$date->setTimezone( $timezone );
$hourNow = $date->format('Y');
return $hourNow;
}
public static function getCurrentHour() {
$date = new DateTime();
$date->setTimestamp( time() );
$timezone = new DateTimeZone( self::getTimezone() );
$date->setTimezone( $timezone );
$hourNow = $date->format('H');
return $hourNow;
}
/**
* Relative Dates
*/
public static function getDayStartTimestamp( $timestamp = 0, $with_timezone = false ) {
if ( empty( $timestamp ) ) {
$timestamp = self::determineDateInput();
}
$day = date( 'd', $timestamp );
$month = date( 'M', $timestamp );
$year = date( 'Y', $timestamp );
$startTime = '00:00:00';
$firstSecond = date( 'U', strtotime( "$startTime $day $month $year" ) );
if ( $with_timezone ) {
$specificDateString = $year.'-'.$month.'-'.$day;
$startDate = new DateTime( $specificDateString . ' ' . $startTime, new DateTimeZone( self::getTimezone() ) );
$startDate->setTimezone( new DateTimeZone( 'UTC' ) );
$firstSecond = $startDate->getTimestamp();
}
return $firstSecond;
}
public static function getDayEndTimestamp( $timestamp = 0, $with_timezone = false ) {
if ( empty( $timestamp ) ) {
$timestamp = self::determineDateInput();
}
$day = date( 'd', $timestamp );
$month = date( 'M', $timestamp );
$year = date( 'Y', $timestamp );
$endTime = '23:59:59';
$lastSecond = date( 'U', strtotime( "$endTime $day $month $year" ) );
if ( $with_timezone ) {
$specificDateString = $year.'-'.$month.'-'.$day;
$endDate = new DateTime( $specificDateString . ' ' . $endTime, new DateTimeZone( self::getTimezone() ) );
$endDate->setTimezone( new DateTimeZone( 'UTC' ) );
$lastSecond = $endDate->getTimestamp();
}
return $lastSecond;
}
public static function getWeekStartTimestamp( $timestamp = 0, $with_timezone = false ) {
if ( empty( $timestamp ) ) {
$timestamp = self::determineDateInput();
}
// $timestamp = intval( $timestamp );
$startTime = '00:00:00';
// find the first sunday in the week containing the date
if ( date( 'N', $timestamp ) == 7 ) {
$firstDate = $timestamp;
} else {
$firstDate = strtotime('last Sunday', $timestamp);
}
$firstSecond = date( 'Y-M-d '. $startTime, $firstDate );
if ( $with_timezone ) {
$startDate = new DateTime( $firstSecond, new DateTimeZone( self::getTimezone() ) );
$startDate->setTimezone( new DateTimeZone( 'UTC' ) );
$firstSecond = $startDate->getTimestamp();
} else {
$firstSecond = strtotime( $firstSecond );
}
return $firstSecond;
}
public static function getWeekEndTimestamp( $timestamp = 0, $with_timezone = false ) {
if ( empty( $timestamp ) ) {
$timestamp = self::determineDateInput();
}
// $timestamp = intval( $timestamp );
$endTime = '23:59:59';
// find the last saturday in the week containing the date
if ( date( 'N', $timestamp ) == 6 ) {
$lastDate = $timestamp;
} else {
$lastDate = strtotime( 'next Saturday', $timestamp );
}
$lastSecond = date( 'Y-M-d '. $endTime, $lastDate );
if ( $with_timezone ) {
$endDate = new DateTime( $lastSecond, new DateTimeZone( self::getTimezone() ) );
$endDate->setTimezone( new DateTimeZone( 'UTC' ) );
$lastSecond = $endDate->getTimestamp();
} else {
$lastSecond = strtotime( $lastSecond );
}
return $lastSecond;
}
public static function getMonthStartTimestamp( $timestamp = 0, $with_timezone = false ) {
if ( empty( $timestamp ) ) {
$timestamp = self::determineDateInput();
}
$startTime = '00:00:00';
$year = date( 'Y', $timestamp );
$month = date( 'M', $timestamp );
$firstDayUnix = strtotime( "$startTime $month 01 $year" );
// find the first sunday in the week containing the date
if ( date( 'N', $firstDayUnix ) == 7 ) {
$firstDate = $firstDayUnix;
} else {
$firstDate = strtotime('last Sunday', $firstDayUnix);
}
$firstSecond = date( 'Y-M-d '. $startTime, $firstDate );
if ( $with_timezone ) {
$startDate = new DateTime( $firstSecond, new DateTimeZone( self::getTimezone() ) );
$startDate->setTimezone( new DateTimeZone( 'UTC' ) );
$firstSecond = $startDate->getTimestamp();
} else {
$firstSecond = strtotime( $firstSecond );
}
return $firstSecond;
}
public static function getMonthEndTimestamp( $timestamp = 0, $with_timezone = false ) {
if ( empty( $timestamp ) ) {
$timestamp = self::determineDateInput();
}
$endTime = '23:59:59';
$year = date( 'Y', $timestamp );
// Find last day of month
$month = date( 'm', $timestamp );
$lastDay = cal_days_in_month( CAL_GREGORIAN, $month, $year );
$month = date( 'M', $timestamp );
$lastDayUnix = strtotime( "$endTime $month $lastDay $year" );
// find the last saturday in the week containing the date
if ( date( 'N', $lastDayUnix ) == 6 ) {
$lastDate = $lastDayUnix;
} else {
$lastDate = strtotime('next Saturday', $lastDayUnix);
}
$lastSecond = date( 'Y-M-d '. $endTime, $lastDate );
if ( $with_timezone ) {
$endDate = new DateTime( $lastSecond, new DateTimeZone( self::getTimezone() ) );
$endDate->setTimezone( new DateTimeZone( 'UTC' ) );
$lastSecond = $endDate->getTimestamp();
} else {
$lastSecond = strtotime( $lastSecond );
}
return $lastSecond;
}
public static function getYearStartTimestamp( $timestamp = 0, $with_timezone = false ) {
if ( empty( $timestamp ) ) {
$timestamp = self::determineDateInput();
}
$startTime = '00:00:00';
$year = date( 'Y', $timestamp );
$firstDayUnix = strtotime( "$startTime January 01 $year" );
$firstSecond = date( 'Y-M-d '. $startTime, $firstDayUnix );
if ( $with_timezone ) {
$startDate = new DateTime( $firstSecond, new DateTimeZone( self::getTimezone() ) );
$startDate->setTimezone( new DateTimeZone( 'UTC' ) );
$firstSecond = $startDate->getTimestamp();
} else {
$firstSecond = strtotime( $firstSecond );
}
return $firstSecond;
}
public static function getYearEndTimestamp( $timestamp = 0, $with_timezone = false ) {
if ( empty( $timestamp ) ) {
$timestamp = self::determineDateInput();
}
$endTime = '23:59:59';
$year = date( 'Y', $timestamp );
$lastDayUnix = strtotime( "$endTime December 31 $year" );
$lastSecond = date( 'Y-M-d '. $endTime, $lastDayUnix );
if ( $with_timezone ) {
$endDate = new DateTime( $lastSecond, new DateTimeZone( self::getTimezone() ) );
$endDate->setTimezone( new DateTimeZone( 'UTC' ) );
$lastSecond = $endDate->getTimestamp();
} else {
$lastSecond = strtotime( $lastSecond );
}
return $lastSecond;
}
}

View File

@ -1,43 +0,0 @@
<?php
/**
* functions/hash.php
*
* This class is used to salt, hash, and check passwords.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Functions;
use TheTempusProject\Canary\Canary as Debug;
class Hash {
/**
* Uses php native hashing scheme to make a password hash.
*
* @param string $password - Validated password input.
* @return string - salted/hashed and ready to use password hash.
*/
public static function make( $password ) {
return password_hash( $password, PASSWORD_DEFAULT );
}
/**
* Uses php native password support to verify the given password.
*
* @param string $password - Password being verified.
* @param string $hash - Saved password hash.
* @return bool
*/
public static function check( $password, $hash ) {
$result = password_verify( $password, $hash );
if ( $result ) {
return true;
}
Debug::info( 'Hash::check: Failed to verify password match.' );
return false;
}
}

Some files were not shown because too many files have changed in this diff Show More