[PHP] Update basicphp to 0.9.1 (#1909) · grepjava/web-frameworks@79cbd86 · GitHub
Skip to content

Commit 79cbd86

Browse files
ray-angwaghanza
authored andcommitted
[PHP] Update basicphp to 0.9.1 (the-benchmarker#1909)
1 parent 3f3290a commit 79cbd86

7 files changed

Lines changed: 319 additions & 256 deletions

File tree

‎php/Dockerfile‎

Lines changed: 1 addition & 0 deletions

‎php/basicphp/config.php‎

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
|--------------------------------------------------------------------------
77
*/
88

9-
// session_start();
9+
session_start();
1010

1111
/*
1212
|--------------------------------------------------------------------------
@@ -19,18 +19,24 @@
1919
*/
2020

2121
// Add class folders to autoload
22-
// $class_folders[] = 'classes';
23-
// $class_folders[] = 'models';
22+
$class_folders[] = 'classes';
23+
$class_folders[] = 'models';
2424
$class_folders[] = 'controllers';
2525

2626
define('AUTOLOAD_CLASSES', $class_folders);
2727

2828
spl_autoload_register(function ($class_name) {
29-
foreach (AUTOLOAD_CLASSES as $folder) {
30-
if (file_exists('../' . $folder . '/' . $class_name . '.php') && is_readable('../' . $folder . '/' . $class_name . '.php')) {
31-
require_once '../' . $folder . '/' . $class_name . '.php';
32-
}
33-
}
29+
30+
foreach (AUTOLOAD_CLASSES as $folder) {
31+
32+
if (file_exists('../' . $folder . '/' . $class_name . '.php') && is_readable('../' . $folder . '/' . $class_name . '.php')) {
33+
34+
require_once '../' . $folder . '/' . $class_name . '.php';
35+
36+
}
37+
38+
}
39+
3440
});
3541

3642
/*
@@ -58,39 +64,51 @@
5864

5965
/*
6066
|--------------------------------------------------------------------------
61-
| Set BASE_URL
67+
| Enforce SSL/HTTPS
6268
|--------------------------------------------------------------------------
63-
|
64-
| Define 'BASE_URL' as the domain with '/' at the end, such as
65-
| 'http://example.com/' or 'https://example.com/'.
66-
| Include subdirectory if index.php is not in DocumentRoot folder.
67-
|
6869
*/
6970

70-
define('BASE_URL', 'http://localhost/');
71+
define('ENFORCE_SSL', FALSE);
7172

7273
/*
7374
|--------------------------------------------------------------------------
74-
| Set URL_PARSE Method as either 'REQUEST_URI' or 'PATH_INFO'.
75-
| When using Nginx server, 'REQUEST_URI' is recommended.
76-
| SUB_DIR as the number of subfolders index.php is located from domain.
75+
| Set URI Whitelisted Characters
7776
|--------------------------------------------------------------------------
78-
|
79-
| Sets the $_SERVER[''] global variable to parse the URL.
80-
|
8177
*/
8278

83-
define('URL_PARSE', 'REQUEST_URI');
79+
define('URI_WHITELISTED', '\w\/\-\?\=\&');
8480

85-
if (URL_PARSE == 'PATH_INFO') {
86-
define('SUB_DIR', 0);
87-
} elseif (URL_PARSE == 'REQUEST_URI') {
88-
define('SUB_DIR', substr_count(BASE_URL, '/')-3);
89-
}
81+
/*
82+
|--------------------------------------------------------------------------
83+
| Set $_POST Blacklisted Characters
84+
| Backslash (\) is blacklisted by default.
85+
|--------------------------------------------------------------------------
86+
*/
87+
88+
define('POST_BLACKLISTED', '\<\>\{\}\[\]\_\;\*\=\+\"\&\#\%\\$');
89+
90+
/*
91+
|--------------------------------------------------------------------------
92+
| Set BASE_URL
93+
|--------------------------------------------------------------------------
94+
*/
95+
96+
if (ENFORCE_SSL == FALSE) { $http_protocol = 'http://'; } else { $http_protocol = 'https://'; }
97+
if (! empty(dirname($_SERVER['SCRIPT_NAME']))) { $subfolder = dirname($_SERVER['SCRIPT_NAME']); } else { $subfolder = ''; }
98+
99+
define('BASE_URL', $http_protocol . $_SERVER['SERVER_NAME'] . $subfolder . '/');
100+
101+
/*
102+
|--------------------------------------------------------------------------
103+
| Number of subdirectories from hostname to index.php
104+
|--------------------------------------------------------------------------
105+
*/
106+
107+
define('SUB_DIR', substr_count($_SERVER['SCRIPT_NAME'], '/')-1);
90108

91109
/*
92110
|--------------------------------------------------------------------------
93-
| Set Homepage
111+
| Set Homepage Controller@method
94112
|--------------------------------------------------------------------------
95113
*/
96114

@@ -113,6 +131,7 @@
113131
|--------------------------------------------------------------------------
114132
|
115133
| If the second URL string is empty, set this method as the default method.
134+
|
116135
*/
117136

118-
define('METHOD_DEFAULT', 'index');
137+
define('METHOD_DEFAULT', 'index');
Lines changed: 26 additions & 9 deletions

‎php/basicphp/controllers/UserController.php‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)