function parse_menu($file_name) { global $contents_dir; // print_msg("parse_menu($file_name)"); $fin = fopen($file_name, "r"); if (!$fin) { echo "Unable to open '{$file_name}' in parse_menu({$file_name})<br />"; return; } echo "Opened '{$file_name}' in parse_menu({$file_name})<br />"; // Parse menu' specifications $count = 0; while (!feof($fin)) { $line = fgets($fin); if (feof($fin)) { break; } $line = trim($line); if (strlen($line) == 0) { continue; } if ($line[0] == '#') { continue; } $articles[$count] = $line; $count++; } echo "Menu {$file_name} contains {$count} voices.<br>"; fclose($fin); // print_msg("Found ".count($articles)." articles"); // print_msg("Extracting info:"); // Extracts info from files or menu' specifications foreach ($articles as $article) { // echo "<b>'".htmlspecialchars($article)."'</b><br />"; if ($article[0] == ">") { // these are not translated from php to html $article = substr($article, 1); list($link, $title, $description) = explode(">", $article); $link = trim($link); $description = trim($description); $title = trim($title); htmlspecialchars($article); // echo "'$link' : '$title' : '$description'<br />"; $headerinfo["description"] = $description; $headerinfo["title"] = $title; if (isset($headers[$link])) { echo "<h2>ERROR: The article '{$link}' is already present.</h2>"; return; } $headers[$link] = $headerinfo; } else { if ($article[0] == "\$") { // simply skip $ $link = "<!--\$-->" . trim(substr($article, 1)); $headerinfo["description"] = "[HTML LONG]"; $headerinfo["title"] = "[HTML LONG]"; if (isset($headers[$link])) { die("Double [HTML LONG]!"); } $headers[$link] = $headerinfo; } else { if ($article[0] == "&") { // simply skip $ $link = "<!--&-->" . trim(substr($article, 1)); $headerinfo["description"] = "[HTML SHORT]"; $headerinfo["title"] = "[HTML SHORT]"; if (isset($headers[$link])) { die("Double [HTML SHORT]!"); } $headers[$link] = $headerinfo; } else { $headerinfo = extract_header_info("{$contents_dir}/" . $article); if (!isset($headerinfo)) { echo "<h2>ERROR EXTRACTING HEADERS FOR '{$article}' </h2>"; return false; } // print_header_info( $headerinfo ); if (isset($headers[$article])) { echo "<h2>ERROR: The article '{$article}' is already present.</h2>"; return; } $headers[$article] = $headerinfo; } } } } return $headers; }
<?php require "config.php"; require "core.php"; global $base_website_address; global $content_file; $content_file = isset($_GET['data']) ? $_GET['data'] : "index"; $content_file = strtolower($content_file); $content_path = "contents/" . $content_file . ".php"; // contents/discografia-canzoni/spartiti-chitarra-testi-accordi-timoria.php // Check existence if (file_exists($content_path) == false) { header("HTTP/1.0 404 Not Found"); echo "{$content_path}<br>"; $content_path = "errors/404.php"; } $header = extract_header_info($content_path); $template_directory = "template/" . (isset($header['template']) ? $header['template'] : "default");