require "funcs.php"; login_init(); require "libvote.php"; if ($loginok != 1 || !isset($currentuser)) { html_nologin(); } html_init("gb2312", "系统投票", "", 1); ?> <br /><p align=center><strong><?php echo BBS_FULL_NAME; ?> 系统投票</strong></p> <?php $link = sysvote_db_connect(); if ($_GET["svid"]) { $vote = sysvote_load_vote_infor($link, $_GET["svid"]); if (!$vote) { html_error_quit("对不起,所选择的投票不存在!"); } if ($vote[active] != 1) { echo "<script language=javascript>window.location.href=\"bbsssysvote.php?svid=" . $vote[svid] . "\";</script>"; } $per = sysvote_user_can_vote($link, $vote, $currentuser); if ($per == -1) { html_error_quit("对不起,本次投票需要登录!"); } elseif ($per == -2) { html_error_quit("对不起,您已经投过票了!"); } elseif ($per == -3) { html_error_quit("对不起,您所在的位置已经投过" . $vote[votesperip] . "次票了!"); } else { if ($_GET["sv"] == "sv") {
function svEndVote($link, $svid, $annType, $annBoard) { global $currentuser, $sysVoteConfig; $this->user = $currentuser; $vote = sysvote_load_vote_infor($link, $svid); //初始化各个变量 $ann = "⊙ 投票开启于:" . $vote[created] . " 类别:系统投票\n" . "⊙ 主题:" . $vote[ori][subject] . "\n" . "⊙ 投票说明:\n\n" . $vote[ori][description] . "\n\n\n" . ($voteres = array()); for ($i = 0; $i < count($vote[probs]); $i++) { $etemNum[$i] = count($vote[probs][$i][etems]); for ($j = 0; $j < $etemNum[$i]; $j++) { $voteres[$i][$j + 1] = 0; } if ($vote[probs][$i][type] == 4) { $voteres[$i][0] = "本题通过投票征集的意见如下:"; } if ($vote[probs][$i][type] == 2 || $vote[probs][$i][type] == 3) { $voteres[$i][$etemNum[$i] + 1] = "本题通过投票征集的意见如下:"; } } //进行结果统计 $query = "SELECT * FROM sysvote_users WHERE svid = '" . $vote[svid] . "' ORDER BY suid"; $result = mysql_query($query, $link); $voteUserNum = mysql_num_rows($result); for ($k = 0; $k < $voteUserNum; $k++) { $rows = mysql_fetch_array($result); $userres = explode("|", $rows[voteinfo]); for ($i = 0; $i < count($vote[probs]); $i++) { if ($vote[probs][$i][type] == 4) { $voteres[$i][0] .= "\n☆─────────────────────────────────────☆\n " . $rows[userid] . " 于 " . time_format($rows[votetime]) . " 说道: \n" . base64_decode($userres[$i]); } elseif ($vote[probs][$i][type] == 1 || $vote[probs][$i][type] == 3) { $etemres = explode("&", $userres[$i]); for ($l = 0; $l < $etemNum[$i]; $l++) { $voteres[$i][(int) $etemres[$l]]++; } if ($vote[probs][$i][type] == 3 && $etemres[count($etemres) - 1]) { $voteres[$i][$etemNum[$i] + 1] .= "\n☆─────────────────────────────────────☆\n " . $rows[userid] . " 于 " . time_format($rows[votetime]) . " 说道: \n" . base64_decode($etemres[count($etemres) - 1]); } } elseif ($vote[probs][$i][type] == 2) { $etemres = explode("&", $userres[$i]); $voteres[$i][(int) $etemres[0]]++; if ($etemres[1]) { $voteres[$i][$etemNum[$i] + 1] .= "\n☆─────────────────────────────────────☆\n " . $rows[userid] . " 于 " . time_format($rows[votetime]) . " 说道: \n" . base64_decode($etemres[1]); } } else { $voteres[$i][(int) $userres[$i]]++; } } // i 循环 题目 } // k 循环 , 用户 //生成投票结果 $ann = "⊙ 参与投票的用户数:" . $voteUserNum . "\n" . "⊙ 投票结果:\n\n\n"; // $res的结构 : 参与投票的用户数量|题目1|...|题目n|文本输出 $res = $voteUserNum; if ($voteUserNum == 0) { $voteUserNum = 1; } $probType = array("单项选择", "多项选择", "单项选择(可发表意见)", "多项选择(可发表意见)", "问答"); for ($i = 0; $i < count($vote[probs]); $i++) { $ann .= "\n\n\n————————————————┤问题 " . ($i + 1) . "├————————————————\n" . "问题 " . ($i + 1) . ":" . $vote[probs][$i][prob] . "\n" . "类型:" . $probType[$vote[probs][$i][type]] . "\n"; if ($vote[probs][$i][type] == 4) { $ann .= "\n" . $voteres[$i][0]; //问答 $res .= "|" . base64_encode($voteres[$i][0]); } else { $res .= "|"; for ($j = 0; $j < $etemNum[$i]; $j++) { if ($j != 0) { $res .= ","; } $res .= $voteres[$i][$j + 1]; $ann .= "\n选项 " . ($j + 1) . ":" . $vote[probs][$i][etems][$j] . " 票数:" . $voteres[$i][$j + 1] . " 约占" . (int) ($voteres[$i][$j + 1] * 1000 / $voteUserNum) / 10 . "%"; } // j 循环 选项 if ($vote[probs][$i][type] == 2 || $vote[probs][$i][type] == 3) { $ann .= "\n\n" . $voteres[$i][$etemNum[$i] + 1]; $res .= "," . base64_encode($voteres[$i][$etemNum[$i] + 1]); } } } // i 循环 题目 $res .= "|" . base64_encode($ann); $voteLog = $vote[logs] . "\n管理员 " . $this->user["userid"] . " 于 " . date("Y-m-d H:i:s") . " 自 " . $_SERVER["REMOTE_ADDR"] . " 结束本次投票;"; $query = "UPDATE sysvote_votes SET active = 0 , results = '" . $res . "' , logs = '" . $voteLog . "' WHERE svid = '" . $vote[svid] . "';"; mysql_query($query, $link); $query = "DELETE FROM sysvote_users WHERE svid = " . $vote[svid]; mysql_query($query, $link); if ($annType == 1) { $annBoard = "vote"; } elseif ($annType == 2) { $annBoard = $sysVoteConfig["BOARD"]; } elseif ($annType == 3) { $brdArr = array(); $boardID = bbs_getboard($annBoard, $brdArr); if ($boardID == 0) { html_error_quit("指定的版面不存在!"); } } if ($annType != 0) { $title = "[公告] 系统投票结果"; $content = "【此篇文章是由自动发信系统所张贴】\n\n" . $ann; $ret = bbs_postarticle($annBoard, $title, $content, 0, 0, 0, 0); } }