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

//=====================================
// LINKER Category Engine
//=====================================
// Filename : review.php
// Path  : Main directory
// last update : 2002/07/13
// Desc : Review link
//=====================================

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

$time1 = microtime();
include ("./function/base_info.php");
include ("./function/main_func.php");
include ("./function/$Sdb_type.php");
include ("./function/template.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"); 

if (!$sid) errmsg($l_error_nolink);

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

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

$tpl->define(	array(review	=> "review.html" ,comment	=> "com_row.html"));

//=====================================
// Get data
//=====================================

$db->query("update LINKER_LINK set count = count +1 where sid='$sid'"); 
$db->query("select * from LINKER_LINK where sid='$sid'");
if (!$db->numrow) errmsg($l_error_nolink);
$row = $db->nrecord();

$vote_max=max($row[n1],$row[n2],$row[n3],$row[n4],$row[n5],$row[n6],$row[n7],$row[n8],$row[n9],$row[n10]);

for ($i=1;$i<=10 ;$i++) {
$vnum = "n".$i;
$vote_total +=$row[$vnum];


$vscore += $row[$vnum]* $i ;
}

$temp_evere = ($vote_total)  ? $vscore / $vote_total : 0 ;
$evere=number_format($temp_evere , 2);

$row[lcont]=nl2br(htmlspecial(stripslashes($row[lcont])));
$row[title]=htmlspecial(stripslashes($row[title]));
$path  = $row[path];
$pathtxt = $row[pathtxt];
$recat = $row[parent];

$tpl->assign(array(
	SID				=> $sid,
	SNAME			=> $row[title],
	CWIDTH			=> $col_width	,
	TEMPLATE		=> $Stemplate,
	DOMAIN			=> $Sdomain,
	CHARSET		=> $Scharset,
	BGCOLOR		=> $Sbgcolor,
	MWIDTH			=> $Smain_width,
	ALIGN			=> $Salign,
	EMAIL			=> $row[email],
	SOURCE		=> text_cut($row[url], 35),
	EURL				=> urlencode($row[url]),
	TITLE				=> $row[title],
	LCONT			=> $row[lcont],
	NAME				=> $row[name],
	COM_NUM		=> $row[comment],
	UPTIME			=> date("Y-m-d H:i:s",$row[uptime]),
	EMAIL			=> $row[email],
	VOTE_TOTAL	=> $vote_total,
	EVERE			=> $evere,
	COUNT			=> $row[count],
	VISIT				=> $row[visit],
	USER1			=> $row[user1],
	USER2			=> $row[user2],
	USER3			=> $row[user3],
	USER4			=> $row[user4],
	USER5			=> $row[user5],
	RECAT	 		=> $row[parent]
	));

$tpl->assign(array(
	L_LCONT		=> $l_lcont,
	L_TITLE			=> $l_title,
	L_SOURCE		=> $l_source,
	L_VOTE_GRAPH => $l_vote_graph,
	L_EMAIL			=> $l_email,
	L_VOTE			=> $l_vote,
	L_ALL_VOTE	=> $l_vote_num,
	L_AVE_VOTE	=> $l_vote_ave,
	L_UPTIME		=> $l_uptime,
	L_FILE			=> $l_file,
	L_DOWN		=> $l_down,
	L_COUNT		=> $l_count,
	L_VISIT			=> $l_visit,
	L_COMMENT	=> $l_comment,
	L_GO_LIST		=> $l_go_list,
	L_VOTE			=> $l_vote,
	L_EDIT			=> $l_edit,
	L_DEL			=> $l_del,
	L_ETC			=> $l_etc,
	L_NAME			=> $l_name,
	L_CONTENT	=> $l_content,
	L_VOTECODE	=> $l_vote_code
));



$upfile = @unserialize(stripslashes($row[upfile]));

$tpl->assign(array(
FILE_NAME => $upfile[0],
FILE_SIZE => size_cut($upfile[2]),
FILE_DOWN => $upfile[6],
FIMGNAME	 => $upfile[1]
));


//=====================================
// User Comment
//=====================================

$db->query("select count(*) as total from LINKER_COM where parent = '$sid'");
$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 parent = '$sid' order by uptime desc limit $vstart,$vend") ;
$link_total = $db->numrow;


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

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

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='review.php?page=$p&sid=$sid'>$view</a>&nbsp;";

	}
}

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


if ($page>0) {
$prev_p=$page-1;
$prev_list="<a href='review.php?page=$prev_p&sid=$sid'><<</a>&nbsp;";
}

//=====================================
// Print Output
//=====================================

while ($row = $db->nrecord()) {
$comment .= view_comment($row);
}

if (!$total) $direct_bar = $l_no_comment;

$tpl->assign(array(
COM_PREV	=> $prev_list,
COM_NEXT	=> $next_list,
DIRECT_BAR  => $direct_bar,
COM_ROW	=> $comment,
PAGE_HEADER  => implode("",file("$Stemplate/header.html")),
PAGE_FOOTER  => implode("",file("$Stemplate/footer.html")),
));

show_menu($recat);
show_here($path,$pathtxt);
show_search();
$tpl->parse(MAIN,"review");
$tpl->simprint("MAIN");


//====================================
// Establish time
//====================================

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


?>
Return current item: Linker IMG