Version 1.1.1

This commit is contained in:
Neo committed 2025-12-19 00:16:25 -08:00
1 parent aabfdc1f57
commit 7ef3d1712a
179 files changed
+57457 -44972

No files matched your search

+173 -173
View File
@@ -1,174 +1,174 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Add POLL module
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
|
| QUOTE OF THE MODULE: (Taken from BtVS)
| --------------------
| Drusilla: I'm naming all the stars...
| Spike: You can't see the stars love, That's the ceiling. Also, it's day.
|
+--------------------------------------------------------------------------
*/
$idx = new Poll;
class Poll {
var $topic = array();
var $poll = array();
var $upload = array();
var $poll_count = 0;
var $poll_choices = "";
function Poll() {
global $ibforums, $std, $DB, $print;
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_post', $ibforums->lang_id);
// Lets do some tests to make sure that we are allowed to start a new topic
if (! $ibforums->member['g_vote_polls'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_reply_polls') );
}
// Did we choose a choice?
if (!$ibforums->input['nullvote'])
{
if (! isset($ibforums->input['poll_vote']) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_vote') );
}
}
// Make sure we have a valid poll id
$ibforums->input[t] = $std->is_number($ibforums->input[t]);
if (! $ibforums->input[t] ) {
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
// Load the topic and poll
$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( LEVEL => 1, MSG => 'poll_none_found') );
}
if ($this->topic['state'] != 'open')
{
$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']."'");
if ( $DB->get_num_rows() )
{
$std->Error( array( LEVEL => 1, MSG => 'poll_you_voted') );
}
// 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->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'])
{
$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']}" );
}
}
<?php
/*
+--------------------------------------------------------------------------
| Invision Board v1.1
| ========================================
| by Matthew Mecham
| (c) 2001,2002 Invision Power Services
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Add POLL module
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
|
| QUOTE OF THE MODULE: (Taken from BtVS)
| --------------------
| Drusilla: I'm naming all the stars...
| Spike: You can't see the stars love, That's the ceiling. Also, it's day.
|
+--------------------------------------------------------------------------
*/
$idx = new Poll;
class Poll {
var $topic = array();
var $poll = array();
var $upload = array();
var $poll_count = 0;
var $poll_choices = "";
function Poll() {
global $ibforums, $std, $DB, $print;
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_post', $ibforums->lang_id);
// Lets do some tests to make sure that we are allowed to start a new topic
if (! $ibforums->member['g_vote_polls'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_reply_polls') );
}
// Did we choose a choice?
if (!$ibforums->input['nullvote'])
{
if (! isset($ibforums->input['poll_vote']) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_vote') );
}
}
// Make sure we have a valid poll id
$ibforums->input[t] = $std->is_number($ibforums->input[t]);
if (! $ibforums->input[t] ) {
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
// Load the topic and poll
$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( LEVEL => 1, MSG => 'poll_none_found') );
}
if ($this->topic['state'] != 'open')
{
$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']."'");
if ( $DB->get_num_rows() )
{
$std->Error( array( LEVEL => 1, MSG => 'poll_you_voted') );
}
// 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->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'])
{
$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']}" );
}
}
?>
+39 -22
View File
@@ -2,10 +2,10 @@
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| Invision Board v1.1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| by Matthew Mecham
| (c) 2001,2002 Invision Power Services
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
@@ -44,7 +44,7 @@ class emailer {
var $template = "";
var $error = "";
var $parts = array();
var $bcc = "";
var $bcc = array();
var $mail_headers = array();
var $multipart = "";
var $boundry = "";
@@ -59,6 +59,8 @@ class emailer {
$this->from = $ibforums->vars['email_out'];
$this->temp_dump = $ibforums->vars['fake_mail'];
// Temporarily assign $header and $footer, this can be over-riden
// also
@@ -68,27 +70,33 @@ class emailer {
}
function add_attachment($data = "", $name = "", $ctype='application/octet-stream') {
function add_attachment($data = "", $name = "", $ctype='application/octet-stream')
{
$this->parts[] = array( 'ctype' => $ctype,
'data' => $data,
'encode' => 'base64',
'name' => $name
);
}
function build_headers() {
$this->mail_headers = "From: ".$this->from. "\n";
function build_headers()
{
global $ibforums;
$this->mail_headers = "From: \"".$ibforums->vars['board_name']."\" <".$this->from.">\n";
if ( count( $this->bcc ) > 1 )
{
$this->mail_headers .= "Bcc: ".implode( "," , $this->bcc ) . "\n";
}
$this->mail_headers .= "Return-Path: ".$this->from."\n";
$this->mail_headers .= "X-Priority: 3\n";
$this->mail_headers .= "X-Mailer: IBForums PHP Mailer\n";
if (is_array( $this->bcc ) )
{
$this->mail_headers .= "BCC: ".implode( "," , $this->bcc ) . "\n";
}
if ( count ($this->parts) > 0 )
{
@@ -130,7 +138,9 @@ class emailer {
// Physically sends the email
//+--------------------------------------------------------------------------
function send_mail() {
function send_mail()
{
global $ibforums;
$this->to = preg_replace( "/[ \t]+/" , " " , $this->to );
$this->from = preg_replace( "/[ \t]+/" , " " , $this->from );
@@ -147,12 +157,13 @@ class emailer {
if ( ($this->from) and ($this->subject) )
{
$this->subject .= " ( From ".$ibforums->vars['board_name']." )";
if ($this->temp_dump == 1)
{
$blah = $this->to."\n".$this->from."\n".$this->subject."\n".$this->mail_headers."\n\n".$this->message;
$blah = $this->subject."\n------------\n".$this->mail_headers."\n\n".$this->message;
$pathy = '/Library/WebServer/Documents/mail/'.date("js.F.Y.h:i.A"); // OS X rules!
$pathy = '/Library/WebServer/Documents/mail/'.date("F.Y.h:i.A").".txt"; // OS X rules!
$fh = fopen ($pathy, 'w');
fputs ($fh, $blah, strlen($blah) );
fclose($fh);
@@ -178,7 +189,7 @@ class emailer {
//+--------------------------------------------------------------------------
function get_template($name="", $language="en") {
global $IB, $DB;
global $ibforums, $IB, $DB;
if ($name == "")
{
@@ -186,19 +197,21 @@ class emailer {
$this->fatal_error("A valid email template ID was not passed to the email library during template parsing", "");
}
if (! file_exists("./lang/$language/email_content.php") )
{
require "./lang/en/email_content.php";
require "./lang/".$ibforums->vars['default_language']."/email_content.php";
}
else
{
require "./lang/$language/email_content.php";
}
if (! isset($EMAIL[ $name ]) ) {
if (! isset($EMAIL[ $name ]) )
{
$this->fatal_error("Could not find an email template with an ID of '$name'", "");
}
$this->template = $EMAIL[ $name ];
$this->template = $EMAIL['header'] . $EMAIL[ $name ] . $EMAIL['footer'];
}
//+--------------------------------------------------------------------------
@@ -241,6 +254,8 @@ class emailer {
function clean_message($message = "" ) {
$message = preg_replace( "/^(\r|\n)+?(.*)$/", "\\2", $message );
$message = preg_replace( "#<b>(.+?)</b>#" , "\\1", $message );
$message = preg_replace( "#<i>(.+?)</i>#" , "\\1", $message );
$message = preg_replace( "#<s>(.+?)</s>#" , "--\\1--", $message );
@@ -266,8 +281,10 @@ class emailer {
$message = preg_replace( "#<!--EDIT\|.+?\|.+?-->#" , "" , $message );
$message = preg_replace( "#<.+?".">#" , "" , $message );
//$message = str_replace( "\r" , "" , $message );
//$message = str_replace( "\n\n", "\n" , $message );
$message = preg_replace( "/(<br>|\n)/" , "\r\n", $message );
$message = str_replace( "<br>" , "\n", $message );
$message = str_replace( "&quot;", "\"", $message );
$message = str_replace( "&#092;", "\\", $message );
+362 -279
View File
@@ -1,280 +1,363 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Edit post library
| > Module written by Matt Mecham
| > Date started: 19th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $moderator = array( 'member_id' => 0, 'member_name' => "", 'edit_post' => 0 );
var $orig_post = array();
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets load the topic from the database before we do anything else.
$DB->query("SELECT * FROM ibf_topics WHERE tid='".$ibforums->input['t']."'");
$this->topic = $DB->fetch_row();
// Is it legitimate?
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
// Load the old post
$DB->query("SELECT * FROM ibf_posts WHERE pid='".$ibforums->input['p']."'");
$this->orig_post = $DB->fetch_row();
if (! $this->orig_post['pid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
// Load the moderator
if ($ibforums->member['id'])
{
$DB->query("SELECT member_id, member_name, mid, edit_post FROM ibf_moderators WHERE member_id='".$ibforums->member['id']."' and forum_id='".$class->forum['id']."'");
$this->moderator = $DB->fetch_row();
}
//-------------------------------------------------
// Lets do some tests to make sure that we are
// allowed to edit this topic
//-------------------------------------------------
$can_edit = 0;
if ($ibforums->member['g_is_supmod'])
{
$can_edit = 1;
}
if ($this->moderator['edit_post'])
{
$can_edit = 1;
}
if ( ($this->orig_post['author_id'] == $ibforums->member['id']) and ($ibforums->member['g_edit_posts']) )
{
$can_edit = 1;
}
if ($can_edit != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'not_op') );
}
// Is the topic locked?
if (($this->topic['state'] != 'open') and (!$ibforums->member['g_is_supmod']))
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
// overwrites saved post intentionally
//-------------------------------------------------
$this->post = $class->compile_post();
if ($class->obj['post_errors'] == "")
{
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
{
// Show the form again
$this->show_form($class);
}
else
{
$this->complete_edit($class);
}
}
function complete_edit($class) {
global $ibforums, $std, $DB, $print;
$time = $std->get_date( time(), 'LONG' );
//-------------------------------------------------
// Reset some data
//-------------------------------------------------
$this->post['attach_id'] = $this->orig_post['attach_id'];
$this->post['attach_type'] = $this->orig_post['attach_type'];
$this->post['attach_hits'] = $this->orig_post['attach_hits'];
$this->post['ip_address'] = $this->orig_post['ip_address'];
$this->post['topic_id'] = $this->orig_post['topic_id'];
$this->post['author_id'] = $this->orig_post['author_id'];
$this->post['pid'] = $this->orig_post['pid'];
$this->post['post_date'] = $this->orig_post['post_date'];
$this->post['author_name'] = $this->orig_post['author_name'];
// If the post icon has changed, update the topic post icon
if ($this->orig_post['new_topic'] == 1)
{
if ($this->post['icon_id'] != $this->orig_post['icon_id'])
{
$DB->query("UPDATE ibf_topics SET icon_id='".$this->post['icon_id']."' WHERE tid='".$this->topic['tid']."'");
}
}
//-------------------------------------------------
// Update the database (ib_forum_post)
//-------------------------------------------------
if ($ibforums->member['g_append_edit'])
{
$this->post['post'] .= "\n\n<br><br><!--EDIT|".$ibforums->member['name']."|".$time."-->";
}
$db_string = $DB->compile_db_update_string( $this->post );
$DB->query("UPDATE ibf_posts SET $db_string WHERE pid='".$this->post['pid']."'");
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$print->redirect_screen( $ibforums->lang['post_edited'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st={$ibforums->input['st']}#entry{$this->post['pid']}");
}
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 <textarea> tag in the raw post var.
//-------------------------------------------------
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : $class->parser->unconvert($this->orig_post['post'], $class->forum['use_ibc'], $class->forum['use_html']);
if (isset($raw_post)) {
$raw_post = preg_replace( "/<\/textarea>/", "&lt;/textarea>", $raw_post );
$raw_post = str_replace( '$', "&#036;", $raw_post );
$raw_post = str_replace( '<%', "&lt;%" , $raw_post );
$raw_post = stripslashes($raw_post);
}
//-------------------------------------------------
// Do we have any posting errors?
//-------------------------------------------------
if ($class->obj['post_errors'])
{
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post'])
{
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '09' ),
2 => array( 't' , $this->topic['tid']),
3 => array( 'p' , $ibforums->input['p'] ),
4 => array( 'st' , $ibforums->input['st'] ),
) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_edit']} {$this->topic['title']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$end_form = $class->html->EndForm( $ibforums->lang['submit_edit'] );
$post_icons = $class->html_post_icons($this->orig_post['icon_id']);
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum['cat_id']}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['editing_post'].' '.$this->topic['title'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
<?php
/*
+--------------------------------------------------------------------------
| Invision Board v1.1
| ========================================
| by Matthew Mecham
| (c) 2001,2002 Invision Power Services
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Edit post library
| > Module written by Matt Mecham
| > Date started: 19th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $moderator = array( 'member_id' => 0, 'member_name' => "", 'edit_post' => 0 );
var $orig_post = array();
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets load the topic from the database before we do anything else.
$DB->query("SELECT * FROM ibf_topics WHERE tid='".$ibforums->input['t']."'");
$this->topic = $DB->fetch_row();
// Is it legitimate?
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
// Load the old post
$DB->query("SELECT * FROM ibf_posts WHERE pid='".$ibforums->input['p']."'");
$this->orig_post = $DB->fetch_row();
if (! $this->orig_post['pid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
// Load the moderator
if ($ibforums->member['id'])
{
$DB->query("SELECT member_id, member_name, mid, edit_post FROM ibf_moderators WHERE forum_id='".$class->forum['id']."' AND (member_id='".$ibforums->member['id']."' OR (is_group=1 AND group_id='".$ibforums->member['mgroup']."'))");
$this->moderator = $DB->fetch_row();
}
//-------------------------------------------------
// Lets do some tests to make sure that we are
// allowed to edit this topic
//-------------------------------------------------
$can_edit = 0;
if ($ibforums->member['g_is_supmod'])
{
$can_edit = 1;
}
if ($this->moderator['edit_post'])
{
$can_edit = 1;
}
if ( ($this->orig_post['author_id'] == $ibforums->member['id']) and ($ibforums->member['g_edit_posts']) )
{
// Have we set a time limit?
if ($ibforums->member['g_edit_cutoff'] > 0)
{
if ( $this->orig_post['post_date'] > ( time() - ( intval($ibforums->member['g_edit_cutoff']) * 60 ) ) )
{
$can_edit = 1;
}
}
else
{
$can_edit = 1;
}
}
if ($can_edit != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'not_op') );
}
// Is the topic locked?
if (($this->topic['state'] != 'open') and (!$ibforums->member['g_is_supmod']))
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
// overwrites saved post intentionally
//-------------------------------------------------
$this->post = $class->compile_post();
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
{
// Show the form again
$this->show_form($class);
}
else
{
$this->complete_edit($class);
}
}
function complete_edit($class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_FILES;
$time = $std->get_date( time(), 'LONG' );
//-------------------------------------------------
// Reset some data
//-------------------------------------------------
// Do we have to adjust the attachments?
if ($this->orig_post['attach_id'])
{
if ($ibforums->input['editupload'] != 'keep')
{
// We're either uploading a new attachment, or deleting one, so lets
// remove the old attachment first eh?
if (is_file($ibforums->vars['upload_dir']."/".$this->orig_post['attach_id']))
{
@unlink($ibforums->vars['upload_dir']."/".$this->orig_post['attach_id']);
}
if ($ibforums->input['editupload'] == 'new')
{
// w00t, we're uploading a new ..um.. upload
$new_upload = $class->process_upload();
if ( $class->obj['post_errors'] != "") {
$this->show_form($class);
}
$this->post['attach_id'] = $new_upload['attach_id'];
$this->post['attach_type'] = $new_upload['attach_type'];
$this->post['attach_hits'] = $new_upload['attach_hits'];
$this->post['attach_file'] = $new_upload['attach_file'];
}
else if ($ibforums->input['editupload'] == 'delete')
{
// Simply remove the DB data as we've already removed the file
$this->post['attach_id'] = "";
$this->post['attach_type'] = "";
$this->post['attach_hits'] = "";
$this->post['attach_file'] = "";
}
}
else
{
// We are keeping the old attachment
$this->post['attach_id'] = $this->orig_post['attach_id'];
$this->post['attach_type'] = $this->orig_post['attach_type'];
$this->post['attach_hits'] = $this->orig_post['attach_hits'];
$this->post['attach_file'] = $this->orig_post['attach_file'];
}
}
$this->post['ip_address'] = $this->orig_post['ip_address'];
$this->post['topic_id'] = $this->orig_post['topic_id'];
$this->post['author_id'] = $this->orig_post['author_id'];
$this->post['pid'] = $this->orig_post['pid'];
$this->post['post_date'] = $this->orig_post['post_date'];
$this->post['author_name'] = $this->orig_post['author_name'];
$this->post['edit_time'] = time();
$this->post['edit_name'] = $ibforums->member['name'];
// If the post icon has changed, update the topic post icon
if ($this->orig_post['new_topic'] == 1)
{
if ($this->post['icon_id'] != $this->orig_post['icon_id'])
{
$DB->query("UPDATE ibf_topics SET icon_id='".$this->post['icon_id']."' WHERE tid='".$this->topic['tid']."'");
}
}
//-------------------------------------------------
// Update the database (ib_forum_post)
//-------------------------------------------------
$this->post['append_edit'] = 1;
if ($ibforums->member['g_append_edit'])
{
if ($ibforums->input['add_edit'] != 1)
{
$this->post['append_edit'] = 0;
}
}
$db_string = $DB->compile_db_update_string( $this->post );
$DB->query("UPDATE ibf_posts SET $db_string WHERE pid='".$this->post['pid']."'");
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$print->redirect_screen( $ibforums->lang['post_edited'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st={$ibforums->input['st']}#entry{$this->post['pid']}");
}
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 <textarea> tag in the raw post var.
//-------------------------------------------------
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : $class->parser->unconvert($this->orig_post['post'], $class->forum['use_ibc'], $class->forum['use_html']);
if (isset($raw_post)) {
$raw_post = str_replace( '$' , "&#036;" , $raw_post );
$raw_post = str_replace( '<' , "&lt;" , $raw_post );
$raw_post = stripslashes($raw_post);
}
//-------------------------------------------------
// Do we have any posting errors?
//-------------------------------------------------
if ($class->obj['post_errors'])
{
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post'])
{
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '09' ),
2 => array( 't' , $this->topic['tid']),
3 => array( 'p' , $ibforums->input['p'] ),
4 => array( 'st' , $ibforums->input['st'] ),
) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_edit']} {$this->topic['title']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$end_form = $class->html->EndForm( $ibforums->lang['submit_edit'] );
$post_icons = $class->html_post_icons($this->orig_post['icon_id']);
if (($class->obj['can_upload']) and ($this->orig_post['attach_id'] != ""))
{
$upload_field = $class->html->edit_upload_field( $ibforums->member['g_attach_max'] * 1024, $this->orig_post['attach_file'] );
}
if ($ibforums->member['g_append_edit'])
{
$checked = "";
if ($this->orig_post['append_edit'])
{
$checked = "checked";
}
$edit_option = $class->html->add_edit_box($checked);
}
//---------------------------------------
$class->output = str_replace( "<!--START TABLE-->" , $start_table , $class->output );
$class->output = str_replace( "<!--NAME FIELDS-->" , $name_fields , $class->output );
$class->output = str_replace( "<!--POST BOX-->" , $post_box , $class->output );
$class->output = str_replace( "<!--POST ICONS-->" , $post_icons , $class->output );
$class->output = str_replace( "<!--END TABLE-->" , $end_form , $class->output );
$class->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $class->output );
$class->output = str_replace( "<!--MOD OPTIONS-->" , $edit_option , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum['cat_id']}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['editing_post'].' '.$this->topic['title'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
?>
+405 -371
View File
@@ -1,372 +1,406 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > New Post module
| > Module written by Matt Mecham
| > Date started: 17th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets do some tests to make sure that we are allowed to start a new topic
$this->m_group = $ibforums->member['mgroup'];
if (! $ibforums->member['g_post_new_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_starting') );
}
if ($class->forum['start_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['start_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_starting') );
}
}
}
function process($class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
//-------------------------------------------------
// check to make sure we have a valid topic title
//-------------------------------------------------
$ibforums->input['TopicTitle'] = str_replace( "<br>", "", $ibforums->input['TopicTitle'] );
$ibforums->input['TopicTitle'] = trim(stripslashes($ibforums->input['TopicTitle']));
if ( (strlen($ibforums->input['TopicTitle']) < 2) or (!$ibforums->input['TopicTitle']) )
{
$class->obj['post_errors'] = 'no_topic_title';
}
if ( strlen($HTTP_POST_VARS['TopicTitle']) > 64 )
{
$class->obj['post_errors'] = 'topic_title_long';
}
//-------------------------------------------------
// If we don't have any errors yet, parse the upload
//-------------------------------------------------
if ($class->obj['post_errors'] == "")
{
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") ) {
// Show the form again
$this->show_form($class);
} else {
$this->add_new_topic($class);
}
}
function add_new_topic($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Fix up the topic title
//-------------------------------------------------
if ($ibforums->vars['etfilter_punct'])
{
$ibforums->input['TopicTitle'] = preg_replace( "/\?{1,}/" , "?" , $ibforums->input['TopicTitle'] );
$ibforums->input['TopicTitle'] = preg_replace( "/(&#33;){1,}/" , "&#33;", $ibforums->input['TopicTitle'] );
}
if ($ibforums->vars['etfilter_shout'])
{
$ibforums->input['TopicTitle'] = ucwords(strtolower($ibforums->input['TopicTitle']));
}
$ibforums->input['TopicTitle'] = $class->parser->bad_words( $ibforums->input['TopicTitle'] );
$ibforums->input['TopicDesc'] = $class->parser->bad_words( $ibforums->input['TopicDesc'] );
$pinned = 0;
$state = 'open';
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
{
if ($ibforums->input['mod_options'] == 'pin')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
{
$pinned = 1;
$class->moderate_log('Pinned topic from post form', $ibforums->input['TopicTitle']);
}
}
else if ($ibforums->input['mod_options'] == 'close')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
{
$state = 'closed';
$class->moderate_log('Closed topic from post form', $ibforums->input['TopicTitle']);
}
}
}
//-------------------------------------------------
// Build the master array
//-------------------------------------------------
$this->topic = array(
'title' => $ibforums->input['TopicTitle'],
'description' => $ibforums->input['TopicDesc'] ,
'state' => $state,
'posts' => 0,
'starter_id' => $ibforums->member['id'],
'starter_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
'start_date' => time(),
'last_poster_id' => $ibforums->member['id'],
'last_poster_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
'last_post' => time(),
'icon_id' => $ibforums->input['iconid'],
'author_mode' => $ibforums->member['id'] ? 1 : 0,
'poll_state' => 0,
'last_vote' => 0,
'views' => 0,
'forum_id' => $class->forum['id'],
'approved' => $class->obj['moderate'] ? 0 : 1,
'pinned' => $pinned,
);
//-------------------------------------------------
// Insert the topic into the database to get the
// last inserted value of the auto_increment field
// follow suit with the post
//-------------------------------------------------
$db_string = $DB->compile_db_insert_string( $this->topic );
$DB->query("INSERT INTO ibf_topics (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['topic_id'] = $DB->get_insert_id();
$this->topic['tid'] = $this->post['topic_id'];
/*---------------------------------------------------*/
// Update the post info with the upload array info
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['attach_file'] = $this->upload['attach_file'];
$this->post['new_topic'] = 1;
$db_string = $DB->compile_db_insert_string( $this->post );
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['pid'] = $DB->get_insert_id();
if ($class->obj['moderate'])
{
// Redirect them with a message telling them the post has to be previewed first
$print->redirect_screen( $ibforums->lang['moderate_topic'], "act=SF&f={$class->forum['id']}" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum stats
//-------------------------------------------------
$class->forum['last_title'] = $this->topic['title'];
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['topics']++;
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"topics='" .$class->forum['topics'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
$DB->query("UPDATE ibf_stats SET TOTAL_TOPICS=TOTAL_TOPICS+1");
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$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 <textarea> tag in the raw post var.
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
$topic_title = isset($HTTP_POST_VARS['TopicTitle']) ? $ibforums->input['TopicTitle'] : "";
$topic_desc = isset($HTTP_POST_VARS['TopicDesc']) ? $ibforums->input['TopicDesc'] : "";
if (isset($raw_post))
{
$raw_post = preg_replace( "/<textarea>/", "&lt;textarea>", $raw_post );
$raw_post = str_replace( '$' , "&#036;" , $raw_post );
$raw_post = str_replace( '<%', "&lt;%" , $raw_post );
$raw_post = stripslashes($raw_post);
}
// Do we have any posting errors?
if ($class->obj['post_errors'])
{
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post'])
{
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '01' ) ) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$topic_title = $class->html->topictitle_fields( array( TITLE => $topic_title, DESC => $topic_desc ) );
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_new']} {$class->forum['name']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options();
$end_form = $class->html->EndForm( $ibforums->lang['submit_new'] );
$post_icons = $class->html_post_icons();
if ($class->obj['can_upload'])
{
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
}
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
$class->output = preg_replace( "/<!--TOPIC TITLE-->/" , "$topic_title" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum['cat_id']}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
);
$this->title = $ibforums->lang['posting_new_topic'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
<?php
/*
+--------------------------------------------------------------------------
| Invision Board v1.1
| ========================================
| by Matthew Mecham
| (c) 2001,2002 Invision Power Services
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > New Post module
| > Module written by Matt Mecham
| > Date started: 17th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets do some tests to make sure that we are allowed to start a new topic
$this->m_group = $ibforums->member['mgroup'];
if (! $ibforums->member['g_post_new_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_starting') );
}
if ($class->forum['start_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['start_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_starting') );
}
}
}
function process($class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
//-------------------------------------------------
// check to make sure we have a valid topic title
//-------------------------------------------------
$ibforums->input['TopicTitle'] = str_replace( "<br>", "", $ibforums->input['TopicTitle'] );
$ibforums->input['TopicTitle'] = trim(stripslashes($ibforums->input['TopicTitle']));
if ( (strlen($ibforums->input['TopicTitle']) < 2) or (!$ibforums->input['TopicTitle']) )
{
$class->obj['post_errors'] = 'no_topic_title';
}
if ( strlen($HTTP_POST_VARS['TopicTitle']) > 64 )
{
$class->obj['post_errors'] = 'topic_title_long';
}
//-------------------------------------------------
// If we don't have any errors yet, parse the upload
//-------------------------------------------------
if ($class->obj['post_errors'] == "")
{
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") ) {
// Show the form again
$this->show_form($class);
} else {
$this->add_new_topic($class);
}
}
function add_new_topic($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Fix up the topic title
//-------------------------------------------------
if ($ibforums->vars['etfilter_punct'])
{
$ibforums->input['TopicTitle'] = preg_replace( "/\?{1,}/" , "?" , $ibforums->input['TopicTitle'] );
$ibforums->input['TopicTitle'] = preg_replace( "/(&#33;){1,}/" , "&#33;", $ibforums->input['TopicTitle'] );
}
if ($ibforums->vars['etfilter_shout'])
{
$ibforums->input['TopicTitle'] = ucwords(strtolower($ibforums->input['TopicTitle']));
}
$ibforums->input['TopicTitle'] = $class->parser->bad_words( $ibforums->input['TopicTitle'] );
$ibforums->input['TopicDesc'] = $class->parser->bad_words( $ibforums->input['TopicDesc'] );
$pinned = 0;
$state = 'open';
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
{
if ($ibforums->input['mod_options'] == 'pin')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
{
$pinned = 1;
$class->moderate_log('Pinned topic from post form', $ibforums->input['TopicTitle']);
}
}
else if ($ibforums->input['mod_options'] == 'close')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
{
$state = 'closed';
$class->moderate_log('Closed topic from post form', $ibforums->input['TopicTitle']);
}
}
}
//-------------------------------------------------
// Build the master array
//-------------------------------------------------
$this->topic = array(
'title' => $ibforums->input['TopicTitle'],
'description' => $ibforums->input['TopicDesc'] ,
'state' => $state,
'posts' => 0,
'starter_id' => $ibforums->member['id'],
'starter_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
'start_date' => time(),
'last_poster_id' => $ibforums->member['id'],
'last_poster_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
'last_post' => time(),
'icon_id' => $ibforums->input['iconid'],
'author_mode' => $ibforums->member['id'] ? 1 : 0,
'poll_state' => 0,
'last_vote' => 0,
'views' => 0,
'forum_id' => $class->forum['id'],
'approved' => $class->obj['moderate'] ? 0 : 1,
'pinned' => $pinned,
);
//-------------------------------------------------
// Insert the topic into the database to get the
// last inserted value of the auto_increment field
// follow suit with the post
//-------------------------------------------------
$db_string = $DB->compile_db_insert_string( $this->topic );
$DB->query("INSERT INTO ibf_topics (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['topic_id'] = $DB->get_insert_id();
$this->topic['tid'] = $this->post['topic_id'];
/*---------------------------------------------------*/
// Update the post info with the upload array info
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['attach_file'] = $this->upload['attach_file'];
$this->post['new_topic'] = 1;
$db_string = $DB->compile_db_insert_string( $this->post );
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['pid'] = $DB->get_insert_id();
if ($class->obj['moderate'])
{
// Redirect them with a message telling them the post has to be previewed first
$print->redirect_screen( $ibforums->lang['moderate_topic'], "act=SF&f={$class->forum['id']}" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum stats
//-------------------------------------------------
$class->forum['last_title'] = $this->topic['title'];
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['topics']++;
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"topics='" .$class->forum['topics'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
$DB->query("UPDATE ibf_stats SET TOTAL_TOPICS=TOTAL_TOPICS+1");
//-------------------------------------------------
// Are we tracking new topics we start 'auto_track'?
//-------------------------------------------------
if ($ibforums->member['auto_track'] == 1)
{
$db_string = $DB->compile_db_insert_string( array (
'member_id' => $ibforums->member['id'],
'topic_id' => $this->topic['tid'],
'start_date' => time(),
) );
$DB->query("INSERT INTO ibf_tracker ({$db_string['FIELD_NAMES']}) VALUES ({$db_string['FIELD_VALUES']})");
}
//---------------------------------------------------------------
// Are we tracking this forum? If so generate some mailies - yay!
//---------------------------------------------------------------
$class->forum_tracker($class->forum['id'], $this->topic['tid'], $this->topic['title'], $class->forum['name'] );
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
// Are we checking for auto promotion?
if ($ibforums->member['g_promotion'] != '-1&-1')
{
list($gid, $gposts) = explode( '&', $ibforums->member['g_promotion'] );
if ( $gid > 0 and $gposts > 0 )
{
if ( $ibforums->member['posts'] + 1 >= $gposts )
{
$mgroup = "mgroup='$gid', ";
}
}
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.$mgroup.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$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 <textarea> tag in the raw post var.
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
$topic_title = isset($HTTP_POST_VARS['TopicTitle']) ? $ibforums->input['TopicTitle'] : "";
$topic_desc = isset($HTTP_POST_VARS['TopicDesc']) ? $ibforums->input['TopicDesc'] : "";
if (isset($raw_post))
{
$raw_post = str_replace( '$' , "&#036;" , htmlspecialchars($raw_post) );
$raw_post = stripslashes($raw_post);
}
// Do we have any posting errors?
if ($class->obj['post_errors'])
{
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post'])
{
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '01' ) ) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$topic_title = $class->html->topictitle_fields( array( TITLE => $topic_title, DESC => $topic_desc ) );
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_new']} {$class->forum['name']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options();
$end_form = $class->html->EndForm( $ibforums->lang['submit_new'] );
$post_icons = $class->html_post_icons();
if ($class->obj['can_upload'])
{
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
}
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
$class->output = preg_replace( "/<!--TOPIC TITLE-->/" , "$topic_title" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum['cat_id']}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
);
$this->title = $ibforums->lang['posting_new_topic'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
?>
File diff suppressed because it is too large. Load diff
+34 -11
View File
@@ -2,10 +2,10 @@
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| Invision Board v1.1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| by Matthew Mecham
| (c) 2001,2002 Invision Power Services
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
@@ -226,12 +226,13 @@ class post_functions extends Post {
$db_string = $std->compile_db_string(
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,
'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']),
)
);
@@ -295,9 +296,24 @@ class post_functions extends Post {
}
// Are we checking for auto promotion?
if ($ibforums->member['g_promotion'] != '-1&-1')
{
list($gid, $gposts) = explode( '&', $ibforums->member['g_promotion'] );
if ( $gid > 0 and $gposts > 0 )
{
if ( $ibforums->member['posts'] + 1 >= $gposts )
{
$mgroup = "mgroup='$gid', ";
}
}
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.
$DB->query("UPDATE ibf_members SET ".$pcount.$mgroup.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
@@ -350,6 +366,13 @@ class post_functions extends Post {
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$extra = "";
if ($ibforums->vars['poll_tags'])
{
$extra = $ibforums->lang['poll_tag_allowed'];
}
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '11' ), 2 => array( 'f', $class->forum['id']) ) );
//---------------------------------------
@@ -370,7 +393,7 @@ class post_functions extends Post {
$mod_options = $class->mod_options();
$poll_box = $class->html->poll_box($poll);
$poll_box = $class->html->poll_box($poll, $extra);
$end_form = $class->html->EndForm( $ibforums->lang['submit_poll'] );
+488 -424
View File
@@ -1,425 +1,489 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Reply with quote library
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $quoted_post = array();
var $quoted_post_author = array();
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets load the topic from the database before we do anything else.
$DB->query("SELECT * FROM ibf_topics WHERE forum_id='".$class->forum['id']."' AND tid='".$ibforums->input['t']."'");
$this->topic = $DB->fetch_row();
// Is it legitimate?
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------------------
// Lets do some tests to make sure that we are
// allowed to reply to this topic
//-------------------------------------------------
if ($this->topic['poll_state'] == 'closed' and $ibforums->member['g_is_supadmin'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
if ($this->topic['starter_id'] == $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
if ($this->topic['starter_id'] != $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
$this->m_group = $ibforums->member['mgroup'];
if ($class->forum['reply_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['reply_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
// Is the topic locked?
if ($this->topic['state'] != 'open')
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
//-------------------------------------------------
// If we have a post to quote, lets sort that now
//-------------------------------------------------
if ($ibforums->input['QPost']) {
$this->quoted_post['post'] = $class->parser->convert( array( 'TEXT' => $ibforums->input['QPost'],
'SMILIES' => 1,
'CODE' => 1,
'HTML' => 0,
) );
$this->quoted_post['AUTHOR']['name'] = $ibforums->input['QAuthorN'];
$this->quoted_post['DATE'] = $std->get_date( $ibforums->input['QDate'], 'LONG' );
// add it to the post
$html = $class->parser->wrap_style( array( 'STYLE' => 'QUOTE',
'EXTRA' => '(' . $this->quoted_post['AUTHOR']['name'] . ' @ ' . $this->quoted_post['DATE'] . ')'
) );
if ( $class->obj['preview_post'] == "" )
{
$this->post['post'] = "<!--QuoteBegin--{$this->quoted_post['AUTHOR']['name']}+{$this->quoted_post['DATE']}-->"
. "{$html['START']}<!--QuoteEBegin-->".trim($this->quoted_post['post'])."<!--QuoteEnd-->"
. "{$html['END']}<!--QuoteEEnd--><br>"
. $this->post['post'];
}
else
{
$class->dump_quote = '[QUOTE='.$this->quoted_post['AUTHOR']['name'].','.$this->quoted_post['DATE'].']'.$ibforums->input['QPost'].'[/QUOTE]'."\n";
}
}
if ($class->obj['post_errors'] == "") {
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") ) {
// Show the form again
$this->show_form($class);
} else {
$this->add_reply($class);
}
}
function add_reply($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Update the post info with the upload array info
//-------------------------------------------------
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['attach_file'] = $this->upload['attach_file'];
//-------------------------------------------------
// Insert the post into the database to get the
// last inserted value of the auto_increment field
//-------------------------------------------------
$this->post['topic_id'] = $this->topic['tid'];
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
{
if ($ibforums->input['mod_options'] == 'pin')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
{
$this->topic['pinned'] = 1;
$class->moderate_log('Pinned topic from post form', $this->topic['title']);
}
}
else if ($ibforums->input['mod_options'] == 'close')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
{
$this->topic['state'] = 'closed';
$class->moderate_log('Closed topic from post form', $this->topic['title']);
}
}
}
$db_string = $std->compile_db_string( $this->post );
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['pid'] = $DB->get_insert_id();
if ($class->obj['moderate']) {
$print->redirect_screen( $ibforums->lang['moderate_post'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum/topic stats
//-------------------------------------------------
$class->forum['last_title'] = $this->topic['title'];
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['posts']++;
if (strlen($class->forum['last_title']) > 30)
{
$class->forum['last_title'] = substr($class->forum['last_title'],0,27) . "...";
}
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"posts='" .$class->forum['posts'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
// Update the database
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_topics SET last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"last_poster_name='" .$class->forum['last_poster_name'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"pinned='" .$this->topic['pinned'] ."', ".
"state='" .$this->topic['state'] ."', ".
"posts=posts+1 ".
"WHERE tid='" .$this->topic['tid'] ."'");
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES+1");
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
// Check for subscribed topics
//-------------------------------------------------
$class->topic_tracker( $this->topic['tid'], $this->post['post'], $class->forum['last_poster_name'] );
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
$page = $page * $ibforums->vars['display_max_posts'];
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st=$page#entry{$this->post['pid']}");
}
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 <textarea> tag in the raw post var.
//-------------------------------------------------
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
if (isset($raw_post)) {
$raw_post = preg_replace( "/<textarea>/", "&lt;textarea>", $raw_post );
$raw_post = str_replace( '$', "&#036;", $raw_post );
$raw_post = str_replace( '<%', "&lt;%" , $raw_post );
$raw_post = stripslashes($raw_post);
if ($class->dump_quote != "")
{
$raw_post = str_replace( "<br>", "\n", $class->dump_quote ) . $raw_post;
}
}
//-------------------------------------------------
// Get the old post
//-------------------------------------------------
$DB->query("SELECT post, author_id, author_name, post_date, pid FROM ibf_posts WHERE pid='".$ibforums->input['p']."'");
$this->quoted_post = $DB->fetch_row();
//-------------------------------------------------
// Unconvert the smilies, HTML and iB_Code
//-------------------------------------------------
$this->quoted_post['post'] = trim($class->parser->unconvert( $this->quoted_post['post'] ));
//-------------------------------------------------
// Do we have any posting errors?
//-------------------------------------------------
if ($class->obj['post_errors'])
{
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post'])
{
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $class->dump_quote . $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '07' ),
2 => array( 't' , $this->topic['tid']),
3 => array( 'p' , $ibforums->input['p'] )
) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
$name_fields = $class->html_name_field();
if (! $class->obj['preview_post'])
{
$quote_box = $class->html->quote_box( $this->quoted_post );
}
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options();
$end_form = $class->html->EndForm( $ibforums->lang['submit_reply'] );
$post_icons = $class->html_post_icons();
if ($class->obj['can_upload'])
{
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
}
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
$class->output = preg_replace( "/<!--QUOTE BOX-->/" , "$quote_box" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum[cat_id]}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['quoting_post'].' '.$this->topic['title'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
<?php
/*
+--------------------------------------------------------------------------
| Invision Board v1.1
| ========================================
| by Matthew Mecham
| (c) 2001,2002 Invision Power Services
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Reply with quote library
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $quoted_post = array();
var $quoted_post_author = array();
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets load the topic from the database before we do anything else.
$DB->query("SELECT * FROM ibf_topics WHERE forum_id='".$class->forum['id']."' AND tid='".$ibforums->input['t']."'");
$this->topic = $DB->fetch_row();
// Is it legitimate?
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------------------
// Lets do some tests to make sure that we are
// allowed to reply to this topic
//-------------------------------------------------
if ($this->topic['poll_state'] == 'closed' and $ibforums->member['g_is_supadmin'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
if ($this->topic['starter_id'] == $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
if ($this->topic['starter_id'] != $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
$this->m_group = $ibforums->member['mgroup'];
if ($class->forum['reply_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['reply_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
// Is the topic locked?
if ($this->topic['state'] != 'open')
{
if ($ibforums->member['g_post_closed'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
//-------------------------------------------------
// If we have a post to quote, lets sort that now
//-------------------------------------------------
if ($ibforums->input['QPost'])
{
$this->quoted_post['post'] = $class->parser->convert( array( 'TEXT' => $ibforums->input['QPost'],
'SMILIES' => 1,
'CODE' => 1,
'HTML' => 0,
) );
$this->quoted_post['AUTHOR']['name'] = $ibforums->input['QAuthorN'];
$this->quoted_post['DATE'] = $std->get_date( $ibforums->input['QDate'], 'LONG' );
// add it to the post
$html = $class->parser->wrap_style( array( 'STYLE' => 'QUOTE',
'EXTRA' => '(' . $this->quoted_post['AUTHOR']['name'] . ' @ ' . $this->quoted_post['DATE'] . ')'
) );
if ( $class->obj['preview_post'] == "" )
{
$this->post['post'] = "<!--QuoteBegin--{$this->quoted_post['AUTHOR']['name']}+{$this->quoted_post['DATE']}-->"
. "{$html['START']}<!--QuoteEBegin-->".trim($this->quoted_post['post'])."<!--QuoteEnd-->"
. "{$html['END']}<!--QuoteEEnd--><br>"
. $this->post['post'];
}
else
{
$class->dump_quote = '[QUOTE='.$this->quoted_post['AUTHOR']['name'].','.$this->quoted_post['DATE'].']'.$ibforums->input['QPost'].'[/QUOTE]'."\n";
}
}
if ($class->obj['post_errors'] == "") {
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") ) {
// Show the form again
$this->show_form($class);
} else {
$this->add_reply($class);
}
}
function add_reply($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Update the post info with the upload array info
//-------------------------------------------------
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['attach_file'] = $this->upload['attach_file'];
//-------------------------------------------------
// Insert the post into the database to get the
// last inserted value of the auto_increment field
//-------------------------------------------------
$this->post['topic_id'] = $this->topic['tid'];
$return_to_move = 0;
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
{
if ($ibforums->input['mod_options'] == 'pin')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
{
$this->topic['pinned'] = 1;
$class->moderate_log('Pinned topic from post form', $this->topic['title']);
}
}
else if ($ibforums->input['mod_options'] == 'close')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
{
$this->topic['state'] = 'closed';
$class->moderate_log('Closed topic from post form', $this->topic['title']);
}
}
else if ($ibforums->input['mod_options'] == 'move')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['move_topic'] == 1)
{
$return_to_move = 1;
}
}
}
$db_string = $std->compile_db_string( $this->post );
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['pid'] = $DB->get_insert_id();
if ($class->obj['moderate']) {
$print->redirect_screen( $ibforums->lang['moderate_post'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum/topic stats
//-------------------------------------------------
$class->forum['last_title'] = $this->topic['title'];
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['posts']++;
if (strlen($class->forum['last_title']) > 30)
{
$class->forum['last_title'] = substr($class->forum['last_title'],0,27) . "...";
}
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"posts='" .$class->forum['posts'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
// Update the database
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_topics SET last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"last_poster_name='" .$class->forum['last_poster_name'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"pinned='" .$this->topic['pinned'] ."', ".
"state='" .$this->topic['state'] ."', ".
"posts=posts+1 ".
"WHERE tid='" .$this->topic['tid'] ."'");
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES+1");
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
// Are we checking for auto promotion?
if ($ibforums->member['g_promotion'] != '-1&-1')
{
list($gid, $gposts) = explode( '&', $ibforums->member['g_promotion'] );
if ( $gid > 0 and $gposts > 0 )
{
if ( $ibforums->member['posts'] + 1 >= $gposts )
{
$mgroup = "mgroup='$gid', ";
}
}
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.$mgroup.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
// Are we tracking topics we reply in 'auto_track'?
//-------------------------------------------------
if ($ibforums->member['auto_track'] == 1)
{
$DB->query("SELECT trid FROM ibf_tracker WHERE topic_id='".$this->topic['tid']."' AND member_id='".$ibforums->member['id']."'");
if ( ! $DB->get_num_rows() )
{
$db_string = $DB->compile_db_insert_string( array (
'member_id' => $ibforums->member['id'],
'topic_id' => $this->topic['tid'],
'start_date' => time(),
) );
$DB->query("INSERT INTO ibf_tracker ({$db_string['FIELD_NAMES']}) VALUES ({$db_string['FIELD_VALUES']})");
}
}
//-------------------------------------------------
// Check for subscribed topics
// Pass on the previous last post time of the topic
// to see if we need to send emails out
//-------------------------------------------------
$class->topic_tracker( $this->topic['tid'], $this->post['post'], $class->forum['last_poster_name'], $this->topic['last_post'] );
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
if ($return_to_move == 1)
{
$std->boink_it($class->base_url."&act=Mod&CODE=02&f={$class->forum['id']}&t={$this->topic['tid']}");
}
else
{
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
$page = $page * $ibforums->vars['display_max_posts'];
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
}
}
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 <textarea> tag in the raw post var.
//-------------------------------------------------
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
if (isset($raw_post)) {
$raw_post = str_replace( '$' , "&#036;" , htmlspecialchars($raw_post) );
$raw_post = stripslashes($raw_post);
if ($class->dump_quote != "")
{
$raw_post = str_replace( "<br>", "\n", $class->dump_quote ) . $raw_post;
}
}
//-------------------------------------------------
// Get the old post
//-------------------------------------------------
$DB->query("SELECT post, author_id, author_name, post_date, pid FROM ibf_posts WHERE pid='".$ibforums->input['p']."'");
$this->quoted_post = $DB->fetch_row();
//-------------------------------------------------
// Unconvert the smilies, HTML and iB_Code
//-------------------------------------------------
$this->quoted_post['post'] = trim($class->parser->unconvert( $this->quoted_post['post'] ));
//-------------------------------------------------
// Are we stripping quotes?
//-------------------------------------------------
if ($ibforums->vars['strip_quotes'])
{
$this->quoted_post['post'] = preg_replace( "#\[QUOTE(=.+?,.+?)?\].+?\[/QUOTE\]#i", "", $this->quoted_post['post'] );
}
//-------------------------------------------------
// Do we have any posting errors?
//-------------------------------------------------
if ($class->obj['post_errors'])
{
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post'])
{
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $class->dump_quote . $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '07' ),
2 => array( 't' , $this->topic['tid']),
3 => array( 'p' , $ibforums->input['p'] )
) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
$name_fields = $class->html_name_field();
if (! $class->obj['preview_post'])
{
$quote_box = $class->html->quote_box( $this->quoted_post );
}
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options(1);
$end_form = $class->html->EndForm( $ibforums->lang['submit_reply'] );
$post_icons = $class->html_post_icons();
if ($class->obj['can_upload'])
{
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
}
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
$class->output = preg_replace( "/<!--QUOTE BOX-->/" , "$quote_box" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum[cat_id]}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['quoting_post'].' '.$this->topic['title'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
?>
+411 -359
View File
@@ -1,360 +1,412 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Reply post module
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets load the topic from the database before we do anything else.
$DB->query("SELECT * FROM ibf_topics WHERE forum_id='".$class->forum['id']."' AND tid='".$ibforums->input['t']."'");
$this->topic = $DB->fetch_row();
// Is it legitimate?
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------------------
// Lets do some tests to make sure that we are
// allowed to reply to this topic
//-------------------------------------------------
if ($this->topic['poll_state'] == 'closed' and $ibforums->member['g_is_supadmin'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
if ($this->topic['starter_id'] == $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
if ($this->topic['starter_id'] != $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
$this->m_group = $ibforums->member['mgroup'];
if ($class->forum['reply_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['reply_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
// Is the topic locked?
if ($this->topic['state'] != 'open')
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
if ($class->obj['post_errors'] == "")
{
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
{
// Show the form again
$this->show_form($class);
}
else
{
$this->add_reply($class);
}
}
function add_reply($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Update the post info with the upload array info
//-------------------------------------------------
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['attach_file'] = $this->upload['attach_file'];
//-------------------------------------------------
// Insert the post into the database to get the
// last inserted value of the auto_increment field
//-------------------------------------------------
$this->post['topic_id'] = $this->topic['tid'];
//-------------------------------------------------
// Are we a mod, and can we change the topic state?
//-------------------------------------------------
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
{
if ($ibforums->input['mod_options'] == 'pin')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
{
$this->topic['pinned'] = 1;
$class->moderate_log('Pinned topic from post form', $this->topic['title']);
}
}
else if ($ibforums->input['mod_options'] == 'close')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
{
$this->topic['state'] = 'closed';
$class->moderate_log('Closed topic from post form', $this->topic['title']);
}
}
}
$db_string = $std->compile_db_string( $this->post );
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['pid'] = $DB->get_insert_id();
if ($class->obj['moderate']) {
$print->redirect_screen( $ibforums->lang['moderate_post'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum/topic stats
//-------------------------------------------------
$class->forum['last_title'] = $this->topic['title'];
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['posts']++;
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"posts='" .$class->forum['posts'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
// Update the database
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_topics SET last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"last_poster_name='" .$class->forum['last_poster_name'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"pinned='" .$this->topic['pinned'] ."', ".
"state='" .$this->topic['state'] ."', ".
"posts=posts+1 ".
"WHERE tid='" .$this->topic['tid'] ."'");
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES+1");
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
// Check for subscribed topics
//-------------------------------------------------
$class->topic_tracker( $this->topic['tid'], $this->post['post'], $class->forum['last_poster_name'] );
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
$page = $page * $ibforums->vars['display_max_posts'];
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
}
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 <textarea> tag in the raw post var.
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
if (isset($raw_post)) {
$raw_post = preg_replace( "/<textarea>/", "&lt;textarea>", $raw_post );
$raw_post = str_replace( '$', "&#036;", $raw_post );
$raw_post = str_replace( '<%', "&lt;%" , $raw_post );
$raw_post = stripslashes($raw_post);
}
// Do we have any posting errors?
if ($class->obj['post_errors']) {
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post']) {
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '03' ),
2 => array( 't' , $this->topic['tid'])
) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options();
$end_form = $class->html->EndForm( $ibforums->lang['submit_reply'] );
$post_icons = $class->html_post_icons();
if ($class->obj['can_upload'])
{
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
}
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum[cat_id]}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['replying_in'].' '.$this->topic['title'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
<?php
/*
+--------------------------------------------------------------------------
| Invision Board v1.1
| ========================================
| by Matthew Mecham
| (c) 2001,2002 Invision Power Services
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Reply post module
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets load the topic from the database before we do anything else.
$DB->query("SELECT * FROM ibf_topics WHERE forum_id='".$class->forum['id']."' AND tid='".$ibforums->input['t']."'");
$this->topic = $DB->fetch_row();
// Is it legitimate?
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------------------
// Lets do some tests to make sure that we are
// allowed to reply to this topic
//-------------------------------------------------
if ($this->topic['poll_state'] == 'closed' and $ibforums->member['g_is_supadmin'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
if ($this->topic['starter_id'] == $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
if ($this->topic['starter_id'] != $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
$this->m_group = $ibforums->member['mgroup'];
if ($class->forum['reply_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['reply_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
// Is the topic locked?
if ($this->topic['state'] != 'open')
{
if ($ibforums->member['g_post_closed'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
if ($class->obj['post_errors'] == "")
{
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
{
// Show the form again
$this->show_form($class);
}
else
{
$this->add_reply($class);
}
}
function add_reply($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Update the post info with the upload array info
//-------------------------------------------------
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['attach_file'] = $this->upload['attach_file'];
//-------------------------------------------------
// Insert the post into the database to get the
// last inserted value of the auto_increment field
//-------------------------------------------------
$this->post['topic_id'] = $this->topic['tid'];
//-------------------------------------------------
// Are we a mod, and can we change the topic state?
//-------------------------------------------------
$return_to_move = 0;
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
{
if ($ibforums->input['mod_options'] == 'pin')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
{
$this->topic['pinned'] = 1;
$class->moderate_log('Pinned topic from post form', $this->topic['title']);
}
}
else if ($ibforums->input['mod_options'] == 'close')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
{
$this->topic['state'] = 'closed';
$class->moderate_log('Closed topic from post form', $this->topic['title']);
}
}
else if ($ibforums->input['mod_options'] == 'move')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['move_topic'] == 1)
{
$return_to_move = 1;
}
}
}
$db_string = $std->compile_db_string( $this->post );
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['pid'] = $DB->get_insert_id();
if ($class->obj['moderate']) {
$print->redirect_screen( $ibforums->lang['moderate_post'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum/topic stats
//-------------------------------------------------
$class->forum['last_title'] = $this->topic['title'];
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['posts']++;
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"posts='" .$class->forum['posts'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
// Update the database
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_topics SET last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"last_poster_name='" .$class->forum['last_poster_name'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"pinned='" .$this->topic['pinned'] ."', ".
"state='" .$this->topic['state'] ."', ".
"posts=posts+1 ".
"WHERE tid='" .$this->topic['tid'] ."'");
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES+1");
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
$mgroup = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
// Are we checking for auto promotion?
if ($ibforums->member['g_promotion'] != '-1&-1')
{
list($gid, $gposts) = explode( '&', $ibforums->member['g_promotion'] );
if ( $gid > 0 and $gposts > 0 )
{
if ( $ibforums->member['posts'] + 1 >= $gposts )
{
$mgroup = "mgroup='$gid', ";
}
}
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.$mgroup.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
// Are we tracking topics we reply in 'auto_track'?
//-------------------------------------------------
if ($ibforums->member['auto_track'] == 1)
{
$DB->query("SELECT trid FROM ibf_tracker WHERE topic_id='".$this->topic['tid']."' AND member_id='".$ibforums->member['id']."'");
if ( ! $DB->get_num_rows() )
{
$db_string = $DB->compile_db_insert_string( array (
'member_id' => $ibforums->member['id'],
'topic_id' => $this->topic['tid'],
'start_date' => time(),
) );
$DB->query("INSERT INTO ibf_tracker ({$db_string['FIELD_NAMES']}) VALUES ({$db_string['FIELD_VALUES']})");
}
}
//-------------------------------------------------
// Check for subscribed topics
// Pass on the previous last post time of the topic
// to see if we need to send emails out
//-------------------------------------------------
$class->topic_tracker( $this->topic['tid'], $this->post['post'], $class->forum['last_poster_name'], $this->topic['last_post'] );
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
if ($return_to_move == 1)
{
$std->boink_it($class->base_url."&act=Mod&CODE=02&f={$class->forum['id']}&t={$this->topic['tid']}");
}
else
{
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
$page = $page * $ibforums->vars['display_max_posts'];
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
}
}
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 <textarea> tag in the raw post var.
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
if (isset($raw_post)) {
$raw_post = str_replace( '$' , "&#036;" , htmlspecialchars($raw_post) );
$raw_post = stripslashes($raw_post);
}
// Do we have any posting errors?
if ($class->obj['post_errors']) {
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post']) {
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '03' ),
2 => array( 't' , $this->topic['tid'])
) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options(1);
$end_form = $class->html->EndForm( $ibforums->lang['submit_reply'] );
$post_icons = $class->html_post_icons();
if ($class->obj['can_upload'])
{
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
}
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum[cat_id]}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['replying_in'].' '.$this->topic['title'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
?>
+17 -3
View File
@@ -2,10 +2,10 @@
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| Invision Board v1.1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| by Matthew Mecham
| (c) 2001,2002 Invision Power Services
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
@@ -29,6 +29,20 @@
| own.
|
+--------------------------------------------------------------------------
|
| LICENCE OF USE (THIS MODULE ONLY)
|
| This module has been created and released under the GNU licence and may be
| freely used and distributed. If you find some space to credit us in your source
| code, it'll be appreciated.
|
| Report all bugs / improvements to matt@ibforums.com
|
| NOTE: This does not affect the current licence for the rest of the Invision
| board code. I just wanted to share this module as there is a lack of other
| decent tar proggies for PHP.
|
+--------------------------------------------------------------------------
*/
/*************************************************************
File diff suppressed because it is too large. Load diff