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

//=====================================
// LINKER Category Engine
//=====================================
// Filename : cool.php
// Path  : Main directory
// last update : 2002/07/13
// Desc : View cool 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( cool_page  => "cool.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
//=====================================


$select_cool = "<select onChange=change_cool(this)>
<option value=''>$l_cool</option>
<option value='count'>$l_count</option>
<option value='aver'>$l_vote_ave</option></select>";

if ($type == "aver") {
$cool_query = " ((n1*1) + (n2*2) + (n3*3) + (n4*4) + (n5*5) + (n6*6) + (n6*7) + (n8*8) + (n9*9) + (n10*10)) / (n1+n2+n3+n4+n5+n6+n7+n8+n9+n10) >= $Scool_aver ";
$here_str = " $l_vote_ave $Scool_aver $l_over $l_cool";
}

else {
$cool_query = " count >= $Scool_num ";
$here_str = " $l_count $Scool_num $l_over $l_cool";
}

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

$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 $cool_query 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='cool.php?page=$p&type=$type&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='cool.php?page=$next_p&type=$type&viewtype=$viewtype&u_sort=$u_sort&u_order=$u_order'><img src='$Stemplate/image/next.gif' border=0 valign=middle></a>&nbsp;"; // next button
}


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



//====================================
// 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("","",$here_str. " ($TotalLink)");
show_search();

$self_file = "cool.php";
$self_str = "cool";
show_norder($select_cool);

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

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

//====================================
// Eatablish Time
//====================================

if ($Stime == "Y") check_time($time1);


?>
Return current item: Linker IMG