Version 2.0.0
This commit is contained in:
1 parent
5699abfc0e
commit
0eecc172d9
696 files changed
+120723
-77160
No files matched your search
@@ -2,21 +2,21 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Add POLL module
|
||||
| > Module written by Matt Mecham
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
|
|
||||
@@ -28,10 +28,13 @@
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
|
||||
exit();
|
||||
}
|
||||
|
||||
$idx = new Poll;
|
||||
|
||||
class Poll {
|
||||
class poll {
|
||||
|
||||
|
||||
var $topic = array();
|
||||
@@ -40,8 +43,7 @@ class Poll {
|
||||
var $poll_count = 0;
|
||||
var $poll_choices = "";
|
||||
|
||||
function Poll() {
|
||||
|
||||
function auto_run() {
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_post', $ibforums->lang_id);
|
||||
@@ -65,15 +67,18 @@ class Poll {
|
||||
|
||||
// Make sure we have a valid poll id
|
||||
|
||||
$ibforums->input[t] = $std->is_number($ibforums->input[t]);
|
||||
if (! $ibforums->input[t] ) {
|
||||
$ibforums->input['t'] = intval($ibforums->input['t']);
|
||||
|
||||
if (! $ibforums->input['t'] )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
|
||||
}
|
||||
|
||||
// Load the topic and poll
|
||||
|
||||
$DB->query("SELECT f.allow_pollbump, t.*, p.pid as poll_id,p.choices,p.starter_id,p.votes from ibf_polls p, ibf_topics t, ibf_forums f WHERE t.tid='".$ibforums->input['t']."' and p.tid=t.tid and t.forum_id=f.id");
|
||||
|
||||
$DB->cache_add_query( 'poll_get_poll_with_topic', array( 'tid' => $ibforums->input['t'] ) );
|
||||
$DB->cache_exec_query();
|
||||
|
||||
$this->topic = $DB->fetch_row();
|
||||
|
||||
if (! $this->topic['tid'] )
|
||||
@@ -85,9 +90,11 @@ class Poll {
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
|
||||
}
|
||||
|
||||
// Have we voted before?
|
||||
|
||||
$DB->query("SELECT member_id from ibf_voters WHERE tid='".$this->topic['tid']."' and member_id='".$ibforums->member['id']."'");
|
||||
$DB->simple_construct( array( 'select' => 'member_id', 'from' => 'voters', 'where' => "tid={$this->topic['tid']} and member_id=".$ibforums->member['id'] ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
if ( $DB->get_num_rows() )
|
||||
{
|
||||
@@ -96,23 +103,16 @@ class Poll {
|
||||
|
||||
// If we're here, lets add the vote
|
||||
|
||||
|
||||
$db_string = $std->compile_db_string(
|
||||
array (
|
||||
'member_id' => $ibforums->member['id'],
|
||||
'ip_address' => $ibforums->input['IP_ADDRESS'],
|
||||
'tid' => $this->topic['tid'],
|
||||
'forum_id' => $this->topic['forum_id'],
|
||||
'vote_date' => time(),
|
||||
)
|
||||
);
|
||||
$DB->do_insert( 'voters', array( 'member_id' => $ibforums->member['id'],
|
||||
'ip_address' => $ibforums->input['IP_ADDRESS'],
|
||||
'tid' => $this->topic['tid'],
|
||||
'forum_id' => $this->topic['forum_id'],
|
||||
'vote_date' => time(),
|
||||
) );
|
||||
|
||||
$DB->query("INSERT INTO ibf_voters (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
|
||||
|
||||
// If this isn't a null vote...
|
||||
|
||||
if (!$ibforums->input['nullvote'])
|
||||
if ( ! $ibforums->input['nullvote'] )
|
||||
{
|
||||
$poll_answers = unserialize(stripslashes($this->topic['choices']));
|
||||
reset($poll_answers);
|
||||
@@ -133,40 +133,29 @@ class Poll {
|
||||
|
||||
$this->topic['choices'] = addslashes(serialize($new_poll_array));
|
||||
|
||||
$DB->query("UPDATE ibf_polls SET ".
|
||||
"votes=votes+1, ".
|
||||
"choices='" . $this->topic['choices'] . "' ".
|
||||
"WHERE pid='" . $this->topic['poll_id'] . "'");
|
||||
$DB->simple_exec_query( array( 'update' => 'polls',
|
||||
'set' => "votes=votes+1,choices='{$this->topic['choices']}'",
|
||||
'where' => "pid={$this->topic['poll_id']}" ) );
|
||||
|
||||
|
||||
if ($this->topic['allow_pollbump'])
|
||||
{
|
||||
|
||||
$this->topic['last_vote'] = time();
|
||||
$this->topic['last_post'] = time();
|
||||
|
||||
$DB->query("UPDATE ibf_topics SET ".
|
||||
"last_vote='" . $this->topic['last_vote'] . "', ".
|
||||
"last_post='" . $this->topic['last_post'] . "' ".
|
||||
"WHERE tid='" . $this->topic['tid'] . "'");
|
||||
|
||||
|
||||
$DB->do_update( 'topics', array( 'last_vote' => $this->topic['last_vote'], 'last_post' => $this->topic['last_post'] ), 'tid='.$this->topic['tid'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->topic['last_vote'] = time();
|
||||
|
||||
$DB->query("UPDATE ibf_topics SET ".
|
||||
"last_vote='" . $this->topic['last_vote'] . "', ".
|
||||
"last_post='" . $this->topic['last_post'] . "' ".
|
||||
"WHERE tid='" . $this->topic['tid'] . "'");
|
||||
|
||||
$DB->do_update( 'topics', array( 'last_vote' => $this->topic['last_vote'], 'last_post' => $this->topic['last_post'] ), 'tid='.$this->topic['tid'] );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$lang = $ibforums->input['nullvote'] ? $ibforums->lang['poll_viewing_results'] : $ibforums->lang['poll_vote_added'];
|
||||
|
||||
$print->redirect_screen( $lang , "act=ST&f={$this->topic['forum_id']}&t={$this->topic['tid']}" );
|
||||
$print->redirect_screen( $lang , "act=ST&f={$this->topic['forum_id']}&t={$this->topic['tid']}&st={$ibforums->input['st']}" );
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user