Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

vote.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: vote.php 7115 2001-09-09 11:49:45Z bf $
5 //
6 // Created on: <20-Sep-2000 13:32:11 ce>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezhttptool.php" );
30
31 $ini =& eZINI::instance( 'site.ini' );
32
33 $Language = $ini->variable( "eZPollMain", "Language" );
34 $DOC_ROOT = $ini->variable( "eZPollMain", "DocumentRoot" );
35 if ( $ini->variable( "eZPollMain", "AllowDoubleVotes" ) == "enabled" )
36 $AllowDoubleVotes = true;
37
38
39 // include_once( "ezpoll/classes/ezpoll.php" );
40 // include_once( "ezpoll/classes/ezvote.php" );
41 // include_once( "ezpoll/classes/ezpollchoice.php" );
42 // include_once( "ezsession/classes/ezsession.php" );
43
44 $session =& eZSession::globalSession();
45
46 if( !$session->fetch() )
47 $session->store();
48
49 // Check if poll is closed.
50 $poll = new eZPoll( $PollID );
51 if ( $poll->isClosed() )
52 {
53 eZHTTPTool::header( "Location: /poll/result/$PollID" );
54 exit();
55 }
56
57 // Check if the poll is anonymous or not.
58 $poll = new eZPoll( $PollID );
59 if ( !$poll->anonymous() )
60 {
61 $pollUser =& eZUser::currentUser();
62 if ( !$pollUser )
63 {
64 eZHTTPTool::header( "Location: /user/user/new/" );
65 exit();
66 }
67 }
68 else
69 {
70
71 $vote = new eZVote();
72 //check if user has or can vote twice
73
74 if ( $AllowDoubleVotes )
75 {
76 $Voted = false;
77 }
78 else
79 {
80 if ( $ini->variable( "eZPollMain", "DoubleVoteCheck" ) == "ip" )
81 {
82 if ( $vote->ipHasVoted( $REMOTE_ADDR, $PollID ) == true )
83 {
84 $Voted = true;
85 }
86 else
87 {
88 $Voted = false;
89 }
90 }
91 else
92 {
93 if ( $GLOBALS["eZPollVote$PollID"] == "voted" )
94 {
95 $Voted = true;
96 }
97 else
98 {
99 $Voted = false;
100 }
101
102 setcookie ( "eZPollVote$PollID", "voted", time() + ( 3600 * 24 * 365 ), "/", "", 0 )
103 or print( "Error: could not set cookie." );
104 }
105
106 }
107
108 }
109
110 if ( $pollUser )
111 {
112 $checkvote = new eZVote();
113 if ( $checkvote->isVoted( $pollUser->id(), $PollID ))
114 $Voted = true;
115 else
116 $Voted = false;
117 }
118
119 if ( !$Voted )
120 {
121 $vote = new eZVote();
122 $vote->setPollID( $PollID );
123 $vote->setChoiceID( $ChoiceID );
124 $vote->setVotingIP( $REMOTE_ADDR );
125 if ( $pollUser )
126 $vote->setUserID( $pollUser->id() );
127 if ( !$ChoiceID == 0 )
128 $vote->store();
129 }
130
131 eZHTTPTool::header( "Location: /poll/result/" . $PollID );
132 exit();
133
134 ?>
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZPoll
Definition: ezpoll.php:64
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
eZVote
Definition: ezvote.php:46
$ChoiceID
$ChoiceID
Definition: ezresponsebool.php:186
exit
exit
Definition: folder.php:81
$poll
$poll
Definition: vote.php:50
$DOC_ROOT
$DOC_ROOT
Definition: vote.php:34
$Language
$Language
Definition: vote.php:33
$ini
$ini
Definition: vote.php:31
$session
$session
Definition: vote.php:44
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.