Version 1.3.0
This commit is contained in:
1 parent
7ef3d1712a
commit
f87d29ba65
290 files changed
+50206
-17930
No files matched your search
@@ -2,15 +2,17 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Board v1.1
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001,2002 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.ibforums.com
|
||||
| Email: phpboards@ibforums.com
|
||||
| Licence Info: phpib-licence@ibforums.com
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Add POLL module
|
||||
@@ -70,7 +72,7 @@ class Poll {
|
||||
|
||||
// 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");
|
||||
$DB->query("SELECT f.allow_pollbump, t.*, p.pid as poll_id,p.choices,p.starter_id,p.votes from ibf_polls p, ibf_topics t, ibf_forums f WHERE t.tid='".$ibforums->input['t']."' and p.tid=t.tid and t.forum_id=f.id");
|
||||
|
||||
$this->topic = $DB->fetch_row();
|
||||
|
||||
@@ -136,7 +138,7 @@ class Poll {
|
||||
"choices='" . $this->topic['choices'] . "' ".
|
||||
"WHERE pid='" . $this->topic['poll_id'] . "'");
|
||||
|
||||
if ($ibforums->vars['allow_poll_bump'])
|
||||
if ($this->topic['allow_pollbump'])
|
||||
{
|
||||
|
||||
$this->topic['last_vote'] = time();
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > IPChat functions
|
||||
| > Script written by Matt Mecham
|
||||
| > Date started: 29th September 2003
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly.";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
class chat_functions
|
||||
{
|
||||
|
||||
var $class = "";
|
||||
var $server = "";
|
||||
var $html = "";
|
||||
|
||||
function chat_functions()
|
||||
{
|
||||
global $DB, $std, $ibforums;
|
||||
|
||||
$this->server = str_replace( 'http://', '', $ibforums->vars['chat_server_addr'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
// register_class($class)
|
||||
//
|
||||
// Register a $this-> with this class
|
||||
//
|
||||
//-----------------------------------------------
|
||||
|
||||
function register_class(&$class)
|
||||
{
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
// Print online list
|
||||
//
|
||||
//-----------------------------------------------
|
||||
|
||||
function get_online_list()
|
||||
{
|
||||
global $DB, $std, $ibforums;
|
||||
|
||||
if ( ! $ibforums->vars['chat_who_on'] )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// Get details from the DB
|
||||
//----------------------------------
|
||||
|
||||
$DB->query("SELECT * FROM ibf_cache_store WHERE cs_key='chatstat'");
|
||||
|
||||
$row = $DB->fetch_row();
|
||||
|
||||
list( $hits, $time ) = explode( '&', $row['cs_extra'] );
|
||||
|
||||
//----------------------------------
|
||||
// Do we need to update?
|
||||
//----------------------------------
|
||||
|
||||
$final = "";
|
||||
$time_is_running_out = time();
|
||||
$member_ids = array();
|
||||
|
||||
if ( $time < time() - ( $ibforums->vars['chat_who_save'] * 60 ) )
|
||||
{
|
||||
$server_url = 'http://'.$this->server.'/ipc_who.pl?id='.$ibforums->vars['chat_account_no'].'&pw='.$ibforums->vars['chat_pass_md5'];
|
||||
|
||||
if ( $data = @file( $server_url ) )
|
||||
{
|
||||
if ( count($data) > 0 )
|
||||
{
|
||||
$hits_left = array_shift($data);
|
||||
}
|
||||
|
||||
$name_string = strtolower( implode( '","', str_replace( '"', '"', str_replace( '_', ' ', $data ) ) ) );
|
||||
|
||||
if ( count($data) > 0 )
|
||||
{
|
||||
$DB->query("SELECT m.id, m.name, g.g_id, g.prefix, g.suffix FROM ibf_members m
|
||||
LEFT JOIN ibf_groups g ON (m.mgroup=g.g_id)
|
||||
WHERE lower(name) IN (\"".$name_string."\") ORDER BY m.name");
|
||||
|
||||
while ( $m = $DB->fetch_row() )
|
||||
{
|
||||
$member_ids[] = "<a href=\"{$ibforums->base_url}showuser={$m['id']}\">{$m['prefix']}{$m['name']}{$m['suffix']}</a>";
|
||||
}
|
||||
|
||||
$final = implode( ",\n", $member_ids );
|
||||
|
||||
$final .= '|&|'.intval(count($member_ids));
|
||||
}
|
||||
|
||||
$DB->query("UPDATE ibf_cache_store SET cs_value='".addslashes($final)."', cs_extra='{$hits_left}&{$time_is_running_out}' WHERE cs_key='chatstat'");
|
||||
|
||||
$row['cs_value'] = $final;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// Any members to show?
|
||||
//----------------------------------
|
||||
|
||||
$ibforums->vars['chat_height'] += $ibforums->vars['chat_poppad'] ? $ibforums->vars['chat_poppad'] : 50;
|
||||
$ibforums->vars['chat_width'] += $ibforums->vars['chat_poppad'] ? $ibforums->vars['chat_poppad'] : 50;
|
||||
|
||||
$chat_link = ( $ibforums->vars['chat_display'] == 'self' )
|
||||
? $this->class->html->whoschatting_inline_link()
|
||||
: $this->class->html->whoschatting_popup_link();
|
||||
|
||||
list ($names, $count) = explode( '|&|', $row['cs_value'] );
|
||||
|
||||
if ( $count > 0 )
|
||||
{
|
||||
$txt = sprintf( $ibforums->lang['whoschatting_delay'], $ibforums->vars['chat_who_save'] );
|
||||
$this->html = $this->class->html->whoschatting_show( intval($count), stripslashes($names), $chat_link, $txt );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! $ibforums->vars['chat_hide_whoschatting'] )
|
||||
{
|
||||
$this->html = $this->class->html->whoschatting_empty($chat_link);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
+625
-308
@@ -1,309 +1,626 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Board v1.1
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001,2002 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| ========================================
|
||||
| Web: http://www.ibforums.com
|
||||
| Email: phpboards@ibforums.com
|
||||
| Licence Info: phpib-licence@ibforums.com
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > 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 = array();
|
||||
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'];
|
||||
|
||||
$this->temp_dump = $ibforums->vars['fake_mail'];
|
||||
|
||||
// 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()
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
$this->mail_headers = "From: \"".$ibforums->vars['board_name']."\" <".$this->from.">\n";
|
||||
|
||||
if ( count( $this->bcc ) > 1 )
|
||||
{
|
||||
$this->mail_headers .= "Bcc: ".implode( "," , $this->bcc ) . "\n";
|
||||
}
|
||||
|
||||
$this->mail_headers .= "Return-Path: ".$this->from."\n";
|
||||
$this->mail_headers .= "X-Priority: 3\n";
|
||||
$this->mail_headers .= "X-Mailer: IBForums PHP Mailer\n";
|
||||
|
||||
if ( 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()
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
$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) )
|
||||
{
|
||||
$this->subject .= " ( From ".$ibforums->vars['board_name']." )";
|
||||
|
||||
if ($this->temp_dump == 1)
|
||||
{
|
||||
$blah = $this->subject."\n------------\n".$this->mail_headers."\n\n".$this->message;
|
||||
|
||||
$pathy = '/Library/WebServer/Documents/mail/'.date("F.Y.h:i.A").".txt"; // OS X rules!
|
||||
$fh = fopen ($pathy, 'w');
|
||||
fputs ($fh, $blah, strlen($blah) );
|
||||
fclose($fh);
|
||||
}
|
||||
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 $ibforums, $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/".$ibforums->vars['default_language']."/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['header'] . $EMAIL[ $name ] . $EMAIL['footer'];
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
// 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( "/^(\r|\n)+?(.*)$/", "\\2", $message );
|
||||
|
||||
$message = preg_replace( "#<b>(.+?)</b>#" , "\\1", $message );
|
||||
$message = preg_replace( "#<i>(.+?)</i>#" , "\\1", $message );
|
||||
$message = preg_replace( "#<s>(.+?)</s>#" , "--\\1--", $message );
|
||||
$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 = str_replace( "\r" , "" , $message );
|
||||
//$message = str_replace( "\n\n", "\n" , $message );
|
||||
|
||||
$message = str_replace( "<br>" , "\n", $message );
|
||||
|
||||
$message = str_replace( """, "\"", $message );
|
||||
$message = str_replace( "\", "\\", $message );
|
||||
$message = str_replace( "$", "\$", $message );
|
||||
$message = str_replace( "!" , "!", $message );
|
||||
$message = str_replace( "'" , "'", $message );
|
||||
$message = str_replace( "<" , "<", $message );
|
||||
$message = str_replace( ">" , ">", $message );
|
||||
$message = str_replace( "&" , "&", $message );
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
function fatal_error($msg, $help="")
|
||||
{
|
||||
echo("<h1>Mail Error!</h1><br><b>$msg</b><br>$help");
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > 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 = array();
|
||||
var $mail_headers = array();
|
||||
var $multipart = "";
|
||||
var $boundry = "";
|
||||
|
||||
var $smtp_fp = FALSE;
|
||||
var $smtp_msg = "";
|
||||
var $smtp_port = "";
|
||||
var $smtp_host = "localhost";
|
||||
var $smtp_user = "";
|
||||
var $smtp_pass = "";
|
||||
var $smtp_code = "";
|
||||
|
||||
var $mail_method = 'mail';
|
||||
|
||||
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'];
|
||||
$this->temp_dump = $ibforums->vars['fake_mail'];
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Set up SMTP if we're using it
|
||||
//---------------------------------------------------------
|
||||
|
||||
if ( $ibforums->vars['mail_method'] == 'smtp' )
|
||||
{
|
||||
$this->mail_method = 'smtp';
|
||||
$this->smtp_port = ( intval($ibforums->vars['smtp_port']) != "" ) ? intval($ibforums->vars['smtp_port']) : 25;
|
||||
$this->smtp_host = ( $ibforums->vars['smtp_host'] != "" ) ? $ibforums->vars['smtp_host'] : 'localhost';
|
||||
$this->smtp_user = $ibforums->vars['smtp_user'];
|
||||
$this->smtp_pass = $ibforums->vars['smtp_pass'];
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// 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()));
|
||||
|
||||
$ibforums->vars['board_name'] = $this->clean_message($ibforums->vars['board_name']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function add_attachment($data = "", $name = "", $ctype='application/octet-stream')
|
||||
{
|
||||
|
||||
$this->parts[] = array( 'ctype' => $ctype,
|
||||
'data' => $data,
|
||||
'encode' => 'base64',
|
||||
'name' => $name
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function build_headers()
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
$this->mail_headers = "From: \"".$ibforums->vars['board_name']."\" <".$this->from.">\n";
|
||||
|
||||
if ( $this->mail_method != 'smtp' )
|
||||
{
|
||||
if ( count( $this->bcc ) > 1 )
|
||||
{
|
||||
$this->mail_headers .= "Bcc: ".implode( "," , $this->bcc ) . "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $this->to )
|
||||
{
|
||||
$this->mail_headers .= "To: ".$this->to."\n";
|
||||
}
|
||||
$this->mail_headers .= "Subject: ".$this->subject."\n";
|
||||
}
|
||||
|
||||
$this->mail_headers .= "Return-Path: ".$this->from."\n";
|
||||
$this->mail_headers .= "X-Priority: 3\n";
|
||||
$this->mail_headers .= "X-Mailer: IPB PHP Mailer\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()
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
$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->lang_subject != "" ) ? $this->lang_subject : $this->subject;
|
||||
|
||||
$this->subject = $this->clean_message($this->subject);
|
||||
|
||||
$this->build_headers();
|
||||
|
||||
if ( ($this->from) and ($this->subject) )
|
||||
{
|
||||
$this->subject .= " ( From ".$ibforums->vars['board_name']." )";
|
||||
|
||||
if ($this->temp_dump == 1)
|
||||
{
|
||||
$blah = $this->subject."\n------------\n".$this->mail_headers."\n\n".$this->message;
|
||||
|
||||
$pathy = './_mail/'.date("M-j-Y,h:i-A").".txt";
|
||||
$fh = fopen ($pathy, 'w');
|
||||
fputs ($fh, $blah, strlen($blah) );
|
||||
fclose($fh);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->mail_method != 'smtp')
|
||||
{
|
||||
if ( ! @mail( $this->to, $this->subject, $this->message, $this->mail_headers ) )
|
||||
{
|
||||
$this->fatal_error("Could not send the email", "Failed at 'mail' command");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->smtp_send_mail();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
// get_template:
|
||||
// Queries the database, and stores the template we wish to use in memory
|
||||
//+--------------------------------------------------------------------------
|
||||
|
||||
function get_template($name="", $language="")
|
||||
{
|
||||
global $ibforums, $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 ( $ibforums->vars['default_language'] == "")
|
||||
{
|
||||
$ibforums->vars['default_language'] = 'en';
|
||||
}
|
||||
|
||||
if ($language == "")
|
||||
{
|
||||
$language = $ibforums->vars['default_language'];
|
||||
}
|
||||
|
||||
if (! file_exists("./lang/$language/email_content.php") )
|
||||
{
|
||||
require "./lang/".$ibforums->vars['default_language']."/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'", "");
|
||||
}
|
||||
|
||||
if ( isset( $SUBJECT[ $name ] ) )
|
||||
{
|
||||
$this->lang_subject = $SUBJECT[ $name ];
|
||||
}
|
||||
|
||||
$this->template = $EMAIL['header'] . $EMAIL[ $name ] . $EMAIL['footer'];
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
// 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( "/^(\r|\n)+?(.*)$/", "\\2", $message );
|
||||
|
||||
$message = preg_replace( "#<b>(.+?)</b>#" , "\\1", $message );
|
||||
$message = preg_replace( "#<i>(.+?)</i>#" , "\\1", $message );
|
||||
$message = preg_replace( "#<s>(.+?)</s>#" , "--\\1--", $message );
|
||||
$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>#" , "\\1://\\2" , $message );
|
||||
$message = preg_replace( "#<a href=[\"']mailto:(.+?)['\"]>(.+?)</a>#" , "(EMAIL: \\2)" , $message );
|
||||
|
||||
$message = preg_replace( "#<!--sql-->(.+?)<!--sql1-->(.+?)<!--sql2-->(.+?)<!--sql3-->#i" , "\n\n--------------- SQL -----------\n\\2\n----------------\n\n", $message);
|
||||
$message = preg_replace( "#<!--html-->(.+?)<!--html1-->(.+?)<!--html2-->(.+?)<!--html3-->#i", "\n\n-------------- HTML -----------\n\\2\n----------------\n\n", $message);
|
||||
|
||||
$message = preg_replace( "#<!--EDIT\|.+?\|.+?-->#" , "" , $message );
|
||||
|
||||
$message = str_replace( "<br>" , "\r\n", $message );
|
||||
$message = preg_replace( "#<.+?".">#" , "" , $message );
|
||||
|
||||
$message = str_replace( """, "\"", $message );
|
||||
$message = str_replace( "\", "\\", $message );
|
||||
$message = str_replace( "$", "\$", $message );
|
||||
$message = str_replace( "!" , "!", $message );
|
||||
$message = str_replace( "'" , "'", $message );
|
||||
$message = str_replace( "<" , "<", $message );
|
||||
$message = str_replace( ">" , ">", $message );
|
||||
$message = str_replace( "|", '|', $message );
|
||||
$message = str_replace( "&" , "&", $message );
|
||||
$message = str_replace( ":" , ":", $message );
|
||||
$message = str_replace( "[" , "[", $message );
|
||||
$message = str_replace( "]" , "]", $message );
|
||||
$message = str_replace( "@", '@', $message );
|
||||
$message = str_replace( "<", '<', $message );
|
||||
$message = str_replace( ">", '>', $message );
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
function fatal_error($msg, $help="")
|
||||
{
|
||||
echo("<h1>Mail Error!</h1><br><b>$msg</b><br>$help");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
//
|
||||
// SMTP methods
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
//+------------------------------------
|
||||
//| get_line()
|
||||
//|
|
||||
//| Reads a line from the socket and returns
|
||||
//| CODE and message from SMTP server
|
||||
//|
|
||||
//+------------------------------------
|
||||
|
||||
function smtp_get_line()
|
||||
{
|
||||
$this->smtp_msg = "";
|
||||
|
||||
while ( $line = fgets( $this->smtp_fp, 515 ) )
|
||||
{
|
||||
$this->smtp_msg .= $line;
|
||||
|
||||
if ( substr($line, 3, 1) == " " )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//+------------------------------------
|
||||
//| send_cmd()
|
||||
//|
|
||||
//| Sends a command to the SMTP server
|
||||
//| Returns TRUE if response, FALSE if not
|
||||
//|
|
||||
//+------------------------------------
|
||||
|
||||
function smtp_send_cmd($cmd)
|
||||
{
|
||||
$this->smtp_msg = "";
|
||||
$this->smtp_code = "";
|
||||
|
||||
fputs( $this->smtp_fp, $cmd."\r\n" );
|
||||
|
||||
$this->smtp_get_line();
|
||||
|
||||
$this->smtp_code = substr( $this->smtp_msg, 0, 3 );
|
||||
|
||||
return $this->smtp_code == "" ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
//+------------------------------------
|
||||
//| error()
|
||||
//|
|
||||
//| Returns SMTP error to our global
|
||||
//| handler
|
||||
//|
|
||||
//+------------------------------------
|
||||
|
||||
function smtp_error($err = "")
|
||||
{
|
||||
|
||||
if ( ($this->smtp_code == 501) AND ( preg_match( "/domain missing/i", $this->smtp_msg ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->fatal_error( "SMTP protocol failure!</b><br>Host: ".$this->smtp_host."<br>Return Code: ".$this->smtp_code."<br>Return Msg: ".$this->smtp_msg."<br>Invision Power Board Error: $err", "Check your SMTP settings from the admin control panel" );
|
||||
}
|
||||
}
|
||||
|
||||
//+------------------------------------
|
||||
//| crlf_encode()
|
||||
//|
|
||||
//| RFC 788 specifies line endings in
|
||||
//| \r\n format with no periods on a
|
||||
//| new line
|
||||
//+------------------------------------
|
||||
|
||||
function smtp_crlf_encode($data)
|
||||
{
|
||||
$data .= "\n";
|
||||
$data = str_replace( "\n", "\r\n", str_replace( "\r", "", $data ) );
|
||||
$data = str_replace( "\n.\r\n" , "\n. \r\n", $data );
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
//+------------------------------------
|
||||
//| send_mail
|
||||
//|
|
||||
//| Does the bulk of the email sending
|
||||
//+------------------------------------
|
||||
|
||||
//$this->to, $this->subject, $this->message, $this->mail_headers
|
||||
|
||||
function smtp_send_mail()
|
||||
{
|
||||
$this->smtp_fp = fsockopen( $this->smtp_host, intval($this->smtp_port), $errno, $errstr, 30 );
|
||||
|
||||
if ( ! $this->smtp_fp )
|
||||
{
|
||||
$this->smtp_error("Could not open a socket to the SMTP server");
|
||||
}
|
||||
|
||||
$this->smtp_get_line();
|
||||
|
||||
$this->smtp_code = substr( $this->smtp_msg, 0, 3 );
|
||||
|
||||
if ( $this->smtp_code == 220 )
|
||||
{
|
||||
$data = $this->smtp_crlf_encode( $this->mail_headers."\n" . $this->message);
|
||||
|
||||
//---------------------
|
||||
// HELO!, er... HELLO!
|
||||
//---------------------
|
||||
|
||||
$this->smtp_send_cmd("HELO ".$this->smtp_host);
|
||||
|
||||
if ( $this->smtp_code != 250 )
|
||||
{
|
||||
$this->smtp_error("HELO");
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// Do you like my user!
|
||||
//---------------------
|
||||
|
||||
if ($this->smtp_user and $this->smtp_pass)
|
||||
{
|
||||
$this->smtp_send_cmd("AUTH LOGIN");
|
||||
|
||||
if ( $this->smtp_code == 334 )
|
||||
{
|
||||
$this->smtp_send_cmd( base64_encode($this->smtp_user) );
|
||||
|
||||
if ( $this->smtp_code != 334 )
|
||||
{
|
||||
$this->smtp_error("Username not accepted from the server");
|
||||
}
|
||||
|
||||
$this->smtp_send_cmd( base64_encode($this->smtp_pass) );
|
||||
|
||||
if ( $this->smtp_code != 235 )
|
||||
{
|
||||
$this->smtp_error("Password not accepted from the server");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->smtp_error("This server does not support authorisation");
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// We're from MARS!
|
||||
//---------------------
|
||||
|
||||
$this->smtp_send_cmd("MAIL FROM:".$this->from);
|
||||
|
||||
if ( $this->smtp_code != 250 )
|
||||
{
|
||||
$this->smtp_error();
|
||||
}
|
||||
|
||||
$to_arry = array( $this->to );
|
||||
|
||||
if ( count( $this->bcc ) > 0 )
|
||||
{
|
||||
foreach ($this->bcc as $bcc)
|
||||
{
|
||||
if ( preg_match( "/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,4})(\]?)$/", str_replace( " ", "", $bcc ) ) )
|
||||
{
|
||||
$to_arry[] = $bcc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// You are from VENUS!
|
||||
//---------------------
|
||||
|
||||
foreach( $to_arry as $to_email )
|
||||
{
|
||||
$this->smtp_send_cmd("RCPT TO:".$to_email);
|
||||
|
||||
if ( $this->smtp_code != 250 )
|
||||
{
|
||||
$this->smtp_error("Incorrect email address: $to_email");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// SEND MAIL!
|
||||
//---------------------
|
||||
|
||||
$this->smtp_send_cmd("DATA");
|
||||
|
||||
if ( $this->smtp_code == 354 )
|
||||
{
|
||||
//$this->smtp_send_cmd( $data );
|
||||
fputs( $this->smtp_fp, $data."\r\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->smtp_error("Error on write to SMTP server");
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// GO ON, NAFF OFF!
|
||||
//---------------------
|
||||
|
||||
$this->smtp_send_cmd(".");
|
||||
|
||||
if ( $this->smtp_code != 250 )
|
||||
{
|
||||
$this->smtp_error();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->smtp_send_cmd("quit");
|
||||
|
||||
if ( $this->smtp_code != 221 )
|
||||
{
|
||||
$this->smtp_error();
|
||||
return;
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// Tubby-bye-bye!
|
||||
//---------------------
|
||||
|
||||
@fclose( $this->smtp_fp );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->smtp_error();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
<html>␍<head><title>Invision Power Board - Bulletin Board System</title></head>␍<body>␍<h1>403: Invision Power Board -> Forbidden</h1>␍<hr>␍You have reached this Page in error, please use␍your back button to return to Invision Board.␍<hr>␍<a href="http://www.invisionboard.com/">Invision Power Board</a>␍</body>␍</html>␍
|
||||
@@ -0,0 +1,961 @@
|
||||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| ========================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@ibforums.com
|
||||
| Licence Info: http://www.invisionpower.com
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Moderator Core Functions
|
||||
| > Module written by Matt Mecham
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
| NOTE:
|
||||
| This module does not do any access/permission checks, it merely
|
||||
| does what is asked and returns - see function for more info
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
class modfunctions
|
||||
{
|
||||
//------------------------------------------------------
|
||||
// @modfunctions: constructor
|
||||
// -----------
|
||||
// Accepts: NOTHING
|
||||
// Returns: NOTHING (TRUE)
|
||||
//------------------------------------------------------
|
||||
|
||||
var $topic = "";
|
||||
var $forum = "";
|
||||
var $error = "";
|
||||
|
||||
var $auto_update = FALSE;
|
||||
|
||||
var $stm = "";
|
||||
var $upload_dir = "";
|
||||
|
||||
var $moderator = "";
|
||||
|
||||
function modfunctions()
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
$this->error = "";
|
||||
|
||||
$this->upload_dir = $ibforums->vars['upload_dir'];
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @init: initialize module (allows us to create new obj)
|
||||
// -----------
|
||||
// Accepts: References to @$forum [ @$topic , @$moderator ]
|
||||
// Returns: NOTHING (TRUE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function init($forum, $topic="", $moderator="")
|
||||
{
|
||||
$this->forum = $forum;
|
||||
|
||||
if ( is_array($topic) )
|
||||
{
|
||||
$this->topic = $topic;
|
||||
}
|
||||
|
||||
if ( is_array($moderator) )
|
||||
{
|
||||
$this->moderator = $moderator;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @topic_add_reply: Appends topic with reply
|
||||
// -----------
|
||||
// Accepts: $post, $tids = array( 'tid', 'forumid' );
|
||||
//
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function topic_add_reply($post="", $tids=array(), $incpost=0)
|
||||
{
|
||||
global $std, $ibforums, $DB;
|
||||
|
||||
if ( $post == "" )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( count( $tids ) < 1 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$post = array(
|
||||
'author_id' => $ibforums->member['id'],
|
||||
'use_sig' => 1,
|
||||
'use_emo' => 1,
|
||||
'ip_address' => $ibforums->input['IP_ADDRESS'],
|
||||
'post_date' => time(),
|
||||
'icon_id' => 0,
|
||||
'post' => $post,
|
||||
'author_name' => $ibforums->member['name'],
|
||||
'forum_id' => "",
|
||||
'topic_id' => "",
|
||||
'queued' => 0,
|
||||
'attach_id' => "",
|
||||
'attach_hits' => "",
|
||||
'attach_type' => "",
|
||||
);
|
||||
|
||||
//-------------------------------------
|
||||
// Add posts...
|
||||
//-------------------------------------
|
||||
|
||||
$seen_fids = array();
|
||||
$add_posts = 0;
|
||||
|
||||
foreach( $tids as $row )
|
||||
{
|
||||
$tid = intval($row[0]);
|
||||
$fid = intval($row[1]);
|
||||
$pa = array();
|
||||
$ta = array();
|
||||
|
||||
if ( ! in_array( $fid, $seen_fids ) )
|
||||
{
|
||||
$seen_fids[] = $fid;
|
||||
}
|
||||
|
||||
if ( $tid and $fid )
|
||||
{
|
||||
$pa = $post;
|
||||
$pa['forum_id'] = $fid;
|
||||
$pa['topic_id'] = $tid;
|
||||
|
||||
$db_string = $DB->compile_db_insert_string( $pa );
|
||||
|
||||
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
|
||||
unset($db_string);
|
||||
|
||||
$ta = array (
|
||||
'last_poster_id' => $ibforums->member['id'],
|
||||
'last_poster_name' => $ibforums->member['name'],
|
||||
'last_post' => $pa['post_date'],
|
||||
);
|
||||
|
||||
$db_string = $DB->compile_db_update_string( $ta );
|
||||
|
||||
$DB->query("UPDATE ibf_topics SET ".$db_string.", posts=posts+1 WHERE tid=$tid");
|
||||
|
||||
$add_posts++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->auto_update != FALSE )
|
||||
{
|
||||
if ( count($seen_fids) > 0 )
|
||||
{
|
||||
foreach( $seen_fids as $id )
|
||||
{
|
||||
$this->forum_recount( $id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $add_posts > 0 )
|
||||
{
|
||||
$DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES+".$add_posts);
|
||||
|
||||
//-------------------------------------------------
|
||||
// Update current members stuff
|
||||
//-------------------------------------------------
|
||||
|
||||
$pcount = "";
|
||||
$mgroup = "";
|
||||
|
||||
|
||||
if ( ($this->forum['inc_postcount']) and ($incpost != 0) )
|
||||
{
|
||||
//------------------------------------
|
||||
// Increment the users post count
|
||||
//------------------------------------
|
||||
|
||||
$pcount = "posts=posts+".$add_posts.", ";
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
// Are we checking for auto promotion?
|
||||
//------------------------------------
|
||||
|
||||
if ($ibforums->member['g_promotion'] != '-1&-1')
|
||||
{
|
||||
list($gid, $gposts) = explode( '&', $ibforums->member['g_promotion'] );
|
||||
|
||||
if ( $gid > 0 and $gposts > 0 )
|
||||
{
|
||||
if ( $ibforums->member['posts'] + $add_posts >= $gposts )
|
||||
{
|
||||
$mgroup = "mgroup='$gid', ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$DB->query("UPDATE ibf_members SET ".$pcount.$mgroup."last_post=".time()." WHERE id=".$ibforums->member['id']);
|
||||
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @topic_close: close topic ID's
|
||||
// -----------
|
||||
// Accepts: Array ID's | Single ID
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function topic_close($id)
|
||||
{
|
||||
global $ibforums, $DB;
|
||||
|
||||
$this->stm_init();
|
||||
$this->stm_add_close();
|
||||
$this->stm_exec($id);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// @topic_open: open topic ID's
|
||||
// -----------
|
||||
// Accepts: Array ID's | Single ID
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function topic_open($id)
|
||||
{
|
||||
global $ibforums, $DB;
|
||||
|
||||
$this->stm_init();
|
||||
$this->stm_add_open();
|
||||
$this->stm_exec($id);
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @topic_pin: pin topic ID's
|
||||
// -----------
|
||||
// Accepts: Array ID's | Single ID
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function topic_pin($id)
|
||||
{
|
||||
global $ibforums, $DB;
|
||||
|
||||
$this->stm_init();
|
||||
$this->stm_add_pin();
|
||||
$this->stm_exec($id);
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @topic_unpin: unpin topic ID's
|
||||
// -----------
|
||||
// Accepts: Array ID's | Single ID
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function topic_unpin($id)
|
||||
{
|
||||
global $ibforums, $DB;
|
||||
|
||||
$this->stm_init();
|
||||
$this->stm_add_unpin();
|
||||
$this->stm_exec($id);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// @topic_delete: deletetopic ID(s)
|
||||
// -----------
|
||||
// Accepts: $id (array | string)
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function topic_delete($id)
|
||||
{
|
||||
global $std, $ibforums, $DB;
|
||||
|
||||
$this->error = "";
|
||||
|
||||
if ( is_array( $id ) )
|
||||
{
|
||||
if ( count($id) > 0 )
|
||||
{
|
||||
$tid = " IN(".implode(",",$id).")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( intval($id) )
|
||||
{
|
||||
$tid = "=$id";
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
// Remove polls assigned to this topic
|
||||
//------------------------------------
|
||||
|
||||
$DB->query("DELETE FROM ibf_polls WHERE tid".$tid);
|
||||
|
||||
//------------------------------------
|
||||
// Remove polls assigned to this topic
|
||||
//------------------------------------
|
||||
|
||||
$DB->query("DELETE FROM ibf_voters WHERE tid".$tid);
|
||||
|
||||
//------------------------------------
|
||||
// Remove polls assigned to this topic
|
||||
//------------------------------------
|
||||
|
||||
$DB->query("DELETE FROM ibf_topics WHERE tid".$tid);
|
||||
|
||||
//------------------------------------
|
||||
// Remove polls assigned to this topic
|
||||
//------------------------------------
|
||||
|
||||
$DB->query("SELECT attach_id, attach_hits, attach_file FROM ibf_posts WHERE attach_id <> '' AND topic_id".$tid);
|
||||
|
||||
//------------------------------------
|
||||
// Remove the attachments
|
||||
//------------------------------------
|
||||
|
||||
if ( $DB->get_num_rows() )
|
||||
{
|
||||
while ( $r = $DB->fetch_row() )
|
||||
{
|
||||
if (is_file($this->upload_dir."/".$r['attach_id']))
|
||||
{
|
||||
@unlink ($this->upload_dir."/".$r['attach_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
// Remove the posts
|
||||
//------------------------------------
|
||||
|
||||
$DB->query("DELETE FROM ibf_posts WHERE topic_id".$tid);
|
||||
|
||||
//------------------------------------
|
||||
// Recount forum...
|
||||
//------------------------------------
|
||||
|
||||
if ( $this->forum['id'] )
|
||||
{
|
||||
$this->forum_recount( $this->forum['id'] );
|
||||
}
|
||||
|
||||
$this->stats_recount();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// @topic_move: move topic ID(s)
|
||||
// -----------
|
||||
// Accepts: $topics (array | string) $source,
|
||||
// $moveto
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function topic_move($topics, $source, $moveto, $leavelink=0)
|
||||
{
|
||||
global $std, $ibforums, $DB;
|
||||
|
||||
$this->error = "";
|
||||
|
||||
$source = intval($source);
|
||||
$moveto = intval($moveto);
|
||||
|
||||
if ( is_array( $topics ) )
|
||||
{
|
||||
if ( count($topics) > 0 )
|
||||
{
|
||||
$tid = " IN(".implode(",",$topics).")";
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( intval($topics) )
|
||||
{
|
||||
$tid = "=$topics";
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// Update the topic
|
||||
//----------------------------------
|
||||
|
||||
$DB->query("UPDATE ibf_topics SET forum_id=$moveto WHERE forum_id=$source AND tid".$tid);
|
||||
|
||||
//----------------------------------
|
||||
// Update the posts
|
||||
//----------------------------------
|
||||
|
||||
$DB->query("UPDATE ibf_posts SET forum_id=$moveto WHERE forum_id=$source AND topic_id".$tid);
|
||||
|
||||
//----------------------------------
|
||||
// Update the polls
|
||||
//----------------------------------
|
||||
|
||||
$DB->query("UPDATE ibf_polls SET forum_id=$moveto WHERE forum_id=$source AND tid".$tid);
|
||||
|
||||
//----------------------------------
|
||||
// Are we leaving a stink er link?
|
||||
//----------------------------------
|
||||
|
||||
if ( $leavelink != 0 )
|
||||
{
|
||||
$oq = $DB->query("SELECT * FROM ibf_topics WHERE tid".$tid);
|
||||
|
||||
while ( $row = $DB->fetch_row($oq) )
|
||||
{
|
||||
$db_string = $DB->compile_db_insert_string( array (
|
||||
'title' => $row['title'],
|
||||
'description' => $row['description'],
|
||||
'state' => 'link',
|
||||
'posts' => 0,
|
||||
'views' => 0,
|
||||
'starter_id' => $row['starter_id'],
|
||||
'start_date' => $row['start_date'],
|
||||
'starter_name' => $row['starter_name'],
|
||||
'last_post' => $row['last_post'],
|
||||
'forum_id' => $source,
|
||||
'approved' => 1,
|
||||
'pinned' => 0,
|
||||
'moved_to' => $row['tid'].'&'.$moveto,
|
||||
'last_poster_id' => $row['last_poster_id'],
|
||||
'last_poster_name' => $row['last_poster_name']
|
||||
) );
|
||||
|
||||
$DB->query("INSERT INTO ibf_topics (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
// Sort out subscriptions
|
||||
//----------------------------------
|
||||
|
||||
$DB->query("SELECT tr.*, m.id, m.mgroup, m.org_perm_id, f.read_perms, f.id, t.tid, g.g_id, g.g_perm_id
|
||||
FROM ibf_tracker tr
|
||||
LEFT JOIN ibf_topics t ON (tr.topic_id=t.tid)
|
||||
LEFT JOIN ibf_forums f ON (t.forum_id=f.id)
|
||||
LEFT JOIN ibf_members m on (m.id=tr.member_id)
|
||||
LEFT JOIN ibf_groups g on (g.g_id=m.mgroup)
|
||||
WHERE tr.topic_id".$tid);
|
||||
|
||||
$trid_to_delete = array();
|
||||
|
||||
while ( $r = $DB->fetch_row() )
|
||||
{
|
||||
//----------------------------------------
|
||||
// Match the perm group against forum_mask
|
||||
//----------------------------------------
|
||||
|
||||
$perm_id = $r['g_perm_id'];
|
||||
|
||||
if ( $r['org_perm_id'] )
|
||||
{
|
||||
$perm_id = $r['org_perm_id'];
|
||||
}
|
||||
|
||||
$pass = 0;
|
||||
|
||||
$forum_perm_array = explode( ",", $r['read_perms'] );
|
||||
|
||||
foreach( explode( ',', $perm_id ) as $u_id )
|
||||
{
|
||||
if ( in_array( $u_id, $forum_perm_array ) )
|
||||
{
|
||||
$pass = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $pass != 1 )
|
||||
{
|
||||
$trid_to_delete[] = $r['trid'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( count($trid_to_delete) > 0 )
|
||||
{
|
||||
$DB->query("DELETE FROM ibf_tracker WHERE trid IN(".implode(',', $trid_to_delete ).")");
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @stats_recount: Recount all topics & posts
|
||||
// -----------
|
||||
// Accepts: NOTHING
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function stats_recount()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$DB->query("SELECT COUNT(tid) as tcount from ibf_topics WHERE approved=1");
|
||||
$topics = $DB->fetch_row();
|
||||
|
||||
$DB->query("SELECT COUNT(pid) as pcount from ibf_posts WHERE queued <> 1");
|
||||
$posts = $DB->fetch_row();
|
||||
|
||||
$posts = $posts['pcount'] - $topics['tcount'];
|
||||
|
||||
$DB->query("UPDATE ibf_stats SET TOTAL_TOPICS=".$topics['tcount'].", TOTAL_REPLIES=".$posts);
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @forum_recount_queue: Resets use_mod_posts boolean
|
||||
// -----------
|
||||
// Accepts: forum_id
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function forum_recount_queue($fid="")
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$fid = intval($fid);
|
||||
|
||||
if ( ! $fid )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$DB->query("SELECT count(tid) as cnt FROM ibf_topics WHERE forum_id=$fid and approved <> 1");
|
||||
|
||||
$topic = $DB->fetch_row();
|
||||
|
||||
$tcount = intval( $topic['cnt'] );
|
||||
|
||||
$DB->query("SELECT count(pid) as cnt FROM ibf_posts WHERE forum_id=$fid and queued=1");
|
||||
|
||||
$post = $DB->fetch_row();
|
||||
|
||||
$pcount = intval( $post['cnt'] );
|
||||
|
||||
if ( ($tcount > 0) or ($pcount > 0) )
|
||||
{
|
||||
$DB->query("UPDATE ibf_forums SET has_mod_posts=1 WHERE id=$fid");
|
||||
}
|
||||
else
|
||||
{
|
||||
$DB->query("UPDATE ibf_forums SET has_mod_posts=0 WHERE id=$fid");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @forum_recount: Recount topic & posts in a forum
|
||||
// -----------
|
||||
// Accepts: forum_id
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function forum_recount($fid="")
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$fid = intval($fid);
|
||||
|
||||
if ( ! $fid )
|
||||
{
|
||||
if ( $this->forum['id'] )
|
||||
{
|
||||
$fid = $this->forum['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------
|
||||
// Get the topics..
|
||||
//----------------------------------------------
|
||||
|
||||
$DB->query("SELECT COUNT(tid) as count FROM ibf_topics WHERE approved=1 and forum_id=$fid");
|
||||
$topics = $DB->fetch_row();
|
||||
|
||||
//----------------------------------------------
|
||||
// Get the posts..
|
||||
//----------------------------------------------
|
||||
|
||||
$DB->query("SELECT COUNT(pid) as count FROM ibf_posts WHERE queued <> 1 and forum_id=$fid");
|
||||
$posts = $DB->fetch_row();
|
||||
|
||||
//----------------------------------------------
|
||||
// Get the forum last poster..
|
||||
//----------------------------------------------
|
||||
|
||||
$DB->query("SELECT tid, title, last_poster_id, last_poster_name, last_post FROM ibf_topics WHERE approved=1 and forum_id=$fid ORDER BY last_post DESC LIMIT 0,1");
|
||||
$last_post = $DB->fetch_row();
|
||||
|
||||
//----------------------------------------------
|
||||
// Get real post count by removing topic starting posts from the count
|
||||
//----------------------------------------------
|
||||
|
||||
$real_posts = intval($posts['count']) - intval($topics['count']);
|
||||
|
||||
//----------------------------------------------
|
||||
// Reset this forums stats
|
||||
//----------------------------------------------
|
||||
|
||||
$db_string = $DB->compile_db_update_string( array (
|
||||
'last_poster_id' => $last_post['last_poster_id'],
|
||||
'last_poster_name' => $last_post['last_poster_name'],
|
||||
'last_post' => $last_post['last_post'],
|
||||
'last_title' => $last_post['title'],
|
||||
'last_id' => $last_post['tid'],
|
||||
'topics' => intval($topics['count']) < 1 ? 0 : intval($topics['count']),
|
||||
'posts' => intval($real_posts) < 1 ? 0 : intval($real_posts),
|
||||
) );
|
||||
|
||||
$DB->query("UPDATE ibf_forums SET $db_string WHERE id=".$fid);
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// @stm_init: Clear statement ready for multi-actions
|
||||
// -----------
|
||||
// Accepts: NOTHING
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function stm_init()
|
||||
{
|
||||
$this->stm = array();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @stm_exec: Executes stored statement
|
||||
// -----------
|
||||
// Accepts: Array ID's | Single ID
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function stm_exec($id)
|
||||
{
|
||||
global $ibforums, $DB;
|
||||
|
||||
if ( count($this->stm) < 1 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$final_array = array();
|
||||
|
||||
foreach( $this->stm as $idx => $real_array )
|
||||
{
|
||||
foreach( $real_array as $k => $v )
|
||||
{
|
||||
$final_array[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$db_string = $DB->compile_db_update_string( $final_array );
|
||||
|
||||
if ( is_array($id) )
|
||||
{
|
||||
if ( count($id) > 0 )
|
||||
{
|
||||
$DB->query("UPDATE ibf_topics SET $db_string WHERE tid IN(".implode( ",", $id ).")");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if ( intval($id) != "" )
|
||||
{
|
||||
$DB->query("UPDATE ibf_topics SET $db_string WHERE tid=".intval($id));
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// @stm_add_pin: add pin command to statement
|
||||
// -----------
|
||||
// Accepts: NOTHING
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function stm_add_pin()
|
||||
{
|
||||
$this->stm[] = array( 'pinned' => 1 );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @stm_add_unpin: add unpin command to statement
|
||||
// -----------
|
||||
// Accepts: NOTHING
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function stm_add_unpin()
|
||||
{
|
||||
$this->stm[] = array( 'pinned' => 0 );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @stm_add_close: add close command to statement
|
||||
// -----------
|
||||
// Accepts: NOTHING
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function stm_add_close()
|
||||
{
|
||||
$this->stm[] = array( 'state' => 'closed' );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @stm_add_open: add open command to statement
|
||||
// -----------
|
||||
// Accepts: NOTHING
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function stm_add_open()
|
||||
{
|
||||
$this->stm[] = array( 'state' => 'open' );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @stm_add_title: add edit title command to statement
|
||||
// -----------
|
||||
// Accepts: new_title
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function stm_add_title($new_title='')
|
||||
{
|
||||
if ( $new_title == "" )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->stm[] = array( 'title' => $new_title );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @stm_add_desc: add edit desc command to statement
|
||||
// -----------
|
||||
// Accepts: new_title
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function stm_add_desc($new_desc='')
|
||||
{
|
||||
if ( $new_desc == "" )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->stm[] = array( 'description' => $new_desc );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @sql_prune_create: returns formatted SQL statement
|
||||
// -----------
|
||||
// Accepts: forum_id, poss_starter_id, poss_topic_state, poss_post_min
|
||||
// poss_date_expiration, poss_ignore_pin_state
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function sql_prune_create( $forum_id, $starter_id="", $topic_state="", $post_min="", $date_exp="", $ignore_pin="" )
|
||||
{
|
||||
$sql = "SELECT tid FROM ibf_topics WHERE approved=1 and forum_id=".intval($forum_id);
|
||||
|
||||
if ( intval($date_exp) )
|
||||
{
|
||||
$sql .= " AND last_post < $date_exp";
|
||||
}
|
||||
|
||||
if ( intval($starter_id) )
|
||||
{
|
||||
$sql .= " AND starter_id=$starter_id";
|
||||
|
||||
}
|
||||
|
||||
if ( intval($post_min) )
|
||||
{
|
||||
$sql .= " AND posts < $post_min";
|
||||
}
|
||||
|
||||
if ($topic_state != 'all')
|
||||
{
|
||||
if ($topic_state)
|
||||
{
|
||||
$sql .= " AND state='$topic_state'";
|
||||
}
|
||||
}
|
||||
|
||||
if ( $ignore_pin != "" )
|
||||
{
|
||||
$sql .= " AND pinned <> 1";
|
||||
}
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @mm_authorize: Authorizes current member
|
||||
// -----------
|
||||
// Accepts: (NOTHING: Should already be passed to init)
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function mm_authorize()
|
||||
{
|
||||
global $ibforums, $std;
|
||||
|
||||
$pass_go = FALSE;
|
||||
|
||||
if ( $ibforums->member['id'] )
|
||||
{
|
||||
if ( $ibforums->member['g_is_supmod'] )
|
||||
{
|
||||
$pass_go = TRUE;
|
||||
}
|
||||
else if ( $this->moderator['can_mm'] == 1 )
|
||||
{
|
||||
$pass_go = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return $pass_go;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @mm_check_id_in_forum: Checks to see if mm_id is in
|
||||
// the forum saved topic_mm_id
|
||||
// -----------
|
||||
// Accepts: (forum_topic_mm_id , this_mm_id)
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function mm_check_id_in_forum( $forum_topic_mm_id, $this_mm_id )
|
||||
{
|
||||
$retval = FALSE;
|
||||
|
||||
if ( stristr( $forum_topic_mm_id , ','.$this_mm_id.',' ) )
|
||||
{
|
||||
$retval = TRUE;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// @add_moderate_log: Adds entry to mod log
|
||||
// -----------
|
||||
// Accepts: (forum_id, topic_id, topic_title, post_id, title)
|
||||
// Returns: NOTHING (TRUE/FALSE)
|
||||
//------------------------------------------------------
|
||||
|
||||
function add_moderate_log($fid, $tid, $pid, $t_title, $mod_title='Unknown')
|
||||
{
|
||||
global $std, $ibforums, $DB, $HTTP_REFERER, $QUERY_STRING;
|
||||
|
||||
$db_string = $std->compile_db_string( array (
|
||||
'forum_id' => $fid,
|
||||
'topic_id' => $tid,
|
||||
'post_id' => $pid,
|
||||
'member_id' => $ibforums->member['id'],
|
||||
'member_name' => $ibforums->member['name'],
|
||||
'ip_address' => $ibforums->input['IP_ADDRESS'],
|
||||
'http_referer'=> $HTTP_REFERER,
|
||||
'ctime' => time(),
|
||||
'topic_title' => $t_title,
|
||||
'action' => $mod_title,
|
||||
'query_string'=> $QUERY_STRING,
|
||||
)
|
||||
);
|
||||
|
||||
$DB->query("INSERT INTO ibf_moderator_logs (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -2,15 +2,17 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Board v1.1
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001,2002 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.ibforums.com
|
||||
| Email: phpboards@ibforums.com
|
||||
| Licence Info: phpib-licence@ibforums.com
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Edit post library
|
||||
@@ -32,26 +34,33 @@ class post_functions extends Post {
|
||||
var $upload = array();
|
||||
var $moderator = array( 'member_id' => 0, 'member_name' => "", 'edit_post' => 0 );
|
||||
var $orig_post = array();
|
||||
var $edit_title = 0;
|
||||
|
||||
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']."'");
|
||||
$DB->query("SELECT * FROM ibf_topics WHERE tid=".intval($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']."'");
|
||||
$DB->query("SELECT * FROM ibf_posts WHERE pid=".intval($ibforums->input['p']));
|
||||
$this->orig_post = $DB->fetch_row();
|
||||
|
||||
if (! $this->orig_post['pid'])
|
||||
@@ -59,11 +68,13 @@ class post_functions extends Post {
|
||||
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Load the moderator
|
||||
//-------------------------------------------------
|
||||
|
||||
if ($ibforums->member['id'])
|
||||
{
|
||||
$DB->query("SELECT member_id, member_name, mid, edit_post FROM ibf_moderators WHERE forum_id='".$class->forum['id']."' AND (member_id='".$ibforums->member['id']."' OR (is_group=1 AND group_id='".$ibforums->member['mgroup']."'))");
|
||||
$DB->query("SELECT member_id, member_name, mid, edit_post, edit_topic FROM ibf_moderators WHERE forum_id=".$class->forum['id']." AND (member_id=".$ibforums->member['id']." OR (is_group=1 AND group_id='".$ibforums->member['mgroup']."'))");
|
||||
$this->moderator = $DB->fetch_row();
|
||||
}
|
||||
|
||||
@@ -104,11 +115,40 @@ class post_functions extends Post {
|
||||
$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') );
|
||||
if ($ibforums->member['g_post_closed'] != 1)
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------
|
||||
// // Do we have edit topic abilities?
|
||||
//-----------------------------
|
||||
|
||||
if ( $this->orig_post['new_topic'] == 1 )
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1)
|
||||
{
|
||||
$this->edit_title = 1;
|
||||
}
|
||||
|
||||
else if ($this->moderator['edit_topic'] == 1)
|
||||
{
|
||||
if ( $ibforums->member['id'] == $this->topic['starter_id'] )
|
||||
{
|
||||
$this->edit_title = 1;
|
||||
}
|
||||
}
|
||||
else if ($ibforums->member['g_edit_topic'] == 1 )
|
||||
{
|
||||
$this->edit_title = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -144,7 +184,7 @@ class post_functions extends Post {
|
||||
global $ibforums, $std, $DB, $print, $HTTP_POST_FILES;
|
||||
|
||||
$time = $std->get_date( time(), 'LONG' );
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Reset some data
|
||||
//-------------------------------------------------
|
||||
@@ -153,7 +193,7 @@ class post_functions extends Post {
|
||||
|
||||
if ($this->orig_post['attach_id'])
|
||||
{
|
||||
if ($ibforums->input['editupload'] != 'keep')
|
||||
if ( isset($ibforums->input['editupload']) AND ($ibforums->input['editupload'] != 'keep') )
|
||||
{
|
||||
// We're either uploading a new attachment, or deleting one, so lets
|
||||
// remove the old attachment first eh?
|
||||
@@ -192,13 +232,31 @@ class post_functions extends Post {
|
||||
else
|
||||
{
|
||||
// We are keeping the old attachment
|
||||
|
||||
$this->post['attach_id'] = $this->orig_post['attach_id'];
|
||||
$this->post['attach_type'] = $this->orig_post['attach_type'];
|
||||
$this->post['attach_hits'] = $this->orig_post['attach_hits'];
|
||||
$this->post['attach_file'] = $this->orig_post['attach_file'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Is there a new attachment?
|
||||
|
||||
$new_upload = $class->process_upload();
|
||||
|
||||
if ( $class->obj['post_errors'] != "") {
|
||||
|
||||
$this->show_form($class);
|
||||
}
|
||||
|
||||
if ( $new_upload['attach_id'] )
|
||||
{
|
||||
$this->post['attach_id'] = $new_upload['attach_id'];
|
||||
$this->post['attach_type'] = $new_upload['attach_type'];
|
||||
$this->post['attach_hits'] = $new_upload['attach_hits'];
|
||||
$this->post['attach_file'] = $new_upload['attach_file'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->post['ip_address'] = $this->orig_post['ip_address'];
|
||||
$this->post['topic_id'] = $this->orig_post['topic_id'];
|
||||
@@ -206,18 +264,81 @@ class post_functions extends Post {
|
||||
$this->post['pid'] = $this->orig_post['pid'];
|
||||
$this->post['post_date'] = $this->orig_post['post_date'];
|
||||
$this->post['author_name'] = $this->orig_post['author_name'];
|
||||
$this->post['queued'] = $this->orig_post['queued'];
|
||||
$this->post['edit_time'] = time();
|
||||
$this->post['edit_name'] = $ibforums->member['name'];
|
||||
|
||||
//-------------------------------------------------
|
||||
// If the post icon has changed, update the topic post icon
|
||||
//-------------------------------------------------
|
||||
|
||||
if ($this->orig_post['new_topic'] == 1)
|
||||
{
|
||||
if ($this->post['icon_id'] != $this->orig_post['icon_id'])
|
||||
{
|
||||
$DB->query("UPDATE ibf_topics SET icon_id='".$this->post['icon_id']."' WHERE tid='".$this->topic['tid']."'");
|
||||
$DB->query("UPDATE ibf_topics SET icon_id='".$this->post['icon_id']."' WHERE tid=".$this->topic['tid']);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Update topic title?
|
||||
//-------------------------------------------------
|
||||
|
||||
if ( $this->edit_title == 1 )
|
||||
{
|
||||
if ($ibforums->vars['etfilter_punct'])
|
||||
{
|
||||
$ibforums->input['TopicTitle'] = preg_replace( "/\?{1,}/" , "?" , $ibforums->input['TopicTitle'] );
|
||||
$ibforums->input['TopicTitle'] = preg_replace( "/(!){1,}/" , "!", $ibforums->input['TopicTitle'] );
|
||||
}
|
||||
|
||||
if ($ibforums->vars['etfilter_shout'])
|
||||
{
|
||||
$ibforums->input['TopicTitle'] = ucwords(strtolower($ibforums->input['TopicTitle']));
|
||||
}
|
||||
|
||||
$ibforums->input['TopicTitle'] = trim( $class->parser->bad_words( $ibforums->input['TopicTitle'] ) );
|
||||
$ibforums->input['TopicDesc'] = trim( $class->parser->bad_words( $ibforums->input['TopicDesc'] ) );
|
||||
|
||||
if ( $ibforums->input['TopicTitle'] != "" )
|
||||
{
|
||||
if ( ($ibforums->input['TopicTitle'] != $this->topic['title']) or ($ibforums->input['TopicDesc'] != $this->topic['description']) )
|
||||
{
|
||||
$dbs = $DB->compile_db_update_string( array(
|
||||
'title' => $ibforums->input['TopicTitle'],
|
||||
'description' => $ibforums->input['TopicDesc']
|
||||
) );
|
||||
|
||||
$DB->query("UPDATE ibf_topics SET $dbs WHERE tid=".$this->topic['tid']);
|
||||
|
||||
if ($this->topic['tid'] == $class->forum['last_id'])
|
||||
{
|
||||
$DB->query("UPDATE ibf_forums SET last_title='{$ibforums->input['TopicTitle']}' WHERE id='".$class->forum['id']."'");
|
||||
}
|
||||
|
||||
if ( ($this->moderator['edit_topic'] == 1) OR ( $ibforums->member['g_is_supmod'] == 1 ) )
|
||||
{
|
||||
$db_string = $std->compile_db_string( array (
|
||||
'forum_id' => $class->forum['id'],
|
||||
'topic_id' => $this->topic['tid'],
|
||||
'post_id' => $this->post['pid'],
|
||||
'member_id' => $ibforums->member['id'],
|
||||
'member_name' => $ibforums->member['name'],
|
||||
'ip_address' => $ibforums->input['IP_ADDRESS'],
|
||||
'http_referer'=> $HTTP_REFERER,
|
||||
'ctime' => time(),
|
||||
'topic_title' => $this->topic['title'],
|
||||
'action' => "Edited topic title or description '{$this->topic['title']}' to '{$ibforums->input['TopicTitle']}' via post form",
|
||||
'query_string'=> $QUERY_STRING,
|
||||
)
|
||||
);
|
||||
|
||||
$DB->query("INSERT INTO ibf_moderator_logs (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Update the database (ib_forum_post)
|
||||
//-------------------------------------------------
|
||||
@@ -260,12 +381,23 @@ class post_functions extends Post {
|
||||
// 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']);
|
||||
$raw_post = isset($HTTP_POST_VARS['Post']) ? $std->txt_htmlspecialchars($HTTP_POST_VARS['Post']) : $class->parser->unconvert($this->orig_post['post'], $class->forum['use_ibc'], $class->forum['use_html']);
|
||||
|
||||
if (isset($raw_post)) {
|
||||
$raw_post = str_replace( '$' , "$" , $raw_post );
|
||||
$raw_post = str_replace( '<' , "<" , $raw_post );
|
||||
$raw_post = stripslashes($raw_post);
|
||||
if (isset($raw_post))
|
||||
{
|
||||
$raw_post = $std->txt_raw2form($raw_post);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Is this the first post in the topic?
|
||||
//-------------------------------------------------
|
||||
|
||||
if ( $this->edit_title == 1 )
|
||||
{
|
||||
$topic_title = isset($HTTP_POST_VARS['TopicTitle']) ? $ibforums->input['TopicTitle'] : $this->topic['title'];
|
||||
$topic_desc = isset($HTTP_POST_VARS['TopicDesc']) ? $ibforums->input['TopicDesc'] : $this->topic['description'];
|
||||
|
||||
$topic_title = $class->html->topictitle_fields( array( 'TITLE' => $topic_title, 'DESC' => $topic_desc ) );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@@ -279,7 +411,15 @@ class post_functions extends Post {
|
||||
|
||||
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']) ) );
|
||||
$this->post['post'] = $class->parser->post_db_parse(
|
||||
$class->parser->convert( array(
|
||||
'TEXT' => $this->post['post'],
|
||||
'CODE' => $class->forum['use_ibc'],
|
||||
'SMILIES' => $ibforums->input['enableemo'],
|
||||
'HTML' => $class->forum['use_html']
|
||||
) ) ,
|
||||
$class->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0);
|
||||
$class->output .= $class->html->preview( $this->post['post'] );
|
||||
}
|
||||
|
||||
$class->check_upload_ability();
|
||||
@@ -308,9 +448,16 @@ class post_functions extends Post {
|
||||
|
||||
$post_icons = $class->html_post_icons($this->orig_post['icon_id']);
|
||||
|
||||
if (($class->obj['can_upload']) and ($this->orig_post['attach_id'] != ""))
|
||||
if ( $class->obj['can_upload'] )
|
||||
{
|
||||
$upload_field = $class->html->edit_upload_field( $ibforums->member['g_attach_max'] * 1024, $this->orig_post['attach_file'] );
|
||||
if ($this->orig_post['attach_id'] != "")
|
||||
{
|
||||
$upload_field = $class->html->edit_upload_field( $std->size_format( $ibforums->member['g_attach_max'] * 1024 ), $this->orig_post['attach_file'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$upload_field = $class->html->Upload_field( $std->size_format( $ibforums->member['g_attach_max'] * 1024 ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ($ibforums->member['g_append_edit'])
|
||||
@@ -334,11 +481,21 @@ class post_functions extends Post {
|
||||
$class->output = str_replace( "<!--END TABLE-->" , $end_form , $class->output );
|
||||
$class->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $class->output );
|
||||
$class->output = str_replace( "<!--MOD OPTIONS-->" , $edit_option , $class->output );
|
||||
$class->output = str_replace( "<!--FORUM RULES-->" , $std->print_forum_rules($class->forum), $class->output );
|
||||
$class->output = str_replace( "<!--TOPIC TITLE-->" , $topic_title , $class->output );
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$class->html_add_smilie_box();
|
||||
|
||||
//---------------------------------------
|
||||
// Add in siggy buttons and such
|
||||
//---------------------------------------
|
||||
|
||||
$class->html_checkboxes('edit');
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$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>",
|
||||
|
||||
@@ -2,15 +2,17 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Board v1.1
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001,2002 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.ibforums.com
|
||||
| Email: phpboards@ibforums.com
|
||||
| Licence Info: phpib-licence@ibforums.com
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > New Post module
|
||||
@@ -41,19 +43,14 @@ class post_functions extends Post {
|
||||
|
||||
// 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 ( $std->check_perms($class->forum['start_perms']) == FALSE )
|
||||
{
|
||||
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['start_perms'] ) )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_starting') );
|
||||
}
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_starting') );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,14 +71,22 @@ class post_functions extends Post {
|
||||
|
||||
$ibforums->input['TopicTitle'] = str_replace( "<br>", "", $ibforums->input['TopicTitle'] );
|
||||
|
||||
$ibforums->input['TopicTitle'] = trim(stripslashes($ibforums->input['TopicTitle']));
|
||||
$ibforums->input['TopicTitle'] = trim($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 )
|
||||
//-------------------------------------------------
|
||||
// More unicode..
|
||||
//-------------------------------------------------
|
||||
|
||||
$temp = $std->txt_stripslashes($HTTP_POST_VARS['TopicTitle']);
|
||||
|
||||
$temp = preg_replace("/&#([0-9]+);/", "-", $temp );
|
||||
|
||||
if ( strlen($temp) > 64 )
|
||||
{
|
||||
$class->obj['post_errors'] = 'topic_title_long';
|
||||
}
|
||||
@@ -154,6 +159,16 @@ class post_functions extends Post {
|
||||
$class->moderate_log('Closed topic from post form', $ibforums->input['TopicTitle']);
|
||||
}
|
||||
}
|
||||
else if ($ibforums->input['mod_options'] == 'pinclose')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or ( $class->moderator['pin_topic'] == 1 AND $class->moderator['close_topic'] == 1 ) )
|
||||
{
|
||||
$pinned = 1;
|
||||
$state = 'closed';
|
||||
|
||||
$class->moderate_log('Pinned & closed topic from post form', $ibforums->input['TopicTitle']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@@ -177,7 +192,7 @@ class post_functions extends Post {
|
||||
'last_vote' => 0,
|
||||
'views' => 0,
|
||||
'forum_id' => $class->forum['id'],
|
||||
'approved' => $class->obj['moderate'] ? 0 : 1,
|
||||
'approved' => ( $class->obj['moderate'] == 1 || $class->obj['moderate'] == 2 ) ? 0 : 1,
|
||||
'pinned' => $pinned,
|
||||
);
|
||||
|
||||
@@ -193,9 +208,10 @@ class post_functions extends Post {
|
||||
$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'];
|
||||
@@ -203,14 +219,32 @@ class post_functions extends Post {
|
||||
$this->post['attach_file'] = $this->upload['attach_file'];
|
||||
$this->post['new_topic'] = 1;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Unqueue the post if we're starting a new topic
|
||||
//-------------------------------------------------
|
||||
|
||||
if ( $class->obj['moderate'] == 3 )
|
||||
{
|
||||
$this->post['queued'] = 0;
|
||||
}
|
||||
|
||||
$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'])
|
||||
if ( $class->obj['moderate'] == 1 OR $class->obj['moderate'] == 2 )
|
||||
{
|
||||
// Redirect them with a message telling them the post has to be previewed first
|
||||
//-------------------------------------------------
|
||||
// Redirect them with a message telling them the
|
||||
// post has to be previewed first
|
||||
//-------------------------------------------------
|
||||
|
||||
$DB->query("UPDATE ibf_forums SET has_mod_posts=1 WHERE id=".$class->forum['id']);
|
||||
|
||||
$class->notify_new_topic_approval( $this->topic['tid'], $this->topic['title'], $this->topic['starter_name'] );
|
||||
|
||||
$print->redirect_screen( $ibforums->lang['moderate_topic'], "act=SF&f={$class->forum['id']}" );
|
||||
}
|
||||
|
||||
@@ -243,7 +277,7 @@ class post_functions extends Post {
|
||||
// Are we tracking new topics we start 'auto_track'?
|
||||
//-------------------------------------------------
|
||||
|
||||
if ($ibforums->member['auto_track'] == 1)
|
||||
if ( $ibforums->member['id'] AND $ibforums->input['enabletrack'] == 1 )
|
||||
{
|
||||
$db_string = $DB->compile_db_insert_string( array (
|
||||
'member_id' => $ibforums->member['id'],
|
||||
@@ -288,6 +322,12 @@ class post_functions extends Post {
|
||||
if ( $ibforums->member['posts'] + 1 >= $gposts )
|
||||
{
|
||||
$mgroup = "mgroup='$gid', ";
|
||||
|
||||
if ( USE_MODULES == 1 )
|
||||
{
|
||||
$class->modules->register_class(&$class);
|
||||
$class->modules->on_group_change($ibforums->member['id'], $gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,7 +343,7 @@ class post_functions extends Post {
|
||||
// Redirect them back to the topic
|
||||
//-------------------------------------------------
|
||||
|
||||
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
$std->boink_it($class->base_url."act=ST&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
|
||||
}
|
||||
|
||||
@@ -319,14 +359,13 @@ class post_functions extends Post {
|
||||
// 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'] : "";
|
||||
$raw_post = isset($HTTP_POST_VARS['Post']) ? $std->txt_htmlspecialchars($HTTP_POST_VARS['Post']) : "";
|
||||
$topic_title = isset($HTTP_POST_VARS['TopicTitle']) ? $ibforums->input['TopicTitle'] : "";
|
||||
$topic_desc = isset($HTTP_POST_VARS['TopicDesc']) ? $ibforums->input['TopicDesc'] : "";
|
||||
|
||||
if (isset($raw_post))
|
||||
{
|
||||
$raw_post = str_replace( '$' , "$" , htmlspecialchars($raw_post) );
|
||||
$raw_post = stripslashes($raw_post);
|
||||
$raw_post = $std->txt_raw2form($raw_post);
|
||||
}
|
||||
|
||||
// Do we have any posting errors?
|
||||
@@ -338,7 +377,15 @@ class post_functions extends Post {
|
||||
|
||||
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']) ) );
|
||||
$this->post['post'] = $class->parser->post_db_parse(
|
||||
$class->parser->convert( array(
|
||||
'TEXT' => $this->post['post'],
|
||||
'CODE' => $class->forum['use_ibc'],
|
||||
'SMILIES' => $ibforums->input['enableemo'],
|
||||
'HTML' => $class->forum['use_html']
|
||||
) ) ,
|
||||
$class->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0 );
|
||||
$class->output .= $class->html->preview( $this->post['post'] );
|
||||
}
|
||||
|
||||
$class->check_upload_ability();
|
||||
@@ -353,7 +400,7 @@ class post_functions extends Post {
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$topic_title = $class->html->topictitle_fields( array( TITLE => $topic_title, DESC => $topic_desc ) );
|
||||
$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']}");
|
||||
|
||||
@@ -369,7 +416,7 @@ class post_functions extends Post {
|
||||
|
||||
if ($class->obj['can_upload'])
|
||||
{
|
||||
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
|
||||
$upload_field = $class->html->Upload_field( $std->size_format( $ibforums->member['g_attach_max'] * 1024 ) );
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
@@ -382,13 +429,22 @@ class post_functions extends Post {
|
||||
$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 = str_replace("<!--FORUM RULES-->", $std->print_forum_rules($class->forum), $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>",
|
||||
//---------------------------------------
|
||||
// Add in siggy buttons and such
|
||||
//---------------------------------------
|
||||
|
||||
$class->html_checkboxes();
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$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'];
|
||||
|
||||
|
||||
+388
-105
@@ -2,19 +2,22 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Board v1.1
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001,2002 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.ibforums.com
|
||||
| Email: phpboards@ibforums.com
|
||||
| Licence Info: phpib-licence@ibforums.com
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Text processor module
|
||||
| > Module written by Matt Mecham
|
||||
| > Official Version: 1.2 - Number of changes to date 3 billion (estimated)
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -32,6 +35,8 @@ class post_parser {
|
||||
var $emoticons = "";
|
||||
var $badwords = "";
|
||||
var $strip_quotes = "";
|
||||
var $in_sig = "";
|
||||
var $allow_unicode = 1;
|
||||
|
||||
function smilie_length_sort($a, $b)
|
||||
{
|
||||
@@ -75,6 +80,10 @@ class post_parser {
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->no_bad_words = 1;
|
||||
}
|
||||
|
||||
// Pre-load the smilies
|
||||
|
||||
@@ -125,21 +134,23 @@ class post_parser {
|
||||
function convert($in=array( 'TEXT' => "", 'SMILIES' => 0, 'CODE' => 0, 'SIGNATURE' => 0, 'HTML' => 0)) {
|
||||
global $ibforums, $DB;
|
||||
|
||||
$this->in_sig = $in['SIGNATURE'];
|
||||
|
||||
$txt = $in['TEXT'];
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// Returns any errors as $this->error
|
||||
//--------------------------------------
|
||||
|
||||
// Remove session id's from any post
|
||||
|
||||
$txt = preg_replace( "#[?&;]s=([0-9a-zA-Z]){32}#", "", $txt );
|
||||
$txt = preg_replace( "#(\?|&|;|&)s=([0-9a-zA-Z]){32}(&|;|&|$)?#e", "\$this->regex_bash_session('\\1', '\\3')", $txt );
|
||||
|
||||
//--------------------------------------
|
||||
// convert <br> to \n
|
||||
//--------------------------------------
|
||||
|
||||
$txt = preg_replace( "/<br>|<br\s*\/>/", "\n", $txt );
|
||||
$txt = preg_replace( "/<br>|<br \/>/", "\n", $txt );
|
||||
|
||||
//--------------------------------------
|
||||
// Are we parsing iB_CODE and do we have either '[' or ']' in the
|
||||
@@ -148,26 +159,25 @@ class post_parser {
|
||||
|
||||
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 );
|
||||
|
||||
//--------------------------------------
|
||||
// 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 [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 );
|
||||
$txt = preg_replace( "#(\[quote(.+?)?\].*\[/quote\])#ies" , "\$this->regex_parse_quotes('\\1')" , $txt );
|
||||
|
||||
/***********************************************/
|
||||
// If we are not parsing a siggie, lets have a bash
|
||||
@@ -179,12 +189,19 @@ class post_parser {
|
||||
$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 );
|
||||
|
||||
while( preg_match( "#\n?\[list\](.+?)\[/list\]\n?#ies" , $txt ) )
|
||||
{
|
||||
$txt = preg_replace( "#\n?\[list\](.+?)\[/list\]\n?#ies", "\$this->regex_list('\\1')" , $txt );
|
||||
}
|
||||
|
||||
while( preg_match( "#\n?\[list=(a|A|i|I|1)\](.+?)\[/list\]\n?#ies" , $txt ) )
|
||||
{
|
||||
$txt = preg_replace( "#\n?\[list=(a|A|i|I|1)\](.+?)\[/list\]\n?#ies", "\$this->regex_list('\\2','\\1')" , $txt );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
@@ -211,6 +228,21 @@ class post_parser {
|
||||
$txt = preg_replace( "#\(tm\)#i" , "™" , $txt );
|
||||
$txt = preg_replace( "#\(r\)#i" , "®" , $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*\"\;([\.\w\-]+\@[\.\w\-]+\.[\.\w\-]+)\s*\"\;\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*\"\;\s*(\S+?)\s*\"\;\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 );
|
||||
|
||||
|
||||
// font size, colour and font style
|
||||
// [font=courier]Text here[/font] [size=6]Text here[/size] [color=red]Text here[/color]
|
||||
|
||||
@@ -229,19 +261,6 @@ class post_parser {
|
||||
$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*\"\;([\.\w\-]+\@[\.\w\-]+\.[\.\w\-]+)\s*\"\;\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*\"\;\s*(\S+?)\s*\"\;\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 );
|
||||
|
||||
}
|
||||
|
||||
@@ -249,6 +268,13 @@ class post_parser {
|
||||
|
||||
$txt = preg_replace( "/\n/", "<br>", $txt );
|
||||
|
||||
// Unicode?
|
||||
|
||||
if ( $this->allow_unicode )
|
||||
{
|
||||
$txt = preg_replace("/&#([0-9]+);/s", "&#\\1;", $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.
|
||||
@@ -256,6 +282,8 @@ class post_parser {
|
||||
|
||||
if ($in['SMILIES'] != 0 and $in['SIGNATURE'] == 0) {
|
||||
|
||||
$txt = ' '.$txt.' ';
|
||||
|
||||
if ( ! is_array($this->emoticons) )
|
||||
{
|
||||
$DB->query("SELECT typed, image from ibf_emoticons");
|
||||
@@ -285,19 +313,11 @@ class post_parser {
|
||||
$code = $row['typed'];
|
||||
$image = $row['image'];
|
||||
|
||||
/*$code = str_replace( "&", "&", $code );
|
||||
$code = str_replace( "<", "<" , $code );
|
||||
$code = str_replace( ">", ">" , $code );
|
||||
$code = str_replace( "\"", """, $code);
|
||||
$code = str_replace( "'", "'" , $code);
|
||||
$code = str_replace( "!", "!" , $code);
|
||||
$code = str_replace( "|", "|" , $code);*/
|
||||
|
||||
// Make safe for regex
|
||||
|
||||
$code = preg_quote($code, "/");
|
||||
|
||||
$txt = preg_replace( "!(?<=[^\w&])$code(?=.\W|\W.|\W$)!ei", "\$this->convert_emoticon('$code', '$image')", ' '.$txt.' ' );
|
||||
$txt = preg_replace( "!(?<=[^\w&;/])$code(?=.\W|\W.|\W$)!ei", "\$this->convert_emoticon('$code', '$image')", $txt );
|
||||
|
||||
}
|
||||
|
||||
@@ -308,6 +328,10 @@ class post_parser {
|
||||
if ($this->emoticon_count > $ibforums->vars['max_emos'])
|
||||
{
|
||||
$this->error = 'too_many_emoticons';
|
||||
|
||||
// Uncovert the little yellow chappies
|
||||
|
||||
//$txt = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , $txt );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,22 +339,120 @@ class post_parser {
|
||||
|
||||
$txt = $this->bad_words($txt);
|
||||
|
||||
if ($in['HTML'] == 1)
|
||||
{
|
||||
$txt = str_replace( "<" ,"<" , $txt );
|
||||
$txt = str_replace( ">" ,">" , $txt );
|
||||
$txt = str_replace( """ ,"\"", $txt);
|
||||
$txt = str_replace( "'" ,"'" , $txt);
|
||||
$txt = str_replace( "&" ,"&" , $txt );
|
||||
}
|
||||
|
||||
return $txt; //trim($txt);
|
||||
return $txt;
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
//--------------------------------------------------------------
|
||||
// Post DB parse tags
|
||||
// ...................
|
||||
//--------------------------------------------------------------
|
||||
|
||||
function post_db_parse($t="", $use_html=0)
|
||||
{
|
||||
global $ibforums, $DB;
|
||||
|
||||
if ( $use_html )
|
||||
{
|
||||
$t = preg_replace( "#\[dohtml\](.+?)\[/dohtml\]#ies", "\$this->parse_html('\\1')", $t );
|
||||
}
|
||||
else
|
||||
{
|
||||
$t = preg_replace( "#(\[dohtml\])(.+?)(\[/dohtml\])#ies", "\$this->my_strip_tags('\\2')", $t );
|
||||
}
|
||||
|
||||
return $t;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// My strip-tags. Converts HTML entities back before strippin' em
|
||||
//---------------------------------------------------------------
|
||||
|
||||
function my_strip_tags($t="")
|
||||
{
|
||||
$t = str_replace( '>', '>', $t );
|
||||
$t = str_replace( '<', '<', $t );
|
||||
|
||||
$t = strip_tags($t);
|
||||
|
||||
// Make sure nothing naughty is left...
|
||||
|
||||
$t = str_replace( '<', '<', $t );
|
||||
$t = str_replace( '>', '>', $t );
|
||||
|
||||
return $t;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Word wrap, wraps 'da word innit
|
||||
//--------------------------------------------------------------
|
||||
|
||||
function my_wordwrap($t="", $chrs=0, $replace="<br />")
|
||||
{
|
||||
if ( $t == "" )
|
||||
{
|
||||
return $t;
|
||||
}
|
||||
|
||||
if ( $chrs < 1 )
|
||||
{
|
||||
return $t;
|
||||
}
|
||||
|
||||
$t = preg_replace("#([^\s<>'\"/\.\\-\?&\n\r\%]{".$chrs."})#i", " \\1".$replace ,$t);
|
||||
|
||||
return $t;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// parse_html
|
||||
// Converts the doHTML tag
|
||||
//--------------------------------------------------------------
|
||||
|
||||
function parse_html($t="", $do_br=1)
|
||||
{
|
||||
if ( $t == "" )
|
||||
{
|
||||
return $t;
|
||||
}
|
||||
|
||||
// Remove <br>s 'cos we know they can't
|
||||
// be user inputted, 'cos they are still
|
||||
// <br> at this point :)
|
||||
|
||||
if ( $do_br == 1 )
|
||||
{
|
||||
$t = str_replace( "<br>" , "\n" , $t );
|
||||
$t = str_replace( "<br />" , "\n" , $t );
|
||||
}
|
||||
$t = str_replace( "'" , "'", $t );
|
||||
$t = str_replace( "!" , "!", $t );
|
||||
$t = str_replace( "$" , "$", $t );
|
||||
$t = str_replace( "|" , "|", $t );
|
||||
$t = str_replace( "&" , "&", $t );
|
||||
$t = str_replace( ">" , ">", $t );
|
||||
$t = str_replace( "<" , "<", $t );
|
||||
$t = str_replace( """ , '"', $t );
|
||||
|
||||
// Take a crack at parsing some of the nasties
|
||||
// NOTE: THIS IS NOT DESIGNED AS A FOOLPROOF METHOD
|
||||
// AND SHOULD NOT BE RELIED UPON!
|
||||
|
||||
$t = preg_replace( "/alert/i" , "alert" , $t );
|
||||
$t = preg_replace( "/onmouseover/i", "onmouseover", $t );
|
||||
$t = preg_replace( "/onclick/i" , "onclick" , $t );
|
||||
$t = preg_replace( "/onload/i" , "onload" , $t );
|
||||
$t = preg_replace( "/onsubmit/i" , "onsubmit" , $t );
|
||||
|
||||
return $t;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Badwords:
|
||||
// Swops naughty, naugty words and stuff
|
||||
/**************************************************/
|
||||
//--------------------------------------------------------------
|
||||
|
||||
function bad_words($text = "")
|
||||
{
|
||||
@@ -341,6 +463,11 @@ class post_parser {
|
||||
return "";
|
||||
}
|
||||
|
||||
if ( $this->no_bad_words == 1 )
|
||||
{
|
||||
return $text;
|
||||
}
|
||||
|
||||
//--------------------------------
|
||||
|
||||
if ( ! is_array($this->badwords) )
|
||||
@@ -409,46 +536,59 @@ class post_parser {
|
||||
|
||||
function unconvert($txt="", $code=1, $html=0) {
|
||||
|
||||
$txt = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , $txt );
|
||||
|
||||
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( "#<!--sql-->(.+?)<!--sql1-->(.+?)<!--sql2-->(.+?)<!--sql3-->#eis" , "\$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( "#<a href=[\"'](http://|https://|ftp://|news://)?(\S+?)['\"].+?".">(.+?)</a>#" , "\[URL=\\1\\2\]\\3\[/URL\]" , $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( "#<!--QuoteBegin-->(.+?)<!--QuoteEBegin-->#" , '[QUOTE]' , $txt );
|
||||
$txt = preg_replace( "#<!--QuoteBegin-{1,2}([^>]+?)\+([^>]+?)-->(.+?)<!--QuoteEBegin-->#" , "[QUOTE=\\1,\\2]" , $txt );
|
||||
$txt = preg_replace( "#<!--QuoteBegin-{1,2}([^>]+?)\+-->(.+?)<!--QuoteEBegin-->#" , "[QUOTE=\\1]" , $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( "#<!--QuoteEnd-->(.+?)<!--QuoteEEnd-->#" , '[/QUOTE]' , $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 );
|
||||
$txt = preg_replace( "#<i>(.+?)</i>#is" , "\[i\]\\1\[/i\]" , $txt );
|
||||
$txt = preg_replace( "#<b>(.+?)</b>#is" , "\[b\]\\1\[/b\]" , $txt );
|
||||
$txt = preg_replace( "#<s>(.+?)</s>#is" , "\[s\]\\1\[/s\]" , $txt );
|
||||
$txt = preg_replace( "#<u>(.+?)</u>#is" , "\[u\]\\1\[/u\]" , $txt );
|
||||
|
||||
$txt = preg_replace( "#(\n){0,}<ul>#" , "\\1\[LIST\]" , $txt );
|
||||
$txt = preg_replace( "#(\n){0,}<ol type='(a|A|i|I|1)'>#" , "\\1\[LIST=\\2\]\n" , $txt );
|
||||
$txt = preg_replace( "#(\n){0,}<li>#" , "\n\[*\]" , $txt );
|
||||
$txt = preg_replace( "#(\n){0,}</ul>(\n){0,}#", "\n\[/LIST\]\\2" , $txt );
|
||||
$txt = preg_replace( "#(\n){0,}</ol>(\n){0,}#", "\n\[/LIST\]\\2" , $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>#se" , "\$this->unconvert_size('\\1', '\\2')", $txt );
|
||||
|
||||
while ( preg_match( "#<span style=['\"]color:(.+?)['\"]>(.+?)</span>#is", $txt ) )
|
||||
{
|
||||
$txt = preg_replace( "#<span style=['\"]color:(.+?)['\"]>(.+?)</span>#is" , "\[color=\\1\]\\2\[/color\]", $txt );
|
||||
}
|
||||
|
||||
$txt = preg_replace( "#<span style=['\"]font-family:(.+?)['\"]>(.+?)</span>#is", "\[font=\\1\]\\2\[/font\]", $txt );
|
||||
|
||||
// Tidy up the end quote stuff
|
||||
|
||||
$txt = preg_replace( "#(\[/QUOTE\])\s*?<br>\s*#si", "\\1\n", $txt );
|
||||
|
||||
$txt = preg_replace( "#<!--EDIT\|.+?\|.+?-->#" , "" , $txt );
|
||||
|
||||
$txt = str_replace( "</li>", "", $txt );
|
||||
|
||||
$txt = str_replace( "™", "(tm)", $txt );
|
||||
}
|
||||
|
||||
if ($html == 1)
|
||||
@@ -496,7 +636,12 @@ class post_parser {
|
||||
|
||||
function unconvert_sql($sql="") {
|
||||
$sql = stripslashes($sql);
|
||||
$sql = preg_replace( "#<span style='.+?'>(.+?)</span>#", "\\1", $sql );
|
||||
|
||||
while ( preg_match( "#<span style='.+?'>(.+?)</span>#is", $sql ) )
|
||||
{
|
||||
$sql = preg_replace( "#<span style='.+?'>(.+?)</span>#is", "\\1", $sql );
|
||||
}
|
||||
|
||||
$sql = preg_replace( "#\s*$#" , "", $sql );
|
||||
|
||||
return '[SQL]'.$sql.'[/SQL]';
|
||||
@@ -505,7 +650,12 @@ class post_parser {
|
||||
|
||||
function unconvert_htm($html="") {
|
||||
$html = stripslashes($html);
|
||||
$html = preg_replace( "#<span style='.+?'>(.+?)</span>#", "\\1", $html );
|
||||
|
||||
while ( preg_match( "#<span style='.+?'>(.+?)</span>#is", $html ) )
|
||||
{
|
||||
$html = preg_replace( "#<span style='.+?'>(.+?)</span>#is", "\\1", $html );
|
||||
}
|
||||
|
||||
$html = preg_replace( "#\s*$#" , "", $html );
|
||||
|
||||
return '[HTML]'.$html.'[/HTML]';
|
||||
@@ -534,7 +684,7 @@ class post_parser {
|
||||
|
||||
$this->emoticon_count++;
|
||||
|
||||
return "<!--emo&$code--><img src='{$ibforums->vars['EMOTICONS_URL']}/$image' border='0' valign='absmiddle' alt='$image'><!--endemo-->";
|
||||
return "<!--emo&".trim($code)."--><img src='{$ibforums->vars['EMOTICONS_URL']}/$image' border='0' style='vertical-align:middle' alt='$image' /><!--endemo-->";
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
@@ -546,7 +696,7 @@ class post_parser {
|
||||
global $ibforums;
|
||||
|
||||
if (! isset($in['TYPE']) ) $in['TYPE'] = 'class';
|
||||
if (! isset($in['CSS']) ) $in['CSS'] = 'postcolor';
|
||||
if (! isset($in['CSS']) ) $in['CSS'] = $this->in_sig == 1 ? 'signature' : 'postcolor';
|
||||
if (! isset($in['STYLE']) ) $in['STYLE'] = 'QUOTE';
|
||||
|
||||
//-----------------------------
|
||||
@@ -562,12 +712,49 @@ class post_parser {
|
||||
'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]}'>"
|
||||
return array( 'START' => "</div><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><div {$in[TYPE]}='{$in[CSS]}'>"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************/
|
||||
// regex_list: List generation
|
||||
//
|
||||
/**************************************************/
|
||||
|
||||
function regex_list( $txt="", $type="" )
|
||||
{
|
||||
if ($txt == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//$txt = str_replace( "\n", "", str_replace( "\r\n", "\n", $txt ) );
|
||||
|
||||
if ( $type == "" )
|
||||
{
|
||||
// Unordered list.
|
||||
|
||||
return "<ul>".$this->regex_list_item($txt)."</ul>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<ol type='$type'>".$this->regex_list_item($txt)."</ol>";
|
||||
}
|
||||
}
|
||||
|
||||
function regex_list_item($txt)
|
||||
{
|
||||
$txt = preg_replace( "#\[\*\]#", "</li><li>" , trim($txt) );
|
||||
|
||||
$txt = preg_replace( "#^</?li>#" , "", $txt );
|
||||
|
||||
return str_replace( "\n</li>", "</li>", $txt."</li>" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************/
|
||||
// regex_html_tag: HTML syntax highlighting
|
||||
//
|
||||
@@ -581,7 +768,8 @@ class post_parser {
|
||||
|
||||
// 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) ) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -592,13 +780,22 @@ class post_parser {
|
||||
|
||||
//$html = nl2br($html);
|
||||
|
||||
// Take a stab at removing most of the common
|
||||
// smilie characters.
|
||||
|
||||
$html = preg_replace( "#:#" , ":", $html );
|
||||
$html = preg_replace( "#\[#" , "[", $html );
|
||||
$html = preg_replace( "#\]#" , "]", $html );
|
||||
$html = preg_replace( "#\)#" , ")", $html );
|
||||
$html = preg_replace( "#\(#" , "(", $html );
|
||||
|
||||
$html = preg_replace( "/^<br>/", "", $html );
|
||||
$html = preg_replace( "/^\s+/" , "", $html );
|
||||
|
||||
$html = preg_replace( "#<([^&<>]+)>#" , "<<span style='color:blue'>\\1</span>>" , $html ); //Matches <tag>
|
||||
$html = preg_replace( "#<([^&<>]+)=#" , "<<span style='color:blue'>\\1</span>=" , $html ); //Matches <tag
|
||||
$html = preg_replace( "#</([^&]+)>#" , "</<span style='color:blue'>\\1</span>>" , $html ); //Matches </tag>
|
||||
$html = preg_replace( "!=("|')(.+?)("|')(\s|>)!" , "=\\1<span style='color:orange'>\\2</span>\\3\\4" , $html ); //Matches ='this'
|
||||
$html = preg_replace( "!=("|')(.+?)?("|')(\s|>)!" , "=\\1<span style='color:orange'>\\2</span>\\3\\4" , $html ); //Matches ='this'
|
||||
$html = preg_replace( "!<!--(.+?)-->!" , "<!<span style='color:red'>--\\1--</span>>", $html );
|
||||
|
||||
|
||||
@@ -640,7 +837,7 @@ class post_parser {
|
||||
$sql = preg_replace( "#(MAX|AVG|SUM|COUNT|MIN)\(#i" , "<span style='color:blue'>\\1</span>(" , $sql );
|
||||
$sql = preg_replace( "!("|'|')(.+?)("|'|')!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( "#(LEFT|JOIN|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 );
|
||||
@@ -671,10 +868,10 @@ class post_parser {
|
||||
// Take a stab at removing most of the common
|
||||
// smilie characters.
|
||||
|
||||
//$txt = str_replace( "&" , "&", $txt );
|
||||
$txt = preg_replace( "#<#" , "<", $txt );
|
||||
$txt = preg_replace( "#>#" , ">", $txt );
|
||||
$txt = preg_replace( "#"#" , """, $txt );
|
||||
$txt = preg_replace( "#\s{1};#" , ";", $txt );
|
||||
$txt = preg_replace( "#:#" , ":", $txt );
|
||||
$txt = preg_replace( "#\[#" , "[", $txt );
|
||||
$txt = preg_replace( "#\]#" , "]", $txt );
|
||||
@@ -682,6 +879,7 @@ class post_parser {
|
||||
$txt = preg_replace( "#\(#" , "(", $txt );
|
||||
$txt = preg_replace( "#\r#" , "<br>", $txt );
|
||||
$txt = preg_replace( "#\n#" , "<br>", $txt );
|
||||
$txt = preg_replace( "#\s{1};#" , ";", $txt );
|
||||
|
||||
// Ensure that spacing is preserved
|
||||
|
||||
@@ -713,17 +911,21 @@ class post_parser {
|
||||
|
||||
$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( "#\[quote\]#ie" , "\$this->regex_simple_quote_tag()" , $txt );
|
||||
$txt = preg_replace( "#\[quote=([^\]]+?),([^\]]+?)\]#ie" , "\$this->regex_quote_tag('\\1', '\\2')" , $txt );
|
||||
$txt = preg_replace( "#\[quote=([^\]]+?)\]#ie" , "\$this->regex_quote_tag('\\1', '')" , $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
|
||||
if ( ($this->quote_open == $this->quote_closed) and ($this->quote_error == 0) )
|
||||
{
|
||||
$txt = preg_replace( "#(<!--QuoteEBegin-->.+?<!--QuoteEnd-->)#es", "\$this->regex_preserve_spacing('\\1')", trim($txt) );
|
||||
|
||||
return $txt;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return $the_txt;
|
||||
}
|
||||
|
||||
@@ -734,8 +936,9 @@ class post_parser {
|
||||
// without CSS killing <pre> tags
|
||||
/**************************************************/
|
||||
|
||||
function regex_preserve_spacing($txt="") {
|
||||
$txt = preg_replace( "#\s{2}#", " ", trim($txt) );
|
||||
function regex_preserve_spacing($txt="")
|
||||
{
|
||||
$txt = preg_replace( "#\s{2}#", " ", trim($txt) );
|
||||
return $txt;
|
||||
}
|
||||
|
||||
@@ -760,14 +963,15 @@ class post_parser {
|
||||
|
||||
function regex_close_quote() {
|
||||
|
||||
if ($this->quote_open == 0) {
|
||||
if ($this->quote_open == 0)
|
||||
{
|
||||
$this->quote_error++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->quote_closed++;
|
||||
$this->quote_closed++;
|
||||
|
||||
return "<!--QuoteEnd-->{$this->quote_html['END']}<!--QuoteEEnd-->";
|
||||
return "<!--QuoteEnd-->{$this->quote_html['END']}<!--QuoteEEnd-->";
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
@@ -775,16 +979,44 @@ class post_parser {
|
||||
// [QUOTE=Matthew,14 February 2002]
|
||||
/**************************************************/
|
||||
|
||||
function regex_quote_tag($name="", $date="") {
|
||||
function regex_quote_tag($name="", $date="")
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
$default = "\[quote=$name,$date\]";
|
||||
if ( $date != "" )
|
||||
{
|
||||
$default = "\[quote=$name,$date\]";
|
||||
}
|
||||
else
|
||||
{
|
||||
$default = "\[quote=$name\]";
|
||||
}
|
||||
|
||||
if ( strstr( $name, '<!--c1-->' ) or strstr( $date, '<!--c1-->' ) )
|
||||
{
|
||||
// Code tag detected...
|
||||
|
||||
$this->quote_error++;
|
||||
return $default;
|
||||
}
|
||||
|
||||
$name = str_replace( "+", "+", $name );
|
||||
$name = str_replace( "-", "-", $name );
|
||||
$name = str_replace( '[', "[", $name );
|
||||
$name = str_replace( ']', "]", $name );
|
||||
|
||||
$this->quote_open++;
|
||||
|
||||
if ($date == "")
|
||||
{
|
||||
$html = $this->wrap_style( array( 'STYLE' => 'QUOTE', 'EXTRA' => "($name)" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$html = $this->wrap_style( array( 'STYLE' => 'QUOTE', 'EXTRA' => "($name @ $date)" ) );
|
||||
}
|
||||
|
||||
$html = $this->wrap_style( array( 'STYLE' => 'QUOTE', 'EXTRA' => "($name @ $date)" ) );
|
||||
|
||||
$extra = "--$name+$date";
|
||||
$extra = "-".$name.'+'.$date;
|
||||
|
||||
return "<!--QuoteBegin".$extra."-->{$html['START']}<!--QuoteEBegin-->";
|
||||
|
||||
@@ -869,10 +1101,19 @@ class post_parser {
|
||||
|
||||
if ($ibforums->vars['img_ext'])
|
||||
{
|
||||
$extension = preg_replace( "/^.*\.(\S+)$/", "\\1", $url );
|
||||
$extension = preg_replace( "#^.*\.(\S+)$#", "\\1", $url );
|
||||
|
||||
$extension = strtolower($extension);
|
||||
|
||||
if ( (! $extension) OR ( preg_match( "#/#", $extension ) ) )
|
||||
{
|
||||
$this->error = 'invalid_ext';
|
||||
return $default;
|
||||
}
|
||||
|
||||
$ibforums->vars['img_ext'] = strtolower($ibforums->vars['img_ext']);
|
||||
if (!preg_match( "/$extension(\||$)/", $ibforums->vars['img_ext'] ))
|
||||
|
||||
if (!preg_match( "/".preg_quote($extension, '/')."(\||$)/", $ibforums->vars['img_ext'] ))
|
||||
{
|
||||
$this->error = 'invalid_ext';
|
||||
return $default;
|
||||
@@ -888,7 +1129,9 @@ class post_parser {
|
||||
|
||||
// If we are still here....
|
||||
|
||||
return "<img src='$url' border='0' alt='user posted image'>";
|
||||
$url = str_replace( " ", "%20", $url );
|
||||
|
||||
return "<img src='$url' border='0' alt='user posted image' />";
|
||||
}
|
||||
|
||||
|
||||
@@ -910,6 +1153,8 @@ class post_parser {
|
||||
$IN['1'] = $attr[0];
|
||||
}
|
||||
|
||||
$IN['1'] = preg_replace( "/[&\(\)\.\%]/", "", $IN['1'] );
|
||||
|
||||
if ($IN['s'] == 'size')
|
||||
{
|
||||
$IN['1'] = $IN['1'] + 7;
|
||||
@@ -979,7 +1224,7 @@ class post_parser {
|
||||
$url['show'] = preg_replace( "/&/" , "&" , $url['show'] );
|
||||
$url['show'] = preg_replace( "/javascript:/i", "javascript: ", $url['show'] );
|
||||
|
||||
if (strlen($url['show']) < 55) $skip_it = 1;
|
||||
if ( (strlen($url['show']) -58 ) < 3 ) $skip_it = 1;
|
||||
|
||||
// Make sure it's a "proper" url
|
||||
|
||||
@@ -998,6 +1243,44 @@ class post_parser {
|
||||
|
||||
}
|
||||
|
||||
function regex_bash_session($start_tok, $end_tok)
|
||||
{
|
||||
// Bug fix :D
|
||||
// Case 1: index.php?s=0000 :: Return nothing (parses: index.php)
|
||||
// Case 2: index.php?s=0000&this=1 :: Return ? (parses: index.php?this=1)
|
||||
// Case 3: index.php?this=1&s=0000 :: Return nothing (parses: index.php?this=1)
|
||||
// Case 4: index.php?t=1&s=00&y=2 :: Return & (parses: index.php?t=1&y=2)
|
||||
// Thanks to LavaSoft for spotting this one.
|
||||
|
||||
$start_tok = str_replace( '&', '&', $start_tok );
|
||||
$end_tok = str_replace( '&', '&', $end_tok );
|
||||
|
||||
//1:
|
||||
if ($start_tok == '?' and $end_tok == '')
|
||||
{
|
||||
return "";
|
||||
}
|
||||
//2:
|
||||
else if ($start_tok == '?' and $end_tok == '&')
|
||||
{
|
||||
return '?';
|
||||
}
|
||||
//3:
|
||||
else if ($start_tok == '&' and $end_tok == '')
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else if ($start_tok == '&' and $end_tok == '&')
|
||||
{
|
||||
return "&";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $start_tok.$end_tok;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,15 +2,17 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Board v1.1
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001,2002 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.ibforums.com
|
||||
| Email: phpboards@ibforums.com
|
||||
| Licence Info: phpib-licence@ibforums.com
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > New Post module
|
||||
@@ -35,11 +37,22 @@ class post_functions extends Post {
|
||||
|
||||
var $m_group = "";
|
||||
|
||||
function post_functions($class) {
|
||||
function post_functions($class)
|
||||
{
|
||||
|
||||
global $ibforums, $std, $DB;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Sort out maximum number of poll choices allowed
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
$ibforums->vars['max_poll_choices'] = $ibforums->vars['max_poll_choices'] ? $ibforums->vars['max_poll_choices'] : 10;
|
||||
|
||||
$ibforums->lang['poll_choices'] = sprintf( $ibforums->lang['poll_choices'], $ibforums->vars['max_poll_choices'] );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Lets do some tests to make sure that we are allowed to start a new topic
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
if (! $ibforums->member['g_post_polls'])
|
||||
{
|
||||
@@ -51,14 +64,11 @@ class post_functions extends Post {
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
|
||||
}
|
||||
|
||||
$this->m_group = $ibforums->member['mgroup'];
|
||||
$this->m_group = $ibforums->perm_id;
|
||||
|
||||
if ($class->forum['start_perms'] != '*')
|
||||
if ( $std->check_perms($class->forum['start_perms']) != TRUE )
|
||||
{
|
||||
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['start_perms'] ) )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
|
||||
}
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -81,7 +91,16 @@ class post_functions extends Post {
|
||||
$class->obj['post_errors'] = 'no_topic_title';
|
||||
}
|
||||
|
||||
if ( strlen($ibforums->input['TopicTitle']) > 64 ) {
|
||||
//-------------------------------------------------
|
||||
// More unicode..
|
||||
//-------------------------------------------------
|
||||
|
||||
$temp = $std->txt_stripslashes($HTTP_POST_VARS['TopicTitle']);
|
||||
|
||||
$temp = preg_replace("/&#([0-9]+);/", "-", $temp );
|
||||
|
||||
if ( strlen($temp) > 64 )
|
||||
{
|
||||
$class->obj['post_errors'] = 'topic_title_long';
|
||||
}
|
||||
|
||||
@@ -95,11 +114,13 @@ class post_functions extends Post {
|
||||
|
||||
$this->poll_choices = preg_replace( "/<br>/e" , "\$this->regex_count_choices()" , $this->poll_choices );
|
||||
|
||||
if ($this->poll_count > 10) {
|
||||
if ($this->poll_count > $ibforums->vars['max_poll_choices'])
|
||||
{
|
||||
$class->obj['post_errors'] = 'poll_to_many';
|
||||
}
|
||||
|
||||
if ($this->poll_count < 1) {
|
||||
if ($this->poll_count < 1)
|
||||
{
|
||||
$class->obj['post_errors'] = 'poll_not_enough';
|
||||
}
|
||||
|
||||
@@ -146,7 +167,7 @@ class post_functions extends Post {
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$poll_array[] = array( $count , $polling, 0 );
|
||||
$poll_array[] = array( $count , $class->parser->bad_words($polling), 0 );
|
||||
$count++;
|
||||
}
|
||||
|
||||
@@ -168,6 +189,15 @@ class post_functions extends Post {
|
||||
$ibforums->input['TopicTitle'] = $class->parser->bad_words( $ibforums->input['TopicTitle'] );
|
||||
$ibforums->input['TopicDesc'] = $class->parser->bad_words( $ibforums->input['TopicDesc'] );
|
||||
|
||||
if ( $ibforums->vars['poll_disable_noreply'] != 1 )
|
||||
{
|
||||
$poll_state = $ibforums->input['allow_disc'] == 0 ? 'open' : 'closed';
|
||||
}
|
||||
else
|
||||
{
|
||||
$poll_state = 'open';
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Build the master array
|
||||
//-------------------------------------------------
|
||||
@@ -185,7 +215,7 @@ class post_functions extends Post {
|
||||
'last_post' => time(),
|
||||
'icon_id' => $ibforums->input['iconid'],
|
||||
'author_mode' => $ibforums->member['id'] ? 1 : 0,
|
||||
'poll_state' => $ibforums->input['allow_disc'] == 0 ? 'open' : 'closed',
|
||||
'poll_state' => $poll_state,
|
||||
'last_vote' => 0,
|
||||
'views' => 0,
|
||||
'forum_id' => $class->forum['id'],
|
||||
@@ -214,6 +244,15 @@ class post_functions extends Post {
|
||||
$this->post['attach_hits'] = $this->upload['attach_hits'];
|
||||
$this->post['new_topic'] = 1;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Unqueue the post if we're starting a new topic
|
||||
//-------------------------------------------------
|
||||
|
||||
if ( $class->obj['moderate'] == 3 )
|
||||
{
|
||||
$this->post['queued'] = 0;
|
||||
}
|
||||
|
||||
$db_string = $DB->compile_db_insert_string( $this->post );
|
||||
|
||||
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
@@ -241,10 +280,14 @@ class post_functions extends Post {
|
||||
|
||||
|
||||
|
||||
if ($class->obj['moderate'])
|
||||
if ( $class->obj['moderate'] == 1 OR $class->obj['moderate'] == 2 )
|
||||
{
|
||||
|
||||
// Redirect them with a message telling them the post has to be previewed first
|
||||
|
||||
$DB->query("UPDATE ibf_forums SET has_mod_posts=1 WHERE id=".$class->forum['id']);
|
||||
|
||||
$class->notify_new_topic_approval( $this->topic['tid'], $this->topic['title'], $this->topic['starter_name'] );
|
||||
|
||||
$print->redirect_screen( $ibforums->lang['moderate_topic'], "act=SF&f={$class->forum['id']}" );
|
||||
}
|
||||
|
||||
@@ -307,6 +350,12 @@ class post_functions extends Post {
|
||||
if ( $ibforums->member['posts'] + 1 >= $gposts )
|
||||
{
|
||||
$mgroup = "mgroup='$gid', ";
|
||||
|
||||
if ( USE_MODULES == 1 )
|
||||
{
|
||||
$class->modules->register_class(&$class);
|
||||
$class->modules->on_group_change($ibforums->member['id'], $gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,7 +377,7 @@ class post_functions extends Post {
|
||||
// Redirect them back to the topic
|
||||
//-------------------------------------------------
|
||||
|
||||
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
$std->boink_it($class->base_url."act=ST&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
|
||||
}
|
||||
|
||||
@@ -344,26 +393,36 @@ class post_functions extends Post {
|
||||
// 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']) : "";
|
||||
$raw_post = isset($HTTP_POST_VARS['Post']) ? $std->txt_htmlspecialchars($HTTP_POST_VARS['Post']) : "";
|
||||
$topic_title = isset($HTTP_POST_VARS['TopicTitle']) ? str_replace("'", "'", stripslashes($HTTP_POST_VARS['TopicTitle']) ) : "";
|
||||
$topic_desc = isset($HTTP_POST_VARS['TopicDesc']) ? str_replace("'", "'", stripslashes($HTTP_POST_VARS['TopicDesc']) ) : "";
|
||||
$poll = isset($HTTP_POST_VARS['PollAnswers']) ? $std->txt_htmlspecialchars($std->txt_stripslashes($HTTP_POST_VARS['PollAnswers'])) : "";
|
||||
|
||||
if (isset($raw_post)) {
|
||||
$raw_post = preg_replace( "/<textarea>/", "<textarea>", $raw_post );
|
||||
$raw_post = str_replace( '$', "$", $raw_post );
|
||||
if (isset($raw_post))
|
||||
{
|
||||
$raw_post = $std->txt_raw2form($raw_post);
|
||||
$raw_post = str_replace( '<%', "<%" , $raw_post );
|
||||
$raw_post = stripslashes($raw_post);
|
||||
|
||||
}
|
||||
|
||||
// Do we have any posting errors?
|
||||
|
||||
if ($class->obj['post_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']) ) );
|
||||
if ($class->obj['preview_post'])
|
||||
{
|
||||
$this->post['post'] = $class->parser->post_db_parse(
|
||||
$class->parser->convert( array(
|
||||
'TEXT' => $this->post['post'],
|
||||
'CODE' => $class->forum['use_ibc'],
|
||||
'SMILIES' => $ibforums->input['enableemo'],
|
||||
'HTML' => $class->forum['use_html']
|
||||
) ) ,
|
||||
$class->forum['use_html']);
|
||||
$class->output .= $class->html->preview( $this->post['post'] );
|
||||
}
|
||||
|
||||
$extra = "";
|
||||
@@ -385,7 +444,7 @@ class post_functions extends Post {
|
||||
|
||||
$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']}");
|
||||
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_poll']}: {$class->forum['name']}");
|
||||
|
||||
$name_fields = $class->html_name_field();
|
||||
|
||||
@@ -393,7 +452,7 @@ class post_functions extends Post {
|
||||
|
||||
$mod_options = $class->mod_options();
|
||||
|
||||
$poll_box = $class->html->poll_box($poll, $extra);
|
||||
$poll_box = $class->html->poll_box( $poll, $extra);
|
||||
|
||||
$end_form = $class->html->EndForm( $ibforums->lang['submit_poll'] );
|
||||
|
||||
@@ -415,14 +474,24 @@ class post_functions extends Post {
|
||||
$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->output = str_replace("<!--FORUM RULES-->", $std->print_forum_rules($class->forum), $class->output );
|
||||
|
||||
if ( $ibforums->vars['poll_disable_noreply'] != 1 )
|
||||
{
|
||||
$class->output = str_replace("<!--IBF.POLL_OPTIONS-->", $class->html->poll_options(), $class->output );
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
// Add in siggy buttons and such
|
||||
//---------------------------------------
|
||||
|
||||
$class->html_checkboxes();
|
||||
|
||||
|
||||
$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->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'];
|
||||
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > 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;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Sort out maximum number of poll choices allowed
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
$ibforums->vars['max_poll_choices'] = $ibforums->vars['max_poll_choices'] ? $ibforums->vars['max_poll_choices'] : 10;
|
||||
|
||||
$ibforums->lang['poll_choices'] = sprintf( $ibforums->lang['poll_choices'], $ibforums->vars['max_poll_choices'] );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Lets do some tests to make sure that we are allowed to start a new topic
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
if (! $ibforums->member['g_post_polls'])
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
|
||||
}
|
||||
|
||||
if ( ! $class->forum['allow_poll'] )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
|
||||
}
|
||||
|
||||
if ( $std->check_perms($class->forum['start_perms']) == FALSE )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
|
||||
}
|
||||
|
||||
if ( ! intval($ibforums->input['t']) )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'is_broken_link') );
|
||||
}
|
||||
else
|
||||
{
|
||||
$tid = intval($ibforums->input['t']);
|
||||
|
||||
$DB->query("SELECT * from ibf_topics WHERE tid=$tid");
|
||||
|
||||
if ( ! $this->topic = $DB->fetch_row() )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'is_broken_link') );
|
||||
}
|
||||
}
|
||||
|
||||
$pass = 0;
|
||||
|
||||
if ( $ibforums->member['id'] )
|
||||
{
|
||||
if ( $ibforums->member['g_is_supmod'] == 1 )
|
||||
{
|
||||
$pass = 1;
|
||||
}
|
||||
else if ( $this->topic['starter_id'] == $ibforums->member['id'] )
|
||||
{
|
||||
if ( ($ibforums->vars['startpoll_cutoff'] > 0) AND ( $this->topic['start_date'] + ($ibforums->vars['startpoll_cutoff'] * 3600) > time() ) )
|
||||
{
|
||||
$pass = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $pass != 1 )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
|
||||
}
|
||||
}
|
||||
|
||||
function process($class) {
|
||||
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
// check to make sure we have a correct # of choices
|
||||
//-------------------------------------------------
|
||||
|
||||
$this->poll_choices = $ibforums->input['PollAnswers'];
|
||||
|
||||
$this->poll_choices = preg_replace( "/<br><br>/" , "" , $this->poll_choices );
|
||||
|
||||
$this->poll_choices = preg_replace( "/<br>/e" , "\$this->regex_count_choices()" , $this->poll_choices );
|
||||
|
||||
if ($this->poll_count > $ibforums->vars['max_poll_choices'])
|
||||
{
|
||||
$class->obj['post_errors'] = 'poll_to_many';
|
||||
}
|
||||
|
||||
if ($this->poll_count < 1)
|
||||
{
|
||||
$class->obj['post_errors'] = 'poll_not_enough';
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($class->obj['post_errors'] != "")
|
||||
{
|
||||
// Show the form again
|
||||
$this->show_form($class);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->add_new_poll($class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function add_new_poll($class) {
|
||||
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Sort out the poll stuff
|
||||
// This is somewhat contrived, but it has to be
|
||||
// compatible with the current perl version.
|
||||
//-------------------------------------------------
|
||||
|
||||
$poll_array = array();
|
||||
$count = 0;
|
||||
|
||||
$polls = explode( "<br>", $this->poll_choices );
|
||||
|
||||
foreach ($polls as $polling)
|
||||
{
|
||||
if ( $polling == "" )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$poll_array[] = array( $count , $class->parser->bad_words($polling), 0 );
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Add the poll to the forum_polls table
|
||||
// if we are moderating this post
|
||||
//-------------------------------------------------
|
||||
|
||||
$db_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,
|
||||
'poll_question' => $class->parser->bad_words($ibforums->input['pollq']),
|
||||
)
|
||||
);
|
||||
|
||||
$DB->query("INSERT INTO ibf_polls (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
|
||||
$DB->query("UPDATE ibf_topics SET poll_state='open' WHERE tid={$this->topic['tid']}");
|
||||
|
||||
//-------------------------------------------------
|
||||
// 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.
|
||||
|
||||
$poll = isset($HTTP_POST_VARS['PollAnswers']) ? $std->txt_htmlspecialchars($HTTP_POST_VARS['PollAnswers']) : "";
|
||||
|
||||
$extra = "";
|
||||
|
||||
if ($ibforums->vars['poll_tags'])
|
||||
{
|
||||
$extra = $ibforums->lang['poll_tag_allowed'];
|
||||
}
|
||||
|
||||
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '15' ), 2 => array( 'f', $class->forum['id']), 2 => array( 't', $this->topic['tid']) ) );
|
||||
|
||||
//---------------------------------------
|
||||
// START TABLE
|
||||
//---------------------------------------
|
||||
|
||||
$class->output .= $class->html->table_structure();
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_poll']}: {$class->forum['name']} -> ".$this->topic['title']);
|
||||
|
||||
$poll_box = $class->html->poll_box($poll, $extra);
|
||||
|
||||
$end_form = $class->html->poll_end_form( $ibforums->lang['submit_poll'] );
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$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->output = str_replace("<!--FORUM RULES-->", $std->print_forum_rules($class->forum), $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>",
|
||||
"<a href='{$class->base_url}act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
|
||||
);
|
||||
$this->title = $ibforums->lang['posting_poll'];
|
||||
|
||||
$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>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -2,15 +2,17 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Board v1.1
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001,2002 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.ibforums.com
|
||||
| Email: phpboards@ibforums.com
|
||||
| Licence Info: phpib-licence@ibforums.com
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Reply with quote library
|
||||
@@ -70,20 +72,15 @@ class post_functions extends Post {
|
||||
|
||||
if ($this->topic['starter_id'] != $ibforums->member['id'])
|
||||
{
|
||||
if (! $ibforums->member['g_reply_own_topics'])
|
||||
if (! $ibforums->member['g_reply_other_topics'])
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
}
|
||||
|
||||
$this->m_group = $ibforums->member['mgroup'];
|
||||
|
||||
if ($class->forum['reply_perms'] != '*')
|
||||
if ( $std->check_perms($class->forum['reply_perms']) == FALSE )
|
||||
{
|
||||
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['reply_perms'] ) )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
|
||||
// Is the topic locked?
|
||||
@@ -114,16 +111,25 @@ class post_functions extends Post {
|
||||
|
||||
if ($ibforums->input['QPost'])
|
||||
{
|
||||
|
||||
$this->quoted_post['AUTHOR']['name'] = $ibforums->input['QAuthorN'];
|
||||
|
||||
$this->quoted_post['DATE'] = $std->get_date( $ibforums->input['QDate'], 'LONG' );
|
||||
|
||||
$this->quoted_post['post'] = $class->parser->convert( array( 'TEXT' => $ibforums->input['QPost'],
|
||||
'SMILIES' => 1,
|
||||
'SMILIES' => $ibforums->input['enableemo'],
|
||||
'CODE' => 1,
|
||||
'HTML' => 0,
|
||||
) );
|
||||
|
||||
|
||||
$this->quoted_post['AUTHOR']['name'] = $ibforums->input['QAuthorN'];
|
||||
|
||||
$this->quoted_post['DATE'] = $std->get_date( $ibforums->input['QDate'], 'LONG' );
|
||||
if ( $class->parser->error != "" )
|
||||
{
|
||||
$class->obj['post_errors'] = $class->parser->error;
|
||||
|
||||
$class->dump_quote = '[QUOTE='.$this->quoted_post['AUTHOR']['name'].','.$this->quoted_post['DATE'].']'.$ibforums->input['QPost'].'[/QUOTE]'."\n";
|
||||
|
||||
$this->show_form($class);
|
||||
}
|
||||
|
||||
// add it to the post
|
||||
|
||||
@@ -132,9 +138,11 @@ class post_functions extends Post {
|
||||
) );
|
||||
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->quoted_post['AUTHOR']['name'] = str_replace( "-", "-", $this->quoted_post['AUTHOR']['name'] );
|
||||
|
||||
$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
|
||||
@@ -144,14 +152,19 @@ class post_functions extends Post {
|
||||
|
||||
}
|
||||
|
||||
if ($class->obj['post_errors'] == "") {
|
||||
if ($class->obj['post_errors'] == "")
|
||||
{
|
||||
$this->upload = $class->process_upload();
|
||||
}
|
||||
|
||||
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") ) {
|
||||
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
|
||||
{
|
||||
// Show the form again
|
||||
|
||||
$this->show_form($class);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->add_reply($class);
|
||||
}
|
||||
}
|
||||
@@ -209,6 +222,16 @@ function add_reply($class) {
|
||||
$return_to_move = 1;
|
||||
}
|
||||
}
|
||||
else if ($ibforums->input['mod_options'] == 'pinclose')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or ( $class->moderator['pin_topic'] == 1 AND $class->moderator['close_topic'] == 1 ) )
|
||||
{
|
||||
$this->topic['pinned'] = 1;
|
||||
$this->topic['state'] = 'closed';
|
||||
|
||||
$class->moderate_log('Pinned & closed topic from post form', $this->topic['title']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db_string = $std->compile_db_string( $this->post );
|
||||
@@ -216,9 +239,14 @@ function add_reply($class) {
|
||||
$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']) {
|
||||
if ( $class->obj['moderate'] == 1 or $class->obj['moderate'] == 3 )
|
||||
{
|
||||
$DB->query("UPDATE ibf_forums SET has_mod_posts=1 WHERE id=".$class->forum['id']);
|
||||
|
||||
$print->redirect_screen( $ibforums->lang['moderate_post'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}" );
|
||||
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
|
||||
$page = $page * $ibforums->vars['display_max_posts'];
|
||||
|
||||
$print->redirect_screen( $ibforums->lang['moderate_post'], "showtopic={$this->topic['tid']}&st=$page" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@@ -226,18 +254,13 @@ function add_reply($class) {
|
||||
// board/forum/topic stats
|
||||
//-------------------------------------------------
|
||||
|
||||
$class->forum['last_title'] = $this->topic['title'];
|
||||
$class->forum['last_title'] = str_replace( "'", "'", $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'] ."', ".
|
||||
@@ -251,7 +274,15 @@ function add_reply($class) {
|
||||
|
||||
|
||||
|
||||
// Update the database
|
||||
//-------------------------------------------------
|
||||
// Get the correct number of replies the topic has
|
||||
//-------------------------------------------------
|
||||
|
||||
$DB->query("SELECT COUNT(pid) as posts FROM ibf_posts WHERE topic_id={$this->topic['tid']} and queued != 1");
|
||||
|
||||
$posts = $DB->fetch_row();
|
||||
|
||||
$pcount = intval( $posts['posts'] - 1 );
|
||||
|
||||
//+------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -260,7 +291,7 @@ function add_reply($class) {
|
||||
"last_post='" .$class->forum['last_post'] ."', ".
|
||||
"pinned='" .$this->topic['pinned'] ."', ".
|
||||
"state='" .$this->topic['state'] ."', ".
|
||||
"posts=posts+1 ".
|
||||
"posts=$pcount ".
|
||||
"WHERE tid='" .$this->topic['tid'] ."'");
|
||||
|
||||
//+------------------------------------------------------------------------------------------------------
|
||||
@@ -295,6 +326,12 @@ function add_reply($class) {
|
||||
if ( $ibforums->member['posts'] + 1 >= $gposts )
|
||||
{
|
||||
$mgroup = "mgroup='$gid', ";
|
||||
|
||||
if ( USE_MODULES == 1 )
|
||||
{
|
||||
$class->modules->register_class(&$class);
|
||||
$class->modules->on_group_change($ibforums->member['id'], $gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +347,7 @@ function add_reply($class) {
|
||||
// Are we tracking topics we reply in 'auto_track'?
|
||||
//-------------------------------------------------
|
||||
|
||||
if ($ibforums->member['auto_track'] == 1)
|
||||
if ( $ibforums->member['id'] AND $ibforums->input['enabletrack'] == 1 )
|
||||
{
|
||||
$DB->query("SELECT trid FROM ibf_tracker WHERE topic_id='".$this->topic['tid']."' AND member_id='".$ibforums->member['id']."'");
|
||||
|
||||
@@ -340,13 +377,13 @@ function add_reply($class) {
|
||||
|
||||
if ($return_to_move == 1)
|
||||
{
|
||||
$std->boink_it($class->base_url."&act=Mod&CODE=02&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
$std->boink_it($class->base_url."act=Mod&CODE=02&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
|
||||
$page = $page * $ibforums->vars['display_max_posts'];
|
||||
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
|
||||
$std->boink_it($class->base_url."showtopic={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -366,15 +403,18 @@ function add_reply($class) {
|
||||
// we have a <textarea> tag in the raw post var.
|
||||
//-------------------------------------------------
|
||||
|
||||
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
|
||||
$quote_post = $this->post['post'];
|
||||
|
||||
$raw_post = isset($HTTP_POST_VARS['Post']) ? $std->txt_htmlspecialchars($HTTP_POST_VARS['Post']) : "";
|
||||
|
||||
if (isset($raw_post)) {
|
||||
$raw_post = str_replace( '$' , "$" , htmlspecialchars($raw_post) );
|
||||
$raw_post = stripslashes($raw_post);
|
||||
if (isset($raw_post))
|
||||
{
|
||||
$raw_post = $std->txt_raw2form($raw_post);
|
||||
|
||||
if ($class->dump_quote != "")
|
||||
{
|
||||
$raw_post = str_replace( "<br>", "\n", $class->dump_quote ) . $raw_post;
|
||||
$raw_post = str_replace( "<br>", "\n", $class->dump_quote ) . $raw_post;
|
||||
$quote_post = str_replace( "<br>", "\n", $class->dump_quote ) . $quote_post;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +437,7 @@ function add_reply($class) {
|
||||
|
||||
if ($ibforums->vars['strip_quotes'])
|
||||
{
|
||||
$this->quoted_post['post'] = preg_replace( "#\[QUOTE(=.+?,.+?)?\].+?\[/QUOTE\]#i", "", $this->quoted_post['post'] );
|
||||
$this->quoted_post['post'] = preg_replace( "#\[QUOTE(=.+?,.+?)?\].+?\[/QUOTE\]#is", "", $this->quoted_post['post'] );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@@ -411,7 +451,15 @@ function add_reply($class) {
|
||||
|
||||
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']) ) );
|
||||
$this->post['post'] = $class->parser->post_db_parse(
|
||||
$class->parser->convert( array(
|
||||
'TEXT' => $quote_post,
|
||||
'CODE' => $class->forum['use_ibc'],
|
||||
'SMILIES' => $ibforums->input['enableemo'],
|
||||
'HTML' => $class->forum['use_html']
|
||||
) ) ,
|
||||
$class->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0);
|
||||
$class->output .= $class->html->preview( $this->post['post'] );
|
||||
}
|
||||
|
||||
$class->check_upload_ability();
|
||||
@@ -447,7 +495,7 @@ function add_reply($class) {
|
||||
|
||||
if ($class->obj['can_upload'])
|
||||
{
|
||||
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
|
||||
$upload_field = $class->html->Upload_field( $std->size_format( $ibforums->member['g_attach_max'] * 1024 ) );
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
@@ -460,16 +508,25 @@ function add_reply($class) {
|
||||
$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->output = str_replace("<!--FORUM RULES-->", $std->print_forum_rules($class->forum), $class->output );
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$class->html_add_smilie_box();
|
||||
|
||||
//---------------------------------------
|
||||
// Add in siggy buttons and such
|
||||
//---------------------------------------
|
||||
|
||||
$class->html_checkboxes('reply', $this->topic['tid']);
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$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->nav = array( "<a href='{$class->base_url}act=SC&c={$class->forum[cat_id]}'>{$class->forum['cat_name']}</a>",
|
||||
"<a href='{$class->base_url}showforum={$class->forum['id']}'>{$class->forum['name']}</a>",
|
||||
"<a href='{$class->base_url}showtopic={$this->topic['tid']}'>{$this->topic['title']}</a>",
|
||||
);
|
||||
|
||||
$this->title = $ibforums->lang['quoting_post'].' '.$this->topic['title'];
|
||||
|
||||
@@ -2,15 +2,17 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Board v1.1
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001,2002 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.ibforums.com
|
||||
| Email: phpboards@ibforums.com
|
||||
| Licence Info: phpib-licence@ibforums.com
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Reply post module
|
||||
@@ -67,20 +69,15 @@ class post_functions extends Post {
|
||||
|
||||
if ($this->topic['starter_id'] != $ibforums->member['id'])
|
||||
{
|
||||
if (! $ibforums->member['g_reply_own_topics'])
|
||||
if (! $ibforums->member['g_reply_other_topics'])
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
}
|
||||
|
||||
$this->m_group = $ibforums->member['mgroup'];
|
||||
|
||||
if ($class->forum['reply_perms'] != '*')
|
||||
|
||||
if ( $std->check_perms($class->forum['reply_perms']) == FALSE )
|
||||
{
|
||||
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['reply_perms'] ) )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
|
||||
// Is the topic locked?
|
||||
@@ -178,16 +175,32 @@ class post_functions extends Post {
|
||||
$return_to_move = 1;
|
||||
}
|
||||
}
|
||||
else if ($ibforums->input['mod_options'] == 'pinclose')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or ( $class->moderator['pin_topic'] == 1 AND $class->moderator['close_topic'] == 1 ) )
|
||||
{
|
||||
$this->topic['pinned'] = 1;
|
||||
$this->topic['state'] = 'closed';
|
||||
|
||||
$class->moderate_log('Pinned & closed topic from post form', $this->topic['title']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db_string = $std->compile_db_string( $this->post );
|
||||
$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']) {
|
||||
if ( $class->obj['moderate'] == 1 or $class->obj['moderate'] == 3 )
|
||||
{
|
||||
$DB->query("UPDATE ibf_forums SET has_mod_posts=1 WHERE id=".$class->forum['id']);
|
||||
|
||||
$print->redirect_screen( $ibforums->lang['moderate_post'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}" );
|
||||
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
|
||||
$page = $page * $ibforums->vars['display_max_posts'];
|
||||
|
||||
$print->redirect_screen( $ibforums->lang['moderate_post'], "showtopic={$this->topic['tid']}&st=$page" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@@ -195,7 +208,7 @@ class post_functions extends Post {
|
||||
// board/forum/topic stats
|
||||
//-------------------------------------------------
|
||||
|
||||
$class->forum['last_title'] = $this->topic['title'];
|
||||
$class->forum['last_title'] = str_replace( "'", "'", $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'];
|
||||
@@ -213,9 +226,15 @@ class post_functions extends Post {
|
||||
"WHERE id='" .$class->forum['id'] ."'");
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Get the correct number of replies the topic has
|
||||
//-------------------------------------------------
|
||||
|
||||
$DB->query("SELECT COUNT(pid) as posts FROM ibf_posts WHERE topic_id={$this->topic['tid']} and queued != 1");
|
||||
|
||||
// Update the database
|
||||
$posts = $DB->fetch_row();
|
||||
|
||||
$pcount = intval( $posts['posts'] - 1 );
|
||||
|
||||
//+------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -224,7 +243,7 @@ class post_functions extends Post {
|
||||
"last_post='" .$class->forum['last_post'] ."', ".
|
||||
"pinned='" .$this->topic['pinned'] ."', ".
|
||||
"state='" .$this->topic['state'] ."', ".
|
||||
"posts=posts+1 ".
|
||||
"posts=$pcount ".
|
||||
"WHERE tid='" .$this->topic['tid'] ."'");
|
||||
|
||||
//+------------------------------------------------------------------------------------------------------
|
||||
@@ -258,6 +277,12 @@ class post_functions extends Post {
|
||||
if ( $ibforums->member['posts'] + 1 >= $gposts )
|
||||
{
|
||||
$mgroup = "mgroup='$gid', ";
|
||||
|
||||
if ( USE_MODULES == 1 )
|
||||
{
|
||||
$class->modules->register_class(&$class);
|
||||
$class->modules->on_group_change($ibforums->member['id'], $gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,7 +298,7 @@ class post_functions extends Post {
|
||||
// Are we tracking topics we reply in 'auto_track'?
|
||||
//-------------------------------------------------
|
||||
|
||||
if ($ibforums->member['auto_track'] == 1)
|
||||
if ( $ibforums->member['id'] AND $ibforums->input['enabletrack'] == 1 )
|
||||
{
|
||||
$DB->query("SELECT trid FROM ibf_tracker WHERE topic_id='".$this->topic['tid']."' AND member_id='".$ibforums->member['id']."'");
|
||||
|
||||
@@ -303,13 +328,13 @@ class post_functions extends Post {
|
||||
|
||||
if ($return_to_move == 1)
|
||||
{
|
||||
$std->boink_it($class->base_url."&act=Mod&CODE=02&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
$std->boink_it($class->base_url."act=Mod&CODE=02&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
|
||||
$page = $page * $ibforums->vars['display_max_posts'];
|
||||
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
|
||||
$std->boink_it($class->base_url."showtopic={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -326,21 +351,31 @@ class post_functions extends Post {
|
||||
// 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'] : "";
|
||||
$raw_post = isset($HTTP_POST_VARS['Post']) ? $std->txt_htmlspecialchars($HTTP_POST_VARS['Post']) : "";
|
||||
|
||||
if (isset($raw_post)) {
|
||||
$raw_post = str_replace( '$' , "$" , htmlspecialchars($raw_post) );
|
||||
$raw_post = stripslashes($raw_post);
|
||||
if (isset($raw_post))
|
||||
{
|
||||
$raw_post = $std->txt_raw2form($raw_post);
|
||||
}
|
||||
|
||||
// Do we have any posting errors?
|
||||
|
||||
if ($class->obj['post_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']) ) );
|
||||
if ($class->obj['preview_post'])
|
||||
{
|
||||
$this->post['post'] = $class->parser->post_db_parse(
|
||||
$class->parser->convert( array(
|
||||
'TEXT' => $this->post['post'],
|
||||
'CODE' => $class->forum['use_ibc'],
|
||||
'SMILIES' => $ibforums->input['enableemo'],
|
||||
'HTML' => $class->forum['use_html']
|
||||
) ) ,
|
||||
$class->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0);
|
||||
$class->output .= $class->html->preview( $this->post['post'] );
|
||||
}
|
||||
|
||||
$class->check_upload_ability();
|
||||
@@ -371,7 +406,7 @@ class post_functions extends Post {
|
||||
|
||||
if ($class->obj['can_upload'])
|
||||
{
|
||||
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
|
||||
$upload_field = $class->html->Upload_field( $std->size_format( $ibforums->member['g_attach_max'] * 1024 ) );
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
@@ -383,16 +418,25 @@ class post_functions extends Post {
|
||||
$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 = str_replace("<!--FORUM RULES-->", $std->print_forum_rules($class->forum), $class->output );
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$class->html_add_smilie_box();
|
||||
|
||||
//---------------------------------------
|
||||
// Add in siggy buttons and such
|
||||
//---------------------------------------
|
||||
|
||||
$class->html_checkboxes('reply', $this->topic['tid']);
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$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->nav = array( "<a href='{$class->base_url}act=SC&c={$class->forum[cat_id]}'>{$class->forum['cat_name']}</a>",
|
||||
"<a href='{$class->base_url}showforum={$class->forum['id']}'>{$class->forum['name']}</a>",
|
||||
"<a href='{$class->base_url}showtopic={$this->topic['tid']}'>{$this->topic['title']}</a>",
|
||||
);
|
||||
|
||||
$this->title = $ibforums->lang['replying_in'].' '.$this->topic['title'];
|
||||
|
||||
@@ -0,0 +1,648 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > MySQL FULL TEXT Search Library
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 31st March 2003
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
class search_lib extends Search
|
||||
{
|
||||
|
||||
var $parser = "";
|
||||
var $is = "";
|
||||
|
||||
//--------------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------
|
||||
|
||||
function search_lib($that)
|
||||
{
|
||||
global $ibforums, $DB, $std, $print;
|
||||
|
||||
$this->is = &$that; // hahaha!
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// Simple search
|
||||
//--------------------------------------------
|
||||
|
||||
|
||||
function do_simple_search()
|
||||
{
|
||||
global $ibforums, $DB, $std, $HTTP_POST_VARS, $print;
|
||||
|
||||
if ( ! $ibforums->input['sid'] )
|
||||
{
|
||||
$boolean = "";
|
||||
|
||||
//--------------------------------------------
|
||||
// NEW SEARCH.. Check Keywords..
|
||||
//--------------------------------------------
|
||||
|
||||
if ( $this->is->mysql_version >= 40010 )
|
||||
{
|
||||
$boolean = 'IN BOOLEAN MODE';
|
||||
$keywords = $this->is->filter_ftext_keywords($ibforums->input['keywords']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$keywords = $this->is->filter_keywords($ibforums->input['keywords']);
|
||||
}
|
||||
|
||||
$check_keywords = trim($keywords);
|
||||
|
||||
if ( (! $check_keywords) or ($check_keywords == "") or (! isset($check_keywords) ) )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_words') );
|
||||
}
|
||||
|
||||
if (strlen(trim($keywords)) < 4)
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => 4) );
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
// Get forums...
|
||||
//--------------------------------------------
|
||||
|
||||
$forums = $this->is->get_searchable_forums();
|
||||
|
||||
if ($forums == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
// How many results?
|
||||
//--------------------------------------------
|
||||
|
||||
$DB->query("SELECT COUNT(*) as dracula FROM ibf_posts p WHERE p.forum_id IN ($forums) AND MATCH(post) AGAINST ('$check_keywords' $boolean)");
|
||||
|
||||
$count = $DB->fetch_row();
|
||||
|
||||
if ( $count['dracula'] < 1 ) // Tee-hee!
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
// Store it daddy-o!
|
||||
//--------------------------------------------
|
||||
|
||||
$cache = "SELECT MATCH(post) AGAINST ('$check_keywords' $boolean) as score, t.tid, t.title, t.posts, t.views,
|
||||
f.category, f.id, f.name, p.post, p.author_id, p.author_name, p.post_date, p.pid
|
||||
FROM ibf_posts p
|
||||
LEFT JOIN ibf_forums f ON (p.forum_id=f.id)
|
||||
LEFT JOIN ibf_topics t on (p.topic_id=t.tid)
|
||||
WHERE p.forum_id IN ($forums) AND t.title IS NOT NULL
|
||||
AND MATCH(post) AGAINST ('$check_keywords' $boolean)";
|
||||
|
||||
if ( $ibforums->input['sortby'] != "relevant" )
|
||||
{
|
||||
$cache .= " ORDER BY p.post_date DESC";
|
||||
}
|
||||
|
||||
$unique_id = md5(uniqid(microtime(),1));
|
||||
|
||||
$str = $DB->compile_db_insert_string( array (
|
||||
'id' => $unique_id,
|
||||
'search_date'=> time(),
|
||||
'topic_id' => '00',
|
||||
'topic_max' => $count['dracula'],
|
||||
'member_id' => $ibforums->member['id'],
|
||||
'ip_address' => $ibforums->input['IP_ADDRESS'],
|
||||
'post_id' => '00',
|
||||
'query_cache'=> $cache,
|
||||
|
||||
) );
|
||||
|
||||
$DB->query("INSERT INTO ibf_search_results ({$str['FIELD_NAMES']}) VALUES ({$str['FIELD_VALUES']})");
|
||||
|
||||
$print->redirect_screen( $ibforums->lang['search_redirect'] , "act=Search&CODE=simpleresults&sid=$unique_id&highlite=".urlencode(trim(str_replace( '&', '&', $ibforums->input['keywords']))) );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//--------------------------------------------
|
||||
// Get SQL schtuff
|
||||
//--------------------------------------------
|
||||
|
||||
$this->unique_id = $ibforums->input['sid'];
|
||||
|
||||
if ($this->unique_id == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
}
|
||||
|
||||
$DB->query("SELECT * FROM ibf_search_results WHERE id='{$this->unique_id}'");
|
||||
|
||||
if ( ! $sr = $DB->fetch_row() )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
}
|
||||
|
||||
$query = stripslashes($sr['query_cache']);
|
||||
|
||||
$check_keywords = preg_replace( '/&(lt|gt|quot);/', "&\\1;", trim(urldecode($ibforums->input['highlite'])) );
|
||||
|
||||
//--------------------------------------------
|
||||
// Display
|
||||
//--------------------------------------------
|
||||
|
||||
$this->links = $std->build_pagelinks(
|
||||
array(
|
||||
'TOTAL_POSS' => $sr['topic_max'],
|
||||
'leave_out' => 10,
|
||||
'PER_PAGE' => 25,
|
||||
'CUR_ST_VAL' => $this->is->first,
|
||||
'L_SINGLE' => $ibforums->lang['sp_single'],
|
||||
'L_MULTI' => "",
|
||||
'BASE_URL' => $ibforums->base_url."&act=Search&CODE=simpleresults&sid=".$this->unique_id."&highlite=".urlencode($check_keywords),
|
||||
)
|
||||
);
|
||||
|
||||
require "./sources/lib/post_parser.php";
|
||||
$this->parser = new post_parser();
|
||||
|
||||
//--------------------------------------------
|
||||
// Get categories
|
||||
//--------------------------------------------
|
||||
|
||||
$DB->query("SELECT id, name FROM ibf_categories");
|
||||
|
||||
while ( $cat = $DB->fetch_row() )
|
||||
{
|
||||
$cat_array[ $cat['id'] ] = $cat['name'];
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// oh look, a query!
|
||||
//--------------------------------------------
|
||||
|
||||
$last_tid = 0;
|
||||
|
||||
$SQLtime = new Debug();
|
||||
|
||||
$SQLtime->startTimer();
|
||||
|
||||
$DB->query($query." LIMIT {$this->is->first},25");
|
||||
|
||||
$ex_time = sprintf( "%.4f",$SQLtime->endTimer() );
|
||||
|
||||
$show_end = 25;
|
||||
|
||||
if ( $sr['topic_max'] < 25 )
|
||||
{
|
||||
$show_end = $sr['topic_max'];
|
||||
}
|
||||
|
||||
$this->output .= $this->is->html->result_simple_header(array(
|
||||
'links' => $this->links,
|
||||
'start' => $this->is->first,
|
||||
'end' => $show_end + $this->is->first,
|
||||
'matches' => $sr['topic_max'],
|
||||
'ex_time' => $ex_time,
|
||||
'keyword' => $check_keywords,
|
||||
) );
|
||||
|
||||
while ( $row = $DB->fetch_row() )
|
||||
{
|
||||
//---------------------------------------------------------------------
|
||||
// Listen up, this is relevant.
|
||||
// MySQL's relevance is a bit of a mystery. It's
|
||||
// based on many hazy variables such as placing, occurance
|
||||
// and such. The result is a floating point number, like 1.239848556
|
||||
// No one can really disect what this means in human terms, so I'm
|
||||
// going to simply assume that anything over 1.0 is 100%, and *100 any
|
||||
// other relevance result.
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
$row['relevance'] = sprintf( "%3d", ( $row['score'] > 1.0 ) ? 100 : $row['score'] * 100 );
|
||||
|
||||
//-----------------------------------------
|
||||
// Fix up da post
|
||||
//-----------------------------------------
|
||||
|
||||
$row['post'] = $this->parser->unconvert($row['post']);
|
||||
|
||||
// Strip out BB tags
|
||||
|
||||
$row['post'] = preg_replace( "#\[.+?/?\]#", "", $row['post'] );
|
||||
|
||||
// Try and locate keyword in the post...
|
||||
|
||||
$start = 0;
|
||||
$end = 250;
|
||||
$tmp_post = strtolower($row['post']);
|
||||
$tmp_words = explode(" ", trim(strtolower($check_keywords)) );
|
||||
|
||||
if ( $st = strpos( $tmp_post, $tmp_words[0] ) )
|
||||
{
|
||||
$start = $st - 100;
|
||||
$start = $start < 0 ? 0 : $start;
|
||||
$end += $start;
|
||||
}
|
||||
|
||||
$row['post'] = substr( $row['post'], $start, $end );
|
||||
|
||||
|
||||
// Finish tidy up..
|
||||
|
||||
if ( $start > 0 )
|
||||
{
|
||||
// We're cutting at the start, so..
|
||||
// If it's not a capital letter, it's probably
|
||||
// cut a word in half / it's a lower case word so it doesnt matter
|
||||
|
||||
if ( ! preg_match( "/^[A-Z]/", $row['post'] ) )
|
||||
{
|
||||
// find the first space..
|
||||
|
||||
if ( $new_start = strpos( $row['post'], " " ) )
|
||||
{
|
||||
// Cut to space..
|
||||
|
||||
$row['post'] = substr( $row['post'], $new_start );
|
||||
|
||||
$row['post'] = '...'.$row['post'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tidy up the end..
|
||||
// Find the last space..
|
||||
|
||||
if ( strlen( $row['post'] ) > 250 )
|
||||
{
|
||||
if ( $new_end = strrpos( $row['post'], " " ) )
|
||||
{
|
||||
$row['post'] = substr( $row['post'], 0, $new_end );
|
||||
|
||||
$row['post'] .= '...';
|
||||
}
|
||||
}
|
||||
|
||||
// Basic highlighting
|
||||
|
||||
$row['post'] = preg_replace( "/".preg_quote($tmp_words[0], '/')."/i", "<strong>".$tmp_words[0]."</strong>", $row['post'] );
|
||||
|
||||
$row['css_class'] = 'googleroot';
|
||||
|
||||
if ( $row['tid'] == $last_tid )
|
||||
{
|
||||
$row['css_class'] = 'googlechild';
|
||||
}
|
||||
|
||||
$last_tid = $row['tid'];
|
||||
|
||||
$row['cat_id'] = $row['category'];
|
||||
$row['cat_name'] = $cat_array[ $row['category'] ];
|
||||
|
||||
$row['post_date'] = $std->get_date( $row['post_date'], 'LONG' );
|
||||
|
||||
// Link member's name
|
||||
|
||||
if ($row['author_id'])
|
||||
{
|
||||
$row['author_name'] = "<a href='{$ibforums->base_url}act=Profile&MID={$row['author_id']}'>{$row['author_name']}</a>";
|
||||
}
|
||||
|
||||
$this->output .= $this->is->html->result_simple_entry($row);
|
||||
}
|
||||
|
||||
$this->output .= $this->is->html->result_simple_footer(array(
|
||||
'links' => $this->links,
|
||||
) );
|
||||
|
||||
$print->add_output("$this->output");
|
||||
$print->do_output( array( 'TITLE' => $ibforums->lang['g_simple_title'], 'JS' => 0, NAV => array( $ibforums->lang['g_simple_title'] ) ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// Main Board Search-e-me-doo-daa
|
||||
//--------------------------------------------
|
||||
|
||||
|
||||
function do_main_search()
|
||||
{
|
||||
global $ibforums, $DB, $std, $HTTP_POST_VARS, $print;
|
||||
|
||||
//------------------------------------
|
||||
// Do we have any input?
|
||||
//------------------------------------
|
||||
|
||||
//------------------------------------
|
||||
// USING FULL TEXT - Wooohoo!!
|
||||
//------------------------------------
|
||||
|
||||
|
||||
if ($ibforums->input['namesearch'] != "")
|
||||
{
|
||||
$name_filter = $this->is->filter_keywords($ibforums->input['namesearch'], 1);
|
||||
}
|
||||
|
||||
if ($ibforums->input['useridsearch'] != "")
|
||||
{
|
||||
$keywords = $this->is->filter_keywords($ibforums->input['useridsearch']);
|
||||
$this->is->search_type = 'userid';
|
||||
}
|
||||
else
|
||||
{
|
||||
$keywords = $this->is->filter_keywords($ibforums->input['keywords']);
|
||||
$this->is->search_type = 'posts';
|
||||
}
|
||||
|
||||
if ( $name_filter != "" AND $ibforums->input['keywords'] != "" )
|
||||
{
|
||||
$type = 'joined';
|
||||
}
|
||||
else if ( $name_filter == "" AND $ibforums->input['keywords'] != "" )
|
||||
{
|
||||
$type= 'postonly';
|
||||
}
|
||||
else if ( $name_filter != "" AND $ibforums->input['keywords'] == "" )
|
||||
{
|
||||
$type='nameonly';
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
if ( $this->is->mysql_version >= 40010 )
|
||||
{
|
||||
$boolean = 'IN BOOLEAN MODE';
|
||||
$keywords = $this->is->filter_ftext_keywords($ibforums->input['keywords']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$keywords = $this->is->filter_keywords($ibforums->input['keywords']);
|
||||
}
|
||||
|
||||
$check_keywords = trim($keywords);
|
||||
|
||||
if ( (! $check_keywords) or ($check_keywords == "") or (! isset($check_keywords) ) )
|
||||
{
|
||||
if ($ibforums->input['namesearch'] == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_words') );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen(trim($keywords)) < 4)
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => 4) );
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
if ($ibforums->input['search_in'] == 'titles')
|
||||
{
|
||||
$this->is->search_in = 'titles';
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
$forums = $this->is->get_searchable_forums();
|
||||
|
||||
//------------------------------------
|
||||
// Do we have any forums to search in?
|
||||
//------------------------------------
|
||||
|
||||
if ($forums == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
foreach( array( 'last_post', 'posts', 'starter_name', 'forum_id' ) as $v )
|
||||
{
|
||||
if ($ibforums->input['sort_key'] == $v)
|
||||
{
|
||||
$this->is->sort_key = $v;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
foreach ( array( 1, 7, 30, 60, 90, 180, 365, 0 ) as $v )
|
||||
{
|
||||
if ($ibforums->input['prune'] == $v)
|
||||
{
|
||||
$this->is->prune = $v;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
if ($ibforums->input['sort_order'] == 'asc')
|
||||
{
|
||||
$this->is->sort_order = 'asc';
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
if ($ibforums->input['result_type'] == 'posts')
|
||||
{
|
||||
$this->is->result_type = 'posts';
|
||||
}
|
||||
|
||||
if ( $ibforums->vars['min_search_word'] < 1 )
|
||||
{
|
||||
$ibforums->vars['min_search_word'] = 4;
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
// Add on the prune days
|
||||
//------------------------------------
|
||||
|
||||
if ($this->is->prune > 0)
|
||||
{
|
||||
$gt_lt = $ibforums->input['prune_type'] == 'older' ? "<" : ">";
|
||||
$time = time() - ($ibforums->input['prune'] * 86400);
|
||||
|
||||
$topics_datecut = "t.last_post $gt_lt $time AND";
|
||||
$posts_datecut = "p.post_date $gt_lt $time AND";
|
||||
}
|
||||
|
||||
// Is this a membername search?
|
||||
|
||||
$name_filter = trim( $name_filter );
|
||||
$member_string = "";
|
||||
|
||||
if ( $name_filter != "" )
|
||||
{
|
||||
//------------------------------------------------------------------
|
||||
// Get all the possible matches for the supplied name from the DB
|
||||
//------------------------------------------------------------------
|
||||
|
||||
$name_filter = str_replace( '|', "|", $name_filter );
|
||||
|
||||
if ($ibforums->input['exactname'] == 1)
|
||||
{
|
||||
$sql_query = "SELECT id from ibf_members WHERE lower(name)='".$name_filter."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql_query = "SELECT id from ibf_members WHERE name like '%".$name_filter."%'";
|
||||
}
|
||||
|
||||
|
||||
$DB->query( $sql_query );
|
||||
|
||||
|
||||
while ($row = $DB->fetch_row())
|
||||
{
|
||||
$member_string .= "'".$row['id']."',";
|
||||
}
|
||||
|
||||
$member_string = preg_replace( "/,$/", "", $member_string );
|
||||
|
||||
// Error out of we matched no members
|
||||
|
||||
if ($member_string == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_name_search_results') );
|
||||
}
|
||||
|
||||
$posts_name = " AND p.author_id IN ($member_string)";
|
||||
$topics_name = " AND t.starter_id IN ($member_string)";
|
||||
|
||||
}
|
||||
|
||||
if ( $type != 'nameonly' )
|
||||
{
|
||||
if (strlen(trim($keywords)) < $ibforums->vars['min_search_word'])
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => $ibforums->vars['min_search_word']) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$unique_id = md5(uniqid(microtime(),1));
|
||||
|
||||
if ($type != 'nameonly')
|
||||
{
|
||||
$topics_query = "SELECT t.tid
|
||||
FROM ibf_topics t
|
||||
WHERE $topics_datecut t.forum_id IN ($forums)
|
||||
$topics_name AND t.approved=1 AND MATCH(title) AGAINST ('".trim($keywords)."' $boolean)";
|
||||
|
||||
|
||||
$posts_query = "SELECT p.pid ".
|
||||
"FROM ibf_posts p ".
|
||||
"WHERE $posts_datecut p.forum_id IN ($forums)".
|
||||
" AND p.queued <> 1".
|
||||
" $posts_name AND MATCH(post) AGAINST ('".trim($keywords)."' $boolean)";
|
||||
}
|
||||
else
|
||||
{
|
||||
$topics_query = "SELECT t.tid
|
||||
FROM ibf_topics t
|
||||
WHERE $topics_datecut t.forum_id IN ($forums)
|
||||
$topics_name";
|
||||
|
||||
|
||||
$posts_query = "SELECT p.pid ".
|
||||
"FROM ibf_posts p ".
|
||||
"WHERE $posts_datecut p.forum_id IN ($forums)".
|
||||
" AND p.queued <> 1".
|
||||
" $posts_name";
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
// Get the topic ID's to serialize and store into
|
||||
// the database
|
||||
//------------------------------------------------
|
||||
|
||||
$topics = "";
|
||||
$posts = "";
|
||||
|
||||
//------------------------------------
|
||||
|
||||
$DB->query($topics_query);
|
||||
|
||||
$topic_max_hits = $DB->get_num_rows();
|
||||
|
||||
while ($row = $DB->fetch_row() )
|
||||
{
|
||||
$topics .= $row['tid'].",";
|
||||
}
|
||||
|
||||
$DB->free_result();
|
||||
|
||||
//------------------------------------
|
||||
|
||||
$DB->query($posts_query);
|
||||
|
||||
$post_max_hits = $DB->get_num_rows();
|
||||
|
||||
while ($row = $DB->fetch_row() )
|
||||
{
|
||||
$posts .= $row['pid'].",";
|
||||
}
|
||||
|
||||
$DB->free_result();
|
||||
|
||||
//------------------------------------
|
||||
|
||||
$topics = preg_replace( "/,$/", "", $topics );
|
||||
$posts = preg_replace( "/,$/", "", $posts );
|
||||
|
||||
//------------------------------------------------
|
||||
// Do we have any results?
|
||||
//------------------------------------------------
|
||||
|
||||
if ($topics == "" and $posts == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
// If we are still here, return data like a good
|
||||
// boy (or girl). Yes Reg; or girl.
|
||||
// What have the Romans ever done for us?
|
||||
//------------------------------------------------
|
||||
|
||||
return array(
|
||||
'topic_id' => $topics,
|
||||
'post_id' => $posts,
|
||||
'topic_max' => $topic_max_hits,
|
||||
'post_max' => $post_max_hits,
|
||||
'keywords' => $keywords,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > MySQL Manual Search Library
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 31st March 2003
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
class search_lib extends Search
|
||||
{
|
||||
|
||||
var $parser = "";
|
||||
var $is = "";
|
||||
|
||||
//--------------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------
|
||||
|
||||
function search_lib($that)
|
||||
{
|
||||
global $ibforums, $DB, $std, $print;
|
||||
|
||||
$this->is = &$that; // hahaha!
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
// Main Board Search-e-me-doo-daa
|
||||
//--------------------------------------------
|
||||
|
||||
|
||||
function do_main_search()
|
||||
{
|
||||
global $ibforums, $DB, $std, $HTTP_POST_VARS, $print;
|
||||
|
||||
//------------------------------------
|
||||
// Do we have any input?
|
||||
//------------------------------------
|
||||
|
||||
|
||||
if ($ibforums->input['namesearch'] != "")
|
||||
{
|
||||
$name_filter = $this->is->filter_keywords($ibforums->input['namesearch'], 1);
|
||||
}
|
||||
|
||||
if ($ibforums->input['useridsearch'] != "")
|
||||
{
|
||||
$keywords = $this->is->filter_keywords($ibforums->input['useridsearch']);
|
||||
$this->is->search_type = 'userid';
|
||||
}
|
||||
else
|
||||
{
|
||||
$keywords = $this->is->filter_keywords($ibforums->input['keywords']);
|
||||
$this->is->search_type = 'posts';
|
||||
}
|
||||
|
||||
if ( $name_filter != "" AND $ibforums->input['keywords'] != "" )
|
||||
{
|
||||
$type = 'joined';
|
||||
}
|
||||
else if ( $name_filter == "" AND $ibforums->input['keywords'] != "" )
|
||||
{
|
||||
$type= 'postonly';
|
||||
}
|
||||
else if ( $name_filter != "" AND $ibforums->input['keywords'] == "" )
|
||||
{
|
||||
$type='nameonly';
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
$check_keywords = trim($keywords);
|
||||
|
||||
$check_keywords = str_replace( "%", "", $check_keywords );
|
||||
|
||||
if ( (! $check_keywords) or ($check_keywords == "") or (! isset($check_keywords) ) )
|
||||
{
|
||||
if ($type != 'nameonly')
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_words') );
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
if ($ibforums->input['search_in'] == 'titles')
|
||||
{
|
||||
$this->is->search_in = 'titles';
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
$forums = $this->is->get_searchable_forums();
|
||||
|
||||
//------------------------------------
|
||||
// Do we have any forums to search in?
|
||||
//------------------------------------
|
||||
|
||||
if ($forums == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
foreach( array( 'last_post', 'posts', 'starter_name', 'forum_id' ) as $v )
|
||||
{
|
||||
if ($ibforums->input['sort_key'] == $v)
|
||||
{
|
||||
$this->is->sort_key = $v;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
foreach ( array( 1, 7, 30, 60, 90, 180, 365, 0 ) as $v )
|
||||
{
|
||||
if ($ibforums->input['prune'] == $v)
|
||||
{
|
||||
$this->is->prune = $v;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
if ($ibforums->input['sort_order'] == 'asc')
|
||||
{
|
||||
$this->is->sort_order = 'asc';
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
if ($ibforums->input['result_type'] == 'posts')
|
||||
{
|
||||
$this->is->result_type = 'posts';
|
||||
}
|
||||
|
||||
if ( $ibforums->vars['min_search_word'] < 1 )
|
||||
{
|
||||
$ibforums->vars['min_search_word'] = 4;
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
// Add on the prune days
|
||||
//------------------------------------
|
||||
|
||||
if ($this->is->prune > 0)
|
||||
{
|
||||
$gt_lt = $ibforums->input['prune_type'] == 'older' ? "<" : ">";
|
||||
$time = time() - ($ibforums->input['prune'] * 86400);
|
||||
|
||||
$topics_datecut = "t.last_post $gt_lt $time AND";
|
||||
$posts_datecut = "p.post_date $gt_lt $time AND";
|
||||
}
|
||||
|
||||
// Is this a membername search?
|
||||
|
||||
$name_filter = trim( $name_filter );
|
||||
$member_string = "";
|
||||
|
||||
if ( $name_filter != "" )
|
||||
{
|
||||
//------------------------------------------------------------------
|
||||
// Get all the possible matches for the supplied name from the DB
|
||||
//------------------------------------------------------------------
|
||||
|
||||
$name_filter = str_replace( '|', "|", $name_filter );
|
||||
|
||||
if ($ibforums->input['exactname'] == 1)
|
||||
{
|
||||
$sql_query = "SELECT id from ibf_members WHERE lower(name)='".$name_filter."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql_query = "SELECT id from ibf_members WHERE name like '%".$name_filter."%'";
|
||||
}
|
||||
|
||||
|
||||
$DB->query( $sql_query );
|
||||
|
||||
|
||||
while ($row = $DB->fetch_row())
|
||||
{
|
||||
$member_string .= "'".$row['id']."',";
|
||||
}
|
||||
|
||||
$member_string = preg_replace( "/,$/", "", $member_string );
|
||||
|
||||
// Error out of we matched no members
|
||||
|
||||
if ($member_string == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_name_search_results') );
|
||||
}
|
||||
|
||||
$posts_name = " AND p.author_id IN ($member_string)";
|
||||
$topics_name = " AND t.starter_id IN ($member_string)";
|
||||
|
||||
}
|
||||
|
||||
if ( $type != 'nameonly' )
|
||||
{
|
||||
|
||||
if (preg_match( "/ and|or /", $keywords) )
|
||||
{
|
||||
preg_match_all( "/(^|and|or)\s{1,}(\S+?)\s{1,}/", $keywords, $matches );
|
||||
|
||||
$title_like = "(";
|
||||
$post_like = "(";
|
||||
|
||||
for ($i = 0 ; $i < count($matches[0]) ; $i++ )
|
||||
{
|
||||
$boolean = $matches[1][$i];
|
||||
$word = trim($matches[2][$i]);
|
||||
|
||||
if (strlen($word) < $ibforums->vars['min_search_word'])
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => $ibforums->vars['min_search_word']) );
|
||||
}
|
||||
|
||||
if ($boolean)
|
||||
{
|
||||
$boolean = " $boolean";
|
||||
}
|
||||
|
||||
$title_like .= "$boolean LOWER(t.title) LIKE '%$word%' ";
|
||||
$post_like .= "$boolean LOWER(p.post) LIKE '%$word%' ";
|
||||
}
|
||||
|
||||
$title_like .= ")";
|
||||
$post_like .= ")";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (strlen(trim($keywords)) < $ibforums->vars['min_search_word'])
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => $ibforums->vars['min_search_word']) );
|
||||
}
|
||||
|
||||
$title_like = " LOWER(t.title) LIKE '%".trim($keywords)."%' ";
|
||||
$post_like = " LOWER(p.post) LIKE '%".trim($keywords)."%' ";
|
||||
}
|
||||
}
|
||||
|
||||
//$posts_datecut $topics_datecut $post_like $title_like $posts_name $topics_name
|
||||
|
||||
$unique_id = md5(uniqid(microtime(),1));
|
||||
|
||||
if ($type != 'nameonly')
|
||||
{
|
||||
$topics_query = "SELECT t.tid
|
||||
FROM ibf_topics t
|
||||
WHERE $topics_datecut t.forum_id IN ($forums)
|
||||
$topics_name AND t.approved=1 AND ($title_like)";
|
||||
|
||||
|
||||
$posts_query = "SELECT p.pid ".
|
||||
"FROM ibf_posts p ".
|
||||
"WHERE $posts_datecut p.forum_id IN ($forums)".
|
||||
" AND p.queued <> 1".
|
||||
" $posts_name AND ($post_like)";
|
||||
}
|
||||
else
|
||||
{
|
||||
$topics_query = "SELECT t.tid
|
||||
FROM ibf_topics t
|
||||
WHERE $topics_datecut t.forum_id IN ($forums)
|
||||
$topics_name";
|
||||
|
||||
|
||||
$posts_query = "SELECT p.pid ".
|
||||
"FROM ibf_posts p ".
|
||||
"WHERE $posts_datecut p.forum_id IN ($forums)".
|
||||
" AND p.queued <> 1".
|
||||
" $posts_name";
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
// Get the topic ID's to serialize and store into
|
||||
// the database
|
||||
//------------------------------------------------
|
||||
|
||||
$topics = "";
|
||||
$posts = "";
|
||||
|
||||
//------------------------------------
|
||||
|
||||
$DB->query($topics_query);
|
||||
|
||||
$topic_max_hits = $DB->get_num_rows();
|
||||
|
||||
while ($row = $DB->fetch_row() )
|
||||
{
|
||||
$topics .= $row['tid'].",";
|
||||
}
|
||||
|
||||
$DB->free_result();
|
||||
|
||||
//------------------------------------
|
||||
|
||||
$DB->query($posts_query);
|
||||
|
||||
$post_max_hits = $DB->get_num_rows();
|
||||
|
||||
while ($row = $DB->fetch_row() )
|
||||
{
|
||||
$posts .= $row['pid'].",";
|
||||
}
|
||||
|
||||
$DB->free_result();
|
||||
|
||||
//------------------------------------
|
||||
|
||||
$topics = preg_replace( "/,$/", "", $topics );
|
||||
$posts = preg_replace( "/,$/", "", $posts );
|
||||
|
||||
//------------------------------------------------
|
||||
// Do we have any results?
|
||||
//------------------------------------------------
|
||||
|
||||
if ($topics == "" and $posts == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
// If we are still here, return data like a good
|
||||
// boy (or girl). Yes Reg; or girl.
|
||||
// What have the Romans ever done for us?
|
||||
//------------------------------------------------
|
||||
|
||||
return array(
|
||||
'topic_id' => $topics,
|
||||
'post_id' => $posts,
|
||||
'topic_max' => $topic_max_hits,
|
||||
'post_max' => $post_max_hits,
|
||||
'keywords' => $keywords,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -2,15 +2,17 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Board v1.1
|
||||
| Invision Power Board v1.3 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001,2002 Invision Power Services
|
||||
| http://www.ibforums.com
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.ibforums.com
|
||||
| Email: phpboards@ibforums.com
|
||||
| Licence Info: phpib-licence@ibforums.com
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Sun, 04 Jan 2004 00:30:16 GMT
|
||||
| Release: 28e7bfb25f08ac72a789cb1b172fa185
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > GNU Tar creation and extraction module
|
||||
@@ -403,7 +405,7 @@ class tar {
|
||||
}
|
||||
if (! is_dir($file_name))
|
||||
{
|
||||
mkdir( $file_name, 0777);
|
||||
@mkdir( $file_name, 0777);
|
||||
}
|
||||
}
|
||||
else if ($file['typeflag'] == 6)
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user