function getMenuXml($site, $table, $j, $parent, $depth, $uid, $code) { global $g; static $j, $string; $xdepth = $depth + 1; $CD = getDbSelect($table, ($site ? 'site=' . $site . ' and ' : '') . 'depth=' . $xdepth . ' and parent=' . $parent . ' and hidden=0 order by gid asc', '*'); while ($C = db_fetch_array($CD)) { $j++; $code = $code . $C['id'] . '/'; $_code = substr($code, 0, strlen($code) - 1); if ($xdepth == 1) { $string .= "\t<!-- " . $C['name'] . "-->\n\t"; } else { for ($i = 0; $i < $xdepth; $i++) { $string .= "\t"; } } $string .= '<depth' . $xdepth . ' name="' . $C['name'] . '" ename="' . $C['id'] . '" link="' . RW('c=' . $_code) . '" target="' . $C['target']; if ($C['isson']) { $string .= '">' . "\n"; getMenuXml($site, $table, $j, $C['uid'], $C['depth'], $uid, $code); for ($i = 0; $i < $xdepth; $i++) { $string .= "\t"; } $string .= '</depth' . $xdepth . '>' . "\n"; } else { $string .= '" />' . "\n"; } if ($xdepth == 1) { $string .= "\n"; } $code = ''; } return $string; }
<?php if (!defined('__KIMS__')) { exit; } checkAdmin(0); include_once $g['path_core'] . 'function/menu.dump.func.php'; if ($type == 'xml') { $filename = 'menu_' . $_HS['id'] . '.xml'; $filepath = $g['path_var'] . 'xml/' . $filename; $fp = fopen($filepath, 'w'); fwrite($fp, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); fwrite($fp, "<menu>\n\n"); fwrite($fp, "\t<!-- " . $_HS['name'] . "-메뉴구조 -->\n"); fwrite($fp, getMenuXml($s, $table['s_menu'], 0, 0, 0, 0, '')); fwrite($fp, "</menu>\n"); fclose($fp); @chmod($filepath, 0707); $filesize = filesize($filepath); header("Content-Type: application/octet-stream"); header("Content-Length: " . $filesize); header('Content-Disposition: attachment; filename="' . $filename . '"'); header("Cache-Control: private, must-revalidate"); header("Pragma: no-cache"); header("Expires: 0"); $fp = fopen($filepath, 'rb'); if (!fpassthru($fp)) { fclose($fp); } exit; } else {