require("./mysql.php3");
$db = new MySQL;
if(!$db->init()) {
echo "Unable to initialize database!
\n";
exit;
}
function breadcrumbs($CatID="")
{
global $db;
global $PHP_SELF;
if(empty($CatID)) { return; }
$db->get_ParentsInt($CatID);
$path = $db->TRAIL;
if(!empty($path))
{
while ( list ( $key,$val ) = each ($path))
{
$CatID = stripslashes($val["CatID"]);
$CatName = stripslashes($val["CatName"]);
$trail = "|$CatName$trail";
}
} else {
$trail = "";
}
return $trail;
}
function start_page($CatID="",$title="",$msg="")
{
global $PHP_SELF;
print "\n";
print "
Wireless HOO - $title\n";
print "\n";
print "\nWireless H O O
\n";
if(!empty($msg))
{
print "\n$msg\n";
}
print "";
print "\nTop\n";
$trail = breadcrumbs($CatID);
print "$trail
\n";
return;
}
function start_browse($CatID = "")
{
global $PHP_SELF;
global $db;
$data = $db->get_Cats($CatID);
$links = $db->get_Links($CatID);
if(!empty($CatID))
{
$currentID = $CatID;
$currentName = $db->get_CatNames($CatID);
} else {
$currentID = "top";
$currentName = "top";
}
if(!empty($data))
{
$count = 0;
print "\n";
// print "\n";
while ( list ( $key,$val ) = each ($data))
{
$CatID = stripslashes($val["CatID"]);
$CatName = stripslashes($val["CatName"]);
print "- $CatName
\n";
$count++;
if ($count && ($count % 4) == 0) {
if ($count && ($count % 8) == 0) {
print " |
| \n";
}
else {
print " | ";
}
}
}
// print "\n";
print " |
\n";
}
if(!empty($links))
{
print "\n";
while ( list ( $key,$val ) = each ($links))
{
$Url = stripslashes($val["Url"]);
$LinkName = stripslashes($val["LinkName"]);
$Desc = stripslashes($val["Description"]);
print "- $LinkName - $Desc
\n";
}
print "
\n";
}
print "
\n";
print "Suggest new link
\n";
// print "
Wireless Hoo is based on PhpHoo
\n";
print "\n";
return;
}
// *****************************************************************
$query = getenv("QUERY_STRING");
if( ($viewCat) or ( (!$HTTP_POST_VARS) and (!$query) ) )
{
start_page($viewCat);
start_browse($viewCat);
exit;
} elseif($add)
{
if("$add" == "top") { $add = 0; }
$CatName = stripslashes($db->get_CatNames($add));
if(empty($CatName)) { $CatName = "Top"; }
//
print "
Wireless Hoo - Add a Resource
 GATEWAY To The... Online Vietnamese Community
|  |
Wireless Hoo
Add a Resource to: $CatName
\n";
} elseif ($suggest)
{
$junk = "";
if(!$db->suggest($HTTP_POST_VARS))
{
$title = "Suggestion Error";
$msg = "Suggestion failed! Required data missing, invalid, or you duplicated an existing entry.\n";
} else {
$title = "Suggestion Submitted";
$msg = "Suggestion submitted for approval\n";
}
start_page($junk,$title,$msg);
start_browse();
exit;
} elseif ($KeyWords)
{
//start_page();
$hits = $db->search($KeyWords);
if( (!$hits) or (empty($hits)) )
{
$junk = "";
$title = "Search Results";
$msg = "No Matches";
start_page($junk,$title,$msg);
} else {
$total = count($hits);
$title = "Search Results";
$msg = "Search returned [$total] matches";
$junk = "";
start_page($junk,$title,$msg);
while ( list ($key,$hit) = each ($hits))
{
if(!empty($hit))
{
$LinkID = $hit["LinkID"];
$LinkName = stripslashes($hit["LinkName"]);
$LinkDesc = stripslashes($hit["Description"]);
$LinkURL = stripslashes($hit["Url"]);
$CatID = $hit["CatID"];
$CatName = stripslashes($db->get_CatNames($CatID));
print "\n";
print "- $LinkName\n";
print "
- $LinkDesc\n";
print "
- Found In: $CatName\n";
print "
\n";
}
}
}
print "
\n";
start_browse();
exit;
} else {
// Something terribly bad happened - start fresh
start_page();
start_browse();
exit;
}
?>