vote_add.php
3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* 投票模块
*
* @version $Id: vote_add.php 1 23:54 2010年7月20日Z tianya $
* @package DedeCMS.Administrator
* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require(dirname(__FILE__)."/config.php");
require_once(DEDEINC."/dedevote.class.php");
require_once(DEDEINC."/helpers/filter.helper.php");
CheckPurview('plus_投票模块');
if(empty($dopost)) $dopost = "";
if(empty($isarc)) $isarc = 0;
if($dopost=="save" && $isarc == 0)
{
$starttime = GetMkTime($starttime);
$endtime = GetMkTime($endtime);
$voteitems = "";
$j = 0;
for($i=1; $i<=15; $i++)
{
if(!empty(${"voteitem".$i}))
{
$j++;
$voteitems .= "<v:note id=\\'$j\\' count=\\'0\\'>".${"voteitem".$i}."</v:note>\r\n";
}
}
$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'); ";
if(!$dsql->ExecuteNoneQuery($inQuery))
{
ShowMsg("增加投票失败,请检查数据是否非法!","-1");
exit();
}
$aid = $dsql->GetLastID();
$vt = new DedeVote($aid);
$vote_content = $vt->GetVoteForm();
$vote_content = preg_replace(array("#/#","#([\r\n])[\s]+#"),array("\/"," "),$vote_content);//取出内容中的空白字符并进行转义
$vote_content = 'document.write("'.$vote_content.'");';
$vote_file = DEDEDATA."/vote/vote_".$aid.".js";
file_put_contents($vote_file, $vote_content);
ShowMsg("成功增加一组投票!","vote_main.php");
exit();
}
else if($dopost=="save" && $isarc == 1)
{
$starttime = GetMkTime($starttime);
$endtime = GetMkTime($endtime);
$voteitems = "";
$j = 0;
for($i=1; $i<=15; $i++)
{
if(!empty(${"voteitem".$i}))
{
$j++;
$voteitems .= "<v:note id=\\'$j\\' count=\\'0\\'>".${"voteitem".$i}."</v:note>\r\n";
}
}
$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'); ";
if(!$dsql->ExecuteNoneQuery($inQuery))
{
ShowMsg("增加投票失败,请检查数据是否非法!","-1");
exit();
}
$aid = $dsql->GetLastID();
$vt = new DedeVote($aid);
$vote_content = $vt->GetVoteForm();
$vote_content = preg_replace(array("#/#","#([\r\n])[\s]+#"),array("\/"," "),$vote_content);//取出内容中的空白字符并进行转义
$vote_content = 'document.write("'.$vote_content.'");';
$vote_file = DEDEDATA."/vote/vote_".$aid.".js";
file_put_contents($vote_file, $vote_content);
ShowMsg("成功增加一组投票!","vote_main.php?issel=1&aid=".$aid);
exit();
}
$startDay = time();
$endDay = AddDay($startDay,30);
$startDay = GetDateTimeMk($startDay);
$endDay = GetDateTimeMk($endDay);
include DedeInclude('templets/vote_add.htm');