加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vote.php 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
石榴木 提交于 2016-10-11 12:02 . format code
<?php
$c_main = 'vote';
include './library/inc.php';
include './language/common.php';
non_numeric_back(intval($_GET['id']), $_lang['illegal']);
// 记入投票数据
if ($act == 'vote') {
if ($db->getOne("SELECT id FROM cms_vote_log WHERE l_ip = '" . getIp() . "'")) {
alert_href('您已参与过投票,谢谢您的支持!', 'vote.php?act=view&id=' . $_GET['id']);
}
foreach ($_GET['vote'] as $row) {
non_numeric_back(intval($_GET['vote']), $_lang['illegal']);
$arr['v_id'] = $_GET['id'];
$arr['o_id'] = $row;
$arr['l_ip'] = getIp();
$arr['l_date'] = gmtime();
$db->autoExecute('cms_vote_log', $arr, 'INSERT');
// 更新项目统计
$db->query("UPDATE cms_vote SET v_count=v_count+1 WHERE id=" . $_GET['id']);
$db->query("UPDATE cms_vote_option SET o_count=o_count+1 WHERE id=" . $row);
}
alert_href('您已完成投票,谢谢您的支持!', 'vote.php?act=view&id=' . $_GET['id']);
$view = 1;
} elseif ($act == 'view') {
// 获取投票数据
$vote = $db->getRow("SELECT * FROM cms_vote WHERE id = " . $_GET['id']);
$vote_option = $db->getAll("SELECT * FROM cms_vote_option WHERE v_id = " . $vote['id'] . " ORDER BY id ASC");
if ($vote['v_count'] == 0) {
foreach ($vote_option as $key => $val) {
$vote_option[$key]['pct'] = '0%';
}
} else {
foreach ($vote_option as $key => $val) {
$vote_option[$key]['pct'] = round($val['o_count'] / $vote['v_count'] * 100) . '%';
}
}
$view = 1;
} else {
// 获取投票数据
$vote = $db->getRow("SELECT * FROM cms_vote WHERE id = " . $_GET['id']);
$vote_option = $db->getAll("SELECT * FROM cms_vote_option WHERE v_id = " . $vote['id'] . " ORDER BY o_order DESC,id ASC");
$view = 0;
}
$current_channel_location = '<li class="am-active">在线调查</li>';
//读取指定的频道模型
include $t_path . 'vote.php';
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化