feat: Complete Woles Framework v1.0 with enterprise-grade UI
- Add comprehensive error handling system with custom error pages - Implement professional enterprise-style design with Tailwind CSS - Create modular HMVC architecture with clean separation of concerns - Add security features: CSRF protection, XSS filtering, Argon2ID hashing - Include CLI tools for development workflow - Add error reporting dashboard with system monitoring - Implement responsive design with consistent slate color scheme - Replace all emoji icons with professional SVG icons - Add comprehensive test suite with PHPUnit - Include database migrations and seeders - Add proper exception handling with fallback pages - Implement template engine with custom syntax support - Add helper functions and facades for clean code - Include proper logging and debugging capabilities
This commit is contained in:
197
app/Core/Request.php
Normal file
197
app/Core/Request.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
/**
|
||||
* NovaCore Request Handler
|
||||
* HTTP request wrapper
|
||||
*/
|
||||
class Request
|
||||
{
|
||||
private array $data;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->data = array_merge($_GET, $_POST, $_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all input data
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get input value by key
|
||||
*/
|
||||
public function input(string $key, $default = null)
|
||||
{
|
||||
return $this->data[$key] ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get only specified keys
|
||||
*/
|
||||
public function only(array $keys): array
|
||||
{
|
||||
return array_intersect_key($this->data, array_flip($keys));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all except specified keys
|
||||
*/
|
||||
public function except(array $keys): array
|
||||
{
|
||||
return array_diff_key($this->data, array_flip($keys));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if key exists
|
||||
*/
|
||||
public function has(string $key): bool
|
||||
{
|
||||
return isset($this->data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request method
|
||||
*/
|
||||
public function method(): string
|
||||
{
|
||||
return $_SERVER['REQUEST_METHOD'] ?? 'GET';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if method is POST
|
||||
*/
|
||||
public function isPost(): bool
|
||||
{
|
||||
return $this->method() === 'POST';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if method is GET
|
||||
*/
|
||||
public function isGet(): bool
|
||||
{
|
||||
return $this->method() === 'GET';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request URI
|
||||
*/
|
||||
public function uri(): string
|
||||
{
|
||||
return $_SERVER['REQUEST_URI'] ?? '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request path
|
||||
*/
|
||||
public function path(): string
|
||||
{
|
||||
return parse_url($this->uri(), PHP_URL_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query string
|
||||
*/
|
||||
public function query(): string
|
||||
{
|
||||
return $_SERVER['QUERY_STRING'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get headers
|
||||
*/
|
||||
public function headers(): array
|
||||
{
|
||||
if (function_exists('getallheaders')) {
|
||||
$h = getallheaders();
|
||||
return is_array($h) ? $h : [];
|
||||
}
|
||||
// Fallback build from $_SERVER
|
||||
$headers = [];
|
||||
foreach ($_SERVER as $key => $value) {
|
||||
if (strpos($key, 'HTTP_') === 0) {
|
||||
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
|
||||
$headers[$name] = $value;
|
||||
} elseif (in_array($key, ['CONTENT_TYPE', 'CONTENT_LENGTH'])) {
|
||||
$name = str_replace('_', '-', ucwords(strtolower($key), '_'));
|
||||
$headers[$name] = $value;
|
||||
}
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific header
|
||||
*/
|
||||
public function header(string $name): ?string
|
||||
{
|
||||
$headers = $this->headers();
|
||||
return $headers[$name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if request is AJAX
|
||||
*/
|
||||
public function isAjax(): bool
|
||||
{
|
||||
return $this->header('X-Requested-With') === 'XMLHttpRequest';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if request expects JSON
|
||||
*/
|
||||
public function expectsJson(): bool
|
||||
{
|
||||
$accept = $this->header('Accept') ?? '';
|
||||
return stripos($accept, 'application/json') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file upload
|
||||
*/
|
||||
public function file(string $key): ?array
|
||||
{
|
||||
return $_FILES[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all files
|
||||
*/
|
||||
public function files(): array
|
||||
{
|
||||
return $_FILES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IP address
|
||||
*/
|
||||
public function ip(): string
|
||||
{
|
||||
return $_SERVER['HTTP_X_FORWARDED_FOR'] ??
|
||||
$_SERVER['HTTP_X_REAL_IP'] ??
|
||||
$_SERVER['REMOTE_ADDR'] ??
|
||||
'unknown';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user agent
|
||||
*/
|
||||
public function userAgent(): string
|
||||
{
|
||||
return $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get referer
|
||||
*/
|
||||
public function referer(): ?string
|
||||
{
|
||||
return $_SERVER['HTTP_REFERER'] ?? null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user