Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
3152d180c0 | |||
42ade08306 | |||
464201cf17 | |||
983f6ed624 | |||
8cd7a6ebbc | |||
ef4818356c | |||
85ed1def88 | |||
7228e530b8 | |||
92c057ad26 | |||
feea409ac7 | |||
7518461cb9 | |||
233565dcd2 | |||
bfd23ecfe1 | |||
67f5dabfa6 | |||
1f720693d1 | |||
77988e612e | |||
3691c60590 | |||
d6a8f56f7d | |||
bbde55881e | |||
c2d7755ab7 | |||
ce77bdd1ac | |||
5cc61666fe | |||
79f21773c6 | |||
d9f0e86ce1 | |||
5b823f02f1 | |||
f80f7bed6b | |||
e3cf6beebb | |||
570a286c13 |
49
.gitlab-ci.yml
Normal file
49
.gitlab-ci.yml
Normal file
@ -0,0 +1,49 @@
|
||||
stages:
|
||||
- update
|
||||
|
||||
variables:
|
||||
TIMEZONE: "America/New_York" # For the system in general
|
||||
DATE_TIMEZONE: ${TIMEZONE} # For PHP
|
||||
|
||||
GIT_DEPTH: 1
|
||||
GITLAB_API_URL: ${CI_API_V4_URL}
|
||||
TARGET_BRANCH: ${CI_COMMIT_REF_NAME} # This is the branch chosen in the `Pipeline Schedule`
|
||||
TARGET_REMOTE: "https://${GITLAB_USERNAME}:${GITLAB_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git"
|
||||
|
||||
# These could/should be overridden in an extending job:
|
||||
UPDATE_BRANCH_PREFIX: "update_PHP_deps_" # Used for the update branch name, it will be followed by the datetime
|
||||
GIT_USER: "DependBot" # Used for the update commit
|
||||
GIT_EMAIL: "webmaster@thetempusproject.com" # Used for the update commit
|
||||
GITLAB_USERNAME: "root" # Used for pushing the new branch and opening the MR
|
||||
GITLAB_ACCESS_TOKEN: "glpat-PKEmivGtBfbz4DVPdhzk" # Used for pushing the new branch and opening the MR
|
||||
MERGE_IF_SUCCESSFUL: "true" # Set to true, to merge automatically if the pipeline succeeds
|
||||
SECONDS_BETWEEN_POOLING: 10 # Nbr of seconds between checking if the MR pipeline is successful, so then it will merge
|
||||
JOB_GIT_FLAGS: ""
|
||||
JOB_CURL_FLAGS: ""
|
||||
JOB_COMPOSER_FLAGS: ""
|
||||
|
||||
composer_update:
|
||||
stage: update
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "main"'
|
||||
image: composer:latest
|
||||
interruptible: true # allows to stop the job if a newer pipeline starts, saving resources and allowing new jobs to start because job concurrency is limited
|
||||
script:
|
||||
- git ${JOB_GIT_FLAGS} fetch origin ${TARGET_BRANCH}
|
||||
- git ${JOB_GIT_FLAGS} checkout ${TARGET_BRANCH}
|
||||
- git reset --hard origin/main
|
||||
- export DATE_TIME="$(date '+%Y%m%d%H%M%S')"
|
||||
- export MR_BRANCH="${UPDATE_BRANCH_PREFIX}${DATE_TIME}"
|
||||
- git ${JOB_GIT_FLAGS} checkout -b "${MR_BRANCH}"
|
||||
- composer update ${JOB_COMPOSER_FLAGS}
|
||||
- if [ "$(git diff)" == "" ]; then echo "No updates needed!"; exit 0; fi
|
||||
- export TITLE="Update PHP dependencies [${DATE_TIME}]"
|
||||
- git ${JOB_GIT_FLAGS} commit -a -m "${TITLE}"
|
||||
- git ${JOB_GIT_FLAGS} push "${TARGET_REMOTE}" "${MR_BRANCH}"
|
||||
artifacts:
|
||||
paths:
|
||||
- vendor/
|
||||
cache:
|
||||
key: ${CI_COMMIT_REF_SLUG}
|
||||
paths:
|
||||
- vendor/
|
115
Bin/Bedrock.php
115
Bin/Bedrock.php
@ -14,7 +14,7 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Bin;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Hermes\Functions\Route as Routes;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
@ -32,6 +32,7 @@ class Bedrock {
|
||||
protected $controllerObject = null;
|
||||
protected $controllerClass = '';
|
||||
protected $params = [];
|
||||
protected $controllerError = false;
|
||||
|
||||
/**
|
||||
* The constructor handles the entire process of parsing the url,
|
||||
@ -46,8 +47,8 @@ class Bedrock {
|
||||
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' ] );
|
||||
set_error_handler( [ BEDROCK_DEFAULT_ERROR_HANDLER, 'handle_error' ] );
|
||||
set_exception_handler( [ BEDROCK_DEFAULT_EXCEPTION_HANDLER, 'handle_exception' ] );
|
||||
self::$controllerName = DEFAULT_CONTROLLER_CLASS;
|
||||
self::$methodName = DEFAULT_CONTROLLER_METHOD;
|
||||
$this->setUrl( $url );
|
||||
@ -64,55 +65,6 @@ class Bedrock {
|
||||
$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 );
|
||||
@ -154,6 +106,65 @@ class Bedrock {
|
||||
}
|
||||
}
|
||||
|
||||
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' ) ?? APP_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;
|
||||
}
|
||||
if ( empty( $this->controllerError ) ) {
|
||||
Components::set( 'TOKEN', Token::generate() );
|
||||
}
|
||||
$this->controllerObject = new $this->controllerClass;
|
||||
}
|
||||
|
||||
protected function setController( $name, $namespace ) {
|
||||
$controllerClass = $namespace . ucfirst( $name );
|
||||
if ( Autoloader::testLoad( $controllerClass ) ) {
|
||||
$this->controllerClass = $controllerClass;
|
||||
self::$controllerName = $name;
|
||||
} else {
|
||||
$this->controllerError = 'setController - Controller not found. Name: ' . $name . ' Namespace: ' . $namespace;
|
||||
Debug::info( $this->controllerError );
|
||||
}
|
||||
}
|
||||
|
||||
protected function setPage( $name ) {
|
||||
$name = strtolower( $name );
|
||||
if ( empty( $this->controllerClass ) ) {
|
||||
Debug::info( 'setPage - controllerClass Empty' );
|
||||
return false;
|
||||
}
|
||||
if ( ! method_exists( $this->controllerClass, $name ) ) {
|
||||
Debug::info( 'setPage - Method not found. Controller: ' . $this->controllerClass . ' Method: ' . $name );
|
||||
return false;
|
||||
}
|
||||
self::$methodName = $name;
|
||||
}
|
||||
|
||||
public static function getCurrentUrl() {
|
||||
return Sanitize::url( Input::get( 'url' ) );
|
||||
}
|
||||
|
@ -17,36 +17,29 @@ 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);
|
||||
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';
|
||||
}
|
||||
if ( class_exists( 'TheTempusProject\Hermes\Classes\Autoloader' ) ) {
|
||||
$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();
|
||||
}
|
||||
|
||||
$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();
|
||||
require_once 'Bedrock.php';
|
||||
|
||||
define( 'BEDROCK_AUTOLOADED', true );
|
||||
|
@ -11,9 +11,10 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Upload;
|
||||
|
||||
class Config {
|
||||
public static $config = false;
|
||||
@ -145,7 +146,19 @@ class Config {
|
||||
}
|
||||
$fieldname = str_ireplace( '/', '-', $name );
|
||||
if ( Input::exists( $fieldname ) ) {
|
||||
$this->update( $category, $field, Input::post( $fieldname ) );
|
||||
if ( 'file' == $node['type'] ) {
|
||||
$upload = Upload::image( $fieldname, IMAGE_DIRECTORY );
|
||||
if ( $upload ) {
|
||||
$route = str_replace( APP_ROOT_DIRECTORY, '', IMAGE_DIRECTORY );
|
||||
$this->update( $category, $field, $route . Upload::last() );
|
||||
} else {
|
||||
Debug::error( 'There was an error with your upload.');
|
||||
}
|
||||
} else {
|
||||
$this->update( $category, $field, Input::post( $fieldname ) );
|
||||
}
|
||||
} elseif ( 'radio' == $node['type'] ) {
|
||||
$this->update( $category, $field, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -15,8 +15,8 @@ namespace TheTempusProject\Bedrock\Classes;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use TheTempusProject\Houdini\Classes\Pagination;
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Canary\Classes\CustomException;
|
||||
|
||||
class Database {
|
||||
public static $instance = null;
|
||||
@ -274,7 +274,7 @@ class Database {
|
||||
foreach ( $params as $param ) {
|
||||
$x++;
|
||||
if ( is_array( $param ) ) {
|
||||
dv( $param );
|
||||
// dv( $param );
|
||||
}
|
||||
$this->query->bindValue( $x, $param );
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Bedrock;
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Bedrock\Classes\Database;
|
||||
|
||||
|
@ -9,14 +9,16 @@
|
||||
* @link https://TheTempusProject.com/Core
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
namespace TheTempusProject\Bedrock\Classes;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Template;
|
||||
use TheTempusProject\Hermes\Functions\Route as Routes;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
|
||||
class Pagination extends Template {
|
||||
//The settings that will not change
|
||||
@ -154,7 +156,7 @@ class Pagination extends Template {
|
||||
$pageData = (object) $pageData;
|
||||
|
||||
if ( self::totalPages() <= 1 ) {
|
||||
Components::set( 'PAGINATION', 'no pagination' );
|
||||
Components::set( 'PAGINATION', '' );
|
||||
} else {
|
||||
Components::set( 'PAGINATION', Views::simpleView( 'nav.pagination', $pageData ) );
|
||||
}
|
||||
|
@ -47,24 +47,30 @@
|
||||
}
|
||||
// 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_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('BEDROCK_DEFAULT_ERROR_HANDLER')) {
|
||||
define('BEDROCK_DEFAULT_ERROR_HANDLER', 'TheTempusProject\\Canary\\Bin\\Canary');
|
||||
}
|
||||
if (!defined('BEDROCK_DEFAULT_EXCEPTION_HANDLER')) {
|
||||
define('BEDROCK_DEFAULT_EXCEPTION_HANDLER', 'TheTempusProject\\Canary\\Bin\\Canary');
|
||||
}
|
||||
if (!defined('DEBUG_EMAIL')) {
|
||||
define('DEBUG_EMAIL', 'webmaster@' . $_SERVER['HTTP_HOST']);
|
||||
}
|
||||
@ -114,40 +120,6 @@
|
||||
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');
|
||||
@ -201,6 +173,10 @@
|
||||
if (!defined('TOKEN_ENABLED')) {
|
||||
define('TOKEN_ENABLED', true);
|
||||
}
|
||||
// dUH
|
||||
if (!defined('APP_NAME')) {
|
||||
define('APP_NAME', 'Bedrock Application');
|
||||
}
|
||||
# Tell the app all constants have been loaded.
|
||||
if ( ! defined('BEDROCK_CONSTANTS_LOADED' ) ) {
|
||||
define( 'BEDROCK_CONSTANTS_LOADED', true );
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
|
||||
class Check {
|
||||
private static $formValidator = null;
|
||||
@ -100,24 +100,24 @@ class Check {
|
||||
*/
|
||||
public static function imageUpload( $imageName ) {
|
||||
if ( !Config::getValue( 'uploads/images' ) ) {
|
||||
self::addError( 'Image uploads are disabled.' );
|
||||
self::addUserError( 'Image uploads are disabled.' );
|
||||
return false;
|
||||
}
|
||||
if ( !isset( $_FILES[$imageName] ) ) {
|
||||
self::addError( 'File not found.', $imageName );
|
||||
self::addUserError( 'File not found.', $imageName );
|
||||
return false;
|
||||
}
|
||||
if ( $_FILES[$imageName]['error'] != 0 ) {
|
||||
self::addError( 'File error:' . $_FILES[$imageName]['error'] );
|
||||
self::addUserError( 'File error:' . $_FILES[$imageName]['error'] );
|
||||
return false;
|
||||
}
|
||||
if ( $_FILES[$imageName]['size'] > Config::getValue( 'uploads/maxImageSize' ) ) {
|
||||
self::addError( 'Image is too large.' );
|
||||
self::addUserError( '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 );
|
||||
self::addUserError( 'Invalid image type', $fileType );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
|
||||
class Code {
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
|
||||
class Cookie {
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
|
||||
class Hash {
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
|
||||
class Input {
|
||||
/**
|
||||
@ -29,7 +29,7 @@ class Input {
|
||||
} elseif ( self::file( $data ) ) {
|
||||
return true;
|
||||
} else {
|
||||
Debug::info( 'Input::exists: No input Found: '. $data );
|
||||
Debug::log( 'Input::exists: No input Found: '. $data );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -43,11 +43,11 @@ class Input {
|
||||
*/
|
||||
public static function file( $data ) {
|
||||
if ( !isset( $_FILES[$data] ) ) {
|
||||
Debug::debug( "Input - file : $data not found." );
|
||||
Debug::log( "Input - file : $data not found." );
|
||||
return false;
|
||||
}
|
||||
if ( $_FILES[$data]['tmp_name'] == '' ) {
|
||||
Debug::debug( "Input - file : $data empty." );
|
||||
Debug::log( "Input - file : $data empty." );
|
||||
return false;
|
||||
}
|
||||
return $_FILES[$data];
|
||||
|
@ -11,7 +11,7 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
|
||||
class Session {
|
||||
/**
|
||||
@ -21,14 +21,17 @@ class Session {
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function exists( $name ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||
if ( isset( $_SESSION[$sessionName] ) ) {
|
||||
if ( isset( $_SESSION[ $sessionName ] ) ) {
|
||||
return true;
|
||||
}
|
||||
Debug::info("Session::exists - Session not found: $sessionName");
|
||||
Debug::log( "Session::exists - Session not found: $sessionName" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -39,14 +42,14 @@ class Session {
|
||||
* @return {string|bool} - Returns the data from the session or false if nothing is found..
|
||||
*/
|
||||
public static function get( $name ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||
if ( self::exists( $name ) ) {
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||
return $_SESSION[$sessionName];
|
||||
return $_SESSION[ $sessionName ];
|
||||
}
|
||||
Debug::info("Session::get - Session not found: $name");
|
||||
Debug::log( "Session::get - Session not found: $sessionName" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,12 +61,15 @@ class Session {
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function put( $name, $data ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||
$_SESSION[$sessionName] = $data;
|
||||
Debug::info("Session: Created: $sessionName");
|
||||
$_SESSION[ $sessionName ] = $data;
|
||||
Debug::log( "Session::get - Created/Updated: $sessionName" );
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,16 +80,16 @@ class Session {
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function delete( $name ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||
if ( self::exists( $name ) ) {
|
||||
$sessionName = DEFAULT_SESSION_PREFIX . $name;
|
||||
unset( $_SESSION[$sessionName] );
|
||||
Debug::info("Session::deleted: $sessionName");
|
||||
Debug::info( "Session::delete - Deleted $sessionName" );
|
||||
return true;
|
||||
}
|
||||
Debug::error("Session::delete - Session not found.");
|
||||
Debug::error( "Session::delete - Session not found." );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -97,11 +103,11 @@ class Session {
|
||||
* @return bool|string - Returns bool if creating, and a string if the check is successful.
|
||||
*/
|
||||
public static function checkFlash( $name ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
if ( self::exists( $name ) ) {
|
||||
Debug::info("Session::flash - Exists");
|
||||
Debug::log("Session::flash - Exists");
|
||||
$session = self::get( $name );
|
||||
self::delete( $name );
|
||||
return $session;
|
||||
@ -110,16 +116,16 @@ class Session {
|
||||
}
|
||||
|
||||
public static function flash( $name, $data = null ) {
|
||||
if ( !Check::sessionName( $name ) ) {
|
||||
if ( ! Check::sessionName( $name ) ) {
|
||||
return false;
|
||||
}
|
||||
if ( !empty( $data ) ) {
|
||||
if ( ! empty( $data ) ) {
|
||||
self::put( $name, $data );
|
||||
Debug::info("Session::flash - Session created.");
|
||||
Debug::log("Session::flash - Session created.");
|
||||
return true;
|
||||
}
|
||||
if ( self::exists( $name ) ) {
|
||||
Debug::info("Session::flash - Exists");
|
||||
Debug::log("Session::flash - Exists");
|
||||
$session = self::get( $name );
|
||||
self::delete( $name );
|
||||
return $session;
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
|
||||
class Token {
|
||||
private static $tokenName;
|
||||
|
@ -13,7 +13,7 @@
|
||||
*/
|
||||
namespace TheTempusProject\Bedrock\Functions;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
|
||||
class Upload {
|
||||
public static $lastUpload = null;
|
||||
|
24
composer.lock
generated
24
composer.lock
generated
@ -12,7 +12,7 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/canary",
|
||||
"reference": "be5589533f8c1d0b1c28bac8829333f0077c698d"
|
||||
"reference": "35415fbf3c5888ccdb8a8695989176a120026c7f"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
@ -21,12 +21,12 @@
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"config/constants.php",
|
||||
"bin/canary.php"
|
||||
"Config/constants.php",
|
||||
"Bin/Canary.php"
|
||||
],
|
||||
"classmap": [
|
||||
"classes"
|
||||
]
|
||||
"psr-4": {
|
||||
"TheTempusProject\\Canary\\Classes\\": "Classes"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
@ -48,7 +48,7 @@
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-08T05:18:19+00:00"
|
||||
"time": "2024-08-20T10:26:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "thetempusproject/hermes",
|
||||
@ -56,7 +56,7 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/hermes",
|
||||
"reference": "e38f8debefb7097b15cb479184dc869e3e3111c0"
|
||||
"reference": "31c51c1a5bad2871df800c89f27ace0a49848583"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0"
|
||||
@ -92,7 +92,7 @@
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-08T05:24:32+00:00"
|
||||
"time": "2024-08-20T10:26:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "thetempusproject/houdini",
|
||||
@ -100,7 +100,7 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.thetempusproject.com/the-tempus-project/houdini",
|
||||
"reference": "b2d044da64ca1869432dc12b9c98fdb60379ffd9"
|
||||
"reference": "d9e61d3f8f5d10f3fa7ba31907a4b3c1edc76614"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1.0",
|
||||
@ -137,7 +137,7 @@
|
||||
"thetempusproject",
|
||||
"tools"
|
||||
],
|
||||
"time": "2024-08-08T05:17:27+00:00"
|
||||
"time": "2024-08-20T10:30:48+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
@ -150,5 +150,5 @@
|
||||
"php": ">=8.1.0"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
Reference in New Issue
Block a user