New Post module | > Module written by Matt Mecham | > DBA Checked: Fri 21 May 2004 | +-------------------------------------------------------------------------- */ class post_functions extends Post { var $nav = array(); var $title = ""; var $post = array(); var $topic = array(); var $upload = array(); var $mod_topic = array(); var $poll_count = 0; var $poll_choices = ""; var $m_group = ""; function post_functions($class) { global $ibforums, $std, $DB; //----------------------------------------- // Sort out maximum number of poll choices allowed //----------------------------------------- $ibforums->vars['max_poll_choices'] = $ibforums->vars['max_poll_choices'] ? $ibforums->vars['max_poll_choices'] : 10; $ibforums->lang['poll_choices'] = sprintf( $ibforums->lang['poll_choices'], $ibforums->vars['max_poll_choices'] ); //----------------------------------------- // Lets do some tests to make sure that we are allowed to start a new topic //----------------------------------------- if (! $ibforums->member['g_post_polls']) { $std->Error( array( LEVEL => 1, MSG => 'no_start_polls') ); } if ( ! $class->forum['allow_poll'] ) { $std->Error( array( LEVEL => 1, MSG => 'no_start_polls') ); } if ( $std->check_perms($class->forum['start_perms']) == FALSE ) { $std->Error( array( LEVEL => 1, MSG => 'no_start_polls') ); } if ( ! intval($ibforums->input['t']) ) { $std->Error( array( 'LEVEL' => 1, 'MSG' => 'is_broken_link') ); } else { $tid = intval($ibforums->input['t']); $DB->simple_construct( array('select' => '*', 'from' => 'topics', 'where' => "tid=$tid") ); $DB->simple_exec(); if ( ! $this->topic = $DB->fetch_row() ) { $std->Error( array( 'LEVEL' => 1, 'MSG' => 'is_broken_link') ); } } $pass = 0; if ( $ibforums->member['id'] ) { if ( $ibforums->member['g_is_supmod'] == 1 ) { $pass = 1; } else if ( $this->topic['starter_id'] == $ibforums->member['id'] ) { if ( ($ibforums->vars['startpoll_cutoff'] > 0) AND ( $this->topic['start_date'] + ($ibforums->vars['startpoll_cutoff'] * 3600) > time() ) ) { $pass = 1; } } } if ( $pass != 1 ) { $std->Error( array( LEVEL => 1, MSG => 'no_start_polls') ); } } function process($class) { global $ibforums, $std, $DB, $print; //----------------------------------------- // check to make sure we have a correct # of choices //----------------------------------------- $this->poll_choices = $ibforums->input['PollAnswers']; $this->poll_choices = preg_replace( "#

#" , "" , $this->poll_choices ); $this->poll_choices = preg_replace( "#
#e" , "\$this->regex_count_choices()" , $this->poll_choices ); if ($this->poll_count > $ibforums->vars['max_poll_choices']) { $class->obj['post_errors'] = 'poll_to_many'; } if ($this->poll_count < 1) { $class->obj['post_errors'] = 'poll_not_enough'; } if ($class->obj['post_errors'] != "") { // Show the form again $this->show_form($class); } else { $this->add_new_poll($class); } } function add_new_poll($class) { global $ibforums, $std, $DB, $print; //----------------------------------------- // Sort out the poll stuff // This is somewhat contrived, but it has to be // compatible with the current perl version. //----------------------------------------- $poll_array = array(); $count = 0; $polls = explode( "
", $this->poll_choices ); foreach ($polls as $polling) { if ( $polling == "" ) { continue; } $poll_array[] = array( $count , $class->parser->bad_words($polling), 0 ); $count++; } //----------------------------------------- // Add the poll to the forum_polls table // if we are moderating this post //----------------------------------------- $DB->do_insert( 'polls', array ( 'tid' => $this->topic['tid'], 'forum_id' => $class->forum['id'], 'start_date' => time(), 'choices' => addslashes(serialize($poll_array)), 'starter_id' => $ibforums->member['id'], 'votes' => 0, 'poll_question' => $class->parser->bad_words($ibforums->input['pollq']), ) ); $DB->simple_construct( array( 'update' => 'topics', 'set' => 'poll_state="open"', 'where' => "tid={$this->topic['tid']}" ) ); $DB->simple_exec(); //----------------------------------------- // Redirect them back to the topic //----------------------------------------- $std->boink_it($class->base_url."showtopic={$this->topic['tid']}"); } function show_form($class) { global $ibforums, $std, $DB, $print, $HTTP_POST_VARS; // Sort out the "raw" textarea input and make it safe incase // we have a