diff --git a/src/bootstrap/auto_loader.php b/src/bootstrap/auto_loader.php index 70c6809..d4ef872 100644 --- a/src/bootstrap/auto_loader.php +++ b/src/bootstrap/auto_loader.php @@ -118,7 +118,7 @@ class Psr4AutoloaderClass { * @return bool True if the file exists, false if not. */ private function require_file(string $path, string $file): bool { - $safer_file = \tts\requires::safer_file_exists($file, $path); + $safer_file = \bs_tts\requires::safer_file_exists($file, $path); if ($safer_file !== false) { if (! isset($this->loaded_files[$safer_file])) { require $safer_file; diff --git a/src/bootstrap/common.php b/src/bootstrap/common.php index f7e948a..7c564f1 100644 --- a/src/bootstrap/common.php +++ b/src/bootstrap/common.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace tts; +namespace bs_tts; final class common { @@ -11,7 +11,7 @@ final class common { } public static function has_user_right(string $right): bool { -// $session = \tts\main\registry::get('di')->get_service('session'); +// $session = \main_tts\registry::get('di')->get_service('session'); $rights = (isset($_SESSION['users_rights'])) ? $_SESSION['users_rights'] : false; if ($rights === false) { return false; @@ -26,7 +26,7 @@ final class common { } public static function get_user_id(): int { - $session = \tts\main\registry::get('di')->get_service('session'); + $session = \main_tts\registry::get('di')->get_service('session'); $sid = (isset($_SESSION['user_id'])) ? $_SESSION['user_id'] : 0; return intval($sid); } @@ -256,7 +256,7 @@ final class common { * @param bool end - if true ends the script */ public static function dump($var = 'nothing', $end = true): void { - if (\tts\main\configure::get('security', 'show_dumps') !== true) { + if (\main_tts\configure::get('security', 'show_dumps') !== true) { return; } if (!is_object($var)) { @@ -270,7 +270,7 @@ final class common { echo 'It is TRUE!'; } elseif (is_resource($var)) { echo 'VAR IS a RESOURCE'; - } elseif (is_array($var) && \tts\common::get_count($var) == 0) { + } elseif (is_array($var) && self::get_count($var) == 0) { echo 'VAR IS an EMPTY ARRAY!'; } elseif (is_numeric($var)) { echo 'VAR is a NUMBER = ' . $var; diff --git a/src/bootstrap/errors.php b/src/bootstrap/errors.php index 639f628..d25bef6 100644 --- a/src/bootstrap/errors.php +++ b/src/bootstrap/errors.php @@ -3,7 +3,7 @@ declare(strict_types=1); define('WORD_WRAP_CHRS', 80); // Letters before Line Wrap on Errors -$root = \tts\site_helper::get_root(); +$root = \bs_tts\site_helper::get_root(); if (!defined('TTS_PROJECT_LOGS_DIR')) { if (! empty($root)) { define('TTS_PROJECT_LOGS_DIR', $root . 'logs'); @@ -26,9 +26,9 @@ function tts_broken_error($ex = ''): void { \tts\api::error(array('response' => $internal_error, 'code' => 500, 'reason' => 'Internal Error')); } - if (\tts\main\configure::get('tts', 'live') === true) { - $resource = \tts\main\configure::get('tts', 'error_page'); - $exists = \tts\requires::secure_include('views/errors', $resource); // Show Broken Page + if (\main_tts\configure::get('tts', 'live') === true) { + $resource = \main_tts\configure::get('tts', 'error_page'); + $exists = \bs_tts\requires::secure_include('views/errors', $resource); // Show Broken Page if ($exists === false) { echo "Sorry, we had an error...We apologize for any inconvenience this may cause."; } @@ -46,14 +46,14 @@ function tts_mini_view(string $file, string $render, string $msg): string { header('Content-Type: text/html; charset=utf-8', true, 200); } - \tts\main\views::ob_start(); + \main_tts\views::ob_start(); $saved_ob_level = ob_get_level(); $mini = new stdClass(); $mini->page_output = $msg; $file = 'templates/' . $file; - \tts\requires::secure_include($file, $render, $mini); + \bs_tts\requires::secure_include($file, $render, $mini); // If you really must close all of your output buffers except one, this'll do it: while (ob_get_level() > $saved_ob_level) { @@ -71,7 +71,7 @@ function tts_is_on_error_page(): bool { if (\tts\console_app::is_cli()) { exit(1); } else { - return (stripos(\tts\site_helper::tts_request_uri(), "error.html") !== false); + return (stripos(\bs_tts\site_helper::tts_request_uri(), "error.html") !== false); } } @@ -139,17 +139,17 @@ function tts_email_error($a_error): bool { } try { - $exists = \tts\main\registry::get('di')->exists('log'); + $exists = \main_tts\registry::get('di')->exists('log'); if ($exists) { - $log = \tts\main\registry::get('di')->get_service('log', ['errors']); + $log = \main_tts\registry::get('di')->get_service('log', ['errors']); $log->write($errors); } } catch (Exception $e) { } - $emails = \tts\main\configure::get('email', 'admin_emails'); + $emails = \main_tts\configure::get('email', 'admin_emails'); - $sitename = \tts\main\configure::get('tts', 'site_name'); + $sitename = \main_tts\configure::get('tts', 'site_name'); if (!empty($sitename)) { $site = $sitename; @@ -160,21 +160,21 @@ function tts_email_error($a_error): bool { $subject = 'System error in ' . $site; $from = 'noreply@' . str_replace(" ", "_", $site); - if ($emails !== false && \tts\common::get_count($emails) > 0) { - if (\tts\main\configure::get('email', 'email_on_errors') === true) { - $email = \tts\main\registry::get('di')->get_service('emailer'); + if ($emails !== false && \bs_tts\common::get_count($emails) > 0) { + if (\main_tts\configure::get('email', 'email_on_errors') === true) { + $email = \main_tts\registry::get('di')->get_service('emailer'); $email::send_email(array('to' => array('addresses' => $emails), 'from' => $from, 'subject' => $subject, 'message' => $errors)); } } - if (\tts\main\configure::get('twilio', 'send_on_errors') === true) { - $twillio = \tts\main\registry::get('di')->get_service('twilio'); + if (\main_tts\configure::get('twilio', 'send_on_errors') === true) { + $twillio = \main_tts\registry::get('di')->get_service('twilio'); $twilioClient = new \Twilio\Rest\Client(tts_configure::get('twilio', 'AccountSid'), tts_configure::get('twilio', 'AuthToken')); - $admins = \tts\main\configure::get('twilio', 'admins'); + $admins = \main_tts\configure::get('twilio', 'admins'); foreach ($admins as $number => $name) { $sms = $twilioClient->account->messages->create( $number, array( - 'from' => \tts\main\configure::get('twilio', 'from_phone_number'), + 'from' => \main_tts\configure::get('twilio', 'from_phone_number'), 'body' => "Hey $name, {$subject} \n {$errors}" ) ); @@ -197,15 +197,15 @@ function tts_json_error_handler($data) { $data = wordwrap($data, WORD_WRAP_CHRS, "
\n"); try { - $exists = \tts\main\registry::get('di')->exists('log'); + $exists = \main_tts\registry::get('di')->exists('log'); if ($exists) { - $logs = \tts\main\registry::get('di')->get_service('log', ['all_errors']); + $logs = \main_tts\registry::get('di')->get_service('log', ['all_errors']); $logs->write($data); } } catch (Exception $e) { } - if (\tts\main\configure::get('tts', 'live') === true) { + if (\main_tts\configure::get('tts', 'live') === true) { \tts_email_error($data); } @@ -254,13 +254,13 @@ function tts_exception_handler(\Throwable $exception) { tts_json_error_handler($err); - $assets = \tts\site_helper::get_asset("uikit/css/uikit.gradient.min.css"); + $assets = \bs_tts\site_helper::get_asset("uikit/css/uikit.gradient.min.css"); $msg = ''; $msg .= '
'; $msg .= $common_err; $msg .= '
'; - if (\tts\main\configure::get('tts', 'live') === true) { + if (\main_tts\configure::get('tts', 'live') === true) { tts_global_error_handler(E_USER_ERROR, $err); } else { echo tts_mini_view('dev_error', 'tts', $msg); @@ -270,7 +270,7 @@ function tts_exception_handler(\Throwable $exception) { set_exception_handler('tts_exception_handler'); -if (\tts\main\configure::get('tts', 'live') === true) { +if (\main_tts\configure::get('tts', 'live') === true) { error_reporting(E_ALL ^ E_NOTICE); set_error_handler('tts_global_error_handler', E_ALL ^ (E_NOTICE | E_USER_NOTICE)); } else { @@ -286,12 +286,12 @@ function tts_custom_error_checker(): void { $a_errors = error_get_last(); if (is_array($a_errors)) { $msg = "Error: {$a_errors['message']} File:{$a_errors['file']} Line:{$a_errors['line']}."; - if (\tts\main\configure::get('tts', 'live') === true) { + if (\main_tts\configure::get('tts', 'live') === true) { $msg = wordwrap($msg, WORD_WRAP_CHRS, "
\n"); try { - $exists = \tts\main\registry::get('di')->exists('log'); + $exists = \main_tts\registry::get('di')->exists('log'); if ($exists) { - $logs = \tts\main\registry::get('di')->get_service('log', ['all_errors']); + $logs = \main_tts\registry::get('di')->get_service('log', ['all_errors']); $logs->write($msg); } } catch (Exception $e) { @@ -299,7 +299,7 @@ function tts_custom_error_checker(): void { } } else { - $assets = $assets = \tts\site_helper::get_asset("uikit/css/uikit.gradient.min.css"); + $assets = $assets = \bs_tts\site_helper::get_asset("uikit/css/uikit.gradient.min.css"); $mini = ''; $mini .= "\r\n\r\n"; @@ -346,21 +346,21 @@ function tts_global_error_handler(int $errno = 0, string $errstr = '', string $e tts_json_error_handler($err); - if (\tts\main\configure::get('tts', 'live') === false) { + if (\main_tts\configure::get('tts', 'live') === false) { return true; } if (\tts_is_on_error_page() === true) { - $resource = \tts\main\configure::get('tts', 'error_page'); - \tts\requires::secure_include('views/errors', $resource); + $resource = \main_tts\configure::get('tts', 'error_page'); + \bs_tts\requires::secure_include('views/errors', $resource); exit(1); // Prevent HTML Looping!!! } $http_response_code = 307; // 307 Temporary Redirect - $prj = \tts\main\configure::get('tts', 'default_project'); + $prj = \main_tts\configure::get('tts', 'default_project'); $ref = TTS_PROJECT_BASE_REF; - if (\tts\common::is_string_found($ref, '/') === false) { + if (\bs_tts\common::is_string_found($ref, '/') === false) { $ref .= '/'; } header('Location: ' . $ref . '/app/' . $prj . '/error.html', TRUE, $http_response_code); diff --git a/src/bootstrap/requires.php b/src/bootstrap/requires.php index ff26e6e..e73bf16 100644 --- a/src/bootstrap/requires.php +++ b/src/bootstrap/requires.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace tts; +namespace bs_tts; final class requires { @@ -80,13 +80,13 @@ final class requires { return false; } - $pos = \tts\common::string_last_position($file, "."); + $pos = \bs_tts\common::string_last_position($file, "."); if ($pos === false) { $file_type = ".php"; $file_name = $file; } else { - $file_name = \tts\common::get_string_left($file, $pos); - $file_kind = \tts\common::get_string_right($file, \tts\common::string_length($file) - $pos); + $file_name = \bs_tts\common::get_string_left($file, $pos); + $file_kind = \bs_tts\common::get_string_right($file, \bs_tts\common::string_length($file) - $pos); $file_type = match ($file_kind) { ".tpl" => ".tpl", default => ".php", @@ -116,8 +116,8 @@ final class requires { private static function secure_file(bool $return_contents, string $file, string $path, $local = null, array $args = array(), bool $load_once = true) { $dir = match ($path) { "dir_fixed" => "", - "framework", "tts" => \tts\main\TTS_FRAMEWORK, - default => \tts\site_helper::get_root(), // project + "framework", "tts" => \main_tts\TTS_FRAMEWORK, + default => \bs_tts\site_helper::get_root(), // project }; $versioned_file = self::safer_file_exists($file, $dir); diff --git a/src/bootstrap/safer_io.php b/src/bootstrap/safer_io.php index f564113..3133792 100644 --- a/src/bootstrap/safer_io.php +++ b/src/bootstrap/safer_io.php @@ -22,7 +22,7 @@ declare(strict_types=1); * false sense of security, and sometimes mangles perfectly good input. */ -namespace tts; +namespace bs_tts; enum HTML_FLAG { case raw; // Dangerious XSS attacks... @@ -113,21 +113,21 @@ final class use_io { final class use_iol { public static function auto_wire( string $root_folder, - string $folder, + string $file, string $method = 'index', string $db_service= 'db_mocker' ) { - $project = rtrim(\tts\site_helper::get_project(), '/'); + $project = rtrim(\bs_tts\site_helper::get_project(), '/'); - \tts\main\registry::set('db', \tts\main\registry::get('di')->get_service($db_service) ); + \main_tts\registry::set('db', \main_tts\registry::get('di')->get_service($db_service) ); - $class_name = "\\prj\\{$project}\\inputs\\{$root_folder}\\{$folder}_in"; + $class_name = "\\prj\\{$project}\\inputs\\{$root_folder}\\{$file}_in"; $input = $class_name::$method(); - $class_name = "\\prj\\{$project}\\logic\\{$root_folder}\\{$folder}_logic"; + $class_name = "\\prj\\{$project}\\logic\\{$root_folder}\\{$file}_logic"; $class_name::$method($input); - $class_name = "\\prj\\{$project}\\outputs\\{$root_folder}\\{$folder}_out"; + $class_name = "\\prj\\{$project}\\outputs\\{$root_folder}\\{$file}_out"; return $class_name::$method($input); } } @@ -163,7 +163,7 @@ final class safer_io { // HTML Purify library public static function p(string $string): string { - $purifer = \tts\main\registry::get('di')->get_service('html_filter'); + $purifer = \main_tts\registry::get('di')->get_service('html_filter'); if (!$purifer->has_loaded()) { $purifer->set_defaults(); } @@ -270,7 +270,7 @@ final class safer_io { if (is_string($item)) { return trim($item); } - if (\tts\common::get_count($data)) { + if (\bs_tts\common::get_count($data)) { $ret = []; foreach($data as $text) { if (is_bool($text) || is_int($text)) { @@ -338,7 +338,7 @@ final class safer_io { private static function get_safer_html($data, use_io $a) { if (is_string($data)) { return self::get_safer_string($data, $a); - } else if (\tts\common::get_count($data)) { + } else if (\bs_tts\common::get_count($data)) { $ret = []; foreach($data as $text) { if (is_bool($text) || is_int($text)) { @@ -442,7 +442,7 @@ final class safer_io { if ($field_type == FIELD_FILTER::raw_string || $field_type == FIELD_FILTER::raw ) { - if (\tts\common::get_count($safer_data)) { + if (\bs_tts\common::get_count($safer_data)) { $safer_data = $safer_data[0]; } } @@ -493,7 +493,7 @@ final class safer_io { $ret['html'] = $safer_html_data; $data[$input_field_name] = $safer_html_data; } - $ret['errors'] = (count($rules)) ? \tts\validator::validate($data, $rules, $messages) : []; + $ret['errors'] = (count($rules)) ? \bs_tts\validator::validate($data, $rules, $messages) : []; return $ret; } diff --git a/src/bootstrap/site_helper.php b/src/bootstrap/site_helper.php index 009315a..c70e56a 100644 --- a/src/bootstrap/site_helper.php +++ b/src/bootstrap/site_helper.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace tts; +namespace bs_tts; final class site_helper { @@ -61,14 +61,14 @@ final class site_helper { if (!empty(self::$REQUEST_URI) && self::$REQUEST_URI !== null) { $uri = self::$REQUEST_URI; } else if (isset($_SERVER['REQUEST_URI'])) { - $uri = \tts\safer_io::get_clean_server_var('REQUEST_URI'); + $uri = \bs_tts\safer_io::get_clean_server_var('REQUEST_URI'); } else { if (isset($_SERVER['argv'])) { - $uri = \tts\safer_io::get_clean_server_var('SCRIPT_NAME') . '?' . $_SERVER['argv'][0]; + $uri = \bs_tts\safer_io::get_clean_server_var('SCRIPT_NAME') . '?' . $_SERVER['argv'][0]; } elseif (isset($_SERVER['QUERY_STRING'])) { - $uri = \tts\safer_io::get_clean_server_var('SCRIPT_NAME') . '?' . \tts\safer_io::get_clean_server_var('QUERY_STRING'); + $uri = \bs_tts\safer_io::get_clean_server_var('SCRIPT_NAME') . '?' . \bs_tts\safer_io::get_clean_server_var('QUERY_STRING'); } else { - $uri = \tts\safer_io::get_clean_server_var('SCRIPT_NAME'); + $uri = \bs_tts\safer_io::get_clean_server_var('SCRIPT_NAME'); } } // Prevent multiple slashes to avoid cross site requests via the Form API. @@ -78,11 +78,11 @@ final class site_helper { } public static function tts_site_url(): string { - $server_port = \tts\safer_io::get_clean_server_var('SERVER_PORT'); - $secure_port_on = \tts\safer_io::get_clean_server_var('HTTPS'); + $server_port = \bs_tts\safer_io::get_clean_server_var('SERVER_PORT'); + $secure_port_on = \bs_tts\safer_io::get_clean_server_var('HTTPS'); $protocol = ($server_port == '443' || $secure_port_on == 'on') ? 'https://' : 'http://'; define('TTS_PROTOCOL', $protocol); - $domainName = \tts\safer_io::get_clean_server_var('HTTP_HOST'); + $domainName = \bs_tts\safer_io::get_clean_server_var('HTTP_HOST'); return $protocol . $domainName . "/"; } @@ -100,7 +100,7 @@ final class site_helper { $call_class = "\\" . $class; if (class_exists($call_class)) { - $auto_class = \tts\main\registry::get('di')->get_auto($call_class); + $auto_class = \main_tts\registry::get('di')->get_auto($call_class); if (method_exists($call_class, $method)) { return call_user_func_array([$auto_class, $method], $params); } @@ -109,7 +109,7 @@ final class site_helper { } private static function do_load_all_files(): void { - $project_folder = \tts\site_helper::get_project(); + $project_folder = \bs_tts\site_helper::get_project(); if ($project_folder === null || empty($project_folder) || @@ -123,7 +123,7 @@ final class site_helper { exit; } $configs_file = self::$ROOT . "configs/{$project_folder}loadall.php"; - $safer_configs_file = \tts\requires::safer_file_exists($configs_file); + $safer_configs_file = \bs_tts\requires::safer_file_exists($configs_file); if ($safer_configs_file !== false) { require $safer_configs_file; } else { @@ -133,7 +133,7 @@ final class site_helper { } $services_file = self::$ROOT . "services/{$project_folder}loadall.php"; - $safer_services_file = \tts\requires::safer_file_exists($services_file); + $safer_services_file = \bs_tts\requires::safer_file_exists($services_file); if ($safer_services_file !== false) { require $safer_services_file; } else { @@ -228,18 +228,18 @@ final class site_helper { public static function set_project_namespace() { $prj = rtrim(self::$ROOT, '/'); - \tts\main\registry::get('loader')->add_namespace("prj", $prj); + \main_tts\registry::get('loader')->add_namespace("prj", $prj); $up_one = dirname(self::$ROOT, 1); $project = self::$PRJ; define('TTS_SITE_URL', self::tts_site_url()); define('TTS_PROJECT_BASE_REF', TTS_SITE_URL . $project); - define("TTS_BROWSER", \tts\safer_io::get_clean_server_var('HTTP_USER_AGENT')); + define("TTS_BROWSER", \bs_tts\safer_io::get_clean_server_var('HTTP_USER_AGENT')); define("PROJECT_ASSETS_DIR", $up_one . "/public/assets/" . $project); define("ASSETS_DIR", $up_one . "/public/assets/"); - \tts\site_helper::do_load_all_files(); + \bs_tts\site_helper::do_load_all_files(); } } diff --git a/src/bootstrap/validator.php b/src/bootstrap/validator.php index 5911043..f78a19d 100644 --- a/src/bootstrap/validator.php +++ b/src/bootstrap/validator.php @@ -6,7 +6,7 @@ declare(strict_types=1); * @link https://www.phptutorial.net/php-tutorial/php-validation/ */ -namespace tts; +namespace bs_tts; class validator { @@ -29,7 +29,7 @@ class validator { private static function make_arrays(array $data, $field): array { $dataset = []; if (isset($data[$field])) { - if (\tts\common::get_count($data[$field])) { + if (\bs_tts\common::get_count($data[$field])) { foreach($data[$field] as $the_data) { $dataset[] = $the_data; } @@ -99,7 +99,7 @@ class validator { private static function is_required(array $data, string $field): bool { if (isset($data[$field])) { - if (\tts\common::get_count($data[$field])) { + if (\bs_tts\common::get_count($data[$field])) { return false; // Should not be an array here } if (is_string($data[$field])) { diff --git a/src/classes/api.php b/src/classes/api.php index c42a942..e0b9e70 100644 --- a/src/classes/api.php +++ b/src/classes/api.php @@ -225,7 +225,7 @@ class api { $data['code'] = $long_code; - $memory_check = \tts\common::get_bool(\tts\request::request_var('debug')); + $memory_check = \bs_tts\common::get_bool(\tts\request::request_var('debug')); if ($memory_check) { $echo = false; $data['memory_used'] = \tts\memory_usage::get_memory_stats($echo); @@ -242,7 +242,7 @@ class api { $data['result'] = true; $code = 200; // OK - $memory_check = \tts\common::get_bool(\tts\request::request_var('debug')); + $memory_check = \bs_tts\common::get_bool(\tts\request::request_var('debug')); if ($memory_check) { $echo = false; $data['memory_used'] = \tts\memory_usage::get_memory_stats($echo); diff --git a/src/classes/app.php b/src/classes/app.php index 755f563..3a1eab0 100644 --- a/src/classes/app.php +++ b/src/classes/app.php @@ -36,7 +36,7 @@ class app { * Do not declare a return type here, as it will Error out!! */ public function __construct() { - $full_route = \tts\site_helper::get_route(); + $full_route = \bs_tts\site_helper::get_route(); $no_hmtl = str_replace(".html", "", $full_route); // Find the Route @@ -45,7 +45,7 @@ class app { // Find the Method $the_method = $this->get_last_part($no_hmtl); - $params = \tts\site_helper::get_params(); + $params = \bs_tts\site_helper::get_params(); // Now load Route $is_from_the_controller = true; // TRUE for from Constructor... @@ -54,7 +54,7 @@ class app { private function get_ctrl_dir(): string { $ctrl = (\tts\console_app::is_cli()) ? "cli_" : ""; - return (\tts\site_helper::get_testing()) ? "test_" : $ctrl; + return (\bs_tts\site_helper::get_testing()) ? "test_" : $ctrl; } /** @@ -65,22 +65,22 @@ class app { * @retval action */ public function router(?string $route, ?string $method, $params, bool $is_controller = false) { - $ROOT = \tts\site_helper::get_root(); + $ROOT = \bs_tts\site_helper::get_root(); $file = ""; $class = ""; if (\tts\request::is_empty($route)) { - $uri = '/app/' . \tts\main\configure::get('tts', 'default_project'); + $uri = '/app/' . \main_tts\configure::get('tts', 'default_project'); } else { $uri = $route; } $filtered_uri = \tts\security::filter_uri($uri); - $safe_folders = \tts\requires::filter_dir_path( + $safe_folders = \bs_tts\requires::filter_dir_path( $this->get_first_chunks($filtered_uri) ); - if (\tts\requires::is_dangerous($safe_folders)) { + if (\bs_tts\requires::is_dangerous($safe_folders)) { $this->local404(); } @@ -89,21 +89,21 @@ class app { $this->local404(); } - $safe_file = \tts\requires::filter_dir_path( + $safe_file = \bs_tts\requires::filter_dir_path( $this->get_last_part($filtered_uri) ); - if (\tts\requires::is_dangerous($safe_file)) { + if (\bs_tts\requires::is_dangerous($safe_file)) { $this->local404(); } $test = $this->get_ctrl_dir(); - $dir = \tts\requires::safer_dir_exists($ROOT . \tts\site_helper::get_project() . "{$test}controllers/" . $safe_folders); + $dir = \bs_tts\requires::safer_dir_exists($ROOT . \bs_tts\site_helper::get_project() . "{$test}controllers/" . $safe_folders); //check for default site controller first if ($dir === false) { $this->local404(); } else { - $file = \tts\requires::safer_file_exists(basename($safe_file) . '_ctrl.php', $dir); + $file = \bs_tts\requires::safer_file_exists(basename($safe_file) . '_ctrl.php', $dir); if ($file !== false) { $class = \tts\security::filter_class($safe_folders) . "\\" . \tts\security::filter_class($safe_file . "_ctrl"); } else { @@ -135,7 +135,7 @@ class app { private function handle_my_errors($controller, string $method_name): void { // if (! method_exists($controller, "skip_default_error_handler_for_" . $method_name)) { -// require_once \tts\main\TTS_FRAMEWORK . 'bootstrap/errors.php'; +// require_once \main_tts\TTS_FRAMEWORK . 'bootstrap/errors.php'; // } } @@ -147,7 +147,7 @@ class app { * @retval type */ private function action(string $file, string $class, string $method, $params) { - $safer_file = \tts\requires::safer_file_exists($file); + $safer_file = \bs_tts\requires::safer_file_exists($file); if (! $safer_file) { $this->local404(); } @@ -158,7 +158,7 @@ class app { $use_api = \tts\request::is_api(); $test = $this->get_ctrl_dir(); - $project_folder = \tts\site_helper::get_project(); + $project_folder = \bs_tts\site_helper::get_project(); $call_class = "\\prj\\" . rtrim($project_folder, "/") . '\\' . $test . 'controllers\\' . $class; $controller = new $call_class(); diff --git a/src/classes/arrays/mocking/phone.php b/src/classes/arrays/mocking/phone.php index 1adb928..8b7bd4b 100644 --- a/src/classes/arrays/mocking/phone.php +++ b/src/classes/arrays/mocking/phone.php @@ -10,7 +10,7 @@ class phone { const AREACODES = [201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 212, 213, 214, 215, 216, 217, 218, 219, 220, 224, 225, 226, 228, 229, 231, 234, 236, 239, 240, 242, 246, 248, 249, 250, 251, 252, 253, 254, 256, 260, 262, 264, 267, 268, 269, 270, 272, 276, 281, 284, 289, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 323, 325, 330, 331, 334, 336, 337, 339, 340, 343, 345, 346, 347, 351, 352, 360, 361, 364, 365, 380, 385, 386, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 412, 413, 414, 415, 416, 417, 418, 419, 423, 424, 425, 430, 431, 432, 434, 435, 437, 438, 440, 441, 442, 443, 450, 458, 469, 470, 473, 475, 478, 479, 480, 484, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 512, 513, 514, 515, 516, 517, 518, 519, 520, 530, 531, 534, 539, 540, 541, 548, 551, 559, 561, 562, 563, 567, 570, 571, 573, 574, 575, 579, 580, 581, 585, 586, 587, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 612, 613, 614, 615, 616, 617, 618, 619, 620, 623, 626, 628, 629, 630, 631, 636, 639, 641, 646, 647, 649, 650, 651, 657, 660, 661, 662, 664, 667, 669, 670, 671, 678, 681, 682, 684, 701, 702, 703, 704, 705, 706, 707, 708, 709, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 724, 725, 727, 731, 732, 734, 737, 740, 743, 747, 754, 757, 758, 760, 762, 763, 765, 767, 769, 770, 772, 773, 774, 775, 778, 779, 780, 781, 782, 784, 785, 786, 787, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 815, 816, 817, 818, 819, 825, 828, 829, 830, 831, 832, 843, 845, 847, 848, 849, 850, 854, 856, 857, 858, 859, 860, 862, 863, 864, 865, 867, 868, 869, 870, 872, 873, 876, 878, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 912, 913, 914, 915, 916, 917, 918, 919, 920, 925, 928, 929, 930, 931, 934, 936, 937, 938, 939, 940, 941, 947, 949, 951, 952, 954, 956, 959, 970, 971, 972, 973, 978, 979, 980, 984, 985, 989]; private static function rnd_a(array $a) { - $array_count = \tts\common::get_count($a); + $array_count = \bs_tts\common::get_count($a); return $a[rand(0, $array_count - 1)]; } diff --git a/src/classes/assets.php b/src/classes/assets.php index be79ffb..f7c5435 100644 --- a/src/classes/assets.php +++ b/src/classes/assets.php @@ -25,14 +25,14 @@ final class assets { */ private static function attempts_root_dir(?string $path): bool { // up from src and back up to public - $open_base_dir_path = dirname(\tts\site_helper::get_root(), 1) . '/public/'; + $open_base_dir_path = dirname(\bs_tts\site_helper::get_root(), 1) . '/public/'; if ($path === null || $path === '') { return false; } - if (\tts\common::get_string_left($path, strlen($open_base_dir_path)) == $open_base_dir_path) { + if (\bs_tts\common::get_string_left($path, strlen($open_base_dir_path)) == $open_base_dir_path) { return false; } - if (\tts\common::get_string_left($path, 1) == '/') { + if (\bs_tts\common::get_string_left($path, 1) == '/') { return true; } return false; @@ -94,15 +94,15 @@ final class assets { * @retval boolean|string false is not found, else Asset REF */ public static function wrap_asset(string $file, string $scope = 'project') { - $scope = \tts\common::string_to_lowercase($scope); + $scope = \bs_tts\common::string_to_lowercase($scope); if ($scope === 'cdn') { - $proto = \tts\safer_io::get_clean_server_var('SERVER_PROTOCOL'); + $proto = \bs_tts\safer_io::get_clean_server_var('SERVER_PROTOCOL'); if ($proto === null) { $protocol = '://'; } else { $protocol = strtolower(substr($proto, 0, strpos($proto, '/'))) . '://'; } - return (\tts\common::is_string_found($file, '://') === true) ? $file : $protocol . $file; + return (\bs_tts\common::is_string_found($file, '://') === true) ? $file : $protocol . $file; } if ($scope === 'project' || $scope === 'app') { $path = PROJECT_ASSETS_DIR . "/"; @@ -123,7 +123,7 @@ final class assets { * @return string|bool */ private static function project_paths(string $file, string $scope = 'project'): string | bool { - $scope = \tts\common::string_to_lowercase($scope); + $scope = \bs_tts\common::string_to_lowercase($scope); if ($scope === 'cdn') { return ""; } else if ($scope === 'project' || $scope === 'app') { @@ -208,8 +208,8 @@ final class assets { $safe_path = \tts\security::filter_uri($path); $safe_file = \tts\security::filter_uri($file); - if (\tts\common::is_string_found($safe_file, '.auto.js')) { - $production = (\tts\main\configure::get('tts', 'live') === true) ? true : false; + if (\bs_tts\common::is_string_found($safe_file, '.auto.js')) { + $production = (\main_tts\configure::get('tts', 'live') === true) ? true : false; $safe_file = str_replace('.auto.js', '', $safe_file); if ( $production && file_exists($safe_path . $safe_file . '.min.js') ) { return $safe_file . '.min.js'; @@ -217,8 +217,8 @@ final class assets { return (file_exists($safe_path . $safe_file . '.js')) ? $safe_file . '.js' : false; } - if (\tts\common::is_string_found($safe_file, '.auto.css')) { - $production = (\tts\main\configure::get('tts', 'live') === true) ? true : false; + if (\bs_tts\common::is_string_found($safe_file, '.auto.css')) { + $production = (\main_tts\configure::get('tts', 'live') === true) ? true : false; $safe_file = str_replace('.auto.css', '', $safe_file); if ( $production && file_exists($safe_path . $safe_file . '.min.css') ) { return $safe_file . '.min.css'; diff --git a/src/classes/database/dummy_data.php b/src/classes/database/dummy_data.php index f9af801..89fa8a7 100644 --- a/src/classes/database/dummy_data.php +++ b/src/classes/database/dummy_data.php @@ -22,7 +22,7 @@ final class dummy_data { private function use_dummy_data(array $data): array { $ret = []; foreach ($data as $field => $array_values) { - $array_count = \tts\common::get_count($array_values); + $array_count = \bs_tts\common::get_count($array_values); if ($array_count) { $ret[$field] = $array_values[rand(0, $array_count - 1)]; } diff --git a/src/classes/database/help_save.php b/src/classes/database/help_save.php index 687b5e0..e11c073 100644 --- a/src/classes/database/help_save.php +++ b/src/classes/database/help_save.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace tts\database; -use \tts\safer_io as SafeIO; +use \bs_tts\safer_io as SafeIO; final class help_save { @@ -89,12 +89,12 @@ final class help_save { foreach(SafeIO::db_sanitize($input) as $data) { $key = $data['name'] ?? false; $value = $data['db'] ?? null; - $error_count = (isset($data['errors'])) ? \tts\common::get_count($data['errors']) : 0; + $error_count = (isset($data['errors'])) ? \bs_tts\common::get_count($data['errors']) : 0; if ($error_count) { return false; } - if (isset($data['meta']['missing']) && \tts\common::get_count($data['meta']['missing'])) { + if (isset($data['meta']['missing']) && \bs_tts\common::get_count($data['meta']['missing'])) { $this->missing = $data['meta']['missing']; } @@ -120,11 +120,11 @@ final class help_save { * the DB security and Inject stuff into the DB via POST, etc... */ public function auto_set_members(array $post = [], array $skip = ['route', 'm'], array $only_these = []): void { - if (\tts\main\configure::get('tts', 'live') === true) { + if (\main_tts\configure::get('tts', 'live') === true) { return; // Bail if LIVE } if (isset($post['json'])) { - $globals = \tts\safer_io::get_json_post_data(); + $globals = \bs_tts\safer_io::get_json_post_data(); } else { $json_post = count($post); $globals = ($json_post) ? $post : filter_input_array(INPUT_POST) ?? []; diff --git a/src/classes/exceptions/DB_Exception.php b/src/classes/exceptions/DB_Exception.php index 21ff440..dec3e8a 100644 --- a/src/classes/exceptions/DB_Exception.php +++ b/src/classes/exceptions/DB_Exception.php @@ -53,8 +53,8 @@ class DB_Exception extends \Exception { if (empty($message)) { $message = self::$error_message; } - $live = \tts\common::get_bool( \tts\main\configure::get('tts', 'live') ); - if ($live === false || \tts\common::has_user_right('debugger')) { + $live = \bs_tts\common::get_bool( \main_tts\configure::get('tts', 'live') ); + if ($live === false || \bs_tts\common::has_user_right('debugger')) { $msg = ($debug == DEBUGGER::basic || (self::$debug === DEBUGGER::basic && $debug === DEBUGGER::static) diff --git a/src/classes/html.php b/src/classes/html.php index 5ddfe0a..2a45289 100644 --- a/src/classes/html.php +++ b/src/classes/html.php @@ -26,7 +26,7 @@ final class html { if (count($a)) { foreach ($a as $k => $v) { if ($escape) { - $more .= " ". \tts\safer_io::h($k) . "=\"" . \tts\safer_io::h($v) . "\""; + $more .= " ". \bs_tts\safer_io::h($k) . "=\"" . \tts\safer_io::h($v) . "\""; } else { $more .= " {$k}=\"{$v}\""; } @@ -38,8 +38,8 @@ final class html { $compair_to = ($select_by == 'text') ? $text : $value; $selected = (!empty($default) && $default == $compair_to) ? 'selected' : ''; if ($escape) { - $value = \tts\safer_io::h($value); - $text = \tts\safer_io::h($text); + $value = \bs_tts\safer_io::h($value); + $text = \bs_tts\safer_io::h($text); } $values .= ""; @@ -64,7 +64,7 @@ final class html { echo "{$nl}{$nl}"; echo "\t{$nl}"; foreach($header_fields as $header_field) { - $field = ($escape) ? \tts\safer_io::h($header_field) : $header_field; + $field = ($escape) ? \bs_tts\safer_io::h($header_field) : $header_field; echo "\t\t{$nl}"; } echo "\t{$nl}"; @@ -72,7 +72,7 @@ final class html { foreach($fields as $field) { echo "\t{$nl}"; foreach($field as $td) { - $cell = ($escape) ? \tts\safer_io::h($td) : $td; + $cell = ($escape) ? \bs_tts\safer_io::h($td) : $td; echo "\t\t{$nl}"; } echo "\t{$nl}"; @@ -97,7 +97,7 @@ final class html { echo "{$nl}
{$field}
{$cell}
{$nl}"; echo "\t{$nl}"; foreach($header_fields as $header_field) { - $field = ($escape) ? \tts\safer_io::h($header_field) : $header_field; + $field = ($escape) ? \bs_tts\safer_io::h($header_field) : $header_field; echo "\t\t{$nl}"; } echo "\t{$nl}"; @@ -110,7 +110,7 @@ final class html { } $td = $value ?? ""; if (is_string($td)) { - $cell = ($escape) ? \tts\safer_io::h($td) : $td; + $cell = ($escape) ? \bs_tts\safer_io::h($td) : $td; } else { $cell = (string) $td; } diff --git a/src/classes/html_document.php b/src/classes/html_document.php index b4f307a..45b1975 100644 --- a/src/classes/html_document.php +++ b/src/classes/html_document.php @@ -26,13 +26,13 @@ class html_document { private $breadcrumb = array(); public function __construct() { - $this->title = \tts\main\configure::get('html', 'title') ?? ''; - $this->author = \tts\main\configure::get('html', 'author') ?? ''; - $this->keywords = \tts\main\configure::get('html', 'keywords') ?? ''; - $this->description = \tts\main\configure::get('html', 'description') ?? ''; - $this->robots = \tts\main\configure::get('html', 'robots'); - $css = \tts\main\configure::get('html', 'css'); - if (\tts\common::get_count($css) > 0) { + $this->title = \main_tts\configure::get('html', 'title') ?? ''; + $this->author = \main_tts\configure::get('html', 'author') ?? ''; + $this->keywords = \main_tts\configure::get('html', 'keywords') ?? ''; + $this->description = \main_tts\configure::get('html', 'description') ?? ''; + $this->robots = \main_tts\configure::get('html', 'robots'); + $css = \main_tts\configure::get('html', 'css'); + if (\bs_tts\common::get_count($css) > 0) { foreach($css as $file=>$path) { if (is_array($file)) continue; if (is_array($path)) { @@ -48,8 +48,8 @@ class html_document { } } } - $js = \tts\main\configure::get('html', 'javascript'); - if (\tts\common::get_count($js) >0) { + $js = \main_tts\configure::get('html', 'javascript'); + if (\bs_tts\common::get_count($js) >0) { foreach($js as $file=>$path) { if (is_array($file)) continue; if (is_array($path)) { diff --git a/src/classes/json.php b/src/classes/json.php index fba77ee..25ec38f 100644 --- a/src/classes/json.php +++ b/src/classes/json.php @@ -14,7 +14,7 @@ final class json { } public static function output(array $data, string $misc = '') { - $number_of_rows = \tts\common::get_count($data); + $number_of_rows = \bs_tts\common::get_count($data); self::do_json_headers(); diff --git a/src/classes/loadall.php b/src/classes/loadall.php index 3e6ba68..8a82a8d 100644 --- a/src/classes/loadall.php +++ b/src/classes/loadall.php @@ -7,8 +7,8 @@ namespace tts; final class loadall { static public function update(string $path): void { - $root_path = \tts\site_helper::get_root(); - if (\tts\requires::is_dangerous($path)) { + $root_path = \bs_tts\site_helper::get_root(); + if (\bs_tts\requires::is_dangerous($path)) { die("System Loader Path Invalid"); } if (!file_exists($root_path . $path)) { @@ -65,7 +65,7 @@ final class loadall { chmod($loadall_file, 0664); - if (\tts\requires::safer_file_exists($loadall_file) !== false) { + if (\bs_tts\requires::safer_file_exists($loadall_file) !== false) { include $loadall_file; } diff --git a/src/classes/memory_usage.php b/src/classes/memory_usage.php index 3f3469b..0ee94b3 100644 --- a/src/classes/memory_usage.php +++ b/src/classes/memory_usage.php @@ -23,7 +23,7 @@ final class memory_usage { public static function get_memory_stats($echo = true) { global $mem_baseline; - $check = \tts\common::get_bool(\tts\request::request_var('debug')); + $check = \bs_tts\common::get_bool(\tts\request::request_var('debug')); if ($check || defined('DEBUG') && DEBUG === true) { $now_mem = memory_get_usage(); diff --git a/src/classes/page_not_found.php b/src/classes/page_not_found.php index a66a341..519fe30 100644 --- a/src/classes/page_not_found.php +++ b/src/classes/page_not_found.php @@ -17,9 +17,9 @@ class page_not_found { $err .= $argv[1]; } - $exists = \tts\main\registry::get('di')->exists('log'); + $exists = \main_tts\registry::get('di')->exists('log'); if ($exists) { - $log = \tts\main\registry::get('di')->get_service('log', ['CLI_404s']); + $log = \main_tts\registry::get('di')->get_service('log', ['CLI_404s']); $log->write($err); } @@ -42,14 +42,14 @@ class page_not_found { self::tts_api_method_not_found(); } - $resource = \tts\main\configure::get('tts', '404_page'); + $resource = \main_tts\configure::get('tts', '404_page'); if ($resource === null) { echo "404 Page Not Found!"; exit(1); } - $loaded = \tts\requires::secure_include('views/404', $resource); // Show 404, Page Not Found Error Page! + $loaded = \bs_tts\requires::secure_include('views/404', $resource); // Show 404, Page Not Found Error Page! if ($loaded === false) { echo "404 Page Not Found!"; diff --git a/src/classes/request.php b/src/classes/request.php index 7d6abd0..7af190f 100644 --- a/src/classes/request.php +++ b/src/classes/request.php @@ -30,7 +30,7 @@ final class request { * @retval boolean true if AJAX request by JQuery, etc... */ public static function is_ajax(): bool { - $http_x_requested_with = \tts\safer_io::get_clean_server_var('HTTP_X_REQUESTED_WITH'); + $http_x_requested_with = \bs_tts\safer_io::get_clean_server_var('HTTP_X_REQUESTED_WITH'); return (self::compair_it($http_x_requested_with, 'xmlhttprequest')); } @@ -44,7 +44,7 @@ final class request { if ($var === null || $var2 === null) { return false; } - return (\tts\common::string_to_lowercase(trim($var)) === \tts\common::string_to_lowercase(trim($var2))); + return (\bs_tts\common::string_to_lowercase(trim($var)) === \bs_tts\common::string_to_lowercase(trim($var2))); } /** @@ -53,7 +53,7 @@ final class request { * @retval string */ public static function safe_lowercase_trim(string $var): string { - return (\tts\common::string_to_lowercase(trim($var))); + return (\bs_tts\common::string_to_lowercase(trim($var))); } /** @@ -300,7 +300,7 @@ final class request { $vars = self::safe_url($vars); } - if (\tts\main\configure::get('tts', 'short_url') === true) { + if (\main_tts\configure::get('tts', 'short_url') === true) { $vars = (!empty($vars)) ? "?{$vars}" : ''; return TTS_PROJECT_BASE_REF . "/{$route}/{$method}.html{$vars}"; } else { @@ -325,7 +325,7 @@ final class request { $vars = self::safe_url($vars); } - if (\tts\main\configure::get('tts', 'short_url') === true) { + if (\main_tts\configure::get('tts', 'short_url') === true) { $vars = (!empty($vars)) ? "?{$vars}" : '?x=0'; return TTS_PROJECT_BASE_REF . "/api/{$route}/{$method}{$vars}&api=true"; } else { @@ -339,7 +339,7 @@ final class request { * @retval bool */ public static function is_api(): bool { - $uri = \tts\site_helper::tts_request_uri(); + $uri = \bs_tts\site_helper::tts_request_uri(); if (strlen($uri) > 2) { return ((substr_count($uri, "/api/") == 1 && self::get_var('api') == 'true') || (substr_count($uri, "/api2/") == 1 && self::get_var('api2') == 'true')) ? true : false; } else { diff --git a/src/classes/router.php b/src/classes/router.php index af78810..eeab57d 100644 --- a/src/classes/router.php +++ b/src/classes/router.php @@ -410,7 +410,7 @@ class router * with a method called get! */ private static function get_all_routes(bool $testing = false) { - $prj = rtrim(\tts\site_helper::get_project(), '/'); + $prj = rtrim(\bs_tts\site_helper::get_project(), '/'); if (!empty($prj)) { $route_name = (\tts\console_app::is_cli()) ? "cli_routes" : "routes"; $routes = ($testing) ? "test_routes" : $route_name; @@ -429,10 +429,10 @@ class router * Execute router */ public static function execute() { - $ROOT = \tts\site_helper::get_root(); - $request_uri = \tts\site_helper::get_uri(); - $request_method = \tts\site_helper::get_method(); - $testing = \tts\site_helper::get_testing(); + $ROOT = \bs_tts\site_helper::get_root(); + $request_uri = \bs_tts\site_helper::get_uri(); + $request_method = \bs_tts\site_helper::get_method(); + $testing = \bs_tts\site_helper::get_testing(); // Generate request and absolute path self::generateURL($ROOT, $request_uri); @@ -574,13 +574,13 @@ class router */ private static function generateURL(string $ROOT, string $request_uri) { - $https = \tts\safer_io::get_clean_server_var('HTTPS'); + $https = \bs_tts\safer_io::get_clean_server_var('HTTPS'); $baseLink = ($https === 'on') ? "https" : "http"; - $server_name = \tts\safer_io::get_clean_server_var('SERVER_NAME'); + $server_name = \bs_tts\safer_io::get_clean_server_var('SERVER_NAME'); $baseLink .= "://" . $server_name; - $port = \tts\safer_io::get_clean_server_var('SERVER_PORT'); + $port = \bs_tts\safer_io::get_clean_server_var('SERVER_PORT'); $baseLink .= ($port !== '80') ? ':' . $port : ':'; $baseRequest = ''; diff --git a/src/classes/security.php b/src/classes/security.php index 36732a0..1c10495 100644 --- a/src/classes/security.php +++ b/src/classes/security.php @@ -55,7 +55,7 @@ final class security { public static function do_password_hash(string $password): bool | string { $pwd_peppered = self::make_hash($password); - $hash_algo = \tts\main\configure::get( + $hash_algo = \main_tts\configure::get( "security", "hash_algo" ); @@ -79,15 +79,15 @@ final class security { * @return string new Hashed */ public static function make_hash(string $text): string { - $level = \tts\main\configure::get('security', 'hash_level'); + $level = \main_tts\configure::get('security', 'hash_level'); if (empty($level)) { $level = "high"; } - $pepper = \tts\main\configure::get('security', 'pepper_pwd'); + $pepper = \main_tts\configure::get('security', 'pepper_pwd'); if (strlen($pepper) < 12) { throw new \Exception("Pepper Password, too short!"); } - $salt = \tts\main\configure::get('security', 'salt_pwd'); + $salt = \main_tts\configure::get('security', 'salt_pwd'); if (strlen($salt) < 5) { throw new \Exception("Salt Password, too short!"); } @@ -129,7 +129,7 @@ final class security { * @retval string of safe class name */ public static function filter_class(string $class): string { - if (\tts\requires::is_dangerous($class)) { + if (\bs_tts\requires::is_dangerous($class)) { throw new \Exception("Dangerious URI!"); } return preg_replace('/[^a-zA-Z0-9_]/', '', $class); @@ -141,10 +141,10 @@ final class security { * @return string Safe URI */ public static function filter_uri(string $uri): string { - if (\tts\requires::is_dangerous($uri) === true) { + if (\bs_tts\requires::is_dangerous($uri) === true) { throw new \Exception("Dangerious URI!"); } - return \tts\requires::filter_file_name($uri); + return \bs_tts\requires::filter_file_name($uri); } public static function id_hash(): string { @@ -161,7 +161,7 @@ final class security { return false; } - if (\tts\common::get_bool(\tts\main\configure::get('important', 'private_ip_as_local')) === true) { + if (\bs_tts\common::get_bool(\main_tts\configure::get('important', 'private_ip_as_local')) === true) { if (!filter_var($_SERVER['SERVER_NAME'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE)) { // | FILTER_FLAG_NO_RES_RANGE return true; // Private IP } diff --git a/src/classes/services/cache/file.php b/src/classes/services/cache/file.php index 4be42f3..ac57099 100644 --- a/src/classes/services/cache/file.php +++ b/src/classes/services/cache/file.php @@ -10,9 +10,9 @@ class file { private $folder; public function __construct() { - $this->expire = intval(\tts\main\configure::get('cache', 'ttl')); + $this->expire = intval(\main_tts\configure::get('cache', 'ttl')); - $safer_dir = \tts\requires::safer_dir_exists(\tts\main\configure::get('cache', 'cache_folder')); + $safer_dir = \bs_tts\requires::safer_dir_exists(\main_tts\configure::get('cache', 'cache_folder')); if ($safer_dir === false) { return; } @@ -36,8 +36,8 @@ class file { } private function filter_key(string $key): string { - if (\tts\requires::is_valid_file($key)) { - return \tts\requires::filter_file_name($key); + if (\bs_tts\requires::is_valid_file($key)) { + return \bs_tts\requires::filter_file_name($key); } throw new \Exception('Bad ID for session!'); } diff --git a/src/classes/services/cache/redis_db.php b/src/classes/services/cache/redis_db.php index bf60879..f96c57f 100644 --- a/src/classes/services/cache/redis_db.php +++ b/src/classes/services/cache/redis_db.php @@ -10,8 +10,8 @@ final class redis_db { public function __construct($redis_servers, $db_select_no, $auth = '') { - $enabled = \tts\main\configure::get('cache', 'enabled'); - if ( \tts\common::get_bool($enabled) === false ) { + $enabled = \main_tts\configure::get('cache', 'enabled'); + if ( \bs_tts\common::get_bool($enabled) === false ) { return false; } @@ -63,8 +63,8 @@ final class redis_db { $data = $this->redis->get($key); $assoc = true; // Returns data as Array - $log_hit = \tts\main\configure::get('cache', 'log_cache_hits'); - if ( \tts\common::get_bool($log_hit) ) { + $log_hit = \main_tts\configure::get('cache', 'log_cache_hits'); + if ( \bs_tts\common::get_bool($log_hit) ) { $this->cache_hit($key); // Log Hits } @@ -146,7 +146,7 @@ final class redis_db { } private function debug($e) { - $logger = \tts\main\registry::get('di')->get_service('log', ['Redis_ERRORs']); + $logger = \main_tts\registry::get('di')->get_service('log', ['Redis_ERRORs']); if (is_object($e) && method_exists($e, 'getMessage')) { $logger->write($e->getMessage()); } elseif (is_string($e)) { @@ -155,7 +155,7 @@ final class redis_db { } private function cache_hit($key = '') { - $logger = \tts\main\registry::get('di')->get_service('log', ['Redis_HITs']); + $logger = \main_tts\registry::get('di')->get_service('log', ['Redis_HITs']); $logger->write("Cache Hit... {$key}"); } diff --git a/src/classes/services/emailer.php b/src/classes/services/emailer.php index 0176824..85fdb75 100644 --- a/src/classes/services/emailer.php +++ b/src/classes/services/emailer.php @@ -18,8 +18,8 @@ class emailer { return false; } - if (! \tts\main\registry::get('loader')->is_loaded('PHPMailer\PHPMailer')) { - \tts\main\registry::get('loader')->add_namespace('PHPMailer\PHPMailer', TTS_VENDOR . 'phpmailer/phpmailer/src'); + if (! \main_tts\registry::get('loader')->is_loaded('PHPMailer\PHPMailer')) { + \main_tts\registry::get('loader')->add_namespace('PHPMailer\PHPMailer', TTS_VENDOR . 'phpmailer/phpmailer/src'); } $mail = new \PHPMailer\PHPMailer\PHPMailer(); @@ -41,7 +41,7 @@ class emailer { $default = (isset($value[0])) ? $value[0] : null; - switch (\tts\common::string_to_lowercase($key)) { + switch (\bs_tts\common::string_to_lowercase($key)) { case 'to': if (is_array($value)) { $mto = (isset($value['addresses']) && is_array($value['addresses'])) ? $value['addresses'] : false; @@ -181,11 +181,11 @@ class emailer { break; } - $settings = \tts\main\registry::get('email'); + $settings = \main_tts\registry::get('email'); if (isset($settings['send_emails']) && $settings['send_emails'] === false) { try { - $log = \tts\main\registry::get('di')->get_service('log', ['emails']); + $log = \main_tts\registry::get('di')->get_service('log', ['emails']); $log->write("To: {$to} Subject: {$subject} Message: {$message}"); } catch (Exception $e) { @@ -219,7 +219,7 @@ class emailer { return true; // Yes, it worked! } else { try { - $log = \tts\main\registry::get('di')->get_service('log', ['failed_emails']); + $log = \main_tts\registry::get('di')->get_service('log', ['failed_emails']); $log->write('Mailer Error: ' . $mail->ErrorInfo); } catch (Exception $e) { diff --git a/src/classes/services/html_filter.php b/src/classes/services/html_filter.php index f5cbd7f..0f955f6 100644 --- a/src/classes/services/html_filter.php +++ b/src/classes/services/html_filter.php @@ -9,13 +9,13 @@ final class html_filter { private $config = null; public function __construct() { - if (\tts\main\registry::get('html_filter') === null) { + if (\main_tts\registry::get('html_filter') === null) { \HTMLPurifier_Bootstrap::registerAutoload(); if (function_exists('__autoload')) { // Be polite and ensure that userland autoload gets retained spl_autoload_register('__autoload'); } - \tts\main\registry::set('html_filter', true); + \main_tts\registry::set('html_filter', true); } } diff --git a/src/classes/services/http_requests/http_curl_request.php b/src/classes/services/http_requests/http_curl_request.php index 5856e7e..57e2d45 100644 --- a/src/classes/services/http_requests/http_curl_request.php +++ b/src/classes/services/http_requests/http_curl_request.php @@ -30,7 +30,7 @@ class http_curl_request { public function http_request($options) { $uri = $options->get_uri(); $action_path = $uri; - if (\tts\common::is_string_found($uri, "://") === false) { + if (\bs_tts\common::is_string_found($uri, "://") === false) { // Check if we have a prefixed / on the path, if not add one. if (substr($uri, 0, 1) != "/") { $action_path = "/" . $uri; @@ -48,7 +48,7 @@ class http_curl_request { // request method was GET, but that doesn't seem to be the case any // longer, so we need to build them into the query string ourselves. $action_postfields_string = http_build_query( $options->get_get_data() ); - $action_path .= ( \tts\common::is_string_found($action_path, '?') === false ? '?' : '&') . $action_postfields_string; + $action_path .= ( \bs_tts\common::is_string_found($action_path, '?') === false ? '?' : '&') . $action_postfields_string; unset($action_postfields_string); break; @@ -96,7 +96,7 @@ class http_curl_request { $http = ( $options->get_ssl() ) ? 'https' : 'http'; - $action_path = (\tts\common::is_string_found($action_path, "://")) ? $action_path : "{$http}://{$options->get_host()}:{$options->get_port()}{$action_path}"; + $action_path = (\bs_tts\common::is_string_found($action_path, "://")) ? $action_path : "{$http}://{$options->get_host()}:{$options->get_port()}{$action_path}"; curl_setopt($ch, CURLOPT_URL, $action_path); diff --git a/src/classes/services/liquid_templates.php b/src/classes/services/liquid_templates.php index 698e788..5e5d377 100644 --- a/src/classes/services/liquid_templates.php +++ b/src/classes/services/liquid_templates.php @@ -11,13 +11,13 @@ final class liquid_templates { public function __construct(string $template_extension = 'tpl') { $this->extension = $template_extension; - if (! \tts\main\registry::get('loader')->is_loaded('Liquid')) { - \tts\main\registry::get('loader')->add_namespace('Liquid', TTS_VENDOR . 'liquid/liquid/src/Liquid'); + if (! \main_tts\registry::get('loader')->is_loaded('Liquid')) { + \main_tts\registry::get('loader')->add_namespace('Liquid', TTS_VENDOR . 'liquid/liquid/src/Liquid'); } \Liquid\Liquid::set('INCLUDE_SUFFIX', $template_extension); \Liquid\Liquid::set('INCLUDE_PREFIX', ''); - $this->liquid = new \Liquid\Template(\tts\site_helper::get_root() . \tts\site_helper::get_project() . '/views/includes'); + $this->liquid = new \Liquid\Template(\bs_tts\site_helper::get_root() . \bs_tts\site_helper::get_project() . '/views/includes'); } public function whitespace_control() { diff --git a/src/classes/services/log.php b/src/classes/services/log.php index 08cf304..0719da5 100644 --- a/src/classes/services/log.php +++ b/src/classes/services/log.php @@ -17,7 +17,7 @@ final class log { if (strpos($filename, "..") !== false) { $this->handle = false; // Too dangerious, so return false } else { - $log_dir = \tts\site_helper::get_root() . 'logs'; + $log_dir = \bs_tts\site_helper::get_root() . 'logs'; if (! is_dir($log_dir)){ //Directory does not exist, so lets create it. mkdir($log_dir, 0775); @@ -37,7 +37,7 @@ final class log { // $success = @touch($file); if ($success === false) { $this->handle = false; - \tts\common::dump($file); + \bs_tts\common::dump($file); return false; } diff --git a/src/classes/services/obsolete/http_socket_request.php b/src/classes/services/obsolete/http_socket_request.php index 6387e16..d1e6a7c 100644 --- a/src/classes/services/obsolete/http_socket_request.php +++ b/src/classes/services/obsolete/http_socket_request.php @@ -10,7 +10,7 @@ final class http_socket_request { $ret = ''; $verb = strtoupper( $options->get_verb() ); $cookie_str = ''; - $sign = \tts\common::is_string_found($options->get_uri(), '?') ? '&' : '?'; + $sign = \bs_tts\common::is_string_found($options->get_uri(), '?') ? '&' : '?'; $getdata_str = count( $options->get_get_data() ) ? $sign : ''; $postdata_str = ''; diff --git a/src/classes/services/sessions.php b/src/classes/services/sessions.php index 3a2e6af..cf73834 100644 --- a/src/classes/services/sessions.php +++ b/src/classes/services/sessions.php @@ -25,22 +25,22 @@ class sessions { } private function get_enc_data(string $data): string { - $security_level = \tts\main\configure::get('session', 'session_security_level'); + $security_level = \main_tts\configure::get('session', 'session_security_level'); if ($security_level === false || empty($data)) { return $data; } else { - $enc_sess = \tts\main\registry::get('di')->get_service('encryption'); + $enc_sess = \main_tts\registry::get('di')->get_service('encryption'); $enc_sess->change_security_level($security_level); - $d = $enc_sess->decrypt($data, \tts\main\configure::get('session', 'key')); + $d = $enc_sess->decrypt($data, \main_tts\configure::get('session', 'key')); unset($enc_sess); return $d; } } private function save_enc_data(string $data): string { - $security_level = \tts\main\configure::get('session', 'session_security_level'); + $security_level = \main_tts\configure::get('session', 'session_security_level'); if ($security_level !== false) { - $enc_sess = \tts\main\registry::get('di')->get_service('encryption'); + $enc_sess = \main_tts\registry::get('di')->get_service('encryption'); $enc_sess->change_security_level($security_level); $data = $enc_sess->encrypt($data, px_configure::get('session', 'key')); unset($enc_sess); @@ -54,7 +54,7 @@ class sessions { * @return data from Session */ public function get_session_var(string $var, int $flags = FILTER_DEFAULT): string { - $svar = \tts\main\configure::get('session', 'session_variable') ?? false; + $svar = \main_tts\configure::get('session', 'session_variable') ?? false; if ($svar === false) { $svar = 'SES_'; } @@ -74,7 +74,7 @@ class sessions { * @param type $content data */ public function set_session_var(string $var, string $content): void { - $svar = \tts\main\configure::get('session', 'session_variable') ?? false; + $svar = \main_tts\configure::get('session', 'session_variable') ?? false; if ($svar === false) { $svar = 'SES_'; } diff --git a/src/classes/services/sessions/file_sessions.php b/src/classes/services/sessions/file_sessions.php index e109f28..8f4675a 100644 --- a/src/classes/services/sessions/file_sessions.php +++ b/src/classes/services/sessions/file_sessions.php @@ -9,14 +9,14 @@ class file_sessions implements \tts\contracts\sessions_interface { private $savePath; private function filter_id(string $id): string { - if (\tts\requires::is_valid_file($id)) { - return \tts\requires::filter_file_name($id); + if (\bs_tts\requires::is_valid_file($id)) { + return \bs_tts\requires::filter_file_name($id); } throw new \Exception('Bad ID for session!'); } public function open(string $savePath, string $sessionName): bool { - $safer_dir = \tts\requires::safer_dir_exists($savePath); + $safer_dir = \bs_tts\requires::safer_dir_exists($savePath); if ($safer_dir === false) { return false; } diff --git a/src/classes/services/simple_rest.php b/src/classes/services/simple_rest.php index d3843d4..49f1d74 100644 --- a/src/classes/services/simple_rest.php +++ b/src/classes/services/simple_rest.php @@ -9,7 +9,7 @@ class simple_rest { private $http_version = "HTTP/1.1"; /** - * Should use \tts\site_helper:: instead! + * Should use \bs_tts\site_helper:: instead! */ public function route(): array { $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); diff --git a/src/classes/services/twilio.php b/src/classes/services/twilio.php index 07f42fe..8f2bc3e 100644 --- a/src/classes/services/twilio.php +++ b/src/classes/services/twilio.php @@ -7,8 +7,8 @@ namespace tts\services; final class twilio { public function __construct() { - if (!\tts\main\registry::get('loader')->is_loaded('Twilio')) { - \tts\main\registry::get('loader')->add_namespace('Twilio', TTS_VENDOR . 'twilio/sdk/Twilio'); + if (!\main_tts\registry::get('loader')->is_loaded('Twilio')) { + \main_tts\registry::get('loader')->add_namespace('Twilio', TTS_VENDOR . 'twilio/sdk/Twilio'); } } diff --git a/src/classes/session_management.php b/src/classes/session_management.php index 577fd67..1d09cb7 100644 --- a/src/classes/session_management.php +++ b/src/classes/session_management.php @@ -8,14 +8,14 @@ final class session_management { public static function make_session_started(bool $force_secure = false) { if ((function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE) || !session_id()) { - $name = \tts\main\configure::get('sessions', 'session_name'); + $name = \main_tts\configure::get('sessions', 'session_name'); if ($name !== null) { session_name($name); } if (! headers_sent()) { - $server_port = \tts\safer_io::get_clean_server_var('SERVER_PORT'); - $secure_port_on = \tts\safer_io::get_clean_server_var('HTTPS'); + $server_port = \bs_tts\safer_io::get_clean_server_var('SERVER_PORT'); + $secure_port_on = \bs_tts\safer_io::get_clean_server_var('HTTPS'); $use_secure = ($server_port == '443' || $secure_port_on == 'on') ? 1 : 0; $use_secure = ($force_secure) ? 1 : $use_secure; session_start([ @@ -33,7 +33,7 @@ final class session_management { } public static function has_user_right(string $right): bool { - $session = \tts\main\registry::get('di')->get_service('session'); + $session = \main_tts\registry::get('di')->get_service('session'); $rights = (isset($_SESSION['users_rights'])) ? $_SESSION['users_rights'] : false; if ($rights === false) { return false; @@ -48,7 +48,7 @@ final class session_management { } public static function get_user_id(): int { - $session = \tts\main\registry::get('di')->get_service('session'); + $session = \main_tts\registry::get('di')->get_service('session'); $sid = (isset($_SESSION['user_id'])) ? $_SESSION['user_id'] : 0; return intval($sid); } diff --git a/src/classes/tag_matches.php b/src/classes/tag_matches.php index cc6ab7d..832aa57 100644 --- a/src/classes/tag_matches.php +++ b/src/classes/tag_matches.php @@ -17,16 +17,16 @@ const tags_to_check = array('div', 'span', 'form', 'i*', 'a*', 'h1', 'p*'); public static function check_tags(string $page): array { $alert = ''; $output = ''; - $l_page = \tts\common::string_to_lowercase($page); + $l_page = \bs_tts\common::string_to_lowercase($page); unset($page); - $assets = \tts\site_helper::get_asset("uikit/css/uikit.gradient.min.css"); + $assets = \bs_tts\site_helper::get_asset("uikit/css/uikit.gradient.min.css"); $ui = ''; $ui .= '
'; $ui_end = '
'; foreach (self::tags_to_check as $tag_name) { - if (\tts\common::is_string_found($tag_name, '*')) { + if (\bs_tts\common::is_string_found($tag_name, '*')) { $tag_name = str_replace('*', '', $tag_name); $otag = "<{$tag_name}>"; // Open Tag $open = substr_count($l_page, $otag); // Count open tags in page @@ -44,11 +44,11 @@ public static function check_tags(string $page): array { if ($total_still_open > 0) { $msg = "{$total_still_open} possibly MISSING closing {$tag_name} !!!"; $alert .= "tts_log('{$msg}');\r\n"; - $output .= (\tts\main\configure::get('tts', 'live') === true) ? "\r\n" : "{$ui}{$msg}{$ui_end}\r\n"; + $output .= (\main_tts\configure::get('tts', 'live') === true) ? "\r\n" : "{$ui}{$msg}{$ui_end}\r\n"; } elseif ($total_still_open < 0) { $msg = abs($total_still_open) . " possibly MISSING opening {$tag_name} !!!"; $alert .= "tts_log('{$msg}');\r\n"; - $output .= (\tts\main\configure::get('tts', 'live') === true) ? "\r\n" : "{$ui}{$msg}{$ui_end}\r\n"; + $output .= (\main_tts\configure::get('tts', 'live') === true) ? "\r\n" : "{$ui}{$msg}{$ui_end}\r\n"; } } return array('output' => $output, 'alert' => $alert); diff --git a/src/classes/time_zones.php b/src/classes/time_zones.php index 323f876..1f5ad61 100644 --- a/src/classes/time_zones.php +++ b/src/classes/time_zones.php @@ -40,7 +40,7 @@ final class time_zones { } private static function mdy($userTime, $format) { - switch (\tts\common::string_to_lowercase($format)) { + switch (\bs_tts\common::string_to_lowercase($format)) { case 'actions': return $userTime->format('m-d-Y / h:iA'); case 'report': @@ -68,7 +68,7 @@ final class time_zones { } private static function dmy($userTime, $format) { - switch (\tts\common::string_to_lowercase($format)) { + switch (\bs_tts\common::string_to_lowercase($format)) { case 'actions': return $userTime->format('d-m-Y / h:iA'); case 'report': @@ -96,7 +96,7 @@ final class time_zones { } private static function ymd($userTime, $format) { - switch (\tts\common::string_to_lowercase($format)) { + switch (\bs_tts\common::string_to_lowercase($format)) { case 'actions': return $userTime->format('Y-m-d / h:iA'); case 'report': @@ -124,7 +124,7 @@ final class time_zones { } public static function dt_format($userTime, $format, $country) { - switch (\tts\common::string_to_lowercase($format)) { + switch (\bs_tts\common::string_to_lowercase($format)) { case 'object': return $userTime; case 'unix': @@ -165,7 +165,7 @@ final class time_zones { return $userTime->format('Y-m-d H:i:s'); } - switch (\tts\common::string_to_lowercase($country)) { + switch (\bs_tts\common::string_to_lowercase($country)) { case 'china': return self::ymd($userTime, $format); case 'int': diff --git a/src/classes/traits/database/run_sql.php b/src/classes/traits/database/run_sql.php index e37ae25..3f2bed0 100644 --- a/src/classes/traits/database/run_sql.php +++ b/src/classes/traits/database/run_sql.php @@ -8,7 +8,7 @@ trait run_sql { public function run($sql, $bind=""): int { $pdostmt = $this->pdo->prepare(trim($sql)); - if (\tts\common::get_count($bind) > 0) { + if (\bs_tts\common::get_count($bind) > 0) { $exec = $pdostmt->execute($bind); } else { $exec = $pdostmt->execute(); diff --git a/src/classes/traits/database/validation.php b/src/classes/traits/database/validation.php index 6f1dca2..ce0e261 100644 --- a/src/classes/traits/database/validation.php +++ b/src/classes/traits/database/validation.php @@ -11,7 +11,7 @@ trait validation { * @retval bool true valid, false failed tests */ public function validate_mysql(): bool { - $tbl = (\tts\common::is_string_found($this->table, "`")) ? $this->table : "`{$this->table}`"; + $tbl = (\bs_tts\common::is_string_found($this->table, "`")) ? $this->table : "`{$this->table}`"; foreach ($this->members as $field => $value) { if ($field == $this->primary_key) { continue; @@ -55,7 +55,7 @@ trait validation { case 'NEWDECIMAL': $prec = intval($meta['precision']); $maxlen = $len - $prec; - if (!\tts\common::is_string_found($value, '.')) { + if (!\bs_tts\common::is_string_found($value, '.')) { $this->do_verr("Failed Validation: No Decimal Found in field {$field}"); return false; } @@ -163,7 +163,7 @@ trait validation { public function is_valid_mysql_date(string $str): bool { $date_parts = explode('-', $str); - if (\tts\main\common::count($date_parts) != 3) + if (\main_tts\common::count($date_parts) != 3) return false; if ((strlen($date_parts[0]) != 4) || (!is_numeric($date_parts[0]))) return false; @@ -188,9 +188,9 @@ trait validation { */ private function do_verr(string $msg): void { $this->error_message = $msg; - $exists = \tts\main\registry::get('di')->exists('log'); - if ($exists && \tts\main\configure::get('database', 'log_validation_errors') === true) { - $log = \tts\main\registry::get('di')->get_service('log', ['validation_errors']); + $exists = \main_tts\registry::get('di')->exists('log'); + if ($exists && \main_tts\configure::get('database', 'log_validation_errors') === true) { + $log = \main_tts\registry::get('di')->get_service('log', ['validation_errors']); $log->write($msg); } } diff --git a/src/classes/traits/security/csrf_token_functions.php b/src/classes/traits/security/csrf_token_functions.php index 9d29002..69073dc 100644 --- a/src/classes/traits/security/csrf_token_functions.php +++ b/src/classes/traits/security/csrf_token_functions.php @@ -66,7 +66,7 @@ trait csrf_token_functions { * @return bool */ public static function csrf_token_is_recent(): bool { - $max_elapsed = intval(\tts\main\configure::get( + $max_elapsed = intval(\main_tts\configure::get( 'security', 'max_token_age' )); diff --git a/src/classes/traits/security/session_hijacking_functions.php b/src/classes/traits/security/session_hijacking_functions.php index ddf05c0..868176f 100644 --- a/src/classes/traits/security/session_hijacking_functions.php +++ b/src/classes/traits/security/session_hijacking_functions.php @@ -11,7 +11,7 @@ namespace tts\traits\security; trait session_hijacking_functions { public static function init() { - $my_sess = \tts\main\configure::get("site", "session_name"); + $my_sess = \main_tts\configure::get("site", "session_name"); session_name($my_sess); session_start(); } @@ -52,7 +52,7 @@ trait session_hijacking_functions { // Has too much time passed since the last login? public static function last_login_is_recent() { - $max_elapsed = intval(\tts\main\configure::get( + $max_elapsed = intval(\main_tts\configure::get( 'security', 'max_last_login_age' )); diff --git a/src/classes/view.php b/src/classes/view.php index efaf855..3b1e8a5 100644 --- a/src/classes/view.php +++ b/src/classes/view.php @@ -15,23 +15,23 @@ final class view { protected $tempalte_engine = null; public function __construct() { - $this->project_dir = \tts\site_helper::get_project(); + $this->project_dir = \bs_tts\site_helper::get_project(); } private function get_file(string $view_file, string $default, string $render_path = 'project'): string { - $file_ext = \tts\common::get_string_right($view_file, 4); - if (! \tts\common::is_string_found($file_ext, '.')) { + $file_ext = \bs_tts\common::get_string_right($view_file, 4); + if (! \bs_tts\common::is_string_found($file_ext, '.')) { $view_file .= '.php'; } if ($render_path === 'tts') { $file = (empty($default)) ? "views/{$view_file}" : "views/{$default}/{$view_file}"; - $path = \tts\main\TTS_FRAMEWORK; + $path = \main_tts\TTS_FRAMEWORK; } else { $file = (empty($default)) ? "{$this->project_dir}/views/{$view_file}" : "{$this->project_dir}/views/{$default}/{$view_file}"; - $path = \tts\site_helper::get_root(); + $path = \bs_tts\site_helper::get_root(); } $vf = $path . $file; - if ( \tts\requires::safer_file_exists($vf) !== false) { + if ( \bs_tts\requires::safer_file_exists($vf) !== false) { return $file; } return ''; @@ -54,7 +54,7 @@ final class view { private function find_view_path(string $view_file, string $render_path) { $found = false; - $ct_default_paths = \tts\main\configure::get('view_mode', 'default_paths'); + $ct_default_paths = \main_tts\configure::get('view_mode', 'default_paths'); $get = \tts\request::request_var('render'); if (\tts\request::is_set($get) && in_array($get, $ct_default_paths)) { if (($key = array_search($get, $ct_default_paths)) !== false) { @@ -75,10 +75,10 @@ final class view { private function find_template_path($tpl_file, $render_path) { $file = "{$this->project_dir}/views/includes/{$tpl_file}"; - $path = ($render_path === 'project') ? \tts\site_helper::get_root() : \tts\main\TTS_FRAMEWORK; + $path = ($render_path === 'project') ? \bs_tts\site_helper::get_root() : \main_tts\TTS_FRAMEWORK; $vf = $path . $file; - return \tts\requires::safer_file_exists($vf); + return \bs_tts\requires::safer_file_exists($vf); } /** @@ -92,8 +92,8 @@ final class view { return; } - $file_ext = \tts\common::get_string_right($view_file, 4); - if (! \tts\common::is_string_found($file_ext, '.')) { + $file_ext = \bs_tts\common::get_string_right($view_file, 4); + if (! \bs_tts\common::is_string_found($file_ext, '.')) { $file_ext = '.php'; } else if ($file_ext !== '.php') { $this->use_template_engine = true; @@ -127,7 +127,7 @@ final class view { if (! empty($render_page)) { $render_page = str_replace('.php', '', $render_page); $templ = "{$this->project_dir}/templates/{$render_page}"; - if (\tts\requires::safer_file_exists(\tts\site_helper::get_root() . $templ. '.php') !== false) { + if (\bs_tts\requires::safer_file_exists(\bs_tts\site_helper::get_root() . $templ. '.php') !== false) { $this->template = $templ; // echo $this->template; return true; @@ -175,7 +175,7 @@ final class view { */ public function fetch($local, string $file = null): string { $page_output = ob_get_clean(); // Get echos before View - \tts\main\views::ob_start(); + \main_tts\views::ob_start(); $saved_ob_level = ob_get_level(); $this->set_view($file); @@ -186,7 +186,7 @@ final class view { } if ($this->use_template_engine) { - $this->tempalte_engine = \tts\main\registry::get('di')->get_service('templates', [$this->template_type]); + $this->tempalte_engine = \main_tts\registry::get('di')->get_service('templates', [$this->template_type]); if ($this->white_space_control) { $this->tempalte_engine->whitespace_control(); } @@ -195,14 +195,14 @@ final class view { if (count($this->files) > 0) { foreach ($this->files as $view_file) { if ($view_file['file_type'] == '.php') { - \tts\requires::secure_include($view_file['file'], $view_file['path'], $local, $this->vars); // Include the file + \bs_tts\requires::secure_include($view_file['file'], $view_file['path'], $local, $this->vars); // Include the file } else { $template_file = str_replace('.tpl', '', $view_file['file']); $this->tempalte_engine->parse_file($template_file); $assigns = $this->vars['template_assigns'] ?? []; $filters = $this->vars['template_filters'] ?? null; $registers = $this->vars['template_registers'] ?? []; - $assigns['production'] =(\tts\main\configure::get('tts', 'live') === true) ? true : false; + $assigns['production'] =(\main_tts\configure::get('tts', 'live') === true) ? true : false; echo $this->tempalte_engine->render($assigns, $filters, $registers); } } @@ -211,7 +211,7 @@ final class view { $page_output .= ob_get_clean(); try { - if (\tts\common::get_bool(\tts\main\configure::get('tts', 'check_HTML_tags')) === true) { + if (\bs_tts\common::get_bool(\main_tts\configure::get('tts', 'check_HTML_tags')) === true) { $tags = \tts\tag_matches::check_tags($page_output); if (! empty($tags['output'])) { $page_output .= $tags['output']; @@ -221,17 +221,17 @@ final class view { } } } - } catch (\tts\bool_Exception $e) { - if (\tts\main\configure::get('tts', 'live') === false) { + } catch (\tts\exceptions\Bool_Exception $e) { + if (\main_tts\configure::get('tts', 'live') === false) { $page_output .= \tts\assets::alert('SET Config for tts: check_HTML_tags'); } } - if ($this->template !== false && \tts\requires::safer_file_exists(\tts\site_helper::get_root() . $this->template . ".php") !== false) { - \tts\main\views::ob_start(); + if ($this->template !== false && \bs_tts\requires::safer_file_exists(\bs_tts\site_helper::get_root() . $this->template . ".php") !== false) { + \main_tts\views::ob_start(); $saved_ob_level = ob_get_level(); $local->page_output = $page_output; - \tts\requires::secure_include($this->template, 'project', $local, $this->vars); + \bs_tts\requires::secure_include($this->template, 'project', $local, $this->vars); $this->clear_ob($saved_ob_level); $page_output = ob_get_clean(); } diff --git a/src/main.inc.php b/src/main.inc.php index bb0a086..0a59ee4 100644 --- a/src/main.inc.php +++ b/src/main.inc.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace tts\main; +namespace main_tts; unset($_REQUEST); // Request is dangerious unset($_GET); @@ -25,18 +25,10 @@ final class views { } } -if (\tts\site_helper::get_testing() === false) { +if (\bs_tts\site_helper::get_testing() === false) { views::ob_start(); } -require_once TTS_FRAMEWORK . 'bootstrap/errors.php'; -require_once TTS_FRAMEWORK . 'bootstrap/validator.php'; -require_once TTS_FRAMEWORK . 'bootstrap/safer_io.php'; -require_once TTS_FRAMEWORK . 'classes/exceptions/Bool_Exception.php'; -require_once TTS_FRAMEWORK . 'bootstrap/common.php'; -require_once TTS_FRAMEWORK . 'bootstrap/requires.php'; -require_once TTS_FRAMEWORK . 'bootstrap/auto_loader.php'; - final class configure { private static $config = []; @@ -90,9 +82,9 @@ final class configure { return; } if ($key === false) { - \tts\common::wipe(self::$config[strtolower($name)]); + \bs_tts\common::wipe(self::$config[strtolower($name)]); } - \tts\common::wipe(self::$config[strtolower($name)][strtolower($key)]); + \bs_tts\common::wipe(self::$config[strtolower($name)][strtolower($key)]); } public static function load_array(array $a): void { @@ -245,9 +237,15 @@ if (extension_loaded('mbstring')) { setlocale(LC_ALL, "en_US.UTF-8"); } +require_once TTS_FRAMEWORK . 'bootstrap/errors.php'; +require_once TTS_FRAMEWORK . 'bootstrap/common.php'; +require_once TTS_FRAMEWORK . 'bootstrap/requires.php'; +require_once TTS_FRAMEWORK . 'bootstrap/auto_loader.php'; + registry::set('loader', new \Psr4AutoloaderClass); registry::get('loader')->register(); +registry::get('loader')->add_namespace("bs_tts", TTS_FRAMEWORK . "bootstrap"); registry::get('loader')->add_namespace("tts", TTS_FRAMEWORK . "classes"); registry::get('loader')->add_namespace("tts", TTS_FRAMEWORK . "tests"); -\tts\site_helper::set_project_namespace(); \ No newline at end of file +\bs_tts\site_helper::set_project_namespace(); \ No newline at end of file diff --git a/src/views/404.php b/src/views/404.php index 4cd4ad3..4a75c71 100644 --- a/src/views/404.php +++ b/src/views/404.php @@ -42,7 +42,7 @@ declare(strict_types=1);
Page not found.

404 Page not found!

{$field}