092a8bc7ce
- Removed all backup/duplicate files - Removed test files from root - Consolidated documentation to /docs/ - Moved scripts to /scripts/ - Renamed f_* directories (removed prefix) - Organized icons and assets - Removed unused vendor directories - Cleaned up redundant config files
35 lines
880 B
PHP
35 lines
880 B
PHP
<?php
|
|
// Core utility functions
|
|
if (!defined("_VALID_ACCESS")) { exit("Direct access not allowed"); }
|
|
|
|
function sanitize_input($input) {
|
|
if (is_array($input)) {
|
|
return array_map("sanitize_input", $input);
|
|
}
|
|
return htmlspecialchars(trim($input), ENT_QUOTES, "UTF-8");
|
|
}
|
|
|
|
function redirect($url, $code = 302) {
|
|
header("Location: " . $url, true, $code);
|
|
exit();
|
|
}
|
|
|
|
function json_response($data, $code = 200) {
|
|
http_response_code($code);
|
|
header("Content-Type: application/json");
|
|
echo json_encode($data);
|
|
exit();
|
|
}
|
|
|
|
function error_response($message, $code = 400) {
|
|
json_response(["error" => $message], $code);
|
|
}
|
|
|
|
function success_response($data = null, $message = "Success") {
|
|
$response = ["success" => true, "message" => $message];
|
|
if ($data !== null) {
|
|
$response["data"] = $data;
|
|
}
|
|
json_response($response);
|
|
}
|