-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvotepolls.php
More file actions
105 lines (98 loc) · 3 KB
/
votepolls.php
File metadata and controls
105 lines (98 loc) · 3 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* iForum - a bulletin Board (Forum) for ImpressCMS
*
* Based upon CBB 3.08
*
* @copyright http://www.xoops.org/ The XOOPS Project
* @copyright http://xoopsforge.com The XOOPS FORGE Project
* @copyright http://xoops.org.cn The XOOPS CHINESE Project
* @copyright XOOPS_copyrights.txt
* @copyright readme.txt
* @copyright http://www.impresscms.org/ The ImpressCMS Project
* @license GNU General Public License (GPL)
* a copy of the GNU license is enclosed.
* ----------------------------------------------------------------------------------------------------------
* @package CBB - XOOPS Community Bulletin Board
* @since 3.08
* @author phppp
* ----------------------------------------------------------------------------------------------------------
* iForum - a bulletin Board (Forum) for ImpressCMS
* @since 1.00
* @author modified by stranger
* @version $Id$
*/
include("header.php");
include_once ICMS_ROOT_PATH."/modules/xoopspoll/include/constants.php";
include_once ICMS_ROOT_PATH."/modules/xoopspoll/class/xoopspoll.php";
include_once ICMS_ROOT_PATH."/modules/xoopspoll/class/xoopspolloption.php";
include_once ICMS_ROOT_PATH."/modules/xoopspoll/class/xoopspolllog.php";
include_once ICMS_ROOT_PATH."/modules/xoopspoll/class/xoopspollrenderer.php";
if (!empty($_POST['poll_id']) )
{
$poll_id = (int)$_POST['poll_id'];
}
elseif (!empty($_GET['poll_id']))
{
$poll_id = (int)$_GET['poll_id'];
}
if (!empty($_POST['topic_id']) )
{
$topic_id = (int)$_POST['topic_id'];
}
elseif (!empty($_GET['topic_id']))
{
$topic_id = (int)$_GET['topic_id'];
}
if (!empty($_POST['forum']) )
{
$forum = (int)$_POST['forum'];
}
elseif (!empty($_GET['forum']))
{
$forum = (int)$_GET['forum'];
}
$topic_handler = icms_getmodulehandler('topic', basename(__DIR__), 'iforum' );
$topic_obj = $topic_handler->get($topic_id);
if (!$topic_handler->getPermission($topic_obj->getVar("forum_id"), $topic_obj->getVar('topic_status'), "vote"))
{
redirect_header("javascript:history.go(-1);", 2, _NOPERM);
}
if (!empty($_POST['option_id']) )
{
$mail_author = false;
$poll = new XoopsPoll($poll_id);
if (is_object(icms::$user) )
{
if (XoopsPollLog::hasVoted($poll_id, $_SERVER['REMOTE_ADDR'], icms::$user->getVar("uid")) )
{
$msg = _PL_ALREADYVOTED;
setcookie("bb_polls[$poll_id]", 1);
}
else
{
$poll->vote($_POST['option_id'], '', icms::$user->getVar("uid"));
$poll->updateCount();
$msg = _PL_THANKSFORVOTE;
setcookie("bb_polls[$poll_id]", 1);
}
}
else
{
if (XoopsPollLog::hasVoted($poll_id, $_SERVER['REMOTE_ADDR']) )
{
$msg = _PL_ALREADYVOTED;
setcookie("bb_polls[$poll_id]", 1);
}
else
{
$poll->vote($_POST['option_id'], $_SERVER['REMOTE_ADDR']);
$poll->updateCount();
$msg = _PL_THANKSFORVOTE;
setcookie("bb_polls[$poll_id]", 1);
}
}
redirect_header("viewtopic.php?topic_id=$topic_id&forum=$forum&poll_id=$poll_id&pollresult=1", 1, $msg);
exit();
}
redirect_header("viewtopic.php?topic_id=$topic_id&forum=$forum", 1, "You must choose an option !!");