Version 2.0.0
This commit is contained in:
1 parent
5699abfc0e
commit
0eecc172d9
696 files changed
+120723
-77160
No files matched your search
@@ -2,21 +2,21 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Add POLL module
|
||||
| > Module written by Matt Mecham
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
|
|
||||
@@ -28,10 +28,13 @@
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
|
||||
exit();
|
||||
}
|
||||
|
||||
$idx = new Poll;
|
||||
|
||||
class Poll {
|
||||
class poll {
|
||||
|
||||
|
||||
var $topic = array();
|
||||
@@ -40,8 +43,7 @@ class Poll {
|
||||
var $poll_count = 0;
|
||||
var $poll_choices = "";
|
||||
|
||||
function Poll() {
|
||||
|
||||
function auto_run() {
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_post', $ibforums->lang_id);
|
||||
@@ -65,15 +67,18 @@ class Poll {
|
||||
|
||||
// Make sure we have a valid poll id
|
||||
|
||||
$ibforums->input[t] = $std->is_number($ibforums->input[t]);
|
||||
if (! $ibforums->input[t] ) {
|
||||
$ibforums->input['t'] = intval($ibforums->input['t']);
|
||||
|
||||
if (! $ibforums->input['t'] )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
|
||||
}
|
||||
|
||||
// Load the topic and poll
|
||||
|
||||
$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");
|
||||
|
||||
$DB->cache_add_query( 'poll_get_poll_with_topic', array( 'tid' => $ibforums->input['t'] ) );
|
||||
$DB->cache_exec_query();
|
||||
|
||||
$this->topic = $DB->fetch_row();
|
||||
|
||||
if (! $this->topic['tid'] )
|
||||
@@ -85,9 +90,11 @@ class Poll {
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
|
||||
}
|
||||
|
||||
// Have we voted before?
|
||||
|
||||
$DB->query("SELECT member_id from ibf_voters WHERE tid='".$this->topic['tid']."' and member_id='".$ibforums->member['id']."'");
|
||||
$DB->simple_construct( array( 'select' => 'member_id', 'from' => 'voters', 'where' => "tid={$this->topic['tid']} and member_id=".$ibforums->member['id'] ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
if ( $DB->get_num_rows() )
|
||||
{
|
||||
@@ -96,23 +103,16 @@ class Poll {
|
||||
|
||||
// If we're here, lets add the vote
|
||||
|
||||
|
||||
$db_string = $std->compile_db_string(
|
||||
array (
|
||||
'member_id' => $ibforums->member['id'],
|
||||
'ip_address' => $ibforums->input['IP_ADDRESS'],
|
||||
'tid' => $this->topic['tid'],
|
||||
'forum_id' => $this->topic['forum_id'],
|
||||
'vote_date' => time(),
|
||||
)
|
||||
);
|
||||
$DB->do_insert( 'voters', array( 'member_id' => $ibforums->member['id'],
|
||||
'ip_address' => $ibforums->input['IP_ADDRESS'],
|
||||
'tid' => $this->topic['tid'],
|
||||
'forum_id' => $this->topic['forum_id'],
|
||||
'vote_date' => time(),
|
||||
) );
|
||||
|
||||
$DB->query("INSERT INTO ibf_voters (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
|
||||
|
||||
// If this isn't a null vote...
|
||||
|
||||
if (!$ibforums->input['nullvote'])
|
||||
if ( ! $ibforums->input['nullvote'] )
|
||||
{
|
||||
$poll_answers = unserialize(stripslashes($this->topic['choices']));
|
||||
reset($poll_answers);
|
||||
@@ -133,40 +133,29 @@ class Poll {
|
||||
|
||||
$this->topic['choices'] = addslashes(serialize($new_poll_array));
|
||||
|
||||
$DB->query("UPDATE ibf_polls SET ".
|
||||
"votes=votes+1, ".
|
||||
"choices='" . $this->topic['choices'] . "' ".
|
||||
"WHERE pid='" . $this->topic['poll_id'] . "'");
|
||||
$DB->simple_exec_query( array( 'update' => 'polls',
|
||||
'set' => "votes=votes+1,choices='{$this->topic['choices']}'",
|
||||
'where' => "pid={$this->topic['poll_id']}" ) );
|
||||
|
||||
|
||||
if ($this->topic['allow_pollbump'])
|
||||
{
|
||||
|
||||
$this->topic['last_vote'] = time();
|
||||
$this->topic['last_post'] = time();
|
||||
|
||||
$DB->query("UPDATE ibf_topics SET ".
|
||||
"last_vote='" . $this->topic['last_vote'] . "', ".
|
||||
"last_post='" . $this->topic['last_post'] . "' ".
|
||||
"WHERE tid='" . $this->topic['tid'] . "'");
|
||||
|
||||
|
||||
$DB->do_update( 'topics', array( 'last_vote' => $this->topic['last_vote'], 'last_post' => $this->topic['last_post'] ), 'tid='.$this->topic['tid'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->topic['last_vote'] = time();
|
||||
|
||||
$DB->query("UPDATE ibf_topics SET ".
|
||||
"last_vote='" . $this->topic['last_vote'] . "', ".
|
||||
"last_post='" . $this->topic['last_post'] . "' ".
|
||||
"WHERE tid='" . $this->topic['tid'] . "'");
|
||||
|
||||
$DB->do_update( 'topics', array( 'last_vote' => $this->topic['last_vote'], 'last_post' => $this->topic['last_post'] ), 'tid='.$this->topic['tid'] );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$lang = $ibforums->input['nullvote'] ? $ibforums->lang['poll_viewing_results'] : $ibforums->lang['poll_vote_added'];
|
||||
|
||||
$print->redirect_screen( $lang , "act=ST&f={$this->topic['forum_id']}&t={$this->topic['tid']}" );
|
||||
$print->redirect_screen( $lang , "act=ST&f={$this->topic['forum_id']}&t={$this->topic['tid']}&st={$ibforums->input['st']}" );
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,506 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Board index functions module
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 18th November 2003
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
class boardstats_functions
|
||||
{
|
||||
|
||||
var $class = "";
|
||||
var $sep_char = "";
|
||||
|
||||
var $users_online = "";
|
||||
var $total_posts = "";
|
||||
var $total_members = "";
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// register_class
|
||||
// ------------------
|
||||
// Register a $this-> class with this module
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function register_class(&$class)
|
||||
{
|
||||
$this->class = $class;
|
||||
|
||||
$this->sep_char = '<{ACTIVE_LIST_SEP}>';
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// DISPLAY ACTIVE USERS
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function active_users()
|
||||
{
|
||||
global $DB, $std, $ibforums;
|
||||
|
||||
$active = array( 'TOTAL' => 0 ,
|
||||
'NAMES' => "",
|
||||
'GUESTS' => 0 ,
|
||||
'MEMBERS' => 0 ,
|
||||
'ANON' => 0 ,
|
||||
);
|
||||
|
||||
$stats_html = "";
|
||||
|
||||
if ($ibforums->vars['show_active'])
|
||||
{
|
||||
if ($ibforums->vars['au_cutoff'] == "")
|
||||
{
|
||||
$ibforums->vars['au_cutoff'] = 15;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get the users from the DB
|
||||
//-----------------------------------------
|
||||
|
||||
$cut_off = $ibforums->vars['au_cutoff'] * 60;
|
||||
$time = time() - $cut_off;
|
||||
$qe = "";
|
||||
$rows = array( 0 => array( 'login_type' => substr($ibforums->member['login_anonymous'],0, 1),
|
||||
'running_time' => time(),
|
||||
'member_id' => $ibforums->member['id'],
|
||||
'member_name' => $ibforums->member['name'],
|
||||
'member_group' => $ibforums->member['mgroup'] ) );
|
||||
|
||||
if ( $ibforums->member['id'] )
|
||||
{
|
||||
$qe = "member_id !=".intval($ibforums->member['id'])." AND ";
|
||||
}
|
||||
|
||||
$DB->simple_construct( array( 'select' => 'id, member_id, member_name, login_type, running_time, member_group',
|
||||
'from' => 'sessions',
|
||||
'where' => $qe." running_time > $time",
|
||||
'order' => "running_time DESC"
|
||||
) );
|
||||
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
//-----------------------------------------
|
||||
// FETCH...
|
||||
//-----------------------------------------
|
||||
|
||||
while ($r = $DB->fetch_row() )
|
||||
{
|
||||
$rows[] = $r;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// cache all printed members so we
|
||||
// don't double print them
|
||||
//-----------------------------------------
|
||||
|
||||
$cached = array();
|
||||
|
||||
foreach ( $rows as $result )
|
||||
{
|
||||
$last_date = $std->get_time( $result['running_time'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// Bot?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( strstr( $result['id'], '_session' ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Seen bot of this type yet?
|
||||
//-----------------------------------------
|
||||
|
||||
$botname = preg_replace( '/^(.+?)=/', "\\1", $result['id'] );
|
||||
|
||||
if ( ! $cached[ $result['member_name'] ] )
|
||||
{
|
||||
if ( $ibforums->vars['spider_anon'] )
|
||||
{
|
||||
if ( $ibforums->member['mgroup'] == $ibforums->vars['admin_group'] )
|
||||
{
|
||||
$active['NAMES'] .= "{$result['member_name']}*{$this->sep_char} \n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$active['NAMES'] .= "{$result['member_name']}{$this->sep_char} \n";
|
||||
}
|
||||
|
||||
$cached[ $result['member_name'] ] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Yup, count others as guest
|
||||
//-----------------------------------------
|
||||
|
||||
$active['GUESTS']++;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Guest?
|
||||
//-----------------------------------------
|
||||
|
||||
else if ($result['member_id'] == 0 )
|
||||
{
|
||||
$active['GUESTS']++;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Member?
|
||||
//-----------------------------------------
|
||||
|
||||
else
|
||||
{
|
||||
if ( empty( $cached[ $result['member_id'] ] ) )
|
||||
{
|
||||
$cached[ $result['member_id'] ] = 1;
|
||||
|
||||
$result['prefix'] = $ibforums->cache['group_cache'][ $result['member_group'] ]['prefix'];
|
||||
$result['suffix'] = $ibforums->cache['group_cache'][ $result['member_group'] ]['suffix'];
|
||||
|
||||
if ($result['login_type'])
|
||||
{
|
||||
if ( ($ibforums->member['mgroup'] == $ibforums->vars['admin_group']) and ($ibforums->vars['disable_admin_anon'] != 1) )
|
||||
{
|
||||
$active['NAMES'] .= "<a href='{$ibforums->base_url}showuser={$result['member_id']}' title='$last_date'>{$result['prefix']}{$result['member_name']}{$result['suffix']}</a>*{$this->sep_char} \n";
|
||||
$active['ANON']++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$active['ANON']++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$active['MEMBERS']++;
|
||||
$active['NAMES'] .= "<a href='{$ibforums->base_url}showuser={$result['member_id']}' title='$last_date'>{$result['prefix']}{$result['member_name']}{$result['suffix']}</a>{$this->sep_char} \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$active['NAMES'] = preg_replace( "/".preg_quote($this->sep_char)."$/", "", trim($active['NAMES']) );
|
||||
|
||||
$active['TOTAL'] = $active['MEMBERS'] + $active['GUESTS'] + $active['ANON'];
|
||||
|
||||
$this->users_online = $active['TOTAL'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Show a link?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['allow_online_list'])
|
||||
{
|
||||
$active['links'] = $this->class->html->active_user_links();
|
||||
}
|
||||
|
||||
$ibforums->lang['active_users'] = sprintf( $ibforums->lang['active_users'], $ibforums->vars['au_cutoff'] );
|
||||
|
||||
return $this->class->html->ActiveUsers($active, $ibforums->vars['au_cutoff']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// SHOW CALENDAR EVENTS
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function show_calendar_events()
|
||||
{
|
||||
global $DB, $ibforums, $std;
|
||||
|
||||
if ($ibforums->vars['show_birthdays'])
|
||||
{
|
||||
$a = explode( ',', gmdate( 'Y,n,j,G,i,s', time() + $std->get_time_offset() ) );
|
||||
|
||||
$day = $a[2];
|
||||
$month = $a[1];
|
||||
$year = $a[0];
|
||||
|
||||
$birthstring = "";
|
||||
$count = 0;
|
||||
$users = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Not caching?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $ibforums->vars['cache_calendar'] )
|
||||
{
|
||||
$DB->simple_construct( array( 'select' => 'id, name, bday_day, bday_month, bday_year', 'from' => 'members', 'where' => "bday_day=$day and bday_month=$month" ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
while( $r = $DB->fetch_row() )
|
||||
{
|
||||
$users[] = $r;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Or caching...
|
||||
//-----------------------------------------
|
||||
|
||||
else
|
||||
{
|
||||
if ( count( $ibforums->cache['birthdays'] ) )
|
||||
{
|
||||
foreach( $ibforums->cache['birthdays'] as $id => $u )
|
||||
{
|
||||
if ( $u['bday_day'] == $day and $u['bday_month'] == $month )
|
||||
{
|
||||
$users[] = $u;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Spin and print...
|
||||
//-----------------------------------------
|
||||
|
||||
foreach ( $users as $id => $user )
|
||||
{
|
||||
$birthstring .= "<a href='{$ibforums->base_url}showuser={$user['id']}'>{$user['name']}</a>";
|
||||
|
||||
if ($user['bday_year'])
|
||||
{
|
||||
$pyear = $year - $user['bday_year'];
|
||||
$birthstring .= "(<b>$pyear</b>)";
|
||||
}
|
||||
|
||||
$birthstring .= $this->sep_char."\n";
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Fix up string...
|
||||
//-----------------------------------------
|
||||
|
||||
$birthstring = preg_replace( "/".$this->sep_char."$/", "", trim($birthstring) );
|
||||
|
||||
$lang = $ibforums->lang['no_birth_users'];
|
||||
|
||||
if ($count > 0)
|
||||
{
|
||||
$lang = ($count > 1) ? $ibforums->lang['birth_users'] : $ibforums->lang['birth_user'];
|
||||
$stats_html .= $this->class->html->birthdays( $birthstring, $count, $lang );
|
||||
}
|
||||
else
|
||||
{
|
||||
$count = "";
|
||||
|
||||
if ( ! $ibforums->vars['autohide_bday'] )
|
||||
{
|
||||
$stats_html .= $this->class->html->birthdays( $birthstring, $count, $lang );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we viewing the calendar?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['show_calendar'])
|
||||
{
|
||||
|
||||
if ($ibforums->vars['calendar_limit'] < 2)
|
||||
{
|
||||
$ibforums->vars['calendar_limit'] = 2;
|
||||
}
|
||||
|
||||
$our_unix = mktime( 0, 0, 1, $month, $day, $year);
|
||||
$max_date = $our_unix + ($ibforums->vars['calendar_limit'] * 86400);
|
||||
$events = array();
|
||||
$show_events = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Not caching?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $ibforums->vars['cache_calendar'] )
|
||||
{
|
||||
$DB->simple_construct( array( 'select' => 'eventid, title, read_perms, priv_event, userid, unix_stamp',
|
||||
'from' => 'calendar_events',
|
||||
'where' => "unix_stamp > $our_unix and unix_stamp < $max_date",
|
||||
'order' => 'unix_stamp'
|
||||
) );
|
||||
$DB->simple_exec();
|
||||
|
||||
while( $r = $DB->fetch_row() )
|
||||
{
|
||||
$events[] = $r;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Or caching...
|
||||
//-----------------------------------------
|
||||
|
||||
else
|
||||
{
|
||||
if ( count( $ibforums->cache['calendar'] ) )
|
||||
{
|
||||
foreach( $ibforums->cache['calendar'] as $id => $u )
|
||||
{
|
||||
if ( $u['unix_stamp'] >= $our_unix and $u['unix_stamp'] <= $max_date )
|
||||
{
|
||||
$events[] = $u;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Print...
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $events as $e => $event )
|
||||
{
|
||||
if ($event['priv_event'] == 1 and $ibforums->member['id'] != $event['userid'])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have permission to see the event?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $event['read_perms'] != '*' )
|
||||
{
|
||||
if ( ! preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $event['read_perms'] ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$c_time = date( 'j-F-y', $event['unix_stamp']);
|
||||
|
||||
$show_events[] = "<a href='{$ibforums->base_url}act=calendar&code=showevent&eventid={$event['eventid']}' title='$c_time'>".$event['title']."</a>";
|
||||
}
|
||||
|
||||
$ibforums->lang['calender_f_title'] = sprintf( $ibforums->lang['calender_f_title'], $ibforums->vars['calendar_limit'] );
|
||||
|
||||
if ( count($show_events) > 0 )
|
||||
{
|
||||
$event_string = implode( $this->sep_char.' ', $show_events );
|
||||
$stats_html .= $this->class->html->calendar_events( $event_string );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! $ibforums->vars['autohide_calendar'] )
|
||||
{
|
||||
$event_string = $ibforums->lang['no_calendar_events'];
|
||||
$stats_html .= $this->class->html->calendar_events( $event_string );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $stats_html;
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// SHOW TOTALS
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function show_totals()
|
||||
{
|
||||
global $DB, $ibforums, $std;
|
||||
|
||||
if ($ibforums->vars['show_totals'])
|
||||
{
|
||||
if ( ! is_array( $ibforums->cache['stats'] ) )
|
||||
{
|
||||
$ibforums->cache['stats'] = array();
|
||||
|
||||
$DB->simple_exec_query( array( 'delete' => 'cache_store', 'where' => "cs_key='stats'" ) );
|
||||
$DB->do_insert( 'cache_store', array( 'cs_array' => 1, 'cs_key' => 'stats', 'cs_value' => addslashes(serialize($ibforums->cache['stats'])) ) );
|
||||
}
|
||||
|
||||
$stats = $ibforums->cache['stats'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Update the most active count if needed
|
||||
//-----------------------------------------
|
||||
|
||||
if ($this->users_online > $stats['most_count'])
|
||||
{
|
||||
$stats['most_count'] = $this->users_online;
|
||||
$stats['most_date'] = time();
|
||||
|
||||
$DB->do_update( 'cache_store',
|
||||
array( 'cs_array' => 1, 'cs_value' => addslashes(serialize($stats)) ),
|
||||
"cs_key='stats'"
|
||||
);
|
||||
}
|
||||
|
||||
$most_time = $std->get_date( $stats['most_date'], 'LONG' );
|
||||
|
||||
$ibforums->lang['most_online'] = str_replace( "<#NUM#>" , $std->do_number_format($stats['most_count']) , $ibforums->lang['most_online'] );
|
||||
$ibforums->lang['most_online'] = str_replace( "<#DATE#>", $most_time , $ibforums->lang['most_online'] );
|
||||
|
||||
$total_posts = $stats['total_replies'] + $stats['total_topics'];
|
||||
|
||||
$total_posts = $std->do_number_format($total_posts);
|
||||
$stats['mem_count'] = $std->do_number_format($stats['mem_count']);
|
||||
|
||||
$this->total_posts = $total_posts;
|
||||
$this->total_members = $stats['mem_count'];
|
||||
|
||||
$link = $ibforums->base_url."showuser=".$stats['last_mem_id'];
|
||||
|
||||
$ibforums->lang['total_word_string'] = str_replace( "<#posts#>" , "$total_posts" , $ibforums->lang['total_word_string'] );
|
||||
$ibforums->lang['total_word_string'] = str_replace( "<#reg#>" , $stats['mem_count'] , $ibforums->lang['total_word_string'] );
|
||||
$ibforums->lang['total_word_string'] = str_replace( "<#mem#>" , $stats['last_mem_name'] , $ibforums->lang['total_word_string'] );
|
||||
$ibforums->lang['total_word_string'] = str_replace( "<#link#>" , $link , $ibforums->lang['total_word_string'] );
|
||||
|
||||
$stats_html .= $this->class->html->ShowStats($ibforums->lang['total_word_string']);
|
||||
|
||||
}
|
||||
|
||||
return $stats_html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| 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['chat04_whodat_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['chat04_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['chat04_who_save'] * 60 ) )
|
||||
//if ( 1 == 1)
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get service library
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( ROOT_PATH.'retail/chatservice.php' );
|
||||
|
||||
$server_url = 'http://'.$CHAT_SERVER[ $ibforums->vars['chat04_servicetype'] ].'/'.$CHAT_ONLINELIST[ $ibforums->vars['chat04_servicetype'] ].$ibforums->vars['chat04_account_no'];
|
||||
|
||||
if ( $data = @file( $server_url ) )
|
||||
{
|
||||
if ( count($data) > 0 )
|
||||
{
|
||||
$hits_left = intval( array_shift($data) );
|
||||
}
|
||||
|
||||
$data = implode( "", $data );
|
||||
$data = str_replace( "<html>" , "", $data );
|
||||
$data = str_replace( "</html>", "", $data );
|
||||
|
||||
$data = preg_replace( "#^.+?:\s#i", "", strtolower($data) );
|
||||
$tmp = explode( " ", $data );
|
||||
$na = array();
|
||||
|
||||
if ( is_array( $tmp ) and count ($tmp) )
|
||||
{
|
||||
foreach( $tmp as $n )
|
||||
{
|
||||
$n = trim( $n );
|
||||
|
||||
//-----------------------------------------
|
||||
// Look for underscore version too?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( strstr( $n, '_' ) )
|
||||
{
|
||||
//$n = str_replace( '_', ' ', $n );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Like?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( strstr( $n, '-' ) )
|
||||
{
|
||||
$n = str_replace( '-', '_', $n );
|
||||
}
|
||||
|
||||
$n = str_replace( '"', '"', $n );
|
||||
|
||||
$na[] = "lower(name) LIKE '{$n}'";
|
||||
}
|
||||
}
|
||||
|
||||
$timecutoff = time() - ( 30 * 60 );
|
||||
|
||||
$query_string = implode( ' OR ', $na );
|
||||
|
||||
if ( $query_string )
|
||||
{
|
||||
$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 $query_string AND m.last_activity > $timecutoff 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));
|
||||
}
|
||||
|
||||
if ( ! $hits_left )
|
||||
{
|
||||
$hits_left = 100000;
|
||||
}
|
||||
|
||||
$DB->query("UPDATE ibf_cache_store SET cs_value='".$DB->add_slashes($final)."', cs_extra='{$hits_left}&{$time_is_running_out}' WHERE cs_key='chatstat'");
|
||||
|
||||
$row['cs_value'] = $final;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Any members to show?
|
||||
//-----------------------------------------
|
||||
|
||||
$ibforums->vars['chat04_height'] += $ibforums->vars['chat04_poppad'] ? $ibforums->vars['chat04_poppad'] : 50;
|
||||
$ibforums->vars['chat04_width'] += $ibforums->vars['chat04_poppad'] ? $ibforums->vars['chat04_poppad'] : 50;
|
||||
|
||||
$chat_link = ( $ibforums->vars['chat04_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['chat04_who_save'] );
|
||||
$this->html = $this->class->html->whoschatting_show( intval($count), stripslashes($names), $chat_link, $txt );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! $ibforums->vars['chat04_hide_whoschatting'] )
|
||||
{
|
||||
$this->html = $this->class->html->whoschatting_empty($chat_link);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->html;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -2,16 +2,15 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
@@ -44,22 +43,22 @@ class chat_functions
|
||||
$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()
|
||||
{
|
||||
@@ -70,9 +69,9 @@ class chat_functions
|
||||
return;
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
//-----------------------------------------
|
||||
// Get details from the DB
|
||||
//----------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query("SELECT * FROM ibf_cache_store WHERE cs_key='chatstat'");
|
||||
|
||||
@@ -80,13 +79,14 @@ class chat_functions
|
||||
|
||||
list( $hits, $time ) = explode( '&', $row['cs_extra'] );
|
||||
|
||||
//----------------------------------
|
||||
//-----------------------------------------
|
||||
// Do we need to update?
|
||||
//----------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$final = "";
|
||||
$time_is_running_out = time();
|
||||
$member_ids = array();
|
||||
$new = array();
|
||||
|
||||
if ( $time < time() - ( $ibforums->vars['chat_who_save'] * 60 ) )
|
||||
{
|
||||
@@ -99,17 +99,26 @@ class chat_functions
|
||||
$hits_left = array_shift($data);
|
||||
}
|
||||
|
||||
$name_string = strtolower( implode( '","', str_replace( '"', '"', str_replace( '_', ' ', $data ) ) ) );
|
||||
|
||||
if ( count($data) > 0 )
|
||||
foreach( $data as $t )
|
||||
{
|
||||
$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)
|
||||
$t = strtolower(trim($t));
|
||||
$t = str_replace( '_', ' ', $t );
|
||||
$t = str_replace( '"', '"', $t );
|
||||
|
||||
$new[] = $t;
|
||||
}
|
||||
|
||||
$name_string = implode( '","', $new );
|
||||
|
||||
if ( count($new) > 0 )
|
||||
{
|
||||
$DB->query("SELECT m.id, m.name, m.mgroup FROM ibf_members m
|
||||
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>";
|
||||
$g = $ibforums->cache['group_cache'][ $m['mgroup'] ];
|
||||
$member_ids[] = "<a href=\"{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?showuser={$m['id']}\">{$g['prefix']}{$m['name']}{$g['suffix']}</a>";
|
||||
}
|
||||
|
||||
$final = implode( ",\n", $member_ids );
|
||||
@@ -123,9 +132,9 @@ class chat_functions
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------
|
||||
//-----------------------------------------
|
||||
// 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;
|
||||
|
||||
@@ -0,0 +1,357 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Task Manager functions ( Digest Library )
|
||||
| > Script written by Matt Mecham
|
||||
| > Date started: 9th June 2004
|
||||
| > DBA Checked: 9th June 2004
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly.";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
class digest_functions
|
||||
{
|
||||
var $digest_time = 'daily';
|
||||
var $digest_type = 'topic';
|
||||
var $root_path = './';
|
||||
var $midnight = 0;
|
||||
var $last_week = 0;
|
||||
var $last_day = 0;
|
||||
var $last_time = 0;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// CONSTRUCTOR
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function digest_functions()
|
||||
{
|
||||
global $DB, $std, $ibforums, $ROOT_PATH;
|
||||
|
||||
if ( $ROOT_PATH )
|
||||
{
|
||||
$this->root_path = $ROOT_PATH.'/';
|
||||
}
|
||||
else if ( ROOT_PATH )
|
||||
{
|
||||
$this->root_path = ROOT_PATH;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get midnight (GMT - roughly)
|
||||
//-----------------------------------------
|
||||
|
||||
$this->midnight = mktime( 0, 0 );
|
||||
|
||||
//-----------------------------------------
|
||||
// Midnight today minus a weeks worth of secs
|
||||
//-----------------------------------------
|
||||
|
||||
$this->last_week = $this->midnight - 604800;
|
||||
|
||||
//-----------------------------------------
|
||||
// Midnight today minus a day worth of secs
|
||||
//-----------------------------------------
|
||||
|
||||
$this->last_day = $this->midnight - 86400;
|
||||
|
||||
$DB->load_cache_file( $this->root_path.'sources/sql/'.SQL_DRIVER.'_extra_queries.php', 'sql_extra_queries' );
|
||||
|
||||
//-----------------------------------------
|
||||
// Load the email libby
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( $this->root_path.'sources/classes/class_email.php' );
|
||||
$this->email = new emailer($this->root_path);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Run the digest
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function run_digest()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$this->last_time = $this->digest_time == 'daily' ? $this->last_day : $this->last_week;
|
||||
|
||||
if ( $this->digest_type == 'topic' )
|
||||
{
|
||||
$this->_send_topic_digest();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_send_forum_digest();
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// TOPIC DIGEST
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function _send_topic_digest()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
//-----------------------------------------
|
||||
// Get all posts / topics
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->cache_add_query( 'digest_get_topics', array(
|
||||
'type' => $this->digest_time,
|
||||
'last_time' => $this->last_time
|
||||
), 'sql_extra_queries' );
|
||||
$topic_query = $DB->cache_exec_query();
|
||||
|
||||
//-----------------------------------------
|
||||
// Now, loop print and send to subscribers
|
||||
//-----------------------------------------
|
||||
|
||||
$main_output = "";
|
||||
$count = 0;
|
||||
$cached = array();
|
||||
$subject = $this->digest_time == 'daily' ? 'digest_topic_daily' : 'digest_topic_weekly';
|
||||
|
||||
while( $t = $DB->fetch_row( $topic_query ) )
|
||||
{
|
||||
$main_output = "";
|
||||
$others_posted = 0;
|
||||
|
||||
if ( ! $cached[ $t['tid'] ] )
|
||||
{
|
||||
$topic_title = $t['title'];
|
||||
$forum_name = $ibforums->cache['forum_cache'][ $t['forum_id'] ]['name'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Get posts...
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->simple_construct( array( 'select' => '*',
|
||||
'from' => 'posts',
|
||||
'where' => "topic_id={$t['tid']} AND queued=0 AND post_date > {$this->last_time}",
|
||||
'order' => 'post_date' ) );
|
||||
|
||||
$post_query = $DB->simple_exec();
|
||||
|
||||
$post_output = "";
|
||||
|
||||
while( $p = $DB->fetch_row( $post_query ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Do we have other posters?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $t['trmid'] != $p['author_id'] )
|
||||
{
|
||||
$others_posted = 1;
|
||||
}
|
||||
|
||||
$post_author = $p['author_name'];
|
||||
$post_date = $std->get_date( $p['post_date'], 'SHORT' );
|
||||
$post_content = $p['post'];
|
||||
|
||||
$post_output .= "\n-------------------------------------------\n"
|
||||
. "{$post_author} -- {$post_date}\n{$post_content}\n\n";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Process
|
||||
//-----------------------------------------
|
||||
|
||||
$main_output .= "Topic: $topic_title (Forum: $forum_name)\n"
|
||||
. "=====================================\n"
|
||||
. $post_output
|
||||
. "\n=====================================\n";
|
||||
|
||||
$cached[ $t['tid'] ] = $main_output;
|
||||
}
|
||||
else
|
||||
{
|
||||
$main_output = $cached[ $t['tid'] ];
|
||||
}
|
||||
|
||||
if ( $others_posted )
|
||||
{
|
||||
$count++;
|
||||
|
||||
//-----------------------------------------
|
||||
// Send email...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->email->get_template( $subject, $data['language']);
|
||||
|
||||
$this->email->build_message( array(
|
||||
'TOPIC_ID' => $t['tid'],
|
||||
'FORUM_ID' => $t['forum_id'],
|
||||
'TITLE' => $topic_title,
|
||||
'NAME' => $t['name'],
|
||||
'CONTENT' => $main_output,
|
||||
) );
|
||||
|
||||
$DB->do_insert( 'mail_queue', array( 'mail_to' => $t['email'],
|
||||
'mail_date' => time(),
|
||||
'mail_subject' => $this->email->lang_subject,
|
||||
'mail_content' => $std->txt_safeslashes($this->email->message) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$ibforums->cache['systemvars']['mail_queue'] += $count;
|
||||
|
||||
//-----------------------------------------
|
||||
// Update cache with remaning email count
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->do_update( 'cache_store', array( 'cs_array' => 1, 'cs_value' => addslashes(serialize($ibforums->cache['systemvars'])) ), "cs_key='systemvars'" );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// TOPIC DIGEST
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function _send_forum_digest()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
//-----------------------------------------
|
||||
// Get all posts / topics
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->cache_add_query( 'digest_get_forums', array(
|
||||
'type' => $this->digest_time
|
||||
), 'sql_extra_queries' );
|
||||
$forum_query = $DB->simple_exec();
|
||||
|
||||
//-----------------------------------------
|
||||
// Now, loop print and send to subscribers
|
||||
//-----------------------------------------
|
||||
|
||||
$main_output = "";
|
||||
$count = 0;
|
||||
$cached = array();
|
||||
$subject = $this->digest_time == 'daily' ? 'digest_forum_daily' : 'digest_forum_weekly';
|
||||
|
||||
while( $t = $DB->fetch_row( $forum_query ) )
|
||||
{
|
||||
$main_output = "";
|
||||
$others_posted = 0;
|
||||
|
||||
if ( ! $cached[ $t['forum_id'] ] )
|
||||
{
|
||||
$forum_name = $ibforums->cache['forum_cache'][ $t['forum_id'] ]['name'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Get topics...
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->cache_add_query( 'digest_get_forums_topics', array(
|
||||
'forum_id' => $t['forum_id'],
|
||||
'last_time' => $this->last_time
|
||||
), 'sql_extra_queries' );
|
||||
$topic_query = $DB->cache_exec_query();
|
||||
|
||||
$post_output = "";
|
||||
|
||||
while( $p = $DB->fetch_row( $topic_query ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Do we have other posters?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $t['member_id'] != $p['starter_id'] )
|
||||
{
|
||||
$others_posted = 1;
|
||||
}
|
||||
|
||||
$post_author = $p['author_name'];
|
||||
$post_date = $std->get_date( $p['post_date'], 'SHORT' );
|
||||
$post_content = $p['post'];
|
||||
$topic_title = $p['title'];
|
||||
|
||||
$post_output .= "\n-------------------------------------------\n"
|
||||
. "Topic: {$topic_title} ({$post_author} -- {$post_date})"
|
||||
. "\n............................................\n"
|
||||
. "{$post_content}\n\n";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Process
|
||||
//-----------------------------------------
|
||||
|
||||
$main_output .= "Forum: $forum_name\n"
|
||||
. "=====================================\n"
|
||||
. $post_output
|
||||
. "\n=====================================\n";
|
||||
|
||||
$cached[ $t['forum_id'] ] = $main_output;
|
||||
}
|
||||
else
|
||||
{
|
||||
$main_output = $cached[ $t['forum_id'] ];
|
||||
}
|
||||
|
||||
if ( $others_posted )
|
||||
{
|
||||
$count++;
|
||||
|
||||
//-----------------------------------------
|
||||
// Send email...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->email->get_template( $subject, $data['language']);
|
||||
|
||||
$this->email->build_message( array(
|
||||
'FORUM_ID' => $t['forum_id'],
|
||||
'NAME' => $t['name'],
|
||||
'CONTENT' => $main_output,
|
||||
) );
|
||||
|
||||
$DB->do_insert( 'mail_queue', array( 'mail_to' => $t['email'],
|
||||
'mail_date' => time(),
|
||||
'mail_subject' => $this->email->lang_subject,
|
||||
'mail_content' => $std->txt_safeslashes($this->email->message) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$ibforums->cache['systemvars']['mail_queue'] += $count;
|
||||
|
||||
//-----------------------------------------
|
||||
// Update cache with remaning email count
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->do_update( 'cache_store', array( 'cs_array' => 1, 'cs_value' => addslashes(serialize($ibforums->cache['systemvars'])) ), "cs_key='systemvars'" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,626 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
+538
-258
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -2,16 +2,15 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
@@ -20,6 +19,7 @@
|
||||
| > Date started: 19th February 2002
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -35,32 +35,40 @@ class post_functions extends Post {
|
||||
var $moderator = array( 'member_id' => 0, 'member_name' => "", 'edit_post' => 0 );
|
||||
var $orig_post = array();
|
||||
var $edit_title = 0;
|
||||
|
||||
function post_functions($class) {
|
||||
var $post_key = "";
|
||||
var $class = "";
|
||||
|
||||
function post_functions($class)
|
||||
{
|
||||
global $ibforums, $std, $DB;
|
||||
|
||||
//-------------------------------------------------
|
||||
$this->class = $class;
|
||||
|
||||
//-----------------------------------------
|
||||
// Lets load the topic from the database before we do anything else.
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'where' => "tid=".intval($ibforums->input['t']) ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
$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->simple_construct( array( 'select' => '*', 'from' => 'posts', 'where' => "pid=".intval($ibforums->input['p']) ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
$DB->query("SELECT * FROM ibf_posts WHERE pid=".intval($ibforums->input['p']));
|
||||
$this->orig_post = $DB->fetch_row();
|
||||
|
||||
if (! $this->orig_post['pid'])
|
||||
@@ -68,20 +76,47 @@ class post_functions extends Post {
|
||||
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Generate post key (do we have one?)
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->orig_post['post_key'] )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Generate one and save back to post and attachment
|
||||
// to ensure 1.3 < compatibility
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post_key = md5(microtime());
|
||||
|
||||
$DB->do_update( 'posts', array( 'post_key' => $this->post_key ), 'pid='.$this->orig_post['pid'] );
|
||||
|
||||
$DB->do_update( 'attachments', array( 'attach_post_key' => $this->post_key ), 'attach_pid='.$this->orig_post['pid'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->post_key = $this->orig_post['post_key'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Load the moderator
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->member['id'])
|
||||
{
|
||||
$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']."'))");
|
||||
$DB->simple_construct( array( 'select' => 'member_id, member_name, mid, edit_post, edit_topic',
|
||||
'from' => 'moderators',
|
||||
'where' => "forum_id=".$this->class->forum['id']." AND (member_id='".$ibforums->member['id']."' OR (is_group=1 AND group_id='".$ibforums->member['mgroup']."'))" ) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
$this->moderator = $DB->fetch_row();
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Lets do some tests to make sure that we are
|
||||
// allowed to edit this topic
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$can_edit = 0;
|
||||
|
||||
@@ -115,21 +150,15 @@ class post_functions extends Post {
|
||||
$std->Error( array( LEVEL => 1, MSG => 'not_op') );
|
||||
}
|
||||
|
||||
//-----------------------------
|
||||
// Is the topic locked?
|
||||
//-----------------------------
|
||||
//-----------------------------------------
|
||||
// Check access
|
||||
//-----------------------------------------
|
||||
|
||||
if (($this->topic['state'] != 'open') and (!$ibforums->member['g_is_supmod']))
|
||||
{
|
||||
if ($ibforums->member['g_post_closed'] != 1)
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
|
||||
}
|
||||
}
|
||||
$this->class->check_for_edit($this->topic);
|
||||
|
||||
//-----------------------------
|
||||
//-----------------------------------------
|
||||
// // Do we have edit topic abilities?
|
||||
//-----------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->orig_post['new_topic'] == 1 )
|
||||
{
|
||||
@@ -150,23 +179,58 @@ class post_functions extends Post {
|
||||
$this->edit_title = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function process($class) {
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// MAIN PROCESS FUNCTION
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function process()
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Did we remove an attachment?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->input['removeattachid'] )
|
||||
{
|
||||
if ( $ibforums->input[ 'removeattach_'. $ibforums->input['removeattachid'] ] )
|
||||
{
|
||||
$this->class->pf_remove_attachment( intval($ibforums->input['removeattachid']), $this->post_key );
|
||||
$this->show_form();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Did we add an attachment?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->input['attachgo'] )
|
||||
{
|
||||
$this->class->obj['post_errors'] = "";
|
||||
$this->upload_id = $this->class->process_upload();
|
||||
$this->show_form();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Parse the post, and check for any errors.
|
||||
// overwrites saved post intentionally
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post = $class->compile_post();
|
||||
$this->post = $this->class->compile_post();
|
||||
|
||||
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
|
||||
if ($this->class->obj['post_errors'] == "")
|
||||
{
|
||||
$this->upload = $this->class->process_upload();
|
||||
}
|
||||
|
||||
if ( ($this->class->obj['post_errors'] != "") or ($this->class->obj['preview_post'] != "") )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Show the form again
|
||||
//-----------------------------------------
|
||||
|
||||
$this->show_form($class);
|
||||
}
|
||||
else
|
||||
@@ -176,87 +240,19 @@ class post_functions extends Post {
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// COMPLETE EDIT THINGY
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
function complete_edit($class) {
|
||||
|
||||
global $ibforums, $std, $DB, $print, $HTTP_POST_FILES;
|
||||
function complete_edit($class)
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
$time = $std->get_date( time(), 'LONG' );
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Reset some data
|
||||
//-------------------------------------------------
|
||||
|
||||
// Do we have to adjust the attachments?
|
||||
|
||||
if ($this->orig_post['attach_id'])
|
||||
{
|
||||
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?
|
||||
|
||||
if (is_file($ibforums->vars['upload_dir']."/".$this->orig_post['attach_id']))
|
||||
{
|
||||
@unlink($ibforums->vars['upload_dir']."/".$this->orig_post['attach_id']);
|
||||
}
|
||||
|
||||
if ($ibforums->input['editupload'] == 'new')
|
||||
{
|
||||
// w00t, we're uploading a new ..um.. upload
|
||||
|
||||
$new_upload = $class->process_upload();
|
||||
|
||||
if ( $class->obj['post_errors'] != "") {
|
||||
|
||||
$this->show_form($class);
|
||||
}
|
||||
|
||||
$this->post['attach_id'] = $new_upload['attach_id'];
|
||||
$this->post['attach_type'] = $new_upload['attach_type'];
|
||||
$this->post['attach_hits'] = $new_upload['attach_hits'];
|
||||
$this->post['attach_file'] = $new_upload['attach_file'];
|
||||
}
|
||||
else if ($ibforums->input['editupload'] == 'delete')
|
||||
{
|
||||
// Simply remove the DB data as we've already removed the file
|
||||
|
||||
$this->post['attach_id'] = "";
|
||||
$this->post['attach_type'] = "";
|
||||
$this->post['attach_hits'] = "";
|
||||
$this->post['attach_file'] = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are keeping the old attachment
|
||||
$this->post['attach_id'] = $this->orig_post['attach_id'];
|
||||
$this->post['attach_type'] = $this->orig_post['attach_type'];
|
||||
$this->post['attach_hits'] = $this->orig_post['attach_hits'];
|
||||
$this->post['attach_file'] = $this->orig_post['attach_file'];
|
||||
}
|
||||
}
|
||||
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'];
|
||||
@@ -268,58 +264,48 @@ class post_functions extends Post {
|
||||
$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->do_update( 'topics', array( 'icon_id' => $this->post['icon_id'] ), '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'] );
|
||||
}
|
||||
$ibforums->input['TopicTitle'] = $this->class->pf_clean_topic_title( $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'] ) );
|
||||
$ibforums->input['TopicTitle'] = trim( $this->class->parser->bad_words( $ibforums->input['TopicTitle'] ) );
|
||||
$ibforums->input['TopicDesc'] = trim( $this->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']);
|
||||
$DB->do_update( 'topics', array( 'title' => $ibforums->input['TopicTitle'],
|
||||
'description' => $ibforums->input['TopicDesc']
|
||||
) , "tid=".$this->topic['tid']
|
||||
);
|
||||
|
||||
if ($this->topic['tid'] == $class->forum['last_id'])
|
||||
if ($this->topic['tid'] == $this->class->forum['last_id'])
|
||||
{
|
||||
$DB->query("UPDATE ibf_forums SET last_title='{$ibforums->input['TopicTitle']}' WHERE id='".$class->forum['id']."'");
|
||||
$DB->do_update( 'forums', array( 'last_title' => $ibforums->input['TopicTitle'] ), 'id='.$this->class->forum['id'] );
|
||||
$std->update_forum_cache();
|
||||
}
|
||||
|
||||
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'],
|
||||
$DB->do_insert( 'moderator_logs', array (
|
||||
'forum_id' => $this->class->forum['id'],
|
||||
'topic_id' => $this->topic['tid'],
|
||||
'post_id' => $this->post['pid'],
|
||||
'member_id' => $ibforums->member['id'],
|
||||
@@ -330,18 +316,15 @@ class post_functions extends Post {
|
||||
'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)
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post['append_edit'] = 1;
|
||||
|
||||
@@ -353,111 +336,117 @@ class post_functions extends Post {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$db_string = $DB->compile_db_update_string( $this->post );
|
||||
|
||||
$DB->query("UPDATE ibf_posts SET $db_string WHERE pid='".$this->post['pid']."'");
|
||||
|
||||
$DB->do_update( 'posts', $this->post, 'pid='.$this->post['pid'] );
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Make attachments "permanent"
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->pf_make_attachments_permanent($this->post_key, $this->topic['tid'], $this->post['pid']);
|
||||
|
||||
//-----------------------------------------
|
||||
// Make sure paperclip symbol is OK
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->pf_recount_topic_attachments($this->topic['tid']);
|
||||
|
||||
//-----------------------------------------
|
||||
// Redirect them back to the topic
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$print->redirect_screen( $ibforums->lang['post_edited'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st={$ibforums->input['st']}#entry{$this->post['pid']}");
|
||||
$print->redirect_screen( $ibforums->lang['post_edited'], "act=ST&f={$this->class->forum['id']}&t={$this->topic['tid']}&st={$ibforums->input['st']}#entry{$this->post['pid']}");
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// SHOW FORM
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function show_form($class) {
|
||||
|
||||
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
|
||||
function show_form()
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// 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']) ? $std->txt_htmlspecialchars($HTTP_POST_VARS['Post']) : $class->parser->unconvert($this->orig_post['post'], $class->forum['use_ibc'], $class->forum['use_html']);
|
||||
$raw_post = isset($_POST['Post']) ? $std->txt_htmlspecialchars($_POST['Post']) : $this->class->parser->unconvert($this->orig_post['post'], $this->class->forum['use_ibc'], $this->class->forum['use_html']);
|
||||
|
||||
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 = isset($_POST['TopicTitle']) ? $ibforums->input['TopicTitle'] : $this->topic['title'];
|
||||
$topic_desc = isset($_POST['TopicDesc']) ? $ibforums->input['TopicDesc'] : $this->topic['description'];
|
||||
|
||||
$topic_title = $class->html->topictitle_fields( array( 'TITLE' => $topic_title, 'DESC' => $topic_desc ) );
|
||||
$topic_title = $this->class->html->topictitle_fields( array( 'TITLE' => $topic_title, 'DESC' => $topic_desc ) );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Do we have any posting errors?
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($class->obj['post_errors'])
|
||||
if ($this->class->obj['post_errors'])
|
||||
{
|
||||
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
|
||||
$this->class->output .= $this->class->html->errors( $ibforums->lang[ $this->class->obj['post_errors'] ]);
|
||||
}
|
||||
|
||||
if ($class->obj['preview_post'])
|
||||
if ($this->class->obj['preview_post'])
|
||||
{
|
||||
$this->post['post'] = $class->parser->post_db_parse(
|
||||
$class->parser->convert( array(
|
||||
$this->class->parser->pp_do_html = intval($ibforums->input['post_htmlstatus']) AND $this->class->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0;
|
||||
$this->class->parser->pp_nl2br = $ibforums->input['post_htmlstatus'] == 2 ? 1 : 0;
|
||||
|
||||
$this->post['post'] = $this->class->parser->post_db_parse(
|
||||
$this->class->parser->convert( array(
|
||||
'TEXT' => $this->post['post'],
|
||||
'CODE' => $class->forum['use_ibc'],
|
||||
'CODE' => $this->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'] );
|
||||
'HTML' => $this->class->forum['use_html']
|
||||
) )
|
||||
);
|
||||
|
||||
$this->class->output .= $this->class->html->preview( $this->post['post'] );
|
||||
}
|
||||
|
||||
$class->check_upload_ability();
|
||||
|
||||
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '09' ),
|
||||
2 => array( 't' , $this->topic['tid']),
|
||||
3 => array( 'p' , $ibforums->input['p'] ),
|
||||
4 => array( 'st' , $ibforums->input['st'] ),
|
||||
) );
|
||||
$this->class->output .= $this->class->html_start_form( array( 1 => array( 'CODE', '09' ),
|
||||
2 => array( 't' , $this->topic['tid']),
|
||||
3 => array( 'p' , $ibforums->input['p'] ),
|
||||
4 => array( 'st' , $ibforums->input['st'] ),
|
||||
5 => array( 'post_key', $this->post_key )
|
||||
) );
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
// START TABLE
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->output .= $class->html->table_structure();
|
||||
$this->class->output .= $this->class->html->table_structure();
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_edit']} {$this->topic['title']}");
|
||||
$start_table = $this->class->html->table_top( "{$ibforums->lang['top_txt_edit']} {$this->topic['title']}");
|
||||
|
||||
$name_fields = $class->html_name_field();
|
||||
$name_fields = $this->class->html_name_field();
|
||||
|
||||
$post_box = $class->html_post_body( $raw_post );
|
||||
$post_box = $this->class->html_post_body( $raw_post );
|
||||
|
||||
$end_form = $class->html->EndForm( $ibforums->lang['submit_edit'] );
|
||||
$end_form = $this->class->html->EndForm( $ibforums->lang['submit_edit'] );
|
||||
|
||||
$post_icons = $class->html_post_icons($this->orig_post['icon_id']);
|
||||
$post_icons = $this->class->html_post_icons($this->orig_post['icon_id']);
|
||||
|
||||
if ( $class->obj['can_upload'] )
|
||||
if ($this->class->can_upload)
|
||||
{
|
||||
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 ) );
|
||||
}
|
||||
$upload_field = $this->class->html_build_uploads($this->post_key,'edit',$this->orig_post['pid']);
|
||||
}
|
||||
|
||||
if ($ibforums->member['g_append_edit'])
|
||||
@@ -469,47 +458,49 @@ class post_functions extends Post {
|
||||
$checked = "checked";
|
||||
}
|
||||
|
||||
$edit_option = $class->html->add_edit_box($checked);
|
||||
$edit_option = $this->class->html->add_edit_box($checked);
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->output = str_replace( "<!--START TABLE-->" , $start_table , $class->output );
|
||||
$class->output = str_replace( "<!--NAME FIELDS-->" , $name_fields , $class->output );
|
||||
$class->output = str_replace( "<!--POST BOX-->" , $post_box , $class->output );
|
||||
$class->output = str_replace( "<!--POST ICONS-->" , $post_icons , $class->output );
|
||||
$class->output = str_replace( "<!--END TABLE-->" , $end_form , $class->output );
|
||||
$class->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $class->output );
|
||||
$class->output = str_replace( "<!--MOD OPTIONS-->" , $edit_option , $class->output );
|
||||
$class->output = str_replace( "<!--FORUM RULES-->" , $std->print_forum_rules($class->forum), $class->output );
|
||||
$class->output = str_replace( "<!--TOPIC TITLE-->" , $topic_title , $class->output );
|
||||
$this->class->output = str_replace( "<!--START TABLE-->" , $start_table , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--NAME FIELDS-->" , $name_fields , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--POST BOX-->" , $post_box , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--POST ICONS-->" , $post_icons , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--END TABLE-->" , $end_form , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--MOD OPTIONS-->" , $edit_option , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--FORUM RULES-->" , $std->print_forum_rules($this->class->forum), $this->class->output );
|
||||
$this->class->output = str_replace( "<!--TOPIC TITLE-->" , $topic_title , $this->class->output );
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->html_add_smilie_box();
|
||||
$this->class->output = $this->class->html_add_smilie_box( $this->class->output );
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
// Add in siggy buttons and such
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->html_checkboxes('edit');
|
||||
$ibforums->input['post_htmlstatus'] = $this->orig_post['post_htmlstate'];
|
||||
|
||||
//---------------------------------------
|
||||
$this->class->html_checkboxes('edit', $this->topic['tid'], $this->class->forum['id']);
|
||||
|
||||
$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->class->html_topic_summary($this->topic['tid']);
|
||||
|
||||
$this->nav = array( "<a href='{$this->class->base_url}&act=SC&c={$this->class->forum['cat_id']}'>{$this->class->forum['cat_name']}</a>",
|
||||
"<a href='{$this->class->base_url}&act=SF&f={$this->class->forum['id']}'>{$this->class->forum['name']}</a>",
|
||||
"<a href='{$this->class->base_url}&act=ST&f={$this->class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
|
||||
);
|
||||
|
||||
$this->title = $ibforums->lang['editing_post'].' '.$this->topic['title'];
|
||||
|
||||
$print->add_output("$class->output");
|
||||
$print->add_output( $this->class->output );
|
||||
|
||||
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
|
||||
'JS' => 1,
|
||||
'NAV' => $this->nav,
|
||||
'NAV' => $this->class->nav,
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
@@ -20,54 +19,80 @@
|
||||
| > Date started: 17th February 2002
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
class post_functions extends Post {
|
||||
|
||||
class post_functions extends Post
|
||||
{
|
||||
var $nav = array();
|
||||
var $title = "";
|
||||
var $post = array();
|
||||
var $topic = array();
|
||||
var $upload = array();
|
||||
var $title = "";
|
||||
var $post = array();
|
||||
var $topic = array();
|
||||
var $upload = array();
|
||||
var $mod_topic = array();
|
||||
|
||||
var $m_group = "";
|
||||
var $class = "";
|
||||
var $m_group = "";
|
||||
var $post_key = "";
|
||||
|
||||
function post_functions($class) {
|
||||
|
||||
function post_functions($class)
|
||||
{
|
||||
global $ibforums, $std, $DB;
|
||||
|
||||
// Lets do some tests to make sure that we are allowed to start a new topic
|
||||
//-----------------------------------------
|
||||
// Check permissions
|
||||
//-----------------------------------------
|
||||
|
||||
if (! $ibforums->member['g_post_new_topics'])
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_starting') );
|
||||
}
|
||||
$this->post_key = $ibforums->input['post_key'] ? $ibforums->input['post_key'] : md5(microtime());
|
||||
|
||||
$this->class = $class;
|
||||
|
||||
$this->class->check_for_new_topic();
|
||||
|
||||
if ( $std->check_perms($class->forum['start_perms']) == FALSE )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_starting') );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function process($class) {
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// MAIN PROCESS FUNCTION
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
|
||||
function process()
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Did we remove an attachment?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->input['removeattachid'] )
|
||||
{
|
||||
if ( $ibforums->input[ 'removeattach_'. $ibforums->input['removeattachid'] ] )
|
||||
{
|
||||
$this->class->pf_remove_attachment( intval($ibforums->input['removeattachid']), $this->post_key );
|
||||
$this->show_form();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Did we add an attachment?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->input['attachgo'] )
|
||||
{
|
||||
$this->class->obj['post_errors'] = "";
|
||||
$this->upload_id = $this->class->process_upload();
|
||||
$this->show_form();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Parse the post, and check for any errors.
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post = $class->compile_post();
|
||||
$this->post = $this->class->compile_post();
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// check to make sure we have a valid topic title
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$ibforums->input['TopicTitle'] = str_replace( "<br>", "", $ibforums->input['TopicTitle'] );
|
||||
|
||||
@@ -75,66 +100,62 @@ class post_functions extends Post {
|
||||
|
||||
if ( (strlen($ibforums->input['TopicTitle']) < 2) or (!$ibforums->input['TopicTitle']) )
|
||||
{
|
||||
$class->obj['post_errors'] = 'no_topic_title';
|
||||
$this->class->obj['post_errors'] = 'no_topic_title';
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// More unicode..
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$temp = $std->txt_stripslashes($HTTP_POST_VARS['TopicTitle']);
|
||||
$temp = $std->txt_stripslashes($_POST['TopicTitle']);
|
||||
|
||||
$temp = preg_replace("/&#([0-9]+);/", "-", $temp );
|
||||
|
||||
if ( strlen($temp) > 64 )
|
||||
{
|
||||
$class->obj['post_errors'] = 'topic_title_long';
|
||||
$this->class->obj['post_errors'] = 'topic_title_long';
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// If we don't have any errors yet, parse the upload
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($class->obj['post_errors'] == "")
|
||||
if ($this->class->obj['post_errors'] == "")
|
||||
{
|
||||
$this->upload = $class->process_upload();
|
||||
$this->upload = $this->class->process_upload();
|
||||
}
|
||||
|
||||
|
||||
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") ) {
|
||||
if ( ($this->class->obj['post_errors'] != "") or ($this->class->obj['preview_post'] != "") )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Show the form again
|
||||
$this->show_form($class);
|
||||
} else {
|
||||
$this->add_new_topic($class);
|
||||
//-----------------------------------------
|
||||
|
||||
$this->show_form();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->add_new_topic();
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// ADD TOPIC FUNCTION
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
function add_new_topic($class) {
|
||||
|
||||
function add_new_topic()
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Fix up the topic title
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['etfilter_punct'])
|
||||
{
|
||||
$ibforums->input['TopicTitle'] = preg_replace( "/\?{1,}/" , "?" , $ibforums->input['TopicTitle'] );
|
||||
$ibforums->input['TopicTitle'] = preg_replace( "/(!){1,}/" , "!", $ibforums->input['TopicTitle'] );
|
||||
}
|
||||
$ibforums->input['TopicTitle'] = $this->class->pf_clean_topic_title( $ibforums->input['TopicTitle'] );
|
||||
|
||||
if ($ibforums->vars['etfilter_shout'])
|
||||
{
|
||||
$ibforums->input['TopicTitle'] = ucwords(strtolower($ibforums->input['TopicTitle']));
|
||||
}
|
||||
|
||||
$ibforums->input['TopicTitle'] = $class->parser->bad_words( $ibforums->input['TopicTitle'] );
|
||||
$ibforums->input['TopicDesc'] = $class->parser->bad_words( $ibforums->input['TopicDesc'] );
|
||||
$ibforums->input['TopicTitle'] = $this->class->parser->bad_words( $ibforums->input['TopicTitle'] );
|
||||
$ibforums->input['TopicDesc'] = $this->class->parser->bad_words( $ibforums->input['TopicDesc'] );
|
||||
|
||||
$pinned = 0;
|
||||
$state = 'open';
|
||||
@@ -143,37 +164,37 @@ class post_functions extends Post {
|
||||
{
|
||||
if ($ibforums->input['mod_options'] == 'pin')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $this->class->moderator['pin_topic'] == 1)
|
||||
{
|
||||
$pinned = 1;
|
||||
|
||||
$class->moderate_log('Pinned topic from post form', $ibforums->input['TopicTitle']);
|
||||
$this->class->moderate_log('Pinned topic from post form', $ibforums->input['TopicTitle']);
|
||||
}
|
||||
}
|
||||
else if ($ibforums->input['mod_options'] == 'close')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $this->class->moderator['close_topic'] == 1)
|
||||
{
|
||||
$state = 'closed';
|
||||
|
||||
$class->moderate_log('Closed topic from post form', $ibforums->input['TopicTitle']);
|
||||
$this->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 ) )
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or ( $this->class->moderator['pin_topic'] == 1 AND $this->class->moderator['close_topic'] == 1 ) )
|
||||
{
|
||||
$pinned = 1;
|
||||
$state = 'closed';
|
||||
|
||||
$class->moderate_log('Pinned & closed topic from post form', $ibforums->input['TopicTitle']);
|
||||
$this->class->moderate_log('Pinned & closed topic from post form', $ibforums->input['TopicTitle']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Build the master array
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->topic = array(
|
||||
'title' => $ibforums->input['TopicTitle'],
|
||||
@@ -191,268 +212,221 @@ class post_functions extends Post {
|
||||
'poll_state' => 0,
|
||||
'last_vote' => 0,
|
||||
'views' => 0,
|
||||
'forum_id' => $class->forum['id'],
|
||||
'approved' => ( $class->obj['moderate'] == 1 || $class->obj['moderate'] == 2 ) ? 0 : 1,
|
||||
'forum_id' => $this->class->forum['id'],
|
||||
'approved' => ( $this->class->obj['moderate'] == 1 || $this->class->obj['moderate'] == 2 ) ? 0 : 1,
|
||||
'pinned' => $pinned,
|
||||
);
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Insert the topic into the database to get the
|
||||
// last inserted value of the auto_increment field
|
||||
// follow suit with the post
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$db_string = $DB->compile_db_insert_string( $this->topic );
|
||||
$DB->do_insert( 'topics', $this->topic );
|
||||
|
||||
$DB->query("INSERT INTO ibf_topics (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
$this->post['topic_id'] = $DB->get_insert_id();
|
||||
$this->topic['tid'] = $this->post['topic_id'];
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Update the post info with the upload array info
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post['attach_id'] = $this->upload['attach_id'];
|
||||
$this->post['attach_type'] = $this->upload['attach_type'];
|
||||
$this->post['attach_hits'] = $this->upload['attach_hits'];
|
||||
$this->post['attach_file'] = $this->upload['attach_file'];
|
||||
$this->post['new_topic'] = 1;
|
||||
$this->post['post_key'] = $this->post_key;
|
||||
$this->post['new_topic'] = 1;
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Unqueue the post if we're starting a new topic
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $class->obj['moderate'] == 3 )
|
||||
{
|
||||
$this->post['queued'] = 0;
|
||||
}
|
||||
$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'] .")");
|
||||
//-----------------------------------------
|
||||
// Add post to DB
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->do_insert( 'posts', $this->post );
|
||||
|
||||
$this->post['pid'] = $DB->get_insert_id();
|
||||
|
||||
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']}" );
|
||||
}
|
||||
//-----------------------------------------
|
||||
// Update topic with firstpost ID
|
||||
//-----------------------------------------
|
||||
|
||||
//-------------------------------------------------
|
||||
$DB->simple_construct( array( 'update' => 'topics',
|
||||
'set' => "topic_firstpost=".$this->post['pid'],
|
||||
'where' => "tid=".$this->topic['tid']
|
||||
) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
//-----------------------------------------
|
||||
// If we are still here, lets update the
|
||||
// board/forum stats
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->forum['last_title'] = $this->topic['title'];
|
||||
$class->forum['last_id'] = $this->topic['tid'];
|
||||
$class->forum['last_post'] = time();
|
||||
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
|
||||
$class->forum['last_poster_id'] = $ibforums->member['id'];
|
||||
$class->forum['topics']++;
|
||||
$this->class->pf_update_forum_and_stats($this->topic['tid'], $this->topic['title'], 'new');
|
||||
|
||||
// Update the database
|
||||
//-----------------------------------------
|
||||
// Make attachments "permanent"
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
|
||||
"last_id='" .$class->forum['last_id'] ."', ".
|
||||
"last_post='" .$class->forum['last_post'] ."', ".
|
||||
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
|
||||
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
|
||||
"topics='" .$class->forum['topics'] ."' ".
|
||||
"WHERE id='" .$class->forum['id'] ."'");
|
||||
$this->class->pf_make_attachments_permanent($this->post_key, $this->topic['tid'], $this->post['pid']);
|
||||
|
||||
|
||||
$DB->query("UPDATE ibf_stats SET TOTAL_TOPICS=TOTAL_TOPICS+1");
|
||||
|
||||
//-------------------------------------------------
|
||||
// Are we tracking new topics we start 'auto_track'?
|
||||
//-------------------------------------------------
|
||||
|
||||
if ( $ibforums->member['id'] AND $ibforums->input['enabletrack'] == 1 )
|
||||
{
|
||||
$db_string = $DB->compile_db_insert_string( array (
|
||||
'member_id' => $ibforums->member['id'],
|
||||
'topic_id' => $this->topic['tid'],
|
||||
'start_date' => time(),
|
||||
) );
|
||||
|
||||
$DB->query("INSERT INTO ibf_tracker ({$db_string['FIELD_NAMES']}) VALUES ({$db_string['FIELD_VALUES']})");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Are we tracking this forum? If so generate some mailies - yay!
|
||||
//---------------------------------------------------------------
|
||||
|
||||
$class->forum_tracker($class->forum['id'], $this->topic['tid'], $this->topic['title'], $class->forum['name'] );
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// If we are a member, lets update thier last post
|
||||
// date and increment their post count.
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$pcount = "";
|
||||
$this->class->pf_increment_user_post_count();
|
||||
|
||||
if ($ibforums->member['id'])
|
||||
//-----------------------------------------
|
||||
// Moderating?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->class->obj['moderate'] == 1 OR $this->class->obj['moderate'] == 2 )
|
||||
{
|
||||
if ($class->forum['inc_postcount'])
|
||||
{
|
||||
// Increment the users post count
|
||||
|
||||
$pcount = "posts=posts+1, ";
|
||||
|
||||
}
|
||||
//-----------------------------------------
|
||||
// Redirect them with a message telling them the
|
||||
// post has to be previewed first
|
||||
//-----------------------------------------
|
||||
|
||||
// Are we checking for auto promotion?
|
||||
$this->class->notify_new_topic_approval( $this->topic['tid'], $this->topic['title'], $this->topic['starter_name'], $this->post['pid'] );
|
||||
|
||||
if ($ibforums->member['g_promotion'] != '-1&-1')
|
||||
{
|
||||
list($gid, $gposts) = explode( '&', $ibforums->member['g_promotion'] );
|
||||
|
||||
if ( $gid > 0 and $gposts > 0 )
|
||||
{
|
||||
if ( $ibforums->member['posts'] + 1 >= $gposts )
|
||||
{
|
||||
$mgroup = "mgroup='$gid', ";
|
||||
|
||||
if ( USE_MODULES == 1 )
|
||||
{
|
||||
$class->modules->register_class(&$class);
|
||||
$class->modules->on_group_change($ibforums->member['id'], $gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ibforums->member['last_post'] = time();
|
||||
|
||||
$DB->query("UPDATE ibf_members SET ".$pcount.$mgroup.
|
||||
"last_post='" .$ibforums->member['last_post'] ."'".
|
||||
"WHERE id='" .$ibforums->member['id']."'");
|
||||
$print->redirect_screen( $ibforums->lang['moderate_topic'], "act=SF&f={$this->class->forum['id']}" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Redirect them back to the topic
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Are we tracking new topics we start 'auto_track'?
|
||||
//-----------------------------------------
|
||||
|
||||
$std->boink_it($class->base_url."act=ST&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
$this->class->pf_add_tracked_topic($this->topic['tid']);
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we tracking this forum? If so generate some mailies - yay!
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->forum_tracker($this->class->forum['id'], $this->topic['tid'], $this->topic['title'], $this->class->forum['name'], $this->post['post'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// Redirect them back to the topic
|
||||
//-----------------------------------------
|
||||
|
||||
$std->boink_it($this->class->base_url."showtopic={$this->topic['tid']}");
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// SHOW FORM
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function show_form(&$class) {
|
||||
|
||||
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
|
||||
function show_form()
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we quoting posts?
|
||||
//-----------------------------------------
|
||||
|
||||
$raw_post = $this->class->check_multi_quote();
|
||||
|
||||
//-----------------------------------------
|
||||
// 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']) ? $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 = $std->txt_raw2form($raw_post);
|
||||
}
|
||||
$topic_title = isset($_POST['TopicTitle']) ? $ibforums->input['TopicTitle'] : "";
|
||||
$topic_desc = isset($_POST['TopicDesc']) ? $ibforums->input['TopicDesc'] : "";
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have any posting errors?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($class->obj['post_errors'])
|
||||
if ($this->class->obj['post_errors'])
|
||||
{
|
||||
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
|
||||
$this->class->output .= $this->class->html->errors( $ibforums->lang[ $this->class->obj['post_errors'] ]);
|
||||
}
|
||||
|
||||
if ($class->obj['preview_post'])
|
||||
if ($this->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'] );
|
||||
$this->class->parser->pp_do_html = intval($ibforums->input['post_htmlstatus']) AND $this->class->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0;
|
||||
$this->class->parser->pp_nl2br = $ibforums->input['post_htmlstatus'] == 2 ? 1 : 0;
|
||||
|
||||
$this->post['post'] = $this->class->parser->post_db_parse(
|
||||
$this->class->parser->convert( array(
|
||||
'TEXT' => $this->post['post'],
|
||||
'CODE' => $this->class->forum['use_ibc'],
|
||||
'SMILIES' => $ibforums->input['enableemo'],
|
||||
'HTML' => $this->class->forum['use_html']
|
||||
) )
|
||||
);
|
||||
|
||||
$this->class->output .= $this->class->html->preview( $this->post['post'] );
|
||||
}
|
||||
|
||||
$class->check_upload_ability();
|
||||
$this->class->output .= $this->class->html_start_form( array( 1 => array( 'CODE', '01' ),
|
||||
2 => array( 'post_key', $this->post_key ),
|
||||
) );
|
||||
|
||||
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '01' ) ) );
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
// START TABLE
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->output .= $class->html->table_structure();
|
||||
$this->class->output .= $this->class->html->table_structure();
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$topic_title = $class->html->topictitle_fields( array( 'TITLE' => $topic_title, 'DESC' => $topic_desc ) );
|
||||
$topic_title = $this->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']}");
|
||||
$start_table = $this->class->html->table_top( "{$ibforums->lang['top_txt_new']} {$this->class->forum['name']}");
|
||||
|
||||
$name_fields = $class->html_name_field();
|
||||
$name_fields = $this->class->html_name_field();
|
||||
|
||||
$post_box = $class->html_post_body( $raw_post );
|
||||
$post_box = $this->class->html_post_body( $raw_post );
|
||||
|
||||
$mod_options = $class->mod_options();
|
||||
$mod_options = $this->class->mod_options();
|
||||
|
||||
$end_form = $class->html->EndForm( $ibforums->lang['submit_new'] );
|
||||
$end_form = $this->class->html->EndForm( $ibforums->lang['submit_new'] );
|
||||
|
||||
$post_icons = $class->html_post_icons();
|
||||
$post_icons = $this->class->html_post_icons();
|
||||
|
||||
if ($class->obj['can_upload'])
|
||||
if ($this->class->can_upload)
|
||||
{
|
||||
$upload_field = $class->html->Upload_field( $std->size_format( $ibforums->member['g_attach_max'] * 1024 ) );
|
||||
$upload_field = $this->class->html_build_uploads($this->post_key,'new');
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$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 = str_replace("<!--FORUM RULES-->", $std->print_forum_rules($class->forum), $class->output );
|
||||
$this->class->output = str_replace( "<!--START TABLE-->" , $start_table , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--NAME FIELDS-->" , $name_fields , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--POST BOX-->" , $post_box , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--POST ICONS-->" , $post_icons , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--MOD OPTIONS-->" , $mod_options , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--END TABLE-->" , $end_form , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--TOPIC TITLE-->" , $topic_title , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--FORUM RULES-->" , $std->print_forum_rules($this->class->forum), $this->class->output );
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->html_add_smilie_box();
|
||||
$this->class->output = $this->class->html_add_smilie_box( $this->class->output );
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
// Add in siggy buttons and such
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->html_checkboxes();
|
||||
$this->class->html_checkboxes('new', 0, $this->class->forum['id']);
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->nav = array( "<a href='{$class->base_url}act=SC&c={$class->forum['cat_id']}'>{$class->forum['cat_name']}</a>",
|
||||
"<a href='{$class->base_url}act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
|
||||
);
|
||||
$this->title = $ibforums->lang['posting_new_topic'];
|
||||
|
||||
$print->add_output("$class->output");
|
||||
$print->add_output( $this->class->output );
|
||||
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
|
||||
'JS' => 1,
|
||||
'NAV' => $this->nav,
|
||||
) );
|
||||
'NAV' => $this->class->nav,
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
+572
-358
File diff suppressed because it is too large.
Load diff
+285
-251
@@ -2,21 +2,21 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > New Post module
|
||||
| > Module written by Matt Mecham
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -39,127 +39,161 @@ class post_functions extends Post {
|
||||
|
||||
function post_functions($class)
|
||||
{
|
||||
|
||||
global $ibforums, $std, $DB;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
$this->class = $class;
|
||||
|
||||
$this->post_key = $ibforums->input['post_key'] ? $ibforums->input['post_key'] : md5(microtime());
|
||||
|
||||
//-----------------------------------------
|
||||
// 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'] )
|
||||
if ( ! $this->class->forum['allow_poll'] )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
|
||||
}
|
||||
|
||||
$this->m_group = $ibforums->perm_id;
|
||||
|
||||
if ( $std->check_perms($class->forum['start_perms']) != TRUE )
|
||||
if ( $std->check_perms($this->class->forum['start_perms']) != TRUE )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function process($class) {
|
||||
|
||||
function process()
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Parse the post, and check for any errors.
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Did we remove an attachment?
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post = $class->compile_post();
|
||||
|
||||
//-------------------------------------------------
|
||||
// check to make sure we have a valid topic title
|
||||
//-------------------------------------------------
|
||||
|
||||
if ( (strlen($ibforums->input['TopicTitle']) < 2) or (!$ibforums->input['TopicTitle']) ) {
|
||||
$class->obj['post_errors'] = 'no_topic_title';
|
||||
if ( $ibforums->input['removeattachid'] )
|
||||
{
|
||||
if ( $ibforums->input[ 'removeattach_'. $ibforums->input['removeattachid'] ] )
|
||||
{
|
||||
$this->class->pf_remove_attachment( intval($ibforums->input['removeattachid']), $this->post_key );
|
||||
$this->show_form();
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// More unicode..
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Did we add an attachment?
|
||||
//-----------------------------------------
|
||||
|
||||
$temp = $std->txt_stripslashes($HTTP_POST_VARS['TopicTitle']);
|
||||
if ( $ibforums->input['attachgo'] )
|
||||
{
|
||||
$this->class->obj['post_errors'] = "";
|
||||
$this->upload_id = $this->class->process_upload();
|
||||
$this->show_form();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Parse the post, and check for any errors.
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post = $this->class->compile_post();
|
||||
|
||||
//-----------------------------------------
|
||||
// check to make sure we have a valid topic title
|
||||
//-----------------------------------------
|
||||
|
||||
if ( (strlen($ibforums->input['TopicTitle']) < 2) or (!$ibforums->input['TopicTitle']) )
|
||||
{
|
||||
$this->class->obj['post_errors'] = 'no_topic_title';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// More unicode..
|
||||
//-----------------------------------------
|
||||
|
||||
$temp = $std->txt_stripslashes($_POST['TopicTitle']);
|
||||
|
||||
$temp = preg_replace("/&#([0-9]+);/", "-", $temp );
|
||||
|
||||
if ( strlen($temp) > 64 )
|
||||
{
|
||||
$class->obj['post_errors'] = 'topic_title_long';
|
||||
$this->class->obj['post_errors'] = 'topic_title_long';
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// check to make sure we have a correct # of choices
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->poll_choices = $ibforums->input['PollAnswers'];
|
||||
|
||||
$this->poll_choices = preg_replace( "/<br><br>/" , "" , $this->poll_choices );
|
||||
$this->poll_choices = preg_replace( "#<br /><br />#" , "" , $this->poll_choices );
|
||||
|
||||
$this->poll_choices = preg_replace( "/<br>/e" , "\$this->regex_count_choices()" , $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';
|
||||
$this->class->obj['post_errors'] = 'poll_to_many';
|
||||
}
|
||||
|
||||
if ($this->poll_count < 1)
|
||||
{
|
||||
$class->obj['post_errors'] = 'poll_not_enough';
|
||||
$this->class->obj['post_errors'] = 'poll_not_enough';
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// If we don't have any errors yet, parse the upload
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($class->obj['post_errors'] == "")
|
||||
if ($this->class->obj['post_errors'] == "")
|
||||
{
|
||||
$this->upload = $class->process_upload();
|
||||
$this->upload = $this->class->process_upload();
|
||||
}
|
||||
|
||||
|
||||
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") ) {
|
||||
if ( ($this->class->obj['post_errors'] != "") or ($this->class->obj['preview_post'] != "") )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Show the form again
|
||||
$this->show_form($class);
|
||||
} else {
|
||||
$this->add_new_poll($class);
|
||||
//-----------------------------------------
|
||||
|
||||
$this->show_form();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->add_new_poll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// ADD POLL FUNCTION
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
function add_new_poll($class) {
|
||||
|
||||
function add_new_poll() {
|
||||
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 );
|
||||
$polls = explode( "<br />", $this->poll_choices );
|
||||
|
||||
foreach ($polls as $polling)
|
||||
{
|
||||
@@ -167,27 +201,18 @@ class post_functions extends Post {
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$poll_array[] = array( $count , $class->parser->bad_words($polling), 0 );
|
||||
$poll_array[] = array( $count , $this->class->parser->bad_words($polling), 0 );
|
||||
$count++;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Fix up the topic title
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['etfilter_punct'])
|
||||
{
|
||||
$ibforums->input['TopicTitle'] = preg_replace( "/\?{1,}/" , "?" , $ibforums->input['TopicTitle'] );
|
||||
$ibforums->input['TopicTitle'] = preg_replace( "/(!){1,}/", "!" , $ibforums->input['TopicTitle'] );
|
||||
}
|
||||
$ibforums->input['TopicTitle'] = $this->class->pf_clean_topic_title( $ibforums->input['TopicTitle'] );
|
||||
|
||||
if ($ibforums->vars['etfilter_shout'])
|
||||
{
|
||||
$ibforums->input['TopicTitle'] = ucwords($ibforums->input['TopicTitle']);
|
||||
}
|
||||
|
||||
$ibforums->input['TopicTitle'] = $class->parser->bad_words( $ibforums->input['TopicTitle'] );
|
||||
$ibforums->input['TopicDesc'] = $class->parser->bad_words( $ibforums->input['TopicDesc'] );
|
||||
$ibforums->input['TopicTitle'] = $this->class->parser->bad_words( $ibforums->input['TopicTitle'] );
|
||||
$ibforums->input['TopicDesc'] = $this->class->parser->bad_words( $ibforums->input['TopicDesc'] );
|
||||
|
||||
if ( $ibforums->vars['poll_disable_noreply'] != 1 )
|
||||
{
|
||||
@@ -198,14 +223,49 @@ class post_functions extends Post {
|
||||
$poll_state = 'open';
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
$pinned = 0;
|
||||
$state = 'open';
|
||||
|
||||
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
|
||||
{
|
||||
if ($ibforums->input['mod_options'] == 'pin')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $this->class->moderator['pin_topic'] == 1)
|
||||
{
|
||||
$pinned = 1;
|
||||
|
||||
$this->class->moderate_log('Pinned topic from post form', $ibforums->input['TopicTitle']);
|
||||
}
|
||||
}
|
||||
else if ($ibforums->input['mod_options'] == 'close')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $this->class->moderator['close_topic'] == 1)
|
||||
{
|
||||
$state = 'closed';
|
||||
|
||||
$this->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 ( $this->class->moderator['pin_topic'] == 1 AND $this->class->moderator['close_topic'] == 1 ) )
|
||||
{
|
||||
$pinned = 1;
|
||||
$state = 'closed';
|
||||
|
||||
$this->class->moderate_log('Pinned & closed topic from post form', $ibforums->input['TopicTitle']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Build the master array
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->topic = array(
|
||||
'title' => $ibforums->input['TopicTitle'],
|
||||
'description' => $ibforums->input['TopicDesc'] ,
|
||||
'state' => 'open',
|
||||
'state' => $state,
|
||||
'posts' => 0,
|
||||
'starter_id' => $ibforums->member['id'],
|
||||
'starter_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
|
||||
@@ -218,211 +278,181 @@ class post_functions extends Post {
|
||||
'poll_state' => $poll_state,
|
||||
'last_vote' => 0,
|
||||
'views' => 0,
|
||||
'forum_id' => $class->forum['id'],
|
||||
'approved' => $class->obj['moderate'] ? 0 : 1,
|
||||
'pinned' => 0,
|
||||
'forum_id' => $this->class->forum['id'],
|
||||
'approved' => $this->class->obj['moderate'] ? 0 : 1,
|
||||
'pinned' => $pinned,
|
||||
);
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Insert the topic into the database to get the
|
||||
// last inserted value of the auto_increment field
|
||||
// follow suit with the post
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$db_string = $DB->compile_db_insert_string( $this->topic );
|
||||
$DB->do_insert( 'topics', $this->topic );
|
||||
|
||||
$DB->query("INSERT INTO ibf_topics (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
$this->post['topic_id'] = $DB->get_insert_id();
|
||||
$this->topic['tid'] = $this->post['topic_id'];
|
||||
/*---------------------------------------------------*/
|
||||
|
||||
//-----------------------------------------
|
||||
// Update the post info with the upload array info
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post['attach_id'] = $this->upload['attach_id'];
|
||||
$this->post['attach_type'] = $this->upload['attach_type'];
|
||||
$this->post['attach_hits'] = $this->upload['attach_hits'];
|
||||
$this->post['post_key'] = $this->post_key;
|
||||
$this->post['new_topic'] = 1;
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Unqueue the post if we're starting a new topic
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $class->obj['moderate'] == 3 )
|
||||
if ( $this->class->obj['moderate'] == 3 )
|
||||
{
|
||||
$this->post['queued'] = 0;
|
||||
}
|
||||
|
||||
$db_string = $DB->compile_db_insert_string( $this->post );
|
||||
//-----------------------------------------
|
||||
// Add post to DB
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
$DB->do_insert( 'posts', $this->post );
|
||||
|
||||
$this->post['pid'] = $DB->get_insert_id();
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Update topic with firstpost ID
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->simple_construct( array( 'update' => 'topics',
|
||||
'set' => "topic_firstpost=".$this->post['pid'],
|
||||
'where' => "tid=".$this->topic['tid']
|
||||
) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// 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'] .")");
|
||||
|
||||
|
||||
|
||||
|
||||
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']}" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
$DB->do_insert( 'polls',
|
||||
array (
|
||||
'tid' => $this->topic['tid'],
|
||||
'forum_id' => $this->class->forum['id'],
|
||||
'start_date' => time(),
|
||||
'choices' => addslashes(serialize($poll_array)),
|
||||
'starter_id' => $ibforums->member['id'],
|
||||
'votes' => 0,
|
||||
'poll_question' => $this->class->parser->bad_words($ibforums->input['pollq']),
|
||||
) );
|
||||
|
||||
//-----------------------------------------
|
||||
// If we are still here, lets update the
|
||||
// board/forum stats
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->forum['last_title'] = $this->topic['title'];
|
||||
$class->forum['last_id'] = $this->topic['tid'];
|
||||
$class->forum['last_post'] = time();
|
||||
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
|
||||
$class->forum['last_poster_id'] = $ibforums->member['id'];
|
||||
$class->forum['topics']++;
|
||||
$this->class->pf_update_forum_and_stats($this->topic['tid'], $this->topic['title'], 'new');
|
||||
|
||||
// Update the database
|
||||
//-----------------------------------------
|
||||
// Make attachments "permanent"
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
|
||||
"last_id='" .$class->forum['last_id'] ."', ".
|
||||
"last_post='" .$class->forum['last_post'] ."', ".
|
||||
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
|
||||
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
|
||||
"topics='" .$class->forum['topics'] ."' ".
|
||||
"WHERE id='" .$class->forum['id'] ."'");
|
||||
$this->class->pf_make_attachments_permanent($this->post_key, $this->topic['tid'], $this->post['pid']);
|
||||
|
||||
// At this point in time, we'll scan the database for the correct number
|
||||
// of topics - if this proves to database intensive, we'll simply increment
|
||||
// the value stored in the ibf_stats database.
|
||||
|
||||
$DB->query("SELECT COUNT(tid) as topic_cnt FROM ibf_topics");
|
||||
$stats = $DB->fetch_row();
|
||||
|
||||
$DB->query("UPDATE ibf_stats SET TOTAL_TOPICS='".$stats['topic_cnt']."'");
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// If we are a member, lets update thier last post
|
||||
// date and increment their post count.
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$pcount = "";
|
||||
$this->class->pf_increment_user_post_count();
|
||||
|
||||
if ($ibforums->member['id'])
|
||||
//-----------------------------------------
|
||||
// Moderating?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->class->obj['moderate'] == 1 OR $this->class->obj['moderate'] == 2 )
|
||||
{
|
||||
if ($class->forum['inc_postcount'])
|
||||
{
|
||||
// Increment the users post count
|
||||
|
||||
$pcount = "posts=posts+1, ";
|
||||
|
||||
}
|
||||
//-----------------------------------------
|
||||
// Redirect them with a message telling them the
|
||||
// post has to be previewed first
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->notify_new_topic_approval( $this->topic['tid'], $this->topic['title'], $this->topic['starter_name'] );
|
||||
|
||||
// Are we checking for auto promotion?
|
||||
|
||||
if ($ibforums->member['g_promotion'] != '-1&-1')
|
||||
{
|
||||
list($gid, $gposts) = explode( '&', $ibforums->member['g_promotion'] );
|
||||
|
||||
if ( $gid > 0 and $gposts > 0 )
|
||||
{
|
||||
if ( $ibforums->member['posts'] + 1 >= $gposts )
|
||||
{
|
||||
$mgroup = "mgroup='$gid', ";
|
||||
|
||||
if ( USE_MODULES == 1 )
|
||||
{
|
||||
$class->modules->register_class(&$class);
|
||||
$class->modules->on_group_change($ibforums->member['id'], $gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ibforums->member['last_post'] = time();
|
||||
|
||||
$DB->query("UPDATE ibf_members SET ".$pcount.$mgroup.
|
||||
"last_post='" .$ibforums->member['last_post'] ."'".
|
||||
"WHERE id='" .$ibforums->member['id']."'");
|
||||
$print->redirect_screen( $ibforums->lang['moderate_topic'], "act=SF&f={$this->class->forum['id']}" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Set a last post time cookie
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Are we tracking new topics we start 'auto_track'?
|
||||
//-----------------------------------------
|
||||
|
||||
$std->my_setcookie( "LPid", time() );
|
||||
$this->class->pf_add_tracked_topic($this->topic['tid']);
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Are we tracking this forum? If so generate some mailies - yay!
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->forum_tracker($this->class->forum['id'], $this->topic['tid'], $this->topic['title'], $this->class->forum['name'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// 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($this->class->base_url."act=ST&f={$this->class->forum['id']}&t={$this->topic['tid']}");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// SHOW FORM
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
function show_form($class) {
|
||||
|
||||
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
|
||||
function show_form()
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we quoting posts?
|
||||
//-----------------------------------------
|
||||
|
||||
$raw_post = $this->class->check_multi_quote();
|
||||
|
||||
//-----------------------------------------
|
||||
// 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']) ? $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'])) : "";
|
||||
$topic_title = isset($_POST['TopicTitle']) ? $ibforums->input['TopicTitle'] : "";
|
||||
$topic_desc = isset($_POST['TopicDesc']) ? $ibforums->input['TopicDesc'] : "";
|
||||
|
||||
if (isset($raw_post))
|
||||
{
|
||||
$raw_post = $std->txt_raw2form($raw_post);
|
||||
$raw_post = str_replace( '<%', "<%" , $raw_post );
|
||||
|
||||
}
|
||||
$poll = isset($_POST['PollAnswers']) ? $std->txt_htmlspecialchars($std->txt_stripslashes($_POST['PollAnswers'])) : "";
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have any posting errors?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($class->obj['post_errors'])
|
||||
if ($this->class->obj['post_errors'])
|
||||
{
|
||||
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
|
||||
$this->class->output .= $this->class->html->errors( $ibforums->lang[ $this->class->obj['post_errors'] ]);
|
||||
}
|
||||
|
||||
if ($class->obj['preview_post'])
|
||||
if ($this->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'] );
|
||||
$this->class->parser->pp_do_html = intval($ibforums->input['post_htmlstatus']) AND $this->class->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0;
|
||||
$this->class->parser->pp_nl2br = $ibforums->input['post_htmlstatus'] == 2 ? 1 : 0;
|
||||
|
||||
$this->post['post'] = $this->class->parser->post_db_parse(
|
||||
$this->class->parser->convert( array(
|
||||
'TEXT' => $this->post['post'],
|
||||
'CODE' => $this->class->forum['use_ibc'],
|
||||
'SMILIES' => $ibforums->input['enableemo'],
|
||||
'HTML' => $this->class->forum['use_html']
|
||||
) )
|
||||
);
|
||||
$this->class->output .= $this->class->html->preview( $this->post['post'] );
|
||||
}
|
||||
|
||||
$extra = "";
|
||||
@@ -432,82 +462,86 @@ class post_functions extends Post {
|
||||
$extra = $ibforums->lang['poll_tag_allowed'];
|
||||
}
|
||||
|
||||
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '11' ), 2 => array( 'f', $class->forum['id']) ) );
|
||||
$this->class->output .= $this->class->html_start_form( array( 1 => array( 'CODE', '11' ),
|
||||
2 => array( 'f', $this->class->forum['id']),
|
||||
3 => array( 'post_key', $this->post_key ),
|
||||
) );
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
// START TABLE
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->output .= $class->html->table_structure();
|
||||
$this->class->output .= $this->class->html->table_structure();
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$topic_title = $class->html->topictitle_fields( array( TITLE => $topic_title, DESC => $topic_desc ) );
|
||||
$topic_title = $this->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 = $this->class->html->table_top( "{$ibforums->lang['top_txt_poll']}: {$this->class->forum['name']}");
|
||||
|
||||
$name_fields = $class->html_name_field();
|
||||
$name_fields = $this->class->html_name_field();
|
||||
|
||||
$post_box = $class->html_post_body( $raw_post );
|
||||
$post_box = $this->class->html_post_body( $raw_post );
|
||||
|
||||
$mod_options = $class->mod_options();
|
||||
$mod_options = $this->class->mod_options();
|
||||
|
||||
$poll_box = $class->html->poll_box( $poll, $extra);
|
||||
$poll_box = $this->class->html->poll_box( $poll, $extra);
|
||||
|
||||
$end_form = $class->html->EndForm( $ibforums->lang['submit_poll'] );
|
||||
$end_form = $this->class->html->EndForm( $ibforums->lang['submit_poll'] );
|
||||
|
||||
$post_icons = $class->html_post_icons();
|
||||
$post_icons = $this->class->html_post_icons();
|
||||
|
||||
if ($class->obj['can_upload'])
|
||||
if ($this->class->can_upload)
|
||||
{
|
||||
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
|
||||
$upload_field = $this->class->html_build_uploads($this->post_key,'new');
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$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 );
|
||||
$this->class->output = str_replace( "<!--POLL BOX-->" , $poll_box , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--START TABLE-->" , $start_table , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--NAME FIELDS-->" , $name_fields , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--POST BOX-->" , $post_box , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--POST ICONS-->" , $post_icons , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--MOD OPTIONS-->" , $mod_options , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--END TABLE-->" , $end_form , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--TOPIC TITLE-->" , $topic_title , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--FORUM RULES-->" , $std->print_forum_rules($this->class->forum), $this->class->output );
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->html_add_smilie_box();
|
||||
|
||||
if ( $ibforums->vars['poll_disable_noreply'] != 1 )
|
||||
{
|
||||
$class->output = str_replace("<!--IBF.POLL_OPTIONS-->", $class->html->poll_options(), $class->output );
|
||||
$this->class->output = str_replace("<!--IBF.POLL_OPTIONS-->", $this->class->html->poll_options(), $this->class->output );
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
// Add in siggy buttons and such
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->html_checkboxes();
|
||||
$this->class->html_checkboxes('new', 0, $this->class->forum['id']);
|
||||
|
||||
$this->class->output = $this->class->html_add_smilie_box( $this->class->output );
|
||||
|
||||
$class->html_add_smilie_box();
|
||||
|
||||
$this->nav = array( "<a href='{$class->base_url}act=SC&c={$class->forum['cat_id']}'>{$class->forum['cat_name']}</a>",
|
||||
"<a href='{$class->base_url}act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
|
||||
);
|
||||
$this->title = $ibforums->lang['posting_new_topic'];
|
||||
|
||||
$print->add_output("$class->output");
|
||||
$print->add_output( $this->class->output );
|
||||
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
|
||||
'JS' => 1,
|
||||
'NAV' => $this->nav,
|
||||
'NAV' => $this->class->nav,
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
function regex_count_choices() {
|
||||
function regex_count_choices()
|
||||
{
|
||||
|
||||
++$this->poll_count;
|
||||
|
||||
return "<br>";
|
||||
return "<br />";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > New Post module
|
||||
| > Module written by Matt Mecham
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,21 +37,21 @@ 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'] );
|
||||
$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'])
|
||||
{
|
||||
@@ -76,7 +76,8 @@ class post_functions extends Post {
|
||||
{
|
||||
$tid = intval($ibforums->input['t']);
|
||||
|
||||
$DB->query("SELECT * from ibf_topics WHERE tid=$tid");
|
||||
$DB->simple_construct( array('select' => '*', 'from' => 'topics', 'where' => "tid=$tid") );
|
||||
$DB->simple_exec();
|
||||
|
||||
if ( ! $this->topic = $DB->fetch_row() )
|
||||
{
|
||||
@@ -108,18 +109,17 @@ class post_functions extends Post {
|
||||
}
|
||||
|
||||
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 /><br />#" , "" , $this->poll_choices );
|
||||
|
||||
$this->poll_choices = preg_replace( "/<br>/e" , "\$this->regex_count_choices()" , $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'])
|
||||
{
|
||||
@@ -149,19 +149,18 @@ class post_functions extends Post {
|
||||
|
||||
|
||||
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 );
|
||||
$polls = explode( "<br />", $this->poll_choices );
|
||||
|
||||
foreach ($polls as $polling)
|
||||
{
|
||||
@@ -174,43 +173,37 @@ class post_functions extends Post {
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// 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->do_insert( 'polls',
|
||||
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']}");
|
||||
|
||||
//-------------------------------------------------
|
||||
$DB->simple_construct( array( 'update' => 'topics', 'set' => 'poll_state="open"', 'where' => "tid={$this->topic['tid']}" ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
//-----------------------------------------
|
||||
// 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."showtopic={$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
|
||||
@@ -227,13 +220,13 @@ class post_functions extends Post {
|
||||
|
||||
$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']);
|
||||
|
||||
@@ -241,7 +234,7 @@ class post_functions extends Post {
|
||||
|
||||
$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 );
|
||||
@@ -254,7 +247,7 @@ class post_functions extends Post {
|
||||
$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();
|
||||
@@ -268,7 +261,7 @@ class post_functions extends Post {
|
||||
$print->add_output("$class->output");
|
||||
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
|
||||
'JS' => 1,
|
||||
'NAV' => $this->nav,
|
||||
'NAV' => $class->nav,
|
||||
) );
|
||||
|
||||
}
|
||||
@@ -277,7 +270,7 @@ class post_functions extends Post {
|
||||
|
||||
++$this->poll_count;
|
||||
|
||||
return "<br>";
|
||||
return "<br />";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,546 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Reply with quote library
|
||||
| > Module written by Matt Mecham
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class post_functions extends Post {
|
||||
|
||||
var $nav = array();
|
||||
var $title = "";
|
||||
var $post = array();
|
||||
var $topic = array();
|
||||
var $upload = array();
|
||||
var $mod_topic = array();
|
||||
var $quoted_post = array();
|
||||
var $quoted_post_author = array();
|
||||
|
||||
var $m_group = "";
|
||||
|
||||
function post_functions($class) {
|
||||
|
||||
global $ibforums, $std, $DB;
|
||||
|
||||
// Lets load the topic from the database before we do anything else.
|
||||
|
||||
$DB->query("SELECT * FROM ibf_topics WHERE forum_id='".$class->forum['id']."' AND tid='".$ibforums->input['t']."'");
|
||||
$this->topic = $DB->fetch_row();
|
||||
|
||||
// Is it legitimate?
|
||||
|
||||
if (! $this->topic['tid'])
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Lets do some tests to make sure that we are
|
||||
// allowed to reply to this topic
|
||||
//-------------------------------------------------
|
||||
|
||||
if ($this->topic['poll_state'] == 'closed' and $ibforums->member['g_is_supadmin'] != 1)
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
|
||||
if ($this->topic['starter_id'] == $ibforums->member['id'])
|
||||
{
|
||||
if (! $ibforums->member['g_reply_own_topics'])
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->topic['starter_id'] != $ibforums->member['id'])
|
||||
{
|
||||
if (! $ibforums->member['g_reply_other_topics'])
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $std->check_perms($class->forum['reply_perms']) == FALSE )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
|
||||
// Is the topic locked?
|
||||
|
||||
if ($this->topic['state'] != 'open')
|
||||
{
|
||||
if ($ibforums->member['g_post_closed'] != 1)
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function process($class) {
|
||||
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Parse the post, and check for any errors.
|
||||
//-------------------------------------------------
|
||||
|
||||
$this->post = $class->compile_post();
|
||||
|
||||
//-------------------------------------------------
|
||||
// If we have a post to quote, lets sort that now
|
||||
//-------------------------------------------------
|
||||
|
||||
if ($ibforums->input['QPost'])
|
||||
{
|
||||
|
||||
$this->quoted_post['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' => $ibforums->input['enableemo'],
|
||||
'CODE' => 1,
|
||||
'HTML' => 0,
|
||||
) );
|
||||
|
||||
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
|
||||
|
||||
$html = $class->parser->wrap_style( array( 'STYLE' => 'QUOTE',
|
||||
'EXTRA' => '(' . $this->quoted_post['AUTHOR']['name'] . ' @ ' . $this->quoted_post['DATE'] . ')'
|
||||
) );
|
||||
if ( $class->obj['preview_post'] == "" )
|
||||
{
|
||||
$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
|
||||
{
|
||||
$class->dump_quote = '[QUOTE='.$this->quoted_post['AUTHOR']['name'].','.$this->quoted_post['DATE'].']'.$ibforums->input['QPost'].'[/QUOTE]'."\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($class->obj['post_errors'] == "")
|
||||
{
|
||||
$this->upload = $class->process_upload();
|
||||
}
|
||||
|
||||
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
|
||||
{
|
||||
// Show the form again
|
||||
|
||||
$this->show_form($class);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->add_reply($class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function add_reply($class) {
|
||||
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Update the post info with the upload array info
|
||||
//-------------------------------------------------
|
||||
|
||||
$this->post['attach_id'] = $this->upload['attach_id'];
|
||||
$this->post['attach_type'] = $this->upload['attach_type'];
|
||||
$this->post['attach_hits'] = $this->upload['attach_hits'];
|
||||
$this->post['attach_file'] = $this->upload['attach_file'];
|
||||
|
||||
//-------------------------------------------------
|
||||
// Insert the post into the database to get the
|
||||
// last inserted value of the auto_increment field
|
||||
//-------------------------------------------------
|
||||
|
||||
$this->post['topic_id'] = $this->topic['tid'];
|
||||
|
||||
$return_to_move = 0;
|
||||
|
||||
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
|
||||
{
|
||||
if ($ibforums->input['mod_options'] == 'pin')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
|
||||
{
|
||||
$this->topic['pinned'] = 1;
|
||||
|
||||
$class->moderate_log('Pinned topic from post form', $this->topic['title']);
|
||||
}
|
||||
}
|
||||
else if ($ibforums->input['mod_options'] == 'close')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
|
||||
{
|
||||
$this->topic['state'] = 'closed';
|
||||
|
||||
$class->moderate_log('Closed topic from post form', $this->topic['title']);
|
||||
}
|
||||
}
|
||||
else if ($ibforums->input['mod_options'] == 'move')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['move_topic'] == 1)
|
||||
{
|
||||
$return_to_move = 1;
|
||||
}
|
||||
}
|
||||
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->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'] == 1 or $class->obj['moderate'] == 3 )
|
||||
{
|
||||
$DB->query("UPDATE ibf_forums SET has_mod_posts=1 WHERE id=".$class->forum['id']);
|
||||
|
||||
$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" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// If we are still here, lets update the
|
||||
// board/forum/topic stats
|
||||
//-------------------------------------------------
|
||||
|
||||
$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']++;
|
||||
|
||||
// Update the database
|
||||
|
||||
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
|
||||
"last_id='" .$class->forum['last_id'] ."', ".
|
||||
"last_post='" .$class->forum['last_post'] ."', ".
|
||||
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
|
||||
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
|
||||
"posts='" .$class->forum['posts'] ."' ".
|
||||
"WHERE id='" .$class->forum['id'] ."'");
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// 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 );
|
||||
|
||||
//+------------------------------------------------------------------------------------------------------
|
||||
|
||||
$DB->query("UPDATE ibf_topics SET last_poster_id='" .$class->forum['last_poster_id'] ."', ".
|
||||
"last_poster_name='" .$class->forum['last_poster_name'] ."', ".
|
||||
"last_post='" .$class->forum['last_post'] ."', ".
|
||||
"pinned='" .$this->topic['pinned'] ."', ".
|
||||
"state='" .$this->topic['state'] ."', ".
|
||||
"posts=$pcount ".
|
||||
"WHERE tid='" .$this->topic['tid'] ."'");
|
||||
|
||||
//+------------------------------------------------------------------------------------------------------
|
||||
|
||||
$DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES+1");
|
||||
|
||||
//-------------------------------------------------
|
||||
// If we are a member, lets update thier last post
|
||||
// date and increment their post count.
|
||||
//-------------------------------------------------
|
||||
|
||||
$pcount = "";
|
||||
|
||||
if ($ibforums->member['id'])
|
||||
{
|
||||
if ($class->forum['inc_postcount'])
|
||||
{
|
||||
// Increment the users post count
|
||||
|
||||
$pcount = "posts=posts+1, ";
|
||||
|
||||
}
|
||||
|
||||
// Are we checking for auto promotion?
|
||||
|
||||
if ($ibforums->member['g_promotion'] != '-1&-1')
|
||||
{
|
||||
list($gid, $gposts) = explode( '&', $ibforums->member['g_promotion'] );
|
||||
|
||||
if ( $gid > 0 and $gposts > 0 )
|
||||
{
|
||||
if ( $ibforums->member['posts'] + 1 >= $gposts )
|
||||
{
|
||||
$mgroup = "mgroup='$gid', ";
|
||||
|
||||
if ( USE_MODULES == 1 )
|
||||
{
|
||||
$class->modules->register_class(&$class);
|
||||
$class->modules->on_group_change($ibforums->member['id'], $gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ibforums->member['last_post'] = time();
|
||||
|
||||
$DB->query("UPDATE ibf_members SET ".$pcount.$mgroup.
|
||||
"last_post='" .$ibforums->member['last_post'] ."'".
|
||||
"WHERE id='" .$ibforums->member['id']."'");
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Are we tracking topics we reply in 'auto_track'?
|
||||
//-------------------------------------------------
|
||||
|
||||
if ( $ibforums->member['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']."'");
|
||||
|
||||
if ( ! $DB->get_num_rows() )
|
||||
{
|
||||
$db_string = $DB->compile_db_insert_string( array (
|
||||
'member_id' => $ibforums->member['id'],
|
||||
'topic_id' => $this->topic['tid'],
|
||||
'start_date' => time(),
|
||||
) );
|
||||
|
||||
$DB->query("INSERT INTO ibf_tracker ({$db_string['FIELD_NAMES']}) VALUES ({$db_string['FIELD_VALUES']})");
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Check for subscribed topics
|
||||
// Pass on the previous last post time of the topic
|
||||
// to see if we need to send emails out
|
||||
//-------------------------------------------------
|
||||
|
||||
$class->topic_tracker( $this->topic['tid'], $this->post['post'], $class->forum['last_poster_name'], $this->topic['last_post'] );
|
||||
|
||||
//-------------------------------------------------
|
||||
// Redirect them back to the topic
|
||||
//-------------------------------------------------
|
||||
|
||||
if ($return_to_move == 1)
|
||||
{
|
||||
$std->boink_it($class->base_url."act=Mod&CODE=02&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
|
||||
$page = $page * $ibforums->vars['display_max_posts'];
|
||||
$std->boink_it($class->base_url."showtopic={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function show_form($class) {
|
||||
|
||||
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Sort out the "raw" textarea input and make it safe incase
|
||||
// we have a <textarea> tag in the raw post var.
|
||||
//-------------------------------------------------
|
||||
|
||||
$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 = $std->txt_raw2form($raw_post);
|
||||
|
||||
if ($class->dump_quote != "")
|
||||
{
|
||||
$raw_post = str_replace( "<br>", "\n", $class->dump_quote ) . $raw_post;
|
||||
$quote_post = str_replace( "<br>", "\n", $class->dump_quote ) . $quote_post;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Get the old post
|
||||
//-------------------------------------------------
|
||||
|
||||
$DB->query("SELECT post, author_id, author_name, post_date, pid FROM ibf_posts WHERE pid='".$ibforums->input['p']."'");
|
||||
$this->quoted_post = $DB->fetch_row();
|
||||
|
||||
//-------------------------------------------------
|
||||
// Unconvert the smilies, HTML and iB_Code
|
||||
//-------------------------------------------------
|
||||
|
||||
$this->quoted_post['post'] = trim($class->parser->unconvert( $this->quoted_post['post'] ));
|
||||
|
||||
//-------------------------------------------------
|
||||
// Are we stripping quotes?
|
||||
//-------------------------------------------------
|
||||
|
||||
if ($ibforums->vars['strip_quotes'])
|
||||
{
|
||||
$this->quoted_post['post'] = preg_replace( "#\[QUOTE(=.+?,.+?)?\].+?\[/QUOTE\]#is", "", $this->quoted_post['post'] );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Do we have any posting errors?
|
||||
//-------------------------------------------------
|
||||
|
||||
if ($class->obj['post_errors'])
|
||||
{
|
||||
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
|
||||
}
|
||||
|
||||
if ($class->obj['preview_post'])
|
||||
{
|
||||
$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();
|
||||
|
||||
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '07' ),
|
||||
2 => array( 't' , $this->topic['tid']),
|
||||
3 => array( 'p' , $ibforums->input['p'] )
|
||||
) );
|
||||
//---------------------------------------
|
||||
// START TABLE
|
||||
//---------------------------------------
|
||||
|
||||
$class->output .= $class->html->table_structure();
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
|
||||
|
||||
$name_fields = $class->html_name_field();
|
||||
|
||||
if (! $class->obj['preview_post'])
|
||||
{
|
||||
$quote_box = $class->html->quote_box( $this->quoted_post );
|
||||
}
|
||||
|
||||
$post_box = $class->html_post_body( $raw_post );
|
||||
|
||||
$mod_options = $class->mod_options(1);
|
||||
|
||||
$end_form = $class->html->EndForm( $ibforums->lang['submit_reply'] );
|
||||
|
||||
$post_icons = $class->html_post_icons();
|
||||
|
||||
if ($class->obj['can_upload'])
|
||||
{
|
||||
$upload_field = $class->html->Upload_field( $std->size_format( $ibforums->member['g_attach_max'] * 1024 ) );
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
|
||||
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
|
||||
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
|
||||
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
|
||||
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
|
||||
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
|
||||
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
|
||||
$class->output = preg_replace( "/<!--QUOTE BOX-->/" , "$quote_box" , $class->output );
|
||||
$class->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}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'];
|
||||
|
||||
$print->add_output("$class->output");
|
||||
|
||||
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
|
||||
'JS' => 1,
|
||||
'NAV' => $this->nav,
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -2,21 +2,21 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Reply post module
|
||||
| > Module written by Matt Mecham
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -24,92 +24,102 @@
|
||||
|
||||
class post_functions extends Post {
|
||||
|
||||
var $nav = array();
|
||||
var $title = "";
|
||||
var $post = array();
|
||||
var $topic = array();
|
||||
var $upload = array();
|
||||
var $mod_topic = array();
|
||||
var $nav = array();
|
||||
var $title = "";
|
||||
var $post = array();
|
||||
var $topic = array();
|
||||
var $upload = array();
|
||||
var $mod_topic = array();
|
||||
var $class = "";
|
||||
var $m_group = "";
|
||||
var $post_key = "";
|
||||
var $quote_pids = array();
|
||||
var $quote_posts = array();
|
||||
|
||||
var $m_group = "";
|
||||
|
||||
function post_functions($class) {
|
||||
|
||||
global $ibforums, $std, $DB;
|
||||
function post_functions($class)
|
||||
{
|
||||
global $ibforums, $std, $DB, $forums;
|
||||
|
||||
$this->class = $class;
|
||||
|
||||
$this->post_key = $ibforums->input['post_key'] ? $ibforums->input['post_key'] : md5(microtime());
|
||||
|
||||
//-----------------------------------------
|
||||
// Lets load the topic from the database before we do anything else.
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'where' => "forum_id=".intval($this->class->forum['id'])." AND tid=".intval($ibforums->input['t']) ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
$DB->query("SELECT * FROM ibf_topics WHERE forum_id='".$class->forum['id']."' AND tid='".$ibforums->input['t']."'");
|
||||
$this->topic = $DB->fetch_row();
|
||||
|
||||
// Is it legitimate?
|
||||
//-----------------------------------------
|
||||
// Check permissions, etc
|
||||
//-----------------------------------------
|
||||
|
||||
if (! $this->topic['tid'])
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Lets do some tests to make sure that we are
|
||||
// allowed to reply to this topic
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($this->topic['poll_state'] == 'closed' and $ibforums->member['g_is_supadmin'] != 1)
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
$this->class->check_for_reply($this->topic);
|
||||
|
||||
if ($this->topic['starter_id'] == $ibforums->member['id'])
|
||||
{
|
||||
if (! $ibforums->member['g_reply_own_topics'])
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->topic['starter_id'] != $ibforums->member['id'])
|
||||
{
|
||||
if (! $ibforums->member['g_reply_other_topics'])
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $std->check_perms($class->forum['reply_perms']) == FALSE )
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
|
||||
}
|
||||
|
||||
// Is the topic locked?
|
||||
|
||||
if ($this->topic['state'] != 'open')
|
||||
{
|
||||
if ($ibforums->member['g_post_closed'] != 1)
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function process($class) {
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// MAIN PROCESS FUNCTION
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function process()
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Parse the post, and check for any errors.
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Did we remove an attachment?
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post = $class->compile_post();
|
||||
|
||||
if ($class->obj['post_errors'] == "")
|
||||
if ( $ibforums->input['removeattachid'] )
|
||||
{
|
||||
$this->upload = $class->process_upload();
|
||||
if ( $ibforums->input[ 'removeattach_'. $ibforums->input['removeattachid'] ] )
|
||||
{
|
||||
$this->class->pf_remove_attachment( intval($ibforums->input['removeattachid']), $this->post_key );
|
||||
$this->show_form();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
|
||||
//-----------------------------------------
|
||||
// Did we add an attachment?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->input['attachgo'] )
|
||||
{
|
||||
$this->class->obj['post_errors'] = "";
|
||||
$this->upload_id = $this->class->process_upload();
|
||||
$this->show_form();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Parse the post, and check for any errors.
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post = $this->class->compile_post();
|
||||
|
||||
if ($this->class->obj['post_errors'] == "")
|
||||
{
|
||||
$this->upload = $this->class->process_upload();
|
||||
}
|
||||
|
||||
if ( ($this->class->obj['post_errors'] != "") or ($this->class->obj['preview_post'] != "") )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Show the form again
|
||||
//-----------------------------------------
|
||||
|
||||
$this->show_form($class);
|
||||
}
|
||||
else
|
||||
@@ -119,32 +129,34 @@ class post_functions extends Post {
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// ADD THE REPLY
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
function add_reply($class) {
|
||||
|
||||
function add_reply()
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Update the post info with the upload array info
|
||||
//-------------------------------------------------
|
||||
|
||||
$this->post['attach_id'] = $this->upload['attach_id'];
|
||||
$this->post['attach_type'] = $this->upload['attach_type'];
|
||||
$this->post['attach_hits'] = $this->upload['attach_hits'];
|
||||
$this->post['attach_file'] = $this->upload['attach_file'];
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Insert the post into the database to get the
|
||||
// last inserted value of the auto_increment field
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post['topic_id'] = $this->topic['tid'];
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Get the last post time of this topic not counting
|
||||
// this new reply
|
||||
//-----------------------------------------
|
||||
|
||||
$this->last_post = $this->topic['last_post'];
|
||||
|
||||
//die( $this->last_post .' - '.$ibforums->member['last_activity'] . ' l');
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we a mod, and can we change the topic state?
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$return_to_move = 0;
|
||||
|
||||
@@ -152,50 +164,134 @@ class post_functions extends Post {
|
||||
{
|
||||
if ($ibforums->input['mod_options'] == 'pin')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $this->class->moderator['pin_topic'] == 1)
|
||||
{
|
||||
$this->topic['pinned'] = 1;
|
||||
|
||||
$class->moderate_log('Pinned topic from post form', $this->topic['title']);
|
||||
$this->class->moderate_log('Pinned topic from post form', $this->topic['title']);
|
||||
}
|
||||
}
|
||||
else if ($ibforums->input['mod_options'] == 'close')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $this->class->moderator['close_topic'] == 1)
|
||||
{
|
||||
$this->topic['state'] = 'closed';
|
||||
|
||||
$class->moderate_log('Closed topic from post form', $this->topic['title']);
|
||||
$this->class->moderate_log('Closed topic from post form', $this->topic['title']);
|
||||
}
|
||||
}
|
||||
else if ($ibforums->input['mod_options'] == 'move')
|
||||
{
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['move_topic'] == 1)
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or $this->class->moderator['move_topic'] == 1)
|
||||
{
|
||||
$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 ) )
|
||||
if ($ibforums->member['g_is_supmod'] == 1 or ( $this->class->moderator['pin_topic'] == 1 AND $this->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']);
|
||||
$this->class->moderate_log('Pinned & closed topic from post form', $this->topic['title']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db_string = $DB->compile_db_insert_string( $this->post );
|
||||
//-----------------------------------------
|
||||
// Add post to DB
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
|
||||
$this->post['post_key'] = $this->post_key;
|
||||
$this->post['post_parent'] = intval($ibforums->input['parent_id']);
|
||||
|
||||
//-----------------------------------------
|
||||
// Typecast
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->force_data_type = array( 'pid' => 'int',
|
||||
'post' => 'string' );
|
||||
|
||||
$DB->do_insert( 'posts', $this->post );
|
||||
|
||||
$this->post['pid'] = $DB->get_insert_id();
|
||||
|
||||
if ( $class->obj['moderate'] == 1 or $class->obj['moderate'] == 3 )
|
||||
//-----------------------------------------
|
||||
// If we are still here, lets update the
|
||||
// board/forum/topic stats
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->pf_update_forum_and_stats($this->topic['tid'], $this->topic['title'], 'reply');
|
||||
|
||||
//-----------------------------------------
|
||||
// Get the correct number of replies
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->simple_construct( array( 'select' => 'COUNT(*) as posts', 'from' => 'posts', 'where' => "topic_id={$this->topic['tid']} and queued != 1" ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
$posts = $DB->fetch_row();
|
||||
|
||||
$pcount = intval( $posts['posts'] - 1 );
|
||||
|
||||
//-----------------------------------------
|
||||
// Get the correct number of queued replies
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->simple_construct( array( 'select' => 'COUNT(*) as posts', 'from' => 'posts', 'where' => "topic_id={$this->topic['tid']} and queued=1" ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
$qposts = $DB->fetch_row();
|
||||
|
||||
$qpcount = intval( $qposts['posts'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// UPDATE TOPIC
|
||||
//-----------------------------------------
|
||||
|
||||
$poster_name = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
|
||||
|
||||
$update_array = array(
|
||||
'posts' => $pcount,
|
||||
'topic_queuedposts'=> $qpcount
|
||||
);
|
||||
|
||||
if ( $this->class->obj['moderate'] != 1 and $this->class->obj['moderate'] != 3 )
|
||||
{
|
||||
$update_array['last_poster_id'] = $ibforums->member['id'];
|
||||
$update_array['last_poster_name'] = $poster_name;
|
||||
$update_array['last_post'] = time();
|
||||
$update_array['pinned'] = $this->topic['pinned'];
|
||||
$update_array['state'] = $this->topic['state'];
|
||||
}
|
||||
|
||||
$DB->do_update( 'topics', $update_array, "tid={$this->topic['tid']}" );
|
||||
|
||||
//-----------------------------------------
|
||||
// If we are a member, lets update thier last post
|
||||
// date and increment their post count.
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->pf_increment_user_post_count();
|
||||
|
||||
//-----------------------------------------
|
||||
// Make attachments "permanent"
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->pf_make_attachments_permanent($this->post_key, $this->topic['tid'], $this->post['pid']);
|
||||
|
||||
//-----------------------------------------
|
||||
// Moderating?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->class->obj['moderate'] == 1 or $this->class->obj['moderate'] == 3 )
|
||||
{
|
||||
$DB->query("UPDATE ibf_forums SET has_mod_posts=1 WHERE id=".$class->forum['id']);
|
||||
//-----------------------------------------
|
||||
// Boing!!!
|
||||
//-----------------------------------------
|
||||
|
||||
$this->class->notify_new_topic_approval( $this->topic['tid'], $this->topic['title'], $this->topic['starter_name'], $this->post['pid'], 'reply' );
|
||||
|
||||
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
|
||||
$page = $page * $ibforums->vars['display_max_posts'];
|
||||
@@ -203,250 +299,150 @@ class post_functions extends Post {
|
||||
$print->redirect_screen( $ibforums->lang['moderate_post'], "showtopic={$this->topic['tid']}&st=$page" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// If we are still here, lets update the
|
||||
// board/forum/topic stats
|
||||
//-------------------------------------------------
|
||||
|
||||
$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']++;
|
||||
|
||||
// Update the database
|
||||
|
||||
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
|
||||
"last_id='" .$class->forum['last_id'] ."', ".
|
||||
"last_post='" .$class->forum['last_post'] ."', ".
|
||||
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
|
||||
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
|
||||
"posts='" .$class->forum['posts'] ."' ".
|
||||
"WHERE id='" .$class->forum['id'] ."'");
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// 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 );
|
||||
|
||||
//+------------------------------------------------------------------------------------------------------
|
||||
|
||||
$DB->query("UPDATE ibf_topics SET last_poster_id='" .$class->forum['last_poster_id'] ."', ".
|
||||
"last_poster_name='" .$class->forum['last_poster_name'] ."', ".
|
||||
"last_post='" .$class->forum['last_post'] ."', ".
|
||||
"pinned='" .$this->topic['pinned'] ."', ".
|
||||
"state='" .$this->topic['state'] ."', ".
|
||||
"posts=$pcount ".
|
||||
"WHERE tid='" .$this->topic['tid'] ."'");
|
||||
|
||||
//+------------------------------------------------------------------------------------------------------
|
||||
|
||||
$DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES+1");
|
||||
|
||||
//-------------------------------------------------
|
||||
// If we are a member, lets update thier last post
|
||||
// date and increment their post count.
|
||||
//-------------------------------------------------
|
||||
|
||||
$pcount = "";
|
||||
$mgroup = "";
|
||||
|
||||
if ($ibforums->member['id'])
|
||||
{
|
||||
if ($class->forum['inc_postcount'])
|
||||
{
|
||||
// Increment the users post count
|
||||
$pcount = "posts=posts+1, ";
|
||||
}
|
||||
|
||||
// Are we checking for auto promotion?
|
||||
|
||||
if ($ibforums->member['g_promotion'] != '-1&-1')
|
||||
{
|
||||
list($gid, $gposts) = explode( '&', $ibforums->member['g_promotion'] );
|
||||
|
||||
if ( $gid > 0 and $gposts > 0 )
|
||||
{
|
||||
if ( $ibforums->member['posts'] + 1 >= $gposts )
|
||||
{
|
||||
$mgroup = "mgroup='$gid', ";
|
||||
|
||||
if ( USE_MODULES == 1 )
|
||||
{
|
||||
$class->modules->register_class(&$class);
|
||||
$class->modules->on_group_change($ibforums->member['id'], $gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ibforums->member['last_post'] = time();
|
||||
|
||||
$DB->query("UPDATE ibf_members SET ".$pcount.$mgroup.
|
||||
"last_post='" .$ibforums->member['last_post'] ."'".
|
||||
"WHERE id='" .$ibforums->member['id']."'");
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Are we tracking topics we reply in 'auto_track'?
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->member['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']."'");
|
||||
|
||||
if ( ! $DB->get_num_rows() )
|
||||
{
|
||||
$db_string = $DB->compile_db_insert_string( array (
|
||||
'member_id' => $ibforums->member['id'],
|
||||
'topic_id' => $this->topic['tid'],
|
||||
'start_date' => time(),
|
||||
) );
|
||||
|
||||
$DB->query("INSERT INTO ibf_tracker ({$db_string['FIELD_NAMES']}) VALUES ({$db_string['FIELD_VALUES']})");
|
||||
}
|
||||
}
|
||||
$this->class->pf_add_tracked_topic($this->topic['tid'], 1);
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Check for subscribed topics
|
||||
// Pass on the previous last post time of the topic
|
||||
// to see if we need to send emails out
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->topic_tracker( $this->topic['tid'], $this->post['post'], $class->forum['last_poster_name'], $this->topic['last_post'] );
|
||||
$this->class->topic_tracker( $this->topic['tid'], $this->post['post'], $poster_name, $this->last_post );
|
||||
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Redirect them back to the topic
|
||||
//-------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($return_to_move == 1)
|
||||
{
|
||||
$std->boink_it($class->base_url."act=Mod&CODE=02&f={$class->forum['id']}&t={$this->topic['tid']}");
|
||||
$std->boink_it($this->class->base_url."act=Mod&CODE=02&f={$this->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."showtopic={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
|
||||
$std->boink_it($ibforums->base_url."showtopic={$this->topic['tid']}&st=$page&p={$this->post['pid']}&#entry{$this->post['pid']}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// SHOW FORM
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
function show_form($class) {
|
||||
|
||||
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
|
||||
function show_form()
|
||||
{
|
||||
global $ibforums, $std, $DB, $print, $forums;
|
||||
|
||||
// Sort out the "raw" textarea input and make it safe incase
|
||||
// we have a <textarea> tag in the raw post var.
|
||||
//-----------------------------------------
|
||||
// Are we quoting posts?
|
||||
//-----------------------------------------
|
||||
|
||||
$raw_post = isset($HTTP_POST_VARS['Post']) ? $std->txt_htmlspecialchars($HTTP_POST_VARS['Post']) : "";
|
||||
|
||||
if (isset($raw_post))
|
||||
{
|
||||
$raw_post = $std->txt_raw2form($raw_post);
|
||||
}
|
||||
$raw_post = $this->class->check_multi_quote();
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have any posting errors?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($class->obj['post_errors'])
|
||||
if ($this->class->obj['post_errors'])
|
||||
{
|
||||
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
|
||||
$this->class->output .= $this->class->html->errors( $ibforums->lang[ $this->class->obj['post_errors'] ]);
|
||||
}
|
||||
|
||||
if ($class->obj['preview_post'])
|
||||
if ($this->class->obj['preview_post'])
|
||||
{
|
||||
$this->post['post'] = $class->parser->post_db_parse(
|
||||
$class->parser->convert( array(
|
||||
$this->class->parser->pp_do_html = intval($ibforums->input['post_htmlstatus']) AND $this->class->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0;
|
||||
$this->class->parser->pp_nl2br = $ibforums->input['post_htmlstatus'] == 2 ? 1 : 0;
|
||||
|
||||
$this->post['post'] = $this->class->parser->post_db_parse(
|
||||
$this->class->parser->convert( array(
|
||||
'TEXT' => $this->post['post'],
|
||||
'CODE' => $class->forum['use_ibc'],
|
||||
'CODE' => $this->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'] );
|
||||
'HTML' => $this->class->forum['use_html']
|
||||
) )
|
||||
);
|
||||
|
||||
$this->class->output .= $this->class->html->preview( $this->post['post'] );
|
||||
}
|
||||
|
||||
$class->check_upload_ability();
|
||||
|
||||
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '03' ),
|
||||
2 => array( 't' , $this->topic['tid'])
|
||||
) );
|
||||
|
||||
$this->class->output .= $this->class->html_start_form( array( 1 => array( 'CODE' , '03' ),
|
||||
2 => array( 't' , $this->topic['tid'] ),
|
||||
3 => array( 'post_key' , $this->post_key ),
|
||||
4 => array( 'parent_id', $ibforums->input['parent_id'] ),
|
||||
) );
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
// START TABLE
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->output .= $class->html->table_structure();
|
||||
$this->class->output .= $this->class->html->table_structure();
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
|
||||
$start_table = $this->class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
|
||||
|
||||
$name_fields = $class->html_name_field();
|
||||
$name_fields = $this->class->html_name_field();
|
||||
|
||||
$post_box = $class->html_post_body( $raw_post );
|
||||
$post_box = $this->class->html_post_body( $raw_post );
|
||||
|
||||
$mod_options = $class->mod_options(1);
|
||||
$mod_options = $this->class->mod_options(1);
|
||||
|
||||
$end_form = $class->html->EndForm( $ibforums->lang['submit_reply'] );
|
||||
$end_form = $this->class->html->EndForm( $ibforums->lang['submit_reply'] );
|
||||
|
||||
$post_icons = $class->html_post_icons();
|
||||
$post_icons = $this->class->html_post_icons();
|
||||
|
||||
if ($class->obj['can_upload'])
|
||||
if ($this->class->can_upload)
|
||||
{
|
||||
$upload_field = $class->html->Upload_field( $std->size_format( $ibforums->member['g_attach_max'] * 1024 ) );
|
||||
$upload_field = $this->class->html_build_uploads($this->post_key,'reply');
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$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 = str_replace("<!--FORUM RULES-->", $std->print_forum_rules($class->forum), $class->output );
|
||||
$this->class->output = str_replace( "<!--START TABLE-->" , $start_table , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--NAME FIELDS-->" , $name_fields , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--POST BOX-->" , $post_box , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--POST ICONS-->" , $post_icons , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--MOD OPTIONS-->" , $mod_options , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--END TABLE-->" , $end_form , $this->class->output );
|
||||
$this->class->output = str_replace( "<!--FORUM RULES-->" , $std->print_forum_rules($this->class->forum), $this->class->output );
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->html_add_smilie_box();
|
||||
$this->class->output = $this->class->html_add_smilie_box( $this->class->output );
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
// Add in siggy buttons and such
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->html_checkboxes('reply', $this->topic['tid']);
|
||||
$this->class->html_checkboxes('reply', $this->topic['tid'], $this->class->forum['id']);
|
||||
|
||||
//---------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$class->html_topic_summary($this->topic['tid']);
|
||||
$this->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}showforum={$class->forum['id']}'>{$class->forum['name']}</a>",
|
||||
"<a href='{$class->base_url}showtopic={$this->topic['tid']}'>{$this->topic['title']}</a>",
|
||||
$this->nav = array( "<a href='{$this->class->base_url}act=SC&c={$this->class->forum[cat_id]}'>{$this->class->forum['cat_name']}</a>",
|
||||
"<a href='{$this->class->base_url}showforum={$this->class->forum['id']}'>{$this->class->forum['name']}</a>",
|
||||
"<a href='{$this->class->base_url}showtopic={$this->topic['tid']}'>{$this->topic['title']}</a>",
|
||||
);
|
||||
|
||||
$this->title = $ibforums->lang['replying_in'].' '.$this->topic['title'];
|
||||
|
||||
$print->add_output("$class->output");
|
||||
$print->add_output( $this->class->output );
|
||||
|
||||
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
|
||||
'JS' => 1,
|
||||
'NAV' => $this->nav,
|
||||
) );
|
||||
'NAV' => $this->class->nav,
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
@@ -30,34 +29,34 @@ class search_lib extends Search
|
||||
var $parser = "";
|
||||
var $is = "";
|
||||
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function search_lib($that)
|
||||
{
|
||||
global $ibforums, $DB, $std, $print;
|
||||
global $ibforums, $DB, $std, $print;
|
||||
|
||||
$this->is = &$that; // hahaha!
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Simple search
|
||||
//--------------------------------------------
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
function do_simple_search()
|
||||
{
|
||||
global $ibforums, $DB, $std, $HTTP_POST_VARS, $print;
|
||||
global $ibforums, $DB, $std, $HTTP_POST_VARS, $print, $forums;
|
||||
|
||||
if ( ! $ibforums->input['sid'] )
|
||||
{
|
||||
$boolean = "";
|
||||
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
// NEW SEARCH.. Check Keywords..
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->is->mysql_version >= 40010 )
|
||||
{
|
||||
@@ -76,45 +75,79 @@ class search_lib extends Search
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_words') );
|
||||
}
|
||||
|
||||
if (strlen(trim($keywords)) < 4)
|
||||
if (strlen(trim($keywords)) < $ibforums->vars['min_search_word'])
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => 4) );
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Check for filter abuse..
|
||||
//-----------------------------------------
|
||||
|
||||
$tmp = explode( ' ', $keywords );
|
||||
|
||||
foreach( $tmp as $t )
|
||||
{
|
||||
if ( ! $t )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$t = preg_replace( "#[\+\-\*\.]#", "", $t );
|
||||
|
||||
//-----------------------------------------
|
||||
// Allow abc* but not a***
|
||||
//-----------------------------------------
|
||||
|
||||
if ( strlen( $t ) < 3 )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => 4) );
|
||||
}
|
||||
}
|
||||
|
||||
//print $check_keywords; exit();
|
||||
|
||||
//-----------------------------------------
|
||||
// Get forums...
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$forums = $this->is->get_searchable_forums();
|
||||
$myforums = $this->is->get_searchable_forums();
|
||||
|
||||
if ($forums == "")
|
||||
if ($myforums == "")
|
||||
{
|
||||
$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)");
|
||||
$DB->query("SELECT COUNT(*) as dracula
|
||||
FROM ".SQL_PREFIX."posts p
|
||||
LEFT JOIN ".SQL_PREFIX."topics t ON (t.tid=p.topic_id)
|
||||
WHERE t.forum_id IN ($myforums)
|
||||
AND MATCH(p.post) AGAINST ('$check_keywords' $boolean)");
|
||||
|
||||
$count = $DB->fetch_row();
|
||||
|
||||
if ( $count['dracula'] < 1 ) // Tee-hee!
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
$this->output .= $this->is->html->search_error_page($ibforums->input['keywords']);
|
||||
$print->add_output( $this->output );
|
||||
$print->do_output( array( 'TITLE' => $ibforums->lang['g_simple_title'], 'JS' => 0, NAV => array( $ibforums->lang['g_simple_title'] ) ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
// 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
|
||||
$cache = "SELECT MATCH(post) AGAINST ('$check_keywords' $boolean) as score, t.tid, t.posts as topic_posts, t.title as topic_title, t.views, t.forum_id,
|
||||
p.post, p.author_id, p.author_name, p.post_date, p.pid, p.post_htmlstate,m.*, me.*
|
||||
FROM ".SQL_PREFIX."posts p
|
||||
LEFT JOIN ".SQL_PREFIX."topics t on (p.topic_id=t.tid)
|
||||
LEFT JOIN ".SQL_PREFIX."members m on (m.id=p.author_id)
|
||||
LEFT JOIN ".SQL_PREFIX."member_extra me on (me.id=p.author_id)
|
||||
WHERE t.forum_id IN ($myforums) AND t.title IS NOT NULL
|
||||
AND MATCH(post) AGAINST ('$check_keywords' $boolean)";
|
||||
|
||||
if ( $ibforums->input['sortby'] != "relevant" )
|
||||
@@ -138,14 +171,25 @@ class search_lib extends Search
|
||||
|
||||
$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']))) );
|
||||
$hilight = str_replace( '"', '', $ibforums->input['keywords'] );
|
||||
$hilight = urlencode(trim(str_replace( '&', '&', $hilight)));
|
||||
|
||||
$print->redirect_screen( $ibforums->lang['search_redirect'] , "act=Search&CODE=simpleresults&sid=$unique_id&highlite=".$hilight );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Load up the topic stuff
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( ROOT_PATH.'sources/topics.php' );
|
||||
$this->topics = new topics();
|
||||
$this->topics->topic_init();
|
||||
|
||||
//-----------------------------------------
|
||||
// Get SQL schtuff
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->unique_id = $ibforums->input['sid'];
|
||||
|
||||
@@ -165,9 +209,9 @@ class search_lib extends Search
|
||||
|
||||
$check_keywords = preg_replace( '/&(lt|gt|quot);/', "&\\1;", trim(urldecode($ibforums->input['highlite'])) );
|
||||
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Display
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$this->links = $std->build_pagelinks(
|
||||
array(
|
||||
@@ -177,28 +221,13 @@ class search_lib extends Search
|
||||
'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),
|
||||
'BASE_URL' => $ibforums->base_url."&act=Search&CODE=simpleresults&sid=".$this->unique_id."&highlite=".urlencode(str_replace('"', '', $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;
|
||||
|
||||
@@ -206,7 +235,7 @@ class search_lib extends Search
|
||||
|
||||
$SQLtime->startTimer();
|
||||
|
||||
$DB->query($query." LIMIT {$this->is->first},25");
|
||||
$outer = $DB->query($query." LIMIT {$this->is->first},25");
|
||||
|
||||
$ex_time = sprintf( "%.4f",$SQLtime->endTimer() );
|
||||
|
||||
@@ -225,10 +254,12 @@ class search_lib extends Search
|
||||
'ex_time' => $ex_time,
|
||||
'keyword' => $check_keywords,
|
||||
) );
|
||||
|
||||
$attach_pids = array();
|
||||
|
||||
while ( $row = $DB->fetch_row() )
|
||||
while ( $row = $DB->fetch_row($outer) )
|
||||
{
|
||||
//---------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// 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
|
||||
@@ -236,89 +267,12 @@ class search_lib extends Search
|
||||
// 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.
|
||||
//---------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$member = $this->topics->parse_member( $row );
|
||||
|
||||
$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
|
||||
@@ -328,12 +282,68 @@ class search_lib extends Search
|
||||
$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);
|
||||
}
|
||||
//-----------------------------------------
|
||||
// Attachments?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( strstr( $row['post'], '[attachmentid=' ) )
|
||||
{
|
||||
$attach_pids[] = $row['pid'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Fix up quotes..
|
||||
//-----------------------------------------
|
||||
|
||||
$row['post'] = $this->topics->parser->unconvert( $row['post'] );
|
||||
|
||||
$row['post'] = $this->topics->parser->convert( array(
|
||||
'TEXT' => $row['post'],
|
||||
'CODE' => $forums->forum_by_id[$row['forum_id']]['use_ibc'],
|
||||
'SMILIES' => 1,
|
||||
'HTML' => 0
|
||||
) );
|
||||
|
||||
$this->topics->parser->pp_do_html = ( $forums->forum_by_id[$row['forum_id']]['use_html'] and $ibforums->cache['group_cache'][ $row['mgroup'] ]['g_dohtml'] and $row['post_htmlstate'] ) ? 1 : 0;
|
||||
$this->topics->parser->pp_wordwrap = $ibforums->vars['post_wordwrap'];
|
||||
$this->topics->parser->pp_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
|
||||
|
||||
$row['post'] = $this->topics->parser->post_db_parse( $row['post'] );
|
||||
|
||||
$keywords_array = explode( " ", str_replace( "+", " ", $ibforums->input['highlite'] ) );
|
||||
|
||||
if ( count($keywords_array) )
|
||||
{
|
||||
foreach( $keywords_array as $keys )
|
||||
{
|
||||
if ( $keys == "" )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->output .= $this->is->html->result_simple_footer(array(
|
||||
'links' => $this->links,
|
||||
) );
|
||||
while( preg_match( "/(^|\s|'|\"|>)(".preg_quote($keys, '/').")(\s|'|\"|,|\.|!|<br|$)/is", $row['post'] ) )
|
||||
{
|
||||
$row['post'] = preg_replace( "/(^|\s|'|\"|>)(".preg_quote($keys, '/').")(\s|'|\"|,|\.|!|<br|$)/is", "\\1<span class='searchlite'>\\2</span>\\3", $row['post'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$row['forum_name'] = $forums->forum_by_id[ $row['forum_id'] ]['name'];
|
||||
|
||||
|
||||
$this->output .= $this->is->html->RenderPostRow($row, $member);
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Add in attachments?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( count( $attach_pids ) )
|
||||
{
|
||||
$this->output = $this->topics->parse_attachments( $this->output, $attach_pids );
|
||||
}
|
||||
|
||||
$this->output .= $this->is->html->end_results_table(array( 'SHOW_PAGES' => $this->links ) , 1 );
|
||||
|
||||
$print->add_output("$this->output");
|
||||
$print->do_output( array( 'TITLE' => $ibforums->lang['g_simple_title'], 'JS' => 0, NAV => array( $ibforums->lang['g_simple_title'] ) ) );
|
||||
@@ -345,22 +355,22 @@ class search_lib extends Search
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
// 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'] != "")
|
||||
@@ -392,7 +402,7 @@ class search_lib extends Search
|
||||
$type='nameonly';
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->is->mysql_version >= 40010 )
|
||||
{
|
||||
@@ -415,33 +425,58 @@ class search_lib extends Search
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen(trim($keywords)) < 4)
|
||||
if ( strlen(trim($keywords)) < $ibforums->vars['min_search_word'] and $type != 'nameonly' )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => 4) );
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
// Check for filter abuse..
|
||||
//-----------------------------------------
|
||||
|
||||
$tmp = explode( ' ', $keywords );
|
||||
|
||||
foreach( $tmp as $t )
|
||||
{
|
||||
if ( ! $t )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$t = preg_replace( "#[\+\-\*\.]#", "", $t );
|
||||
|
||||
//-----------------------------------------
|
||||
// Allow abc* but not a***
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ( strlen( $t ) < $ibforums->vars['min_search_word'] ) and $type != 'nameonly' )
|
||||
{
|
||||
$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 )
|
||||
{
|
||||
@@ -451,7 +486,7 @@ class search_lib extends Search
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
foreach ( array( 1, 7, 30, 60, 90, 180, 365, 0 ) as $v )
|
||||
{
|
||||
@@ -461,14 +496,14 @@ class search_lib extends Search
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->input['sort_order'] == 'asc')
|
||||
{
|
||||
$this->is->sort_order = 'asc';
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->input['result_type'] == 'posts')
|
||||
{
|
||||
@@ -480,16 +515,24 @@ class search_lib extends Search
|
||||
$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";
|
||||
if ( $this->is->result_type == 'posts' )
|
||||
{
|
||||
$topics_datecut = "t.start_date $gt_lt $time AND";
|
||||
}
|
||||
else
|
||||
{
|
||||
$topics_datecut = "t.last_post $gt_lt $time AND";
|
||||
}
|
||||
|
||||
$posts_datecut = "p.post_date $gt_lt $time AND";
|
||||
}
|
||||
|
||||
@@ -500,9 +543,9 @@ class search_lib extends Search
|
||||
|
||||
if ( $name_filter != "" )
|
||||
{
|
||||
//------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Get all the possible matches for the supplied name from the DB
|
||||
//------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$name_filter = str_replace( '|', "|", $name_filter );
|
||||
|
||||
@@ -551,93 +594,117 @@ class search_lib extends Search
|
||||
|
||||
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)";
|
||||
if ( ! $this->is->topic_search_only )
|
||||
{
|
||||
$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
|
||||
LEFT JOIN ibf_topics t ON ( p.topic_id=t.tid )
|
||||
WHERE $posts_datecut t.forum_id IN ($forums)
|
||||
AND p.queued <> 1
|
||||
$posts_name AND MATCH(post) AGAINST ('".trim($keywords)."' $boolean)";
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Search in topic only
|
||||
//-----------------------------------------
|
||||
|
||||
$posts_query = "SELECT p.pid
|
||||
FROM ibf_posts p
|
||||
LEFT JOIN ibf_topics t ON ( p.topic_id=t.tid )
|
||||
WHERE
|
||||
p.topic_id={$this->is->topic_id}
|
||||
AND $posts_datecut t.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";
|
||||
$posts_query = "SELECT p.pid
|
||||
FROM ibf_posts p
|
||||
LEFT JOIN ibf_topics t ON ( p.topic_id=t.tid )
|
||||
WHERE $posts_datecut t.forum_id IN ($forums)
|
||||
AND p.queued <> 1
|
||||
$posts_name";
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
//-----------------------------------------
|
||||
// Get the topic ID's to serialize and store into
|
||||
// the database
|
||||
//------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$topics = "";
|
||||
$posts = "";
|
||||
$topic_array = array();
|
||||
$post_array = array();
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query($topics_query);
|
||||
|
||||
$topic_max_hits = $DB->get_num_rows();
|
||||
|
||||
while ($row = $DB->fetch_row() )
|
||||
if ( ! $this->is->topic_search_only )
|
||||
{
|
||||
$topics .= $row['tid'].",";
|
||||
$DB->query($topics_query);
|
||||
|
||||
while ($row = $DB->fetch_row() )
|
||||
{
|
||||
$topic_array[ $row['tid'] ] = $row['tid'];
|
||||
}
|
||||
|
||||
$DB->free_result();
|
||||
}
|
||||
|
||||
$DB->free_result();
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query($posts_query);
|
||||
|
||||
$post_max_hits = $DB->get_num_rows();
|
||||
|
||||
while ($row = $DB->fetch_row() )
|
||||
{
|
||||
$posts .= $row['pid'].",";
|
||||
$post_array[ $row['pid'] ] = $row['pid'];
|
||||
}
|
||||
|
||||
$DB->free_result();
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$topics = preg_replace( "/,$/", "", $topics );
|
||||
$posts = preg_replace( "/,$/", "", $posts );
|
||||
$topics = implode( ",", $topic_array );
|
||||
$posts = implode( ",", $post_array );
|
||||
|
||||
//------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Do we have any results?
|
||||
//------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($topics == "" and $posts == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
$this->output .= $this->is->html->search_error_page($ibforums->input['keywords']);
|
||||
$print->add_output( $this->output );
|
||||
$print->do_output( array( 'TITLE' => $ibforums->lang['g_simple_title'], 'JS' => 0, NAV => array( $ibforums->lang['g_simple_title'] ) ) );
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// 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,
|
||||
'topic_max' => intval( count( $topic_array ) ),
|
||||
'post_max' => intval( count( $post_array ) ),
|
||||
'keywords' => str_replace( '"', "", $keywords ),
|
||||
);
|
||||
|
||||
}
|
||||
@@ -645,4 +712,4 @@ class search_lib extends Search
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -2,16 +2,15 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
@@ -26,33 +25,32 @@
|
||||
|
||||
class search_lib extends Search
|
||||
{
|
||||
|
||||
var $parser = "";
|
||||
var $is = "";
|
||||
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function search_lib($that)
|
||||
{
|
||||
global $ibforums, $DB, $std, $print;
|
||||
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'] != "")
|
||||
@@ -84,7 +82,7 @@ class search_lib extends Search
|
||||
$type='nameonly';
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$check_keywords = trim($keywords);
|
||||
|
||||
@@ -98,27 +96,27 @@ class search_lib extends Search
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
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 )
|
||||
{
|
||||
@@ -128,7 +126,7 @@ class search_lib extends Search
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
foreach ( array( 1, 7, 30, 60, 90, 180, 365, 0 ) as $v )
|
||||
{
|
||||
@@ -138,14 +136,14 @@ class search_lib extends Search
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->input['sort_order'] == 'asc')
|
||||
{
|
||||
$this->is->sort_order = 'asc';
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->input['result_type'] == 'posts')
|
||||
{
|
||||
@@ -157,9 +155,9 @@ class search_lib extends Search
|
||||
$ibforums->vars['min_search_word'] = 4;
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
// Add on the prune days
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ($this->is->prune > 0)
|
||||
{
|
||||
@@ -177,9 +175,9 @@ class search_lib extends Search
|
||||
|
||||
if ( $name_filter != "" )
|
||||
{
|
||||
//------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Get all the possible matches for the supplied name from the DB
|
||||
//------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$name_filter = str_replace( '|', "|", $name_filter );
|
||||
|
||||
@@ -273,11 +271,12 @@ class search_lib extends Search
|
||||
$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)";
|
||||
$posts_query = "SELECT p.pid
|
||||
FROM ibf_posts p
|
||||
LEFT JOIN ibf_topics t on (t.tid=p.topic_id)
|
||||
WHERE $posts_datecut t.forum_id IN ($forums)
|
||||
AND p.queued <> 1
|
||||
$posts_name AND ($post_like)";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -287,22 +286,23 @@ class search_lib extends Search
|
||||
$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";
|
||||
$posts_query = "SELECT p.pid
|
||||
FROM ibf_posts p
|
||||
LEFT JOIN ibf_topics t on (t.tid=p.topic_id)
|
||||
WHERE $posts_datecut t.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);
|
||||
|
||||
@@ -315,7 +315,7 @@ class search_lib extends Search
|
||||
|
||||
$DB->free_result();
|
||||
|
||||
//------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query($posts_query);
|
||||
|
||||
@@ -328,25 +328,25 @@ class search_lib extends Search
|
||||
|
||||
$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,
|
||||
@@ -361,4 +361,4 @@ class search_lib extends Search
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
+80
-61
@@ -2,16 +2,15 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
@@ -90,9 +89,9 @@ class tar {
|
||||
var $tarfile_path_name = "";
|
||||
var $workfiles = array();
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// CONSTRUCTOR: Attempt to guess the current working dir.
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function tar() {
|
||||
global $HTTP_SERVER_VARS;
|
||||
@@ -119,12 +118,12 @@ class tar {
|
||||
);
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Set the tarname. If we are extracting a tarball, then it must be the
|
||||
// path to the tarball, and it's name (eg: $tar->new_tar("/foo/bar" ,'myTar.tar')
|
||||
// or if we are creating a tar, then it must be the path and name of the tar file
|
||||
// to create.
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function new_tar($tarpath, $tarname) {
|
||||
|
||||
@@ -140,9 +139,9 @@ class tar {
|
||||
}
|
||||
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Easy way to overwrite defaults
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function over_write_existing() {
|
||||
$this->attributes['over_write_existing'] = 1;
|
||||
@@ -159,9 +158,9 @@ class tar {
|
||||
|
||||
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// User assigns the root directory for the tar ball creation/extraction
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function current_dir($dir = "") {
|
||||
|
||||
@@ -169,9 +168,9 @@ class tar {
|
||||
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// list files: returns an array with all the filenames in the tar file
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function list_files($advanced="") {
|
||||
|
||||
@@ -201,13 +200,13 @@ class tar {
|
||||
return $final;
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Add a directory to the tar files.
|
||||
// $tar->add_directory( str(TO DIRECTORY) )
|
||||
// Can be used in the following methods.
|
||||
// $tar->add_directory( "/foo/bar" );
|
||||
// $tar->write_tar( "/foo/bar" );
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function add_directory( $dir ) {
|
||||
|
||||
@@ -233,7 +232,7 @@ class tar {
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function get_dir_contents( $dir )
|
||||
{
|
||||
@@ -276,7 +275,7 @@ class tar {
|
||||
}
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Extract the tarball
|
||||
// $tar->extract_files( str(TO DIRECTORY), [ array( FILENAMES ) ] )
|
||||
// Can be used in the following methods.
|
||||
@@ -284,7 +283,7 @@ class tar {
|
||||
// This will seek out the files in the user array and extract them
|
||||
// $tar->extract( "/foo/bar" );
|
||||
// Will extract the complete tar file into the user specified directory
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function extract_files( $to_dir, $files="" ) {
|
||||
|
||||
@@ -299,18 +298,18 @@ class tar {
|
||||
return;
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
// change into the directory chosen by the user.
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
chdir($to_dir);
|
||||
$cur_dir = getcwd();
|
||||
|
||||
$to_dir_slash = $to_dir . "/";
|
||||
|
||||
//+------------------------------
|
||||
//-----------------------------------------
|
||||
// Get the file info from the tar
|
||||
//+------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$in_files = $this->read_tar();
|
||||
|
||||
@@ -320,9 +319,9 @@ class tar {
|
||||
|
||||
foreach ($in_files as $k => $file) {
|
||||
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Are we choosing which files to extract?
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if (is_array($files))
|
||||
{
|
||||
@@ -334,10 +333,10 @@ class tar {
|
||||
|
||||
chdir($cur_dir);
|
||||
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
// GNU TAR format dictates that all paths *must* be in the *nix
|
||||
// format - if this is not the case, blame the tar vendor, not me!
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ( preg_match("#/#", $file['name']) )
|
||||
{
|
||||
@@ -349,9 +348,9 @@ class tar {
|
||||
$file_name = $file['name'];
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
// If we have a path, then we must build the directory tree
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if (count($path_info) > 0)
|
||||
@@ -380,9 +379,9 @@ class tar {
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
// check the typeflags, and work accordingly
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if (($file['typeflag'] == 0) or (!$file['typeflag']) or ($file['typeflag'] == ""))
|
||||
{
|
||||
@@ -445,7 +444,7 @@ class tar {
|
||||
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// add files:
|
||||
// Takes an array of files, and adds them to the tar file
|
||||
// Optionally takes a path to use as root for the tar file - if omitted, it
|
||||
@@ -461,20 +460,21 @@ class tar {
|
||||
// in an error. Either that, or use:
|
||||
// chdir("/usr/home/somedir/forums");
|
||||
// $tar->add_files( $files );
|
||||
//+--------------------------------------------------------------------------
|
||||
|
||||
function add_files( $files, $root_path="" ) {
|
||||
//-----------------------------------------
|
||||
|
||||
function add_files( $files, $root_path="" )
|
||||
{
|
||||
// Do we a root path to change into?
|
||||
|
||||
if ($root_path != "") {
|
||||
if ($root_path != "")
|
||||
{
|
||||
chdir($root_path);
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
// is it a Mac OS X work file?
|
||||
|
||||
if ( preg_match("/\.ds_store/i", $file ) )
|
||||
@@ -490,7 +490,8 @@ class tar {
|
||||
|
||||
// Did stat fail?
|
||||
|
||||
if (! is_array($stat) ) {
|
||||
if (! is_array($stat) )
|
||||
{
|
||||
$this->warnings[] = "Error: Stat failed on $file";
|
||||
continue;
|
||||
}
|
||||
@@ -502,25 +503,34 @@ class tar {
|
||||
$size = filesize($file);
|
||||
$mtime = filemtime($file);
|
||||
|
||||
if (is_file($file)) {
|
||||
if (is_file($file))
|
||||
{
|
||||
// It's a plain file, so lets suck it up
|
||||
|
||||
$typeflag = 0;
|
||||
if ( $FH = fopen($file, 'rb') ) {
|
||||
|
||||
if ( $FH = fopen($file, 'rb') )
|
||||
{
|
||||
$data = fread( $FH, filesize($file) );
|
||||
fclose($FH);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->warnings[] = "ERROR: Failed to open $file";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (is_link($file)) {
|
||||
else if (is_link($file))
|
||||
{
|
||||
$typeflag = 1;
|
||||
$linkname = @readlink($file);
|
||||
}
|
||||
else if (is_dir($file)) {
|
||||
else if (is_dir($file))
|
||||
{
|
||||
$typeflag = 5;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// Sockets, Pipes and char/block specials are not
|
||||
// supported, so - lets use a silly value to keep the
|
||||
// tar ball legitimate.
|
||||
@@ -563,11 +573,11 @@ class tar {
|
||||
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// write_tar:
|
||||
// Writes the tarball into the directory specified in new_tar with a filename
|
||||
// specified in new_tar
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function write_tar() {
|
||||
|
||||
@@ -591,16 +601,22 @@ class tar {
|
||||
|
||||
// make sure the filename isn't longer than 99 characters.
|
||||
|
||||
if (strlen($file['name']) > 99) {
|
||||
if (strlen($file['name']) > 99)
|
||||
{
|
||||
$pos = strrpos( $file['name'], "/" );
|
||||
if (is_string($pos) && !$pos) {
|
||||
|
||||
if (is_string($pos) && !$pos)
|
||||
{
|
||||
// filename alone is longer than 99 characters!
|
||||
$this->error[] = "Filename {$file['name']} exceeds the length allowed by GNU Tape ARchives";
|
||||
continue;
|
||||
}
|
||||
|
||||
$prefix = substr( $file['name'], 0 , $pos ); // Move the path to the prefix
|
||||
$file['name'] = substr( $file['name'], ($pos+1));
|
||||
if (strlen($prefix) > 154) {
|
||||
|
||||
if (strlen($prefix) > 154)
|
||||
{
|
||||
$this->error[] = "File path exceeds the length allowed by GNU Tape ARchives";
|
||||
continue;
|
||||
}
|
||||
@@ -635,15 +651,18 @@ class tar {
|
||||
|
||||
$checksum = 0;
|
||||
|
||||
for ($i = 0 ; $i < 148 ; $i++ ) {
|
||||
for ($i = 0 ; $i < 148 ; $i++ )
|
||||
{
|
||||
$checksum += ord( substr($tmp, $i, 1) );
|
||||
}
|
||||
|
||||
for ($i = 148 ; $i < 156 ; $i++) {
|
||||
for ($i = 148 ; $i < 156 ; $i++)
|
||||
{
|
||||
$checksum += ord(' ');
|
||||
}
|
||||
|
||||
for ($i = 156, $j = 0 ; $i < 512 ; $i++, $j++) {
|
||||
for ($i = 156, $j = 0 ; $i < 512 ; $i++, $j++)
|
||||
{
|
||||
$checksum += ord( substr($last, $j, 1) );
|
||||
}
|
||||
|
||||
@@ -684,9 +703,9 @@ class tar {
|
||||
// Done..
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Read the tarball - builds an associative array
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function read_tar() {
|
||||
|
||||
@@ -832,13 +851,13 @@ class tar {
|
||||
|
||||
|
||||
|
||||
//+------------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// INTERNAL FUNCTIONS - These should NOT be called outside this module
|
||||
//+------------------------------------------------------------------------------
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// build_string: Builds a repititive string
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function internal_build_string($string="", $times=0) {
|
||||
|
||||
|
||||
@@ -0,0 +1,472 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Task Manager functions
|
||||
| > Script written by Matt Mecham
|
||||
| > Date started: 29th September 2003
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly.";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
class task_functions
|
||||
{
|
||||
var $type = 'internal';
|
||||
var $root_path = './';
|
||||
var $time_now = 0;
|
||||
var $date_now = array();
|
||||
var $cron_key = "";
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// CONSTRUCTOR
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function task_functions()
|
||||
{
|
||||
global $DB, $std, $ibforums, $ROOT_PATH;
|
||||
|
||||
if ( $ROOT_PATH )
|
||||
{
|
||||
$this->root_path = $ROOT_PATH.'/';
|
||||
}
|
||||
else if ( ROOT_PATH )
|
||||
{
|
||||
$this->root_path = ROOT_PATH;
|
||||
}
|
||||
|
||||
if ( $ibforums->input['ck'] )
|
||||
{
|
||||
$this->type = 'cron';
|
||||
|
||||
$this->cron_key = substr( trim($ibforums->input['ck']), 0, 32 );
|
||||
}
|
||||
|
||||
$this->time_now = time();
|
||||
|
||||
$this->date_now['minute'] = intval( gmdate( 'i', $this->time_now ) );
|
||||
$this->date_now['hour'] = intval( gmdate( 'H', $this->time_now ) );
|
||||
$this->date_now['wday'] = intval( gmdate( 'w', $this->time_now ) );
|
||||
$this->date_now['mday'] = intval( gmdate( 'd', $this->time_now ) );
|
||||
$this->date_now['month'] = intval( gmdate( 'm', $this->time_now ) );
|
||||
$this->date_now['year'] = intval( gmdate( 'Y', $this->time_now ) );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Run the task
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function run_task()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
if ( $this->type == 'internal' )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Loaded by our image...
|
||||
// ... get next job
|
||||
//-----------------------------------------
|
||||
|
||||
$this_task = $DB->simple_exec_query( array( 'select' => '*',
|
||||
'from' => 'task_manager',
|
||||
'where' => 'task_enabled = 1 AND task_next_run <= '.$this->time_now,
|
||||
'order' => 'task_next_run ASC',
|
||||
'limit' => array(0,1)
|
||||
) );
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Cron.. load from cron key
|
||||
//-----------------------------------------
|
||||
|
||||
$this_task = $DB->simple_exec_query( array( 'select' => '*',
|
||||
'from' => 'task_manager',
|
||||
'where' => "task_cronkey='".$this->cron_key."'",
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ( $this_task['task_id'] )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Got it, now update row and run..
|
||||
//-----------------------------------------
|
||||
|
||||
$newdate = $this->generate_next_run($this_task);
|
||||
|
||||
$DB->do_update( 'task_manager', array( 'task_next_run' => $newdate ), "task_id=".$this_task['task_id'] );
|
||||
|
||||
$this->save_next_run_stamp();
|
||||
|
||||
if ( file_exists( $this->root_path.'sources/tasks/'.$this_task['task_file'] ) )
|
||||
{
|
||||
require_once( $this->root_path.'sources/tasks/'.$this_task['task_file'] );
|
||||
$myobj = new task_item();
|
||||
$myobj->register_class( $this );
|
||||
$myobj->pass_task( $this_task );
|
||||
$myobj->run_task();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Update next run variable in the systemvars cache
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function save_next_run_stamp()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$this_task = $DB->simple_exec_query( array( 'select' => 'task_next_run', 'from' => 'task_manager', 'where' => 'task_enabled = 1', 'order' => 'task_next_run ASC', 'limit' => array(0,1) ) );
|
||||
|
||||
if ( ! $this_task['task_next_run'] )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Fail safe...
|
||||
//-----------------------------------------
|
||||
|
||||
$this_task['task_next_run'] = $this->time_now + 3600;
|
||||
}
|
||||
|
||||
$cache_array = array();
|
||||
|
||||
$cache = $DB->simple_exec_query( array( 'select' => '*', 'from' => 'cache_store', 'where' => "cs_key='systemvars'" ) );
|
||||
|
||||
$cache_array = unserialize(stripslashes($cache['cs_value']));
|
||||
|
||||
$cache_array['task_next_run'] = $this_task['task_next_run'];
|
||||
|
||||
$DB->do_update( 'cache_store', array( 'cs_value' => addslashes(serialize($cache_array)) ), "cs_key='systemvars'" );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Generate next_run unix timestamp
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function generate_next_run($task=array())
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
//-----------------------------------------
|
||||
// Did we set a day?
|
||||
//-----------------------------------------
|
||||
|
||||
$day_set = 1;
|
||||
$min_set = 1;
|
||||
$day_increment = 0;
|
||||
|
||||
$this->run_day = $this->date_now['wday'];
|
||||
$this->run_minute = $this->date_now['minute'];
|
||||
$this->run_hour = $this->date_now['hour'];
|
||||
$this->run_month = $this->date_now['month'];
|
||||
$this->run_year = $this->date_now['year'];
|
||||
|
||||
if ( $task['task_week_day'] == -1 and $task['task_month_day'] == -1 )
|
||||
{
|
||||
$day_set = 0;
|
||||
}
|
||||
|
||||
if ( $task['task_minute'] == -1 )
|
||||
{
|
||||
$min_set = 0;
|
||||
}
|
||||
|
||||
if ( $task['task_week_day'] == -1 )
|
||||
{
|
||||
if ( $task['task_month_day'] != -1 )
|
||||
{
|
||||
$this->run_day = $task['task_month_day'];
|
||||
$day_increment = 'month';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->run_day = $this->date_now['mday'];
|
||||
$day_increment = 'anyday';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Calc. next week day from today
|
||||
//-----------------------------------------
|
||||
|
||||
$this->run_day = $this->date_now['mday'] + ( $task['task_week_day'] - $this->date_now['wday'] );
|
||||
|
||||
$day_increment = 'week';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// If the date to run next is less
|
||||
// than today, best fetch the next
|
||||
// time...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->run_day < $this->date_now['mday'] )
|
||||
{
|
||||
switch ( $day_increment )
|
||||
{
|
||||
case 'month':
|
||||
$this->_add_month();
|
||||
break;
|
||||
case 'week':
|
||||
$this->_add_day(7);
|
||||
break;
|
||||
default:
|
||||
$this->_add_day();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Sort out the hour...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $task['task_hour'] == -1)
|
||||
{
|
||||
$this->run_hour = $this->date_now['hour'];
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// If ! min and ! day then it's
|
||||
// every X hour
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $day_set and ! $min_set )
|
||||
{
|
||||
$this->_add_hour( $task['task_hour'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->run_hour = $task['task_hour'];
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Can we run the minute...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $task['task_minute'] == -1 )
|
||||
{
|
||||
$this->_add_minute();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $task['task_hour'] == -1 and ! $day_set )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Runs every X minute..
|
||||
//-----------------------------------------
|
||||
|
||||
$this->_add_minute($task['task_minute']);
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// runs at hh:mm
|
||||
//-----------------------------------------
|
||||
|
||||
$this->run_minute = $task['task_minute'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->run_hour <= $this->date_now['hour'] and $this->run_day == $this->date_now['mday'] )
|
||||
{
|
||||
if ( $task['task_hour'] == -1 )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Every hour...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->run_hour == $this->date_now['hour'] and $this->run_minute <= $this->date_now['min'] )
|
||||
{
|
||||
$this->_add_hour();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Every X hour, try again in x hours
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $day_set and ! $min_set )
|
||||
{
|
||||
$this->_add_hour($task['task_hour'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Specific hour, try tomorrow
|
||||
//-----------------------------------------
|
||||
|
||||
else if ( ! $day_set )
|
||||
{
|
||||
$this->_add_day();
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Oops, specific day...
|
||||
//-----------------------------------------
|
||||
|
||||
switch ( $day_increment )
|
||||
{
|
||||
case 'month':
|
||||
$this->_add_month();
|
||||
break;
|
||||
case 'week':
|
||||
$this->_add_day(7);
|
||||
break;
|
||||
default:
|
||||
$this->_add_day();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Return stamp...
|
||||
//-----------------------------------------
|
||||
|
||||
$next_run = gmmktime( $this->run_hour, $this->run_minute, 0, $this->run_month, $this->run_day, $this->run_year );
|
||||
|
||||
return $next_run;
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Add to the log file
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function append_task_log($task,$desc)
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
if ( ! $task['task_log'] )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$save = array( 'log_title' => $task['task_title'],
|
||||
'log_date' => time(),
|
||||
'log_ip' => $_SERVER['REMOTE_ADDR'],
|
||||
'log_desc' => $desc
|
||||
);
|
||||
|
||||
$DB->do_insert( 'task_logs', $save );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Add on a month for the next run time..
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function _add_month()
|
||||
{
|
||||
if ($this->date_now['month'] == 12)
|
||||
{
|
||||
$this->run_month = 1;
|
||||
$this->run_year++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->run_month++;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Add on a day for the next run time..
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function _add_day($days=1)
|
||||
{
|
||||
if ( $this->date['mday'] >= ( gmdate( 't', $this->time_now ) - $days ) )
|
||||
{
|
||||
$this->run_day = ($this->date['mday'] + $days) - date( 't', $this->time_now );
|
||||
$this->_add_month();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->run_day += $days;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Add on a hour for the next run time...
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function _add_hour($hour=1)
|
||||
{
|
||||
if ($this->date_now['hour'] >= (24 - $hour ) )
|
||||
{
|
||||
$this->run_hour = ($this->date_now['hour'] + $hour) - 24;
|
||||
$this->_add_day();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->run_hour += $hour;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Add on a minute...
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function _add_minute($mins=1)
|
||||
{
|
||||
if ( $this->date_now['minute'] >= (60 - $mins) )
|
||||
{
|
||||
$this->run_minute = ( $this->date_now['minute'] + $mins ) - 60;
|
||||
$this->_add_hour();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->run_minute += $mins;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,451 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Template Engine module
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 5th January 2004
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
+--------------------------------------------------------------------------
|
||||
| New template module to build, rebuild and generate caches of templates
|
||||
| which include the new IPB HTML Logic system.
|
||||
| Example:
|
||||
| <ipb-htmllogic>
|
||||
| <if="ibf.vars['threaded_per_page'] == 10">
|
||||
| html here
|
||||
| </if>
|
||||
| <else if="ibf.vars['threaded_per_page'] >= 100 or some_var == 'this'">
|
||||
| html here
|
||||
| </if>
|
||||
| <else if="show['this'] > 100">
|
||||
| html here
|
||||
| </if>
|
||||
| <else>
|
||||
| html here
|
||||
| </else>
|
||||
| </ipb-htmllogic>
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
class ipb_template_engine
|
||||
{
|
||||
var $root_path = './';
|
||||
var $cache_dir = 'skin_cache';
|
||||
var $cache_id = '1';
|
||||
var $database_id = '1';
|
||||
|
||||
var $cache_path = '';
|
||||
|
||||
function class_template()
|
||||
{
|
||||
$this->cache_path = $this->root_path . $this->cache_dir . '/cacheid_' . $this->cache_id;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Convert HTML to PHP cache file
|
||||
//===================================================
|
||||
|
||||
function convert_html_to_php($func_name, $func_data, $func_html)
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Make sure we have ="" on each
|
||||
// func data
|
||||
//-----------------------------------------
|
||||
|
||||
$func_data = preg_replace( "#".'\$'."(\w+)(,|$)#i", "\$\\1=\"\"\\2", str_replace( " ", "", $func_data ) );
|
||||
|
||||
$top = "//===========================================================================\n".
|
||||
"// {$func_name}\n".
|
||||
"//===========================================================================\n";
|
||||
|
||||
$start = "function {$func_name}($func_data) {\nglobal \$ibforums;\n\$IPBHTML = \"\";\n//--starthtml--//\n";
|
||||
$middle = $this->build_section_html_to_php($func_html);
|
||||
$end = "\n//--endhtml--//\nreturn \$IPBHTML;\n}\n";
|
||||
|
||||
return $top.$start.$middle.$end;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Alias: Convert PHP to HTML
|
||||
//===================================================
|
||||
|
||||
function convert_php_to_html($php)
|
||||
{
|
||||
return $this->_convert_php_to_html($php);
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Build Section: PHP to HTML
|
||||
// - Updates HTML database with PHP cache file
|
||||
//===================================================
|
||||
|
||||
function build_section_php_to_html($php="")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Build Section: HTML to PHP
|
||||
// - Makes PHP cache of raw HTML
|
||||
//===================================================
|
||||
|
||||
function build_section_html_to_php($html="")
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Does it have logic sections?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( preg_match( "#<ipb-htmllogic>#si", $html ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Convert between logic sections
|
||||
//-----------------------------------------
|
||||
|
||||
$html = preg_replace( "#(</ipb-htmllogic>)(.+?)(<ipb-htmllogic>)#ise", "\$this->_wrap_in_php('\\2', '\\3', '\\1');", $html );
|
||||
|
||||
//-----------------------------------------
|
||||
// Convert before logic sections
|
||||
//-----------------------------------------
|
||||
|
||||
$html = preg_replace( "#^(.+?)(<ipb-htmllogic>)#ise", "\$this->_wrap_in_php('\\1', '\\2');", $html );
|
||||
|
||||
//-----------------------------------------
|
||||
// Convert after logic sections
|
||||
//-----------------------------------------
|
||||
|
||||
if ( preg_match( "#^(.*)</ipb-htmllogic>(.+?)$#is", $html, $match ) )
|
||||
{
|
||||
if ( $match[1] and $match[2] )
|
||||
{
|
||||
$html = preg_replace( "#^(.*</ipb-htmllogic>)(.+?)$#ise", "\$this->_wrap_in_php('\\2', '', '\\1');", $html );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Find and convert ipb-htmllogic bits
|
||||
//-----------------------------------------
|
||||
|
||||
while ( preg_match( "#<ipb-htmllogic>(.+?)</ipb-htmllogic>#si", $html, $match ) )
|
||||
{
|
||||
$html = preg_replace( "#<ipb-htmllogic>(.+?)</ipb-htmllogic>#sie", "'//start-htmllogic' . \$this->_convert_html_to_php('\\1') . '//end-htmllogic';", $html );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$html = $this->_wrap_in_php( $html );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Remove extra spaces
|
||||
//-----------------------------------------
|
||||
|
||||
$html = preg_replace( "#(//endelse|//endif)\s+?(//end-htmllogic)#is", "\\1\n\\2", $html );
|
||||
|
||||
//-----------------------------------------
|
||||
// Unconvert special tags
|
||||
//-----------------------------------------
|
||||
|
||||
$html = $this->unconvert_tags($html);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Convert special tags into HTML safe versions
|
||||
//===================================================
|
||||
|
||||
function convert_tags($t="")
|
||||
{
|
||||
$t = preg_replace( "/{?\\\$ibforums->base_url}?/" , "{ipb.script_url}" , $t );
|
||||
$t = preg_replace( "/{?\\\$ibforums->session_id}?/" , "{ipb.session_id}" , $t );
|
||||
$t = preg_replace( "#\\\$ibforums->(member|vars|skin|lang)#i" , "ipb.\\1" , $t );
|
||||
|
||||
//-----------------------------------------
|
||||
// Make some tags safe..
|
||||
//-----------------------------------------
|
||||
|
||||
$t = preg_replace( "/\{ipb\.vars\[(['\"])?(sql_driver|sql_host|sql_database|sql_pass|sql_user|sql_port|sql_tbl_prefix|smtp_host|smtp_port|smtp_user|smtp_pass|html_dir|base_dir|upload_dir)(['\"])?\]\}/", "" , $t );
|
||||
|
||||
return $t;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Uncovert them back again
|
||||
//===================================================
|
||||
|
||||
function unconvert_tags($t="")
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Make some tags safe..
|
||||
//-----------------------------------------
|
||||
|
||||
$t = preg_replace( "/\{ipb\.vars\[(['\"])?(sql_driver|sql_host|sql_database|sql_pass|sql_user|sql_port|sql_tbl_prefix|smtp_host|smtp_port|smtp_user|smtp_pass|html_dir|base_dir|upload_dir)(['\"])?\]\}/", "" , $t );
|
||||
|
||||
$t = preg_replace( "/{ipb\.script_url}/i" , '{$ibforums->base_url}' , $t);
|
||||
$t = preg_replace( "/{ipb\.session_id}/i" , '{$ibforums->session_id}', $t);
|
||||
$t = preg_replace( "#ipb\.(member|vars|skin|lang)#i", '$ibforums->\\1' , $t );
|
||||
|
||||
return $t;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Wrap HTML into PHP
|
||||
//===================================================
|
||||
|
||||
function _wrap_in_php( $html, $after="", $before="" )
|
||||
{
|
||||
$html = $this->_trim_newlines($this->_trim_slashes($html));
|
||||
|
||||
$before = $this->_trim_slashes($before);
|
||||
$after = $this->_trim_slashes($after);
|
||||
|
||||
if ( strlen($html) < 1 )
|
||||
{
|
||||
return $before.$html.$after;
|
||||
}
|
||||
|
||||
return $before."\n\$IPBHTML .= <<<EOF\n$html\nEOF;\n".$after;
|
||||
}
|
||||
|
||||
|
||||
//===================================================
|
||||
// Convert: HTML Logic to PHP logic
|
||||
//===================================================
|
||||
|
||||
function _convert_html_to_php($html)
|
||||
{
|
||||
$html = $this->_trim_slashes($html);
|
||||
$html = preg_replace( "#\s+?<if=[\"'](.+?)[\"']>(.+?)</if>#ise", "\$this->_statement_if('\\1', '\\2')", $html );
|
||||
$html = preg_replace( "#\s+?<else if=[\"'](.+?)[\"']>(.+?)</if>#ise", '$this->_statement_elseif("\\1", "\\2")', $html );
|
||||
$html = preg_replace( "#\s+?<else>(.+?)</else>#ise", '$this->_statement_else("\\1")', $html );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Convert: PHP logic to HTML logic
|
||||
//===================================================
|
||||
|
||||
function _convert_php_to_html($php)
|
||||
{
|
||||
$php = preg_replace( "#else if\s+?\((.+?)\)\s+?{(.+?)}//endif\n?#ise", "\$this->_reverse_if('\\1', '\\2', 'else if')", $php );
|
||||
$php = preg_replace( "#if\s+?\((.+?)\)\s+?{(.+?)}//endif\n?#ise", "\$this->_reverse_if('\\1', '\\2', 'if')", $php );
|
||||
$php = preg_replace( "#else\s+?{(.+?)}//endelse\n?#ise", "\$this->_reverse_else( '\\1' )", $php );
|
||||
|
||||
//-----------------------------------------
|
||||
// Parse raw sections
|
||||
//-----------------------------------------
|
||||
|
||||
$php = $this->_reverse_ipbhtml($php);
|
||||
|
||||
//-----------------------------------------
|
||||
// Convert ipb-htmllogic tags
|
||||
//-----------------------------------------
|
||||
|
||||
$php = preg_replace( "#//start-htmllogic#i" , "<ipb-htmllogic>", $php );
|
||||
$php = preg_replace( "#//end-htmllogic#i", "</ipb-htmllogic>" , $php );
|
||||
|
||||
//-----------------------------------------
|
||||
// Remove extra spaces
|
||||
//-----------------------------------------
|
||||
|
||||
$php = preg_replace( "#(</if>|</else>)\s+?(<if|<else|</ipb-htmllogic>)#is", "\\1\n\\2", $php );
|
||||
|
||||
//-----------------------------------------
|
||||
// Make safe special $Ibforums vars
|
||||
//-----------------------------------------
|
||||
|
||||
$php = $this->convert_tags($php);
|
||||
|
||||
return $php;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Reverse: PHP IF to HTML IF
|
||||
//===================================================
|
||||
|
||||
function _reverse_if( $code, $php, $start='if' )
|
||||
{
|
||||
$code = $this->_trim_slashes(trim($code));
|
||||
$code = preg_replace( "/(^|and|or)(\s+)(.+?)(\s|$)/ise", "\$this->_reverse_prep_left('\\3', '\\1', '\\2', '\\4')", ' '.$code );
|
||||
|
||||
$php = $this->_reverse_ipbhtml($php);
|
||||
|
||||
return "<".$start."=\"".trim($code)."\">\n".$php."\n</if>\n";
|
||||
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Reverse: PHP else to HTML else
|
||||
//===================================================
|
||||
|
||||
function _reverse_else( $php )
|
||||
{
|
||||
$php = $this->_trim_slashes(trim($php));
|
||||
|
||||
$php = $this->_reverse_ipbhtml($php);
|
||||
|
||||
return "<else>\n".$php."\n</else>\n";
|
||||
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Reverse: $IPBHTML to normal $HTML
|
||||
//===================================================
|
||||
|
||||
function _reverse_ipbhtml( $code )
|
||||
{
|
||||
$code = $this->_trim_slashes($code);
|
||||
|
||||
$code = preg_replace("/".'\$'."IPBHTML\s+?\.?=\s+?<<<EOF(.+?)EOF;\s?/si", "\\1", $code );
|
||||
|
||||
$code = trim($code);
|
||||
$code = $this->_trim_newlines($code);
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Reverse PHP IF code to HTML code
|
||||
//===================================================
|
||||
|
||||
function _reverse_prep_left($left, $andor="", $fs="", $ls="")
|
||||
{
|
||||
$left = trim($this->_trim_slashes($left));
|
||||
|
||||
if ( preg_match( "/".'\$'."ibforums->/", $left ) )
|
||||
{
|
||||
$left = preg_replace( "/".'\$'."ibforums->(.+?)$/", 'ipb.'."\\1", $left );
|
||||
}
|
||||
else
|
||||
{
|
||||
$left = str_replace( '$', '', $left );
|
||||
}
|
||||
|
||||
return $andor.$fs.$left.$ls;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Statement: Return PHP 'IF' statement
|
||||
//===================================================
|
||||
|
||||
function _statement_if( $code, $html )
|
||||
{
|
||||
$html = $this->_func_prep_html($html);
|
||||
$code = $this->_func_prep_if($code);
|
||||
|
||||
return "\nif ( $code )\n{\n\$IPBHTML .= <<<EOF\n$html\nEOF;\n}//endif\n";
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Statement: Return PHP 'ELSE IF' statement
|
||||
//===================================================
|
||||
|
||||
function _statement_elseif( $code, $html )
|
||||
{
|
||||
$html = $this->_func_prep_html($html);
|
||||
$code = $this->_func_prep_if($code);
|
||||
|
||||
return "\nelse if ( $code )\n{\n\$IPBHTML .= <<<EOF\n$html\nEOF;\n}//endif\n";
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Statement: Return PHP 'ELSE' statement
|
||||
//===================================================
|
||||
|
||||
function _statement_else( $html )
|
||||
{
|
||||
$html = $this->_func_prep_html($html);
|
||||
|
||||
return "\nelse\n{\n\$IPBHTML .= <<<EOF\n$html\nEOF;\n}//endelse\n";
|
||||
}
|
||||
|
||||
|
||||
//===================================================
|
||||
// Strip leading newlines, etc
|
||||
//===================================================
|
||||
|
||||
function _func_prep_html($html)
|
||||
{
|
||||
$html = trim($this->_trim_slashes($html));
|
||||
|
||||
//$html = preg_replace( '/"/', '\\"', $html );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Sort out left bit of comparison
|
||||
//===================================================
|
||||
|
||||
function _func_prep_left($left, $andor="", $fs="", $ls="")
|
||||
{
|
||||
$left = trim($this->_trim_slashes($left));
|
||||
|
||||
if ( preg_match( "/^ipb\./", $left ) )
|
||||
{
|
||||
$left = preg_replace( "/^ipb\.(.+?)$/", '$ibforums->'."\\1", $left );
|
||||
}
|
||||
else
|
||||
{
|
||||
$left = '$'.$left;
|
||||
}
|
||||
|
||||
return $andor.$fs.$left.$ls;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Statement: Prep AND OR, etc
|
||||
//===================================================
|
||||
|
||||
function _func_prep_if( $code )
|
||||
{
|
||||
$code = preg_replace( "/(^|and|or)(\s+)(.+?)(\s|$)/ise", "\$this->_func_prep_left('\\3', '\\1', '\\2', '\\4')", ' '.$code );
|
||||
|
||||
return trim($code);
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Remove leading and trailing newlines
|
||||
//===================================================
|
||||
|
||||
function _trim_newlines($code)
|
||||
{
|
||||
$code = preg_replace("/^\n{1,}/s", "", $code );
|
||||
$code = preg_replace("/\n{1,}$/s", "", $code );
|
||||
return $code;
|
||||
}
|
||||
|
||||
//===================================================
|
||||
// Remove preg_replace/e slashes
|
||||
//===================================================
|
||||
|
||||
function _trim_slashes($code)
|
||||
{
|
||||
$code = str_replace( '\"' , '"', $code );
|
||||
$code = str_replace( "\\'", "'", $code );
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Topic display module
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 18th February 2002
|
||||
|
|
||||
| > Module Version Number: 1.1.0
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class topic_display {
|
||||
|
||||
var $output = "";
|
||||
var $base_url = "";
|
||||
var $html = "";
|
||||
var $moderator = array();
|
||||
var $forum = array();
|
||||
var $topic = array();
|
||||
var $mem_titles = array();
|
||||
var $mod_action = array();
|
||||
var $poll_html = "";
|
||||
var $parser = "";
|
||||
var $mimetypes = "";
|
||||
var $nav_extra = "";
|
||||
var $read_array = array();
|
||||
var $mod_panel_html = "";
|
||||
var $warn_range = 0;
|
||||
var $warn_done = 0;
|
||||
var $pfields = array();
|
||||
var $pfields_dd = array();
|
||||
var $md5_check = "";
|
||||
var $post_count = 0;
|
||||
var $cached_members = array();
|
||||
var $first_printed = 0;
|
||||
var $pids = array();
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Register class
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function register_class($class="")
|
||||
{
|
||||
$this->lib = &$class;
|
||||
|
||||
$this->topic = $this->lib->topic;
|
||||
$this->forum = $this->lib->forum;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Our constructor, load words, load skin, print the topic listing
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function auto_run()
|
||||
{
|
||||
global $ibforums, $forums, $DB, $std, $print, $skin_universal;
|
||||
|
||||
require_once( ROOT_PATH.'sources/topics.php' );
|
||||
|
||||
$this->lib = new topics();
|
||||
|
||||
$this->lib->init();
|
||||
$this->lib->topic_set_up();
|
||||
|
||||
$this->topic = &$this->lib->topic;
|
||||
$this->forum = &$this->lib->forum;
|
||||
|
||||
//-----------------------------------------
|
||||
// Checky checky
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->topic['topic_firstpost'] )
|
||||
{
|
||||
$std->boink_it($ibforums->base_url."showtopic=".$this->topic['tid'].'&mode=standard');
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Print it
|
||||
//-----------------------------------------
|
||||
|
||||
$this->output = str_replace( "<!--IBF.MOD_PANEL-->", $this->lib->moderation_panel(), $this->output );
|
||||
|
||||
// Enable quick reply box?
|
||||
|
||||
if ( ( $this->topic['quick_reply'] == 1 )
|
||||
and ( $std->check_perms( $this->topic['reply_perms']) == TRUE )
|
||||
and ( $this->topic['state'] != 'closed' ) )
|
||||
{
|
||||
$show = "none";
|
||||
|
||||
$sqr = $std->my_getcookie("open_qr");
|
||||
|
||||
if ( $sqr == 1 )
|
||||
{
|
||||
$show = "show";
|
||||
}
|
||||
$this->output = str_replace( "<!--IBF.QUICK_REPLY_CLOSED-->", $this->lib->html->quick_reply_box_closed(), $this->output );
|
||||
$this->output = str_replace( "<!--IBF.QUICK_REPLY_OPEN-->" , $this->lib->html->quick_reply_box_open($this->topic['forum_id'], $this->topic['tid'], $show, $this->md5_check), $this->output );
|
||||
}
|
||||
|
||||
$this->output = str_replace( "<!--IBF.TOPIC_OPTIONS_CLOSED-->", $this->lib->html->topic_opts_closed(), $this->output );
|
||||
$this->output = str_replace( "<!--IBF.TOPIC_OPTIONS_OPEN-->" , $this->lib->html->topic_opts_open($this->topic['forum_id'], $this->topic['tid']), $this->output );
|
||||
|
||||
$this->topic['id'] = $this->topic['forum_id'];
|
||||
|
||||
$this->output = str_replace( "<!--IBF.FORUM_RULES-->", $std->print_forum_rules($this->topic), $this->output );
|
||||
|
||||
//-----------------------------------------
|
||||
// Topic multi-moderation - yay!
|
||||
//-----------------------------------------
|
||||
|
||||
$this->output = str_replace( "<!--IBF.MULTIMOD-->", $this->lib->multi_moderation(), $this->output );
|
||||
|
||||
// Pass it to our print routine
|
||||
|
||||
$print->add_output("$this->output");
|
||||
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> {$this->topic['title']}",
|
||||
'JS' => 1,
|
||||
'NAV' => $this->lib->nav,
|
||||
) );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Show the damned topic batman
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function display_topic()
|
||||
{
|
||||
global $ibforums, $forums, $DB, $std, $print;
|
||||
|
||||
//-----------------------------------------
|
||||
// Grab the posts we'll need
|
||||
//-----------------------------------------
|
||||
|
||||
$first = intval($ibforums->input['st']);
|
||||
|
||||
$query_type = 'topics_get_posts';
|
||||
|
||||
if ( $ibforums->vars['post_order_column'] != 'post_date' )
|
||||
{
|
||||
$ibforums->vars['post_order_column'] = 'pid';
|
||||
}
|
||||
|
||||
if ( $ibforums->vars['post_order_sort'] != 'desc' )
|
||||
{
|
||||
$ibforums->vars['post_order_sort'] = 'asc';
|
||||
}
|
||||
|
||||
if ($ibforums->vars['au_cutoff'] == "")
|
||||
{
|
||||
$ibforums->vars['au_cutoff'] = 15;
|
||||
}
|
||||
|
||||
if ( $ibforums->vars['custom_profile_topic'] == 1 )
|
||||
{
|
||||
$query_type = 'topics_get_posts_with_join';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Moderator?
|
||||
//-----------------------------------------
|
||||
|
||||
$queued_query_bit = ' and queued=0';
|
||||
|
||||
if ( $std->can_queue_posts($this->topic['forum_id']) )
|
||||
{
|
||||
$queued_query_bit = '';
|
||||
|
||||
if ( $ibforums->input['modfilter'] == 'invisible_posts' )
|
||||
{
|
||||
$queued_query_bit = ' and queued=1';
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Using "new" mode?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->lib->topic_view_mode == 'linearplus' and $this->topic['topic_firstpost'] )
|
||||
{
|
||||
$this->topic['new_mode_start'] = $first + 1;
|
||||
|
||||
if ( $first )
|
||||
{
|
||||
$this->topic['new_mode_start']--;
|
||||
}
|
||||
|
||||
if ( $first + $ibforums->vars['display_max_posts'] > ( $this->topic['posts'] + 1 ) )
|
||||
{
|
||||
$this->topic['new_mode_end'] = $this->topic['posts'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->topic['new_mode_end'] = $first + ($ibforums->vars['display_max_posts'] - 1);
|
||||
}
|
||||
|
||||
if ( $first )
|
||||
{
|
||||
$this->pids = array( 0 => $this->topic['topic_firstpost'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get PIDS of this page/topic
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->simple_construct( array (
|
||||
'select' => 'pid',
|
||||
'from' => 'posts',
|
||||
'where' => 'topic_id='.$this->topic['tid']. $queued_query_bit,
|
||||
'order' => 'pid',
|
||||
'limit' => array( $first, $ibforums->vars['display_max_posts'] )
|
||||
) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
while( $p = $DB->fetch_row() )
|
||||
{
|
||||
$this->pids[] = $p['pid'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Run query
|
||||
//-----------------------------------------
|
||||
|
||||
$this->lib->topic_view_mode = 'linear';
|
||||
|
||||
$DB->simple_construct( array (
|
||||
'select' => 'pid',
|
||||
'from' => 'posts',
|
||||
'where' => 'topic_id='.$this->topic['tid']. $queued_query_bit,
|
||||
'order' => $ibforums->vars['post_order_column'].' '.$ibforums->vars['post_order_sort'],
|
||||
'limit' => array( $first, $ibforums->vars['display_max_posts'] )
|
||||
) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
while( $p = $DB->fetch_row() )
|
||||
{
|
||||
$this->pids[] = $p['pid'];
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have any PIDS?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! count( $this->pids ) )
|
||||
{
|
||||
if ( $first )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Add dummy PID, AUTO FIX
|
||||
// will catch this below...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->pids[] = 0;
|
||||
}
|
||||
|
||||
if ( $ibforums->input['modfilter'] == 'invisible_posts' )
|
||||
{
|
||||
$this->pids[] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Attachment PIDS
|
||||
//-----------------------------------------
|
||||
|
||||
$this->lib->attach_pids = $this->pids;
|
||||
|
||||
//-----------------------------------------
|
||||
// Fail safe
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! is_array( $this->pids ) or ! count( $this->pids ) )
|
||||
{
|
||||
$this->pids = array( 0 => 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get posts
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->cache_add_query( $query_type, array( 'pids' => $this->pids, 'scol' => $ibforums->vars['post_order_column'], 'sord' => $ibforums->vars['post_order_sort'] ) );
|
||||
|
||||
$oq = $DB->simple_exec();
|
||||
|
||||
if ( ! $DB->get_num_rows() )
|
||||
{
|
||||
if ($first >= $ibforums->vars['display_max_posts'])
|
||||
{
|
||||
//-----------------------------------------
|
||||
// AUTO FIX: Get the correct number of replies...
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->simple_construct( array(
|
||||
'select' => 'COUNT(*) as pcount',
|
||||
'from' => 'posts',
|
||||
'where' => "topic_id=".$this->topic['tid']." and queued !=1"
|
||||
) );
|
||||
|
||||
$newq = $DB->simple_exec();
|
||||
|
||||
$pcount = $DB->fetch_row($newq);
|
||||
|
||||
$pcount['pcount'] = $pcount['pcount'] > 0 ? $pcount['pcount'] - 1 : 0;
|
||||
|
||||
//-----------------------------------------
|
||||
// Update the post table...
|
||||
//-----------------------------------------
|
||||
|
||||
if ($pcount['pcount'] > 1)
|
||||
{
|
||||
$DB->simple_construct( array(
|
||||
'update' => 'topics',
|
||||
'set' => "posts=".$pcount['pcount'],
|
||||
'where' => "tid=".$this->topic['tid']
|
||||
) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
}
|
||||
|
||||
$std->boink_it($ibforums->base_url."act=ST&f={$this->forum['id']}&t={$this->topic['tid']}&view=getlastpost");
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Render the page top
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->lib->topic_view_mode == 'linearplus' and $this->topic['posts'] > 0 )
|
||||
{
|
||||
$this->output .= $this->lib->html->topic_page_top_new_mode( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->output .= $this->lib->html->topic_page_top_classic( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Format and print out the topic list
|
||||
//-----------------------------------------
|
||||
|
||||
while ( $row = $DB->fetch_row( $oq ) )
|
||||
{
|
||||
$return = $this->lib->parse_row( $row );
|
||||
|
||||
$poster = $return['poster'];
|
||||
$row = $return['row'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we giving this bloke a good ignoring?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->member['ignored_users'] )
|
||||
{
|
||||
if ( strstr( $ibforums->member['ignored_users'], ','.$poster['id'].',' ) and $ibforums->input['p'] != $row['pid'] )
|
||||
{
|
||||
if ( ! strstr( $ibforums->vars['cannot_ignore_groups'], ','.$poster['mgroup'].',' ) )
|
||||
{
|
||||
$this->output .= $this->lib->html->render_row_hidden( $row, $poster );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output .= $this->lib->html->RenderRow( $row, $poster );
|
||||
|
||||
//-----------------------------------------
|
||||
// Show end first post
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->lib->topic_view_mode == 'linearplus' and $this->first_printed == 0 and $row['pid'] == $this->topic['topic_firstpost'] and $this->topic['posts'] > 0)
|
||||
{
|
||||
$this->output .= $this->lib->html->topic_end_first_post( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Print the footer
|
||||
//-----------------------------------------
|
||||
|
||||
$this->output .= $this->lib->html->TableFooter( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ), 0, $std->return_md5_check() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,508 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Topic Outline Display Module wodule wookie, nookie shut up
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 1st December 2003 (Pinch and a punch!)
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > DBA Checked: Fri 21 May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class topic_display {
|
||||
|
||||
var $output = "";
|
||||
var $html = "";
|
||||
var $forum = array();
|
||||
var $topic = array();
|
||||
var $mem_titles = array();
|
||||
var $mod_action = array();
|
||||
var $poll_html = "";
|
||||
var $parser = "";
|
||||
var $mimetypes = "";
|
||||
var $nav_extra = "";
|
||||
var $mod_panel_html = "";
|
||||
var $warn_range = 0;
|
||||
var $warn_done = 0;
|
||||
var $pfields = array();
|
||||
var $pfields_dd = array();
|
||||
var $md5_check = "";
|
||||
var $post_count = 0;
|
||||
var $cached_members = array();
|
||||
var $pids = array();
|
||||
var $lib = "";
|
||||
var $structured_pids = array();
|
||||
var $post_cache = array();
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Register class
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function register_class($class="")
|
||||
{
|
||||
$this->lib = &$class;
|
||||
|
||||
$this->topic = $this->lib->topic;
|
||||
$this->forum = $this->lib->forum;
|
||||
|
||||
$this->topic['SHOW_PAGES'] = "";
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Our constructor, load words, load skin, print the topic listing
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function auto_run()
|
||||
{
|
||||
global $ibforums, $forums, $DB, $std, $print, $skin_universal;
|
||||
|
||||
//-----------------------------------------
|
||||
// Require and init topics.php
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( ROOT_PATH.'sources/topics.php' );
|
||||
|
||||
$this->lib = new topics();
|
||||
|
||||
$this->lib->init();
|
||||
$this->lib->topic_set_up();
|
||||
|
||||
$this->topic = &$this->lib->topic;
|
||||
$this->forum = &$this->lib->forum;
|
||||
|
||||
$this->topic['SHOW_PAGES'] = "";
|
||||
|
||||
//-----------------------------------------
|
||||
// Checky checky
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->topic['topic_firstpost'] )
|
||||
{
|
||||
$std->boink_it($ibforums->base_url."showtopic=".$this->topic['tid'].'&mode=standard');
|
||||
}
|
||||
|
||||
$this->display_topic();
|
||||
|
||||
//-----------------------------------------
|
||||
// Print it
|
||||
//-----------------------------------------
|
||||
|
||||
$this->topic['id'] = $this->topic['forum_id'];
|
||||
|
||||
$this->output = str_replace( "<!--IBF.FORUM_RULES-->", $std->print_forum_rules($this->topic), $this->output );
|
||||
|
||||
// Pass it to our print routine
|
||||
|
||||
$print->add_output("$this->output");
|
||||
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> {$this->topic['title']}",
|
||||
'JS' => 1,
|
||||
'NAV' => $this->lib->nav,
|
||||
) );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Show the damned topic batman
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function display_topic()
|
||||
{
|
||||
global $ibforums, $forums, $DB, $std, $print, $skin_universal;
|
||||
|
||||
//-----------------------------------------
|
||||
// Grab the posts we'll need
|
||||
//-----------------------------------------
|
||||
|
||||
$query_type = 'topics_get_posts';
|
||||
|
||||
$first = intval($ibforums->input['start']);
|
||||
$last = $ibforums->vars['threaded_per_page'] ? $ibforums->vars['threaded_per_page'] : 250;
|
||||
|
||||
if ( $ibforums->vars['custom_profile_topic'] == 1 )
|
||||
{
|
||||
$query_type = 'topics_get_posts_with_join';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// GET meh pids
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $first > 0 )
|
||||
{
|
||||
// we're on a page, make sure init val is there
|
||||
|
||||
$this->pids[0] = $this->topic['topic_firstpost'];
|
||||
$this->structured_pids[ 0 ][] = $this->topic['topic_firstpost'];
|
||||
}
|
||||
|
||||
$DB->simple_construct( array (
|
||||
'select' => 'pid, post_parent',
|
||||
'from' => 'posts',
|
||||
'where' => 'topic_id='.$this->topic['tid']. ' and queued != 1',
|
||||
'order' => 'pid',
|
||||
'limit' => array( $first, $last )
|
||||
) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
while( $p = $DB->fetch_row() )
|
||||
{
|
||||
$this->pids[] = $p['pid'];
|
||||
|
||||
// Force to be children of 'root' post
|
||||
|
||||
if ( ! $p['post_parent'] and $p['pid'] != $this->topic['topic_firstpost'] )
|
||||
{
|
||||
$p['post_parent'] = $this->topic['topic_firstpost'];
|
||||
}
|
||||
|
||||
$this->structured_pids[ $p['post_parent'] ][] = $p['pid'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get post bodah
|
||||
//-----------------------------------------
|
||||
|
||||
if ( count( $this->pids ) )
|
||||
{
|
||||
$DB->simple_construct( array (
|
||||
'select' => 'pid, post, author_id, author_name, post_date, post_title, post_parent, topic_id, icon_id',
|
||||
'from' => 'posts',
|
||||
'where' => 'pid IN('.implode(',',$this->pids).')',
|
||||
'order' => 'pid',
|
||||
) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
while( $p = $DB->fetch_row() )
|
||||
{
|
||||
if ( ! $p['post_parent'] and $p['pid'] != $this->topic['topic_firstpost'] )
|
||||
{
|
||||
$p['post_parent'] = $this->topic['topic_firstpost'];
|
||||
}
|
||||
|
||||
$this->post_cache[ $p['pid'] ] = $p;
|
||||
|
||||
$this->last_id = $p['pid'];
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Force root in cache
|
||||
//-----------------------------------------
|
||||
|
||||
$this->post_cache[0] = array( 'id' => 1 );
|
||||
|
||||
$this->post_cache[$this->topic['topic_firstpost']]['post_title'] = $this->topic['title'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we viewing Posts?
|
||||
//-----------------------------------------
|
||||
|
||||
$post_id = intval($ibforums->input['pid']);
|
||||
|
||||
$postid_array = array( 1 => $post_id );
|
||||
|
||||
if ( $post_id and $post_id != $this->topic['topic_firstpost'] )
|
||||
{
|
||||
$parents = $this->post_get_parents( $post_id );
|
||||
|
||||
if ( count($parents) )
|
||||
{
|
||||
foreach( $parents as $p => $pid )
|
||||
{
|
||||
if ( $pid != $this->topic['topic_firstpost'] )
|
||||
{
|
||||
$postid_array[] = $pid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count($postid_array) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get root post and children of clicked
|
||||
//-----------------------------------------
|
||||
|
||||
$this->used_post_ids = ','.implode( ",", $postid_array ).',';
|
||||
|
||||
$postid_array[0] = $this->topic['topic_firstpost'];
|
||||
|
||||
$DB->cache_add_query( $query_type, array( 'pids' => $postid_array, 'scol' => 'pid', 'sord' => 'asc') );
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Just get root
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->cache_add_query( $query_type, array( 'pids' => array( 0 => $this->topic['topic_firstpost'] ) ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Attachment PIDS
|
||||
//-----------------------------------------
|
||||
|
||||
$this->lib->attach_pids = $postid_array;
|
||||
|
||||
//-----------------------------------------
|
||||
// Render the original post
|
||||
//-----------------------------------------
|
||||
|
||||
$this->output .= $this->lib->html->topic_page_top_new_mode( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
//-----------------------------------------
|
||||
// Format and print out the topic list
|
||||
//-----------------------------------------
|
||||
|
||||
$num_rows = $DB->get_num_rows();
|
||||
|
||||
while ( $row = $DB->fetch_row() )
|
||||
{
|
||||
$return = $this->lib->parse_row( $row );
|
||||
|
||||
$poster = $return['poster'];
|
||||
$row = $return['row'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we giving this bloke a good ignoring?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->member['ignored_users'] )
|
||||
{
|
||||
if ( strstr( $ibforums->member['ignored_users'], ','.$poster['id'].',' ) and $ibforums->input['p'] != $row['pid'] )
|
||||
{
|
||||
if ( ! strstr( $ibforums->vars['cannot_ignore_groups'], ','.$poster['mgroup'].',' ) )
|
||||
{
|
||||
$this->output .= $this->lib->html->render_row_hidden( $row, $poster );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output .= $this->lib->html->RenderRow( $row, $poster );
|
||||
|
||||
if ( ! $this->printed and $num_rows > 1 )
|
||||
{
|
||||
$this->output .= $this->lib->html->topic_end_first_post( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ), 1 );
|
||||
$this->printed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->output .= $this->lib->html->topic_end_outline( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Sort out pagination
|
||||
//-----------------------------------------
|
||||
|
||||
$total_replies = $this->topic['posts'];
|
||||
$show_replies = count( $this->structured_pids) - 1;
|
||||
|
||||
$this->topic['threaded_pages'] = $std->build_pagelinks( array( 'TOTAL_POSS' => $total_replies,
|
||||
'PER_PAGE' => $last,
|
||||
'CUR_ST_VAL' => $ibforums->input['start'],
|
||||
'L_SINGLE' => "",
|
||||
'BASE_URL' => $ibforums->base_url."showtopic=".$this->topic['tid'],
|
||||
'USE_ST' => 'start'
|
||||
) );
|
||||
|
||||
//-----------------------------------------
|
||||
// START GETTING THE OUTLINE LIST
|
||||
//-----------------------------------------
|
||||
|
||||
$this->output .= $this->lib->html->toutline_start_list();
|
||||
|
||||
$this->output .= $this->loop_get_children();
|
||||
|
||||
$this->output .= $this->lib->html->toutline_end_list($this->topic['threaded_pages']);
|
||||
|
||||
$this->output .= $this->lib->html->TableFooter( array( 'TOPIC' => $this->topic, 'FORUM' => $this->forum ), 1, $std->return_md5_check() );
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Render kiddies
|
||||
//-----------------------------------------
|
||||
|
||||
function loop_get_children($root_id=0, $html="" ,$dguide=-1)
|
||||
{
|
||||
global $DB, $ibforums, $std, $forums;
|
||||
|
||||
$dguide++;
|
||||
|
||||
if ( is_array( $this->structured_pids[ $root_id ] ) )
|
||||
{
|
||||
if ( count( $this->structured_pids[ $root_id ] ) )
|
||||
{
|
||||
$html .= $this->lib->html->toutline_start_new_parent();
|
||||
|
||||
foreach( $this->structured_pids[ $root_id ] as $idx => $pid )
|
||||
{
|
||||
$html .= $this->render_list_row( $this->post_cache[ $pid ], $dguide );
|
||||
|
||||
$html = $this->loop_get_children( $pid, $html, $dguide );
|
||||
}
|
||||
|
||||
$html .= $this->lib->html->toutline_end_new_parent();
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Parse row
|
||||
//-----------------------------------------
|
||||
|
||||
function render_list_row( $post, $depth=0 )
|
||||
{
|
||||
global $DB, $ibforums, $std, $forums;
|
||||
|
||||
$post['depthguide'] = "";
|
||||
|
||||
$ibforums->vars['post_showtext_notitle'] = 1;
|
||||
|
||||
for( $i = 1 ; $i < $depth; $i++ )
|
||||
{
|
||||
$post['depthguide'] .= $this->depth_guide[ $i ];
|
||||
}
|
||||
|
||||
// Last child?
|
||||
|
||||
if ( $depth > 0 )
|
||||
{
|
||||
$last_id = count($this->structured_pids[ $post['post_parent'] ]) - 1;
|
||||
|
||||
if ( $this->structured_pids[ $post['post_parent'] ][$last_id] == $post['pid'] )
|
||||
{
|
||||
$this->depth_guide[ $depth ] = '<img src="style_images/<#IMG_DIR#>/spacer.gif" width="20" height="16">';
|
||||
$post['depthguide'] .= '<img src="style_images/<#IMG_DIR#>/to_post_no_children.gif" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->depth_guide[ $depth ] = '<img src="style_images/<#IMG_DIR#>/to_down_pipe.gif">';
|
||||
$post['depthguide'] .= '<img src="style_images/<#IMG_DIR#>/to_post_with_children.gif" />';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $post['post_title'] )
|
||||
{
|
||||
if ( $ibforums->vars['post_showtext_notitle'] )
|
||||
{
|
||||
$post_text = $this->lib->parser->strip_all_tags( $post['post'] );
|
||||
|
||||
if ( strlen($post_text) > 50 )
|
||||
{
|
||||
$post['post_title'] = substr( $post_text, 0, 50 ).'...';
|
||||
$post['post_title'] = preg_replace( "/&#?(\w+)?;?\.\.\.$/", '...', $post['post_title'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$post['post_title'] = $post_text;
|
||||
}
|
||||
|
||||
if ( ! trim($post['post_title']) )
|
||||
{
|
||||
$post['post_title'] = 'RE: '.$this->topic['title'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$post['post_title'] = 'RE: '.$this->topic['title'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$post['linked_name'] = $std->make_profile_link( $post['author_name'], $post['author_id'] );
|
||||
|
||||
$post['formatted_date'] = $std->get_date( $post['post_date'], 'LONG' );
|
||||
|
||||
$post['new_post'] = '<img src="style_images/<#IMG_DIR#>/to_post_off.gif" />';
|
||||
|
||||
if ( $post['post_date'] > $this->lib->last_read_tid )
|
||||
{
|
||||
$post['new_post'] = '<img src="style_images/<#IMG_DIR#>/to_post.gif" />';
|
||||
}
|
||||
|
||||
//$post['post_debug'] = "{ID: {$post['pid']}} Last Array Index: $last_id - Last id in tree{$this->structured_pids[ $post['post_parent'] ][$last_id]}, DEPTH: $depth, [parent: {$post['post_parent']}]";
|
||||
|
||||
if ( strstr( $this->used_post_ids, ','.$post['pid'].',' ) )
|
||||
{
|
||||
return $this->lib->html->toutline_show_row_highlight( $post );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->lib->html->toutline_show_row( $post );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get parents
|
||||
//-----------------------------------------
|
||||
|
||||
function post_get_parents($root_id, $ids=array())
|
||||
{
|
||||
if ( $this->post_cache[ $root_id ]['post_parent'] )
|
||||
{
|
||||
$ids[] = $this->post_cache[ $root_id ]['post_parent'];
|
||||
|
||||
$ids = $this->post_get_parents( $this->post_cache[ $root_id ]['post_parent'], $ids );
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get children
|
||||
//-----------------------------------------
|
||||
|
||||
function post_get_children($root_id, $ids=array())
|
||||
{
|
||||
if ( is_array($this->structured_pids[ $root_id ]) )
|
||||
{
|
||||
foreach( $this->structured_pids[ $root_id ] as $id => $pid )
|
||||
{
|
||||
$ids[] = $pid;
|
||||
|
||||
$ids = $this->post_get_children( $pdaid, $ids );
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user