From 9b4c12913f7df96a03324514c580ed9679dac070 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 30 Dec 2022 02:13:25 -0500 Subject: [PATCH] Refactored code to use tts.php file --- cli_cron | 8 +- public/main.page | 8 +- src/before_main.php | 3 +- src/configs/ex/loadall.php | 72 -------- src/configs/ex/on_email.php | 2 +- src/configs/ex/on_html.php | 2 +- src/configs/ex/on_http_request.php | 2 +- src/configs/ex/on_security.php | 2 +- src/configs/ex/on_sessions.php | 2 +- src/configs/ex/on_tts.php | 22 ++- src/configs/ex/on_view_mode.php | 2 +- src/configs/mockup/loadall.php | 160 +++++++++--------- src/configs/mockup/on_email.php | 2 +- src/configs/mockup/on_html.php | 2 +- src/configs/mockup/on_http_request.php | 2 +- src/configs/mockup/on_security.php | 2 +- src/configs/mockup/on_sessions.php | 2 +- src/configs/mockup/on_tts.php | 6 +- src/configs/mockup/on_view_mode.php | 2 +- src/ex/controllers/app/home_ctrl.php | 2 +- src/ex/inputs/app/home_in.php | 12 +- src/ex/logic/app/home_logic.php | 4 +- src/ex/models/app/home_model.php | 18 +- src/ex/outputs/app/home_out.php | 6 +- src/ex/outputs/bills/notices_out.php | 4 +- src/main.php | 5 +- src/mockup/cli_controllers/app/home_ctrl.php | 3 +- src/mockup/controllers/app/enc_ctrl.php | 8 +- src/mockup/controllers/app/home_ctrl.php | 2 +- src/mockup/inputs/app/home_in.php | 12 +- src/mockup/logic/app/home_logic.php | 4 +- src/mockup/models/app/home_model.php | 20 +-- src/mockup/outputs/app/home_out.php | 6 +- src/mockup/outputs/bills/notices_out.php | 4 +- src/services/ex/loadall.php | 54 ------ src/services/ex/on_html_filter.php | 4 +- src/services/ex/on_log.php | 8 +- src/services/ex/on_templates.php | 4 +- src/services/ex/on_test_db.php | 2 +- src/services/mockup/loadall.php | 33 ++-- src/services/mockup/on_html_filter.php | 4 +- src/services/mockup/on_log.php | 8 +- src/services/mockup/on_session_encryption.php | 13 +- src/services/mockup/on_templates.php | 4 +- src/services/mockup/on_test_db.php | 2 +- 45 files changed, 214 insertions(+), 335 deletions(-) delete mode 100644 src/configs/ex/loadall.php delete mode 100644 src/services/ex/loadall.php diff --git a/cli_cron b/cli_cron index 89f0dad..f6dcfb6 100755 --- a/cli_cron +++ b/cli_cron @@ -10,13 +10,13 @@ declare(strict_types=1); */ require 'src/before_main.php'; -\bs_tts\site_helper::set_all_projects(['mockup','ex','live']); -\bs_tts\site_helper::set_default_project("mockup"); +\tts\site_helper::set_all_projects(['mockup','ex','live']); +\tts\site_helper::set_default_project("mockup"); $PHPUNIT_Testing = false; -$cli_args = \bs_tts\site_helper::get_cli_args(); -\bs_tts\site_helper::init(PROJECT_BASE_DIR, $cli_args, "get", $PHPUNIT_Testing); +$cli_args = \tts\site_helper::get_cli_args(); +\tts\site_helper::init(PROJECT_BASE_DIR, $cli_args, "get", $PHPUNIT_Testing); require 'src/main.php'; diff --git a/public/main.page b/public/main.page index 3aab066..3cadbaf 100644 --- a/public/main.page +++ b/public/main.page @@ -8,7 +8,7 @@ declare(strict_types=1); * @license https://mit-license.org/ */ -$show_all_startup_errors = false; // Always, Keep false on LIVE PROD SYS!! +$show_all_startup_errors = true; // Always, Keep false on LIVE PROD SYS!! if ($show_all_startup_errors) { ini_set('display_errors', 1); ini_set('display_startup_errors', 1); @@ -16,11 +16,11 @@ if ($show_all_startup_errors) { } require '../src/before_main.php'; -\bs_tts\site_helper::set_all_projects(['mockup','ex','live']); -\bs_tts\site_helper::set_default_project("mockup"); +\tts\site_helper::set_all_projects(['mockup','ex','live']); +\tts\site_helper::set_default_project("mockup"); $PHPUNIT_Testing = false; -\bs_tts\site_helper::init(PROJECT_BASE_DIR, $_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD'], $PHPUNIT_Testing); +\tts\site_helper::init(PROJECT_BASE_DIR, $_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD'], $PHPUNIT_Testing); require '../src/main.php'; diff --git a/src/before_main.php b/src/before_main.php index 10fb32b..79e702f 100644 --- a/src/before_main.php +++ b/src/before_main.php @@ -4,4 +4,5 @@ declare(strict_types=1); const PROJECT_BASE_DIR = __DIR__ . '/'; -require '/var/www/frames/tts_framework/src/bootstrap/site_helper.php'; \ No newline at end of file +require '/var/www/frames/tts_framework/src/dist/tts.php'; +//require '/var/www/frames/tts_framework/src/bootstrap/site_helper.php'; diff --git a/src/configs/ex/loadall.php b/src/configs/ex/loadall.php deleted file mode 100644 index df946f2..0000000 --- a/src/configs/ex/loadall.php +++ /dev/null @@ -1,72 +0,0 @@ - '', // SMTP Hosts - seperated by ; -// 'username' => '', -// 'password' => '', - 'send_emails' => false, // Enable emails - 'email_on_errors' => false, - 'admin_emails' => array('Bob'=>'bob@localost', 'Chris'=>'chris@localost'), // Email Admins on error -)); -/* Contents of : on_html.php */ - -\main_tts\configure::set('html', array( - 'author' => 'Robert Strutts', - 'title' => 'In Example Project...', - 'javascript' => array('js/error_handler.js'=>'tts', 'js/store.js'=>'tts'), //'js/analytics.js'=>'project' - 'robots' => 'noindex', - 'keywords' => '', - 'description' => '', -)); -/* Contents of : on_http_request.php */ - -\main_tts\configure::set('http_request', array( - 'use' => 'sockets', // curl or sockets -)); - -/* Contents of : on_security.php */ - -\main_tts\configure::set('security', array( - 'show_dumps' => true, - 'key' => 'y8+HSfrO8wFknxND8SA2mQZBoYpPDeK+2FmIzdxFU9EmTsZ2rdo7GED0nt4DsKoHmbiBBIoNTMAfl+eEMv6qeA==', - 'main_salt' => 'e6fde23484881a29f7b6c6459456f3e1', - 'csrf_security_level' => 'high', // Stop Attacks at what cost?? - 'retries_allowed_before_throttling' => 3, // Reties attempts allowed for login, before it throttles it... - 'throttling_login_seconds' => 20, // Seconds to deny more login attempts - 'password_hash' => PASSWORD_BCRYPT, - 'password_hash_options' => ['cost' => 10], // Default=10. This is a good baseline cost, but you may want to consider increasing it depending on your hardware. -)); - -/* Contents of : on_sessions.php */ - -\main_tts\configure::set('sessions', array( - 'engine' => 'php', // php, db - 'type' => 'none', // Session Type: files, database, or cache - 'session_variable' => 'ses_app_aaa_', // set session variable name for project - 'session_name' => 'aaa_sys_342_', // More secure then PHPSESSID - 'session_table' => false, // DB PHP Session Table name, false = USE FILES - 'session_security_level' => 'blaze', // Faster Reqests keep at: blaze - 'session_key' => '6cb0d56f2345917624f2c5473e4d32cd', -)); -/* Contents of : on_tts.php */ - -\main_tts\configure::set_key('important', 'private_ip_as_local', false); - -\main_tts\configure::set('tts', array( - 'site_name' => 'Testing', - 'short_url' => true, - 'default_project' => 'home', - 'check_HTML_tags' => true, - 'live' => false, //(! \tts\security::is_localhost() ) // Is this Production?? -)); - -/* Contents of : on_view_mode.php */ - -\main_tts\configure::set('view_mode', array( - 'default_paths' => array('json', 'common', 'flexbox', 'default') -)); \ No newline at end of file diff --git a/src/configs/ex/on_email.php b/src/configs/ex/on_email.php index a01f8e8..79247fe 100644 --- a/src/configs/ex/on_email.php +++ b/src/configs/ex/on_email.php @@ -1,6 +1,6 @@ '', // SMTP Hosts - seperated by ; // 'username' => '', // 'password' => '', diff --git a/src/configs/ex/on_html.php b/src/configs/ex/on_html.php index af44526..a37ede6 100644 --- a/src/configs/ex/on_html.php +++ b/src/configs/ex/on_html.php @@ -1,6 +1,6 @@ 'Robert Strutts', 'title' => 'In Example Project...', 'javascript' => array('js/error_handler.js'=>'tts', 'js/store.js'=>'tts'), //'js/analytics.js'=>'project' diff --git a/src/configs/ex/on_http_request.php b/src/configs/ex/on_http_request.php index 1ed2535..b9093de 100644 --- a/src/configs/ex/on_http_request.php +++ b/src/configs/ex/on_http_request.php @@ -1,5 +1,5 @@ 'sockets', // curl or sockets )); diff --git a/src/configs/ex/on_security.php b/src/configs/ex/on_security.php index e44cb02..0105d62 100644 --- a/src/configs/ex/on_security.php +++ b/src/configs/ex/on_security.php @@ -1,6 +1,6 @@ true, 'key' => 'y8+HSfrO8wFknxND8SA2mQZBoYpPDeK+2FmIzdxFU9EmTsZ2rdo7GED0nt4DsKoHmbiBBIoNTMAfl+eEMv6qeA==', 'main_salt' => 'e6fde23484881a29f7b6c6459456f3e1', diff --git a/src/configs/ex/on_sessions.php b/src/configs/ex/on_sessions.php index 690daa0..37055d3 100644 --- a/src/configs/ex/on_sessions.php +++ b/src/configs/ex/on_sessions.php @@ -1,6 +1,6 @@ 'php', // php, db 'type' => 'none', // Session Type: files, database, or cache 'session_variable' => 'ses_app_aaa_', // set session variable name for project diff --git a/src/configs/ex/on_tts.php b/src/configs/ex/on_tts.php index 0158377..e9308b5 100644 --- a/src/configs/ex/on_tts.php +++ b/src/configs/ex/on_tts.php @@ -1,11 +1,25 @@ 'Testing', 'short_url' => true, 'default_project' => 'home', 'check_HTML_tags' => true, - 'live' => false, //(! \tts\security::is_localhost() ) // Is this Production?? -)); + 'live' => (\tts\site_helper::remote_not_allowed_force_live()), +)); \ No newline at end of file diff --git a/src/configs/ex/on_view_mode.php b/src/configs/ex/on_view_mode.php index 7c18958..9963106 100644 --- a/src/configs/ex/on_view_mode.php +++ b/src/configs/ex/on_view_mode.php @@ -1,5 +1,5 @@ array('json', 'common', 'flexbox', 'default') )); \ No newline at end of file diff --git a/src/configs/mockup/loadall.php b/src/configs/mockup/loadall.php index 311386e..ccd6c85 100644 --- a/src/configs/mockup/loadall.php +++ b/src/configs/mockup/loadall.php @@ -3,84 +3,84 @@ /* * This file is Auto-Generated, Do NOT Modify!!! Please Delete this file to update configuration! */ - -/* Contents of : on_email.php */ - -\main_tts\configure::set('email', array( -// 'host' => '', // SMTP Hosts - seperated by ; -// 'username' => '', -// 'password' => '', - 'send_emails' => false, // Enable emails - 'email_on_errors' => false, - 'admin_emails' => array('Bob'=>'bob@localost', 'Chris'=>'chris@localhost'), // Email Admins on error -)); -/* Contents of : on_html.php */ - -\main_tts\configure::set('html', array( - 'title' => 'In Mockup...', - 'author' => 'Robert Strutts', - 'javascript' => array('js/tts.min.js'=>'assets'), //'js/analytics.js'=>'project' - 'css' => array('css/style.css'=>'project'), - 'robots' => 'noindex', - 'keywords' => '', - 'description' => '', -)); -/* Contents of : on_http_request.php */ - -\main_tts\configure::set('http_request', array( - 'use' => 'sockets', // curl or sockets -)); - -/* Contents of : on_security.php */ - -\main_tts\configure::set('security', array( - 'show_dumps' => true, - 'key' => 'y8+HSfrO8wFknxND8SA2mQZBoYpPDeK+2FmIzdxFU9EmTsZ2rdo7GED0nt4DsKoHmbiBBIoNTMAfl+eEMv6qeA==', - 'main_salt' => 'e6fde23484881a29f7b6c6459456f3e1', - 'csrf_security_level' => 'high', // Stop Attacks at what cost?? - 'retries_allowed_before_throttling' => 3, // Reties attempts allowed for login, before it throttles it... - 'throttling_login_seconds' => 20, // Seconds to deny more login attempts - 'pepper_pwd' => 'SZFJXX]7HcwJjS]av3q8cUR', - 'salt_pwd' => 'fVN(P8nBNK3;tM88Kkku', -)); - -/* Contents of : on_sessions.php */ - -\main_tts\configure::set('sessions', array( - 'type' => 'cookies', // Session Type: php, files, redis, or cookies - 'session_variable' => 'ses_app_', // set session variable name for project - 'session_name' => 'main_SESS', // More secure then PHPSESSID - 'session_table' => false, // DB PHP Session Table name, false = USE FILES - 'session_security_level' => 'blaze', // Faster Reqests keep at: blaze - 'session_key' => '78a5011b9997cd03a28a3412c66565b7c32715b35e055d7abfc228236308d3b2', -)); -/* Contents of : on_tts.php */ - -/** - * @todo REMOVE or CHANGE [set_local_site_domains] to your - * PRIVATE or non-public accessible site domain name. - * - * Make sure the web-server only servers it on a - * loop-back or non-routable IP address range, - * otherwise people will be able to see lots of - * private DEBUG info. Also, make sure your HOST file has an - * entry to your web server's IP IG: 127.0.0.1 tts.home.local - * - * When in Doubt, just make live false, below here!!! - */ -\bs_tts\site_helper::set_local_site_domains('tts.home.local'); -// \bs_tts\site_helper::set_allowed_Private_IPs(['192.168.32.2', '192.168.32.3']); -// \bs_tts\site_helper::set_allowed_Public_IPs('12.x.x.x'); - -\main_tts\configure::set('tts', array( - 'site_name' => 'Testing', - 'short_url' => true, - 'default_project' => 'home', - 'check_HTML_tags' => true, - 'live' => (\bs_tts\site_helper::remote_not_allowed_force_live()), -)); -/* Contents of : on_view_mode.php */ - -\main_tts\configure::set('view_mode', array( - 'default_paths' => array('json', 'common', 'flexbox', 'default') + +/* Contents of : on_email.php */ + +\tts\configure::set('email', array( +// 'host' => '', // SMTP Hosts - seperated by ; +// 'username' => '', +// 'password' => '', + 'send_emails' => false, // Enable emails + 'email_on_errors' => false, + 'admin_emails' => array('Bob'=>'bob@localost', 'Chris'=>'chris@localhost'), // Email Admins on error +)); +/* Contents of : on_html.php */ + +\tts\configure::set('html', array( + 'title' => 'In Mockup...', + 'author' => 'Robert Strutts', + 'javascript' => array('js/tts.min.js'=>'assets'), //'js/analytics.js'=>'project' + 'css' => array('css/style.css'=>'project'), + 'robots' => 'noindex', + 'keywords' => '', + 'description' => '', +)); +/* Contents of : on_http_request.php */ + +\tts\configure::set('http_request', array( + 'use' => 'sockets', // curl or sockets +)); + +/* Contents of : on_security.php */ + +\tts\configure::set('security', array( + 'show_dumps' => true, + 'key' => 'y8+HSfrO8wFknxND8SA2mQZBoYpPDeK+2FmIzdxFU9EmTsZ2rdo7GED0nt4DsKoHmbiBBIoNTMAfl+eEMv6qeA==', + 'main_salt' => 'e6fde23484881a29f7b6c6459456f3e1', + 'csrf_security_level' => 'high', // Stop Attacks at what cost?? + 'retries_allowed_before_throttling' => 3, // Reties attempts allowed for login, before it throttles it... + 'throttling_login_seconds' => 20, // Seconds to deny more login attempts + 'pepper_pwd' => 'SZFJXX]7HcwJjS]av3q8cUR', + 'salt_pwd' => 'fVN(P8nBNK3;tM88Kkku', +)); + +/* Contents of : on_sessions.php */ + +\tts\configure::set('sessions', array( + 'type' => 'cookies', // Session Type: php, files, redis, or cookies + 'session_variable' => 'ses_app_', // set session variable name for project + 'session_name' => 'main_SESS', // More secure then PHPSESSID + 'session_table' => false, // DB PHP Session Table name, false = USE FILES + 'session_security_level' => 'blaze', // Faster Reqests keep at: blaze + 'session_key' => '78a5011b9997cd03a28a3412c66565b7c32715b35e055d7abfc228236308d3b2', +)); +/* Contents of : on_tts.php */ + +/** + * @todo REMOVE or CHANGE [set_local_site_domains] to your + * PRIVATE or non-public accessible site domain name. + * + * Make sure the web-server only servers it on a + * loop-back or non-routable IP address range, + * otherwise people will be able to see lots of + * private DEBUG info. Also, make sure your HOST file has an + * entry to your web server's IP IG: 127.0.0.1 tts.home.local + * + * When in Doubt, just make live false, below here!!! + */ +\tts\site_helper::set_local_site_domains('tts.home.local'); +// \bs_tts\site_helper::set_allowed_Private_IPs(['192.168.32.2', '192.168.32.3']); +// \bs_tts\site_helper::set_allowed_Public_IPs('12.x.x.x'); + +\tts\configure::set('tts', array( + 'site_name' => 'Testing', + 'short_url' => true, + 'default_project' => 'home', + 'check_HTML_tags' => true, + 'live' => (\tts\site_helper::remote_not_allowed_force_live()), +)); +/* Contents of : on_view_mode.php */ + +\tts\configure::set('view_mode', array( + 'default_paths' => array('json', 'common', 'flexbox', 'default') )); \ No newline at end of file diff --git a/src/configs/mockup/on_email.php b/src/configs/mockup/on_email.php index fff13e3..5d526c4 100644 --- a/src/configs/mockup/on_email.php +++ b/src/configs/mockup/on_email.php @@ -1,6 +1,6 @@ '', // SMTP Hosts - seperated by ; // 'username' => '', // 'password' => '', diff --git a/src/configs/mockup/on_html.php b/src/configs/mockup/on_html.php index 2395a5b..e6a3220 100644 --- a/src/configs/mockup/on_html.php +++ b/src/configs/mockup/on_html.php @@ -1,6 +1,6 @@ 'In Mockup...', 'author' => 'Robert Strutts', 'javascript' => array('js/tts.min.js'=>'assets'), //'js/analytics.js'=>'project' diff --git a/src/configs/mockup/on_http_request.php b/src/configs/mockup/on_http_request.php index 1ed2535..b9093de 100644 --- a/src/configs/mockup/on_http_request.php +++ b/src/configs/mockup/on_http_request.php @@ -1,5 +1,5 @@ 'sockets', // curl or sockets )); diff --git a/src/configs/mockup/on_security.php b/src/configs/mockup/on_security.php index 140130a..b35c583 100644 --- a/src/configs/mockup/on_security.php +++ b/src/configs/mockup/on_security.php @@ -1,6 +1,6 @@ true, 'key' => 'y8+HSfrO8wFknxND8SA2mQZBoYpPDeK+2FmIzdxFU9EmTsZ2rdo7GED0nt4DsKoHmbiBBIoNTMAfl+eEMv6qeA==', 'main_salt' => 'e6fde23484881a29f7b6c6459456f3e1', diff --git a/src/configs/mockup/on_sessions.php b/src/configs/mockup/on_sessions.php index 1ca8948..5066585 100644 --- a/src/configs/mockup/on_sessions.php +++ b/src/configs/mockup/on_sessions.php @@ -1,6 +1,6 @@ 'cookies', // Session Type: php, files, redis, or cookies 'session_variable' => 'ses_app_', // set session variable name for project 'session_name' => 'main_SESS', // More secure then PHPSESSID diff --git a/src/configs/mockup/on_tts.php b/src/configs/mockup/on_tts.php index c43f284..e9308b5 100644 --- a/src/configs/mockup/on_tts.php +++ b/src/configs/mockup/on_tts.php @@ -12,14 +12,14 @@ * * When in Doubt, just make live false, below here!!! */ -\bs_tts\site_helper::set_local_site_domains('tts.home.local'); +\tts\site_helper::set_local_site_domains('tts.home.local'); // \bs_tts\site_helper::set_allowed_Private_IPs(['192.168.32.2', '192.168.32.3']); // \bs_tts\site_helper::set_allowed_Public_IPs('12.x.x.x'); -\main_tts\configure::set('tts', array( +\tts\configure::set('tts', array( 'site_name' => 'Testing', 'short_url' => true, 'default_project' => 'home', 'check_HTML_tags' => true, - 'live' => (\bs_tts\site_helper::remote_not_allowed_force_live()), + 'live' => (\tts\site_helper::remote_not_allowed_force_live()), )); \ No newline at end of file diff --git a/src/configs/mockup/on_view_mode.php b/src/configs/mockup/on_view_mode.php index 7c18958..9963106 100644 --- a/src/configs/mockup/on_view_mode.php +++ b/src/configs/mockup/on_view_mode.php @@ -1,5 +1,5 @@ array('json', 'common', 'flexbox', 'default') )); \ No newline at end of file diff --git a/src/ex/controllers/app/home_ctrl.php b/src/ex/controllers/app/home_ctrl.php index 8276eb9..9d7e738 100644 --- a/src/ex/controllers/app/home_ctrl.php +++ b/src/ex/controllers/app/home_ctrl.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace prj\ex\controllers\app; -use \bs_tts\use_iol as IOL; +use \tts\use_iol as IOL; class home_ctrl { public $page_output; diff --git a/src/ex/inputs/app/home_in.php b/src/ex/inputs/app/home_in.php index 6980795..d687ed0 100644 --- a/src/ex/inputs/app/home_in.php +++ b/src/ex/inputs/app/home_in.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace prj\ex\inputs\app; -use \tts\enum\INPUTS; -use \tts\enum\FIELD_FILTER; -use \tts\enum\HTML_FLAG; -use \tts\enum\DB_FILTER; +use \tts\INPUTS; +use \tts\FIELD_FILTER; +use \tts\HTML_FLAG; +use \tts\DB_FILTER; -use \bs_tts\use_io as IO; +use \tts\use_io as IO; class home_in { @@ -22,7 +22,7 @@ class home_in { */ public static function name_demo(): array { - \bs_tts\safer_io::init_json(); // Staticly set JSON data if any + \tts\safer_io::init_json(); // Staticly set JSON data if any $required_post_string_field = new IO(); $required_post_string_field->input_type = INPUTS::post; diff --git a/src/ex/logic/app/home_logic.php b/src/ex/logic/app/home_logic.php index a771cd9..538084d 100644 --- a/src/ex/logic/app/home_logic.php +++ b/src/ex/logic/app/home_logic.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace prj\ex\logic\app; -use \bs_tts\safer_io as SafeIO; +use \tts\safer_io as SafeIO; class home_logic { public static function name_demo(array & $input): void { - $model = new \prj\ex\models\app\home_model(\main_tts\registry::get('db')); + $model = new \prj\ex\models\app\home_model(\tts\registry::get('db')); $submitted = true; foreach(SafeIO::logic_sanitize($input) as $data) { diff --git a/src/ex/models/app/home_model.php b/src/ex/models/app/home_model.php index 7ef44be..e3d42ef 100644 --- a/src/ex/models/app/home_model.php +++ b/src/ex/models/app/home_model.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace prj\ex\models\app; -class home_model extends \tts\database\model { +class home_model extends \tts\model { protected $pdo; protected $table = "test_names"; @@ -36,19 +36,19 @@ class home_model extends \tts\database\model { try { $this->pdo->query($create_table_sql); } catch (\PDOException $e) { - echo \tts\exceptions\DB_Exception::customMessage($e, "Unable to make table!"); + echo \tts\DB_Exception::customMessage($e, "Unable to make table!"); } } public function populate($rows): void { - $dummy = new \tts\database\dummy_data($this->pdo); - $data = [ 'first_name' => \tts\arrays\mocking\rnd_names::get_first_names(), - 'last_name' => \tts\arrays\mocking\rnd_names::get_last_names(), - 'age' => \tts\arrays\mocking\rnd_names::mock_age() ]; + $dummy = new \tts\dummy_data($this->pdo); + $data = [ 'first_name' => \tts\rnd_names::get_first_names(), + 'last_name' => \tts\rnd_names::get_last_names(), + 'age' => \tts\rnd_names::mock_age() ]; try { $dummy->add_dummy_data($this->table, $rows, $data); } catch (\PDOException $e) { - echo \tts\exceptions\DB_Exception::customMessage($e, "Unable to populate table!"); + echo \tts\DB_Exception::customMessage($e, "Unable to populate table!"); } } @@ -60,7 +60,7 @@ class home_model extends \tts\database\model { try { $status = $this->save(); } catch (\PDOException $e) { - echo \tts\exceptions\DB_Exception::customMessage($e, "Unable to save changes!"); + echo \tts\DB_Exception::customMessage($e, "Unable to save changes!"); } if ($status === self::successful_save) { return true; // It saved @@ -77,7 +77,7 @@ class home_model extends \tts\database\model { $result = $this->pdo->query($sql); return self::pdo_fetch_lazy($result); } catch (\PDOException $e) { - echo \tts\exceptions\DB_Exception::customMessage($e); + echo \tts\DB_Exception::customMessage($e); } } } \ No newline at end of file diff --git a/src/ex/outputs/app/home_out.php b/src/ex/outputs/app/home_out.php index 407b666..154b064 100644 --- a/src/ex/outputs/app/home_out.php +++ b/src/ex/outputs/app/home_out.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace prj\ex\outputs\app; -use \bs_tts\safer_io as SafeIO; +use \tts\safer_io as SafeIO; class home_out { @@ -21,7 +21,7 @@ class home_out { $key = $html['name'] ?? ""; $html_output[$key] = $html['html']; - if (\bs_tts\common::get_count($html['errors'])) { + if (\tts\common::get_count($html['errors'])) { $errors[$key] = $html['errors'][$key]; } } @@ -30,7 +30,7 @@ class home_out { $first_name = $html_output['first_name'] ?? "Unknown"; $last_name = $html_output['last_name'] ?? "Unknown"; - $ret['main'] = (\bs_tts\common::get_count($errors)) ? "" : "Hello, {$first_name} {$last_name}, you are {$age} years old!" . PHP_EOL; + $ret['main'] = (\tts\common::get_count($errors)) ? "" : "Hello, {$first_name} {$last_name}, you are {$age} years old!" . PHP_EOL; $ret['errors'] = $errors; } else { $ret['main'] = "Welcome"; diff --git a/src/ex/outputs/bills/notices_out.php b/src/ex/outputs/bills/notices_out.php index 1164163..edaf7ed 100644 --- a/src/ex/outputs/bills/notices_out.php +++ b/src/ex/outputs/bills/notices_out.php @@ -24,10 +24,10 @@ class notices_out { } public static function gen_pdf_for_late_payment(string $html_code): void { - $style_sheet = file_get_contents(\bs_tts\site_helper::get_root() . \bs_tts\site_helper::get_project() . 'views/default/bills/notice_of_late_payment_css.php'); + $style_sheet = file_get_contents(\tts\site_helper::get_root() . \tts\site_helper::get_project() . 'views/default/bills/notice_of_late_payment_css.php'); require_once TTS_VENDOR . 'autoload.php'; - $mpdf = new \Mpdf\Mpdf(['tempDir' => \bs_tts\site_helper::get_root() . '/tmp/mpdf']); // chown www-data, chmod 775 + $mpdf = new \Mpdf\Mpdf(['tempDir' => \tts\site_helper::get_root() . '/tmp/mpdf']); // chown www-data, chmod 775 $mpdf->AddFontDirectory(PROJECT_ASSETS_DIR . '/fonts'); $mpdf->fontdata['jennasue'] = ['R'=>"JennaSue.ttf"]; diff --git a/src/main.php b/src/main.php index 4c21284..877df01 100644 --- a/src/main.php +++ b/src/main.php @@ -1,5 +1,7 @@ key); + $enc = new \tts\encryption($this->key); foreach($levels as $level) { echo "ENC: Level = $level
" . PHP_EOL; $enc->change_security_level($level); @@ -70,7 +70,7 @@ class enc_ctrl { public function sodium() { // 0.0041 Seconds $key = "oH5LUubQXkUgC2sXkxahLnzgcZokVFANyxAew+kOvuk="; - $crypto = new \tts\services\paragon_crypto\crypto($key); + $crypto = new \tts\crypto($key); // echo $crypto->a_single_key_maker(); @@ -91,7 +91,7 @@ class enc_ctrl { public function storage() { $key = "78a5011b9997cd03a28a3412c66565b7c32715b35e055d7abfc228236308d3b2"; - $sc = new \tts\services\paragon_crypto\sodium_storage($key); + $sc = new \tts\sodium_storage($key); $startTime = microtime(true); $encoded = $sc->encrypt($this->get_roles()); @@ -113,7 +113,7 @@ class enc_ctrl { public function sodium_pwd_test() { // 0.1233 Seconds $startTime = microtime(true); - $c = new \tts\services\paragon_crypto\password_storage(); + $c = new \tts\password_storage(); // $key = $c->generate_a_key(); $key = "9054695cc0f4080c15865de470f63ee993478b14c357eb910c815a4e0a1d4401"; diff --git a/src/mockup/controllers/app/home_ctrl.php b/src/mockup/controllers/app/home_ctrl.php index 360dcaa..2109ff8 100644 --- a/src/mockup/controllers/app/home_ctrl.php +++ b/src/mockup/controllers/app/home_ctrl.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace prj\mockup\controllers\app; -use \bs_tts\use_iol as IOL; +use \tts\use_iol as IOL; class home_ctrl { public $page_output; diff --git a/src/mockup/inputs/app/home_in.php b/src/mockup/inputs/app/home_in.php index 0b6f30c..bda2c06 100644 --- a/src/mockup/inputs/app/home_in.php +++ b/src/mockup/inputs/app/home_in.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace prj\mockup\inputs\app; -use \tts\enum\INPUTS; -use \tts\enum\FIELD_FILTER; -use \tts\enum\HTML_FLAG; -use \tts\enum\DB_FILTER; +use \tts\INPUTS; +use \tts\FIELD_FILTER; +use \tts\HTML_FLAG; +use \tts\DB_FILTER; -use \bs_tts\use_io as IO; +use \tts\use_io as IO; class home_in { @@ -22,7 +22,7 @@ class home_in { */ public static function name_demo(): array { - \bs_tts\safer_io::init_json(); // Staticly set JSON data if any + \tts\safer_io::init_json(); // Staticly set JSON data if any $required_post_string_field = new IO(); $required_post_string_field->input_type = INPUTS::post; diff --git a/src/mockup/logic/app/home_logic.php b/src/mockup/logic/app/home_logic.php index 71d6ec8..ce73449 100644 --- a/src/mockup/logic/app/home_logic.php +++ b/src/mockup/logic/app/home_logic.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace prj\mockup\logic\app; -use \bs_tts\safer_io as SafeIO; +use \tts\safer_io as SafeIO; class home_logic { public static function name_demo(array & $input): void { - $model = new \prj\mockup\models\app\home_model(\main_tts\registry::get('db')); + $model = new \prj\mockup\models\app\home_model(\tts\registry::get('db')); $submitted = true; foreach(SafeIO::logic_sanitize($input) as $data) { diff --git a/src/mockup/models/app/home_model.php b/src/mockup/models/app/home_model.php index c09e2f6..cc30de6 100644 --- a/src/mockup/models/app/home_model.php +++ b/src/mockup/models/app/home_model.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace prj\mockup\models\app; -class home_model extends \tts\database\model { +class home_model extends \tts\model { protected $pdo; protected $table = "test_names"; public function __construct($dbh) { -// \tts\exceptions\DB_Exception::$error_message = "Home Model Error"; +// \tts\DB_Exception::$error_message = "Home Model Error"; $this->pdo = $dbh; } @@ -36,19 +36,19 @@ class home_model extends \tts\database\model { try { $this->pdo->query($create_table_sql); } catch (\PDOException $e) { - echo \tts\exceptions\DB_Exception::customMessage($e, "Unable to make table!"); + echo \tts\DB_Exception::customMessage($e, "Unable to make table!"); } } public function populate($rows): void { - $dummy = new \tts\database\dummy_data($this->pdo); - $data = [ 'first_name' => \tts\arrays\mocking\rnd_names::get_first_names(), - 'last_name' => \tts\arrays\mocking\rnd_names::get_last_names(), - 'age' => \tts\arrays\mocking\rnd_names::mock_age() ]; + $dummy = new \tts\dummy_data($this->pdo); + $data = [ 'first_name' => \tts\rnd_names::get_first_names(), + 'last_name' => \tts\rnd_names::get_last_names(), + 'age' => \tts\rnd_names::mock_age() ]; try { $dummy->add_dummy_data($this->table, $rows, $data); } catch (\PDOException $e) { - echo \tts\exceptions\DB_Exception::customMessage($e, "Unable to populate table!"); + echo \tts\DB_Exception::customMessage($e, "Unable to populate table!"); } } @@ -60,7 +60,7 @@ class home_model extends \tts\database\model { try { $status = $this->save(); } catch (\PDOException $e) { - echo \tts\exceptions\DB_Exception::customMessage($e, "Unable to save changes!"); + echo \tts\DB_Exception::customMessage($e, "Unable to save changes!"); } if ($status === self::successful_save) { return true; // It saved @@ -77,7 +77,7 @@ class home_model extends \tts\database\model { $result = $this->pdo->query($sql); return self::pdo_fetch_lazy($result); } catch (\PDOException $e) { - echo \tts\exceptions\DB_Exception::customMessage($e); + echo \tts\DB_Exception::customMessage($e); } } } \ No newline at end of file diff --git a/src/mockup/outputs/app/home_out.php b/src/mockup/outputs/app/home_out.php index dd2d39c..4607db3 100644 --- a/src/mockup/outputs/app/home_out.php +++ b/src/mockup/outputs/app/home_out.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace prj\mockup\outputs\app; -use \bs_tts\safer_io as SafeIO; +use \tts\safer_io as SafeIO; class home_out { @@ -21,7 +21,7 @@ class home_out { $key = $html['name'] ?? ""; $html_output[$key] = $html['html']; - if (\bs_tts\common::get_count($html['errors'])) { + if (\tts\common::get_count($html['errors'])) { $errors[$key] = $html['errors'][$key]; } } @@ -30,7 +30,7 @@ class home_out { $first_name = $html_output['first_name'] ?? "Unknown"; $last_name = $html_output['last_name'] ?? "Unknown"; - $ret['main'] = (\bs_tts\common::get_count($errors)) ? "" : "Hello, {$first_name} {$last_name}, you are {$age} years old!" . PHP_EOL; + $ret['main'] = (\tts\common::get_count($errors)) ? "" : "Hello, {$first_name} {$last_name}, you are {$age} years old!" . PHP_EOL; $ret['errors'] = $errors; } else { $ret['main'] = "Welcome"; diff --git a/src/mockup/outputs/bills/notices_out.php b/src/mockup/outputs/bills/notices_out.php index d8b91be..b419ac0 100644 --- a/src/mockup/outputs/bills/notices_out.php +++ b/src/mockup/outputs/bills/notices_out.php @@ -24,10 +24,10 @@ class notices_out { } public static function gen_pdf_for_late_payment(string $html_code): void { - $style_sheet = file_get_contents(\bs_tts\site_helper::get_root() . \bs_tts\site_helper::get_project() . 'views/default/bills/notice_of_late_payment_css.php'); + $style_sheet = file_get_contents(\tts\site_helper::get_root() . \tts\site_helper::get_project() . 'views/default/bills/notice_of_late_payment_css.php'); require_once TTS_VENDOR . 'autoload.php'; - $mpdf = new \Mpdf\Mpdf(['tempDir' => \bs_tts\site_helper::get_root() . '/tmp/mpdf']); // chown www-data, chmod 775 + $mpdf = new \Mpdf\Mpdf(['tempDir' => \tts\site_helper::get_root() . '/tmp/mpdf']); // chown www-data, chmod 775 $mpdf->AddFontDirectory(PROJECT_ASSETS_DIR . '/fonts'); $mpdf->fontdata['jennasue'] = ['R'=>"JennaSue.ttf"]; diff --git a/src/services/ex/loadall.php b/src/services/ex/loadall.php deleted file mode 100644 index 781f84b..0000000 --- a/src/services/ex/loadall.php +++ /dev/null @@ -1,54 +0,0 @@ -register('html_filter', function() { - return new \tts\services\html_filter(); -}); -/* Contents of : on_log.php */ - -\main_tts\registry::get('di')->register('log', function(array $arg) { - $file_name = null; - if (isset($arg[0]) && is_string($arg[0])) { - $file_name = $arg[0]; // filename - } - - if (isset($arg[1]) && is_int($arg[1])) { - $count = $arg[1]; // max count - return new \tts\services\log($file_name, $count); - } - - if (! empty($file_name)) { - return new \tts\services\log($file_name); - } - - return new \tts\services\log(); -}); -/* Contents of : on_templates.php */ - -\main_tts\registry::get('di')->register('templates', function(array $arg) { - $file_type = '.tpl'; - if (isset($arg[0]) && is_string($arg[0])) { - $file_type = $arg[0]; - } - return new \tts\services\liquid_templates($file_type); -}); -/* Contents of : on_test_db.php */ - -\main_tts\registry::get('di')->register('db_mocker', function($args) { - try { - $conn = new \PDO('sqlite::memory:'); - // set the PDO error mode to exception - $conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - return $conn; - } catch (\PDOException $e) { - echo $e->getMessage(); - } catch (\Exception $e) { - echo $e->getMessage(); - } -}); \ No newline at end of file diff --git a/src/services/ex/on_html_filter.php b/src/services/ex/on_html_filter.php index 2e609f2..71f6f18 100644 --- a/src/services/ex/on_html_filter.php +++ b/src/services/ex/on_html_filter.php @@ -2,6 +2,6 @@ declare(strict_types=1); -\main_tts\registry::get('di')->register('html_filter', function() { - return new \tts\services\html_filter(); +\tts\registry::get('di')->register('html_filter', function() { + return new \tts\html_filter(); }); \ No newline at end of file diff --git a/src/services/ex/on_log.php b/src/services/ex/on_log.php index 5f5c308..3a77542 100644 --- a/src/services/ex/on_log.php +++ b/src/services/ex/on_log.php @@ -2,7 +2,7 @@ declare(strict_types=1); -\main_tts\registry::get('di')->register('log', function(array $arg) { +\tts\registry::get('di')->register('log', function(array $arg) { $file_name = null; if (isset($arg[0]) && is_string($arg[0])) { $file_name = $arg[0]; // filename @@ -10,12 +10,12 @@ declare(strict_types=1); if (isset($arg[1]) && is_int($arg[1])) { $count = $arg[1]; // max count - return new \tts\services\log($file_name, $count); + return new \tts\log($file_name, $count); } if (! empty($file_name)) { - return new \tts\services\log($file_name); + return new \tts\log($file_name); } - return new \tts\services\log(); + return new \tts\log(); }); \ No newline at end of file diff --git a/src/services/ex/on_templates.php b/src/services/ex/on_templates.php index 4adf54e..7aca185 100644 --- a/src/services/ex/on_templates.php +++ b/src/services/ex/on_templates.php @@ -2,10 +2,10 @@ declare(strict_types=1); -\main_tts\registry::get('di')->register('templates', function(array $arg) { +\tts\registry::get('di')->register('templates', function(array $arg) { $file_type = '.tpl'; if (isset($arg[0]) && is_string($arg[0])) { $file_type = $arg[0]; } - return new \tts\services\liquid_templates($file_type); + return new \tts\liquid_templates($file_type); }); \ No newline at end of file diff --git a/src/services/ex/on_test_db.php b/src/services/ex/on_test_db.php index 9cf2948..f14b1cc 100644 --- a/src/services/ex/on_test_db.php +++ b/src/services/ex/on_test_db.php @@ -2,7 +2,7 @@ declare(strict_types=1); -\main_tts\registry::get('di')->register('db_mocker', function($args) { +\tts\registry::get('di')->register('db_mocker', function($args) { try { $conn = new \PDO('sqlite::memory:'); // set the PDO error mode to exception diff --git a/src/services/mockup/loadall.php b/src/services/mockup/loadall.php index bb87c6a..29a5ae7 100644 --- a/src/services/mockup/loadall.php +++ b/src/services/mockup/loadall.php @@ -6,14 +6,12 @@ /* Contents of : on_html_filter.php */ - -\main_tts\registry::get('di')->register('html_filter', function() { - return new \tts\services\html_filter(); +\tts\registry::get('di')->register('html_filter', function() { + return new \tts\html_filter(); }); /* Contents of : on_log.php */ - -\main_tts\registry::get('di')->register('log', function(array $arg) { +\tts\registry::get('di')->register('log', function(array $arg) { $file_name = null; if (isset($arg[0]) && is_string($arg[0])) { $file_name = $arg[0]; // filename @@ -21,43 +19,38 @@ if (isset($arg[1]) && is_int($arg[1])) { $count = $arg[1]; // max count - return new \tts\services\log($file_name, $count); + return new \tts\log($file_name, $count); } if (! empty($file_name)) { - return new \tts\services\log($file_name); + return new \tts\log($file_name); } - return new \tts\services\log(); + return new \tts\log(); }); /* Contents of : on_session_encryption.php */ -/** - * @author Robert Strutts - * @copyright Copyright (c) 2022, Robert Strutts. - * @license https://mit-license.org/ - */ - -\main_tts\registry::get('di')->register('session_encryption', function($args) { +\tts\registry::get('di')->register('session_encryption', function($args) { try { - $key = \main_tts\configure::get('sessions', 'session_key'); - return new \tts\services\paragon_crypto\sodium_storage($key); + return new \tts\sodium_storage( + \tts\configure::get('sessions', 'session_key') + ); } catch (\Exception $e) { } }); /* Contents of : on_templates.php */ -\main_tts\registry::get('di')->register('templates', function(array $arg) { +\tts\registry::get('di')->register('templates', function(array $arg) { $file_type = '.tpl'; if (isset($arg[0]) && is_string($arg[0])) { $file_type = $arg[0]; } - return new \tts\services\liquid_templates($file_type); + return new \tts\liquid_templates($file_type); }); /* Contents of : on_test_db.php */ -\main_tts\registry::get('di')->register('db_mocker', function($args) { +\tts\registry::get('di')->register('db_mocker', function($args) { try { $conn = new \PDO('sqlite::memory:'); // set the PDO error mode to exception diff --git a/src/services/mockup/on_html_filter.php b/src/services/mockup/on_html_filter.php index 0a3155a..90b3708 100644 --- a/src/services/mockup/on_html_filter.php +++ b/src/services/mockup/on_html_filter.php @@ -1,5 +1,5 @@ register('html_filter', function() { - return new \tts\services\html_filter(); +\tts\registry::get('di')->register('html_filter', function() { + return new \tts\html_filter(); }); \ No newline at end of file diff --git a/src/services/mockup/on_log.php b/src/services/mockup/on_log.php index 91a26fd..b4b91f5 100644 --- a/src/services/mockup/on_log.php +++ b/src/services/mockup/on_log.php @@ -1,6 +1,6 @@ register('log', function(array $arg) { +\tts\registry::get('di')->register('log', function(array $arg) { $file_name = null; if (isset($arg[0]) && is_string($arg[0])) { $file_name = $arg[0]; // filename @@ -8,12 +8,12 @@ if (isset($arg[1]) && is_int($arg[1])) { $count = $arg[1]; // max count - return new \tts\services\log($file_name, $count); + return new \tts\log($file_name, $count); } if (! empty($file_name)) { - return new \tts\services\log($file_name); + return new \tts\log($file_name); } - return new \tts\services\log(); + return new \tts\log(); }); \ No newline at end of file diff --git a/src/services/mockup/on_session_encryption.php b/src/services/mockup/on_session_encryption.php index 9ac80e3..d200edb 100644 --- a/src/services/mockup/on_session_encryption.php +++ b/src/services/mockup/on_session_encryption.php @@ -1,15 +1,10 @@ - * @copyright Copyright (c) 2022, Robert Strutts. - * @license https://mit-license.org/ - */ - -\main_tts\registry::get('di')->register('session_encryption', function($args) { +\tts\registry::get('di')->register('session_encryption', function($args) { try { - $key = \main_tts\configure::get('sessions', 'session_key'); - return new \tts\services\paragon_crypto\sodium_storage($key); + return new \tts\sodium_storage( + \tts\configure::get('sessions', 'session_key') + ); } catch (\Exception $e) { } diff --git a/src/services/mockup/on_templates.php b/src/services/mockup/on_templates.php index 622b755..92366c1 100644 --- a/src/services/mockup/on_templates.php +++ b/src/services/mockup/on_templates.php @@ -1,9 +1,9 @@ register('templates', function(array $arg) { +\tts\registry::get('di')->register('templates', function(array $arg) { $file_type = '.tpl'; if (isset($arg[0]) && is_string($arg[0])) { $file_type = $arg[0]; } - return new \tts\services\liquid_templates($file_type); + return new \tts\liquid_templates($file_type); }); \ No newline at end of file diff --git a/src/services/mockup/on_test_db.php b/src/services/mockup/on_test_db.php index bdc127b..40ffec6 100644 --- a/src/services/mockup/on_test_db.php +++ b/src/services/mockup/on_test_db.php @@ -1,6 +1,6 @@ register('db_mocker', function($args) { +\tts\registry::get('di')->register('db_mocker', function($args) { try { $conn = new \PDO('sqlite::memory:'); // set the PDO error mode to exception