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

//=====================================
// LINKER Category Engine
//=====================================
// Filename : show_slide.php
// Path  : Main directory
// last update : 2002/07/10
// Desc : Show Image slide
//=====================================


//=====================================
// 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
//=====================================

while (list($key,$val) = each($HTTP_POST_VARS)) $$key = trim($val) ;
while (list($key,$val) = each($HTTP_GET_VARS)) $$key = trim($val) ;

$db = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);
$tpl = new Stemplate($Stemplate);
$tpl->define(array( slide  => "slide_show.html" ));

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

if (!$u_sort) $u_sort = $Ssort;
if (!$u_order) $u_order = $Sorder;


//======================================
// Normal Category
//======================================

if ($switch == "category") 
{
	$db->query("select sid,title,upfile from LINKER_LINK where parent='$cat' order by $u_sort $u_order ");
}

//======================================
// Cool image
//======================================

else if ($switch =="cool") 
{
	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 ";
	}

	else {
	$cool_query = " count >= $Scool_num ";
	}
	$db->query("select sid,title,upfile from LINKER_LINK where $cool_query order by $u_sort $u_order ");
}

//======================================
// Pick image
//======================================

else if ($switch =="pick") 
{
	$db->query("select sid,title,upfile from LINKER_LINK where c_pick='1' order by $u_sort $u_order ");
}

//======================================
// New image
//======================================

else if ($switch =="new") 
{
	$s_time = $timestamp;
	$e_time = $timestamp + 86400;
	$db->query("select sid,title,upfile from LINKER_LINK where uptime > $s_time and uptime < $e_time order by $u_sort $u_order");
}

//======================================
// Search || Extended Search
//======================================

else if ($switch =="search" || $switch =="extsearch") 
{
	// if normal search
	if ($switch== "search") 	
	{
	include ("./function/search_info.php"); 
	}


	if (!$c_sep) $c_sep = "or";
	$kword=trim($kword);


	$kword_buffer = explode(" ",$kword);
	for ($i=0; $i<count($kword_buffer) ;$i++) {
	if ($kword_buffer[$i]) $kword_array[] = $kword_buffer[$i];
	}

	$kword_num = count($kword_array);

	for ($i=0; $i <$kword_num ; $i++) {

		if ($c_title) $query_buffer =" title like '%$kword_array[$i]%'"; 
		if ($c_url) { 
			if ($query_buffer) 	$query_buffer .= " or ";
			$query_buffer .= " url like '%$kword_array[$i]%'";
		}
		
		if ($c_name) { 
			if ($query_buffer) 	$query_buffer .= " or ";
			$query_buffer .= " name like '%$kword_array[$i]%'";
		}
		if ($c_email) { 
			if ($query_buffer) 	$query_buffer .= " or ";
			$query_buffer .= " email like '%$kword_array[$i]%'";
		}
		if ($c_scont) { 
			if ($query_buffer) 	$query_buffer .= " or ";
			$query_buffer .= " scont like '%$kword_array[$i]%'";
		}
		if ($c_lcont) { 
			if ($query_buffer) 	$query_buffer .= " or ";
			$query_buffer .= " lcont like '%$kword_array[$i]%'";
		}

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

		if($u_name) {
		if ($query_buffer) 	$query_buffer .= " or ";
		$query_buffer .= " $u_fname like '%$kword_array[$i]%'";

			}
		}


	if ($kword_num>1) $query_buffer = "(" . $query_buffer . ")";
	if ($kword_array[$i+1]) $query_buffer .= " $c_sep ";
	$add_query .= $query_buffer;
	unset($query_buffer);
	}

	if ($switch== "search") 	
	{
		if ($search_path) 
		{
			$add_query = "(" . $add_query . ")" ;
			$path_query = " and (path like '$search_path%' or parent='$search_sid') ";
		}
	}
	else 
	{
		if ($search_sid) 
		{
			$db->query("select path from LINKER_LINK where sid='$search_sid'");
			$prow = $db->nrecord();
			$add_query = "(" . $add_query . ")" ;
			$path_query = " and (path like '$prow[path]%' or sid='$search_sid') ";
		}
	}
	
	$db->query("select sid,title,upfile from LINKER_LINK where $add_query $path_query order by $u_sort $u_order");
}


//======================================
// Show Slide image
//======================================

while ($row = $db->nrecord()) 
{
	$imgc++;
	$row[title] = addslashes($row[title]);
	$upfile = @unserialize(stripslashes($row[upfile]));
	$image_row .= "SlidePic[$imgc]  = '$Sdomain/imageview.php?uid=$upfile[1]&vtype=orgin'; \n";
	$title_row .= "SlideTitle[$imgc]  = '$row[title]'; \n";
}

$tpl->assign(array(
	L_TITLE					=> $l_title,
	L_CLOSE				=> $l_clowin,
	IMAGE_ROW			=> $image_row,
	TITLE_ROW			=> $title_row
) );

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

?>
Return current item: Linker IMG