Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
ajax.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2024 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: Bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
13
include_once __DIR__ .
'/../../root.php'
;
14
21
$procMap
= [
22
'summary'
=> __DIR__ .
'/ajax/ajax.summary.php'
,
23
'latestversion'
=> __DIR__ .
'/ajax/ajax.latestversion.php'
,
24
'apache'
=> __DIR__ .
'/ajax/ajax.apache.php'
,
25
'mailpit'
=> __DIR__ .
'/ajax/ajax.mailpit.php'
,
26
'memcached'
=> __DIR__ .
'/ajax/ajax.memcached.php'
,
27
'mariadb'
=> __DIR__ .
'/ajax/ajax.mariadb.php'
,
28
'mysql'
=> __DIR__ .
'/ajax/ajax.mysql.php'
,
29
'nodejs'
=> __DIR__ .
'/ajax/ajax.nodejs.php'
,
30
'php'
=> __DIR__ .
'/ajax/ajax.php.php'
,
31
'postgresql'
=> __DIR__ .
'/ajax/ajax.postgresql.php'
,
32
'xlight'
=> __DIR__ .
'/ajax/ajax.xlight.php'
,
33
'quickpick'
=> __DIR__ .
'/ajax/ajax.quickpick.php'
,
34
'toggleenhancedquickpick'
=> __DIR__ .
'/ajax/ajax.toggle.enhancedquickpick.php'
,
35
'applymoduleconfig'
=> __DIR__ .
'/ajax/ajax.apply.moduleconfig.php'
36
];
37
45
$proc
=
UtilInput::cleanPostVar
(
'proc'
,
'text'
);
// Ensure 'proc' is cleaned and read correctly
46
52
$csrfProtectedEndpoints
= [
53
'quickpick'
,
// Installs modules
54
'toggleenhancedquickpick'
,
// Changes configuration
55
'applymoduleconfig'
// Applies configuration changes
56
];
57
61
if
(
$proc
!==
'quickpick'
) {
62
Csrf::init
();
63
}
64
68
if
(in_array(
$proc
,
$csrfProtectedEndpoints
,
true
)) {
69
if
(
$proc
===
'quickpick'
) {
70
// quickpick handles its own headers and needs session started carefully
71
if
(session_status() === PHP_SESSION_NONE) {
72
@session_start();
73
}
74
}
75
76
if
(!
Csrf::validateRequest
()) {
77
http_response_code(403);
78
header(
'Content-Type: application/json'
);
79
echo json_encode([
80
'error'
=>
'CSRF validation failed'
,
81
'message'
=>
'Invalid or expired security token. Please refresh the page and try again.'
82
]);
83
exit
;
84
}
85
}
86
92
if
(isset(
$procMap
[
$proc
]) && file_exists(
$procMap
[
$proc
])) {
96
include
$procMap
[
$proc
];
97
}
else
{
103
$errorMessage =
'Invalid proc parameter'
;
104
if
(!empty(
$proc
)) {
105
$errorMessage .=
': "'
. htmlspecialchars(
$proc
) .
'" is not a valid procedure'
;
106
}
else
{
107
$errorMessage .=
': no procedure was specified'
;
108
}
109
echo json_encode([
'error'
=> $errorMessage]);
110
}
exit
exit
Definition
ajax.apply.moduleconfig.php:63
$csrfProtectedEndpoints
$csrfProtectedEndpoints
Definition
ajax.php:52
$procMap
$procMap
Definition
ajax.php:21
$proc
$proc
Definition
ajax.php:45
Csrf\validateRequest
static validateRequest($removeAfterValidation=false)
Definition
class.csrf.php:186
Csrf\init
static init()
Definition
class.csrf.php:58
UtilInput\cleanPostVar
static cleanPostVar($name, $type='text')
Definition
class.util.input.php:88
sandbox
core
resources
homepage
ajax.php
Generated by
1.17.0