blob: 18de1193dabf883d3b69ff9d469fe4c2b62d5f36 (
plain)
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
|
<?php
// Minimal session check - no framework bootstrap
include 'auth_config.php';
if( !empty( $_SESSION['user_role'] ) && $_SESSION['user_role'] > 0 ) {
http_response_code(200);
exit;
}
// anonymous - check content_id from URI
preg_match( '|/attachments/\d+/(\d+)/|', $_SERVER['REQUEST_URI'], $matches );
if( !empty( $matches[1] ) ) {
$contentId = (int)$matches[1];
try {
$pdo = new PDO( $gBitDbHost, $gBitDbUser, $gBitDbPassword );
$stmt = $pdo->prepare(
"SELECT COUNT(*) FROM LIBERTY_CONTENT_ROLE_MAP
WHERE content_id = ?",
);
$stmt->execute( [$contentId] );
if( $stmt->fetchColumn() == 0 ) {
http_response_code( 200 );
} else {
http_response_code( 403 );
}
} catch( PDOException $e ) {
// db failure - deny access safely
http_response_code( 403 );
exit;
}
exit;
}
|