Skip to content

Commit b133576

Browse files
authored
Merge pull request #8 from dconco/dev
Refactor routing logic and database info
2 parents 3b99719 + 8739fbf commit b133576

24 files changed

+763
-158
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ APP_NAME='PhpSlides'
22
APP_VERSION='1.0.0'
33
APP_SERVER='localhost'
44

5-
## DATABASE INFO (MySQL)
5+
## DATABASE INFO
66
DB_USER='root'
77
DB_PASS='root'
88
DB_HOST='localhost'

App/Controller/RouteController.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,39 @@ protected static function config_file(): array|bool
4040

4141

4242

43+
/**
44+
* -----------------------------------------------------------
45+
* |
46+
* @param mixed $filename The file which to gets the contents
47+
* @return mixed The executed included file received
48+
* |
49+
* -----------------------------------------------------------
50+
*/
51+
protected static function get_included_file($filename)
52+
{
53+
if (is_file($filename))
54+
{
55+
ob_start();
56+
include $filename;
57+
$output = ob_get_contents();
58+
ob_end_clean();
59+
60+
if ($output != false)
61+
{
62+
return $output;
63+
}
64+
else
65+
{
66+
throw new Exception("Empty file.");
67+
}
68+
}
69+
else
70+
{
71+
return false;
72+
}
73+
}
74+
75+
4376
/**
4477
* ==============================
4578
* | Don't use this function!!!
@@ -76,8 +109,7 @@ protected static function routing(array|string $route, $callback, string $method
76109
exit('Method Not Allowed');
77110
}
78111

79-
$charset = self::config_file()['charset'];
80-
header("Content-type: */*, charset=$charset");
112+
header("Content-Type: */*");
81113
http_response_code(200);
82114

83115
return $callback;

0 commit comments

Comments
 (0)