国内流行的内容管理系统(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.

75 lines
3.1KB

  1. <?php
  2. /**
  3. * 添加投票模块
  4. *
  5. * @version $id:vote_add.php 23:54 2010年7月20日 tianya $
  6. * @package DedeBIZ.Administrator
  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__)."/config.php");
  12. require_once(DEDEINC."/dedevote.class.php");
  13. require_once(DEDEINC."/helpers/filter.helper.php");
  14. CheckPurview('plus_投票模块');
  15. if (empty($dopost)) $dopost = "";
  16. if (empty($isarc)) $isarc = 0;
  17. if ($dopost == "save" && $isarc == 0) {
  18. CheckCSRF();
  19. $starttime = GetMkTime($starttime);
  20. $endtime = GetMkTime($endtime);
  21. $voteitems = "";
  22. $j = 0;
  23. for ($i = 1; $i <= 15; $i++) {
  24. if (!empty(${"voteitem".$i})) {
  25. $j++;
  26. $voteitems .= "<v:note id=\\'$j\\' count=\\'0\\'>".${"voteitem".$i}."</v:note>\r\n";
  27. }
  28. }
  29. $inQuery = "INSERT INTO `#@__vote` (votename,starttime,endtime,totalcount,ismore,votenote,isallow,view,spec,isenable) VALUES ('$votename','$starttime','$endtime','0','$ismore','$voteitems','$isallow','$view','$spec','$isenable'); ";
  30. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  31. ShowMsg("添加投票失败,请检查数据是否非法", "-1");
  32. exit();
  33. }
  34. $aid = $dsql->GetLastID();
  35. $vt = new DedeVote($aid);
  36. $vote_content = $vt->GetVoteForm();
  37. $vote_content = preg_replace(array("#/#", "#([\r\n])[\s]+#"), array("\/", " "), $vote_content); //取出文档中的空白字符并进行转义
  38. $vote_content = 'document.write("'.$vote_content.'");';
  39. $vote_file = DEDEDATA."/vote/vote_".$aid.".js";
  40. file_put_contents($vote_file, $vote_content);
  41. ShowMsg("成功添加一组投票", "vote_main.php");
  42. exit();
  43. } else if ($dopost == "save" && $isarc == 1) {
  44. $starttime = GetMkTime($starttime);
  45. $endtime = GetMkTime($endtime);
  46. $voteitems = "";
  47. $j = 0;
  48. for ($i = 1; $i <= 15; $i++) {
  49. if (!empty(${"voteitem".$i})) {
  50. $j++;
  51. $voteitems .= "<v:note id=\\'$j\\' count=\\'0\\'>".${"voteitem".$i}."</v:note>\r\n";
  52. }
  53. }
  54. $inQuery = "INSERT INTO `#@__vote` (votename,starttime,endtime,totalcount,ismore,votenote,isallow,view,spec,isenable) VALUES ('$votename','$starttime','$endtime','0','$ismore','$voteitems','$isallow','$view','$spec','$isenable'); ";
  55. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  56. ShowMsg("添加投票失败,请检查数据是否非法", "-1");
  57. exit();
  58. }
  59. $aid = $dsql->GetLastID();
  60. $vt = new DedeVote($aid);
  61. $vote_content = $vt->GetVoteForm();
  62. $vote_content = preg_replace(array("#/#", "#([\r\n])[\s]+#"), array("\/", " "), $vote_content); //取出文档中的空白字符并进行转义
  63. $vote_content = 'document.write("'.$vote_content.'");';
  64. $vote_file = DEDEDATA."/vote/vote_".$aid.".js";
  65. file_put_contents($vote_file, $vote_content);
  66. ShowMsg("成功添加一组投票", "vote_main.php?issel=1&aid=".$aid);
  67. exit();
  68. }
  69. $startDay = time();
  70. $endDay = AddDay($startDay, 30);
  71. $startDay = GetDateTimeMk($startDay);
  72. $endDay = GetDateTimeMk($endDay);
  73. include DedeInclude('templets/vote_add.htm');
  74. ?>