-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlpk-api.php
More file actions
54 lines (47 loc) · 1.34 KB
/
lpk-api.php
File metadata and controls
54 lines (47 loc) · 1.34 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
46
47
48
49
50
51
52
53
54
<?php namespace ProcessWire;
/*
* Copyright (c) 2025.
* Clip Magic - Prue Rowland
* Web: www.clipmagic.com.au
* Email: admin@clipmagic.com.au
* Licensed under MIT, see LICENSE.TXT
*
* ProcessWire 3.x
* Copyright (C) 2014 by R
* Licensed under GNU/GPL
*
* https://processwire.com
*/
$lpkMaxRequestBodyBytes = 65536;
if(!headers_sent()) {
header('Content-Type: application/json; charset=utf-8');
header('X-Content-Type-Options: nosniff');
header('Cache-Control: no-store');
header('Referrer-Policy: no-referrer');
}
if((int) ($_SERVER['CONTENT_LENGTH'] ?? 0) > $lpkMaxRequestBodyBytes) {
http_response_code(413);
return \json_encode([
'end' => true,
'msg' => 'Request body too large',
'errno' => 413,
'next' => 'end',
]);
}
$rawPost = file_get_contents('php://input', false, null, 0, $lpkMaxRequestBodyBytes + 1);
$rawPost = $rawPost === false ? '' : $rawPost;
if(strlen($rawPost) > $lpkMaxRequestBodyBytes) {
http_response_code(413);
return \json_encode([
'end' => true,
'msg' => 'Request body too large',
'errno' => 413,
'next' => 'end',
]);
}
$post = trim($rawPost);
if ($post) {
$data = \json_decode($post, null, 512, 0);
$lpk = $modules->get('LoginPassKey');
return \json_encode($lpk->handleApiStep($data, $input->urlSegment(1)));
}