Version 1.0.1

This commit is contained in:
Neo committed 2025-12-19 00:15:26 -08:00
1 parent 227753f492
commit aabfdc1f57
341 files changed
+55517

No files matched your search

+174
View File
@@ -0,0 +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']}" );
}
}
?>
+292
View File
@@ -0,0 +1,292 @@
<?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
+---------------------------------------------------------------------------
|
| > Sending email module
| > Module written by Matt Mecham
| > Date started: 26th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
|
| QUOTE OF THE MODULE: (Taken from "Shrek" (c) Dreamworks Pictures)
| --------------------
| DONKEY: We can stay up late, swap manly stories and in the morning,
| I'm making waffles!
|
+--------------------------------------------------------------------------
*/
// This module is fairly basic, more functionality is expected in future
// versions (such as MIME attachments, SMTP stuff, etc)
class emailer {
var $from = "";
var $to = "";
var $subject = "";
var $message = "";
var $header = "";
var $footer = "";
var $template = "";
var $error = "";
var $parts = array();
var $bcc = "";
var $mail_headers = array();
var $multipart = "";
var $boundry = "";
var $temp_dump = 0;
function emailer() {
global $ibforums;
// Assign $from as the admin out email address, this can be
// over-riden at any time.
$this->from = $ibforums->vars['email_out'];
// Temporarily assign $header and $footer, this can be over-riden
// also
$this->header = $ibforums->vars['email_header'];
$this->footer = $ibforums->vars['email_footer'];
$this->boundry = "----=_NextPart_000_0022_01C1BD6C.D0C0F9F0"; //"b".md5(uniqid(time()));
}
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";
$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 )
{
$this->mail_headers .= "MIME-Version: 1.0\n";
$this->mail_headers .= "Content-Type: multipart/mixed;\n\tboundary=\"".$this->boundry."\"\n\nThis is a MIME encoded message.\n\n--".$this->boundry;
$this->mail_headers .= "\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\"\nContent-Transfer-Encoding: quoted-printable\n\n".$this->message."\n\n--".$this->boundry;
$this->mail_headers .= $this->build_multipart();
$this->message = "";
}
}
function encode_attachment($part) {
$msg = chunk_split(base64_encode($part['data']));
return "Content-Type: ".$part['ctype']. ($part['name'] ? ";\n\tname =\"".$part['name']."\"" : "").
"\nContent-Transfer-Encoding: ".$part['encode']."\nContent-Disposition: attachment;\n\tfilename=\"".$part['name']."\"\n\n".$msg."\n";
}
function build_multipart() {
$multipart = "";
for ($i = sizeof($this->parts) - 1 ; $i >= 0 ; $i--)
{
$multipart .= "\n".$this->encode_attachment($this->parts[$i]) . "--".$this->boundry;
}
return $multipart . "--\n";
}
//+--------------------------------------------------------------------------
// send_mail:
// Physically sends the email
//+--------------------------------------------------------------------------
function send_mail() {
$this->to = preg_replace( "/[ \t]+/" , " " , $this->to );
$this->from = preg_replace( "/[ \t]+/" , " " , $this->from );
$this->to = preg_replace( "/,,/" , "," , $this->to );
$this->from = preg_replace( "/,,/" , "," , $this->from );
$this->to = preg_replace( "#\#\[\]'\"\(\):;/\$!£%\^&\*\{\}#" , "", $this->to );
$this->from = preg_replace( "#\#\[\]'\"\(\):;/\$!£%\^&\*\{\}#" , "", $this->from);
$this->subject = $this->clean_message($this->subject);
$this->build_headers();
if ( ($this->from) and ($this->subject) )
{
if ($this->temp_dump == 1)
{
$blah = $this->to."\n".$this->from."\n".$this->subject."\n".$this->mail_headers."\n\n".$this->message;
$pathy = '/Library/WebServer/Documents/mail/'.date("js.F.Y.h:i.A"); // OS X rules!
$fh = fopen ($pathy, 'w');
fputs ($fh, $blah, strlen($blah) );
fclose($fh);
}
else
{
if ( ! @mail( $this->to, $this->subject, $this->message, $this->mail_headers ) )
{
$this->fatal_error("Could not sent the email", "Failed at 'mail' command");
}
}
}
else
{
return FALSE;
}
}
//+--------------------------------------------------------------------------
// get_template:
// Queries the database, and stores the template we wish to use in memory
//+--------------------------------------------------------------------------
function get_template($name="", $language="en") {
global $IB, $DB;
if ($name == "")
{
$this->error++;
$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";
}
else
{
require "./lang/$language/email_content.php";
}
if (! isset($EMAIL[ $name ]) ) {
$this->fatal_error("Could not find an email template with an ID of '$name'", "");
}
$this->template = $EMAIL[ $name ];
}
//+--------------------------------------------------------------------------
// build_message:
// Swops template tags into the corresponding string held in $words array.
// Also joins header and footer to message and cleans the message for sending
//+--------------------------------------------------------------------------
function build_message($words) {
global $ibforums;
if ($this->template == "") {
$this->error++;
$this->fatal_error("Could not build the email message, no template assigned", "Make sure a template is assigned first.");
}
$this->message = $this->template;
// Add some default words
$words['BOARD_ADDRESS'] = $ibforums->vars['board_url'] . '/index.' . $ibforums->vars['php_ext'];
$words['WEB_ADDRESS'] = $ibforums->vars['home_url'];
$words['BOARD_NAME'] = $ibforums->vars['board_name'];
$words['SIGNATURE'] = $ibforums->vars['signature'];
// Swop the words
$this->message = preg_replace( "/<#(.+?)#>/e", "\$words[\\1]", $this->message );
$this->message = $this->clean_message( $this->message );
}
//+--------------------------------------------------------------------------
// clean_message: (Mainly used internally)
// Ensures that \n and <br> are converted into CRLF (\r\n)
// Also unconverts some iB_CODE.
//+--------------------------------------------------------------------------
function clean_message($message = "" ) {
$message = preg_replace( "#<b>(.+?)</b>#" , "\\1", $message );
$message = preg_replace( "#<i>(.+?)</i>#" , "\\1", $message );
$message = preg_replace( "#<s>(.+?)</s>#" , "--\\1--", $message );
$message = preg_replace( "#<u>(.+?)</u>#" , "-\\1-" , $message );
$message = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , $message );
$message = preg_replace( "#<!--c1-->(.+?)<!--ec1-->#", "\n\n------------ CODE SAMPLE ----------\n" , $message );
$message = preg_replace( "#<!--c2-->(.+?)<!--ec2-->#", "\n-----------------------------------\n\n" , $message );
$message = preg_replace( "#<!--QuoteBegin-->(.+?)<!--QuoteEBegin-->#" , "\n\n------------ QUOTE ----------\n" , $message );
$message = preg_replace( "#<!--QuoteBegin--(.+?)\+(.+?)-->(.+?)<!--QuoteEBegin-->#" , "\n\n------------ QUOTE ----------\n" , $message );
$message = preg_replace( "#<!--QuoteEnd-->(.+?)<!--QuoteEEnd-->#" , "\n-----------------------------\n\n" , $message );
$message = preg_replace( "#<!--Flash (.+?)-->.+?<!--End Flash-->#e" , "(FLASH MOVIE)" , $message );
$message = preg_replace( "#<img src=[\"'](\S+?)['\"].+?".">#" , "(IMAGE: \\1)" , $message );
$message = preg_replace( "#<a href=[\"'](http|https|ftp|news)://(\S+?)['\"].+?".">(.+?)</a>#" , "(URL: \\1)" , $message );
$message = preg_replace( "#<a href=[\"']mailto:(.+?)['\"]>(.+?)</a>#" , "(EMAIL: \\2)" , $message );
$message = preg_replace( "#<!--sql-->(.+?)<!--sql1-->(.+?)<!--sql2-->(.+?)<!--sql3-->#e" , "\n\n--------------- SQL -----------\n\\2\n----------------\n\n", $message);
$message = preg_replace( "#<!--html-->(.+?)<!--html1-->(.+?)<!--html2-->(.+?)<!--html3-->#e", "\n\n-------------- HTML -----------\n\\2\n----------------\n\n", $message);
$message = preg_replace( "#<!--EDIT\|.+?\|.+?-->#" , "" , $message );
$message = preg_replace( "#<.+?".">#" , "" , $message );
$message = preg_replace( "/(<br>|\n)/" , "\r\n", $message );
$message = str_replace( "&quot;", "\"", $message );
$message = str_replace( "&#092;", "\\", $message );
$message = str_replace( "&#036;", "\$", $message );
$message = str_replace( "&#33;" , "!", $message );
$message = str_replace( "&#39;" , "'", $message );
$message = str_replace( "&lt;" , "<", $message );
$message = str_replace( "&gt;" , ">", $message );
$message = str_replace( "&amp;" , "&", $message );
return $message;
}
function fatal_error($msg, $help="")
{
echo("<h1>Mail Error!</h1><br><b>$msg</b><br>$help");
exit();
}
}
?>
+280
View File
@@ -0,0 +1,280 @@
<?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,
) );
}
}
?>
+372
View File
@@ -0,0 +1,372 @@
<?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,
) );
}
}
?>
+972
View File
@@ -0,0 +1,972 @@
<?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
+---------------------------------------------------------------------------
|
| > Text processor module
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
*/
class post_parser {
var $error = "";
var $image_count = 0;
var $emoticon_count = 0;
var $quote_html = array();
var $quote_open = 0;
var $quote_closed = 0;
var $quote_error = 0;
var $emoticons = "";
var $badwords = "";
function smilie_length_sort($a, $b)
{
if ( strlen($a['typed']) == strlen($b['typed']) )
{
return 0;
}
return ( strlen($a['typed']) > strlen($b['typed']) ) ? -1 : 1;
}
function word_length_sort($a, $b)
{
if ( strlen($a['type']) == strlen($b['type']) )
{
return 0;
}
return ( strlen($a['type']) > strlen($b['type']) ) ? -1 : 1;
}
function post_parser($load=0)
{
global $ibforums, $DB;
if ($load != 0)
{
// Pre-load the bad words
$DB->query("SELECT * from ibf_badwords");
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$this->badwords[] = array( 'type' => stripslashes($r['type']),
'swop' => stripslashes($r['swop']),
'm_exact' => $r['m_exact'],
);
}
}
// Pre-load the smilies
$this->emoticons = array();
$DB->query("SELECT typed, image from ibf_emoticons");
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$this->emoticons[] = array( 'typed' => stripslashes($r['typed']),
'image' => stripslashes($r['image']),
'clickable' => $r['clickable'],
);
}
}
}
}
/**************************************************/
// convert:
// Parses raw text into smilies, HTML and iB CODE
/**************************************************/
function convert($in=array( 'TEXT' => "", 'SMILIES' => 0, 'CODE' => 0, 'SIGNATURE' => 0, 'HTML' => 0)) {
global $ibforums, $DB;
$txt = $in['TEXT'];
//--------------------------------------
// Returns any errors as $this->error
//--------------------------------------
// Remove session id's from any post
$txt = preg_replace( "#[?&;]s=([0-9][a-z][A-Z]){32}#", "", $txt );
//--------------------------------------
// convert <br> to \n
//--------------------------------------
$txt = preg_replace( "/<br>|<br\s*\/>/", "\n", $txt );
//--------------------------------------
// Are we parsing iB_CODE and do we have either '[' or ']' in the
// text we are processing?
//--------------------------------------
if ( $in['CODE'] == 1 ) {
//--------------------------------------
// Auto parse URLs
//--------------------------------------
$txt = preg_replace( "#(^|\s)((http|https|news|ftp)://\w+\S+)#ie" , "\$this->regex_build_url(array('html' => '\\2', 'show' => '\\2', 'st' => '\\1'))", $txt );
//---------------------------------
// Do [CODE] tag
//---------------------------------
$txt = preg_replace( "#\[code\](.+?)\[/code\]#ies", "\$this->regex_code_tag('\\1')", $txt );
//---------------------------------
// Do [QUOTE(name,date)] tags
//---------------------------------
// Find the first, and last quote tag (greedy match)...
$txt = preg_replace( "#(\[quote.*\].*\[/quote\])#ies" , "\$this->regex_parse_quotes('\\1')" , $txt );
/***********************************************/
// If we are not parsing a siggie, lets have a bash
// at the [PHP] [SQL] and [HTML] tags.
/***********************************************/
if ($in['SIGNATURE'] != 1) {
$txt = preg_replace( "#\[sql\](.+?)\[/sql\]#ies" , "\$this->regex_sql_tag('\\1')" , $txt );
$txt = preg_replace( "#\[html\](.+?)\[/html\]#ies" , "\$this->regex_html_tag('\\1')" , $txt );
// [LIST] [*] [/LIST]
//-------------------------
$txt = preg_replace( "#\[list\]#i" , "<ul>" , $txt );
$txt = preg_replace( "#\[\*\]#" , "<li>" , $txt );
$txt = preg_replace( "#\[/list\]#i" , "</ul>", $txt );
}
//---------------------------------
// Do [IMG] [FLASH] tags
//---------------------------------
if ($ibforums->vars['allow_images'])
{
$txt = preg_replace( "#\[img\](.+?)\[/img\]#ie" , "\$this->regex_check_image('\\1')" , $txt );
$txt = preg_replace( "#(\[flash=)(\S+?)(\,)(\S+?)(\])(\S+?)(\[\/flash\])#ie", "\$this->regex_check_flash('\\2','\\4','\\6')", $txt );
}
// Start off with the easy stuff
$txt = preg_replace( "#\[b\](.+?)\[/b\]#is", "<b>\\1</b>", $txt );
$txt = preg_replace( "#\[i\](.+?)\[/i\]#is", "<i>\\1</i>", $txt );
$txt = preg_replace( "#\[u\](.+?)\[/u\]#is", "<u>\\1</u>", $txt );
$txt = preg_replace( "#\[s\](.+?)\[/s\]#is", "<s>\\1</s>", $txt );
// (c) (r) and (tm)
$txt = preg_replace( "#\(c\)#i" , "&copy;" , $txt );
$txt = preg_replace( "#\(tm\)#i" , "&#153;" , $txt );
$txt = preg_replace( "#\(r\)#i" , "&reg;" , $txt );
// font size, colour and font style
// [font=courier]Text here[/font] [size=6]Text here[/size] [color=red]Text here[/color]
while ( preg_match( "#\[size=([^\]]+)\](.+?)\[/size\]#ies", $txt ) )
{
$txt = preg_replace( "#\[size=([^\]]+)\](.+?)\[/size\]#ies" , "\$this->regex_font_attr(array('s'=>'size','1'=>'\\1','2'=>'\\2'))", $txt );
}
while ( preg_match( "#\[font=([^\]]+)\](.*?)\[/font\]#ies", $txt ) )
{
$txt = preg_replace( "#\[font=([^\]]+)\](.*?)\[/font\]#ies" , "\$this->regex_font_attr(array('s'=>'font','1'=>'\\1','2'=>'\\2'))", $txt );
}
while( preg_match( "#\[color=([^\]]+)\](.+?)\[/color\]#ies", $txt ) )
{
$txt = preg_replace( "#\[color=([^\]]+)\](.+?)\[/color\]#ies" , "\$this->regex_font_attr(array('s'=>'col' ,'1'=>'\\1','2'=>'\\2'))", $txt );
}
// email tags
// [email]matt@index.com[/email] [email=matt@index.com]Email me[/email]
$txt = preg_replace( "#\[email\](\S+?)\[/email\]#i" , "<a href='mailto:\\1'>\\1</a>", $txt );
$txt = preg_replace( "#\[email\s*=\s*\&quot\;([\.\w\-]+\@[\.\w\-]+\.[\.\w\-]+)\s*\&quot\;\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\\1'>\\2</a>", $txt );
$txt = preg_replace( "#\[email\s*=\s*([\.\w\-]+\@[\.\w\-]+\.[\w\-]+)\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\\1'>\\2</a>", $txt );
// url tags
// [url]http://www.index.com[/url] [url=http://www.index.com]ibforums![/url]
$txt = preg_replace( "#\[url\](\S+?)\[/url\]#ie" , "\$this->regex_build_url(array('html' => '\\1', 'show' => '\\1'))", $txt );
$txt = preg_replace( "#\[url\s*=\s*\&quot\;\s*(\S+?)\s*\&quot\;\s*\](.*?)\[\/url\]#ie" , "\$this->regex_build_url(array('html' => '\\1', 'show' => '\\2'))", $txt );
$txt = preg_replace( "#\[url\s*=\s*(\S+?)\s*\](.*?)\[\/url\]#ie" , "\$this->regex_build_url(array('html' => '\\1', 'show' => '\\2'))", $txt );
}
// Swop \n back to <br>
$txt = preg_replace( "/\n/", "<br>", $txt );
//+---------------------------------------------------------------------------------------------------
// Parse smilies (disallow smilies in siggies, or we'll have to query the DB for each post
// and each signature when viewing a topic, not something that we really want to do.
//+---------------------------------------------------------------------------------------------------
if ($in['SMILIES'] != 0 and $in['SIGNATURE'] == 0) {
if ( ! is_array($this->emoticons) )
{
$DB->query("SELECT typed, image from ibf_emoticons");
$this->emoticons = array();
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$this->emoticons[] = array( 'typed' => stripslashes($r['typed']),
'image' => stripslashes($r['image']),
'clickable' => $r['clickable'],
);
}
}
}
usort($this->emoticons, array( 'post_parser', 'smilie_length_sort' ) );
if ( count($this->emoticons) > 0 )
{
foreach($this->emoticons as $a_id => $row)
{
$code = $row['typed'];
$image = $row['image'];
/*$code = str_replace( "&", "&amp;", $code );
$code = str_replace( "<", "&lt;" , $code );
$code = str_replace( ">", "&gt;" , $code );
$code = str_replace( "\"", "&quot;", $code);
$code = str_replace( "'", "&#039;" , $code);
$code = str_replace( "!", "&#033;" , $code);
$code = str_replace( "|", "&#124;" , $code);*/
// Make safe for regex
$code = preg_quote($code, "/");
$txt = preg_replace( "!(?<=[^\w&])$code(?=.\W|\W.|\W$)!ei", "\$this->convert_emoticon('$code', '$image')", ' '.$txt.' ' );
}
}
if ($ibforums->vars['max_emos'])
{
if ($this->emoticon_count > $ibforums->vars['max_emos'])
{
$this->error = 'too_many_emoticons';
}
}
}
$txt = $this->bad_words($txt);
if ($in['HTML'] == 1)
{
$txt = str_replace( "&lt;" ,"<" , $txt );
$txt = str_replace( "&gt;" ,">" , $txt );
$txt = str_replace( "&quot;" ,"\"", $txt);
$txt = str_replace( "&#039;" ,"'" , $txt);
$txt = str_replace( "&amp;" ,"&" , $txt );
}
return $txt; //trim($txt);
}
/**************************************************/
// Badwords:
// Swops naughty, naugty words and stuff
/**************************************************/
function bad_words($text = "")
{
global $DB, $ibforums;
if ($text == "")
{
return "";
}
//--------------------------------
if ( ! is_array($this->badwords) )
{
$DB->query("SELECT * from ibf_badwords");
$this->badwords = array();
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$this->badwords[] = array( 'type' => stripslashes($r['type']),
'swop' => stripslashes($r['swop']),
'm_exact' => $r['m_exact'],
);
}
}
}
usort($this->badwords, array( 'post_parser', 'word_length_sort' ) );
if ( count($this->badwords) > 0 )
{
foreach($this->badwords as $idx => $r)
{
if ($r['swop'] == "")
{
$replace = '######';
}
else
{
$replace = $r['swop'];
}
//---------------------------
$r['type'] = preg_quote($r['type'], "/");
//---------------------------
if ($r['m_exact'] == 1)
{
$text = preg_replace( "/(^|\b)".$r['type']."(\b|!|\?|\.|,|$)/i", "$replace", $text );
}
else
{
$text = preg_replace( "/".$r['type']."/i", "$replace", $text );
}
}
}
return $text;
}
/**************************************************/
// unconvert:
// Parses the HTML back into plain text
/**************************************************/
function unconvert($txt="", $code=1, $html=0) {
if ($code == 1)
{
$txt = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , $txt );
$txt = preg_replace( "#<!--sql-->(.+?)<!--sql1-->(.+?)<!--sql2-->(.+?)<!--sql3-->#e" , "\$this->unconvert_sql(\"\\2\")", $txt);
$txt = preg_replace( "#<!--html-->(.+?)<!--html1-->(.+?)<!--html2-->(.+?)<!--html3-->#e", "\$this->unconvert_htm(\"\\2\")", $txt);
$txt = preg_replace( "#<!--Flash (.+?)-->.+?<!--End Flash-->#e" , "\$this->unconvert_flash('\\1')", $txt );
$txt = preg_replace( "#<img src=[\"'](\S+?)['\"].+?".">#" , "\[IMG\]\\1\[/IMG\]" , $txt );
$txt = preg_replace( "#<a href=[\"'](http://|https://|ftp://|news://)?(\S+?)['\"].+?".">(.+?)</a>#" , "\[URL=\\1\\2\]\\3\[/URL\]" , $txt );
$txt = preg_replace( "#<a href=[\"']mailto:(.+?)['\"]>(.+?)</a>#" , "\[EMAIL=\\1\]\\2\[/EMAIL\]" , $txt );
$txt = preg_replace( "#<i>(.+?)</i>#" , "\[i\]\\1\[/i\]" , $txt );
$txt = preg_replace( "#<b>(.+?)</b>#" , "\[b\]\\1\[/b\]" , $txt );
$txt = preg_replace( "#<s>(.+?)</s>#" , "\[s\]\\1\[/s\]" , $txt );
$txt = preg_replace( "#<u>(.+?)</u>#" , "\[u\]\\1\[/u\]" , $txt );
$txt = preg_replace( "#<ul>#" , "\[LIST\]" , $txt );
$txt = preg_replace( "#<li>#" , "\[*\]" , $txt );
$txt = preg_replace( "#</ul>#", "\[/LIST\]" , $txt );
$txt = preg_replace( "#<!--me&(.+?)-->(.+?)<!--e--me-->#e" , "\$this->unconvert_me('\\1', '\\2')", $txt );
$txt = preg_replace( "#<span style=['\"]font-size:(.+?)pt;line-height:100%['\"]>(.+?)</span>#e" , "\$this->unconvert_size('\\1', '\\2')", $txt );
$txt = preg_replace( "#<span style=['\"]color:(.+?)['\"]>(.+?)</span>#" , "\[color=\\1\]\\2\[/color\]", $txt );
$txt = preg_replace( "#<span style=['\"]font-family:(.+?)['\"]>(.+?)</span>#" , "\[font=\\1\]\\2\[/font\]" , $txt );
$txt = preg_replace( "#<!--c1-->(.+?)<!--ec1-->#", '[CODE]' , $txt );
$txt = preg_replace( "#<!--c2-->(.+?)<!--ec2-->#", '[/CODE]' , $txt );
$txt = preg_replace( "#<!--QuoteBegin-->(.+?)<!--QuoteEBegin-->#" , '[QUOTE]' , $txt );
$txt = preg_replace( "#<!--QuoteBegin--(.+?)\+(.+?)-->(.+?)<!--QuoteEBegin-->#" , "[QUOTE=\\1,\\2]" , $txt );
$txt = preg_replace( "#<!--QuoteEnd-->(.+?)<!--QuoteEEnd-->#" , '[/QUOTE]' , $txt );
// Tidy up the end quote stuff
$txt = preg_replace( "#(\[/QUOTE\])\s*?<br>\s*#si", "\\1\n", $txt );
$txt = preg_replace( "#<!--EDIT\|.+?\|.+?-->#" , "" , $txt );
}
if ($html == 1)
{
$txt = str_replace( "&#39;", "'", $txt);
}
$txt = preg_replace( "#<br>#", "\n", $txt );
return trim(stripslashes($txt));
}
//+-----------------------------------------------------------------------------------------
//+-----------------------------------------------------------------------------------------
// UNCONVERT FUNCTIONS
//+-----------------------------------------------------------------------------------------
//+-----------------------------------------------------------------------------------------
function unconvert_size($size="", $text="") {
$size -= 7;
return '[SIZE='.$size.']'.$text.'[/SIZE]';
}
function unconvert_flash($flash="") {
$f_arr = explode( "+", $flash );
return '[FLASH='.$f_arr[0].','.$f_arr[1].']'.$f_arr[2].'[/FLASH]';
}
function unconvert_me($name="", $text="") {
$text = preg_replace( "#<span id='ME'><center>(.+?)</center></span>#", "\\1" , $text );
$text = preg_replace( "#$name#", "", $text );
return '[ME='.$name.']'.$text.'[/ME]';
}
function unconvert_sql($sql="") {
$sql = stripslashes($sql);
$sql = preg_replace( "#<span style='.+?'>(.+?)</span>#", "\\1", $sql );
$sql = preg_replace( "#\s*$#" , "", $sql );
return '[SQL]'.$sql.'[/SQL]';
}
function unconvert_htm($html="") {
$html = stripslashes($html);
$html = preg_replace( "#<span style='.+?'>(.+?)</span>#", "\\1", $html );
$html = preg_replace( "#\s*$#" , "", $html );
return '[HTML]'.$html.'[/HTML]';
}
//+-----------------------------------------------------------------------------------------
//+-----------------------------------------------------------------------------------------
// CONVERT FUNCTIONS
//+-----------------------------------------------------------------------------------------
//+-----------------------------------------------------------------------------------------
/**************************************************/
// convert_emoticon:
// replaces the text with the emoticon image
/**************************************************/
function convert_emoticon($code="", $image="") {
global $ibforums;
if (!$code or !$image) return;
// Remove slashes added by preg_quote
$code = stripslashes($code);
$this->emoticon_count++;
return "<!--emo&$code--><img src='{$ibforums->vars['EMOTICONS_URL']}/$image' border='0' valign='absmiddle' alt='$image'><!--endemo-->";
}
/**************************************************/
// wrap style:
// code and quote table HTML generator
/**************************************************/
function wrap_style( $in=array() ) {
global $ibforums;
if (! isset($in['TYPE']) ) $in['TYPE'] = 'id';
if (! isset($in['CSS']) ) $in['CSS'] = 'postcolor';
if (! isset($in['STYLE']) ) $in['STYLE'] = 'QUOTE';
//-----------------------------
// This returns two array elements:
// START: Contains the HTML code for the start wrapper
// END : Contains the HTML code for the end wrapper
//-----------------------------
$possible_use = array( 'CODE' => array( 'CODE', 'CODE' ),
'QUOTE' => array( 'QUOTE', 'QUOTE' ),
'SQL' => array( 'CODE' , 'SQL'),
'HTML' => array( 'CODE' , 'HTML'),
'PHP' => array( 'CODE' , 'PHP')
);
return array( 'START' => "</span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>{$possible_use[$in[STYLE]][1]}</b> {$in[EXTRA]}</td></tr><tr><td id='{$possible_use[ $in[STYLE] ][0]}'>",
'END' => "</td></tr></table><span {$in[TYPE]}='{$in[CSS]}'>"
);
}
/**************************************************/
// regex_html_tag: HTML syntax highlighting
//
/**************************************************/
function regex_html_tag($html="") {
if ($html == "") return;
// Ensure that spacing is preserved
// Too many embedded code/quote/html/sql tags can crash Opera and Moz
if (preg_match( "/\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\]/i", $html) ) {
return $default;
}
//$html = preg_replace( "#\s{2}#", " &nbsp;", $html );
// Knock off any preceeding newlines (which have
// since been converted into <br>)
//$html = nl2br($html);
$html = preg_replace( "/^<br>/", "", $html );
$html = preg_replace( "/^\s+/" , "", $html );
$html = preg_replace( "#&lt;([^&<>]+)&gt;#" , "&lt;<span style='color:blue'>\\1</span>&gt;" , $html ); //Matches <tag>
$html = preg_replace( "#&lt;([^&<>]+)=#" , "&lt;<span style='color:blue'>\\1</span>=" , $html ); //Matches <tag
$html = preg_replace( "#&lt;/([^&]+)&gt;#" , "&lt;/<span style='color:blue'>\\1</span>&gt;" , $html ); //Matches </tag>
$html = preg_replace( "!=(&quot;|&#39;)(.+?)(&quot;|&#39;)(\s|&gt;)!" , "=\\1<span style='color:orange'>\\2</span>\\3\\4" , $html ); //Matches ='this'
$html = preg_replace( "!&#60;&#33;--(.+?)--&#62;!" , "&lt;&#33;<span style='color:red'>--\\1--</span>&gt;", $html );
$wrap = $this->wrap_style( array( 'STYLE' => 'HTML' ) );
return "<!--html-->{$wrap['START']}<!--html1-->$html<!--html2-->{$wrap['END']}<!--html3-->";
}
/**************************************************/
// regex_sql_tag: SQL syntax highlighting
//
/**************************************************/
function regex_sql_tag($sql="") {
if ($sql == "") return;
// Too many embedded code/quote/html/sql tags can crash Opera and Moz
if (preg_match( "/\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\]/i", $sql) ) {
return $default;
}
// Knock off any preceeding newlines (which have
// since been converted into <br>)
$sql = preg_replace( "/^<br>/", "", $sql );
$sql = preg_replace( "/^\s+/" , "", $sql );
// Make certain regex work..
if (! preg_match( "/\s+$/" , $sql) )
{
$sql = $sql.' ';
}
$sql = preg_replace( "#(=|\+|\-|&gt;|&lt;|~|==|\!=|LIKE|NOT LIKE|REGEXP)#i" , "<span style='color:orange'>\\1</span>", $sql );
$sql = preg_replace( "#(MAX|AVG|SUM|COUNT|MIN)\(#i" , "<span style='color:blue'>\\1</span>(" , $sql );
$sql = preg_replace( "!(&quot;|&#39;|&#039;)(.+?)(&quot;|&#39;|&#039;)!i" , "<span style='color:red'>\\1\\2\\3</span>" , $sql );
$sql = preg_replace( "#\s{1,}(AND|OR)\s{1,}#i" , " <span style='color:blue'>\\1</span> " , $sql );
$sql = preg_replace( "#(WHERE|MODIFY|CHANGE|AS|DISTINCT|IN|ASC|DESC|ORDER BY)\s{1,}#i" , "<span style='color:green'>\\1</span> " , $sql );
$sql = preg_replace( "#LIMIT\s*(\d+)\s*,\s*(\d+)#i" , "<span style='color:green'>LIMIT</span> <span style='color:orange'>\\1, \\2</span>" , $sql );
$sql = preg_replace( "#(FROM|INTO)\s{1,}(\S+?)\s{1,}#i" , "<span style='color:green'>\\1</span> <span style='color:orange'>\\2</span> ", $sql );
$sql = preg_replace( "#(SELECT|INSERT|UPDATE|DELETE|ALTER TABLE|DROP)#i" , "<span style='color:blue;font-weight:bold'>\\1</span>" , $sql );
$html = $this->wrap_style( array( 'STYLE' => 'SQL' ) );
return "<!--sql-->{$html['START']}<!--sql1-->{$sql}<!--sql2-->{$html['END']}<!--sql3-->";
}
/**************************************************/
// regex_code_tag: Builds this code tag HTML
//
/**************************************************/
function regex_code_tag($txt="") {
global $ibforums;
$default = "\[code\]$txt\[/code\]";
if ($txt == "") return;
// Too many embedded code/quote/html/sql tags can crash Opera and Moz
if (preg_match( "/\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\]/i", $txt) ) {
return $default;
}
// Take a stab at removing most of the common
// smilie characters.
$txt = preg_replace( "#&lt;#" , "&#60;", $txt );
$txt = preg_replace( "#&gt;#" , "&#62;", $txt );
$txt = preg_replace( "#&quot;#" , "&#34;", $txt );
$txt = preg_replace( "#\s{1};#" , "&#59;", $txt );
$txt = preg_replace( "#:#" , "&#58;", $txt );
$txt = preg_replace( "#\[#" , "&#91;", $txt );
$txt = preg_replace( "#\]#" , "&#93;", $txt );
$txt = preg_replace( "#\)#" , "&#41;", $txt );
$txt = preg_replace( "#\(#" , "&#40;", $txt );
$txt = preg_replace( "#\r#" , "<br>", $txt );
$txt = preg_replace( "#\n#" , "<br>", $txt );
// Ensure that spacing is preserved
$txt = preg_replace( "#\s{2}#", " &nbsp;", $txt );
$html = $this->wrap_style( array( 'STYLE' => 'CODE' ) );
return "<!--c1-->{$html['START']}<!--ec1-->$txt<!--c2-->{$html['END']}<!--ec2-->";
}
/****************************************************************************************************/
// regex_parse_quotes: Builds this quote tag HTML
// [QUOTE] .. [/QUOTE] - allows for embedded quotes
/**************************************************/
function regex_parse_quotes($the_txt="") {
if ($the_txt == "") return;
$txt = $the_txt;
// Too many embedded code/quote/html/sql tags can crash Opera and Moz
/*if (preg_match( "/\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\]/is", $txt) ) {
$this->quote_error++;
return $txt;
}*/
$this->quote_html = $this->wrap_style( array( 'STYLE' => 'QUOTE' ) );
$txt = preg_replace( "#\[quote\]#ie" , "\$this->regex_simple_quote_tag()" , $txt );
$txt = preg_replace( "#\[quote=(.+?),\s*(.+?)\]#ie" , "\$this->regex_quote_tag('\\1', '\\2')" , $txt );
$txt = preg_replace( "#\[/quote\]#ie" , "\$this->regex_close_quote()" , $txt );
$txt = preg_replace( "/\n/", "<br>", $txt );
if ( ($this->quote_open == $this->quote_closed) and ($this->quote_error == 0) ) {
// Preserve spacing
$txt = preg_replace( "#(<!--QuoteEBegin-->.+?<!--QuoteEnd-->)#es", "\$this->regex_preserve_spacing('\\1')", trim($txt) );
return $txt;
} else {
return $the_txt;
}
}
/**************************************************/
// regex_preserve_spacing: keeps double spaces
// without CSS killing <pre> tags
/**************************************************/
function regex_preserve_spacing($txt="") {
$txt = preg_replace( "#\s{2}#", " &nbsp;", trim($txt) );
return $txt;
}
/**************************************************/
// regex_simple_quote_tag: Builds this quote tag HTML
// [QUOTE] .. [/QUOTE]
/**************************************************/
function regex_simple_quote_tag() {
global $ibforums;
$this->quote_open++;
return "<!--QuoteBegin-->{$this->quote_html['START']}<!--QuoteEBegin-->";
}
/**************************************************/
// regex_close_quote: closes a quote tag
//
/**************************************************/
function regex_close_quote() {
if ($this->quote_open == 0) {
$this->quote_error++;
return;
}
$this->quote_closed++;
return "<!--QuoteEnd-->{$this->quote_html['END']}<!--QuoteEEnd-->";
}
/**************************************************/
// regex_quote_tag: Builds this quote tag HTML
// [QUOTE=Matthew,14 February 2002]
/**************************************************/
function regex_quote_tag($name="", $date="") {
global $ibforums;
$default = "\[quote=$name,$date\]";
$this->quote_open++;
$html = $this->wrap_style( array( 'STYLE' => 'QUOTE', 'EXTRA' => "($name @ $date)" ) );
$extra = "--$name+$date";
return "<!--QuoteBegin".$extra."-->{$html['START']}<!--QuoteEBegin-->";
}
/****************************************************************************************************/
// regex_check_flash: Checks, and builds the <object>
// html.
/**************************************************/
function regex_check_flash($width="", $height="", $url="") {
global $ibforums;
$default = "\[flash=$width,$height\]$url\[/flash\]";
if (!$ibforums->vars['allow_flash']) {
return $default;
}
if ($width > $ibforums->vars['max_w_flash']) {
$this->error = 'flash_too_big';
return $default;
}
if ($height > $ibforums->vars['max_h_flash']) {
$this->error = 'flash_too_big';
return $default;
}
if (!preg_match( "/^http:\/\/(\S+)\.swf$/i", $url) ) {
$this->error = 'flash_url';
return $default;
}
return "<!--Flash $width+$height+$url--><OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' WIDTH=$width HEIGHT=$height><PARAM NAME=MOVIE VALUE=$url><PARAM NAME=PLAY VALUE=TRUE><PARAM NAME=LOOP VALUE=TRUE><PARAM NAME=QUALITY VALUE=HIGH><EMBED SRC=$url WIDTH=$width HEIGHT=$height PLAY=TRUE LOOP=TRUE QUALITY=HIGH></EMBED></OBJECT><!--End Flash-->";
}
/**************************************************/
// regex_check_image: Checks, and builds the <img>
// html.
/**************************************************/
function regex_check_image($url="") {
global $ibforums;
if (!$url) return;
$url = trim($url);
$default = "[img]".$url."[/img]";
++$this->image_count;
// Make sure we've not overriden the set image # limit
if ($ibforums->vars['max_images'])
{
if ($this->image_count > $ibforums->vars['max_images'])
{
$this->error = 'too_many_img';
return $default;
}
}
// Are they attempting to post a dynamic image, or JS?
if ($ibforums->vars['allow_dynamic_img'] != 1)
{
if (preg_match( "/[?&;]/", $url))
{
$this->error = 'no_dynamic';
return $default;
}
if (preg_match( "/javascript(\:|\s)/i", $url ))
{
$this->error = 'no_dynamic';
return $default;
}
}
// Is the img extension allowed to be posted?
if ($ibforums->vars['img_ext'])
{
$extension = preg_replace( "/^.*\.(\S+)$/", "\\1", $url );
$extension = strtolower($extension);
$ibforums->vars['img_ext'] = strtolower($ibforums->vars['img_ext']);
if (!preg_match( "/$extension(\||$)/", $ibforums->vars['img_ext'] ))
{
$this->error = 'invalid_ext';
return $default;
}
}
// Is it a legitimate image?
if (!preg_match( "/^(http|https|ftp):\/\//i", $url )) {
$this->error = 'no_dynamic';
return $default;
}
// If we are still here....
return "<img src='$url' border='0' alt='user posted image'>";
}
/**************************************************/
// regex_font_attr:
// Returns a string for an /e regexp based on the input
/**************************************************/
function regex_font_attr($IN) {
if (!is_array($IN)) return "";
if ($IN['s'] == 'size')
{
$IN['1'] = $IN['1'] + 7;
if ($IN['1'] > 30)
{
$IN['1'] = 30;
}
return "<span style='font-size:".$IN['1']."pt;line-height:100%'>".$IN['2']."</span>";
}
else if ($IN['s'] == 'col')
{
return "<span style='color:".$IN['1']."'>".$IN['2']."</span>";
}
else if ($IN['s'] == 'font')
{
return "<span style='font-family:".$IN['1']."'>".$IN['2']."</span>";
}
}
/**************************************************/
// regex_build_url: Checks, and builds the a href
// html
/**************************************************/
function regex_build_url($url=array()) {
$skip_it = 0;
// Make sure the last character isn't punctuation.. if it is, remove it and add it to the
// end array
if ( preg_match( "/([\.,\?]|&#33;)$/", $url['html'], $match) )
{
$url['end'] .= $match[1];
$url['html'] = preg_replace( "/([\.,\?]|&#33;)$/", "", $url['html'] );
$url['show'] = preg_replace( "/([\.,\?]|&#33;)$/", "", $url['show'] );
}
// Make sure it's not being used in a closing code/quote/html or sql block
if (preg_match( "/\[\/(html|quote|code|sql)/i", $url['html']) )
{
return $url['html'];
}
// clean up the ampersands
$url['html'] = preg_replace( "/&amp;/" , "&" , $url['html'] );
// Make sure we don't have a JS link
$url['html'] = preg_replace( "/javascript:/i", "java script&#58; ", $url['html'] );
// Do we have http:// at the front?
if ( ! preg_match("#^(http|news|https|ftp|aim)://#", $url['html'] ) )
{
$url['html'] = 'http://'.$url['html'];
}
//-------------------------
// Tidy up the viewable URL
//-------------------------
if (preg_match( "/^<img src/i", $url['show'] )) $skip_it = 1;
$url['show'] = preg_replace( "/&amp;/" , "&" , $url['show'] );
$url['show'] = preg_replace( "/javascript:/i", "javascript&#58; ", $url['show'] );
if (strlen($url['show']) < 55) $skip_it = 1;
// Make sure it's a "proper" url
if (!preg_match( "/^(http|ftp|https|news):\/\//i", $url['show'] )) $skip_it = 1;
$show = $url['show'];
if ($skip_it != 1) {
$stripped = preg_replace( "#^(http|ftp|https|news)://(\S+)$#i", "\\2", $url['show'] );
$uri_type = preg_replace( "#^(http|ftp|https|news)://(\S+)$#i", "\\1", $url['show'] );
$show = $uri_type.'://'.substr( $stripped , 0, 35 ).'...'.substr( $stripped , -15 );
}
return $url['st'] . "<a href='".$url['html']."' target='_blank'>".$show."</a>" . $url['end'];
}
}
?>
+425
View File
@@ -0,0 +1,425 @@
<?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
|
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $poll_count = 0;
var $poll_choices = "";
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets do some tests to make sure that we are allowed to start a new topic
if (! $ibforums->member['g_post_polls'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
}
if ( ! $class->forum['allow_poll'] )
{
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
}
$this->m_group = $ibforums->member['mgroup'];
if ($class->forum['start_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['start_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
}
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
//-------------------------------------------------
// check to make sure we have a valid topic title
//-------------------------------------------------
if ( (strlen($ibforums->input['TopicTitle']) < 2) or (!$ibforums->input['TopicTitle']) ) {
$class->obj['post_errors'] = 'no_topic_title';
}
if ( strlen($ibforums->input['TopicTitle']) > 64 ) {
$class->obj['post_errors'] = 'topic_title_long';
}
//-------------------------------------------------
// check to make sure we have a correct # of choices
//-------------------------------------------------
$this->poll_choices = $ibforums->input['PollAnswers'];
$this->poll_choices = preg_replace( "/<br><br>/" , "" , $this->poll_choices );
$this->poll_choices = preg_replace( "/<br>/e" , "\$this->regex_count_choices()" , $this->poll_choices );
if ($this->poll_count > 10) {
$class->obj['post_errors'] = 'poll_to_many';
}
if ($this->poll_count < 1) {
$class->obj['post_errors'] = 'poll_not_enough';
}
//-------------------------------------------------
// 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_poll($class);
}
}
function add_new_poll($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Sort out the poll stuff
// This is somewhat contrived, but it has to be
// compatible with the current perl version.
//-------------------------------------------------
$poll_array = array();
$count = 0;
$polls = explode( "<br>", $this->poll_choices );
foreach ($polls as $polling)
{
if ( $polling == "" )
{
continue;
}
$poll_array[] = array( $count , $polling, 0 );
$count++;
}
//-------------------------------------------------
// 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($ibforums->input['TopicTitle']);
}
$ibforums->input['TopicTitle'] = $class->parser->bad_words( $ibforums->input['TopicTitle'] );
$ibforums->input['TopicDesc'] = $class->parser->bad_words( $ibforums->input['TopicDesc'] );
//-------------------------------------------------
// Build the master array
//-------------------------------------------------
$this->topic = array(
'title' => $ibforums->input['TopicTitle'],
'description' => $ibforums->input['TopicDesc'] ,
'state' => 'open',
'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' => $ibforums->input['allow_disc'] == 0 ? 'open' : 'closed',
'last_vote' => 0,
'views' => 0,
'forum_id' => $class->forum['id'],
'approved' => $class->obj['moderate'] ? 0 : 1,
'pinned' => 0,
);
//-------------------------------------------------
// 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['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();
//-------------------------------------------------
// Add the poll to the forum_polls table
// if we are moderating this 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,
)
);
$DB->query("INSERT INTO ibf_polls (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
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'] ."'");
// At this point in time, we'll scan the database for the correct number
// of topics - if this proves to database intensive, we'll simply increment
// the value stored in the ibf_stats database.
$DB->query("SELECT COUNT(tid) as topic_cnt FROM ibf_topics");
$stats = $DB->fetch_row();
$DB->query("UPDATE ibf_stats SET TOTAL_TOPICS='".$stats['topic_cnt']."'");
//-------------------------------------------------
// 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']."'");
}
//-------------------------------------------------
// Set a last post time cookie
//-------------------------------------------------
$std->my_setcookie( "LPid", time() );
//-------------------------------------------------
// 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']) ? $HTTP_POST_VARS['TopicTitle'] : "";
$topic_desc = isset($HTTP_POST_VARS['TopicDesc']) ? $HTTP_POST_VARS['TopicDesc'] : "";
$poll = isset($HTTP_POST_VARS['PollAnswers']) ? stripslashes($HTTP_POST_VARS['PollAnswers']) : "";
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', '11' ), 2 => array( 'f', $class->forum['id']) ) );
//---------------------------------------
// 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_poll']} {$class->forum['name']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options();
$poll_box = $class->html->poll_box($poll);
$end_form = $class->html->EndForm( $ibforums->lang['submit_poll'] );
$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->output = preg_replace( "/<!--POLL BOX-->/" , "$poll_box" , $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,
) );
}
function regex_count_choices() {
++$this->poll_count;
return "<br>";
}
}
?>
+425
View File
@@ -0,0 +1,425 @@
<?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,
) );
}
}
?>
+360
View File
@@ -0,0 +1,360 @@
<?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,
) );
}
}
?>
+844
View File
@@ -0,0 +1,844 @@
<?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
+---------------------------------------------------------------------------
|
| > GNU Tar creation and extraction module
| > Module written by Matt Mecham
| > Usage style based on the C and Perl GNU modules
| > Will only work with PHP 4+
|
| > Date started: 15th Feb 2002
|
| > Module Version Number: 1.0.0
| > Module Author: Matthew Mecham
+--------------------------------------------------------------------------
|
| QUOTE OF THE MODULE:
| If you can't find a program the does what you want it to do, write your
| own.
|
+--------------------------------------------------------------------------
*/
/*************************************************************
|
| EXTRACTION USAGE:
|
| $tar = new tar();
| $tar->new_tar("/foo/bar", "myTar.tar");
| $files = $tar->list_files();
| $tar->extract_files( "/extract/to/here/dir" );
|
| CREATION USAGE:
|
| $tar = new tar();
| $tar->new_tar("/foo/bar" , "myNewTar.tar");
| $tar->current_dir("/foo" ); //Optional - tells the script which dir we are in
| to syncronise file creation from the tarball
| $tar->add_files( $file_names_with_path_array );
| (or $tar->add_directory( "/foo/bar/myDir" ); to archive a complete dir)
| $tar->write_tar();
|
*************************************************************/
class tar {
var $tar_header_length = '512';
var $tar_unpack_header = 'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8chksum/a1typeflag/a100linkname/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155/prefix';
var $tar_pack_header = 'A100 A8 A8 A8 A12 A12 A8 A1 A100 A6 A2 A32 A32 A8 A8 A155';
var $current_dir = "";
var $unpack_dir = "";
var $pack_dir = "";
var $error = "";
var $work_dir = array();
var $tar_in_mem = array();
var $tar_filename = "";
var $filehandle = "";
var $warnings = array();
var $attributes = array();
var $tarfile_name = "";
var $tarfile_path = "";
var $tarfile_path_name = "";
var $workfiles = array();
//+--------------------------------------------------------------------------
// CONSTRUCTOR: Attempt to guess the current working dir.
//+--------------------------------------------------------------------------
function tar() {
global $HTTP_SERVER_VARS;
if ($this_dir = getcwd())
{
$this->current_dir = $this_dir;
}
else if (isset($HTTP_SERVER_VARS['DOCUMENT_ROOT']))
{
$this->current_dir = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
}
else
{
$this->current_dir = './';
}
// Set some attributes, these can be overriden later
$this->attributes = array( 'over_write_existing' => 0,
'over_write_newer' => 0,
'remove_tar_file' => 0,
'remove_original_files' => 0,
);
}
//+--------------------------------------------------------------------------
// Set the tarname. If we are extracting a tarball, then it must be the
// path to the tarball, and it's name (eg: $tar->new_tar("/foo/bar" ,'myTar.tar')
// or if we are creating a tar, then it must be the path and name of the tar file
// to create.
//+--------------------------------------------------------------------------
function new_tar($tarpath, $tarname) {
$this->tarfile_name = $tarname;
$this->tarfile_path = $tarpath;
// Make sure there isn't a trailing slash on the path
$this->tarfile_path = preg_replace( "#[/\\\]$#" , "" , $this->tarfile_path );
$this->tarfile_path_name = $this->tarfile_path .'/'. $this->tarfile_name;
}
//+--------------------------------------------------------------------------
// Easy way to overwrite defaults
//+--------------------------------------------------------------------------
function over_write_existing() {
$this->attributes['over_write_existing'] = 1;
}
function over_write_newer() {
$this->attributes['over_write_newer'] = 1;
}
function remove_tar_file() {
$this->attributes['remove_tar_file'] = 1;
}
function remove_original_files() {
$this->attributes['remove_original_files'] = 1;
}
//+--------------------------------------------------------------------------
// User assigns the root directory for the tar ball creation/extraction
//+--------------------------------------------------------------------------
function current_dir($dir = "") {
$this->current_dir = $dir;
}
//+--------------------------------------------------------------------------
// list files: returns an array with all the filenames in the tar file
//+--------------------------------------------------------------------------
function list_files($advanced="") {
// $advanced == "" - return name only
// $advanced == 1 - return name, size, mtime, mode
$data = $this->read_tar();
$final = array();
foreach($data as $d)
{
if ($advanced == 1)
{
$final[] = array ( 'name' => $d['name'],
'size' => $d['size'],
'mtime' => $d['mtime'],
'mode' => substr(decoct( $d['mode'] ), -4),
);
}
else
{
$final[] = $d['name'];
}
}
return $final;
}
//+--------------------------------------------------------------------------
// Add a directory to the tar files.
// $tar->add_directory( str(TO DIRECTORY) )
// Can be used in the following methods.
// $tar->add_directory( "/foo/bar" );
// $tar->write_tar( "/foo/bar" );
//+--------------------------------------------------------------------------
function add_directory( $dir ) {
$this->error = "";
// Make sure the $to_dir is pointing to a valid dir, or we error
// and return
if (! is_dir($dir) )
{
$this->error = "Extract files error: Destination directory ($to_dir) does not exist";
return FALSE;
}
$cur_dir = getcwd();
chdir($dir);
$this->get_dir_contents("./");
$this->add_files($this->workfiles, $dir);
chdir($cur_dir);
}
//-------------------------------------
function get_dir_contents( $dir )
{
$dir = preg_replace( "#/$#", "", $dir );
if ( file_exists($dir) )
{
if ( is_dir($dir) )
{
$handle = opendir($dir);
while (($filename = readdir($handle)) !== false)
{
if (($filename != ".") && ($filename != ".."))
{
if (is_dir($dir."/".$filename))
{
$this->get_dir_contents($dir."/".$filename);
}
else
{
$this->workfiles[] = $dir."/".$filename;
}
}
}
closedir($handle);
}
else
{
$this->error = "$dir is not a directory";
return FALSE;
}
}
else
{
$this->error = "Could not locate $dir";
return;
}
}
//+--------------------------------------------------------------------------
// Extract the tarball
// $tar->extract_files( str(TO DIRECTORY), [ array( FILENAMES ) ] )
// Can be used in the following methods.
// $tar->extract( "/foo/bar" , $files );
// This will seek out the files in the user array and extract them
// $tar->extract( "/foo/bar" );
// Will extract the complete tar file into the user specified directory
//+--------------------------------------------------------------------------
function extract_files( $to_dir, $files="" ) {
$this->error = "";
// Make sure the $to_dir is pointing to a valid dir, or we error
// and return
if (! is_dir($to_dir) )
{
$this->error = "Extract files error: Destination directory ($to_dir) does not exist";
return;
}
//---------------------------------------------
// change into the directory chosen by the user.
//---------------------------------------------
chdir($to_dir);
$cur_dir = getcwd();
$to_dir_slash = $to_dir . "/";
//+------------------------------
// Get the file info from the tar
//+------------------------------
$in_files = $this->read_tar();
if ($this->error != "") {
return;
}
foreach ($in_files as $k => $file) {
//---------------------------------------------
// Are we choosing which files to extract?
//---------------------------------------------
if (is_array($files))
{
if (! in_array($file['name'], $files) )
{
continue;
}
}
chdir($cur_dir);
//---------------------------------------------
// GNU TAR format dictates that all paths *must* be in the *nix
// format - if this is not the case, blame the tar vendor, not me!
//---------------------------------------------
if ( preg_match("#/#", $file['name']) )
{
$path_info = explode( "/" , $file['name'] );
$file_name = array_pop($path_info);
} else
{
$path_info = array();
$file_name = $file['name'];
}
//---------------------------------------------
// If we have a path, then we must build the directory tree
//---------------------------------------------
if (count($path_info) > 0)
{
foreach($path_info as $dir_component)
{
if ($dir_component == "")
{
continue;
}
if ( (file_exists($dir_component)) && (! is_dir($dir_component)) )
{
$this->warnings[] = "WARNING: $dir_component exists, but is not a directory";
continue;
}
if (! is_dir($dir_component))
{
mkdir( $dir_component, 0777);
chmod( $dir_component, 0777);
}
if (! @chdir($dir_component))
{
$this->warnings[] = "ERROR: CHDIR to $dir_component FAILED!";
}
}
}
//---------------------------------------------
// check the typeflags, and work accordingly
//---------------------------------------------
if (($file['typeflag'] == 0) or (!$file['typeflag']) or ($file['typeflag'] == ""))
{
if ( $FH = fopen($file_name, "wb") )
{
fputs( $FH, $file['data'], strlen($file['data']) );
fclose($FH);
}
else
{
$this->warnings[] = "Could not write data to $file_name";
}
}
else if ($file['typeflag'] == 5)
{
if ( (file_exists($file_name)) && (! is_dir($file_name)) )
{
$this->warnings[] = "$file_name exists, but is not a directory";
continue;
}
if (! is_dir($file_name))
{
mkdir( $file_name, 0777);
}
}
else if ($file['typeflag'] == 6)
{
$this->warnings[] = "Cannot handle named pipes";
continue;
}
else if ($file['typeflag'] == 1)
{
$this->warnings[] = "Cannot handle system links";
}
else if ($file['typeflag'] == 4)
{
$this->warnings[] = "Cannot handle device files";
}
else if ($file['typeflag'] == 3)
{
$this->warnings[] = "Cannot handle device files";
}
else
{
$this->warnings[] = "Unknown typeflag found";
}
if (! @chmod( $file_name, $file['mode'] ) )
{
$this->warnings[] = "ERROR: CHMOD $mode on $file_name FAILED!";
}
@touch( $file_name, $file['mtime'] );
}
// Return to the "real" directory the scripts are in
@chdir($this->current_dir);
}
//+--------------------------------------------------------------------------
// add files:
// Takes an array of files, and adds them to the tar file
// Optionally takes a path to use as root for the tar file - if omitted, it
// assumes the current working directory is the tarball root. Be careful with
// this, or you may get unexpected results -especially when attempting to read
// and add files to the tarball.
// EXAMPLE DIR STRUCTURE
// /usr/home/somedir/forums/sources
// BRIEF: To tar up the sources directory
// $files = array( 'sources/somescript.php', 'sources/anothersscript.php' );
// If CWD is 'somedir', you'll need to use $tar->add_files( $files, "/usr/home/somedir/forums" );
// or it'll attempt to open /usr/home/somedir/sources/somescript.php - which would result
// in an error. Either that, or use:
// chdir("/usr/home/somedir/forums");
// $tar->add_files( $files );
//+--------------------------------------------------------------------------
function add_files( $files, $root_path="" ) {
// Do we a root path to change into?
if ($root_path != "") {
chdir($root_path);
}
$count = 0;
foreach ($files as $file) {
// is it a Mac OS X work file?
if ( preg_match("/\.ds_store/i", $file ) )
{
continue;
}
$typeflag = 0;
$data = "";
$linkname = "";
$stat = stat($file);
// Did stat fail?
if (! is_array($stat) ) {
$this->warnings[] = "Error: Stat failed on $file";
continue;
}
$mode = fileperms($file);
$uid = $stat[4];
$gid = $stat[5];
$rdev = $stat[6];
$size = filesize($file);
$mtime = filemtime($file);
if (is_file($file)) {
// It's a plain file, so lets suck it up
$typeflag = 0;
if ( $FH = fopen($file, 'rb') ) {
$data = fread( $FH, filesize($file) );
fclose($FH);
} else {
$this->warnings[] = "ERROR: Failed to open $file";
continue;
}
}
else if (is_link($file)) {
$typeflag = 1;
$linkname = @readlink($file);
}
else if (is_dir($file)) {
$typeflag = 5;
}
else {
// Sockets, Pipes and char/block specials are not
// supported, so - lets use a silly value to keep the
// tar ball legitimate.
$typeflag = 9;
}
// Add this data to our in memory tar file
$this->tar_in_mem[] = array (
'name' => $file,
'mode' => $mode,
'uid' => $uid,
'gid' => $gid,
'size' => strlen($data),
'mtime' => $mtime,
'chksum' => " ",
'typeflag' => $typeflag,
'linkname' => $linkname,
'magic' => "ustar\0",
'version' => '00',
'uname' => 'unknown',
'gname' => 'unknown',
'devmajor' => "",
'devminor' => "",
'prefix' => "",
'data' => $data
);
// Clear the stat cache
@clearstatcache();
$count++;
}
@chdir($this->current_dir);
//Return the number of files to anyone who's interested
return $count;
}
//+--------------------------------------------------------------------------
// write_tar:
// Writes the tarball into the directory specified in new_tar with a filename
// specified in new_tar
//+--------------------------------------------------------------------------
function write_tar() {
if ($this->tarfile_path_name == "") {
$this->error = 'No filename or path was specified to create a new tar file';
return;
}
if ( count($this->tar_in_mem) < 1 ) {
$this->error = 'No data to write to the new tar file';
return;
}
$tardata = "";
foreach ($this->tar_in_mem as $file) {
$prefix = "";
$tmp = "";
$last = "";
// make sure the filename isn't longer than 99 characters.
if (strlen($file['name']) > 99) {
$pos = strrpos( $file['name'], "/" );
if (is_string($pos) && !$pos) {
// filename alone is longer than 99 characters!
$this->error[] = "Filename {$file['name']} exceeds the length allowed by GNU Tape ARchives";
continue;
}
$prefix = substr( $file['name'], 0 , $pos ); // Move the path to the prefix
$file['name'] = substr( $file['name'], ($pos+1));
if (strlen($prefix) > 154) {
$this->error[] = "File path exceeds the length allowed by GNU Tape ARchives";
continue;
}
}
// BEGIN FORMATTING (a8a1a100)
$mode = sprintf("%6s ", decoct($file['mode']));
$uid = sprintf("%6s ", decoct($file['uid']));
$gid = sprintf("%6s ", decoct($file['gid']));
$size = sprintf("%11s ", decoct($file['size']));
$mtime = sprintf("%11s ", decoct($file['mtime']));
$tmp = pack("a100a8a8a8a12a12",$file['name'],$mode,$uid,$gid,$size,$mtime);
$last = pack("a1" , $file['typeflag']);
$last .= pack("a100" , $file['linkname']);
$last .= pack("a6", "ustar"); // magic
$last .= pack("a2", "" ); // version
$last .= pack("a32", $file['uname']);
$last .= pack("a32", $file['gname']);
$last .= pack("a8", ""); // devmajor
$last .= pack("a8", ""); // devminor
$last .= pack("a155", $prefix);
//$last .= pack("a12", "");
$test_len = $tmp . $last . "12345678";
$last .= $this->internal_build_string( "\0" , ($this->tar_header_length - strlen($test_len)) );
// Here comes the science bit, handling
// the checksum.
$checksum = 0;
for ($i = 0 ; $i < 148 ; $i++ ) {
$checksum += ord( substr($tmp, $i, 1) );
}
for ($i = 148 ; $i < 156 ; $i++) {
$checksum += ord(' ');
}
for ($i = 156, $j = 0 ; $i < 512 ; $i++, $j++) {
$checksum += ord( substr($last, $j, 1) );
}
$checksum = sprintf( "%6s ", decoct($checksum) );
$tmp .= pack("a8", $checksum);
$tmp .= $last;
$tmp .= $file['data'];
// Tidy up this chunk to the power of 512
if ($file['size'] > 0)
{
if ($file['size'] % 512 != 0)
{
$homer = $this->internal_build_string( "\0" , (512 - ($file['size'] % 512)) );
$tmp .= $homer;
}
}
$tardata .= $tmp;
}
// Add the footer
$tardata .= pack( "a512", "" );
// print it to the tar file
$FH = fopen( $this->tarfile_path_name, 'wb' );
fputs( $FH, $tardata, strlen($tardata) );
fclose($FH);
@chmod( $this->tarfile_path_name, 0777);
// Done..
}
//+--------------------------------------------------------------------------
// Read the tarball - builds an associative array
//+--------------------------------------------------------------------------
function read_tar() {
$filename = $this->tarfile_path_name;
if ($filename == "") {
$this->error = 'No filename specified when attempting to read a tar file';
return array();
}
if (! file_exists($filename) ) {
$this->error = 'Cannot locate the file '.$filename;
return array();
}
$tar_info = array();
$this->tar_filename = $filename;
// Open up the tar file and start the loop
if (! $FH = fopen( $filename , 'rb' ) ) {
$this->error = "Cannot open $filename for reading";
return array();
}
// Grrr, perl allows spaces, PHP doesn't. Pack strings are hard to read without
// them, so to save my sanity, I'll create them with spaces and remove them here
$this->tar_unpack_header = preg_replace( "/\s/", "" , $this->tar_unpack_header);
while (!feof($FH)) {
$buffer = fread( $FH , $this->tar_header_length );
// check the block
$checksum = 0;
for ($i = 0 ; $i < 148 ; $i++) {
$checksum += ord( substr($buffer, $i, 1) );
}
for ($i = 148 ; $i < 156 ; $i++) {
$checksum += ord(' ');
}
for ($i = 156 ; $i < 512 ; $i++) {
$checksum += ord( substr($buffer, $i, 1) );
}
$fa = unpack( $this->tar_unpack_header, $buffer);
$name = trim($fa[filename]);
$mode = OctDec(trim($fa[mode]));
$uid = OctDec(trim($fa[uid]));
$gid = OctDec(trim($fa[gid]));
$size = OctDec(trim($fa[size]));
$mtime = OctDec(trim($fa[mtime]));
$chksum = OctDec(trim($fa[chksum]));
$typeflag = trim($fa[typeflag]);
$linkname = trim($fa[linkname]);
$magic = trim($fa[magic]);
$version = trim($fa[version]);
$uname = trim($fa[uname]);
$gname = trim($fa[gname]);
$devmajor = OctDec(trim($fa[devmajor]));
$devminor = OctDec(trim($fa[devminor]));
$prefix = trim($fa[prefix]);
if ( ($checksum == 256) && ($chksum == 0) ) {
//EOF!
break;
}
if ($prefix) {
$name = $prefix.'/'.$name;
}
// Some broken tars don't set the type flag
// correctly for directories, so we assume that
// if it ends in / it's a directory...
if ( (preg_match( "#/$#" , $name)) and (! $name) ) {
$typeflag = 5;
}
// If it's the end of the tarball...
$test = $this->internal_build_string( '\0' , 512 );
if ($buffer == $test) {
break;
}
// Read the next chunk
$data = fread( $FH, $size );
if (strlen($data) != $size) {
$this->error = "Read error on tar file";
fclose( $FH );
return array();
}
$diff = $size % 512;
if ($diff != 0) {
// Padding, throw away
$crap = fread( $FH, (512-$diff) );
}
// Protect against tarfiles with garbage at the end
if ($name == "") {
break;
}
$tar_info[] = array (
'name' => $name,
'mode' => $mode,
'uid' => $uid,
'gid' => $gid,
'size' => $size,
'mtime' => $mtime,
'chksum' => $chksum,
'typeflag' => $typeflag,
'linkname' => $linkname,
'magic' => $magic,
'version' => $version,
'uname' => $uname,
'gname' => $gname,
'devmajor' => $devmajor,
'devminor' => $devminor,
'prefix' => $prefix,
'data' => $data
);
}
fclose($FH);
return $tar_info;
}
//+------------------------------------------------------------------------------
// INTERNAL FUNCTIONS - These should NOT be called outside this module
//+------------------------------------------------------------------------------
//+--------------------------------------------------------------------------
// build_string: Builds a repititive string
//+--------------------------------------------------------------------------
function internal_build_string($string="", $times=0) {
$return = "";
for ($i=0 ; $i < $times ; ++$i ) {
$return .= $string;
}
return $return;
}
}
?>
+584
View File
@@ -0,0 +1,584 @@
<?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
+---------------------------------------------------------------------------
|
| > UserCP functions library
| > Module written by Matt Mecham
| > Date started: 20th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class usercp_functions {
var $class;
function usercp_functions($class) {
$this->class = $class;
}
function do_skin_langs() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS;
// Check input for 1337 h/\x0r nonsense
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
if ( preg_match( "/\.\./", $ibforums->input['u_skin'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
if ( preg_match( "/\.\./", $ibforums->input['u_language'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
$DB->query("SELECT sid FROM ibf_skins WHERE hidden <> 1 AND sid='".$ibforums->input['u_skin']."'");
if (! $DB->get_num_rows() )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'skin_not_found' ) );
}
//+----------------------------------------
$db_string = $DB->compile_db_update_string( array (
'language' => $ibforums->input['u_language'],
'skin ' => $ibforums->input['u_skin'],
) );
$DB->query("UPDATE ibf_members SET $db_string WHERE id='".$this->class->member['id']."'");
$print->redirect_screen( $ibforums->lang['set_updated'], "act=UserCP&CODE=06" );
}
function do_board_prefs() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS;
// Check the input for naughties :D
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
if ( ! preg_match( "/^[\-\d\.]+$/", $ibforums->input['u_timezone'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
if ( ! preg_match( "/^\d+$/", $ibforums->input['VIEW_IMG'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
if ( ! preg_match( "/^\d+$/", $ibforums->input['VIEW_SIGS'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
if ( ! preg_match( "/^\d+$/", $ibforums->input['VIEW_AVS'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
if ( ! preg_match( "/^\d+$/", $ibforums->input['DO_POPUP'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
if ( ! preg_match( "/^\d+$/", $ibforums->input['HIDE_SESS'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
$db_string = $DB->compile_db_update_string( array (
'time_offset' => $ibforums->input['u_timezone'],
'view_avs' => $ibforums->input['VIEW_AVS'],
'view_sigs' => $ibforums->input['VIEW_SIGS'],
'view_img' => $ibforums->input['VIEW_IMG'],
'view_pop' => $ibforums->input['DO_POPUP'],
'dst_in_use' => $ibforums->input['DST'],
) );
$DB->query("UPDATE ibf_members SET $db_string WHERE id='".$this->class->member['id']."'");
if ($ibforums->input['HIDE_SESS'] == 1)
{
$std->my_setcookie('hide_sess', '1');
}
else
{
$std->my_setcookie('hide_sess', '0');
}
$print->redirect_screen( $ibforums->lang['set_updated'], "act=UserCP&CODE=04" );
}
function do_email_settings() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS;
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
//check and set the rest of the info
foreach ( array('hide_email', 'admin_send', 'send_full_msg', 'pm_reminder') as $v )
{
$ibforums->input[ $v ] = $std->is_number( $ibforums->input[ $v ] );
if ( $ibforums->input[ $v ] < 1 )
{
$ibforums->input[ $v ] = 0;
}
}
$db_string = $DB->compile_db_update_string( array (
'hide_email' => $ibforums->input['hide_email'],
'email_full' => $ibforums->input['send_full_msg'],
'email_pm' => $ibforums->input['pm_reminder'],
'allow_admin_mails' => $ibforums->input['admin_send'],
) );
$DB->query("UPDATE ibf_members SET $db_string WHERE id='".$this->class->member['id']."'");
$print->redirect_screen( "Email Settings updated", "act=UserCP&CODE=02" );
}
function do_avatar() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS, $HTTP_POST_FILES, $FILE_UPLOAD;
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
$real_choice = 'noavatar';
$real_dims = '';
if ($ibforums->input['choice'] == 'gallery')
{
$avatar_gallery = array();
$dh = opendir( $ibforums->vars['html_dir'].'avatars' );
while ( $file = readdir( $dh ) )
{
if ( !preg_match( "/^..?$|^index/i", $file ) )
{
$avatar_gallery[] = $file;
}
}
closedir( $dh );
if (!in_array( $HTTP_POST_VARS['gallery_list'], $avatar_gallery ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_avatar_selected' ) );
}
$real_choice = $ibforums->input['gallery_list'];
}
else if ($ibforums->input['choice'] == 'url')
{
//-----------------------------------
// Check to make sure we don't just have
// http:// in the URL box..
//------------------------------------
if ( preg_match( "/^http:\/\/$/i", $ibforums->input['url_avatar'] ) )
{
$ibforums->input['url_avatar'] = "";
}
if (empty($ibforums->input['url_avatar']) )
{
//------------------------------------
// Lets check for an uploaded avatar..
//------------------------------------
if ($HTTP_POST_FILES['FILE_UPLOAD']['name'] != "" and ($HTTP_POST_FILES['FILE_UPLOAD']['name'] != "none") )
{
$FILE_NAME = $HTTP_POST_FILES['FILE_UPLOAD']['name'];
$FILE_SIZE = $HTTP_POST_FILES['FILE_UPLOAD']['size'];
$FILE_TYPE = $HTTP_POST_FILES['FILE_UPLOAD']['type'];
if ($HTTP_POST_FILES['FILE_UPLOAD']['name'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_name' ) );
}
// Naughty Opera adds the filename on the end of the
// mime type - we don't want this.
$FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
// Are we allowed to upload or has the admin stopped us?
if ( ($ibforums->member['g_avatar_upload'] != 1) or ($ibforums->vars['avup_size_max'] < 1) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_upload' ) );
}
// Check to make sure it's the correct content type.
// Naughty Nominell won't be able to use PNG :P
require "./conf_mime_types.php";
if ($mime_types[ $FILE_TYPE ][3] != 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_type' ) );
}
//-------------------------------------------------
// Check the file size
//-------------------------------------------------
if ($FILE_SIZE > ($ibforums->vars['avup_size_max']*1024))
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_to_big' ) );
}
$ext = '.gif';
switch($FILE_TYPE)
{
case 'image/gif':
$ext = '.gif';
break;
case 'image/jpeg':
$ext = '.jpg';
break;
case 'image/pjpeg':
$ext = '.jpg';
break;
case 'image/x-png':
$ext = '.png';
break;
default:
$ext = '.gif';
break;
}
$real_name = 'av-'.$this->class->member['id'].$ext;
//-------------------------------------------------
// Copy the upload to the uploads directory
//-------------------------------------------------
if (! @move_uploaded_file( $HTTP_POST_FILES['FILE_UPLOAD']['tmp_name'], $ibforums->vars['upload_dir']."/".$real_name) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_failed' ) );
}
// Set the "real" avatar..
$real_choice = 'upload:'.$real_name;
$w = $ibforums->input['Avatar_width'];
$h = $ibforums->input['Avatar_height'];
list($aw, $ah) = explode( "x", $ibforums->vars['avatar_dims'] );
$w = $w > $aw ? $aw : $w;
$h = $h > $ah ? $ah : $h;
$real_dims = $w.'x'.$h;
}
else if ( preg_match( "/^upload:/", $this->class->member['avatar'] ) )
{
// Keep the current avatar
$real_choice = $this->class->member['avatar'];
$w = $ibforums->input['Avatar_width'];
$h = $ibforums->input['Avatar_height'];
list($aw, $ah) = explode( "x", $ibforums->vars['avatar_dims'] );
$w = $w > $aw ? $aw : $w;
$h = $h > $ah ? $ah : $h;
$real_dims = $w.'x'.$h;
}
else
{
// URL field and upload field left blank.
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_avatar_selected' ) );
}
}
else
{
// Non empty URL field, upload box is empty.
if (!preg_match( "/^http:\/\//i", $ibforums->input['url_avatar'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'avatar_invalid_url' ) );
}
$ext = explode ( "|", $ibforums->vars['avatar_ext'] );
$checked = 0;
$av_ext = preg_replace( "/^.*\.(\S+)$/", "\\1", $ibforums->input['url_avatar'] );
foreach ($ext as $v )
{
if (strtolower($v) == strtolower($av_ext))
{
$checked = 1;
}
}
if ($checked != 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'avatar_invalid_ext' ) );
}
$w = $ibforums->input['Avatar_width'];
$h = $ibforums->input['Avatar_height'];
list($aw, $ah) = explode( "x", $ibforums->vars['avatar_dims'] );
$w = $w > $aw ? $aw : $w;
$h = $h > $ah ? $ah : $h;
$real_dims = $w.'x'.$h;
$real_choice = $ibforums->input['url_avatar'];
}
}
else
{
$real_choice = 'noavatar';
}
// Update the DB
$DB->query("UPDATE ibf_members SET avatar='$real_choice', avatar_size='$real_dims' WHERE id='".$this->class->member['id']."'");
$print->redirect_screen( "Avatar choice updated", "act=UserCP&CODE=24" );
}
function do_profile() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS;
//----------------------------------
// Check for bad entry
//----------------------------------
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
if ( (strlen($HTTP_POST_VARS['Interests']) > $ibforums->vars['max_interest_length']) and ($ibforums->vars['max_interest_length']) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'int_too_long' ) );
}
//+--------------------
if ( (strlen($HTTP_POST_VARS['Location']) > $ibforums->vars['max_location_length']) and ($ibforums->vars['max_location_length']) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'loc_too_long' ) );
}
//+--------------------
if (strlen($HTTP_POST_VARS['WebSite']) > 150)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'web_too_long' ) );
}
//+--------------------
if (strlen($HTTP_POST_VARS['Photo']) > 150)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'photo_too_long' ) );
}
//+--------------------
if ( ($HTTP_POST_VARS['ICQNumber']) && (!preg_match( "/^(?:\d+)$/", $HTTP_POST_VARS['ICQNumber'] ) ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'not_icq_number' ) );
}
//+--------------------
if ( empty($ibforums->vars['allow_dynamic_img']) )
{
if ( preg_match( "/[?&;]/", $HTTP_POST_VARS['Photo'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'not_url_photo' ) );
}
}
//----------------------------------
// make sure that either we entered
// all calendar fields, or we left them
// all blank
//----------------------------------
$c_cnt = 0;
foreach ( array('day','month','year') as $v )
{
if (!empty($ibforums->input[$v]))
{
$c_cnt++;
}
}
if ( ($c_cnt > 0) and ($c_cnt != 3) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'calendar_not_all' ) );
}
if ( ! preg_match( "#^http://#", $ibforums->input['WebSite'] ) )
{
$ibforums->input['WebSite'] = 'http://'.$ibforums->input['WebSite'];
}
//----------------------------------
// Start off our array
//----------------------------------
$set = array( 'website' => $ibforums->input['WebSite'],
'icq_number' => $ibforums->input['ICQNumber'],
'aim_name' => $ibforums->input['AOLName'],
'yahoo' => $ibforums->input['YahooName'],
'msnname' => $ibforums->input['MSNName'],
'location' => $ibforums->input['Location'],
'interests' => $ibforums->input['Interests'],
'photo' => $ibforums->input['Photo'],
'bday_day' => $ibforums->input['day'],
'bday_month' => $ibforums->input['month'],
'bday_year' => $ibforums->input['year'],
);
//----------------------------------
// check to see if we can enter a member title
// and if one is entered, update it.
//----------------------------------
if ( ($ibforums->input['member_title']) and ($ibforums->vars['post_titlechange']) and ( $this->class->member['posts'] > $ibforums->vars['post_titlechange']) )
{
$set['title'] = $ibforums->input['member_title'];
}
//----------------------------------
// Update the DB
//----------------------------------
$set_string = $DB->compile_db_update_string($set);
$DB->query("UPDATE ibf_members SET $set_string WHERE id='".$this->class->member['id']."'");
// Return us!
$print->redirect_screen( $ibforums->lang['profile_edited'], "act=UserCP&CODE=01" );
}
function do_signature() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS;
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
//----------------------------------
// Check for bad entry
//----------------------------------
if ( (strlen($HTTP_POST_VARS['Post']) > $ibforums->vars['max_sig_length']) and ($ibforums->vars['max_sig_length']) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'sig_too_long' ) );
}
//----------------------------------
// Check for valid IB CODE
//----------------------------------
//
// For efficiency, we convert the IBF code into HTML and store it in the DB
// Otherwise we'll have to parse the siggies each time we view a post - that
// gets boring after a while.
//
// We will adjust raw HTML on the fly, as some admins may allow it until it's abused
// then switch it off. If we pre-compile HTML in siggies, we'd have to edit everyones
// siggies to remove it. We don't want that.
//
// I'm going to stick my neck out again and say that most admins will allow IBF Code
// in siggies, so it's not much of a bother.
$ibforums->input['Post'] = $this->class->parser->convert( array( 'TEXT' => $ibforums->input['Post'],
'SMILIES' => 0,
'CODE' => $ibforums->vars['sig_allow_ibc'],
'HTML' => $ibforums->vars['sig_allow_html'],
'SIGNATURE' => 1
) );
if ($this->class->parser->error != "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => $this->class->parser->error) );
}
//Write it to the DB.
$ibforums->input['Post'] = preg_replace( "/'/", "\\'", $ibforums->input['Post'] );
$DB->query("UPDATE ibf_members SET signature='".$ibforums->input['Post']."' WHERE id ='".$this->class->member['id']."'");
// Buh BYE:
$std->boink_it($this->class->base_url."&act=UserCP&CODE=22");
exit;
}
}
?>