$cfgDir = '/var/www/html/content/news'; $cfgPrefix = 'nws'; $cfgLink = 'news'; $cfgTopSort = 'tardix'; $cfgSortMode = 'date'; $availableFlags = require '/var/www/html/core/lang/flags.php'; $siteLang = $lang ?? 'fr'; $activeLang = $_GET['db_lang'] ?? $siteLang; $allItems = []; $allTags = []; $existingLangs = []; if (is_dir($cfgDir)) { foreach (glob($cfgDir . '/*', GLOB_ONLYDIR) as $dir) { $folderLang = basename($dir); $existingLangs[] = $folderLang; if ($folderLang === $activeLang) { foreach (glob($dir . '/*.php') as $phpFile) { $filename = basename($phpFile); if (in_array($filename, ['main.php', 'index.php', 'template.php'])) continue; $linkName = basename($phpFile, '.php'); $fileContent = file_get_contents($phpFile); preg_match_all('/\$page_([a-z_]+)\s*=\s*[\'"](.*?)[\'"];/is', $fileContent, $matches); if (!empty($matches[1])) { $meta = ['lang' => $folderLang, 'link_href' => $linkName]; foreach ($matches[1] as $index => $key) { $meta[$key] = stripcslashes($matches[2][$index]); } if (!empty($meta['title'])) { if ($cfgHiddenEntreprise !== '') { $itemEnt = isset($meta['entreprise']) ? strtolower(trim($meta['entreprise'])) : ''; if ($itemEnt !== strtolower($cfgHiddenEntreprise)) { continue; } } if (!empty($meta['tags'])) { $tagsArray = explode(' ', $meta['tags']); foreach ($tagsArray as $tag) { $cleanTag = trim($tag); if ($cleanTag !== '') $allTags[] = $cleanTag; } } $allItems[] = $meta; } } } } } } $allItems = array_merge($allItems, $rows); } catch (PDOException $e) { } } foreach (glob($dir . '/*.php') as $phpFile) { $filename = basename($phpFile); if ($filename === 'main.php' || $filename === 'index.php') continue; $linkName = basename($phpFile, '.php'); $content = file_get_contents($phpFile); preg_match_all('/\$page_([a-z_]+)\s*=\s*[\'"](.*?)[\'"];/is', $content, $matches); if (!empty($matches[1])) { $meta = ['lang' => $folderLang, 'link_href' => $linkName]; foreach ($matches[1] as $index => $key) { $meta[$key] = $matches[2][$index]; } if (!empty($meta['title'])) { if (!empty($meta['tags'])) { $tagsArray = explode(' ', $meta['tags']); foreach ($tagsArray as $tag) { $cleanTag = trim($tag); if ($cleanTag !== '') $allTags[] = $cleanTag; } } $allItems[] = $meta; } } } } } } $uniqueTags = array_unique($allTags); sort($uniqueTags); if ($cfgSortMode === 'random') { shuffle($allItems); } usort($allItems, function($a, $b) use ($activeLang, $cfgTopSort, $cfgSortMode) { if ($a['lang'] === $activeLang && $b['lang'] !== $activeLang) return -1; if ($a['lang'] !== $activeLang && $b['lang'] === $activeLang) return 1; $aTop = (strpos($a['section_id'] ?? '', $cfgTopSort) === 0) ? 0 : 1; $bTop = (strpos($b['section_id'] ?? '', $cfgTopSort) === 0) ? 0 : 1; if ($aTop !== $bTop) return $aTop - $bTop; if ($cfgSortMode === 'date') { $dateA = strtotime($a['date'] ?? '1970-01-01'); $dateB = strtotime($b['date'] ?? '1970-01-01'); return $dateB <=> $dateA; } if ($cfgSortMode === 'alpha') { return strcmp($a['title'] ?? '', $b['title'] ?? ''); } return 0; }); $imgBase = isset($img) ? $img : ''; ?>

Ultime notizie

Nessun dato disponibile per questa selezione.