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

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


//=====================================
// File include part
//=====================================
$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->assign(array(
TEMPLATE	=> $Stemplate,
DOMAIN			=> $Sdomain,
CHARSET		=> $Scharset,
BGCOLOR		=> $Sbgcolor,
MWIDTH			=> $Smain_width,
ALIGN			=> $Salign,
NEW_BOFORE	=> $Snewdate,
L_NEW_SITE	=> $l_new_site ,
PAGE_HEADER  => implode("",file("$Stemplate/header.html")),
PAGE_FOOTER  => implode("",file("$Stemplate/footer.html"))
));

//===============================================
// View date
//===============================================

if (!$switch) {


$tpl->define(	array(new_page      => "new.html" ));
$tpl->dyn_define ( "newrow", "new_page" );

	for ($u=0;$u<$Snewdate ;$u++) 
	{
		$s_time = mktime(0,0,0,date("m"),date("d")-$u, date("Y"));
		$e_time = mktime(0,0,0,date("m"),date("d")-$u +1, date("Y"));
		$new_date=date("Y{$l_year} m{$l_month} d{$l_date}",$s_time);

		$db->query("select count(*) as total from LINKER_LINK where uptime > $s_time and uptime < $e_time");
		$row = $db->nrecord();


		$tpl->assign( array( 
		NEW_DATE => $new_date,
		NEW_NUM => $row[total],
		TIMESTAMP => $s_time
		));

		$tpl->parse(ROWS,".newrow");

	} // end for


//=====================================
// Print data
//=====================================

show_menu();
show_here("","",$l_new_site);
show_search();

$tpl->assign(array(
L_NEWADD_SITE => $l_newadd_site,
L_NEWFOR_SITE => $l_newfor_site
));

$tpl->parse(MAIN, ".new_page");
$tpl->simprint("MAIN");
}

//===============================================
// View Link part
//===============================================


if ($switch) {

// error check
if (!$timestamp) errmsg($l_error_nodate);

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


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

$s_time = $timestamp;
$e_time = $timestamp + 86400;
$view_date = 	date("Y{$l_year} m{$l_month} d{$l_date}",$s_time);

$db->query("select count(*) as TotalLink from LINKER_LINK where uptime > $s_time and uptime < $e_time");
if ($db->numrow) $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 uptime > $s_time and uptime < $e_time order by $u_sort $u_order
limit $vstart,$Spagecut") ;


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

$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='new.php?page=$p&switch=newview&timestamp=$timestamp&viewtype=$viewtype&u_sort=$u_sort&u_order=$u_order'><font class=midsmall>$p</font></a>]";
}

if ($TotalLink > $vstart+$Spagecut ) {		// Next Button
$next_p=$page+1;
$next_list = "<a href='new.php?page=$next_p&switch=newview&timestamp=$timestamp&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 Button
$prev_p=$page-1;
$prev_list="<a href='new.php?page=$prev_p&switch=newview&timestamp=$timestamp&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("",""," $view_date $l_newadd_site ($TotalLink)");
show_search();

$self_file = "new.php";
$self_str = "new";
$mode = "newview";
show_norder("");

$tpl->assign(array(
LINK				=> $link,
PREV				=> $prev_list,
DIRECT			=> $direct_bar,
NEXT				=> $next_list
));

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

}


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

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