Location: PHPKode > scripts > PHP Link Directory Script > linkdirectory/www/quickbrowse.php
<?php
/* PHP Link Directory Copyright 2011 Robert Rook */
require('dblogon.php');
require('userhead.php');
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>

<title>Category Browser</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="AdvanceByDesign">

<script type="text/Javascript" language="Javascript">
<!--
function send_category_to_opener(catid, ctitle, cpath) {
	if(window.opener) {
		if(typeof window.opener.change_category=='function' ||
			typeof window.opener.change_category=='object') {
			window.opener.change_category(catid, ctitle, cpath);
			window.close();
		}
	}
	return;
}
//-->
</script>
<style type="text/css">
body {
	padding:5px;
	margin:0;
	background-color:#FFF;
	font-size:0.8em;
	font-family:Arial,Helvetica,sans-serif;
	color:#000;
}
.yeslinks {
	font-style:italic;
	color:#0B0;
}
.nolinks {
	color:#B90;
}
</style>

</head>
<body>

<?php
if(isset($_GET['c']) && is_numeric($_GET['c'])) {
	$res = mysql_query("SELECT ctitle, catid, cpath, cdesc, acceptlinks FROM {$prefix}cat WHERE catid='{$_GET['c']}'", $db);
	if(mysql_num_rows($res)) { $c = mysql_fetch_array($res); }
}
if(!isset($c)) {
	$c = array("ctitle"=>"Home", "cdesc"=>"Root category", "catid"=>0, "cpath"=>"", "acceptlinks"=>0);
}

$qbmode = (isset($_GET['mode'])?"&mode={$_GET['mode']}":"");

$c['cdesc'] = substr($c['cdesc'], 0, 100);
$breadcrumbs = array();
$htmcpath = array();
if(strlen($c['cpath'])) {
	$c['cpath'] = explode("&&", $c['cpath']);
	foreach($c['cpath'] as $value) {
		if(strlen($value)<4) { continue; }
		$value = explode("&:", $value);
		
		array_push($breadcrumbs, "<a href=\"quickbrowse.php?c={$value[0]}{$qbmode}\">{$value[1]}</a>");
		array_push($htmcpath, $value[1]);
	}
}
$breadcrumbs = implode(" :: ", $breadcrumbs);
$htmcpath = implode(" / ", $htmcpath);

$htmlinks = ($c['acceptlinks']?"[ <span class=\"yeslinks\">This category accepts links</span> ]":
	"[ <span class=\"nolinks\">Links are not accepted in this category</span> ]");
if(isset($_GET['mode']) && $_GET['mode']=="useany") {
	$htmlinks = "";
	$htmaddlink = "<input type=\"button\" value=\"Use Category\" onclick='Javascript:send_category_to_opener({$c['catid']}, \"{$c['ctitle']}\", \"{$htmcpath}\");'>";
} else if($c['catid']>0) {
	$htmaddlink = "<input type=\"button\" value=\"Use Category\" onclick='Javascript:send_category_to_opener({$c['catid']}, \"{$c['ctitle']}\", \"{$htmcpath}\");'>";
} else {
	$htmaddlink = "";
}

echo <<<ENDHTML
	<h1>{$c['ctitle']}</h1>
	{$breadcrumbs}
	<p>{$c['cdesc']}... {$htmlinks}</p>
	{$htmaddlink}
ENDHTML;

$res = mysql_query("SELECT ctitle, catid FROM {$prefix}cat WHERE cparent='{$c['catid']}' ORDER BY ctitle ASC", $db);
if(mysql_num_rows($res)) {
	echo "<ul>";
	while($row = mysql_fetch_array($res)) {
		echo "<li><a href=\"quickbrowse.php?c={$row['catid']}{$qbmode}\">{$row['ctitle']}</a></li>\n";
	}
	echo "</ul>\n";
}
?>

</body>
</html>
Return current item: PHP Link Directory Script