function lib_vote(&$ctag, &$refObj) { global $dsql; $attlist = "id|0,lineheight|24,tablewidth|100%,titlebgcolor|#EDEDE2,titlebackgroup|,tablebg|#FFFFFF"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); if (empty($id)) { $id = 0; } if ($id == 0) { $row = $dsql->GetOne("SELECT aid FROM `#@__vote` ORDER BY aid DESC LIMIT 0,1"); if (!isset($row['aid'])) { return ''; } else { $id = $row['aid']; } } $vt = new DedeVote($id); return $vt->GetVoteForm($lineheight, $tablewidth, $titlebgcolor, $titlebackgroup, $tablebg); }
if ($dsql->ExecuteNoneQuery("DELETE FROM #@__vote WHERE aid='{$aid}'")) { if ($dsql->ExecuteNoneQuery("DELETE FROM #@__vote_member WHERE voteid='{$aid}'")) { ShowMsg('成功删除一组投票!', $ENV_GOBACK_URL); exit; } } else { ShowMsg('指定删除投票不存在!', $ENV_GOBACK_URL); exit; } } else { if ($dopost == "saveedit") { $starttime = GetMkTime($starttime); $endtime = GetMkTime($endtime); $query = "UPDATE #@__vote SET votename='{$votename}',\r\n starttime='{$starttime}',\r\n endtime='{$endtime}',\r\n totalcount='{$totalcount}',\r\n ismore='{$ismore}',\r\n votenote='{$votenote}',\r\n isallow='{$isallow}',\r\n view='{$view}',\r\n spec='{$spec}',\r\n isenable='{$isenable}'\r\n WHERE aid='{$aid}'\r\n "; if ($dsql->ExecuteNoneQuery($query)) { $vt = new DedeVote($aid); $vote_file = DEDEDATA . "/vote/vote_" . $aid . ".js"; $vote_content = $vt->GetVoteForm(); $vote_content = preg_replace(array("#/#", "#([\r\n])[\\s]+#"), array("\\/", " "), $vote_content); //取出内容中的空白字符并进行转义 $vote_content = 'document.write("' . $vote_content . '");'; file_put_contents($vote_file, $vote_content); ShowMsg('成功更改一组投票!', $ENV_GOBACK_URL); } else { ShowMsg('更改一组投票失败!', $ENV_GOBACK_URL); } } else { $row = $dsql->GetOne("SELECT * FROM #@__vote WHERE aid='{$aid}'"); if (!is_array($row)) { ShowMsg('指定投票不存在!', '-1'); exit;
$file = DEDEDATA . '/cache/vote_' . $aid . '_' . $member->M_ID . '.inc'; //存放会员投票记录的缓存文件 $loginurl = $cfg_basehost . "/member"; $ENV_GOBACK_URL = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; if (empty($dopost)) { $dopost = ''; } $aid = isset($aid) && is_numeric($aid) ? $aid : 0; if ($aid == 0) { die(" Request Error! "); } if ($aid == 0) { ShowMsg("没指定投票项目的ID!", "-1"); exit; } $vo = new DedeVote($aid); $rsmsg = ''; $row = $dsql->GetOne("SELECT * FROM #@__vote WHERE aid='{$aid}'"); //判断是否允许游客进行投票 if ($row['range'] == 1) { if (!$member->IsLogin()) { ShowMsg('请先登录再进行投票', $loginurl); exit; } } if ($dopost == 'send') { if (!empty($voteitem)) { $rsmsg = "<br /> 你方才的投票状态:" . $vo->SaveVote($voteitem) . "<br />"; } else { $rsmsg = "<br /> 你刚才没选择任何投票项目!<br />"; }
<?php require_once(dirname(__FILE__)."/config.php"); require_once(dirname(__FILE__)."/../include/inc_vote.php"); $aid = ereg_replace("[^0-9]","",$aid); $vt = new DedeVote($aid); $vcode = $vt->GetVoteForm(); $vt->Close(); require_once(dirname(__FILE__)."/templets/vote_getcode.htm"); ClearAllLink(); ?>
function GetVote($id=0,$lineheight=24,$tablewidth="100%",$titlebgcolor="#EDEDE2",$titlebackgroup="",$tablebg="#FFFFFF"){ if($id=="") $id=0; if($id==0){ $row = $this->dsql->GetOne("select aid From #@__vote order by aid desc limit 0,1"); if(!isset($row['aid'])) return ""; else $id=$row['aid']; } include_once(dirname(__FILE__)."/inc_vote.php"); $vt = new DedeVote($id); //$vt->Close(); return $vt->GetVoteForm($lineheight,$tablewidth,$titlebgcolor,$titlebackgroup,$tablebg); }