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

//=====================================
// LINKER Category Engine
//=====================================
// Filename : view.php
// Path  : Main directory
// last update : 2002/03/13
// Desc : Vote link
//=====================================

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

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"); 

//=====================================
// 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 
));
//=====================================
// Vote Form
//=====================================

if (!$n) {

$tpl->define(	array(vote	=> "vote.html"));
$tpl->assign(array( 

SID => $sid,
L_VOTE => $l_vote,
CHARSET		=> $Scharset,
L_VOTE_TXT => $l_vote_txt,
L_SCORE		=> $l_score
));

$tpl->parse("VOTE","vote");
$tpl->simprint("VOTE");
exit;
}

//=====================================
// Vote submit
//=====================================

$tpl->define(	array(
vote_ok => "vote_ok.html",
vote_error	=> "vote_error.html"
));

$tpl->assign(array (
L_ALREADY_VOTE => $l_already_vote,
L_VOTE_OK			=> $l_vote_ok
));

// duplicate vote check
$cook_vote = unserialize(stripslashes($HTTP_COOKIE_VARS[cook_vote]));

if (is_array($cook_vote) && isset($cook_vote)) {
	while (list(,$val) = each($cook_vote)) 
	if ($val == $sid) {
	$tpl->parse("MAIN","vote_error");
	$tpl->simprint("MAIN");
	exit;
	}
}
$cook_vote[] = $sid;
setcookie("cook_vote",serialize($cook_vote),time() + $Scooklimit,"/");

// vote update
$db->query("update LINKER_LINK SET $n = $n +1  where sid='$sid'");


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

$tpl->parse("VOTE_OK","vote_ok");
$tpl->simprint("VOTE_OK");


?>
Return current item: Linker IMG