Repository navigation
Expand file tree
/
Copy pathpatch_ajax.php
More file actions
45 lines (38 loc) · 1.62 KB
/
Copy pathpatch_ajax.php
File metadata and controls
45 lines (38 loc) · 1.62 KB
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
41
42
43
44
45
<?php
$files = [
"settings.php",
"user.config.php",
"user.role.add.php",
"sign-up.php",
"ledger.php"
];
foreach ($files as $file) {
if (!file_exists($file)) continue;
$content = file_get_contents($file);
// settings.php, user.config.php, sign-up.php uploadFile
$content = preg_replace("/var formData = new FormData\(\);/", "var formData = new FormData();\n formData.append('csrf_token', '<?=generate_csrf_token()?>');", $content);
// sign-up.php verifyUsername
$content = preg_replace("/data: { username: username }/", "data: { username: username, csrf_token: '<?=generate_csrf_token()?>' }", $content);
// user.role.add.php get_permissions
$content = preg_replace("/data: { role_id: role_id }/", "data: { role_id: role_id, csrf_token: '<?=generate_csrf_token()?>' }", $content);
// ledger.php get_ledger
$content = preg_replace("/data: { 'property': select2 }/", "data: { 'property': select2, csrf_token: '<?=generate_csrf_token()?>' }", $content);
// settings.php clearCache
if (strpos($file, 'settings.php') !== false) {
$content = str_replace(
" $.ajax({
url: 'ajax/clear.cache.php',
type: 'POST',
contentType: false,",
" var fd = new FormData();
fd.append('csrf_token', '<?=generate_csrf_token()?>');
$.ajax({
url: 'ajax/clear.cache.php',
type: 'POST',
data: fd,
contentType: false,"
, $content);
}
file_put_contents($file, $content);
}
echo "Done patching AJAX.\n";