41 lines
765 B
PHP
Executable File
41 lines
765 B
PHP
Executable File
<?php
|
|
|
|
function getBaseUrl(): string
|
|
{
|
|
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
|
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
|
|
|
return "{$protocol}://{$host}";
|
|
}
|
|
|
|
function getAppUrl(string $path = ''): string
|
|
{
|
|
return getBaseUrl() . '/' . ltrim($path, '/');
|
|
}
|
|
|
|
function site_url(string $path = ''): string
|
|
{
|
|
return getAppUrl($path);
|
|
}
|
|
|
|
function asset(string $path): string
|
|
{
|
|
return getAppUrl('assets/' . ltrim($path, '/'));
|
|
}
|
|
|
|
function url(string $path): string
|
|
{
|
|
return getAppUrl($path);
|
|
}
|
|
|
|
function redirect(string $path): void
|
|
{
|
|
header('Location: ' . site_url($path));
|
|
exit;
|
|
}
|
|
|
|
function current_url(): string
|
|
{
|
|
return getBaseUrl() . ($_SERVER['REQUEST_URI'] ?? '/');
|
|
}
|