📄 add_poll.php
字号:
<?php
class poll
{
var $topic = array( );
var $poll = array( );
var $upload = array( );
var $poll_count = 0;
var $poll_choices = "";
function poll( )
{
global $ibforums;
global $std;
global $DB;
global $print;
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_post", $ibforums->lang_id );
if ( !$ibforums->member['g_vote_polls'] )
{
$std->error( array( 1, "no_reply_polls" ) );
}
if ( !$ibforums->input['nullvote'] && !isset( $ibforums->input['poll_vote'] ) )
{
$std->error( array( 1, "no_vote" ) );
}
$ibforums->input[t] = $std->is_number( $ibforums->input[t] );
if ( !$ibforums->input[t] )
{
$std->error( array( 1, "missing_files" ) );
}
$DB->query( "SELECT t.*, p.pid as poll_id,p.choices,p.starter_id,p.votes from ibf_polls p, ibf_topics t WHERE t.tid='".$ibforums->input['t']."' and p.tid=t.tid" );
$this->topic = $DB->fetch_row( );
if ( !$this->topic['tid'] )
{
$std->error( array( 1, "poll_none_found" ) );
}
if ( $this->topic['state'] != "open" )
{
$std->error( array( 1, "locked_topic" ) );
}
$DB->query( "SELECT member_id from ibf_voters WHERE tid='".$this->topic['tid']."' and member_id='".$ibforums->member['id']."'" );
if ( $DB->get_num_rows( ) )
{
$std->error( array( 1, "poll_you_voted" ) );
}
$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->query( "INSERT INTO ibf_voters (".$db_string['FIELD_NAMES'].") VALUES (".$db_string['FIELD_VALUES'].")" );
if ( !$ibforums->input['nullvote'] )
{
$poll_answers = unserialize( stripslashes( $this->topic['choices'] ) );
reset( $poll_answers );
$new_poll_array = array( );
foreach ( $poll_answers as $entry )
{
$id = $entry[0];
$choice = $entry[1];
$votes = $entry[2];
if ( $id == $ibforums->input['poll_vote'] )
{
++$votes;
}
$new_poll_array[] = array(
$id,
$choice,
$votes
);
}
$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']."'" );
if ( $ibforums->vars['allow_poll_bump'] )
{
$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']."'" );
}
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']."'" );
}
}
$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']}" );
}
}
$idx = new poll( );
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -