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

//=====================================
// LINKER Category Engine
//=====================================
// Filename : view_link.php
// Path  : Manage directory
// last update : 2002/07/13
// Desc : View Link
//=====================================


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

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

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

//=====================================
//  Ouput Search Form
//=====================================


if (!$switch) {

$view_category = view_category("sid",1);

print <<<EOF
<html>
<head>
<title></title>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
</head>
<body bgcolor="#E9E9E9" text='black' link='blue' vlink='purple' alink='red'>
<form action='view_link.php?switch=search&type=$type' method='post'>

<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_link_head </font></td>
</tr>

<tr>
<td width='100' height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_sid</font></td>
<td  bgcolor='#F6F6F6'><input type='text' size=25 name='sid' style="width:220px"></td>
</tr>

<tr>
<td width='100' height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_title</font></td>
<td  bgcolor='#F6F6F6'><input type='text' size=25 name='title' style="width:220px"></td>
</tr>

<tr>
<td width='100' height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_source</font></td>
<td  bgcolor='#F6F6F6'><input type='text' size=25 name='url' style="width:220px"></td>
</tr>

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

<tr>
<td width='100' height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_scont</font></td>
<td  bgcolor='#F6F6F6'><input type='text' size=25 name='scont' style="width:220px"></td>
</tr>

<tr>
<td width='100' height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_lcont</font></td>
<td  bgcolor='#F6F6F6'><input type='text' size=25 name='lcont' style="width:220px"></td>
</tr>

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

<tr>
<td width='100' height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_email</font></td>
<td  bgcolor='#F6F6F6'><input type='text' size=25 name='email' style="width:220px"></td>
</tr>

EOF;

//=====================================
//  User Filed
//=====================================

for ($k=1 ;$k<=5 ;$k++) {
$u_name = ${"u_user" . $k};
$u_fname = "user". $k;

if($u_name)
print <<<EOF

<tr>
<td width='100' height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$u_name</font></td>
<td  bgcolor='#F6F6F6'><input type='text' size=25 name='$u_fname' style="width:220px"></td>
</tr>

EOF;

}

//=====================================
//  Output others
//=====================================

print <<<EOF

<tr>
<td width='100' height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_search_type</font></td>
<td  bgcolor='#F6F6F6'><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'></font>&nbsp;</td>	

	</form><form action='view_link.php?type=$type' 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>
<br>

</body></html>

EOF;
exit;
}

//============================
// View Links part
//============================


// make sql
if ($sid || $title || $url || $parent || $scont || $lcont || $name || $email || $user1
|| $user2 || $user3 || $user4 || $user4)  $where="where ";

if (!$sid && !$title  && !$url && !$parent && !$scont && !$lcont && !$name && !$email
&& !$user1 && !$user2 && !$user3 && !$user4 && !$user5 && $view_type) 
errmsg($l_error_nofield);

if ($sid) {   if ($cque) $cque.="$view_type "; $cque.="sid=$sid ";}
if ($title) {  if ($cque) $cque.="$view_type "; $cque.="title like '%$title%' ";}
if ($url) {  if ($cque) $cque.="$view_type "; $cque.="url like '%$url%' ";}
if ($parent) {    if ($cque) $cque.="$view_type ";  $cque.="parent = '$parent' ";} 
if ($scon) {  if ($cque) $cque.="$view_type "; $cque.="scont like '%$scont%' ";}
if ($lcon) {  if ($cque) $cque.="$view_type "; $cque.="lcont like '%$lcont%' ";}
if ($name) {    if ($cque) $cque.="$view_type "; $cque.="name like '%$name%' ";} 
if ($email) {  if ($cque) $cque.="$view_type "; $cque.="email like '%$email%' ";}
if ($user1) {  if ($cque) $cque.="$view_type "; $cque.="user1 like '%$user1%' ";}
if ($user2) {  if ($cque) $cque.="$view_type "; $cque.="user2 like '%$user2%' ";}
if ($user3) {  if ($cque) $cque.="$view_type "; $cque.="user3 like '%$user3%' ";}
if ($user4) {  if ($cque) $cque.="$view_type "; $cque.="user4 like '%$user4%' ";}
if ($user5) {  if ($cque) $cque.="$view_type "; $cque.="user5 like '%$user5%' ";}


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

$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_LINK $where $cque order by uptime desc limit $vstart,$vend") ;
$link_total = $db->numrow;


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

$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_link.php?page=$p&switch=$switch&view_type=$view_type&type=$type&sid=$sid&title=$title&url=$url&parent=$parent&scont=$scont&lcont=$lcont&name=$name&email=$email&user1=$user1&user2=$user2&user3=$user3&user4=$user4&user5=$user5'>$view</a> </font>";

	}
}

if ($total>$vstart+$Spagecut) 
{ 
$next_p=$page+1;
$next_list="<a href='view_link.php?page=$next_p&switch=$switch&view_type=$view_type&type=$type&sid=$sid&title=$title&url=$url&parent=$parent&scont=$scont&lcont=$lcont&name=$name&email=$email&user1=$user1&user2=$user2&user3=$user3&user4=$user4&user5=$user5'>>></a>";
}


if ($page>0) 
{
$prev_p=$page-1;
$prev_list="<a href='view_link.php?page=$prev_p&switch=$switch&view_type=$view_type&type=$type&sid=$sid&title=$title&url=$url&parent=$parent&scont=$scont&lcont=$lcont&name=$name&email=$email&user1=$user1&user2=$user2&user3=$user3&user4=$user4&user5=$user5'><<</a>&nbsp;";
}


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


if($type=='delete') {

$form_txt = "<form action='./del_link.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_link.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" text='black' link='blue' vlink='purple' alink='red'>
$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_link</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>

EOF;

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

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

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

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


//=====================================
//  Delete / update input 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 others
//=====================================
		
	
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='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$l_sid</font></td>
<td width='400' bgcolor='white' height='24'><font  size='2'>&nbsp; $row[sid]</font></td>
</tr>

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

<tr>
<td width='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$l_source</font></td>
<td width='400' bgcolor='white' height='24'><font  size='2'>&nbsp; $row[url]</font></td>
</tr>

<tr>
<td width='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$l_cat</font></td>
<td width='400' bgcolor='white' height='24'>&nbsp; <a href="../index.php?cat=$row[parent]" target="_blank"><font  size='2'>$pathtxt</font></a></td>
</tr>

<tr>
<td width='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$l_scont</font></td>
<td width='400' bgcolor='white' height='24'><font  size='2'>&nbsp; $row[scont]</font></td>
</tr>

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

<tr>
<td width='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$l_email</font></td>
<td width='400' bgcolor='white' height='24'><font  size='2'>&nbsp; $row[email]</font></td>
</tr>
EOF;


//--------------------------------
// FILE
//--------------------------------


$upfile = @unserialize(stripslashes($row[upfile]));
$upfile[2] = size_cut($upfile[2]);
$upfile[5] = strtoupper($upfile[5]);

print <<<EOF
<tr>
<td width='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$l_link</font></td>
<td bgcolor='white' height='24'>

	<table width=100% border=0><tr>
	<td><ul>
	<li><a href="../download.php?sid=$row[sid]"><font size='2'>$upfile[0]</font></a></li>
	<li><font size='2'>$upfile[3] X $upfile[4]</font></li>
	<li><font size='2'>$upfile[5], $upfile[2]</font></li>
	<li><font size='2'>$l_down : $upfile[6]</font></li>

	</ul></td>
	<td align=right><a href='../imageview.php?uid=$upfile[1]&vtype=orgin' target='_blank'><font  size='2'><img src='../imageview.php?uid=$upfile[1]' border=0></font></td>
	</tr></table>
</td>
</tr>

EOF;


for ($k=1 ;$k<=5 ;$k++) {
$u_name = ${"u_user" . $k};
$u_fname = "user". $k;

if($u_name)
print <<<EOF
<tr>
	<td width='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$u_name</font></td>
	<td width='400' bgcolor='white' height='24'>&nbsp;<font  size='2'>$row[$u_fname]</font></td>
</tr>
EOF;
}

print <<<EOF
<tr>
<td width='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$l_pick</font></td>
<td width='400' bgcolor='white' height='24'>&nbsp;<font  size='2'> $row[c_pick]</font></td>
</tr>

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

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


<tr>
<td width='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$l_vote_score</font></td>
<td width='400' bgcolor='white' height='24'><font size='2'>
&nbsp;1{$l_score_dot}&nbsp;	$row[n1]	&nbsp;2{$l_score_dot}&nbsp;	$row[n2]	&nbsp;3{$l_score_dot}&nbsp;
$row[n3] &nbsp;4{$l_score_dot}&nbsp;	$row[n4]	&nbsp;5{$l_score_dot}&nbsp;	$row[n5]
</font>	</td>
</tr>

<tr>
<td width='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$l_vote_score</font></td>
<td width='400' bgcolor='white' height='24'><font size='2'>
&nbsp;6{$l_score_dot}&nbsp;	$row[n6]	&nbsp;7{$l_score_dot}&nbsp;	$row[n7]	&nbsp;8{$l_score_dot}&nbsp; $row[n8]
&nbsp;9{$l_score_dot}&nbsp;	$row[n9]	&nbsp;10{$l_score_dot}&nbsp;	$row[n10]</font></td>
</tr>

<tr>
<td width='96' bgcolor='#F6F6F6' height='24'><font  size='2'>&nbsp;$l_lcont</font></td>
<td width='400' bgcolor='white' height='24'><font  size='2'>&nbsp; $row[lcont]</font></td>
</tr>

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

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

EOF;

} // for





//=====================================
//  Output Directbar
//=====================================

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

EOF;

?>
Return current item: Linker IMG