<?
		$listuser -> checklogin($_SESSION["member"]->uid);
		
		$iserror = 0;
		
		$bid = isset($bid)?intval($bid):0;
		$bookinfo = $db->query_object("select sortid,articlename,agentid from ".JIEQI_DB_PREFIX."_article_article where display=0 and articleid = ".$bid);
		
		if(!$bookinfo){
				$iserror = 1;
				$url = array();
				$tourl = URL_book_index($url);
				$pagecontent = "<b>提醒：</b><br/>";
				$pagecontent .= "该小说不存在或已经被删除！<br/>";
				$pagecontent .= ">>".backurl()."<br/>";	
		}else{
				$sortid = $bookinfo->sortid;
				if($sortid == 0){
						$sortname = "未分类";
				}else{
						$sortname = iconv("gbk","utf-8",$jieqiSort['article'][$sortid]["shortname"]);
				}
				$dayvotes = ($jieqiRight['article']['dayvotes']['honors'][$listuser->getmemberlevel($_SESSION["member"]->experience,"level")]=="") ? ($jieqiConfigs['article']['dayvotes']) : $jieqiRight['article']['dayvotes']['honors'][$listuser->getmemberlevel($_SESSION["member"]->experience,"level")];
		}
		
		if($iserror == 0){
		
				$userdayvotes = unserialize($_SESSION["member"]->setting);
				
				$fullpolldate = time(); 
				$polldate = date("Y-m-d",time());
				
				@$userdayvotes["polldate"] = ($userdayvotes["polldate"]=="") ? $polldate : $userdayvotes["polldate"];
				
				if($userdayvotes["polldate"] == $polldate){
						@$userdayvotes["pollnum"] = ($userdayvotes["pollnum"]=="") ? 0 : $userdayvotes["pollnum"];
				}else{
						@$userdayvotes["pollnum"] =  0;
				}
				
				if($userdayvotes["pollnum"] >= $dayvotes){
						$pagecontent = "推荐失败！<br/>";
				}else{
						$pagecontent = "推荐成功！<br/>";
						
						$userdayvotes["polldate"] = $polldate;
						$userdayvotes["pollnum"] ++;
						$_SESSION["member"]->setting = serialize($userdayvotes);
						$sql = "UPDATE ".JIEQI_DB_PREFIX."_system_users SET setting = '".$_SESSION["member"]->setting."' WHERE uid = ".$_SESSION["member"]->uid;
						$db->query($sql);
						
						$sqli = "";
						if(date("W",$fullpolldate)!=date("W"))$sqli .= "weekvote=0,";
						if(date("m",$fullpolldate)!=date("m"))$sqli .= "monthvote=0,";
						if(date("d",$fullpolldate)!=date("d"))$sqli .= "dayvote=0,";
						$db -> query("UPDATE ".JIEQI_DB_PREFIX."_article_article SET {$sqli}allvote=allvote+1,monthvote=monthvote+1,weekvote=weekvote+1,dayvote=dayvote+1 WHERE articleid=".$bid);
				}
				
				
				if($userdayvotes["pollnum"] >= $dayvotes){
						$pagecontent .= "您今天的推荐次数已经用光！<br/>";
				}else{
						$overdayvotes = $dayvotes - $userdayvotes["pollnum"];
						$pagecontent .= "您今天还可以推荐".$overdayvotes."次<br/>";
				}
				
				$pagecontent .= "今天第".$userdayvotes["pollnum"]."次推荐/每天最多{$dayvotes}次<br/>";
				
				$url = array(
						"bid" => $bid,
						"act" => "",
				);
				$tourl = URL_book_cover($url);
		          
		}
		
		$smartydate = array("pagetitle" => "提醒",
												"pagecontent" => $pagecontent,
												"tourl" => $tourl,
												"redirecturl" => $tourl,
												);
		$tplpath = "public.tpl";

?>