Bearsampp
2026.7.28
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
'reloadstatus'
=> __DIR__ .
'/ajax/ajax.reload.status.php'
37
];
38
46
$proc
=
UtilInput::cleanPostVar
(
'proc'
,
'text'
);
// Ensure 'proc' is cleaned and read correctly
47
53
$csrfProtectedEndpoints
= [
54
'quickpick'
,
// Installs modules
55
'toggleenhancedquickpick'
,
// Changes configuration
56
'applymoduleconfig'
// Applies configuration changes
57
];
58
62
if
(
$proc
!==
'quickpick'
) {
63
Csrf::init
();
64
}
65
69
if
(in_array(
$proc
,
$csrfProtectedEndpoints
,
true
)) {
70
if
(
$proc
===
'quickpick'
) {
71
// quickpick handles its own headers and needs session started carefully
72
if
(session_status() === PHP_SESSION_NONE) {
73
@session_start();
74
}
75
}
76
77
if
(!
Csrf::validateRequest
()) {
78
http_response_code(403);
79
header(
'Content-Type: application/json'
);
80
echo json_encode([
81
'error'
=>
'CSRF validation failed'
,
82
'message'
=>
'Invalid or expired security token. Please refresh the page and try again.'
83
]);
84
exit
;
85
}
86
}
87
93
if
(isset(
$procMap
[
$proc
]) && file_exists(
$procMap
[
$proc
])) {
97
include
$procMap
[
$proc
];
98
}
else
{
104
$errorMessage =
'Invalid proc parameter'
;
105
if
(!empty(
$proc
)) {
106
$errorMessage .=
': "'
. htmlspecialchars(
$proc
) .
'" is not a valid procedure'
;
107
}
else
{
108
$errorMessage .=
': no procedure was specified'
;
109
}
110
echo json_encode([
'error'
=> $errorMessage]);
111
}
exit
exit
Definition
ajax.apply.moduleconfig.php:63
$csrfProtectedEndpoints
$csrfProtectedEndpoints
Definition
ajax.php:53
$procMap
$procMap
Definition
ajax.php:21
$proc
$proc
Definition
ajax.php:46
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