( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
require_once __DIR__ . '/dashboard/config.php';
$folderId = 7;
$currentUserId = $userid; // From config.php
echo "Current User ID: $currentUserId\n";
echo "Checking access for Folder ID: $folderId\n";
// Access check logic from brandDetails.php
$allowed = false;
$foldersOwnerCol = teams_find_owner_column($conn, 'brand_teams_folders');
echo "Owner Column: " . ($foldersOwnerCol ? $foldersOwnerCol : "None") . "\n";
if ($foldersOwnerCol) {
$stmt = $conn->prepare("SELECT * FROM brand_teams_folders WHERE id=? AND `$foldersOwnerCol`=? LIMIT 1");
if ($stmt) {
$stmt->bind_param('ii', $folderId, $currentUserId);
$stmt->execute();
$res = $stmt->get_result();
if ($res && $res->num_rows) {
$allowed = true;
echo "Access allowed via ownership.\n";
$row = $res->fetch_assoc();
print_r($row);
} else {
echo "Not owner.\n";
}
$stmt->close();
}
}
if (!$allowed) {
$stmt = $conn->prepare("SELECT * FROM brand_teams_folder_members WHERE folder_id=? AND user_id=? LIMIT 1");
if ($stmt) {
$stmt->bind_param('ii', $folderId, $currentUserId);
$stmt->execute();
$res = $stmt->get_result();
if ($res && $res->num_rows) {
$allowed = true;
echo "Access allowed via membership.\n";
$row = $res->fetch_assoc();
print_r($row);
} else {
echo "Not a member.\n";
}
$stmt->close();
}
}
if (!$allowed) {
echo "Access DENIED.\n";
} else {
echo "Access GRANTED.\n";
// Check content
echo "Fetching content...\n";
$stmt = $conn->prepare("SELECT f.id, f.file_path, f.title, f.url, f.kind, p.title AS p_title, p.poster AS p_poster
FROM brand_teams_folder_files f
LEFT JOIN profilepicture p ON p.id=f.file_path
WHERE f.folder_id=?
ORDER BY f.id DESC LIMIT 200");
if ($stmt) {
$stmt->bind_param('i', $folderId);
$stmt->execute();
$res = $stmt->get_result();
$count = 0;
while ($res && ($row = $res->fetch_assoc())) {
$count++;
echo "Item $count: ID={$row['id']}, Kind={$row['kind']}, URL={$row['url']}, P_Poster={$row['p_poster']}\n";
}
if ($count == 0) {
echo "No content found in brand_teams_folder_files for folder_id=$folderId.\n";
}
$stmt->close();
} else {
echo "Prepare failed: " . $conn->error . "\n";
}
}