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

//=====================================
// LINKER Category Engine
//=====================================
// Filename : view_category.php
// Path  : Manage directory
// last update : 2002/03/13
// Desc : View Category
//=====================================


//=====================================
// File include part & DB Layer
//=====================================

include ("./authen.php");
include ("../function/$Sdb_type.php"); 
include ("../function/main_func.php"); 
include ("../$Slang/m_common.php"); 

$db = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);
$db1 = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);

//=====================================
// Print search form parts
//=====================================


if (!$switch) {

$view_category = view_category("sid");

print <<<EOF
<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
</head>
<body bgcolor="#E9E9E9">

<form action='view_category.php' method='post'>
<input type='hidden' name='switch' value='search'>

<table border=0 cellpadding=0 cellspacing=1>
<tr>
<td colspan=2>

	<table width="100%" border="1"><tr><td bgcolor="#000066" align="center">
	<b><font color="white" size="2">$l_search_item_input</font></b>
	</td></tr></table>

</td>	</tr>

<tr><td colspan=2>&nbsp;</td>	</tr>

<tr>
<td bgcolor='#E0E0E0' colspan=2 height=24 align=center width=500>
<font size='2'>&nbsp; $l_search_cat_head </font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'>&nbsp;<font  size='2'>$l_sid</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<input type='text' name='sid' size=30></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'>&nbsp;<font  size='2'>$l_title</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<input type='text' name='title' size=30></td>
</tr>

<tr>
<td width='100'  bgcolor='#F6F6F6'>&nbsp;<font  size='2'>$l_sub_desc</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<input type='text' name='descript' size=30></td>
</tr>

<tr>
<td width='100'  bgcolor='#F6F6F6'>&nbsp;<font  size='2'>$l_cat</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size=2><select name='parent'>
<option value="">$l_cat</option>
$view_category
</select></font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'>&nbsp;<font  size='2'>$l_search_type</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size=2><select name='view_type'>
<option>or</option>
<option>and</option>
</select></font></td>
</tr>

<tr><td bgcolor="#E0E0E0" colspan=2 height=23>

	<table border=0 cellpadding=0 cellspacing=0 width=100%><tr>
	<td align=right><font size='2'><input type='submit' value='$l_view_select' class=cinput>
	<input type='hidden' name='type' value='$type'>&nbsp;</font></td>	

	</form><form action='view_category.php' method='post'>
	<input type='hidden' name='switch' value='search'>

	<td bgcolor="#E0E0E0"><font size='2'><input type='submit' value='$l_view_all' class=cinput></font>
	<input type='hidden' name='type' value='$type'></td></form></tr>
	</table>

</table><br>

EOF;
exit;
  }

//=====================================
// Print Search result parts
//=====================================
 
// make query
if (!$title && !$descript && $parent=="" && $sid=="" && $view_type ) errmsg($l_error_nofield);
$where = (!$title && !$descript && $parent=="" && $sid=="" && !$view_type) ? "" : "where";

if ($sid != "") $sear_where = "sid='$sid' ";

if ($title){ 
	if ($sear_where)  $sear_where .= "$view_type ";		
	$sear_where.= "title like '%$title%' ";  
}

if ($cont) {
	if ($sear_where) $sear_where .="$view_type ";
	$sear_where .= "descript like '%$cont%' ";
}

if ($parent != "") {
	if ($sear_where) $sear_where .="$view_type ";
	$sear_where.="sid  = '{$parent}'"; 
}

$db->query("select count(*) as total from LINKER_CAT $where  $sear_where");
$allrow = $db->nrecord();
$total = $allrow[total];
$page_num = ceil($total / $Spagecut); // total page num

$page = ($page) ? $page : 0;
$vstart = $Spagecut * $page;
$vend = $Spagecut;

$db->query("select * from LINKER_CAT $where  $sear_where  order by pathtxt limit $vstart,$vend") ;
$link_total = $db->numrow;

//=====================================
// Make Directbar button
//=====================================

$directbar_cut = 10;
$page_start = floor($page/$directbar_cut) * $directbar_cut ; 
$page_end=$page_start+$directbar_cut; 

for ($p=$page_start ; $p<$page_end  ; $p++ ) 
{	
	$view=$p+1;
	if ($p<$page_num) 
	{
		if ($page==$p) 	$direct_bar.="<b>$view</b>&nbsp;";
		else 	$direct_bar.="<a href='view_category.php?page=$p&switch=$switch&title=$title&descript=$descript&parent=$parent&sid=$sid&view_type=$view_type&type=$type'>$view</a>&nbsp;";

	}
}

if ($total>$vstart+$Spagecut) 
{ 
$next_p=$page+1;
$next_list="<a href='view_category.php?page=$next_p&switch=$switch&title=$title&descript=$descript&parent=$parent&sid=$sid&view_type=$view_type&type=$type'>>></a>";
}


if ($page>0) 
{
$prev_p=$page-1;
$prev_list="<a href='view_category.php?page=$prev_p&switch=$switch&title=$title&descript=$descript&parent=$parent&sid=$sid&view_type=$view_type&type=$type'><<</a>&nbsp;";
}

//=====================================
// Del / Edit /Move
//=====================================

if($type=='delete') {
$form_txt = "<form action='./del_category.php' method='post' name='myform'>";
$delup_form="
<input type='button' onClick='javascript:selectall()' value='$l_select_all' class=cinput>
<input type='button' onClick='javascript:selectnone()' value='$l_select_none' class=cinput>
<input type='submit' value=' $l_del ' class=cinput>";
}

elseif($type=='update') {
$form_txt = "<form action='./edit_category.php' method='post'>";
$delup_form="
<input type='submit' value=' $l_edit ' class=cinput>";
}

elseif($type=='move') {
$form_txt = "<form action='./move_category.php' method='post'>";
$delup_form="
<input type='submit' value=' $l_move ' class=cinput>";
}

//=====================================
// Print other
//=====================================

print <<<EOF

<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
<SCRIPT LANGUAGE="JavaScript">
<!--
function selectall()
{
	 
	for( var i=0; i<document.myform.elements.length; i++) {
		var ele = document.myform.elements[i];
		if(ele.type == 'checkbox')
			{ele.checked = true;}
	}
	return;

}

function selectnone()
{
	 
	for( var i=0; i<document.myform.elements.length; i++) {
		var ele = document.myform.elements[i];
		if(ele.type == 'checkbox')
			{ele.checked = false;}
	}
	return;

}

//-->
</SCRIPT>

</head>
<body bgcolor="#E9E9E9">
$form_txt
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td colspan=2>

	<table width="100%" border="1"><tr><td bgcolor="#000066" align="center">
	<b><font color="white" size="2">$total $l_search_result</font></b>
	</td></tr></table>

</td>	</tr>

<tr><td colspan=2>&nbsp;</td>	</tr>

<tr>
<td  bgcolor='#E0E0E0' width='250' height='24'>&nbsp;<font size='2'>$prev_list  $direct_bar &nbsp;$next_list </font></td>
<td  bgcolor='#E0E0E0' width='250' align='right'>&nbsp; $delup_form</td>
</tr></table><br>
EOF;


for ($v=$start; $v< $link_total ;$v++) {

if ($db->numrow >0 ) $row = $db->nrecord();
while(list($key , $val) = each ($row))
$row[$key] =  htmlspecialchars(stripslashes($val));

$row[pathtxt] = str_replace($Ssepchar, $Sarrow, $row[pathtxt]);

// relate
if ($row[relate]>0) {

$db1->query("select pathtxt from LINKER_CAT where sid='$row[relate]'");
$rrow = $db1->nrecord();
$relate_path = str_replace($Ssepchar,$Sarrow, $rrow[pathtxt]);
}
else 
$relate_path = "$l_relate_no";

switch ($row[c_sub]) 
{
    case 1: $c_sub = $l_sub_desc; break;
    case 2: $c_sub = $l_sub_cat; break;
    default: $c_sub = $l_sub_no;
}

$lasttime = date("Y/m/d  H:i:s",$row[lasttime]);
$uptime = date("Y/m/d  H:i:s",$row[uptime]);


//=====================================
// Make Delete Edit button
//=====================================

switch ($type) 
{
    case "delete": $del="<input type='checkbox' name='$row[sid]' value='delete'> <font size='2'>$l_del</font>"; break;
    case "update": $del="<input type='radio' name='update' value='$row[sid]'> <font size='2'>$l_edit</font>"; break;
    case "move": $del="<input type='radio' name='move' value='$row[sid]'> <font size='2'>$l_move</font>"; break;
    default: $del = "";
}


//=====================================
// Print other
//=====================================

  print <<<EOF
<table border='0' width='500' cellpadding=0 cellspacing=1>

<tr><td colspan=2 height=2 bgcolor="#999999"><img src="../image/x1.gif"></td></tr>

<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_sid</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$row[sid]</font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_title</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$row[title]</font></td>
</tr>

<tr>
<td width='100'  bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_sub_desc</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$row[descript]</font></td>
</tr>

<tr>
<td width='100'  bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_parent</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$row[parent]</font></td>
</tr>

<tr>
<td width='100'  bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_pparent</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$row[pparent]</font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_sub_type</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$c_sub</font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_cat</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$row[pathtxt]</font></td>
</tr>
<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_relate_cat</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$relate_path</font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_meta</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$row[meta_key]</font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_head</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$row[header]</font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_foot</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$row[footer]</font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_count</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$row[count]</font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_uptime</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$uptime</font></td>
</tr>

<tr>
<td width='120' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_lastuptime</font></td>
<td width="380" height='24' bgcolor="white">&nbsp;<font size='2'>$lasttime</font></td>
</tr>

<tr><td colspan=2 height=2 bgcolor="#999999"><img src="../image/x1.gif"></td></tr>

<tr><td colspan='2' bgcolor='#E0E0E0'>$del</td><tr>
</table><br>
EOF;

} // end for

//=====================================
// Print Direct bar
//=====================================

echo "
<table border='0'  width='500' cellpadding='0' cellspacing='0'>
<tr>
<td  bgcolor='#E0E0E0' width='250' height='24'>&nbsp;<font size='2'>$prev_list  $direct_bar &nbsp;$next_list </font></td>
<td  bgcolor='#E0E0E0' width='250' align='right'>&nbsp; $delup_form</td>
</tr></table>
</form>
<br><br>";

?>
Return current item: Linker IMG