-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.php
40 lines (31 loc) · 1.18 KB
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
function ensureTrailingSlash($url)
{
return rtrim($url, '/') . '/';
}
function validateConfig()
{
if (!defined('BASE_URI') || !defined('RIOT_CLIENT_ID') || !defined('RIOT_CLIENT_SECRET')) {
die('Missing required configuration constants. Please check your config.php file.');
}
if (!str_starts_with(strtolower(BASE_URI), 'https://')) {
die('BASE_URI must use HTTPS. Riot Games RSO requires a secure connection.');
}
if (empty(RIOT_CLIENT_ID) || RIOT_CLIENT_ID === 'YOUR_CLIENT_ID_HERE') {
die('Please set a valid RIOT_CLIENT_ID in config.php');
}
if (empty(RIOT_CLIENT_SECRET) || RIOT_CLIENT_SECRET === 'YOUR_CLIENT_SECRET_HERE') {
die('Please set a valid RIOT_CLIENT_SECRET in config.php');
}
}
function handleError($exception)
{
error_log($exception->getMessage());
if (strpos($exception->getMessage(), '401') !== false) {
return 'Authentication failed. Please check your client credentials.';
}
if (strpos($exception->getMessage(), '404') !== false) {
return 'Resource not found. Please check the API endpoints.';
}
return 'An unexpected error occurred. Please try again later.';
}