Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ByeCorps ID Legacy
Manage
Activity
Members
Labels
Plan
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ByeCorps
ID
ByeCorps ID Legacy
Commits
fed68541
Commit
fed68541
authored
Jun 28, 2024
by
Bye
Browse files
Options
Downloads
Patches
Plain Diff
Import languages
parent
76c96d3a
Branches
Branches containing commit
No related tags found
1 merge request
!4
Draft: Merge rewrite branch into main
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
index.php
+34
-11
34 additions, 11 deletions
index.php
with
34 additions
and
11 deletions
index.php
+
34
−
11
View file @
fed68541
<?php
$DOC_ROOT
=
$_SERVER
[
'DOCUMENT_ROOT'
];
// Includes
try
{
require
"config.php"
;
require
_once
"config.php"
;
}
catch
(
Error
$e
)
{
echo
"<b>Critical error:</b> "
.
$e
->
getMessage
()
.
"<br />This isn't your fault. Please contact the developers."
;
exit
;
...
...
@@ -15,32 +17,53 @@ try {
echo
"<b>Critical error:</b> "
.
$e
->
getMessage
()
.
"<br />"
;
}
require_once
'strings/en.php'
;
// This ensures strings will fallback to English if one is missing.
require_once
'common/strings.php'
;
require_once
'common/account_utils.php'
;
require_once
'common/database.php'
;
// Starts the session
// TODO: write this to use the database to work across more than one server
// TODO: write this to use the database to work across more than one server
(e.g. don't use PHP sessions)
session_start
();
$user
=
null
;
if
(
$_SESSION
[
'auth'
])
{
$user
=
get_user_by_id
(
$_SESSION
[
'id'
]);
}
$uri_string
=
$_SERVER
[
'REQUEST_URI'
];
// `/foo/bar?bar=foo&foo=bar`
$uri_explode
=
explode
(
'?'
,
$uri_string
);
$path
=
$uri_explode
[
0
];
// `/foo/bar`
$path
_array
=
explode
(
'/'
,
$path
);
$path
_raw
=
$uri_explode
[
0
];
// `/foo/bar`
$path
=
explode
(
'/'
,
$path
_raw
);
// Remove trailing slashes
if
(
str_ends_with
(
$path
,
'/'
)
&&
$path
!=
'/'
)
{
if
(
str_ends_with
(
$path
_raw
,
'/'
)
&&
$path
_raw
!=
'/'
)
{
http_response_code
(
308
);
header
(
'Location: '
.
substr
(
$path
,
0
,
-
1
));
header
(
'Location: '
.
substr
(
$path
_raw
,
0
,
-
1
));
exit
;
}
$routes
=
[
''
=>
function
()
{
require
'views/home.php'
;
},
'api'
=>
function
()
{
require
'api.php'
;
/* Handoff further routing to API script. */
}
];
'api'
=>
function
()
{
require
'api.php'
;
/* Handoff further routing to API script. */
},
'profile'
=>
function
()
{
global
$path
,
$user
,
$profile_owner
;
// don't forget this lol
//print_r($path_array);
if
(
isset
(
$path
[
2
]))
{
$profile_owner
=
$path
[
2
];
$profile_owner
=
get_user_by_id
(
$profile_owner
);
}
else
{
$profile_owner
=
$user
;
}
require
'views/profile.php'
;
},
];
if
(
array_key_exists
(
$path
_array
[
1
],
$routes
))
{
$res
=
$routes
[
$path
_array
[
1
]]();
if
(
array_key_exists
(
$path
[
1
],
$routes
))
{
$res
=
$routes
[
$path
[
1
]]();
if
(
$res
==
404
)
{
require
"views/404.php"
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment