$f = $_GET['filter'];
if (strpos($f,':')!==false){ list($k,$v)=explode(':',$f,2); $k = trim($k); $v = trim($v); if(in_array($k,$allowed)) { $where[] = "$k LIKE :f_$k"; $params['f_'.$k] = '%'.$v.'%'; } }
}
foreach($allowed as $k){ if(isset($_GET[$k]) && $_GET[$k] !== ''){ $where[] = "$k LIKE :$k"; $params[$k] = '%'.$_GET[$k].'%'; } }
$sql = 'SELECT id,titre,poster,categorie,sous_categorie,tag,motcle,description,date_creation,note,duree,acteurs FROM xbvcn_video';
if ($where) $sql .= ' WHERE ' . implode(' AND ', $where);
$sql .= ' ORDER BY date_creation DESC, id DESC LIMIT 500';
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
}catch(Exception $e){ $rows = []; }
// derive quick counts for initial display
$categories = []; $subcats = []; $tags = [];
foreach($rows as $r){ if(!empty($r['categorie'])) $categories[$r['categorie']] = ($categories[$r['categorie']] ?? 0) + 1; if(!empty($r['sous_categorie'])) $subcats[$r['sous_categorie']] = ($subcats[$r['sous_categorie']] ?? 0) + 1; $raw = trim(($r['tag']??'').','.($r['motcle']??'')); if($raw!=='') foreach(preg_split('/[,;]+/',$raw) as $p){ $p=trim($p); if($p!=='') $tags[$p]=($tags[$p]??0)+1; } }
arsort($categories); arsort($subcats); arsort($tags);
?>
Kitstream - Catalogue
Catalogue