国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.1KB

  1. <?php
  2. /**
  3. * 投票
  4. *
  5. * @version $Id: vote.php$
  6. * @package DedeBIZ.Site
  7. * @copyright Copyright (c) 2022, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require(dirname(__FILE__)."/../system/common.inc.php");
  12. require(DEDEINC."/dedevote.class.php");
  13. require(DEDEINC."/memberlogin.class.php");
  14. require(DEDEINC."/userlogin.class.php");
  15. $member = new MemberLogin;
  16. $memberID = $member->M_LoginID;
  17. $time = time();
  18. $content = $memberID.'|'.$time;
  19. $file = DEDEDATA.'/cache/vote_'.$aid.'_'.$member->M_ID.'.inc'; //存放会员投票记录的缓存文件
  20. $loginurl = $cfg_basehost."/user";
  21. $ENV_GOBACK_URL = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
  22. if (empty($dopost)) $dopost = '';
  23. $aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
  24. if ($aid == 0) die("dedebiz");
  25. if ($aid == 0) {
  26. ShowMsg("没指定投票项目的ID", "-1");
  27. exit();
  28. }
  29. $vo = new DedeVote($aid);
  30. $rsmsg = '';
  31. $row = $dsql->GetOne("SELECT * FROM `#@__vote` WHERE aid='$aid'");
  32. //判断是否允许游客进行投票
  33. if ($row['isallow'] == 1) {
  34. if (!$member->IsLogin()) {
  35. ShowMsg('请先登录再进行投票', $loginurl);
  36. exit();
  37. }
  38. }
  39. if ($dopost == 'send') {
  40. if (!empty($voteitem)) {
  41. $rsmsg = "<br>您方才的投票状态:".$vo->SaveVote($voteitem)."<br>";
  42. } else {
  43. $rsmsg = "<br>您刚才没选择任何投票项目<br>";
  44. }
  45. if ($row['isenable'] == 1) {
  46. ShowMsg('此投票项未启用,暂时不能进行投票', $ENV_GOBACK_URL);
  47. exit();
  48. }
  49. }
  50. $voname = $vo->VoteInfos['votename'];
  51. $totalcount = $vo->VoteInfos['totalcount'];
  52. $starttime = GetDateMk($vo->VoteInfos['starttime']);
  53. $endtime = GetDateMk($vo->VoteInfos['endtime']);
  54. $votelist = $vo->GetVoteResult("98%", 30, "30%");
  55. //判断是否允许被查看
  56. $admin = new userLogin;
  57. if ($dopost == 'view') {
  58. if ($row['view'] == 1 && empty($admin->userName)) {
  59. ShowMsg('此投票项不允许查看结果', $ENV_GOBACK_URL);
  60. exit();
  61. }
  62. }
  63. //显示模板(简单PHP文件)
  64. include(DEDETEMPLATE.'/plus/vote.htm');