<?
if(!$_SESSION['ID_Glob']) exit();
ob_start();
echo "<?\n";

function get_tree_map_all($parent_id) {
      global $out;

	  $query = "SELECT * FROM catalog WHERE id_catalog > 0 AND parent_id = '".$parent_id."' ORDER BY num, id_catalog";
      $result = mysql_query($query);	
	  
      while ($rr = mysql_fetch_array($result)) 
	  	{
		echo '$arr_razdel['.$rr['parent_id'].']['.$rr['id_catalog'].']=\''.$rr['catalog'].'\';';
		echo "\n";
		echo '$arr_razdel_url['.$rr['parent_id'].']['.$rr['id_catalog'].']=\''.$rr['url'].'\';';
		echo "\n";
		get_tree_map_all($rr['id_catalog']);
      	}
      return $out;
} 
get_tree_map_all(0);
echo "?>";

$buf = ob_get_contents();
ob_end_clean();

file_put_contents("../cashe_catalog/_svod_catalog.php", $buf);
/*
$file1 = fopen ("../cashe_catalog/_svod_catalog.php", "w");
flock($file1, LOCK_EX);
fputs($file1, $buf);
fclose($file1);
*/
?>