Version 2.0.0
This commit is contained in:
1 parent
5699abfc0e
commit
0eecc172d9
696 files changed
+120723
-77160
No files matched your search
@@ -0,0 +1,543 @@
|
||||
<?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
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > CUSTOM PROFILE FIELD CLASS
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 7th April 2004 ( hairdresser was closed today :( )
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > DBA Checked: Wed 19 May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
| EXAMPLE:
|
||||
|
|
||||
| $profile->cache_data = $ibforums->cache['profilefields'];
|
||||
| $profile->member_id = $ibforums->member['id']; // Viewing member
|
||||
| $profile->mem_data_id = $data['id']; // Get data for this member
|
||||
| $profile->init_data();
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
class custom_fields
|
||||
{
|
||||
var $member_id = 0;
|
||||
var $admin = 0;
|
||||
var $supmod = 0;
|
||||
var $mem_data_id = 0;
|
||||
var $init = 0;
|
||||
var $in_fields = array();
|
||||
var $out_fields = array();
|
||||
var $out_chosen = array();
|
||||
var $tmp_fields = array();
|
||||
var $cache_data = "";
|
||||
var $member_data = array();
|
||||
var $field_names = array();
|
||||
var $field_desc = array();
|
||||
var $kill_html = 1;
|
||||
var $error_fields = array( 'toobig' => array(), 'empty' => array(), 'invalid' => array() );
|
||||
|
||||
var $DB = "";
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// CONSTRUCTOR
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function custom_fields( &$DB )
|
||||
{
|
||||
$this->DB = &$DB;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Init (check, load cache)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function init_data()
|
||||
{
|
||||
if ( ! $this->init )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Cache data...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! is_array( $this->cache_data ) )
|
||||
{
|
||||
$this->DB->simple_construct( array( 'select' => '*', 'from' => 'pfields_data', 'order' => 'pf_position' ) );
|
||||
$this->DB->simple_exec();
|
||||
|
||||
while ( $r = $this->DB->fetch_row() )
|
||||
{
|
||||
$this->cache_data[ $r['pf_id'] ] = $r;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get names...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array($this->cache_data) and count($this->cache_data) )
|
||||
{
|
||||
foreach( $this->cache_data as $id => $data )
|
||||
{
|
||||
$this->field_names[ $id ] = $data['pf_title'];
|
||||
$this->field_desc[ $id ] = $data['pf_desc'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Clean up on aisle #4
|
||||
//-----------------------------------------
|
||||
|
||||
$this->out_fields = array();
|
||||
$this->tmp_fields = array();
|
||||
$this->out_chosen = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Get member...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! count( $this->member_data ) and $this->mem_data_id )
|
||||
{
|
||||
$this->member_data = $this->DB->simple_exec_query( array( 'select' => '*', 'from' => 'pfields_content', 'where' => 'member_id='.intval($this->mem_data_id) ) );
|
||||
}
|
||||
|
||||
if ( count( $this->member_data ) )
|
||||
{
|
||||
$this->mem_data_id = $this->member_data['id'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Parse into in fields
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array($this->cache_data) and count( $this->cache_data ) )
|
||||
{
|
||||
foreach( $this->cache_data as $id => $data )
|
||||
{
|
||||
$this->in_fields[ $id ] = $this->member_data['field_'.$id];
|
||||
}
|
||||
}
|
||||
|
||||
$this->init = 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Generate for saving
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function parse_to_save( $register=0, $post='field_' )
|
||||
{
|
||||
if ( is_array($this->cache_data) and count($this->cache_data) )
|
||||
{
|
||||
foreach( $this->cache_data as $i => $row )
|
||||
{
|
||||
if ( ! $register )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Admin / mod only?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $row['pf_admin_only'] )
|
||||
{
|
||||
if ( ! $this->admin or ! $this->supmod )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Can edit? (member, admin, mod)
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $row['pf_member_edit'] )
|
||||
{
|
||||
if ( ! $this->admin or ! $this->supmod )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Show on reg?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $row['pf_show_on_reg'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->tmp_fields[ $i ] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Grab editable fields...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array($this->tmp_fields) and count($this->tmp_fields) )
|
||||
{
|
||||
foreach( $this->tmp_fields as $i => $row )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Too big?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->cache_data[$i]['pf_max_input'] and strlen( $_POST[ $post.$i ] ) > $this->cache_data[$i]['pf_max_input'] )
|
||||
{
|
||||
$this->error_fields['toobig'][] = $row;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Required and NULL?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->cache_data[$i]['pf_not_null'] and trim($_POST[ $post.$i ]) == "" )
|
||||
{
|
||||
$this->error_fields['empty'][] = $row;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Invalid format?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->cache_data[$i]['pf_input_format'] )
|
||||
{
|
||||
$regex = str_replace( 'n', '\\d', preg_quote( $this->cache_data[$i]['pf_input_format'], "#" ) );
|
||||
$regex = str_replace( 'a', '\\w', $regex );
|
||||
|
||||
if ( ! preg_match( "#^".$regex."$#i", trim($_POST[ $post.$i ]) ) )
|
||||
{
|
||||
$this->error_fields['invalid'][] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$this->out_fields[ $post.$i ] = $this->method_format_text_to_save( $_POST[ $post.$i ] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Generate for viewing
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function parse_to_view( $check_topic_format=0 )
|
||||
{
|
||||
if ( is_array( $this->cache_data ) and count( $this->cache_data ) )
|
||||
{
|
||||
foreach( $this->cache_data as $i => $row )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Admin / mod only?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $row['pf_admin_only'] )
|
||||
{
|
||||
if ( ! $this->admin or ! $this->supmod )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Private field (member, admin, mod)
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $row['pf_member_hide'] )
|
||||
{
|
||||
$pass = 0;
|
||||
|
||||
if ( $this->admin )
|
||||
{
|
||||
$pass = 1;
|
||||
}
|
||||
else if ( $this->supmod )
|
||||
{
|
||||
$pass = 1;
|
||||
}
|
||||
else if ( $this->member_id and ( $this->member_id == $this->mem_data_id ) )
|
||||
{
|
||||
$pass = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pass = 0;
|
||||
}
|
||||
|
||||
if ( ! $pass )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Topic format?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $check_topic_format )
|
||||
{
|
||||
if ( ! $row['pf_topic_format'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->tmp_fields[ $i ] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$this->method_parse_out_fields('view');
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Generate for viewing on reg form
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function parse_to_register()
|
||||
{
|
||||
if ( is_array( $this->cache_data ) and count( $this->cache_data ) )
|
||||
{
|
||||
foreach( $this->cache_data as $i => $row )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Show on reg?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $row['pf_show_on_reg'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->tmp_fields[ $i ] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$this->method_parse_out_fields('reg');
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Generate for editing
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function parse_to_edit()
|
||||
{
|
||||
if ( is_array($this->cache_data) and count($this->cache_data) )
|
||||
{
|
||||
foreach( $this->cache_data as $i => $row )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Admin / mod only?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $row['pf_admin_only'] )
|
||||
{
|
||||
if ( ! $this->admin or ! $this->supmod )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Private field (member, admin, mod)
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $row['pf_member_hide'] )
|
||||
{
|
||||
$pass = 0;
|
||||
|
||||
if ( $this->admin )
|
||||
{
|
||||
$pass = 1;
|
||||
}
|
||||
else if ( $this->mod )
|
||||
{
|
||||
$pass = 1;
|
||||
}
|
||||
else if ( $this->member_id )
|
||||
{
|
||||
$pass = 1;
|
||||
}
|
||||
|
||||
if ( ! $pass )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Can edit? (member, admin, mod)
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $row['pf_member_edit'] )
|
||||
{
|
||||
if ( ! $this->admin or ! $this->supmod )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->tmp_fields[ $i ] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$this->method_parse_out_fields('edit');
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Method: Parse out_fields
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function method_parse_out_fields($type='view')
|
||||
{
|
||||
foreach( $this->tmp_fields as $i => $row )
|
||||
{
|
||||
if ($row['pf_type'] == 'drop')
|
||||
{
|
||||
$carray = explode( '|', trim( $row['pf_content'] ) );
|
||||
|
||||
foreach( $carray as $entry )
|
||||
{
|
||||
$value = explode( '=', $entry );
|
||||
|
||||
$ov = trim($value[0]);
|
||||
$td = trim($value[1]);
|
||||
|
||||
if ( $type == 'reg' )
|
||||
{
|
||||
$this->out_fields[ $row['pf_id'] ] .= "<option value='$ov'>$td</option>\n";
|
||||
}
|
||||
else if ( $type == 'view' )
|
||||
{
|
||||
if ( $this->in_fields[ $row['pf_id'] ] == $ov)
|
||||
{
|
||||
$this->out_fields[ $row['pf_id'] ] = $td;
|
||||
$this->out_chosen[ $row['pf_id'] ] = $ov;
|
||||
}
|
||||
}
|
||||
else if ( $type == 'edit' )
|
||||
{
|
||||
if ( $this->in_fields[ $row['pf_id'] ] == $ov and $this->in_fields[ $row['pf_id'] ])
|
||||
{
|
||||
$this->out_fields[ $row['pf_id'] ] .= "<option value='$ov' selected='selected'>$td</option>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->out_fields[ $row['pf_id'] ] .= "<option value='$ov'>$td</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $type == 'view' )
|
||||
{
|
||||
$this->out_fields[ $row['pf_id'] ] = $this->method_make_safe_for_view( $this->in_fields[ $row['pf_id'] ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->out_fields[ $row['pf_id'] ] = $this->method_make_safe_for_form( $this->in_fields[ $row['pf_id'] ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Method: format text to save
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function method_format_text_to_save( $t )
|
||||
{
|
||||
$t = str_replace( "<br>" , "\n", $t );
|
||||
$t = str_replace( "<br />", "\n", $t );
|
||||
$t = str_replace( "'" , "'" , $t );
|
||||
|
||||
if ( @get_magic_quotes_gpc() )
|
||||
{
|
||||
$t = stripslashes($t);
|
||||
}
|
||||
|
||||
return $t;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Method: format_field_for_edit
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function method_format_content_for_edit( $c )
|
||||
{
|
||||
return str_replace( '|', "\n", $c );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Method: format_field_for_topic_view
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function method_format_field_for_topic_view( $i )
|
||||
{
|
||||
$out = $this->out_fields[$i];
|
||||
|
||||
$tmp = $this->cache_data[$i]['pf_topic_format'];
|
||||
|
||||
$tmp = str_replace( '{title}' , $this->field_names[$i], $tmp );
|
||||
$tmp = str_replace( '{key}' , $this->out_chosen[$i] , $tmp );
|
||||
$tmp = str_replace( '{content}', $out , $tmp );
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Method: format_field_for_save
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function method_format_content_for_save( $c )
|
||||
{
|
||||
$c = str_replace( "\r" , "\n", $c );
|
||||
$c = str_replace( "'", "'" , $c );
|
||||
return str_replace( "\n", '|', str_replace( "\n\n", "\n", trim($c) ) );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Make safe for form viewing
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function method_make_safe_for_form( $t )
|
||||
{
|
||||
return str_replace( "'", "'", $t );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Make safe for other viewing (profile, etc)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function method_make_safe_for_view( $t )
|
||||
{
|
||||
if ( $this->kill_html )
|
||||
{
|
||||
$t = htmlentities( $t );
|
||||
$t = preg_replace("/&#([0-9]+);/s", "&#\\1;", $t );
|
||||
}
|
||||
|
||||
return $t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,927 @@
|
||||
<?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
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > DISPLAY CLASS
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 26th January 2004
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > DBA Checked: Wed 19 May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
class display {
|
||||
|
||||
var $to_print = "";
|
||||
var $output = "";
|
||||
var $macros = "";
|
||||
|
||||
//-----------------------------------------
|
||||
// CONSTRUCTOR
|
||||
//-----------------------------------------
|
||||
|
||||
function display()
|
||||
{
|
||||
global $ibforums, $std;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Appends the parsed HTML to our class var
|
||||
//-----------------------------------------
|
||||
|
||||
function add_output($to_add)
|
||||
{
|
||||
$this->to_print .= $to_add;
|
||||
//return 'true' on success
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Parses all the information and prints it.
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function do_output($output_array)
|
||||
{
|
||||
global $DB, $Debug, $ibforums, $std;
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we IPSing?
|
||||
//-----------------------------------------
|
||||
|
||||
$this->_check_ips_report();
|
||||
|
||||
//-----------------------------------------
|
||||
// UNPACK MACROS
|
||||
//-----------------------------------------
|
||||
|
||||
$this->_unpack_macros();
|
||||
|
||||
//-----------------------------------------
|
||||
// END TIMER
|
||||
//-----------------------------------------
|
||||
|
||||
$this->ex_time = sprintf( "%.4f",$Debug->endTimer() );
|
||||
|
||||
//-----------------------------------------
|
||||
// SQL DEBUG?
|
||||
//-----------------------------------------
|
||||
|
||||
$this->_check_debug();
|
||||
|
||||
$stats = $this->_show_debug();
|
||||
|
||||
//-----------------------------------------
|
||||
// NAVIGATION
|
||||
//-----------------------------------------
|
||||
|
||||
$nav = $ibforums->skin_global->start_nav();
|
||||
|
||||
$nav .= "<a href='{$ibforums->base_url}act=idx'>{$ibforums->vars['board_name']}</a>";
|
||||
|
||||
if ( empty($output_array['OVERRIDE']) )
|
||||
{
|
||||
if (is_array( $output_array['NAV'] ) )
|
||||
{
|
||||
foreach ($output_array['NAV'] as $n)
|
||||
{
|
||||
if ($n)
|
||||
{
|
||||
$nav .= "<{F_NAV_SEP}>" . $n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nav .= $ibforums->skin_global->end_nav();
|
||||
|
||||
//-----------------------------------------
|
||||
// CSS
|
||||
//-----------------------------------------
|
||||
|
||||
$css = $this->_get_css();
|
||||
|
||||
//-----------------------------------------
|
||||
// Copy it right
|
||||
//-----------------------------------------
|
||||
|
||||
$extra = "";
|
||||
$ur = '(Trial)';
|
||||
$pwd = 'Powered by ';
|
||||
|
||||
if ( $ibforums->vars['ipb_reg_number'] )
|
||||
{
|
||||
$ur = '';
|
||||
$pwd = '';
|
||||
|
||||
if ( $ibforums->vars['ipb_reg_show'] and $ibforums->vars['ipb_reg_name'] )
|
||||
{
|
||||
$extra = "<div align='center' class='copyright'>Registered to: ". $ibforums->vars['ipb_reg_name']."</div>";
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// REMOVAL OF THIS WITHOUT PURCHASING COPYRIGHT REMOVAL WILL VIOLATE THE LICENCE YOU AGREED
|
||||
// TO WHEN DOWNLOADING THIS PRODUCT. THIS COULD MEAN REMOVAL OF YOUR BOARD AND EVEN
|
||||
// CRIMINAL CHARGES
|
||||
//-----------------------------------------
|
||||
|
||||
$copyright = "<!-- Copyright Information -->\n\n<div align='center' class='copyright'>{$pwd}<a href=\"http://www.invisionboard.com\" target='_blank'>Invision Power Board</a>{$ur} {$ibforums->version} © ".date("Y")." <a href='http://www.invisionpower.com' target='_blank'>IPS, Inc.</a></div>";
|
||||
|
||||
if ($ibforums->vars['ipb_copy_number'])
|
||||
{
|
||||
$copyright = "";
|
||||
}
|
||||
|
||||
$copyright .= $extra;
|
||||
|
||||
//-----------------------------------------
|
||||
// Board header
|
||||
//-----------------------------------------
|
||||
|
||||
$this_header = $ibforums->skin_global->global_board_header();
|
||||
$this_footer = $ibforums->skin_global->global_board_footer( $std->get_date( time(), 'SHORT', 1 ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Show rules link?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['gl_show'] and $ibforums->vars['gl_title'])
|
||||
{
|
||||
if ($ibforums->vars['gl_link'] == "")
|
||||
{
|
||||
$ibforums->vars['gl_link'] = $ibforums->base_url."act=boardrules";
|
||||
}
|
||||
|
||||
$this_header = str_replace( "<!--IBF.RULES-->", $ibforums->skin_global->rules_link($ibforums->vars['gl_link'], $ibforums->vars['gl_title']), $this_header );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Build the members bar
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ($ibforums->member['g_max_messages'] > 0) and ($ibforums->member['msg_total'] >= $ibforums->member['g_max_messages']) )
|
||||
{
|
||||
$msg_data['TEXT'] = $ibforums->lang['msg_full'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ibforums->member['new_msg'] = $ibforums->member['new_msg'] == "" ? 0 : $ibforums->member['new_msg'];
|
||||
|
||||
$msg_data['TEXT'] = sprintf( $ibforums->lang['msg_new'], $ibforums->member['new_msg']);
|
||||
}
|
||||
|
||||
$output_array['MEMBER_BAR'] = $ibforums->skin_global->member_bar($msg_data);
|
||||
|
||||
//-----------------------------------------
|
||||
// Board offline?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['board_offline'] == 1)
|
||||
{
|
||||
$output_array['TITLE'] = $ibforums->lang['warn_offline']." ".$output_array['TITLE'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Showing skin jump?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->vars['allow_skins'] and $ibforums->member['id'] > 0 )
|
||||
{
|
||||
$skin_jump = $ibforums->skin_global->global_skin_chooser( $this->_build_skin_list() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$skin_jump = "";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Showing skin jump?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->member['id'] > 0 )
|
||||
{
|
||||
$lang_jump = $ibforums->skin_global->global_lang_chooser( $this->_build_language_list() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$lang_jump = "";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Show quick stats?
|
||||
//-----------------------------------------
|
||||
|
||||
$gzip_status = $ibforums->vars['disable_gzip'] == 1 ? $ibforums->lang['gzip_off'] : $ibforums->lang['gzip_on'];
|
||||
|
||||
if ( ! $ibforums->server_load )
|
||||
{
|
||||
$ibforums->server_load = '--';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Basics
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->member['id'] and $ibforums->vars['debug_level'] )
|
||||
{
|
||||
$quickstats = $ibforums->skin_global->global_quick_stats($this->ex_time, $gzip_status, $ibforums->server_load, $DB->get_query_cnt() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$quickstats = "";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Add in task image?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( time() >= $ibforums->cache['systemvars']['task_next_run'] )
|
||||
{
|
||||
$this->to_print .= "<!--TASK--><img src='{$ibforums->base_url}act=task' border='0' height='1' width='1' /><!--ETASK-->";
|
||||
}
|
||||
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% CSS %>" , $css , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% JAVASCRIPT %>" , "" , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% TITLE %>" , $output_array['TITLE'] , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% BOARD %>" , $this->to_print , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% STATS %>" , $stats , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% GENERATOR %>" , "" , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% COPYRIGHT %>" , $copyright , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% BOARD HEADER %>" , $this_header , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% BOARD FOOTER %>" , $this_footer , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% NAVIGATION %>" , $nav , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% SKINCHOOSER %>" , $skin_jump , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% LANGCHOOSER %>" , $lang_jump , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% QUICKSTATS %>" , $quickstats , $ibforums->skin['_wrapper']);
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% LOFIVERSION %>" , $this->_get_lofi_link() , $ibforums->skin['_wrapper']);
|
||||
|
||||
if ( empty($output_array['OVERRIDE']) )
|
||||
{
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% MEMBER BAR %>", $output_array['MEMBER_BAR'], $ibforums->skin['_wrapper']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<% MEMBER BAR %>", $ibforums->skin_global->member_bar_disabled(), $ibforums->skin['_wrapper']);
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have a PM show?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->member['show_popup'])
|
||||
{
|
||||
$DB->simple_construct( array( 'update' => 'members', 'set' => 'show_popup=0', 'where' => 'id='.$ibforums->member['id'] ) );
|
||||
$DB->simple_shutdown_exec();
|
||||
|
||||
if ( $ibforums->input['act'] != 'Msg' )
|
||||
{
|
||||
$ibforums->skin['_wrapper'] = str_replace( '<!--IBF.NEWPMBOX-->', $std->get_new_pm_notification(), $ibforums->skin['_wrapper'] );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Stick in chat link? top_site_list_integrate
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['chat_account_no'] or $ibforums->vars['chat04_account_no'])
|
||||
{
|
||||
$ibforums->vars['chat_height'] += $ibforums->vars['chat_poppad'] ? $ibforums->vars['chat_poppad'] : 50;
|
||||
$ibforums->vars['chat_width'] += $ibforums->vars['chat_poppad'] ? $ibforums->vars['chat_poppad'] : 50;
|
||||
|
||||
$chat_link = ( $ibforums->vars['chat_display'] == 'self' )
|
||||
? $ibforums->skin_global->show_chat_link_inline()
|
||||
: $ibforums->skin_global->show_chat_link_popup();
|
||||
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<!--IBF.CHATLINK-->", $chat_link, $ibforums->skin['_wrapper'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Stick in TSL link?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['top_site_list_integrate'])
|
||||
{
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<!--IBF.TSLLINK-->", $ibforums->skin_global->show_tsl_link_inline(), $ibforums->skin['_wrapper'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get the macros and replace them
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array( $this->macros ) )
|
||||
{
|
||||
foreach( $this->macros as $i => $row )
|
||||
{
|
||||
if ($row['macro_value'] != "")
|
||||
{
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<{".$row['macro_value']."}>", $row['macro_replace'], $ibforums->skin['_wrapper'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<#IMG_DIR#>", $ibforums->skin['_imagedir'], $ibforums->skin['_wrapper'] );
|
||||
$ibforums->skin['_wrapper'] = str_replace( "<#EMO_DIR#>", $ibforums->skin['_emodir'] , $ibforums->skin['_wrapper'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// Images on another server? uncomment and alter below
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->vars['ipb_img_url'] )
|
||||
{
|
||||
$ibforums->skin['_wrapper'] = preg_replace( "#img\s+?src=[\"']style_(images|avatars|emoticons)(.+?)[\"'](.+?)?".">#is", "img src=\"".$ibforums->vars['ipb_img_url']."style_\\1\\2\"\\3>", $ibforums->skin['_wrapper'] );
|
||||
}
|
||||
|
||||
$this->_finish();
|
||||
|
||||
print $ibforums->skin['_wrapper'];
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// print the headers
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function do_headers()
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
if ($ibforums->vars['print_headers'])
|
||||
{
|
||||
@header("HTTP/1.0 200 OK");
|
||||
@header("HTTP/1.1 200 OK");
|
||||
@header("Content-type: text/html");
|
||||
|
||||
if ($ibforums->vars['nocache'])
|
||||
{
|
||||
@header("Cache-Control: no-cache, must-revalidate, max-age=0");
|
||||
@header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
@header("Pragma: no-cache");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// print a pure redirect screen
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function redirect_screen($text="", $url="", $override=0)
|
||||
{
|
||||
global $ibforums, $std, $DB;
|
||||
|
||||
//-----------------------------------------
|
||||
// Make sure global skin is loaded
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->skin_global == "" )
|
||||
{
|
||||
$std->load_template('skin_global');
|
||||
}
|
||||
|
||||
if ($ibforums->input['debug'])
|
||||
{
|
||||
flush();
|
||||
exit();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// $ibforums not initialized yet?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $override != 1 )
|
||||
{
|
||||
if ( $ibforums->base_url )
|
||||
{
|
||||
$url = $ibforums->base_url.$url;
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?".$url;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Feck off first?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->vars['ipb_remove_redirect_pages'] == 1 )
|
||||
{
|
||||
$std->boink_it( $url );
|
||||
}
|
||||
|
||||
$ibforums->lang['stand_by'] = stripslashes($ibforums->lang['stand_by']);
|
||||
|
||||
//-----------------------------------------
|
||||
// CSS
|
||||
//-----------------------------------------
|
||||
|
||||
$css = $this->_get_css();
|
||||
|
||||
//-----------------------------------------
|
||||
// Get template
|
||||
//-----------------------------------------
|
||||
|
||||
$htm = $ibforums->skin_global->Redirect( ucfirst($text), $url, $css);
|
||||
|
||||
//-----------------------------------------
|
||||
// Get and parse macros
|
||||
//-----------------------------------------
|
||||
|
||||
$this->_unpack_macros();
|
||||
|
||||
foreach( $this->macros as $i => $row )
|
||||
{
|
||||
if ($row['macro_value'] != "")
|
||||
{
|
||||
$htm = str_replace( "<{".$row['macro_value']."}>", $row['macro_replace'], $htm );
|
||||
}
|
||||
}
|
||||
|
||||
$htm = str_replace( "<#IMG_DIR#>", $ibforums->skin['_imagedir'], $htm );
|
||||
|
||||
$this->_finish();
|
||||
|
||||
echo ($htm);
|
||||
exit;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// print a minimalist screen suitable for small pop up windows
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function pop_up_window($title = 'Invision Power Board', $text = "" )
|
||||
{
|
||||
global $ibforums, $DB;
|
||||
|
||||
//-----------------------------------------
|
||||
// CSS
|
||||
//-----------------------------------------
|
||||
|
||||
$css = $this->_get_css();
|
||||
|
||||
//-----------------------------------------
|
||||
// Get template
|
||||
//-----------------------------------------
|
||||
|
||||
$html = $ibforums->skin_global->pop_up_window($title, $css, $text);
|
||||
|
||||
//-----------------------------------------
|
||||
// Get and parse macros
|
||||
//-----------------------------------------
|
||||
|
||||
$this->_unpack_macros();
|
||||
|
||||
foreach( $this->macros as $i => $row )
|
||||
{
|
||||
if ($row['macro_value'] != "")
|
||||
{
|
||||
$html = str_replace( "<{".$row['macro_value']."}>", $row['macro_replace'], $html );
|
||||
}
|
||||
}
|
||||
|
||||
$html = str_replace( "<#IMG_DIR#>", $ibforums->skin['_imagedir'], $html );
|
||||
$html = str_replace( "<#EMO_DIR#>", $ibforums->skin['_emodir'] , $html );
|
||||
|
||||
//-----------------------------------------
|
||||
// Images on another server? uncomment and alter below
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->vars['ipb_img_url'] )
|
||||
{
|
||||
$html = preg_replace( "#img\s+?src=[\"']style_(images|avatars|emoticons)(.+?)[\"'](.+?)?".">#is", "img src=\"".$ibforums->vars['ipb_img_url']."style_\\1\\2\"\\3>", $html );
|
||||
}
|
||||
|
||||
$this->_finish();
|
||||
|
||||
echo ($html);
|
||||
exit;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Show lo-fi link
|
||||
// @internal
|
||||
//-----------------------------------------
|
||||
|
||||
function _get_lofi_link()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$link = "";
|
||||
$char = '/';
|
||||
|
||||
if ( substr(PHP_OS, 0, 3) == 'WIN' OR php_sapi_name() == 'cgi' OR php_sapi_name() == 'apache2filter' )
|
||||
{
|
||||
$char = '?';
|
||||
}
|
||||
|
||||
if ( $ibforums->input['act'] == 'st' )
|
||||
{
|
||||
$link = $char.'t'.$ibforums->input['t'].'.html';
|
||||
}
|
||||
else if ( $ibforums->input['act'] == 'sf' )
|
||||
{
|
||||
$link = $char.'f'.$ibforums->input['f'].'.html';
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Build Languages List
|
||||
// @internal
|
||||
//-----------------------------------------
|
||||
|
||||
function _build_language_list()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$lang_list = "";
|
||||
|
||||
//-----------------------------------------
|
||||
// Roots
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $ibforums->cache['languages'] as $id => $data )
|
||||
{
|
||||
if ( $ibforums->member['language'] == $data['ldir'] )
|
||||
{
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = "";
|
||||
}
|
||||
|
||||
$lang_list .= "\n<option value='{$data['ldir']}'{$selected}>{$data['lname']}</option>";
|
||||
}
|
||||
|
||||
return $lang_list;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Build Skin List
|
||||
// @internal
|
||||
//-----------------------------------------
|
||||
|
||||
function _build_skin_list()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$skin_list = "";
|
||||
|
||||
//-----------------------------------------
|
||||
// Roots
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $ibforums->cache['skin_id_cache'] as $id => $data )
|
||||
{
|
||||
$skin_sets[ $data['set_parent'] ]['_children'][] = $id;
|
||||
|
||||
if ( $data['set_parent'] < 1 and $id > 1 )
|
||||
{
|
||||
if ( $data['set_hidden'] and ! $ibforums->member['g_access_cp'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$star = $data['set_hidden'] ? ' *' : '';
|
||||
|
||||
if ( $ibforums->skin['_setid'] == $id )
|
||||
{
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = "";
|
||||
}
|
||||
|
||||
$skin_list .= "\n<option value='$id'{$selected}>{$data['set_name']}{$star}</option><!--CHILDREN:{$id}-->";
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Kids...
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $skin_sets as $id => $data )
|
||||
{
|
||||
if ( is_array( $data['_children'] ) and count( $data['_children'] ) > 0 )
|
||||
{
|
||||
$html = "";
|
||||
|
||||
foreach( $data['_children'] as $cid )
|
||||
{
|
||||
if ( $ibforums->cache['skin_id_cache'][ $cid ]['set_hidden'] and ! $ibforums->member['g_access_cp'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$star = $ibforums->cache['skin_id_cache'][ $cid ]['set_hidden'] ? ' *' : '';
|
||||
|
||||
if ( $ibforums->skin['_setid'] == $cid )
|
||||
{
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = "";
|
||||
}
|
||||
|
||||
$html .= "\n<option value='$cid'{$selected}>---- {$ibforums->cache['skin_id_cache'][ $cid ]['set_name']}{$star}</option>";
|
||||
}
|
||||
|
||||
$skin_list = str_replace( "<!--CHILDREN:{$id}-->", $html, $skin_list );
|
||||
}
|
||||
}
|
||||
return $skin_list;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// unpack_macros
|
||||
// @internal
|
||||
//-----------------------------------------
|
||||
|
||||
function _unpack_macros()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$this->macros = unserialize(stripslashes($ibforums->skin['_macro']));
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// show_debug
|
||||
// @internal
|
||||
//-----------------------------------------
|
||||
|
||||
function _show_debug()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$input = "";
|
||||
$queries = "";
|
||||
$sload = "";
|
||||
$stats = "";
|
||||
|
||||
//-----------------------------------------
|
||||
// Form & Get & Skin
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['debug_level'] >= 2)
|
||||
{
|
||||
$stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>FORM and GET Input</div><div class='row1' style='padding:6px'>\n";
|
||||
|
||||
while( list($k, $v) = each($ibforums->input) )
|
||||
{
|
||||
$stats .= "<strong>$k</strong> = $v<br />\n";
|
||||
}
|
||||
|
||||
$stats .= "</div>\n</div>";
|
||||
|
||||
$stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>SKIN & TASK Info</div><div class='row1' style='padding:6px'>\n";
|
||||
|
||||
while( list($k, $v) = each($ibforums->skin) )
|
||||
{
|
||||
if ( strlen($v) > 120 )
|
||||
{
|
||||
$v = substr( $v, 0, 120 ). '...';
|
||||
}
|
||||
$stats .= "<strong>$k</strong> = ".$std->txt_htmlspecialchars($v)."<br />\n";
|
||||
}
|
||||
|
||||
$stats .= "<b>Next task</b> = ".$std->get_date( $ibforums->cache['systemvars']['task_next_run'], 'LONG' )."\n<br /><b>Time now</b> = ".$std->get_date( time(), 'LONG' );
|
||||
$stats .= "<br /><b>Timestamp Now</b> = ".time();
|
||||
|
||||
$stats .= "</div>\n</div>";
|
||||
|
||||
$stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Loaded PHP Templates</div><div class='row1' style='padding:6px'>\n";
|
||||
|
||||
$stats .= "<strong>".implode(", ",$ibforums->loaded_templates)."</strong><br />\n";
|
||||
|
||||
$stats .= "</div>\n</div>";
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// SQL
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['debug_level'] >= 3)
|
||||
{
|
||||
$stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Queries Used</div><div class='row1' style='padding:6px'>";
|
||||
|
||||
foreach($DB->obj['cached_queries'] as $q)
|
||||
{
|
||||
$q = htmlspecialchars($q);
|
||||
$q = preg_replace( "/^SELECT/i" , "<span class='red'>SELECT</span>" , $q );
|
||||
$q = preg_replace( "/^UPDATE/i" , "<span class='blue'>UPDATE</span>" , $q );
|
||||
$q = preg_replace( "/^DELETE/i" , "<span class='orange'>DELETE</span>", $q );
|
||||
$q = preg_replace( "/^INSERT/i" , "<span class='green'>INSERT</span>" , $q );
|
||||
$q = str_replace( "LEFT JOIN" , "<span class='red'>LEFT JOIN</span>" , $q );
|
||||
|
||||
$q = preg_replace( "/(".$ibforums->vars['sql_tbl_prefix'].")(\S+?)([\s\.,]|$)/", "<span class='purple'>\\1\\2</span>\\3", $q );
|
||||
|
||||
$stats .= "$q<hr />\n";
|
||||
}
|
||||
|
||||
if ( count( $DB->obj['shutdown_queries'] ) )
|
||||
{
|
||||
foreach($DB->obj['shutdown_queries'] as $q)
|
||||
{
|
||||
$q = htmlspecialchars($q);
|
||||
$q = preg_replace( "/^SELECT/i" , "<span class='red'>SELECT</span>" , $q );
|
||||
$q = preg_replace( "/^UPDATE/i" , "<span class='blue'>UPDATE</span>" , $q );
|
||||
$q = preg_replace( "/^DELETE/i" , "<span class='orange'>DELETE</span>", $q );
|
||||
$q = preg_replace( "/^INSERT/i" , "<span class='green'>INSERT</span>" , $q );
|
||||
$q = str_replace( "LEFT JOIN" , "<span class='red'>LEFT JOIN</span>" , $q );
|
||||
|
||||
$q = preg_replace( "/(".$ibforums->vars['sql_tbl_prefix'].")(\S+?)([\s\.,]|$)/", "<span class='purple'>\\1\\2</span>\\3", $q );
|
||||
|
||||
$stats .= "<div style='background:#DEDEDE'><b>SHUTDOWN:</b> $q</div><hr />\n";
|
||||
}
|
||||
}
|
||||
|
||||
$stats .= "</div>\n</div>";
|
||||
}
|
||||
|
||||
if ( $stats )
|
||||
{
|
||||
$collapsed_ids = ','.$std->my_getcookie('collapseprefs').',';
|
||||
|
||||
$show['div_fo'] = 'show';
|
||||
$show['div_fc'] = 'none';
|
||||
|
||||
if ( strstr( $collapsed_ids, ',debug,' ) )
|
||||
{
|
||||
$show['div_fo'] = 'none';
|
||||
$show['div_fc'] = 'show';
|
||||
}
|
||||
|
||||
$stats = "<div align='center' style='display:{$show['div_fc']}' id='fc_debug'>
|
||||
<div class='row2' style='padding:8px;vertical-align:middle'><a href='javascript:togglecategory(\"debug\", 0);'>Show Debug Information</a></div>
|
||||
</div>
|
||||
|
||||
<div align='center' style='display:{$show['div_fo']}' id='fo_debug'>
|
||||
<div class='row2' style='padding:8px;vertical-align:middle'><a href='javascript:togglecategory(\"debug\", 1);'>Hide Debug Information</a></div>
|
||||
<br />
|
||||
<div class='tableborder' align='left'>
|
||||
<div class='maintitle'>Debug Information</div>
|
||||
<div style='padding:5px;background:#8394B2;'>$stats</div>
|
||||
</div>
|
||||
</div>";
|
||||
}
|
||||
|
||||
return $stats;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// check_debug
|
||||
// @internal
|
||||
//-----------------------------------------
|
||||
|
||||
function _check_debug()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
if ($DB->obj['debug'])
|
||||
{
|
||||
flush();
|
||||
print "<html><head><title>SQL Debugger</title><body bgcolor='white'><style type='text/css'> TABLE, TD, TR, BODY { font-family: verdana,arial, sans-serif;color:black;font-size:11px }</style>";
|
||||
print "<h1 align='center'>SQL Total Time: {$DB->sql_time} for {$query_cnt} queries</h1><br />".$ibforums->debug_html;
|
||||
print "<br /><div align='center'><strong>Total SQL Time: {$DB->sql_time}</div></body></html>";
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// check_ips_report
|
||||
// @internal
|
||||
//-----------------------------------------
|
||||
|
||||
function _check_ips_report()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
//-----------------------------------------
|
||||
// Note, this is designed to allow IPS validate boards
|
||||
// who've purchased copyright removal / registration.
|
||||
// The order number is the only thing shown and the
|
||||
// order number is unique to the person who paid and
|
||||
// is no good to anyone else.
|
||||
// Showing the order number poses no risk at all -
|
||||
// the information is useless to anyone outside of IPS.
|
||||
//-----------------------------------------
|
||||
|
||||
$pass = 0;
|
||||
|
||||
if ( $ibforums->input['ipsreport'] or $ibforums->input['ipscheck'] )
|
||||
{
|
||||
if ( $ibforums->vars['ipb_copy_number'] )
|
||||
{
|
||||
flush();
|
||||
print preg_replace( "/^(\d+?)-(\d+?)-(\d+?)-(\d+?)$/", "\\2,\\3", $ibforums->vars['ipb_copy_number'] );
|
||||
exit();
|
||||
}
|
||||
else if ( $ibforums->vars['ipb_reg_number'] )
|
||||
{
|
||||
flush();
|
||||
print preg_replace( "/^(\d+?)-(\d+?)-(\d+?)-(\d+?)-(\d+?)$/", "\\2,\\4", $ibforums->vars['ipb_reg_number'] );
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
print "--";
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// get_css
|
||||
// @internal
|
||||
//-----------------------------------------
|
||||
|
||||
function _get_css()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
if ( $ibforums->skin['_usecsscache'] and @file_exists( CACHE_PATH.'style_images/css_'. $ibforums->skin['_csscacheid'] .'.css' ) )
|
||||
{
|
||||
$css = $ibforums->skin_global->css_external($ibforums->skin['_csscacheid']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$css = $ibforums->skin_global->css_inline( str_replace( "<#IMG_DIR#>", $ibforums->skin['_imagedir'], $ibforums->skin['_css'] ) );
|
||||
}
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// finish
|
||||
// @internal
|
||||
//-----------------------------------------
|
||||
|
||||
function _finish()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
//-----------------------------------------
|
||||
// Do shutdown
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! USE_SHUTDOWN )
|
||||
{
|
||||
$std->my_deconstructor();
|
||||
$DB->close_db();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Start GZIP compression
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['disable_gzip'] != 1 )
|
||||
{
|
||||
$buffer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
@ob_start('ob_gzhandler');
|
||||
print $buffer;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Print, plop and part
|
||||
//-----------------------------------------
|
||||
|
||||
$this->do_headers();
|
||||
}
|
||||
|
||||
} // END class
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,823 @@
|
||||
<?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
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Sending email module
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 26th February 2002
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > DBA Checked: Wed 19 May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
|
|
||||
| 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 = "";
|
||||
var $multipart = "";
|
||||
var $boundry = "";
|
||||
|
||||
var $html_email = 0;
|
||||
var $char_set = 'iso-8859-1';
|
||||
|
||||
var $smtp_fp = FALSE;
|
||||
var $smtp_msg = "";
|
||||
var $smtp_port = "";
|
||||
var $smtp_host = "localhost";
|
||||
var $smtp_user = "";
|
||||
var $smtp_pass = "";
|
||||
var $smtp_code = "";
|
||||
|
||||
var $wrap_brackets = 0;
|
||||
|
||||
var $mail_method = 'mail';
|
||||
|
||||
var $temp_dump = 0;
|
||||
var $root_path = './';
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// CONSTRUCTOR
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function emailer($ROOT_PATH="")
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
$this->email_init();
|
||||
|
||||
//-----------------------------------------
|
||||
// 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'];
|
||||
}
|
||||
|
||||
if ( $ROOT_PATH )
|
||||
{
|
||||
$this->root_path = $ROOT_PATH;
|
||||
}
|
||||
|
||||
if ( ! defined( 'ROOT_PATH') )
|
||||
{
|
||||
define( 'ROOT_PATH', $this->root_path );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// 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']);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Email init
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function email_init()
|
||||
{
|
||||
global $ibforums, $DB, $std;
|
||||
|
||||
//-----------------------------------------
|
||||
// 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'];
|
||||
$this->wrap_brackets = $ibforums->vars['mail_wrap_brackets'];
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// ADD ATTACHMENT
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function add_attachment($data = "", $name = "", $ctype='application/octet-stream')
|
||||
{
|
||||
|
||||
$this->parts[] = array( 'ctype' => $ctype,
|
||||
'data' => $data,
|
||||
'encode' => 'base64',
|
||||
'name' => $name
|
||||
);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// BUILD HEADERS
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function build_headers()
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
//-----------------------------------------
|
||||
// HTML (hitmuhl)
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->html_email )
|
||||
{
|
||||
$this->mail_headers .= "MIME-Version: 1.0\n";
|
||||
$this->mail_headers .= "Content-type: text/html; charset=\"".$this->char_set."\"\n";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Start mail headers
|
||||
//-----------------------------------------
|
||||
|
||||
$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";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// we're not spam, really!
|
||||
//-----------------------------------------
|
||||
|
||||
$this->mail_headers .= "Return-Path: ".$this->from."\n";
|
||||
$this->mail_headers .= "X-Priority: 3\n";
|
||||
$this->mail_headers .= "X-Mailer: IPB PHP Mailer\n";
|
||||
|
||||
//-----------------------------------------
|
||||
// Count.. oh you get the idea
|
||||
//-----------------------------------------
|
||||
|
||||
if ( count ($this->parts) > 0 )
|
||||
{
|
||||
if ( ! $this->html )
|
||||
{
|
||||
$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=\"".$this->char_set."\"\nContent-Transfer-Encoding: quoted-printable\n\n".$this->message."\n\n--".$this->boundry;
|
||||
}
|
||||
else
|
||||
{
|
||||
$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/html;\n\tcharset=\"".$this->char_set."\"\nContent-Transfer-Encoding: quoted-printable\n\n".$this->message."\n\n--".$this->boundry;
|
||||
}
|
||||
|
||||
$this->mail_headers .= $this->build_multipart();
|
||||
|
||||
$this->message = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// ENCODE ATTACHMENT
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
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";
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// BUILD MULTIPART
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
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, $DB, $std;
|
||||
|
||||
//-----------------------------------------
|
||||
// Wipe ya face
|
||||
//-----------------------------------------
|
||||
|
||||
$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 = ( trim($this->lang_subject) != "" ) ? $this->lang_subject : $this->subject;
|
||||
|
||||
$this->subject = $this->clean_message($this->subject);
|
||||
|
||||
//-----------------------------------------
|
||||
// Build headers
|
||||
//-----------------------------------------
|
||||
|
||||
$this->build_headers();
|
||||
|
||||
//-----------------------------------------
|
||||
// Lets go..
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ($this->from) and ($this->subject) )
|
||||
{
|
||||
$this->subject .= " ( From ".$ibforums->vars['board_name']." )";
|
||||
|
||||
//-----------------------------------------
|
||||
// Tmp dump? (Testing)
|
||||
//-----------------------------------------
|
||||
|
||||
if ($this->temp_dump == 1)
|
||||
{
|
||||
$blah = $this->subject."\n------------\n".$this->mail_headers."\n\n".$this->message;
|
||||
|
||||
$pathy = $this->root_path.'_mail/'.date("M-j-Y,hi-A").str_replace( '@', '+', $this->to ).".txt";
|
||||
$fh = fopen ($pathy, 'w');
|
||||
fputs ($fh, $blah, strlen($blah) );
|
||||
fclose($fh);
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// PHP MAIL()
|
||||
//-----------------------------------------
|
||||
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");
|
||||
}
|
||||
}
|
||||
//-----------------------------------------
|
||||
// SMTP
|
||||
//-----------------------------------------
|
||||
else
|
||||
{
|
||||
$this->smtp_send_mail();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->fatal_error("From or subject empty");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->to = "";
|
||||
$this->from = "";
|
||||
$this->message = "";
|
||||
$this->subject = "";
|
||||
$this->mail_headers = "";
|
||||
|
||||
$this->email_init();
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// get_template:
|
||||
// Queries the database, and stores the template we wish to use in memory
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function get_template($name="", $language="")
|
||||
{
|
||||
global $ibforums, $IB, $DB, $lang;
|
||||
|
||||
//-----------------------------------------
|
||||
// Check..
|
||||
//-----------------------------------------
|
||||
|
||||
if ($name == "")
|
||||
{
|
||||
$this->error++;
|
||||
$this->fatal_error("A valid email template ID was not passed to the email library during template parsing", "");
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Default?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->vars['default_language'] == "")
|
||||
{
|
||||
$ibforums->vars['default_language'] = 'en';
|
||||
}
|
||||
|
||||
if ($language == "")
|
||||
{
|
||||
$language = $ibforums->vars['default_language'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Check and get
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! file_exists($this->root_path."lang/$language/lang_email_content.php") )
|
||||
{
|
||||
if ( ! is_array( $lang ) )
|
||||
{
|
||||
$lang = array();
|
||||
}
|
||||
|
||||
require_once( $this->root_path."lang/".$ibforums->vars['default_language']."/lang_email_content.php" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! is_array( $lang ) )
|
||||
{
|
||||
$lang = array();
|
||||
}
|
||||
|
||||
require_once( $this->root_path."lang/$language/lang_email_content.php" );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Stored KEY?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! isset($lang[ $name ]) )
|
||||
{
|
||||
if ( $language == $ibforums->vars['default_language'] )
|
||||
{
|
||||
$this->fatal_error("Could not find an email template with an ID of '$name'", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once( $this->root_path."lang/".$ibforums->vars['default_language']."/lang_email_content.php" );
|
||||
|
||||
if ( ! isset($lang[ $name ]) )
|
||||
{
|
||||
$this->fatal_error("Could not find an email template with an ID of '$name'", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Subject?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( isset( $lang[ 'subject__'. $name ] ) )
|
||||
{
|
||||
$this->lang_subject = stripslashes($lang[ 'subject__'. $name ]);
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Return
|
||||
//-----------------------------------------
|
||||
|
||||
$this->template = stripslashes($lang['header']) . stripslashes($lang[ $name ]) . stripslashes($lang['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 BBCode
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
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 );
|
||||
|
||||
//-----------------------------------------
|
||||
// Bear with me...
|
||||
//-----------------------------------------
|
||||
|
||||
$message = str_replace( "\n" , "<br />", $message );
|
||||
$message = str_replace( "\r" , "" , $message );
|
||||
|
||||
$message = str_replace( "<br>" , "\r\n", $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;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// FATAL ERROR : LOG AND RETURN
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function fatal_error($msg, $help="")
|
||||
{
|
||||
global $DB, $std, $ibforums;
|
||||
|
||||
$DB->do_insert( 'mail_error_logs',
|
||||
array(
|
||||
'mlog_date' => time(),
|
||||
'mlog_to' => $this->to,
|
||||
'mlog_from' => $this->from,
|
||||
'mlog_subject' => $this->subject,
|
||||
'mlog_content' => substr( $this->message, 0, 200 ),
|
||||
'mlog_msg' => $msg,
|
||||
'mlog_code' => $this->smtp_code,
|
||||
'mlog_smtp_msg' => $this->smtp_msg
|
||||
)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// 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 = "")
|
||||
{
|
||||
$this->smtp_msg = $err;
|
||||
$this->fatal_error( $err );
|
||||
return;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
//| 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");
|
||||
return;
|
||||
}
|
||||
|
||||
$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");
|
||||
return;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// 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");
|
||||
return;
|
||||
}
|
||||
|
||||
$this->smtp_send_cmd( base64_encode($this->smtp_pass) );
|
||||
|
||||
if ( $this->smtp_code != 235 )
|
||||
{
|
||||
$this->smtp_error("Password not accepted from the server");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->smtp_error("This server does not support authorisation");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// We're from MARS!
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->wrap_brackets )
|
||||
{
|
||||
if ( ! preg_match( "/^</", $this->from ) )
|
||||
{
|
||||
$this->from = "<".$this->from.">";
|
||||
}
|
||||
}
|
||||
|
||||
$this->smtp_send_cmd("MAIL FROM:".$this->from);
|
||||
|
||||
if ( $this->smtp_code != 250 )
|
||||
{
|
||||
$this->smtp_error();
|
||||
return;
|
||||
}
|
||||
|
||||
$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 )
|
||||
{
|
||||
if ( $this->wrap_brackets )
|
||||
{
|
||||
$this->smtp_send_cmd("RCPT TO:<".$to_email.">");
|
||||
}
|
||||
else
|
||||
{
|
||||
$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");
|
||||
return;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// 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();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,795 @@
|
||||
<?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
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > FORUMS CLASS
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 26th January 2004
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > DBA Checked: Wed 19 May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
class forum_functions
|
||||
{
|
||||
|
||||
var $forum_cache = array();
|
||||
var $forum_by_id = array();
|
||||
var $forum_built = array();
|
||||
var $class = "";
|
||||
var $template_bit = "";
|
||||
var $depth_guide = "--";
|
||||
var $return = "";
|
||||
var $this_forum = array();
|
||||
var $strip_invisible = 0;
|
||||
var $mod_cache = array();
|
||||
var $mod_cache_got = 0;
|
||||
var $read_topic_only = 0;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// register_class
|
||||
// ------------------
|
||||
// Register a $this-> class with this module
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function register_class(&$class)
|
||||
{
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// forums_init
|
||||
// ------------------
|
||||
// Grab all forums and stuff into array
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_init()
|
||||
{
|
||||
global $DB, $std, $ibforums;
|
||||
|
||||
if ( ! is_array( $ibforums->cache['forum_cache'] ) )
|
||||
{
|
||||
$std->update_forum_cache();
|
||||
}
|
||||
|
||||
$hide_parents = ',';
|
||||
|
||||
foreach( $ibforums->cache['forum_cache'] as $i => $f )
|
||||
{
|
||||
if ( $this->strip_invisible )
|
||||
{
|
||||
if ( strstr( $hide_parents, ','. $f['parent_id'] .',' ) )
|
||||
{
|
||||
// Don't show any children of hidden parents
|
||||
$hide_parents .= $f['id'].',';
|
||||
continue;
|
||||
}
|
||||
|
||||
//if ( $f['status'] < 1 )
|
||||
//{
|
||||
// $hide_parents .= $f['id'].',';
|
||||
// continue;
|
||||
//}
|
||||
|
||||
if ( $f['show_perms'] != '*' )
|
||||
{
|
||||
if ( $std->check_perms($f['show_perms']) != TRUE )
|
||||
{
|
||||
$hide_parents .= $f['id'].',';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $f['parent_id'] < 1 )
|
||||
{
|
||||
$f['parent_id'] = 'root';
|
||||
}
|
||||
|
||||
$f['fid'] = $f['id'];
|
||||
|
||||
$this->forum_cache[ $f['parent_id'] ][ $f['id'] ] = $f;
|
||||
$this->forum_by_id[ $f['id'] ] = &$this->forum_cache[ $f['parent_id'] ][ $f['id'] ];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function forums_remove_childless_parents()
|
||||
{
|
||||
foreach ( $this->forum_cache['root'] as $id => $forum_data )
|
||||
{
|
||||
if ( ! is_array( $this->forum_cache['root'][ $forum_data['id'] ] ) )
|
||||
{
|
||||
unset( $this->forum_cache['root'][ $forum_data['id'] ] );
|
||||
unset( $this->forum_by_id[ $forum_data['id'] ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// forums_get_moderator_cache
|
||||
// ------------------
|
||||
// Grab all mods innit
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_get_moderator_cache()
|
||||
{
|
||||
global $DB, $ibforums, $std;
|
||||
|
||||
$this->can_see_queued = array();
|
||||
|
||||
if ( ! is_array( $ibforums->cache['moderators'] ) )
|
||||
{
|
||||
$ibforums->cache['moderators'] = array();
|
||||
|
||||
$DB->simple_construct( array( 'select' => "*",
|
||||
'from' => 'moderators'
|
||||
) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
while ( $i = $DB->fetch_row() )
|
||||
{
|
||||
$ibforums->cache['moderators'][ $i['mid'] ] = $i;
|
||||
}
|
||||
|
||||
$std->update_cache( array( 'name' => 'moderators', 'array' => 1, 'deletefirst' => 1 ) );
|
||||
}
|
||||
|
||||
if ( count($ibforums->cache['moderators']) )
|
||||
{
|
||||
foreach( $ibforums->cache['moderators'] as $i => $r )
|
||||
{
|
||||
$this->mod_cache[ $r['forum_id'] ][ $r['mid'] ] = array( 'name' => $r['member_name'],
|
||||
'memid' => $r['member_id'],
|
||||
'id' => $r['mid'],
|
||||
'isg' => $r['is_group'],
|
||||
'gname' => $r['group_name'],
|
||||
'gid' => $r['group_id'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->mod_cache_got = 1;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// forums_get_moderators
|
||||
// ------------------
|
||||
// Grab all mods innit
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_get_moderators($forum_id="")
|
||||
{
|
||||
global $DB, $ibforums;
|
||||
|
||||
if ( ! $this->mod_cache_got )
|
||||
{
|
||||
$this->forums_get_moderator_cache();
|
||||
}
|
||||
|
||||
$mod_string = "";
|
||||
|
||||
if ($forum_id == "")
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if (isset($this->mod_cache[ $forum_id ] ) )
|
||||
{
|
||||
$mod_string = $ibforums->lang['forum_leader'].' ';
|
||||
|
||||
if (is_array($this->mod_cache[ $forum_id ]) )
|
||||
{
|
||||
foreach ($this->mod_cache[ $forum_id ] as $moderator)
|
||||
{
|
||||
if ($moderator['isg'] == 1)
|
||||
{
|
||||
$mod_string .= "<a href='{$ibforums->base_url}act=Members&max_results=30&filter={$moderator['gid']}&sort_order=asc&sort_key=name&st=0&b=1'>{$moderator['gname']}</a>, ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$mod_string .= "<a href='{$ibforums->base_url}showuser={$moderator['memid']}'>{$moderator['name']}</a>, ";
|
||||
}
|
||||
}
|
||||
|
||||
$mod_string = preg_replace( "!,\s+$!", "", $mod_string );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($moderator['isg'] == 1)
|
||||
{
|
||||
$mod_string .= "<a href='{$ibforums->base_url}act=Members&max_results=30&filter={$this->mods[$forum_id]['gid']}&sort_order=asc&sort_key=name&st=0&b=1'>{$this->mods[$forum_id]['gname']}</a>, ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$mod_string .= "<a href='{$ibforums->base_url}showuser={$this->mods[$forum_id]['memid']}'>{$this->mods[$forum_id]['name']}</a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $mod_string;
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Forums check access
|
||||
// ------------------
|
||||
// Blah-de-blah
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_check_access($fid, $prompt_login=0, $in='forum')
|
||||
{
|
||||
global $ibforums, $std;
|
||||
|
||||
$deny_access = 1;
|
||||
|
||||
if ( $std->check_perms($this->forum_by_id[$fid]['show_perms']) == TRUE )
|
||||
{
|
||||
if ( $std->check_perms($this->forum_by_id[$fid]['read_perms']) == TRUE )
|
||||
{
|
||||
$deny_access = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Can see topics?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->forum_by_id[$fid]['permission_showtopic'] )
|
||||
{
|
||||
$this->read_topic_only = 1;
|
||||
|
||||
if ( $in == 'forum' )
|
||||
{
|
||||
$deny_access = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Custom error?
|
||||
//-----------------------------------------
|
||||
|
||||
$this->forums_custom_error($fid);
|
||||
|
||||
$deny_access = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->forums_custom_error($fid);
|
||||
|
||||
$deny_access = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// custom error
|
||||
//-----------------------------------------
|
||||
|
||||
$this->forums_custom_error($fid);
|
||||
|
||||
$deny_access = 1;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have permission to even see the password page?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($deny_access == 0)
|
||||
{
|
||||
if ($this->forum_by_id[$fid]['password'])
|
||||
{
|
||||
if ( $this->forums_compare_password( $fid ) == TRUE )
|
||||
{
|
||||
$deny_access = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$deny_access = 1;
|
||||
|
||||
if ( $prompt_login == 1 )
|
||||
{
|
||||
$this->forums_show_login( $fid );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($deny_access == 1)
|
||||
{
|
||||
$std->Error( array( LEVEL => 1, MSG => 'no_permission') );
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Compare forum pasword
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_compare_password( $fid )
|
||||
{
|
||||
global $ibforums, $std;
|
||||
|
||||
$cookie_pass = $std->my_getcookie( 'ipbforumpass_'.$fid );
|
||||
|
||||
if ( trim($cookie_pass) == md5($this->forum_by_id[$fid]['password']) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Quick check
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_quick_check_access($fid)
|
||||
{
|
||||
global $ibforums, $std;
|
||||
|
||||
$deny_access = 1;
|
||||
|
||||
if ( $std->check_perms($this->forum_by_id[$fid]['show_perms']) == TRUE )
|
||||
{
|
||||
$deny_access = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have permission to even see the password page?
|
||||
//-----------------------------------------
|
||||
|
||||
if ($deny_access == 0)
|
||||
{
|
||||
if ($this->forum_by_id[$fid]['password'])
|
||||
{
|
||||
if ( $this->forums_compare_password( $fid ) == TRUE )
|
||||
{
|
||||
$deny_access = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$deny_access = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $deny_access;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Forums custom error
|
||||
// ------------------
|
||||
// Blah-de-blah
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_custom_error( $fid )
|
||||
{
|
||||
global $ibforums, $std, $DB;
|
||||
|
||||
$tmp = $DB->simple_exec_query( array( 'select' => 'permission_custom_error', 'from' => 'forums', 'where' => "id=".$fid) );
|
||||
|
||||
if ( $tmp['permission_custom_error'] )
|
||||
{
|
||||
$ibforums->lang = $std->load_words($ibforums->lang, "lang_error", $ibforums->lang_id);
|
||||
|
||||
//-----------------------------------------
|
||||
// Update session
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->do_shutdown_update( 'sessions', array( 'in_error' => 1 ), "id='{$ibforums->my_session}'" );
|
||||
|
||||
list($em_1, $em_2) = explode( '@', $ibforums->vars['email_in'] );
|
||||
|
||||
$html = $ibforums->skin_global->Error( $tmp['permission_custom_error'], $em_1, $em_2);
|
||||
$print = new display();
|
||||
$print->add_output($html);
|
||||
$print->do_output( array('TITLE' => $ibforums->lang['error_title'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Forums log in screen
|
||||
// ------------------
|
||||
// Blah-de-blah
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_show_login( $fid )
|
||||
{
|
||||
global $ibforums, $std, $DB, $print;
|
||||
|
||||
if ( ! class_exists( 'skin_forum' ) )
|
||||
{
|
||||
$this->html = $std->load_template('skin_forum');
|
||||
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_forum', $ibforums->lang_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->html = new skin_forum();
|
||||
}
|
||||
|
||||
if (empty($ibforums->member['id']))
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
|
||||
}
|
||||
|
||||
$this->output = $this->html->forum_password_log_in( $fid );
|
||||
|
||||
$print->add_output( $this->output );
|
||||
|
||||
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->forum_by_id[$fid]['name'],
|
||||
'JS' => 0,
|
||||
'NAV' => array(
|
||||
"<a href='".$ibforums->base_url."showforum={$fid}'>{$this->forum_by_id[$fid]['name']}</a>",
|
||||
),
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Get parents
|
||||
// ------------------
|
||||
// Find all the parents of a child without getting the nice lady to
|
||||
// use the superstore tannoy to shout "Small ugly boy in tears at reception"
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_get_parents($root_id, $ids=array())
|
||||
{
|
||||
if ( $this->forum_by_id[ $root_id ]['parent_id'] and $this->forum_by_id[ $root_id ]['parent_id'] != 'root' )
|
||||
{
|
||||
$ids[] = $this->forum_by_id[ $root_id ]['parent_id'];
|
||||
|
||||
$ids = $this->forums_get_parents( $this->forum_by_id[ $root_id ]['parent_id'], $ids );
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Gets children (Debug purposes)
|
||||
// ------------------
|
||||
// Get all meh children
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_get_children( $root_id, $ids=array() )
|
||||
{
|
||||
if ( is_array( $this->forum_cache[ $root_id ] ) )
|
||||
{
|
||||
foreach( $this->forum_cache[ $root_id ] as $id => $forum_data )
|
||||
{
|
||||
$ids[] = $forum_data['id'];
|
||||
|
||||
$ids = $this->forums_get_children($forum_data['id'], $ids);
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Calcualte Children
|
||||
// ------------------
|
||||
// Gets cumulative posts/topics - sets new post marker and last topic id
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_calc_children($root_id, $forum_data=array(), $done_pass=0)
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
if ( is_array( $this->forum_cache[ $root_id ] ) )
|
||||
{
|
||||
foreach( $this->forum_cache[ $root_id ] as $id => $data )
|
||||
{
|
||||
if ($data['last_post'] > $forum_data['last_post'])
|
||||
{
|
||||
$forum_data['last_post'] = $data['last_post'];
|
||||
$forum_data['fid'] = $data['id'];
|
||||
$forum_data['last_id'] = $data['last_id'];
|
||||
$forum_data['last_title'] = $data['last_title'];
|
||||
$forum_data['password'] = $data['password'];
|
||||
$forum_data['last_poster_id'] = $data['last_poster_id'];
|
||||
$forum_data['last_poster_name'] = $data['last_poster_name'];
|
||||
$forum_data['status'] = $data['status'];
|
||||
}
|
||||
|
||||
$forum_data['posts'] += $data['posts'];
|
||||
$forum_data['topics'] += $data['topics'];
|
||||
|
||||
if ( $ibforums->member['g_is_supmod'] or $ibforums->member['_moderator'][ $data['id'] ]['post_q'] == 1 )
|
||||
{
|
||||
$forum_data['queued_posts'] += $data['queued_posts'];
|
||||
$forum_data['queued_topics'] += $data['queued_topics'];
|
||||
}
|
||||
|
||||
if ( ! $done_pass )
|
||||
{
|
||||
$forum_data['subforums'][ $data['id'] ] = $this->class->html->show_subforum_link($data['id'],$data['name']);
|
||||
}
|
||||
|
||||
$forum_data = $this->forums_calc_children( $data['id'], $forum_data, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return $forum_data;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Create forum breadcrumb nav
|
||||
// ------------------
|
||||
// Simple and effective - just like me :(
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_breadcrumb_nav($root_id, $url='showforum=')
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
$nav_array[] = "<a href='".$ibforums->base_url."$url{$root_id}'>{$this->forum_by_id[$root_id]['name']}</a>";
|
||||
|
||||
$ids = $this->forums_get_parents( $root_id );
|
||||
|
||||
if ( is_array($ids) and count($ids) )
|
||||
{
|
||||
foreach( $ids as $id )
|
||||
{
|
||||
$data = $this->forum_by_id[$id];
|
||||
|
||||
$nav_array[] = "<a href='".$ibforums->base_url."$url{$data['id']}'>{$data['name']}</a>";
|
||||
}
|
||||
}
|
||||
|
||||
return array_reverse($nav_array);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// forum jumpee
|
||||
// ------------------
|
||||
// Builds the forum jumpee dunnit
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_forum_jump($html=0, $override=0)
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
foreach( $this->forum_cache['root'] as $id => $forum_data )
|
||||
{
|
||||
if ( $forum_data['sub_can_post'] or ( is_array($this->forum_cache[ $forum_data['id'] ]) and count($this->forum_cache[ $forum_data['id'] ]) ) )
|
||||
{
|
||||
if ($html == 1 or $override == 1)
|
||||
{
|
||||
$selected = "";
|
||||
|
||||
if ($ibforums->input['f'] and $ibforums->input['f'] == $forum_data['id'])
|
||||
{
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
}
|
||||
|
||||
$jump_string .= "<option value=\"{$forum_data['id']}\"".$selected.">".$forum_data['name']."</option>\n";
|
||||
|
||||
$depth_guide = $this->depth_guide;
|
||||
|
||||
if ( is_array( $this->forum_cache[ $forum_data['id'] ] ) )
|
||||
{
|
||||
foreach( $this->forum_cache[ $forum_data['id'] ] as $id => $forum_data )
|
||||
{
|
||||
if ($html == 1 or $override == 1)
|
||||
{
|
||||
$selected = "";
|
||||
|
||||
if ($ibforums->input['f'] and $ibforums->input['f'] == $forum_data['id'])
|
||||
{
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
}
|
||||
|
||||
$jump_string .= "<option value=\"{$forum_data['id']}\"".$selected."> |".$depth_guide." ".$forum_data['name']."</option>\n";
|
||||
|
||||
$jump_string = $this->forums_forum_jump_internal( $forum_data['id'], $jump_string, $depth_guide . $this->depth_guide, $html, $override );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $jump_string;
|
||||
}
|
||||
|
||||
function forums_forum_jump_internal($root_id, $jump_string="", $depth_guide="",$html=0, $override=0)
|
||||
{
|
||||
global $ibforums;
|
||||
|
||||
if ( is_array( $this->forum_cache[ $root_id ] ) )
|
||||
{
|
||||
foreach( $this->forum_cache[ $root_id ] as $id => $forum_data )
|
||||
{
|
||||
if ($html == 1 or $override == 1)
|
||||
{
|
||||
$selected = "";
|
||||
|
||||
if ($ibforums->input['f'] and $ibforums->input['f'] == $forum_data['id'])
|
||||
{
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
}
|
||||
|
||||
$jump_string .= "<option value=\"{$forum_data['id']}\"".$selected."> |".$depth_guide." ".$forum_data['name']."</option>\n";
|
||||
|
||||
$jump_string = $this->forums_forum_jump_internal( $forum_data['id'], $jump_string, $depth_guide . $this->depth_guide, $html, $override );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $jump_string;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Format Forum
|
||||
// ------------------
|
||||
// Sorts out last poster, etc
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_format_lastinfo($forum_data)
|
||||
{
|
||||
global $std, $DB, $ibforums;
|
||||
|
||||
$show_subforums = 1;
|
||||
|
||||
if ( $std->check_perms($this->forum_by_id[ $forum_data['id'] ]['read_perms']) != TRUE )
|
||||
{
|
||||
$show_subforums = 0;
|
||||
}
|
||||
|
||||
$forum_data['img_new_post'] = $this->forums_new_posts($forum_data);
|
||||
|
||||
if ( $forum_data['img_new_post'] == '<{C_ON}>' )
|
||||
{
|
||||
$forum_data['img_new_post'] = $this->class->html->forum_img_with_link($forum_data['img_new_post'], $forum_data['id']);
|
||||
}
|
||||
else if ( $forum_data['img_new_post'] == '<{C_ON_CAT}>' )
|
||||
{
|
||||
$forum_data['img_new_post'] = $this->class->html->subforum_img_with_link($forum_data['img_new_post'], $forum_data['id']);
|
||||
}
|
||||
|
||||
$forum_data['last_post'] = $std->get_date($forum_data['last_post'], 'LONG');
|
||||
|
||||
$forum_data['last_topic'] = $ibforums->lang['f_none'];
|
||||
|
||||
$forum_data['full_last_title'] = $forum_data['last_title'];
|
||||
|
||||
if (isset($forum_data['last_title']) and $forum_data['last_id'])
|
||||
{
|
||||
$forum_data['last_title'] = strip_tags($forum_data['last_title']);
|
||||
$forum_data['last_title'] = str_replace( "!" , "!", $forum_data['last_title'] );
|
||||
$forum_data['last_title'] = str_replace( """, "\"", $forum_data['last_title'] );
|
||||
|
||||
$forum_data['last_title'] = $std->txt_truncate($forum_data['last_title'], 30);
|
||||
|
||||
if ( $forum_data['password'] OR ( $std->check_perms($this->forum_by_id[ $forum_data['fid'] ]['read_perms']) != TRUE AND $this->forum_by_id[ $forum_data['fid'] ]['permission_showtopic'] == 0 ) )
|
||||
{
|
||||
$forum_data['last_topic'] = $ibforums->lang['f_protected'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_data['last_unread'] = $this->class->html->forumrow_lastunread_link($forum_data['id'], $forum_data['last_id']);
|
||||
$forum_data['last_topic'] = "<a href='{$ibforums->base_url}showtopic={$forum_data['last_id']}&view=getnewpost' title='{$ibforums->lang['tt_gounread']}: {$forum_data['full_last_title']}'>{$forum_data['last_title']}</a>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( isset($forum_data['last_poster_name']))
|
||||
{
|
||||
$forum_data['last_poster'] = $forum_data['last_poster_id'] ? "<a href='{$ibforums->base_url}showuser={$forum_data['last_poster_id']}'>{$forum_data['last_poster_name']}</a>"
|
||||
: $forum_data['last_poster_name'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$forum_data['last_poster'] = $ibforums->lang['f_none'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Moderators
|
||||
//-----------------------------------------
|
||||
|
||||
$forum_data['moderator'] = $this->forums_get_moderators($forum_data['id']);
|
||||
|
||||
$forum_data['posts'] = $std->do_number_format($forum_data['posts']);
|
||||
$forum_data['topics'] = $std->do_number_format($forum_data['topics']);
|
||||
|
||||
if ( $ibforums->vars['disable_subforum_show'] == 0 AND $show_subforums == 1 )
|
||||
{
|
||||
if ( is_array( $forum_data['subforums'] ) and count( $forum_data['subforums'] ) )
|
||||
{
|
||||
$forum_data['show_subforums'] = $this->class->html->show_subforum_all_links( implode( ', ', $forum_data['subforums'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( $ibforums->member['g_is_supmod'] or $ibforums->member['_moderator'][ $forum_data['id'] ]['post_q'] == 1 )
|
||||
and ( $forum_data['queued_posts'] or $forum_data['queued_topics'] ) )
|
||||
{
|
||||
$forum_data['_queued_info'] = $this->class->html->show_queued_info( intval($forum_data['queued_posts']), intval($forum_data['queued_topics']) );
|
||||
$forum_data['_queued_img'] = $this->class->html->show_queued_img($forum_data['fid']);
|
||||
}
|
||||
|
||||
return $forum_data;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Generate the appropriate folder icon for a forum
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function forums_new_posts($forum_data)
|
||||
{
|
||||
global $ibforums, $std;
|
||||
|
||||
$sub = 0;
|
||||
|
||||
if ( count($forum_data['subforums']) )
|
||||
{
|
||||
$sub = 1;
|
||||
}
|
||||
|
||||
$rtime = $ibforums->input['last_visit'];
|
||||
|
||||
$fid = $forum_data['fid'] == "" ? $forum_data['id'] : $forum_data['fid'];
|
||||
|
||||
$ftime = $ibforums->forum_read[ $fid ];
|
||||
|
||||
if ( $ibforums->forum_read[0] > $ftime )
|
||||
{
|
||||
$ftime = $ibforums->forum_read[0];
|
||||
}
|
||||
|
||||
$rtime = $ftime > $rtime ? $ftime : $rtime;
|
||||
|
||||
if ($sub == 0)
|
||||
{
|
||||
if ( ! $forum_data['status'] )
|
||||
{
|
||||
return "<{C_LOCKED}>";
|
||||
}
|
||||
|
||||
$sub_cat_img = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sub_cat_img = '_CAT';
|
||||
}
|
||||
|
||||
if ($forum_data['password'] and $sub == 0)
|
||||
{
|
||||
return $forum_data['last_post'] > $rtime ? "<{C_ON_RES}>"
|
||||
: "<{C_OFF_RES}>";
|
||||
}
|
||||
|
||||
return $forum_data['last_post'] > $rtime ? "<{C_ON".$sub_cat_img."}>"
|
||||
: "<{C_OFF".$sub_cat_img."}>";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,968 @@
|
||||
<?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
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > SESSION CLASS
|
||||
| > Module written by Matt Mecham
|
||||
| > Date started: 26th January 2004
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > DBA Checked: Wed 19 May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
class session {
|
||||
|
||||
var $ip_address = 0;
|
||||
var $user_agent = "";
|
||||
var $time_now = 0;
|
||||
var $session_id = 0;
|
||||
var $session_dead_id = 0;
|
||||
var $session_user_id = 0;
|
||||
var $session_user_pass = "";
|
||||
var $last_click = 0;
|
||||
var $location = "";
|
||||
var $member = array();
|
||||
var $botmap = array();
|
||||
|
||||
// No need for a constructor
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Authorise
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function authorise()
|
||||
{
|
||||
global $DB, $ibforums, $std;
|
||||
|
||||
//-----------------------------------------
|
||||
// Before we go any lets check the load settings..
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->vars['load_limit'] > 0)
|
||||
{
|
||||
if ( file_exists('/proc/loadavg') )
|
||||
{
|
||||
if ( $fh = @fopen( '/proc/loadavg', 'r' ) )
|
||||
{
|
||||
$data = @fread( $fh, 6 );
|
||||
@fclose( $fh );
|
||||
|
||||
$load_avg = explode( " ", $data );
|
||||
|
||||
$ibforums->server_load = trim($load_avg[0]);
|
||||
|
||||
if ($ibforums->server_load > $ibforums->vars['load_limit'])
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'server_too_busy', 'INIT' => 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $serverstats = @exec("uptime") )
|
||||
{
|
||||
preg_match( "/(?:averages)?\: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $serverstats, $load );
|
||||
|
||||
$ibforums->server_load = $load[1];
|
||||
|
||||
if ($ibforums->server_load > $ibforums->vars['load_limit'])
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'server_too_busy', 'INIT' => 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Are they banned?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array( $ibforums->cache['banfilters'] ) and count( $ibforums->cache['banfilters'] ) )
|
||||
{
|
||||
foreach ($ibforums->cache['banfilters'] as $ip)
|
||||
{
|
||||
$ip = str_replace( '\*', '.*', preg_quote($ip, "/") );
|
||||
|
||||
if ( preg_match( "/^$ip$/", $ibforums->input['IP_ADDRESS'] ) )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'you_are_banned', 'INIT' => 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
$this->member = array( 'id' => 0, 'name' => "", 'mgroup' => $ibforums->vars['guest_group'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// Return as guest if running a task
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->input['act'] == 'task' )
|
||||
{
|
||||
$this->member = $std->set_up_guest();
|
||||
$this->member['mgroup'] = $ibforums->vars['guest_group'];
|
||||
$ibforums->input['last_activity'] = time();
|
||||
$ibforums->input['last_visit'] = time();
|
||||
|
||||
return $this->member;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// no new headers if we're simply viewing an attachment..
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->input['act'] == 'Attach' or $ibforums->input['act'] == 'Reg' )
|
||||
{
|
||||
$ibforums->no_print_header = 1;
|
||||
}
|
||||
|
||||
$_SERVER['HTTP_USER_AGENT'] = $std->clean_value($_SERVER['HTTP_USER_AGENT']);
|
||||
|
||||
$this->ip_address = $ibforums->input['IP_ADDRESS'] ? $ibforums->input['IP_ADDRESS'] : $_SERVER['REMOTE_ADDR'];
|
||||
$this->user_agent = substr($_SERVER['HTTP_USER_AGENT'],0,50);
|
||||
$this->time_now = time();
|
||||
|
||||
//-----------------------------------------
|
||||
// Manage bots? (tee-hee)
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->vars['spider_sense'] == 1 and $ibforums->vars['search_engine_bots'] )
|
||||
{
|
||||
foreach( explode( "\n", $ibforums->vars['search_engine_bots'] ) as $bot )
|
||||
{
|
||||
list($ua, $n) = explode( "=", $bot );
|
||||
|
||||
if ( $ua and $n )
|
||||
{
|
||||
$this->bot_map[ $ua ] = $n;
|
||||
$this->bot_safe[] = preg_quote( $ua, "/" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( preg_match( '/('.implode( '|', $this->bot_safe ) .')/i', $_SERVER['HTTP_USER_AGENT'], $match ) )
|
||||
{
|
||||
$DB->simple_construct( array( 'select' => '*',
|
||||
'from' => 'groups',
|
||||
'where' =>" g_id=".intval($ibforums->vars['spider_group'])
|
||||
) );
|
||||
$DB->simple_exec();
|
||||
|
||||
$group = $DB->fetch_row();
|
||||
|
||||
foreach ($group as $k => $v)
|
||||
{
|
||||
$this->member[ $k ] = $v;
|
||||
}
|
||||
|
||||
$this->member['restrict_post'] = 1;
|
||||
$this->member['g_use_search'] = 0;
|
||||
$this->member['g_email_friend'] = 0;
|
||||
$this->member['g_edit_profile'] = 0;
|
||||
$this->member['g_use_pm'] = 0;
|
||||
$this->member['g_is_supmod'] = 0;
|
||||
$this->member['g_access_cp'] = 0;
|
||||
$this->member['g_access_offline'] = 0;
|
||||
$this->member['g_avoid_flood'] = 0;
|
||||
$this->member['id'] = 0;
|
||||
|
||||
$ibforums->perm_id = $this->member['g_perm_id'];
|
||||
$ibforums->perm_id_array = explode( ",", $ibforums->perm_id );
|
||||
$ibforums->session_type = 'cookie';
|
||||
$ibforums->is_bot = 1;
|
||||
$this->session_id = "";
|
||||
|
||||
$agent = trim($match[0]);
|
||||
|
||||
//-----------------------------------------
|
||||
// Using lofi?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( strstr( $_SERVER['PHP_SELF'], 'lofiversion' ) )
|
||||
{
|
||||
$qstring = "Lo-Fi: ".str_replace( "/", "", strrchr( $_SERVER['PHP_SELF'], "/" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$qstring = str_replace( "'", "", $_SERVER['QUERY_STRING']);
|
||||
}
|
||||
|
||||
if ( $ibforums->vars['spider_visit'] )
|
||||
{
|
||||
$DB->do_shutdown_insert( 'spider_logs', array (
|
||||
'bot' => $agent,
|
||||
'query_string' => $qstring,
|
||||
'ip_address' => $_SERVER['REMOTE_ADDR'],
|
||||
'entry_date' => time(),
|
||||
) );
|
||||
}
|
||||
|
||||
if ( $ibforums->vars['spider_active'] )
|
||||
{
|
||||
$DB->simple_construct( array( 'delete' => 'sessions',
|
||||
'where' => "id='".$agent.'='.str_replace('.','',$this->ip_address )."_session'"
|
||||
) );
|
||||
$DB->simple_shutdown_exec();
|
||||
|
||||
$this->create_bot_session($agent, $this->bot_map[ $agent ]);
|
||||
}
|
||||
|
||||
return $this->member;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Continue!
|
||||
//-----------------------------------------
|
||||
|
||||
$cookie = array();
|
||||
$cookie['session_id'] = $std->my_getcookie('session_id');
|
||||
$cookie['member_id'] = $std->my_getcookie('member_id');
|
||||
$cookie['pass_hash'] = $std->my_getcookie('pass_hash');
|
||||
|
||||
|
||||
if ( $cookie['session_id'] )
|
||||
{
|
||||
$this->get_session($cookie['session_id']);
|
||||
$ibforums->session_type = 'cookie';
|
||||
}
|
||||
elseif ( $ibforums->input['s'] )
|
||||
{
|
||||
$this->get_session($ibforums->input['s']);
|
||||
$ibforums->session_type = 'url';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session_id = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have a valid session ID?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->session_id )
|
||||
{
|
||||
// We've checked the IP addy and browser, so we can assume that this is
|
||||
// a valid session.
|
||||
|
||||
if ( ($this->session_user_id != 0) and ( ! empty($this->session_user_id) ) )
|
||||
{
|
||||
// It's a member session, so load the member.
|
||||
|
||||
$this->load_member($this->session_user_id);
|
||||
|
||||
// Did we get a member?
|
||||
|
||||
if ( (! $this->member['id']) or ($this->member['id'] == 0) )
|
||||
{
|
||||
$this->unload_member();
|
||||
$this->update_guest_session();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->update_member_session();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->update_guest_session();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// We didn't have a session, or the session didn't validate
|
||||
|
||||
// Do we have cookies stored?
|
||||
|
||||
if ($cookie['member_id'] != "" and $cookie['pass_hash'] != "")
|
||||
{
|
||||
$this->load_member($cookie['member_id']);
|
||||
|
||||
if ( (! $this->member['id']) or ($this->member['id'] == 0) )
|
||||
{
|
||||
$this->unload_member();
|
||||
$this->create_guest_session();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->member['member_login_key'] == $cookie['pass_hash'])
|
||||
{
|
||||
$this->create_member_session();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->unload_member();
|
||||
$this->create_guest_session();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->create_guest_session();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we a member of several groups?
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if (! $this->member['id'])
|
||||
{
|
||||
$this->member = $std->set_up_guest();
|
||||
$this->member['mgroup'] = $ibforums->vars['guest_group'];
|
||||
$ibforums->input['last_activity'] = time();
|
||||
$ibforums->input['last_visit'] = time();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Do we have a cache?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! is_array( $ibforums->cache['group_cache'] ) )
|
||||
{
|
||||
$ibforums->cache['group_cache'] = array();
|
||||
|
||||
$DB->simple_construct( array( 'select' => "*",
|
||||
'from' => 'groups'
|
||||
) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
while ( $i = $DB->fetch_row() )
|
||||
{
|
||||
$ibforums->cache['group_cache'][ $i['g_id'] ] = $i;
|
||||
}
|
||||
|
||||
$std->update_cache( array( 'name' => 'group_cache', 'array' => 1, 'deletefirst' => 1 ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Set up main 'display' group
|
||||
//-----------------------------------------
|
||||
|
||||
$this->member = array_merge( $this->member, $ibforums->cache['group_cache'][ $this->member['mgroup'] ] );
|
||||
|
||||
//-----------------------------------------
|
||||
// Sprinkle on some moderator stuff...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->member['mgroup'] != $ibforums->vars['guest_group'] )
|
||||
{
|
||||
if ( $this->member['g_is_supmod'] == 1 )
|
||||
{
|
||||
$this->member['is_mod'] = 1;
|
||||
}
|
||||
else if ( count($ibforums->cache['moderators']) )
|
||||
{
|
||||
foreach( $ibforums->cache['moderators'] as $i => $r )
|
||||
{
|
||||
if ( $r['member_id'] == $this->member['id'] or $r['group_id'] == $this->member['mgroup'] )
|
||||
{
|
||||
$this->member['_moderator'][ $r['forum_id'] ] = $r;
|
||||
$this->member['is_mod'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//header('content-type:text/plain'); print_r($this->member); exit();
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we a member of several groups?
|
||||
//-----------------------------------------
|
||||
|
||||
$this->build_group_permissions();
|
||||
|
||||
//-----------------------------------------
|
||||
// Synchronise the last visit and activity times if
|
||||
// we have some in the member profile
|
||||
//-----------------------------------------
|
||||
|
||||
if ($this->member['id'])
|
||||
{
|
||||
if ( ! $ibforums->input['last_activity'] )
|
||||
{
|
||||
if ($this->member['last_activity'])
|
||||
{
|
||||
$ibforums->input['last_activity'] = $this->member['last_activity'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ibforums->input['last_activity'] = $this->time_now;
|
||||
}
|
||||
}
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $ibforums->input['last_visit'] )
|
||||
{
|
||||
if ($this->member['last_visit'])
|
||||
{
|
||||
$ibforums->input['last_visit'] = $this->member['last_visit'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ibforums->input['last_visit'] = $this->time_now;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// If there hasn't been a cookie update in 2 hours,
|
||||
// we assume that they've gone and come back
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->member['last_visit'] )
|
||||
{
|
||||
// No last visit set, do so now!
|
||||
|
||||
$DB->simple_construct( array( 'update' => 'members',
|
||||
'lowpro' => 1,
|
||||
'set' => "last_visit=".$this->time_now.", last_activity=".$this->time_now,
|
||||
'where' => "id=".$this->member['id']
|
||||
) );
|
||||
|
||||
$DB->simple_shutdown_exec();
|
||||
|
||||
}
|
||||
else if ( (time() - $ibforums->input['last_activity']) > 300 )
|
||||
{
|
||||
// If the last click was longer than 5 mins ago and this is a member
|
||||
// Update their profile.
|
||||
|
||||
list( $be_anon, $loggedin ) = explode( '&', $this->member['login_anonymous'] );
|
||||
|
||||
$DB->simple_construct( array( 'update' => 'members',
|
||||
'lowpro' => 1,
|
||||
'set' => "login_anonymous='$be_anon&1', last_activity=".$this->time_now,
|
||||
'where' => "id=".$this->member['id']
|
||||
) );
|
||||
|
||||
$DB->simple_shutdown_exec();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Check ban status
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->member['temp_ban'] )
|
||||
{
|
||||
$ban_arr = $std->hdl_ban_line( $this->member['temp_ban'] );
|
||||
|
||||
if ( time() >= $ban_arr['date_end'] )
|
||||
{
|
||||
// Update this member's profile
|
||||
|
||||
$DB->simple_construct( array( 'update' => 'members',
|
||||
'lowpro' => 1,
|
||||
'set' => "temp_ban=''",
|
||||
'where' => "id=".$this->member['id']
|
||||
) );
|
||||
|
||||
$DB->simple_shutdown_exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
$ibforums->member = $this->member; // Set time right
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'account_susp', 'INIT' => 1, 'EXTRA' => $std->get_date($ban_arr['date_end'],'LONG', 1) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Set a session ID cookie
|
||||
//-----------------------------------------
|
||||
|
||||
$std->my_setcookie("session_id", $this->session_id, -1);
|
||||
|
||||
return $this->member;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Build group permissions
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function build_group_permissions()
|
||||
{
|
||||
global $ibforums, $std;
|
||||
|
||||
if ( $this->member['mgroup_others'] )
|
||||
{
|
||||
$groups_id = explode( ',', $this->member['mgroup_others'] );
|
||||
$exclude = array( 'g_title', 'g_icon', 'prefix', 'suffix', 'g_promotion', 'g_photo_max_vars' );
|
||||
$less_is_more = array( 'g_search_flood' );
|
||||
|
||||
if ( count( $groups_id ) )
|
||||
{
|
||||
foreach( $groups_id as $pid )
|
||||
{
|
||||
if ( ! $ibforums->cache['group_cache'][ $pid ]['g_id'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Loop through and mix
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $ibforums->cache['group_cache'][ $pid ] as $k => $v )
|
||||
{
|
||||
if ( ! in_array( $k, $exclude ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Add to perm id list
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $k == 'g_perm_id' )
|
||||
{
|
||||
$this->member['g_perm_id'] .= ','.$v;
|
||||
}
|
||||
else if ( in_array( $k, $less_is_more ) )
|
||||
{
|
||||
if ( $v < $this->member[ $k ] )
|
||||
{
|
||||
$this->member[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $v > $this->member[ $k ] )
|
||||
{
|
||||
$this->member[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Tidy perms_id
|
||||
//-----------------------------------------
|
||||
|
||||
$rmp = array();
|
||||
$tmp = explode( ',', $std->clean_perm_string($this->member['g_perm_id']) );
|
||||
|
||||
if ( count( $tmp ) )
|
||||
{
|
||||
foreach( $tmp as $t )
|
||||
{
|
||||
$rmp[ $t ] = $t;
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $rmp ) )
|
||||
{
|
||||
$this->member['g_perm_id'] = implode( ',', $rmp );
|
||||
}
|
||||
}
|
||||
|
||||
$ibforums->perm_id = ( $this->member['org_perm_id'] ) ? $this->member['org_perm_id'] : $this->member['g_perm_id'];
|
||||
|
||||
$ibforums->perm_id_array = explode( ",", $ibforums->perm_id );
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Attempt to load a member
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function load_member($member_id=0)
|
||||
{
|
||||
global $DB, $std, $ibforums;
|
||||
|
||||
$member_id = intval($member_id);
|
||||
|
||||
if ($member_id != 0)
|
||||
{
|
||||
$DB->cache_add_query( 'session_load_member', array( 'mid' => $member_id ) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
if ( $DB->get_num_rows() )
|
||||
{
|
||||
$this->member = $DB->fetch_row();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Unless they have a member id, log 'em in as a guest
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ($this->member['id'] == 0) or (empty($this->member['id'])) )
|
||||
{
|
||||
$this->unload_member();
|
||||
}
|
||||
}
|
||||
|
||||
unset($member_id);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Remove the users cookies
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function unload_member()
|
||||
{
|
||||
global $DB, $std, $ibforums;
|
||||
|
||||
// Boink the cookies
|
||||
|
||||
$std->my_setcookie( "member_id" , "0", -1 );
|
||||
$std->my_setcookie( "pass_hash" , "0", -1 );
|
||||
|
||||
$this->member['id'] = 0;
|
||||
$this->member['name'] = "";
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Updates a current session.
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function update_member_session()
|
||||
{
|
||||
global $DB, $ibforums;
|
||||
|
||||
// Make sure we have a session id.
|
||||
|
||||
if ( ! $this->session_id )
|
||||
{
|
||||
$this->create_member_session();
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($this->member['id']))
|
||||
{
|
||||
$this->unload_member();
|
||||
$this->create_guest_session();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$DB->do_shutdown_update( 'sessions',
|
||||
array(
|
||||
'member_name' => $this->member['name'],
|
||||
'member_id' => intval($this->member['id']),
|
||||
'member_group' => $this->member['mgroup'],
|
||||
'in_forum' => intval($ibforums->input['f']),
|
||||
'in_topic' => intval($ibforums->input['t']),
|
||||
'login_type' => substr($this->member['login_anonymous'],0, 1),
|
||||
'running_time' => $this->time_now,
|
||||
'location' => $ibforums->input['act'].",".$ibforums->input['p'].",".$ibforums->input['CODE'],
|
||||
'in_error' => 0,
|
||||
),
|
||||
"id='{$this->session_id}'"
|
||||
);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Update guest session
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function update_guest_session()
|
||||
{
|
||||
global $DB, $ibforums, $INFO;
|
||||
|
||||
// Make sure we have a session id.
|
||||
|
||||
if ( ! $this->session_id )
|
||||
{
|
||||
$this->create_guest_session();
|
||||
return;
|
||||
}
|
||||
|
||||
$DB->do_shutdown_update( 'sessions',
|
||||
array(
|
||||
'member_name' => "",
|
||||
'member_id' => 0,
|
||||
'member_group' => $ibforums->vars['guest_group'],
|
||||
'in_forum' => intval($ibforums->input['f']),
|
||||
'in_topic' => intval($ibforums->input['t']),
|
||||
'login_type' => substr($this->member['login_anonymous'],0, 1),
|
||||
'running_time' => $this->time_now,
|
||||
'location' => $ibforums->input['act'].",".$ibforums->input['p'].",".$ibforums->input['CODE'],
|
||||
'in_error' => 0,
|
||||
),
|
||||
"id='{$this->session_id}'"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Get a session based on the current session ID
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function get_session($session_id="")
|
||||
{
|
||||
global $DB, $ibforums, $std;
|
||||
|
||||
$result = array();
|
||||
|
||||
$query = "";
|
||||
|
||||
$session_id = preg_replace("/([^a-zA-Z0-9])/", "", $session_id);
|
||||
|
||||
if ( $session_id )
|
||||
{
|
||||
if ($ibforums->vars['match_browser'] == 1)
|
||||
{
|
||||
$query = " AND browser='".$this->user_agent."'";
|
||||
}
|
||||
|
||||
$DB->simple_construct( array( 'select' => 'id, member_id, running_time, location',
|
||||
'from' => 'sessions',
|
||||
'where' => "id='".$session_id."' and ip_address='".$this->ip_address."'".$query
|
||||
) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
if ( $DB->get_num_rows() != 1 )
|
||||
{
|
||||
// Either there is no session, or we have more than one session..
|
||||
|
||||
$this->session_dead_id = $session_id;
|
||||
$this->session_id = 0;
|
||||
$this->session_user_id = 0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $DB->fetch_row();
|
||||
|
||||
if ($result['id'] == "")
|
||||
{
|
||||
$this->session_dead_id = $session_id;
|
||||
$this->session_id = 0;
|
||||
$this->session_user_id = 0;
|
||||
unset($result);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session_id = $result['id'];
|
||||
$this->session_user_id = $result['member_id'];
|
||||
$this->last_click = $result['running_time'];
|
||||
$this->location = $result['location'];
|
||||
unset($result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Creates a member session.
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function create_member_session()
|
||||
{
|
||||
global $DB, $INFO, $std, $ibforums;
|
||||
|
||||
if ($this->member['id'])
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Remove the defunct sessions
|
||||
//-----------------------------------------
|
||||
|
||||
$ibforums->vars['session_expiration'] = $ibforums->vars['session_expiration'] ? (time() - $ibforums->vars['session_expiration']) : (time() - 3600);
|
||||
|
||||
$DB->simple_construct( array( 'delete' => 'sessions', 'where' => "member_id=".$this->member['id'] ) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
$this->session_id = md5( uniqid(microtime()) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Insert the new session
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->do_shutdown_insert( 'sessions',
|
||||
array(
|
||||
'id' => $this->session_id,
|
||||
'member_name' => $this->member['name'],
|
||||
'member_id' => intval($this->member['id']),
|
||||
'member_group' => $this->member['mgroup'],
|
||||
'in_forum' => intval($ibforums->input['f']),
|
||||
'in_topic' => intval($ibforums->input['t']),
|
||||
'login_type' => substr($this->member['login_anonymous'],0, 1),
|
||||
'running_time' => $this->time_now,
|
||||
'location' => $ibforums->input['act'].",".$ibforums->input['p'].",".$ibforums->input['CODE'],
|
||||
'ip_address' => $this->ip_address,
|
||||
'browser' => $this->user_agent,
|
||||
'in_error' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
//-----------------------------------------
|
||||
// If this is a member, update their last visit times, etc.
|
||||
//-----------------------------------------
|
||||
|
||||
if ( time() - $this->member['last_activity'] > 3600 )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Reset the topics read cookie..
|
||||
//-----------------------------------------
|
||||
|
||||
$std->my_setcookie('topicsread', '');
|
||||
|
||||
list( $be_anon, $loggedin ) = explode( '&', $this->member['login_anonymous'] );
|
||||
|
||||
$DB->simple_construct( array( 'update' => 'members',
|
||||
'set' => "login_anonymous='$be_anon&1', last_visit=last_activity, last_activity=".$this->time_now,
|
||||
'where' => "id=".$this->member['id']
|
||||
) );
|
||||
|
||||
$DB->simple_shutdown_exec();
|
||||
|
||||
//-----------------------------------------
|
||||
// Fix up the last visit/activity times.
|
||||
//-----------------------------------------
|
||||
|
||||
$ibforums->input['last_visit'] = $this->member['last_activity'];
|
||||
$ibforums->input['last_activity'] = $this->time_now;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->create_guest_session();
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Create guest session
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function create_guest_session()
|
||||
{
|
||||
global $DB, $std, $ibforums;
|
||||
|
||||
//-----------------------------------------
|
||||
// Remove the defunct sessions
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ($this->session_dead_id != 0) and ( ! empty($this->session_dead_id) ) )
|
||||
{
|
||||
$extra = " or id='".$this->session_dead_id."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$extra = "";
|
||||
}
|
||||
|
||||
$ibforums->vars['session_expiration'] = $ibforums->vars['session_expiration'] ? (time() - $ibforums->vars['session_expiration']) : (time() - 3600);
|
||||
|
||||
$DB->simple_construct( array( 'delete' => 'sessions', 'where' => "ip_address='".$this->ip_address."'".$extra ) );
|
||||
|
||||
$DB->simple_exec();
|
||||
|
||||
$this->session_id = md5( uniqid(microtime()) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Insert the new session
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->do_shutdown_insert( 'sessions',
|
||||
array(
|
||||
'id' => $this->session_id,
|
||||
'member_name' => '',
|
||||
'member_id' => 0,
|
||||
'member_group' => $ibforums->vars['guest_group'],
|
||||
'in_forum' => intval($ibforums->input['f']),
|
||||
'in_topic' => intval($ibforums->input['t']),
|
||||
'login_type' => 0,
|
||||
'running_time' => $this->time_now,
|
||||
'location' => $ibforums->input['act'].",".$ibforums->input['p'].",".$ibforums->input['CODE'],
|
||||
'ip_address' => $this->ip_address,
|
||||
'browser' => $this->user_agent,
|
||||
'in_error' => 0,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Creates a BOT session
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function create_bot_session($bot, $name="")
|
||||
{
|
||||
global $DB, $std, $ibforums;
|
||||
|
||||
$DB->do_shutdown_insert( 'sessions',
|
||||
array(
|
||||
'id' => $bot.'='.str_replace('.','',$this->ip_address ).'_session',
|
||||
'member_name' => $name ? $name : $bot,
|
||||
'member_id' => 0,
|
||||
'member_group' => $ibforums->vars['spider_group'],
|
||||
'in_forum' => intval($ibforums->input['f']),
|
||||
'in_topic' => intval($ibforums->input['t']),
|
||||
'login_type' => $ibforums->vars['spider_anon'],
|
||||
'running_time' => $this->time_now,
|
||||
'location' => $ibforums->input['act'].",".$ibforums->input['p'].",".$ibforums->input['CODE'],
|
||||
'ip_address' => $this->ip_address,
|
||||
'browser' => $this->user_agent,
|
||||
'in_error' => 0,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// Updates a BOT current session.
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function update_bot_session($bot, $name="")
|
||||
{
|
||||
global $DB, $ibforums;
|
||||
|
||||
$DB->do_shutdown_update( 'sessions',
|
||||
array(
|
||||
'member_name' => $name ? $name : $bot,
|
||||
'member_id' => 0,
|
||||
'member_group' => $ibforums->vars['spider_group'],
|
||||
'in_forum' => intval($ibforums->input['f']),
|
||||
'in_topic' => intval($ibforums->input['t']),
|
||||
'login_type' => $ibforums->vars['spider_anon'],
|
||||
'running_time' => $this->time_now,
|
||||
'location' => $ibforums->input['act'].",".$ibforums->input['p'].",".$ibforums->input['CODE'],
|
||||
'in_error' => 0,
|
||||
),
|
||||
"id='".$bot.'='.str_replace('.','',$this->ip_address )."_session'"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user