Robert 5 months ago
parent 1241626ed5
commit 5376fa4a39
  1. 1
      .gitignore
  2. 28
      protected/cli/makeLicense.php
  3. 3
      protected/logs/error_log.txt
  4. 119
      protected/src/errors.php
  5. 6
      public/assets/favicon/about.txt
  6. BIN
      public/assets/favicon/android-chrome-192x192.png
  7. BIN
      public/assets/favicon/android-chrome-512x512.png
  8. BIN
      public/assets/favicon/apple-touch-icon.png
  9. BIN
      public/assets/favicon/favicon-16x16.png
  10. BIN
      public/assets/favicon/favicon-32x32.png
  11. BIN
      public/assets/favicon/favicon.ico
  12. 1
      public/assets/favicon/site.webmanifest
  13. BIN
      public/assets/images/404page.jpg
  14. 20
      public/index.php

1
.gitignore vendored

@ -3,5 +3,6 @@ protected/src/secret_php_files
protected/src/aes protected/src/aes
protected/src/aeskeys.php protected/src/aeskeys.php
protected/keydata protected/keydata
protected/runtime
*.swp *.swp
*.log *.log

@ -1,9 +1,15 @@
<?php <?php
/**
* Keep this file from the customer...
*/
use HydraterLicense\MakeLicense; use HydraterLicense\MakeLicense;
if (! class_exists("HydraterLicense\MakeLicense")) {
die("Sorry, this extenstion is not availiable!");
}
define("BaseDir", dirname(__DIR__)); define("BaseDir", dirname(__DIR__));
// Using standard ISO 8601 format, and make it expire in 4 years // Using standard ISO 8601 format, and make it expire in 4 years
define('EXPIRES_DATE', (new DateTime('+4 years'))->format(DateTime::ATOM)); define('EXPIRES_DATE', (new DateTime('+4 years'))->format(DateTime::ATOM));
@ -12,28 +18,18 @@ $license_maker = new MakeLicense();
define("PWD1", $license_maker->makePassword()); define("PWD1", $license_maker->makePassword());
define("PWD2", $license_maker->makePassword()); define("PWD2", $license_maker->makePassword());
// PHP Files to keep secure are in src/secret_php_files
const Array_For_Files = [ const Array_For_Files = [
BaseDir. "/src/aes/main.aes" => BaseDir. "/src/aes/testing.aes" =>
[ "feature" => "testing", "enabled" => true, "expires" => EXPIRES_DATE, "password" => PWD1 ], [ "feature" => "testing", "enabled" => true, "expires" => EXPIRES_DATE, "password" => PWD1 ],
BaseDir. "/src/aes/config.aes" => BaseDir. "/src/aes/config.aes" =>
[ "feature" => "junk", "enabled" => false, "password" => PWD2 ], [ "feature" => "junk", "enabled" => false, "password" => PWD2 ],
]; ];
const ALLOWED_DOMAINS = ["localhost", "sub.example.org"]; const ALLOWED_DOMAINS = ["localhost", "sub.example.org"];
const PrivatePEM = BaseDir."/keydata/private.pem";
const PublicPEM = BaseDir."/keydata/public.pem"; $license_maker->runSymlink(BaseDir. "/FWCodeHydrater", "src/classes/makeLicenseFiles.php");
const AESKeysFile = BaseDir."/src/aeskeys.php";
const LicenseFile = BaseDir."/keydata/license.json";
$license_maker->generateLicense(
Array_For_Files,
ALLOWED_DOMAINS,
PrivatePEM,
PublicPEM,
AESKeysFile,
LicenseFile
);
/** /**
* use stars for unlimited access for domains and expires dates if desired! * use stars for unlimited access for domains and expires dates if desired!

@ -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

@ -1,119 +0,0 @@
<?php
// Configuration
if (! defined('BaseDir')) {
define('LOG_FILE', __DIR__ . '/logs/error_log.txt');
} else {
define('LOG_FILE', BaseDir . '/logs/error_log.txt');
}
if (! defined('ENVIRONMENT')) {
define('ENVIRONMENT', 'production'); // 'production' or 'development'
}
/**
* Format message with appropriate colors based on environment
*/
function formatMessage($message, $type = 'error') {
if (PHP_SAPI === 'cli') {
// CLI color formatting
$colors = [
'error' => "\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 "<div style='{$style}padding:10px;border:1px solid #f99;margin:10px;'>$message</div>";
}
}
// 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

@ -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/))

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@ -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"}

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
/**
* @author Robert Strutts <Bob_586@Yahoo.com>
* @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";
Loading…
Cancel
Save