diff --git a/.gitignore b/.gitignore index 62c3e2b..b9c43f6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ protected/src/secret_php_files protected/src/aes protected/src/aeskeys.php protected/keydata +protected/runtime *.swp *.log diff --git a/protected/cli/makeLicense.php b/protected/cli/makeLicense.php index d669306..b0464e4 100644 --- a/protected/cli/makeLicense.php +++ b/protected/cli/makeLicense.php @@ -1,9 +1,15 @@ format(DateTime::ATOM)); @@ -12,28 +18,18 @@ $license_maker = new MakeLicense(); define("PWD1", $license_maker->makePassword()); define("PWD2", $license_maker->makePassword()); +// PHP Files to keep secure are in src/secret_php_files const Array_For_Files = [ - BaseDir. "/src/aes/main.aes" => + BaseDir. "/src/aes/testing.aes" => [ "feature" => "testing", "enabled" => true, "expires" => EXPIRES_DATE, "password" => PWD1 ], BaseDir. "/src/aes/config.aes" => [ "feature" => "junk", "enabled" => false, "password" => PWD2 ], ]; const ALLOWED_DOMAINS = ["localhost", "sub.example.org"]; -const PrivatePEM = BaseDir."/keydata/private.pem"; -const PublicPEM = BaseDir."/keydata/public.pem"; -const AESKeysFile = BaseDir."/src/aeskeys.php"; -const LicenseFile = BaseDir."/keydata/license.json"; - - -$license_maker->generateLicense( - Array_For_Files, - ALLOWED_DOMAINS, - PrivatePEM, - PublicPEM, - AESKeysFile, - LicenseFile -); + +$license_maker->runSymlink(BaseDir. "/FWCodeHydrater", "src/classes/makeLicenseFiles.php"); + /** * use stars for unlimited access for domains and expires dates if desired! diff --git a/protected/logs/error_log.txt b/protected/logs/error_log.txt index 0058aab..e69de29 100644 --- a/protected/logs/error_log.txt +++ b/protected/logs/error_log.txt @@ -1,3 +0,0 @@ -[2025-07-23 16:53:30] [WARNING] HydraterLicense\KeyGenerator::generatePublicKey(/var/www/ProjectCodeHydrater/protected/keydata/private.pem): Failed to open stream: No such file or directory in /var/www/ProjectCodeHydrater/protected/cli/makeLicense.php on line 109 -[2025-07-23 16:53:30] [WARNING] file_get_contents(/var/www/ProjectCodeHydrater/protected/keydata/private.pem): Failed to open stream: No such file or directory in /var/www/ProjectCodeHydrater/protected/cli/makeLicense.php on line 114 -[2025-07-23 16:53:30] [WARNING] openssl_sign(): Supplied key param cannot be coerced into a private key in /var/www/ProjectCodeHydrater/protected/cli/makeLicense.php on line 118 diff --git a/protected/src/errors.php b/protected/src/errors.php deleted file mode 100644 index 341eb35..0000000 --- a/protected/src/errors.php +++ /dev/null @@ -1,119 +0,0 @@ - "\033[31m", // red - 'warning' => "\033[33m", // yellow - 'notice' => "\033[36m", // cyan - 'reset' => "\033[0m" // reset - ]; - $color = $colors[$type] ?? $colors['error']; - return $color . $message . $colors['reset'] . PHP_EOL; - } else { - // Web HTML formatting - $styles = [ - 'error' => 'color:red;', - 'warning' => 'color:orange;', - 'notice' => 'color:blue;' - ]; - $style = $styles[$type] ?? $styles['error']; - return "
$message
"; - } -} - -// Custom error handler -set_error_handler(function($errno, $errstr, $errfile, $errline) { - // Skip if error reporting is turned off - if (!(error_reporting() & $errno)) { - return false; - } - - $errorTypes = [ - E_ERROR => ['ERROR', 'error'], - E_WARNING => ['WARNING', 'warning'], - E_PARSE => ['PARSE ERROR', 'error'], - E_NOTICE => ['NOTICE', 'notice'], - E_CORE_ERROR => ['CORE ERROR', 'error'], - E_CORE_WARNING => ['CORE WARNING', 'warning'], - E_COMPILE_ERROR => ['COMPILE ERROR', 'error'], - E_COMPILE_WARNING => ['COMPILE WARNING', 'warning'], - E_USER_ERROR => ['USER ERROR', 'error'], - E_USER_WARNING => ['USER WARNING', 'warning'], - E_USER_NOTICE => ['USER NOTICE', 'notice'], - E_STRICT => ['STRICT', 'notice'], - E_RECOVERABLE_ERROR=> ['RECOVERABLE ERROR', 'error'], - E_DEPRECATED => ['DEPRECATED', 'warning'], - E_USER_DEPRECATED => ['USER DEPRECATED', 'warning'] - ]; - - $errorInfo = $errorTypes[$errno] ?? ['UNKNOWN', 'error']; - $errorType = $errorInfo[0]; - $errorCategory = $errorInfo[1]; - - $logMessage = date('[Y-m-d H:i:s]') . " [$errorType] $errstr in $errfile on line $errline" . PHP_EOL; - $displayMessage = "$errorType: $errstr in $errfile on line $errline"; - - // Log to file - file_put_contents(LOG_FILE, $logMessage, FILE_APPEND); - - // Display in development environment - if (ENVIRONMENT === 'development') { - echo formatMessage($displayMessage, $errorCategory); - } - - // Prevent PHP's default error handler - return true; -}); - -// Handle exceptions -set_exception_handler(function($e) { - $logMessage = date('[Y-m-d H:i:s]') . " [EXCEPTION] " . $e->getMessage() . - " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL; - $displayMessage = "UNCAUGHT EXCEPTION: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine(); - - file_put_contents(LOG_FILE, $logMessage, FILE_APPEND); - - if (ENVIRONMENT === 'development') { - echo formatMessage($displayMessage, 'error'); - } else { - // In production, show user-friendly message - echo PHP_SAPI === 'cli' - ? "An error occurred. Our team has been notified." . PHP_EOL - : "An error occurred. Our team has been notified."; - } -}); - -// Handle fatal errors -register_shutdown_function(function() { - $error = error_get_last(); - if ($error && in_array($error['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR])) { - $logMessage = date('[Y-m-d H:i:s]') . " [FATAL] {$error['message']} in {$error['file']} on line {$error['line']}" . PHP_EOL; - $displayMessage = "FATAL ERROR: {$error['message']} in {$error['file']} on line {$error['line']}"; - - file_put_contents(LOG_FILE, $logMessage, FILE_APPEND); - - if (ENVIRONMENT === 'development') { - echo formatMessage($displayMessage, 'error'); - } - } -}); - -// Test the error handler (uncomment to test) -// trigger_error("This is a test warning", E_USER_WARNING); -// throw new Exception("This is a test exception"); -// nonexistentFunction(); // Will trigger a fatal error in shutdown handler \ No newline at end of file diff --git a/public/assets/favicon/about.txt b/public/assets/favicon/about.txt new file mode 100644 index 0000000..86a430c --- /dev/null +++ b/public/assets/favicon/about.txt @@ -0,0 +1,6 @@ +This favicon was generated using the following font: + +- Font Title: Ubuntu Mono +- Font Author: Copyright 2011 Canonical Ltd. Licensed under the Ubuntu Font Licence 1.0 +- Font Source: http://fonts.gstatic.com/s/ubuntumono/v14/KFO8CneDtsqEr0keqCMhbCc_Mn33tYhkf3O1GVg.ttf +- Font License: Ubuntu Font License, 1.0 (http://font.ubuntu.com/ufl/)) diff --git a/public/assets/favicon/android-chrome-192x192.png b/public/assets/favicon/android-chrome-192x192.png new file mode 100644 index 0000000..4e5e38f Binary files /dev/null and b/public/assets/favicon/android-chrome-192x192.png differ diff --git a/public/assets/favicon/android-chrome-512x512.png b/public/assets/favicon/android-chrome-512x512.png new file mode 100644 index 0000000..517d0be Binary files /dev/null and b/public/assets/favicon/android-chrome-512x512.png differ diff --git a/public/assets/favicon/apple-touch-icon.png b/public/assets/favicon/apple-touch-icon.png new file mode 100644 index 0000000..3b3916f Binary files /dev/null and b/public/assets/favicon/apple-touch-icon.png differ diff --git a/public/assets/favicon/favicon-16x16.png b/public/assets/favicon/favicon-16x16.png new file mode 100644 index 0000000..a984ebc Binary files /dev/null and b/public/assets/favicon/favicon-16x16.png differ diff --git a/public/assets/favicon/favicon-32x32.png b/public/assets/favicon/favicon-32x32.png new file mode 100644 index 0000000..5b32be4 Binary files /dev/null and b/public/assets/favicon/favicon-32x32.png differ diff --git a/public/assets/favicon/favicon.ico b/public/assets/favicon/favicon.ico new file mode 100644 index 0000000..3b1cd3d Binary files /dev/null and b/public/assets/favicon/favicon.ico differ diff --git a/public/assets/favicon/site.webmanifest b/public/assets/favicon/site.webmanifest new file mode 100644 index 0000000..27ea6f8 --- /dev/null +++ b/public/assets/favicon/site.webmanifest @@ -0,0 +1 @@ +{"name":"","short_name":"","icons":[{"src":"./android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"./android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} \ No newline at end of file diff --git a/public/assets/images/404page.jpg b/public/assets/images/404page.jpg new file mode 100644 index 0000000..4d7fbe8 Binary files /dev/null and b/public/assets/images/404page.jpg differ diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..b684416 --- /dev/null +++ b/public/index.php @@ -0,0 +1,20 @@ + + * @copyright (c) 2025, Robert Strutts + * @license MIT + */ + +define("BaseDir", dirname(__DIR__)); // Project DIR +const CodeHydrater_PROJECT = BaseDir . "/protected/src/"; +const CodeHydrater_FRAMEWORK = BaseDir . "/protected/FWCodeHydrater/src/"; + +$testing = false; + +require_once CodeHydrater_FRAMEWORK . 'bootstrap/siteHelper.php'; +CodeHydrater\bootstrap\siteHelper::init(BaseDir, $_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD'], $testing); + +require_once CodeHydrater_FRAMEWORK . "bootstrap/main.php"; \ No newline at end of file