Location: PHPKode > scripts > Linker IMG > linker-img/sitemap.php
<?php

//=====================================
// LINKER Category Engine
//=====================================
// Filename : sitemap.php
// Path  : Main directory
// last update : 2002/03/13
// Desc : View category tree
//=====================================

//=====================================
// Info File include
//=====================================

$time1 = microtime();
include ("./function/base_info.php");
include ("./function/main_func.php");
include ("./function/$Sdb_type.php");
include ("./function/template.php");
include ("./function/tree.php");

$lan_dir = $HTTP_COOKIE_VARS[cook_lan];
if ($lan_dir && file_exists("./$lan_dir/u_common.php")) 
include ("./$lan_dir/u_common.php"); 
else include ("./$Slang/u_common.php"); 

//=====================================
// DB_LAYER / TEMPLATE
//=====================================

$db = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);
$tpl = new Stemplate($Stemplate);
$tree = new Tree ("$Stemplate/tree");

if ($Streetype == "java") 
$tpl->define(array( theader	=>	 "tree_head_java.html" ));
else 
$tpl->define(array( theader	=>	 "tree_head_nomal.html" ));
$tpl->define(array( tfooter	=>	 "tree_footer.html" ));

$tpl->assign(array(
TEMPLATE	=> $Stemplate,
DOMAIN			=> $Sdomain,
CHARSET		=> $Scharset,
BGCOLOR		=> $Sbgcolor,
MWIDTH			=> $Smain_width,
ALIGN			=> $Salign,
PAGE_HEADER  => implode("",file("$Stemplate/header.html"))
));


//=====================================
// Print header
//=====================================

show_menu();
show_here("","","$l_cat $l_cat_tree");
show_search();

//===============================================
//  java tree
//===============================================


if ($Streetype == "java") 
{

$tpl->assign( array( 
L_CAT_TREE => $l_cat_tree,
L_EXT_TREE	=> $l_ext_tree,
L_CLO_TREE	=> $l_clo_tree
));
$tpl->parse("HMAIN","theader");
$tpl->simprint("HMAIN");

//=====================================
// View Tree part
//=====================================


// make tree
if ($opentree) 
$tree->set_startallopen (true);
$tree->set_frame ("_new");

$db->query("select sid,title,sub_cat,sub_link,path from LINKER_CAT order by pathtxt");

while ($row = $db->nrecord()) {

$row[title] = htmlspecialchars(stripslashes($row[title]));
$count++;
$non_parent_num = count(explode("/",$row[path]));

if ($non_parent_num == 1) {
$root = $tree->open_tree ("$row[title] ($row[sub_link]/$row[sub_cat])", "index.php?cat=$row[sid]"); 
continue;
}

elseif ($non_parent_num== 2) {
$old_node = $root;
}

else {
$old_key_temp = substr($row[path],0,-strlen(strrchr($row[path],"/"))); 
$old_node = $node_key[$old_key_temp];
}

$node_array[$count] =  $tree->add_folder ($old_node, "$row[title] ($row[sub_link]/$row[sub_cat])", "index.php?cat=$row[sid]");
$node_key[$row[path]] = $node_array[$count];
unset($old_node);


$path_node = $node_array[$count];
$old_key[$key] = $path_node;

}

$tree->close_tree ( );


} // end if java

//===============================================
//  nomal tree
//===============================================

else 
{

$tpl->dyn_define ( "tcol", "theader" );

$db->query("select sid,title,sub_cat,sub_link,path from LINKER_CAT order by pathtxt");

while ($row = $db->nrecord()) {

$blank_num = substr_count($row[path], "/");
$blank = str_repeat ("&nbsp;&nbsp;&nbsp;&nbsp;", $blank_num);

$tpl->assign(array (
BLANK	=> $blank,
CAT		=> $row[sid],
CATTITLE	=> "$row[title] ($row[sub_link]/$row[sub_cat])"
));
$tpl->parse("TROW",".tcol");
}

$tpl->parse("HMAIN","theader");
$tpl->simprint("HMAIN");

}

//=====================================
// End view Tree
//=====================================

$tpl->assign( array(
PAGE_FOOTER  => implode("",file("$Stemplate/footer.html"))
));

$tpl->parse("FMAIN","tfooter");
$tpl->simprint("FMAIN");

//====================================
// Establish Time
//====================================

if ($Stime == "Y") check_time($time1);

?>
Return current item: Linker IMG