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

//=====================================
// LINKER Category Engine
//=====================================
// Filename : new.php
// Path  : Main directory
// last update : 2002/07/13
// Desc : View new links
//=====================================

//=====================================
// Info File include
//=====================================

$time1 = microtime();
include ("./function/base_info.php");
include ("./function/main_func.php");
include ("./function/$Sdb_type.php");
include ("./function/template.php");
include ("./function/userfield_info.php"); 

$lan_dir = $HTTP_COOKIE_VARS[cook_lan];
if ($lan_dir && file_exists("./$lan_dir/u_common.php")) 
include ("./$lan_dir/u_common.php"); 
else include ("./$Slang/u_common.php"); 

//=====================================
// DB_LAYER / TEMPLATE
//=====================================

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

$tpl->define(	array( pick_page      => "pick.html"));
if ($viewtype == "list") 
{
	$tpl->define( array( link_row => "link.html"));
}
else 
{
	$tpl->define( array( link_row => "link_list.html"));
}

$tpl->assign(array(
TEMPLATE	=> $Stemplate,
DOMAIN			=> $Sdomain,
CHARSET		=> $Scharset,
BGCOLOR		=> $Sbgcolor,
MWIDTH			=> $Smain_width,
ALIGN			=> $Salign
));

//====================================
// Make Link
//====================================

$db->query("select count(*) as TotalLink from LINKER_LINK where c_pick = '1'");
$Trow = $db->nrecord();

$TotalLink = $Trow[TotalLink];
$page_num = ceil($TotalLink / $Spagecut);

$page = ($page) ? $page : 1;
$vstart = $Spagecut * ($page-1);

if (!$u_sort) $u_sort = "uptime";
if (!$u_order) $u_order = "desc";

$db->query("select * from LINKER_LINK where c_pick='1' order by $u_sort $u_order limit $vstart,$Spagecut") ;

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

$page_start = floor(($page-1)/ $Sdirectcut ) * $Sdirectcut ; 
$page_end = $page_start + $Sdirectcut; 

for ($p=$page_start+1 ; ($p <= $page_end) && ($p <= $page_num)  ; $p++ ) 
{	
	if ($page == $p) 	$direct_bar .= "[<b>$p</b>]";
	else 	$direct_bar .= "[<a href='pick.php?page=$p&viewtype=$viewtype&u_sort=$u_sort&u_order=$u_order'><font class=midsmall>$p</font></a>]";
}

if ($TotalLink > $vstart+$Spagecut ) {
$next_p=$page+1;
$next_list = "<a href='pick.php?page=$next_p&viewtype=$viewtype&u_sort=$u_sort&u_order=$u_order'><img src='$Stemplate/image/next.gif' border=0 valign=middle></a>&nbsp;";
}


if ($page>1) {
$prev_p=$page-1;
$prev_list="<a href='pick.php?page=$prev_p&viewtype=$viewtype&u_sort=$u_sort&u_order=$u_order'><img src='$Stemplate/image/prev.gif' border=0 valign=middle></a>&nbsp;";
}

//====================================
// Link assign and make
//====================================

	link_assign();

	$row_width = intval($Smain_width / $Snail_row);

	while ($row = $db->nrecord()) 
	{
		$imgcount++;
		if (!($imgcount % $Snail_row))	$tpl->assign("TRROW", "</tr><tr>");
		else	$tpl->assign("TRROW", "");

		$link .= view_link($row);
	}
	
	while ($imgcount % $Snail_row) {

		$link .= "<td width=$row_width>&nbsp;</td>\n";
		$imgcount++;
	}

//====================================
// Output Main page
//====================================



show_menu(); 
show_here("","","$l_pick ($TotalLink)");
show_search();

$self_file = "pick.php";
$self_str = "pick";
show_norder();

$tpl->assign(array(
PAGE_HEADER  => implode("",file("$Stemplate/header.html")),
PAGE_FOOTER  => implode("",file("$Stemplate/footer.html")),
LINK				=> $link,
PREV				=> $prev_list,
DIRECT			=> $direct_bar,
NEXT				=> $next_list,
L_PICK			=> $l_pick
));

$tpl->parse(MAIN, "pick_page");
$tpl->simprint("MAIN");

//====================================
// Establish Time
//====================================

if ($Stime == "Y") check_time($time1);
?>
Return current item: Linker IMG