forked from panicsteve/w2wiki
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapi.php
More file actions
25 lines (20 loc) · 696 Bytes
/
Copy pathapi.php
File metadata and controls
25 lines (20 loc) · 696 Bytes
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
<?php
define('W2APP', true);
require_once "config.php";
require_once "auth.php";
header('Content-Type: application/json');
if ( !isLoggedIn() )
{
http_response_code(403);
echo json_encode(array('error' => 'not logged in'));
exit;
}
$task = $_REQUEST['task'] ?? '';
if ($task == 'checkupload')
{
// only consider file names directly within the uploads folder
$filename = basename(str_replace('\\', '/', (string)($_REQUEST['filename'] ?? '')));
// hidden files (like .htaccess) are not uploads, and "." / ".." are folders
$isUpload = $filename !== '' && !str_starts_with($filename, '.');
echo json_encode($isUpload && file_exists(PAGES_PATH . "/". UPLOAD_FOLDER . "/" . $filename));
}