{source 0}".$arr['full'].""; } elseif ($t < 2) { //echo "
  • Неверный раздел
  • "; } else { echo "
      ".$arr['full'].""; foreach ($arr as $key => $val) { if (($key!='link')||($key!='full')) {parse_arr($val);} } echo "
    "; } } function parse_xml($filemap) { $db =& JFactory::getDBO(); if (!$db->connected()) { echo "Нет соединения с сервером баз данных"; jexit(); } else { libxml_use_internal_errors(true); $xml = simplexml_load_file('./'.$filemap); if (!$xml) { echo "Ошибка загрузки Карты сайта\t"; foreach(libxml_get_errors() as $error) { echo "\t", $error->message; } } else { foreach ($xml as $url) { $subs = substr($url->loc,8); $expl = explode('/',$subs); $count = count($expl); if ($expl[1] == '') { $pos = 'root'; $name = $expl[0]; $link = 'https://'.$expl[0]; $arr[1][$pos][$name] = [ 'link'=>$link, 'full'=>'Главная', ]; } else { $pages = explode('.',$expl[$count-1]); $pos = $expl[$count - 2]; $link = 'https://'.$subs; $name = $pages[0]; $db->setQuery("(SELECT title FROM #__menu WHERE alias='".$name."' ORDER BY id ASC LIMIT 1) UNION ALL (SELECT title FROM #__content WHERE alias='".$name."' ORDER BY id ASC LIMIT 1)"); $full = $db->loadResult(); $arr[$count][$pos][$name] = [ 'link'=>$link, 'full'=>$full, ]; } } for ($i=count($arr);$i>1;$i--) { foreach ($arr[$i-1] as $key => $row) { foreach ($row as $k => $v) { if (array_key_exists($k,$arr[$i])) {$arr[$i-1][$key][$k] = array_merge_recursive($row[$k],$arr[$i][$k]);} } } } $file = fopen('./site_map.json','w+'); fwrite($file, json_encode($arr[1]['root'],JSON_UNESCAPED_UNICODE)); fclose($file); echo "
    "; $json = file_get_contents('./site_map.json','r'); $arr = json_decode($json, true); foreach ($arr as $row) {parse_arr($row);} echo "
    "; } } } $filename = 'site_map.json'; $lvl = 0; if (!empty($_GET['newmap'])) { $newmap = $_GET['newmap'].'.xml'; if ((file_exists($newmap))&&($newmap != 'sitemap.xml')) { parse_xml($newmap); if (file_exists('sitemap.xml')) {rename($newmap,'sitemap.xml');} $lvl = 1; } } if ($lvl == 0) { if (file_exists($filename)) { echo "
    "; $json = file_get_contents('./'.$filename,'r'); $arr = json_decode($json, true); foreach ($arr as $row) {parse_arr($row);} echo "
    "; } else { if (file_exists('sitemap.xml')) { parse_xml('sitemap.xml'); } else { echo 'Нет карты сайта!'; } } } ?>{/source}