$Date: 2008-10-02 12:04:59 -0400 (Thu, 02 Oct 2008) $
| > $Revision: 2573 $
| > $Author: matt $
+---------------------------------------------------------------------------
|
| > Post Class
| > Module written by Matt Mecham
| > Date started: Wednesday 9th March 2005 (15:23)
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_IPB' ) )
{
print "
Incorrect access
You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class class_post
{
# Classes
var $ipsclass;
var $parser;
var $email;
var $han_editor;
var $class_attach;
var $output = "";
var $base_url = "";
var $html = "";
var $moderator = array();
var $forum = array();
var $topic = array();
var $category = array();
var $mem_groups = array();
var $mem_titles = array();
var $obj = array();
var $times = array( 'open' => NULL, 'close' => NULL );
var $root_path = '';
var $md5_check = "";
var $module = "";
var $attach_sum = -1;
var $is_merging_posts = 0;
var $cur_post_attach = array();
# Permissions
var $can_add_poll = 0;
var $max_poll_questions = 0;
var $max_poll_choices_per_question = 0;
var $can_upload = 0;
var $can_edit_poll = 0;
var $poll_total_votes = 0;
var $can_set_close_time = 0;
var $can_set_open_time = 0;
/*-------------------------------------------------------------------------*/
// INIT
/*-------------------------------------------------------------------------*/
function load_classes()
{
//-----------------------------------------
// Load and config the post parser
//-----------------------------------------
require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );
$this->parser = new parse_bbcode();
$this->parser->ipsclass =& $this->ipsclass;
$this->parser->allow_update_caches = 1;
$this->parser->bypass_badwords = intval($this->ipsclass->member['g_bypass_badwords']);
//-----------------------------------------
// Load and config the std/rte editors
//-----------------------------------------
require_once( ROOT_PATH."sources/handlers/han_editor.php" );
$this->han_editor = new han_editor();
$this->han_editor->ipsclass =& $this->ipsclass;
$this->han_editor->init();
//-----------------------------------------
// Load the email libby
//-----------------------------------------
require_once( ROOT_PATH."sources/classes/class_email.php" );
$this->email = new emailer();
$this->email->ipsclass =& $this->ipsclass;
$this->email->email_init();
//-----------------------------------------
// Compile the language file
//-----------------------------------------
$this->ipsclass->load_language('lang_post');
$this->ipsclass->load_template('skin_post');
}
/*-------------------------------------------------------------------------*/
// Build permissions
/*-------------------------------------------------------------------------*/
function convert_open_close_times()
{
//-----------------------------------------
// OPEN...
//-----------------------------------------
$_POST['open_time_date'] = isset($_POST['open_time_date']) ? $_POST['open_time_date'] : NULL;
$_POST['open_time_time'] = isset($_POST['open_time_time']) ? $_POST['open_time_time'] : NULL;
$_POST['close_time_date'] = isset($_POST['close_time_date']) ? $_POST['close_time_date'] : NULL;
$_POST['close_time_time'] = isset($_POST['close_time_time']) ? $_POST['close_time_time'] : NULL;
if ( $this->can_set_open_time AND $_POST['open_time_date'] AND $_POST['open_time_time'] )
{
list( $month, $day, $year ) = explode( "/", $_POST['open_time_date'] );
list( $hour , $minute ) = explode( ":", $_POST['open_time_time'] );
if ( checkdate( $month, $day, $year ) )
{
$this->times['open'] = $this->ipsclass->convert_local_date_to_unix( array( 'month' => intval($month),
'day' => intval($day),
'year' => intval($year),
'hour' => intval($hour),
'minute' => intval($minute) ) );
}
}
//-----------------------------------------
// CLOSE...
//-----------------------------------------
if ( $this->can_set_open_time AND $_POST['close_time_date'] AND $_POST['close_time_time'] )
{
list( $month, $day, $year ) = explode( "/", $_POST['close_time_date'] );
list( $hour , $minute ) = explode( ":", $_POST['close_time_time'] );
if ( checkdate( $month, $day, $year ) )
{
$this->times['close'] = $this->ipsclass->convert_local_date_to_unix( array( 'month' => intval($month),
'day' => intval($day),
'year' => intval($year),
'hour' => intval($hour),
'minute' => intval($minute) ) );
}
}
}
/*-------------------------------------------------------------------------*/
// Build permissions
/*-------------------------------------------------------------------------*/
function build_permissions()
{
//-----------------------------------------
// Can we upload files?
//-----------------------------------------
if ( $this->ipsclass->check_perms($this->forum['upload_perms']) == TRUE )
{
if ( $this->ipsclass->member['g_attach_max'] != -1 )
{
$this->can_upload = 1;
$this->obj['form_extra'] = " enctype='multipart/form-data'";
$this->obj['hidden_field'] = "";
}
}
//-----------------------------------------
// Allowed poll?
//-----------------------------------------
$this->can_add_poll = intval($this->ipsclass->member['g_post_polls']);
$this->max_poll_choices_per_question = intval($this->ipsclass->vars['max_poll_choices']);
$this->max_poll_questions = intval($this->ipsclass->vars['max_poll_questions']);
$this->can_edit_poll = ( $this->ipsclass->member['g_is_supmod'] ) ? $this->ipsclass->member['g_is_supmod'] : ( isset($this->ipsclass->member['_moderator'][ $this->forum['id'] ]['edit_post']) ? intval( $this->ipsclass->member['_moderator'][ $this->forum['id'] ]['edit_post'] ) : 0 );
if ( ! $this->max_poll_questions )
{
$this->can_add_poll = 0;
}
if ( ! $this->forum['allow_poll'] )
{
$this->can_add_poll = 0;
}
//-----------------------------------------
// Are we a moderator?
//-----------------------------------------
if ( $this->ipsclass->member['id'] != 0 and $this->ipsclass->member['g_is_supmod'] == 0 )
{
$this->moderator = isset($this->ipsclass->member['_moderator'][ $this->forum['id'] ]) ? $this->ipsclass->member['_moderator'][ $this->forum['id'] ] : NULL;
}
//-----------------------------------------
// Set open and close time
//-----------------------------------------
$this->can_set_open_time = ( $this->ipsclass->member['g_is_supmod'] ) ? $this->ipsclass->member['g_is_supmod'] : ( isset($this->ipsclass->member['_moderator'][ $this->forum['id'] ]['mod_can_set_open_time']) ? intval( $this->ipsclass->member['_moderator'][ $this->forum['id'] ]['mod_can_set_open_time'] ) : 0 );
$this->can_set_close_time = ( $this->ipsclass->member['g_is_supmod'] ) ? $this->ipsclass->member['g_is_supmod'] : ( isset($this->ipsclass->member['_moderator'][ $this->forum['id'] ]['mod_can_set_close_time']) ? intval( $this->ipsclass->member['_moderator'][ $this->forum['id'] ]['mod_can_set_close_time'] ) : 0 );
}
/*-------------------------------------------------------------------------*/
// Show post preview
/*-------------------------------------------------------------------------*/
function show_post_preview( $t="", $post_key='' )
{
$this->parser->parse_html = (intval($this->ipsclass->input['post_htmlstatus']) AND $this->forum['use_html'] AND $this->ipsclass->member['g_dohtml']) ? 1 : 0;
$this->parser->parse_nl2br = $this->ipsclass->input['post_htmlstatus'] == 2 ? 1 : 0;
$this->parser->parse_smilies = intval($this->ipsclass->input['enableemo']);
$this->parser->parse_bbcode = $this->forum['use_ibc'];
# Make sure we have the pre-edit look
$t = $this->parser->pre_display_parse( $t );
//-----------------------------------------
// Attachments?
//-----------------------------------------
$attach_pids = array();
preg_match_all( "#\[attachment=(\d+?)\:(?:[^\]]+?)\]#is", $t, $match );
if ( is_array( $match[0] ) and count( $match[0] ) )
{
for ( $i = 0 ; $i < count( $match[0] ) ; $i++ )
{
if ( intval($match[1][$i]) == $match[1][$i] )
{
$attach_pids[ $match[1][$i] ] = $match[1][$i];
}
}
}
//-----------------------------------------
// Got any?
//-----------------------------------------
if ( count( $attach_pids ) )
{
if ( ! is_object( $this->class_attach ) )
{
//-----------------------------------------
// Grab render attach class
//-----------------------------------------
require_once( ROOT_PATH . 'sources/classes/attach/class_attach.php' );
$this->class_attach = new class_attach();
$this->class_attach->ipsclass =& $this->ipsclass;
$this->class_attach->attach_post_key = $post_key;
}
$this->ipsclass->load_template( 'skin_topic' );
$this->class_attach->type = 'post';
$this->class_attach->init();
$t = $this->class_attach->render_attachments( $t, $attach_pids );
}
return $t;
}
/*-------------------------------------------------------------------------*/
// Get navigation
/*-------------------------------------------------------------------------*/
function show_post_navigation()
{
$this->nav = $this->ipsclass->forums->forums_breadcrumb_nav( $this->forum['id'] );
if ( isset($this->topic['tid']) AND $this->topic['tid'] )
{
$this->nav[] = "{$this->topic['title']}";
}
}
/*-------------------------------------------------------------------------*/
// Notify new topic mod Q
/*-------------------------------------------------------------------------*/
function notify_new_topic_approval($tid, $title, $author, $pid=0, $type='new')
{
$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'notify_modq_emails', 'from' => 'forums', 'where' => "id=".$this->forum['id']) );
if ( $tmp['notify_modq_emails'] == "" )
{
return;
}
if ( $type == 'new' )
{
$this->email->get_template("new_topic_queue_notify");
}
else
{
$this->email->get_template("new_post_queue_notify");
}
$this->email->build_message( array(
'TOPIC' => $title,
'FORUM' => $this->forum['name'],
'POSTER' => $author,
'DATE' => $this->ipsclass->get_date( time(), 'SHORT', 1 ),
'LINK' => $this->ipsclass->vars['board_url'].'/index.'.$this->ipsclass->vars['php_ext'].'?act=findpost&pid='.$pid,
)
);
$email_message = $this->email->message;
foreach( explode( ",", $tmp['notify_modq_emails'] ) as $email )
{
$this->email->message = $email_message;
$this->email->to = trim($email);
$this->email->send_mail();
}
}
/*-------------------------------------------------------------------------*/
// topic tracker
// ------------------
// Checks and sends out the emails as needed.
/*-------------------------------------------------------------------------*/
function topic_tracker($tid="", $post="", $poster="", $last_post="" )
{
if ($tid == "")
{
return TRUE;
}
$count = 0;
//-----------------------------------------
// Get the email addy's, topic ids and email_full stuff - oh yeah.
// We only return rows that have a member last_activity of greater than the post itself
// Ergo:
// Last topic post: 8:50am
// Last topic visit: 9:00am
// Next topic reply: 9:10am
// if ( last.activity > last.topic.post ) { send.... }
// Next topic reply: 9:20am
// if ( last.activity > last.topic.post ) { will fail as 9:10 > 8:50 }
//-----------------------------------------
$this->ipsclass->DB->cache_add_query( 'post_topic_tracker', array( 'tid' => $tid, 'mid' => $this->ipsclass->member['id'], 'last_post' => $last_post ) );
$outer = $this->ipsclass->DB->simple_exec();
if ( $this->ipsclass->DB->get_num_rows($outer) )
{
$trids = array();
while ( $r = $this->ipsclass->DB->fetch_row($outer) )
{
//-----------------------------------------
// Test for group permissions
//-----------------------------------------
$mgroup_others = "";
$temp_mgroups = array();
$mgroup_perms = array();
if( $r['mgroup_others'] )
{
$r['mgroup_others'] = $this->ipsclass->clean_perm_string( $r['mgroup_others'] );
$temp_mgroups = explode( ",", $r['mgroup_others'] );
if( count($temp_mgroups) )
{
foreach( $temp_mgroups as $other_mgroup )
{
$mgroup_perms[] = $this->ipsclass->cache['group_cache'][ $other_mgroup ]['g_perm_id'];
}
}
if( count($mgroup_perms) )
{
$mgroup_others = ",".implode( ",", $mgroup_perms ).",";
}
}
$perm_id = ( $r['org_perm_id'] ) ? $r['org_perm_id'] : $this->ipsclass->cache['group_cache'][ $r['mgroup'] ]['g_perm_id'].$mgroup_others;
// INIT
$permissions = array();
$tmp_perms = array();
$forum_perms = array();
$tmp_perms = explode( ",", $perm_id );
if( is_array($tmp_perms) )
{
foreach( $tmp_perms as $v )
{
if( $v != "" )
{
$permissions[] = $v;
}
}
unset($tmp_perms);
}
else
{
$permissions[] = $perm_id;
}
if ($this->forum['read_perms'] != '*')
{
$pass = 0;
$forum_perms = explode( ",", $this->forum['read_perms'] );
foreach( $permissions as $v )
{
if( in_array( $v, $forum_perms ) )
{
$pass = 1;
}
}
if ( $pass == 0 )
{
continue;
}
}
unset($permissions);
unset($forum_perms);
//-----------------------------------------
// Test for approved/approve perms
//-----------------------------------------
if( $r['approved'] == 0 )
{
$mod = 0;
if( $this->ipsclass->cache['group_cache'][$r['mgroup']]['g_is_supmod'] == 1 )
{
$mod = 1;
}
else if ( count($this->ipsclass->cache['moderators']) )
{
$other_mgroups = array();
if( $this->member['mgroup_others'] )
{
$other_mgroups = explode( ",", $this->ipsclass->clean_perm_string( $this->member['mgroup_others'] ) );
}
foreach( $this->ipsclass->cache['moderators'] as $moderators )
{
if ( $moderators['member_id'] == $r['id'] or $moderators['group_id'] == $r['mgroup'] )
{
$mod = 1;
}
else if( count($other_mgroups) AND in_array( $moderators['group_id'], $other_mgroups ) )
{
$mod = 1;
}
}
}
if( $mod == 0 )
{
continue;
}
}
// Only send one email until user logs in again...
// That is, unless they want the full post
if( $r['last_sent'] > $r['last_activity'] AND !$r['email_full'] )
{
continue;
}
else
{
$this->ipsclass->DB->do_update( "tracker", array( 'last_sent' => time() ), "trid=".$r['trid'] );
}
$count++;
$r['language'] = $r['language'] ? $r['language'] : 'en';
if ($r['email_full'] == 1)
{
$this->email->get_template("subs_with_post", $r['language']);
$this->email->build_message( array(
'TOPIC_ID' => $r['topic_id'],
'FORUM_ID' => $r['forum_id'],
'TITLE' => $r['title'],
'NAME' => $r['members_display_name'],
'POSTER' => $poster,
'POST' => $post,
)
);
}
else
{
$this->email->get_template("subs_no_post", $r['language']);
$this->email->build_message( array(
'TOPIC_ID' => $r['topic_id'],
'FORUM_ID' => $r['forum_id'],
'TITLE' => $r['title'],
'NAME' => $r['members_display_name'],
'POSTER' => $poster,
)
);
}
$trids[] = $r['trid'];
//-----------------------------------------
// Add to mail queue
//-----------------------------------------
$this->ipsclass->DB->do_insert( 'mail_queue', array( 'mail_to' => $r['email'], 'mail_date' => time(), 'mail_subject' => $this->email->lang_subject, 'mail_content' => $this->email->message ) );
}
$this->ipsclass->cache['systemvars']['mail_queue'] += $count;
//-----------------------------------------
// Update cache with remaning email count
//-----------------------------------------
$this->ipsclass->update_cache( array( 'array' => 1, 'name' => 'systemvars', 'donow' => 1, 'deletefirst' => 0 ) );
}
return TRUE;
}
/*-------------------------------------------------------------------------*/
// Forum tracker
/*-------------------------------------------------------------------------*/
function forum_tracker($fid="", $this_tid="", $title="", $forum_name="", $post="", $mid=0, $mname="")
{
if ($this_tid == "")
{
return TRUE;
}
if ($fid == "")
{
return TRUE;
}
$mid = $mid > 0 ? $mid : $this->ipsclass->member['id'];
$mname = $mname != '' ? $mname : $this->ipsclass->member['members_display_name'];
//-----------------------------------------
// Work out the time stamp needed to "guess"
// if the user is still active on the board
// We will base this guess on a period of
// non activity of time_now - 30 minutes.
//-----------------------------------------
$time_limit = time() - (30*60);
$count = 0;
$gotem = array();
$this->ipsclass->DB->build_query( array( 'select' => 'tr.frid, tr.last_sent',
'from' => array( 'forum_tracker' => 'tr' ),
'where' => 'tr.forum_id='.$fid." AND ( ( tr.forum_track_type='delayed' AND m.last_activity < {$time_limit} ) OR tr.forum_track_type='immediate' )",
'add_join' => array( 0 => array( 'select' => 'm.members_display_name, m.email, m.id, m.language, m.last_activity, m.org_perm_id, m.mgroup_others',
'from' => array( 'members' => 'm' ),
'where' => "tr.member_id=m.id AND m.id <> {$mid}",
'type' => 'inner' ),
1 => array( 'select' => 'g.g_perm_id',
'from' => array( 'groups' => 'g' ),
'where' => "m.mgroup=g.g_id",
'type' => 'left' ) )
) );
$outer = $this->ipsclass->DB->exec_query();
while ( $r = $this->ipsclass->DB->fetch_row($outer) )
{
$this->ipsclass->DB->do_update( "forum_tracker", array( 'last_sent' => time() ), "frid=".$r['frid'] );
$gotem[ $r['id'] ] = $r;
}
//-----------------------------------------
// Get "all" groups?
//-----------------------------------------
if ( $this->ipsclass->vars['autoforum_sub_groups'] )
{
$this->ipsclass->DB->build_query( array( 'select' => 'm.name, m.email, m.id, m.language, m.last_activity, m.org_perm_id, m.mgroup_others',
'from' => array( 'members' => 'm' ),
'where' => "m.mgroup IN ({$this->ipsclass->vars['autoforum_sub_groups']})
AND m.id <> {$mid}
AND m.allow_admin_mails=1
AND m.last_activity < {$time_limit}",
'add_join' => array( 0 => array( 'select' => 'g.g_perm_id',
'from' => array( 'groups' => 'g' ),
'where' => "m.mgroup=g.g_id",
'type' => 'left' ) )
) );
$this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
$gotem[ $r['id'] ] = $r;
}
}
//-----------------------------------------
// Row, row and parse, parse
//-----------------------------------------
if ( count( $gotem ) )
{
foreach( $gotem as $mid => $r )
{
$count++;
$mgroup_others = "";
$temp_mgroups = array();
$mgroup_perms = array();
if( $r['mgroup_others'] )
{
$r['mgroup_others'] = $this->ipsclass->clean_perm_string( $r['mgroup_others'] );
$temp_mgroups = explode( ",", $r['mgroup_others'] );
if( count($temp_mgroups) )
{
foreach( $temp_mgroups as $other_mgroup )
{
$mgroup_perms[] = $this->ipsclass->cache['group_cache'][ $other_mgroup ]['g_perm_id'];
}
}
if( count($mgroup_perms) )
{
$mgroup_others = ",".implode( ",", $mgroup_perms ).",";
}
}
$perm_id = ( $r['org_perm_id'] ) ? $r['org_perm_id'] : $r['g_perm_id'].$mgroup_others;
//$perm_id = ( $r['org_perm_id'] ) ? $r['org_perm_id'] : $r['g_perm_id'];
// INIT
$permissions = array();
$tmp_perms = array();
$forum_perms = array();
$tmp_perms = explode( ",", $perm_id );
if( is_array($tmp_perms) )
{
foreach( $tmp_perms as $v )
{
if( $v != "" )
{
$permissions[] = $v;
}
}
unset($tmp_perms);
}
else
{
$permissions[] = $perm_id;
}
if ($this->forum['read_perms'] != '*')
{
$pass = 0;
$forum_perms = explode( ",", $this->forum['read_perms'] );
foreach( $permissions as $v )
{
if( in_array( $v, $forum_perms ) )
{
$pass = 1;
}
}
if ( $pass == 0 )
{
continue;
}
}
unset($permissions);
unset($forum_perms);
$r['language'] = $r['language'] ? $r['language'] : 'en';
$this->email->get_template("subs_new_topic", $r['language']);
$this->email->build_message( array(
'TOPIC_ID' => $this_tid,
'FORUM_ID' => $fid,
'TITLE' => $title,
'NAME' => $r['members_display_name'],
'POSTER' => $mname,
'FORUM' => $forum_name,
'POST' => $post,
)
);
$this->ipsclass->DB->do_insert( 'mail_queue', array( 'mail_to' => $r['email'], 'mail_date' => time(), 'mail_subject' => $this->email->lang_subject, 'mail_content' => $this->email->message ) );
}
}
$this->ipsclass->cache['systemvars']['mail_queue'] += $count;
//-----------------------------------------
// Update cache with remaning email count
//-----------------------------------------
$this->ipsclass->update_cache( array( 'array' => 1, 'name' => 'systemvars', 'donow' => 1, 'deletefirst' => 0 ) );
return TRUE;
}
/*-------------------------------------------------------------------------*/
// Compile poll
/*-------------------------------------------------------------------------*/
function compile_poll()
{
//-----------------------------------------
// Check poll
//-----------------------------------------
$questions = array();
$choices_count = 0;
$is_mod = $this->ipsclass->member['g_is_supmod'] ? $this->ipsclass->member['g_is_supmod'] : ( isset($this->moderator['edit_topic']) ? intval($this->moderator['edit_topic']) : 0);
if ( $this->can_add_poll )
{
if ( isset($_POST['question']) AND is_array( $_POST['question'] ) and count( $_POST['question'] ) )
{
$has_poll = 1;
foreach( $_POST['question'] as $id => $q )
{
if ( ! $q OR ! $id )
{
continue;
}
$questions[ $id ]['question'] = $this->parser->bad_words( $this->ipsclass->parse_clean_value( $q ) );
}
}
if ( isset($_POST['multi']) AND is_array( $_POST['multi'] ) and count( $_POST['multi'] ) )
{
foreach( $_POST['multi'] as $id => $q )
{
if ( ! $q OR ! $id )
{
continue;
}
$questions[ $id ]['multi'] = intval($q);
}
}
//-----------------------------------------
// Choices...
//-----------------------------------------
if ( isset($_POST['choice']) AND is_array( $_POST['choice'] ) and count( $_POST['choice'] ) )
{
foreach( $_POST['choice'] as $mainid => $choice )
{
list( $question_id, $choice_id ) = explode( "_", $mainid );
$question_id = intval( $question_id );
$choice_id = intval( $choice_id );
if ( ! $question_id OR ! isset($choice_id) )
{
continue;
}
if ( ! $questions[ $question_id ]['question'] )
{
continue;
}
$questions[ $question_id ]['choice'][ $choice_id ] = $this->parser->bad_words( $this->ipsclass->parse_clean_value( $choice ) );
if ( ! $is_mod )
{
$questions[ $question_id ]['votes'][ $choice_id ] = intval($this->poll_answers[ $question_id ]['votes'][ $choice_id ]);
}
else
{
$_POST['votes'] = isset($_POST['votes']) ? $_POST['votes'] : 0;
$questions[ $question_id ]['votes'][ $choice_id ] = intval( $_POST['votes'][ $question_id.'_'.$choice_id ] );
}
$this->poll_total_votes += $questions[ $question_id ]['votes'][ $choice_id ];
}
}
//-----------------------------------------
// Make sure we have choices for each
//-----------------------------------------
foreach( $questions as $id => $data )
{
if ( ! is_array( $data['choice'] ) OR ! count( $data['choice'] ) )
{
unset( $questions[ $id ] );
}
else
{
$choices_count += intval( count( $data['choice'] ) );
}
}
//-----------------------------------------
// Error check...
//-----------------------------------------
if ( count( $questions ) > $this->max_poll_questions )
{
$this->obj['post_errors'] = 'poll_to_many';
}
if ( count( $choices_count ) > ( $this->max_poll_questions * $this->max_poll_choices_per_question ) )
{
$this->obj['post_errors'] = 'poll_to_many';
}
}
return $questions;
}
/*-------------------------------------------------------------------------*/
// compile post
// ------------------
// Compiles all the incoming information into an array
// which is returned to the accessor
/*-------------------------------------------------------------------------*/
function compile_post()
{
$this->ipsclass->vars['max_post_length'] = $this->ipsclass->vars['max_post_length'] ? $this->ipsclass->vars['max_post_length'] : 2140000;
//-----------------------------------------
// Sort out some of the form data, check for posting length, etc.
// THIS MUST BE CALLED BEFORE CHECKING ATTACHMENTS
//-----------------------------------------
$this->ipsclass->input['enablesig'] = (isset($this->ipsclass->input['enablesig']) AND $this->ipsclass->input['enablesig']) == 'yes' ? 1 : 0;
$this->ipsclass->input['enableemo'] = (isset($this->ipsclass->input['enableemo']) AND $this->ipsclass->input['enableemo']) == 'yes' ? 1 : 0;
$this->ipsclass->input['enabletrack'] = (isset($this->ipsclass->input['enabletrack']) AND intval($this->ipsclass->input['enabletrack']) != 0) ? 1 : 0;
//-----------------------------------------
// Do we have a valid post?
//-----------------------------------------
if ( strlen( trim( $this->ipsclass->my_br2nl( $_POST['Post'] ) ) ) < 1 )
{
if ( ! $_POST['preview'] )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_post') );
}
}
if ( strlen( $_POST['Post'] ) > ( $this->ipsclass->vars['max_post_length'] * 1024 ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'post_too_long') );
}
//-----------------------------------------
// Remove board tags
//-----------------------------------------
$this->ipsclass->input['Post'] = $this->ipsclass->remove_tags( $this->ipsclass->input['Post'] );
//-----------------------------------------
// Post process the editor
// Now we have safe HTML and bbcode
//-----------------------------------------
if ( isset($_POST['fast_reply_used']) AND $_POST['fast_reply_used'] )
{
if ( $this->han_editor->method == 'rte' && $this->ipsclass->can_use_fancy_js )
{
//-----------------------------------------
// Fast reply used.. and we've chosen the RTE
// Convert STD to RTE first...
//-----------------------------------------
$_POST['Post'] = $this->parser->convert_std_to_rte( $_POST['Post'] );
}
}
$this->ipsclass->input['Post'] = $this->han_editor->process_raw_post( 'Post' );
//-----------------------------------------
// Parse post
//-----------------------------------------
$this->parser->parse_smilies = $this->ipsclass->input['enableemo'];
$this->parser->parse_html = (intval($this->ipsclass->input['post_htmlstatus']) AND $this->forum['use_html'] AND $this->ipsclass->member['g_dohtml']) ? 1 : 0;
$this->parser->parse_nl2br = intval($this->ipsclass->input['post_htmlstatus']) == 2 ? 1 : 0;
$this->parser->parse_bbcode = $this->forum['use_ibc'];
$this->parser->bypass_badwords = intval($this->ipsclass->member['g_bypass_badwords']);
$post = array(
'author_id' => $this->ipsclass->member['id'] ? $this->ipsclass->member['id'] : 0,
'use_sig' => $this->ipsclass->input['enablesig'],
'use_emo' => $this->ipsclass->input['enableemo'],
'ip_address' => $this->ipsclass->ip_address,
'post_date' => time(),
'icon_id' => isset($this->ipsclass->input['iconid']) ? $this->ipsclass->input['iconid'] : 0,
'post' => $this->parser->pre_display_parse( $this->parser->pre_db_parse( $this->ipsclass->input['Post'] ) ),
'author_name' => $this->ipsclass->member['id'] ? $this->ipsclass->member['members_display_name'] : $this->ipsclass->input['UserName'],
'topic_id' => "",
'queued' => ( isset($this->obj['moderate']) AND ( $this->obj['moderate'] == 1 || $this->obj['moderate'] == 3 ) ) ? 1 : 0,
'post_htmlstate' => isset($this->ipsclass->input['post_htmlstatus']) ? intval($this->ipsclass->input['post_htmlstatus']) : 0,
);
//-----------------------------------------
// If we had any errors, parse them back to this class
// so we can track them later.
//-----------------------------------------
$this->obj['post_errors'] = $this->parser->error;
return $post;
}
/*-------------------------------------------------------------------------*/
// HTML: mod_options.
// ------------------
// Returns the HTML for the mod options drop down box
/*-------------------------------------------------------------------------*/
function mod_options($type='new')
{
$can_close = 0;
$can_pin = 0;
$can_move = 0;
$html = "";
$mytimes = array();
$this->ipsclass->input['mod_options'] = isset($this->ipsclass->input['mod_options']) ? $this->ipsclass->input['mod_options'] : '';
//-----------------------------------------
// Mod options
//-----------------------------------------
if ( $type != 'edit' )
{
if ( $this->ipsclass->member['g_is_supmod'] )
{
$can_close = 1;
$can_pin = 1;
$can_move = 1;
}
else if ( $this->ipsclass->member['id'] != 0 )
{
if ( $this->moderator['mid'] != "" )
{
if ($this->moderator['close_topic'])
{
$can_close = 1;
}
if ($this->moderator['pin_topic'])
{
$can_pin = 1;
}
if ($this->moderator['move_topic'])
{
$can_move = 1;
}
}
}
else
{
// Guest
return "";
}
if ( !($can_pin == 0 and $can_close == 0 and $can_move == 0) )
{
$selected = ($this->ipsclass->input['mod_options'] == 'nowt') ? " selected='selected'" : '';
$html = "