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

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


//=====================================
// 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
//=====================================


if (!$switch) {

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_coment.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_com_head </font></td>
</tr>

<tr>
<td width='100' bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_sid</font></td>
<td height='24' bgcolor='#F6F6F6'>&nbsp;<input type='text' name='sid' size='15'></td>
</tr>

<tr>
<td width='100' bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_link_sid</font></td>
<td height='24' bgcolor='#F6F6F6'><font size='2'>&nbsp;<input type=text name='parent' size=25></font></td>
</tr>

<tr>
<td width='100' bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_name</font></td>
<td height='24' bgcolor='#F6F6F6'>&nbsp;<input type='text' name='name' size='25'></td>
</tr>

<tr>
<td width='100' bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_content</font></td>
<td height='24' bgcolor='#F6F6F6'>&nbsp;<input type='text' name='content' size='25'></td>
</tr>

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

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

	<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'></font>&nbsp;</td>	

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

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

</td></tr></table>


EOF;
exit();

}

//=====================================
// View comment parts
//=====================================

while (list($key,$val) = each($HTTP_POST_VARS)) 
$$key = trim($val);

if ($sid || $parent  || $name || $email || $home || $content) $where="where ";
if (!$sid && !$parent  && !$name && !$email && !$home && !$content && $view_type) errmsg($l_error_nofield);
	
if ($sid) {   if ($cque) $cque.="$view_type "; $cque.="sid = $sid ";}
if ($parent) {  if ($cque) $cque.="$view_type "; $cque.="parent = '$parent' ";}
if ($name) { if ($cque) $cque.="$view_type "; $cque.="name like '%$name%' ";} 
if ($content) { if ($cque) $cque.="$view_type "; $cque.="content like '%$content%' ";} 

$db->query("select count(*) as total from LINKER_COM $where $cque");

$allrow = $db->nrecord();
$total = $allrow[total];
$page_num = ceil($total / $Spagecut);

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

$db->query("select * from LINKER_COM $where $cque order by uptime desc limit $vstart,$vend") ;
$link_total = $db->numrow;

//=====================================
// Make Direct bar
//=====================================

$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.="<font size='2'><b>$view</b></font> ";
		else 	$direct_bar.="<font size='2'><a href='view_coment.php?page=$p&switch=$switch&view_type=$view_type&type=$type&sid=$sid&parent=$parent&name=$name&content=$content'>$view</a> </font>";

	}
}

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


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

//=====================================
// Delete / Edit
//=====================================

if($type=='delete') {

$form_txt = "<form action='./del_coment.php' method='post' name='myform'>";
$add_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_coment.php' method='post'>";
$add_form = "
<input type='submit' value='$l_edit' class=cinput>
";
}


//=====================================
// Print search result
//=====================================

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_com</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; $add_form</td>
</tr></table><br>

 </td></tr>

EOF;


//=====================================
// Make data and get upper link title
//=====================================

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

while(list($key , $val) = each ($row))
$row[$key] =  htmlspecial(stripslashes($val));

$row[pathtxt] = str_replace($Ssepchar, " >> ", $row[pathtxt]);
$time = date("Y/m/d H:i:s",$row[uptime]);

$db1->query("select title,pathtxt from LINKER_LINK where sid='$row[parent]'");
$rrow = $db1->nrecord();
$ptitle = $rrow[title];
$ppathtxt = str_replace($Ssepchar, $Sarrow,stripslashes($rrow[pathtxt]));
//=====================================
// Make Edit / del box
//=====================================

if($type=='delete') 
$type_func="<input type='checkbox' name='$row[sid]' value='delete'> <font size='2'>$l_del</font>";

elseif ($type=='update')
$type_func="<input type='radio' name='update' value='$row[sid]'> <font size='2'>$l_edit</font>";

//=====================================
// 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='100' height='24'  bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_sid</font></td>
<td width="400" bgcolor='#FFFFFF' height='24'><font size='2'>&nbsp;$row[sid]</font></td>
</tr>

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

<tr>
<td width='100' height='24'  bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_link_title</font></td>
<td bgcolor='#FFFFFF' height='24'><font size='2'>&nbsp;$ptitle</font></td>
</tr>

<tr>
<td width='100' height='24'  bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_here</font></td>
<td bgcolor='#FFFFFF' height='24'><font size='2'>&nbsp;$ppathtxt</font></td>
</tr>

<tr>
<td width='100' height='24'  bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_name</font></td>
<td bgcolor='#FFFFFF' height='24'><font size='2'>&nbsp;$row[name]</font></td>
</tr>

<tr>
<td width='100' height='24'  bgcolor='#F6F6F6'><font size='2'>&nbsp;I.P</font></td>
<td bgcolor='#FFFFFF' height='24'><font size='2'>&nbsp;$row[ipaddr]</font></td>
</tr>

<tr>
<td width='100' height='24'  bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_vote</font></td>
<td bgcolor='#FFFFFF' height='24'><font size='2'>&nbsp;$row[vote]</font></td>
</tr>

<tr>
<td width='100' height='24'  bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_uptime</font></td>
<td bgcolor='#FFFFFF' height='24'><font size='2'>&nbsp;$time</font></td>
</tr>

<tr>
<td width='100' height='24'  bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_content</font></td>
<td bgcolor='#FFFFFF' height='24'><font size='2'>&nbsp;$row[content]</font></td>
</tr>

<tr><td colspan='2' bgcolor="E0E0E0">$type_func</td></tr>

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

} //for



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

print <<<EOF
<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; $add_form</td>
</tr></table>
</form><br><br><br>

EOF;

?>
Return current item: Linker IMG