Version 1.3.0

This commit is contained in:
Neo committed 2025-12-19 00:17:06 -08:00
1 parent 7ef3d1712a
commit f87d29ba65
290 files changed
+50206 -17930

No files matched your search

+296 -89
View File
@@ -2,15 +2,17 @@
/*
+--------------------------------------------------------------------------
| Invision Board v1.1
| Invision Power Board v1.3 Final
| ========================================
| by Matthew Mecham
| (c) 2001,2002 Invision Power Services
| http://www.ibforums.com
| (c) 2001 - 2003 Invision Power Services
| http://www.invisionpower.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
| Web: http://www.invisionboard.com
| Time: Sun, 04 Jan 2004 00:30:16 GMT
| Release: 28e7bfb25f08ac72a789cb1b172fa185
| Email: matt@invisionpower.com
| Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|
| > Post core module
@@ -39,6 +41,8 @@ class Post {
var $obj = array();
var $email = "";
var $can_upload = 0;
var $md5_check = "";
var $module = "";
/***********************************************************************************/
//
@@ -46,15 +50,18 @@ class Post {
//
/***********************************************************************************/
function Post() {
function Post()
{
global $ibforums, $DB, $std, $print, $skin_universal;
require "./sources/lib/post_parser.php";
require ROOT_PATH."sources/lib/post_parser.php";
$this->parser = new post_parser(1);
require ROOT_PATH."sources/lib/emailer.php";
$this->email = new emailer();
//--------------------------------------
// Compile the language file
//--------------------------------------
@@ -63,13 +70,26 @@ class Post {
$this->html = $std->load_template('skin_post');
//--------------------------------------------
// Get the sync module
//--------------------------------------------
if ( USE_MODULES == 1 )
{
require ROOT_PATH."modules/ipb_member_sync.php";
$this->modules = new ipb_member_sync();
}
//--------------------------------------
// Check the input
//--------------------------------------
$this->md5_check = $std->return_md5_check();
if ($ibforums->input['t'])
{
$ibforums->input['t'] = $std->is_number($ibforums->input['t']);
$ibforums->input['t'] = intval($ibforums->input['t']);
if (! $ibforums->input['t'] )
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
@@ -78,20 +98,20 @@ class Post {
if ($ibforums->input['p'])
{
$ibforums->input['p'] = $std->is_number($ibforums->input['p']);
$ibforums->input['p'] = intval($ibforums->input['p']);
if (! $ibforums->input['p'] )
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
}
$ibforums->input['f'] = $std->is_number($ibforums->input['f']);
$ibforums->input['f'] = intval($ibforums->input['f']);
if (! $ibforums->input['f'] )
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
$ibforums->input['st'] = $ibforums->input['st'] ? $std->is_number($ibforums->input['st']) : 0;
$ibforums->input['st'] = $ibforums->input['st'] ?intval($ibforums->input['st']) : 0;
// Did the user press the "preview" button?
@@ -106,22 +126,14 @@ class Post {
$this->forum = $DB->fetch_row();
if ($this->forum['read_perms'] != '*')
if ( $std->check_perms($this->forum['read_perms']) != TRUE )
{
if (! preg_match("/(^|,)".$ibforums->member['mgroup']."(,|$)/", $this->forum['read_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_view_topic') );
}
$std->Error( array( LEVEL => 1, MSG => 'no_view_topic') );
}
// Can we upload stuff?
if ($this->forum['upload_perms'] == '*')
{
$this->can_upload = 1;
}
else if ( preg_match("/(^|,)".$ibforums->member['mgroup']."(,|$)/", $this->forum['upload_perms'] ) )
if ( $std->check_perms($this->forum['upload_perms']) == TRUE )
{
$this->can_upload = 1;
}
@@ -189,25 +201,49 @@ class Post {
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
$this->base_url = $ibforums->base_url;
//--------------------------------------
// Is this forum moderated?
//--------------------------------------
$this->obj['moderate'] = $this->forum['preview_posts'] ? 1 : 0;
$this->obj['moderate'] = intval($this->forum['preview_posts']);
// Can we bypass it?
if ($ibforums->member['g_avoid_q'])
{
$this->obj['moderate'] = 0;
}
//--------------------------------------
// Does this member have mod_posts enabled?
if ($ibforums->member['mod_posts'] == 1)
{
$this->obj['moderate'] = 1;
}
//--------------------------------------
if ( $ibforums->member['mod_posts'] )
{
if ( $ibforums->member['mod_posts'] == 1 )
{
$this->obj['moderate'] = 1;
}
else
{
$mod_arr = $std->hdl_ban_line( $ibforums->member['mod_posts'] );
if ( time() >= $mod_arr['date_end'] )
{
// Update this member's profile
$DB->query("UPDATE ibf_members SET mod_posts=0 WHERE id=".intval($ibforums->member['id']) );
$this->obj['moderate'] = intval($this->forum['preview_posts']);
}
else
{
$this->obj['moderate'] = 1;
}
}
}
//--------------------------------------
// Are we allowed to post at all?
@@ -215,14 +251,31 @@ class Post {
if ($ibforums->member['id'])
{
if (!$ibforums->member['allow_post'])
if ( $ibforums->member['restrict_post'] )
{
$std->Error( array( LEVEL => 1, MSG => 'posting_off') );
if ( $ibforums->member['restrict_post'] == 1 )
{
$std->Error( array( LEVEL => 1, MSG => 'posting_off') );
}
$post_arr = $std->hdl_ban_line( $ibforums->member['restrict_post'] );
if ( time() >= $post_arr['date_end'] )
{
// Update this member's profile
$DB->query("UPDATE ibf_members SET restrict_post=0 WHERE id=".intval($ibforums->member['id']) );
}
else
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'posting_off_susp', 'EXTRA' => $std->get_date($post_arr['date_end'], 'LONG') ) );
}
}
// Flood check..
if ( $ibforums->input['CODE'] != "08" and $ibforums->input['CODE'] != "09" )
if ( $ibforums->input['CODE'] != "08" and $ibforums->input['CODE'] != "09" and $ibforums->input['CODE'] != "14" and $ibforums->input['CODE'] != "15" )
{
if ( $ibforums->vars['flood_control'] > 0 )
{
@@ -238,6 +291,11 @@ class Post {
}
}
else if ( $ibforums->is_bot == 1 )
{
$std->Error( array( LEVEL => 1, MSG => 'posting_off') );
}
if ($ibforums->member['id'] != 0 and $ibforums->member['g_is_supmod'] == 0)
{
@@ -260,6 +318,8 @@ class Post {
'09' => array( '1' , 'edit_post' ),
'10' => array( '0' , 'poll' ),
'11' => array( '1' , 'poll' ),
'14' => array( '0' , 'poll_after' ),
'15' => array( '1' , 'poll_after' ),
);
// Make sure our input CODE element is legal.
@@ -284,6 +344,13 @@ class Post {
if ($this->obj['action_codes'][ $ibforums->input['CODE'] ][0])
{
// Make sure we have a valid auth key
if ( $ibforums->input['auth_key'] != $this->md5_check )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post') );
}
// Make sure we have a "Guest" Name..
if (!$ibforums->member['id'])
@@ -328,14 +395,14 @@ class Post {
$topic = $DB->fetch_row();
$std->boink_it($ibforums->base_url."&act=ST&f=".$this->forum['id']."&t=".$topic['tid']);
$std->boink_it($ibforums->base_url."act=ST&f=".$this->forum['id']."&t=".$topic['tid']);
exit();
}
else
{
// It's a reply, so simply show the topic...
$std->boink_it($ibforums->base_url."&act=ST&f=".$this->forum['id']."&t=".$ibforums->input['t']."&view=getlastpost");
$std->boink_it($ibforums->base_url."act=ST&f=".$this->forum['id']."&t=".$ibforums->input['t']."&view=getlastpost");
exit();
}
}
@@ -356,6 +423,41 @@ class Post {
}
/*****************************************************/
// Notify new topic mod Q
// ----------------------
/*****************************************************/
function notify_new_topic_approval($tid, $title, $author)
{
global $ibforums, $DB, $std;
if ( $this->forum['notify_modq_emails'] == "" )
{
return;
}
$this->email->get_template("new_topic_queue_notify");
$this->email->build_message( array(
'TOPIC' => $title,
'FORUM' => $this->forum['name'],
'POSTER' => $author,
'DATE' => $std->get_date( time(), 'SHORT' ),
'LINK' => $ibforums->vars['board_url'].'/index.'.$ibforums->vars['php_ext'].'?act=modcp&fact=mod_topic&CODE=fchoice&f='.$this->forum['id'],
)
);
foreach( explode( ",", $this->forum['notify_modq_emails'] ) as $email )
{
$this->email->to = trim($email);
$this->email->send_mail();
}
}
/*****************************************************/
// topic tracker
// ------------------
@@ -366,17 +468,11 @@ class Post {
{
global $ibforums, $DB, $std;
require "./sources/lib/emailer.php";
$this->email = new emailer();
//-------------------------
if ($tid == "")
{
return TRUE;
}
// 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
@@ -388,7 +484,7 @@ class Post {
AND t.tid=tr.topic_id
AND m.last_activity > '$last_post'");
if ( $DB->get_num_rows() )
if ( $DB->get_num_rows() )
{
$trids = array();
@@ -399,7 +495,6 @@ class Post {
if ($r['email_full'] == 1)
{
$this->email->get_template("subs_with_post", $r['language']);
$this->email->build_message( array(
@@ -441,7 +536,8 @@ class Post {
$trids[] = $r['trid'];
}
}
return TRUE;
//return TRUE;
}
@@ -457,12 +553,6 @@ class Post {
{
global $ibforums, $DB, $std;
require "./sources/lib/emailer.php";
$this->email = new emailer();
//-------------------------
if ($this_tid == "")
{
return TRUE;
@@ -478,36 +568,32 @@ class Post {
$time_limit = time() - (30*60);
// There is the chance that an admin makes a forum, leaves it. Some one subscribes to the forum
// and then the admin decides to make it hidden from the public via member groups. If this happened,
// this forum will still send all notifications - this is not desirable, so we check for permissions
// in the SQL query - just in case.
$allowed_groups = "";
if ($this->forum['read_perms'] != '*')
{
if (strlen($this->forum['read_perms'] > 0))
{
$allowed_groups = " AND m.mgroup IN (0,".$this->forum['read_perms'].") ";
}
}
// 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
$DB->query("SELECT tr.frid, m.name, m.email, m.id, m.language, m.last_activity
FROM ibf_forum_tracker tr,ibf_members m
$DB->query("SELECT tr.frid, m.name, m.email, m.id, m.language, m.last_activity, m.org_perm_id, g.g_perm_id
FROM ibf_forum_tracker tr,ibf_members m, ibf_groups g
WHERE tr.forum_id='$fid'
AND tr.member_id=m.id
AND m.mgroup=g.g_id
AND m.id <> '{$ibforums->member['id']}'
$allowed_groups
AND m.last_activity < '$time_limit'");
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$perm_id = ( $r['org_perm_id'] ) ? $r['org_perm_id'] : $r['g_perm_id'];
if ($this->forum['read_perms'] != '*')
{
if ( ! preg_match("/(^|,)".str_replace( ",", '|', $perm_id )."(,|$)/", $this->forum['read_perms'] ) )
{
continue;
}
}
$r['language'] = $r['language'] ? $r['language'] : 'en';
$this->email->get_template("subs_new_topic", $r['language']);
@@ -545,19 +631,29 @@ class Post {
$ibforums->vars['max_post_length'] = $ibforums->vars['max_post_length'] ? $ibforums->vars['max_post_length'] : 2140000;
// sort out some of the form data, check for posting length, etc.
//----------------------------------------------------------------
// Sort out some of the form data, check for posting length, etc.
// THIS MUST BE CALLED BEFORE CHECKING ATTACHMENTS
//----------------------------------------------------------------
$ibforums->input['enablesig'] = $ibforums->input['enablesig'] == 'yes' ? 1 : 0;
$ibforums->input['enableemo'] = $ibforums->input['enableemo'] == 'yes' ? 1 : 0;
$ibforums->input['enablesig'] = $ibforums->input['enablesig'] == 'yes' ? 1 : 0;
$ibforums->input['enableemo'] = $ibforums->input['enableemo'] == 'yes' ? 1 : 0;
$ibforums->input['enabletrack'] = $ibforums->input['enabletrack'] == 1 ? 1 : 0;
//----------------------------------------------------------------
// Do we have a valid post?
//----------------------------------------------------------------
if (strlen( trim($HTTP_POST_VARS['Post']) ) < 1) {
$std->Error( array( LEVEL => 1, MSG => 'no_post') );
if (strlen( trim($HTTP_POST_VARS['Post']) ) < 1)
{
if ( ! $HTTP_POST_VARS['preview'] )
{
$std->Error( array( LEVEL => 1, MSG => 'no_post') );
}
}
if (strlen( $HTTP_POST_VARS['Post'] ) > ($ibforums->vars['max_post_length']*1024)) {
if (strlen( $HTTP_POST_VARS['Post'] ) > ($ibforums->vars['max_post_length']*1024))
{
$std->Error( array( LEVEL => 1, MSG => 'post_too_long') );
}
@@ -577,7 +673,7 @@ class Post {
'author_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
'forum_id' => $this->forum['id'],
'topic_id' => "",
'queued' => $this->obj['moderate'],
'queued' => ( $this->obj['moderate'] == 1 || $this->obj['moderate'] == 3 ) ? 1 : 0,
'attach_id' => "",
'attach_hits' => "",
'attach_type' => "",
@@ -696,6 +792,9 @@ class Post {
case 'image/x-png':
$ext = '.png';
break;
case 'image/png':
$ext = '.png';
break;
default:
$ext = '.ibf';
break;
@@ -761,7 +860,7 @@ class Post {
{
$this->obj['can_upload'] = 1;
$this->obj['form_extra'] = " enctype='multipart/form-data'";
$this->obj['hidden_field'] = "<input type='hidden' name='MAX_FILE_SIZE' value='".($ibforums->member['g_attach_max']*1024)."'>";
$this->obj['hidden_field'] = "<input type='hidden' name='MAX_FILE_SIZE' value='".($ibforums->member['g_attach_max']*1024)."' />";
}
}
@@ -824,6 +923,11 @@ class Post {
$html .= "<option value='close'>".$ibforums->lang['mod_close']."</option>";
}
if ($can_close and $can_pin)
{
$html .= "<option value='pinclose'>".$ibforums->lang['mod_pinclose']."</option>";
}
if ($can_move and $is_reply)
{
$html .= "<option value='move'>".$ibforums->lang['mod_move']."</option>";
@@ -832,7 +936,8 @@ class Post {
return $this->html->mod_options($html);
}
/*****************************************************/
// HTML: start form.
// ------------------
@@ -842,18 +947,21 @@ class Post {
function html_start_form($additional_tags=array()) {
global $ibforums;
$form = "<form action='{$this->base_url}' method='POST' name='REPLIER' onSubmit='return ValidateForm()'".$this->obj['form_extra'].">".
"<input type='hidden' name='st' value='".$ibforums->input[st]."'>".
"<input type='hidden' name='act' value='Post'>".
"<input type='hidden' name='s' value='".$ibforums->session_id."'>".
"<input type='hidden' name='f' value='".$this->forum['id']."'>".
$form = $this->html->get_javascript();
$form .= "<form action='{$this->base_url}' method='post' name='REPLIER' onsubmit='return ValidateForm()'".$this->obj['form_extra'].">".
"<input type='hidden' name='st' value='".$ibforums->input[st]."' />\n".
"<input type='hidden' name='act' value='Post' />\n".
"<input type='hidden' name='s' value='".$ibforums->session_id."' />\n".
"<input type='hidden' name='f' value='".$this->forum['id']."' />\n".
"<input type='hidden' name='auth_key' value='".$this->md5_check."' />\n".
$this->obj['hidden_field'];
// Any other tags to add?
if (isset($additional_tags)) {
foreach($additional_tags as $k => $v) {
$form .= "\n<input type='hidden' name='{$v[0]}' value='{$v[1]}'>";
$form .= "\n<input type='hidden' name='{$v[0]}' value='{$v[1]}' />";
}
}
@@ -910,11 +1018,74 @@ class Post {
if ($post_icon) {
$html = preg_replace( "/name=[\"']iconid[\"']\s*value=[\"']$post_icon\s?[\"']/", "name='iconid' value='$post_icon' checked", $html );
$html = preg_replace( "/name=[\"']iconid[\"']\s*value=[\"']0[\"']\s*checked/i" , "name='iconid' value='0'", $html );
$html = preg_replace( "/name=[\"']iconid[\"']\s*value=[\"']0[\"']\s*checked=['\"]checked['\"]/i" , "name='iconid' value='0'", $html );
}
return $html;
}
/*****************************************************/
// HTML: checkboxes
// ------------------
// Returns the HTML for sig/emo/track boxes
/*****************************************************/
function html_checkboxes($type="", $tid="")
{
global $ibforums, $DB;
$default_checked = array(
'sig' => 'checked="checked"',
'emo' => 'checked="checked"',
'tra' => $ibforums->member['auto_track'] ? 'checked="checked"' : ''
);
// Make sure we're not previewing them and they've been unchecked!
if ( isset( $ibforums->input['enablesig'] ) AND ( ! $ibforums->input['enablesig'] ) )
{
$default_checked['sig'] = "";
}
if ( isset( $ibforums->input['enableemo'] ) AND ( ! $ibforums->input['enableemo'] ) )
{
$default_checked['emo'] = "";
}
if ( isset( $ibforums->input['enabletrack'] ) AND ( ! $ibforums->input['enabletrack'] ) )
{
$default_checked['tra'] = "";
}
else if ( isset( $ibforums->input['enabletrack'] ) AND ( $ibforums->input['enabletrack'] == 1 ) )
{
$default_checked['tra'] = 'checked="checked"';
}
$this->output = str_replace( '<!--IBF.EMO-->' , $this->html->get_box_enableemo( $default_checked['emo'] ) , $this->output );
$this->output = str_replace( '<!--IBF.SIG-->' , $this->html->get_box_enablesig( $default_checked['sig'] ) , $this->output );
if ( $type == 'reply' )
{
if ( $tid and $ibforums->member['id'] )
{
$DB->query("SELECT trid FROM ibf_tracker WHERE topic_id=$tid AND member_id=".$ibforums->member['id']);
if ( $DB->get_num_rows() )
{
$this->output = str_replace( '<!--IBF.TRACK-->',$this->html->get_box_alreadytrack(), $this->output );
}
else
{
$this->output = str_replace( '<!--IBF.TRACK-->', $this->html->get_box_enabletrack( $default_checked['tra'] ), $this->output );
}
}
}
else if ( $type != 'edit' )
{
$this->output = str_replace( '<!--IBF.TRACK-->', $this->html->get_box_enabletrack( $default_checked['tra'] ), $this->output );
}
}
/*****************************************************/
// HTML: add smilie box.
// ------------------
@@ -937,7 +1108,21 @@ class Post {
$show_table++;
$count++;
$smilies .= "<td><a href=\"javascript:emoticon('".$elmo['typed']."')\"><img src=\"".$ibforums->vars['EMOTICONS_URL']."/".$elmo['image']."\" alt='smilie' border='0'></a>&nbsp;</td>\n";
// Make single quotes as URL's with html entites in them
// are parsed by the browser, so ' causes JS error :o
if (strstr( $elmo['typed'], "&#39;" ) )
{
$in_delim = '"';
$out_delim = "'";
}
else
{
$in_delim = "'";
$out_delim = '"';
}
$smilies .= "<td><a href={$out_delim}javascript:emoticon($in_delim".$elmo['typed']."$in_delim){$out_delim}><img src=\"".$ibforums->vars['EMOTICONS_URL']."/".$elmo['image']."\" alt='smilie' border='0' /></a>&nbsp;</td>\n";
if ($count == $ibforums->vars['emo_per_row']) {
$smilies .= "</tr>\n\n<tr align='center'>";
@@ -983,7 +1168,7 @@ class Post {
// This section will probably change at some point
//--------------------------------------------------------------
$post_query = $DB->query("SELECT post, pid, post_date, author_id, author_name FROM ibf_posts WHERE topic_id='$topic_id' and queued <> 1 ORDER BY pid DESC LIMIT 0,10");
$post_query = $DB->query("SELECT post, pid, post_date, author_id, author_name FROM ibf_posts WHERE topic_id=$topic_id and queued <> 1 ORDER BY pid DESC LIMIT 0,10");
while ( $row = $DB->fetch_row($post_query) )
{
@@ -992,6 +1177,28 @@ class Post {
$row['date'] = $std->get_date( $row['post_date'], 'LONG' );
if (!$ibforums->member['view_img'])
{
// unconvert smilies first, or it looks a bit crap.
$row['post'] = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , $row['post'] );
$row['post'] = preg_replace( "/<img src=[\"'](.+?)[\"'].+?".">/", "(IMG:<a href='\\1' target='_blank'>\\1</a>)", $row['post'] );
}
$row['post'] = $this->parser->post_db_parse($row['post'], $this->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0);
//--------------------------------------------------------------
// Do word wrap?
//--------------------------------------------------------------
if ( $ibforums->vars['post_wordwrap'] > 0 )
{
$row['post'] = $this->parser->my_wordwrap( $row['post'], $ibforums->vars['post_wordwrap']) ;
}
$row['post'] = str_replace( "<br>", "<br />", $row['post'] );
$this->output .= $this->html->TopicSummary_body( $row );
}