fix simple php errors
This commit is contained in:
parent
708594d32f
commit
862ff4e52a
4 changed files with 19 additions and 6 deletions
|
@ -66,10 +66,14 @@ class Router {
|
||||||
* Gets the curret request info
|
* Gets the curret request info
|
||||||
* @return array<string,mixed>
|
* @return array<string,mixed>
|
||||||
*/
|
*/
|
||||||
private function get_req(): array {
|
private function get_req(): array|bool {
|
||||||
$method = $_SERVER['REQUEST_METHOD'];
|
$method = $_SERVER['REQUEST_METHOD'];
|
||||||
|
|
||||||
$uri = parse_url($_SERVER['REQUEST_URI']);
|
$uri = parse_url($_SERVER['REQUEST_URI']);
|
||||||
|
if (!$uri) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
$path = $uri['path'];
|
$path = $uri['path'];
|
||||||
|
|
||||||
return array_merge(
|
return array_merge(
|
||||||
|
@ -100,9 +104,11 @@ class Router {
|
||||||
die($code . ' (recursed)');
|
die($code . ' (recursed)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->main->info = array();
|
||||||
$this->main->info['slug'] = 'index';
|
$this->main->info['slug'] = 'index';
|
||||||
$this->main->info['app'] = 'error';
|
$this->main->info['app'] = 'error';
|
||||||
$this->main->info['route'] = 'apps/error';
|
$this->main->info['route'] = 'apps/error';
|
||||||
|
$this->main->info['lang'] = $this->get_lang();
|
||||||
$req = $this->main->info;
|
$req = $this->main->info;
|
||||||
$_GET['code'] = $code;
|
$_GET['code'] = $code;
|
||||||
|
|
||||||
|
@ -114,6 +120,12 @@ class Router {
|
||||||
* @param bool $recursed
|
* @param bool $recursed
|
||||||
*/
|
*/
|
||||||
private function handle_req($req, $recursed = FALSE): void {
|
private function handle_req($req, $recursed = FALSE): void {
|
||||||
|
|
||||||
|
if ($req === FALSE) {
|
||||||
|
$this->handle_error(500, $recursed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$controller = $this->load->controller($req['route']);
|
$controller = $this->load->controller($req['route']);
|
||||||
|
|
||||||
if ($controller === NULL) {
|
if ($controller === NULL) {
|
||||||
|
|
|
@ -4,6 +4,6 @@ function error_page($code, $msg) {
|
||||||
$root = $GLOBALS['webroot'];
|
$root = $GLOBALS['webroot'];
|
||||||
error_reporting(E_ERROR | E_PARSE);
|
error_reporting(E_ERROR | E_PARSE);
|
||||||
http_response_code($code);
|
http_response_code($code);
|
||||||
require($root . '/views/template/error.php');
|
require($root . '/_views/template/error.php');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
lang_part() {
|
lang_part() {
|
||||||
echo "$1" | awk "{split(\$0,a,\" = \"); print a[$2]}"
|
echo "$1" | awk "{split(\$0,a,\" = \"); print a[$2]}"
|
||||||
|
@ -10,7 +10,8 @@ handle_line() {
|
||||||
left=$(lang_part "$line" 1)
|
left=$(lang_part "$line" 1)
|
||||||
right=$(lang_part "$line" 2)
|
right=$(lang_part "$line" 2)
|
||||||
echo "$left" | grep -Ev '_content|_line' > /dev/null
|
echo "$left" | grep -Ev '_content|_line' > /dev/null
|
||||||
if [ "$?" -eq 0 ]; then
|
code=$?
|
||||||
|
if [ $code -eq 0 ]; then
|
||||||
right=$(echo "$right" | uwuify)
|
right=$(echo "$right" | uwuify)
|
||||||
fi;
|
fi;
|
||||||
right=${right%;};
|
right=${right%;};
|
||||||
|
@ -23,7 +24,7 @@ transpile() {
|
||||||
out="$2"
|
out="$2"
|
||||||
printf "" > "$out"
|
printf "" > "$out"
|
||||||
printf "<?php /* Copyright (c) 2024 Freya Murphy */\n\n" > "$out";
|
printf "<?php /* Copyright (c) 2024 Freya Murphy */\n\n" > "$out";
|
||||||
cat "$file" | grep '$lang' | xargs -d'\n' -I {} bash -c 'handle_line "$@"' _ {} >> "$out"
|
grep "\$lang" < "$file" | xargs -d'\n' -I{} bash -c 'handle_line "$@"' _ {} >> "$out"
|
||||||
}
|
}
|
||||||
|
|
||||||
transpile "$1" "$2"
|
transpile "$1" "$2"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php /* Copyright (c) 2024 Freya Murphy */
|
<?php /* Copyright (c) 2024 Freya Murphy */
|
||||||
|
|
||||||
$lang['version'] = 'Version 2.0.0';
|
$lang['version'] = 'Version 2.0.1';
|
||||||
$lang['copyright'] = 'Freya Murphy © 2024';
|
$lang['copyright'] = 'Freya Murphy © 2024';
|
||||||
|
|
||||||
// Navigation Bar Lang
|
// Navigation Bar Lang
|
||||||
|
|
Loading…
Reference in a new issue