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

88 lines
3.2KB

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