Files
IPB/upload/sources/lib/func_usercp.php
T
2025-12-19 00:21:15 -08:00

1818 lines
58 KiB
PHP

<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board 2.1.7
| =============================================
| by Matthew Mecham
| (c) 2001 - 2005 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| http://www.ibresource.ru/products/invisionpowerboard/
| Time: Tuesday 18th of July 2006 05:56:00 PM
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
| Licence Info: http://www.invisionboard.com/?license
| http://www.ibresource.ru/license
+---------------------------------------------------------------------------
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
+---------------------------------------------------------------------------
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
+---------------------------------------------------------------------------
| > $Date: 2006-02-17 14:52:09 +0000 (Fri, 17 Feb 2006) $
| > $Revision: 142 $
| > $Author: bfarber $
+---------------------------------------------------------------------------
|
| > UserCP functions library
| > Module written by Matt Mecham
| > Date started: 20th February 2002
|
| > Module Version Number: 1.0.0
| > DBA Checked: Fri 21 May 2004
+--------------------------------------------------------------------------
*/
class func_usercp
{
var $ipsclass;
var $class;
var $image;
var $jump_html;
/*-------------------------------------------------------------------------*/
// CONSTRUCTOR
/*-------------------------------------------------------------------------*/
function func_usercp(&$class)
{
$this->class = &$class;
require_once( KERNEL_PATH.'class_image.php' );
$this->image = new class_image();
}
/*-------------------------------------------------------------------------*/
// Generate the UserCP menu
/*-------------------------------------------------------------------------*/
function ucp_generate_menu()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$menu_html = "";
$component_html = "";
$folder_links = "";
//-----------------------------------------
// Get all member info..
//-----------------------------------------
$this->ipsclass->DB->cache_add_query( 'generic_get_all_member', array( 'mid' => $this->ipsclass->member['id'] ) );
$this->ipsclass->DB->cache_exec_query();
if ( ! $member = $this->ipsclass->DB->fetch_row() )
{
$this->ipsclass->DB->do_insert( 'member_extra', array( 'id' => $this->ipsclass->member['id'] ) );
}
else
{
$this->ipsclass->member = array_merge( $member, $this->ipsclass->member );
}
//-----------------------------------------
// Get enabled components
//-----------------------------------------
if ( is_array( $this->ipsclass->cache['components'] ) and count( $this->ipsclass->cache['components'] ) )
{
foreach( $this->ipsclass->cache['components'] as $id => $data )
{
$file = ROOT_PATH.'sources/components_ucp/'.$data['com_filename'].'.php';
if ( file_exists( $file ) )
{
require_once( $file );
$name = 'components_ucp_'.$data['com_filename'];
$tmp = new $name();
$tmp->ipsclass =& $this->ipsclass;
$component_html .= $tmp->ucp_build_menu();
unset($tmp);
}
}
}
//-----------------------------------------
// Print the top button menu
//-----------------------------------------
$menu_html = $this->ipsclass->compiled_templates['skin_ucp']->Menu_bar( $component_html );
//-----------------------------------------
// Messenger
//-----------------------------------------
if ( $this->ipsclass->member['g_use_pm'] )
{
//-----------------------------------------
// Do a little set up, do a litle dance, get
// down tonight! *boogie*
//-----------------------------------------
$this->jump_html = "<select name='VID' class='forminput'>\n";
$this->ipsclass->member['dir_data'] = array();
//-----------------------------------------
// Do we have VID?
// No, it's just the way we walk! Haha, etc.
//-----------------------------------------
if ($this->ipsclass->input['VID'])
{
$this->vid = $this->ipsclass->input['VID'];
}
else
{
$this->vid = 'in';
}
//-----------------------------------------
// Print folder links
//-----------------------------------------
if ( ! $this->ipsclass->member['vdirs'] )
{
$this->ipsclass->member['vdirs'] = "in:Âõîäÿùèå|sent:Îòïðàâëåííûå";
}
foreach( explode( "|", $this->ipsclass->member['vdirs'] ) as $dir )
{
list ($id , $data) = explode( ":", $dir );
list ($real, $count) = explode( ";", $data );
if ( ! $id )
{
continue;
}
$this->ipsclass->member['dir_data'][$id] = array( 'id' => $id, 'real' => $real, 'count' => $count );
if ($this->vid == $id)
{
$this->ipsclass->member['current_dir'] = $real;
$this->ipsclass->member['current_id'] = $id;
$this->jump_html .= "<option value='$id' selected='selected'>$real</option>\n";
}
else
{
$this->jump_html .= "<option value='$id'>$real</option>\n";
}
if ( $count )
{
$real .= " ({$count})";
}
$folder_links .= $this->ipsclass->compiled_templates['skin_ucp']->menu_bar_msg_folder_link($id, $real);
}
if ( $folder_links != "" )
{
$menu_html = str_replace( "<!--IBF.FOLDER_LINKS-->", $folder_links, $menu_html );
}
}
$this->jump_html .= "<!--EXTRA--></select>\n\n";
return $menu_html;
}
/*-------------------------------------------------------------------------*/
// HANDLE SUBSCRIPTION START
/*-------------------------------------------------------------------------*/
function subs_choose($save="")
{
//-----------------------------------------
// Topic - forum - what?
//-----------------------------------------
$method = $this->ipsclass->input['method'] == 'forum' ? 'forum' : 'topic';
$tid = intval($this->ipsclass->input['tid']);
$fid = intval($this->ipsclass->input['fid']);
if ( $method == 'topic' )
{
//-----------------------------------------
// Get the details from the DB (TOPIC)
//-----------------------------------------
$topic = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'topics', 'where' => 'tid='.$tid ) );
if ( ! $topic['tid'] )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
$forum = $this->ipsclass->forums->forum_by_id[ $topic['forum_id'] ];
}
else
{
//-----------------------------------------
// Get the details (FORUM)
//-----------------------------------------
$forum = $this->ipsclass->forums->forum_by_id[ $fid ];
}
//-----------------------------------------
// Permy check
//-----------------------------------------
if ( $this->ipsclass->check_perms( $this->ipsclass->forums->forum_by_id[ $forum['id'] ]['read_perms'] ) != TRUE )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-----------------------------------------
// Passy check
//-----------------------------------------
if ( $forum['password'] != "" )
{
if ( $this->ipsclass->forums->forums_compare_password( $forum['id'] ) != TRUE )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'forum_no_access') );
}
}
//-----------------------------------------
// Have we already subscribed?
//-----------------------------------------
if ( $method == 'forum' )
{
$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'frid as tmpid',
'from' => 'forum_tracker',
'where' => "forum_id={$fid} AND member_id=".$this->ipsclass->member['id'] ) );
}
else
{
$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'trid as tmpid',
'from' => 'tracker',
'where' => "topic_id={$tid} AND member_id=".$this->ipsclass->member['id'] ) );
}
if ( $tmp['tmpid'] )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'already_sub') );
}
//-----------------------------------------
// What to do...
//-----------------------------------------
if ( ! $save )
{
//-----------------------------------------
// Okay, lets do the HTML
//-----------------------------------------
$this->class->output .= $this->ipsclass->compiled_templates['skin_ucp']->subs_show_choice_page( $forum, $topic, $method, $this->class->md5_check );
}
else
{
//-----------------------------------------
// Method..
//-----------------------------------------
switch ($this->ipsclass->input['emailtype'])
{
case 'immediate':
$this->method = 'immediate';
break;
case 'delayed':
$this->method = 'delayed';
break;
case 'none':
$this->method = 'none';
break;
case 'daily':
$this->method = 'daily';
break;
case 'weekly':
$this->method = 'weekly';
break;
default:
$this->method = 'delayed';
break;
}
//-----------------------------------------
// Add it to the DB
//-----------------------------------------
if ( $method == 'forum' )
{
$this->ipsclass->DB->do_insert( 'forum_tracker', array (
'member_id' => $this->ipsclass->member['id'],
'forum_id' => $fid,
'start_date' => time(),
'forum_track_type' => $this->method,
) );
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['sub_added'], "showforum=$fid" );
}
else
{
$this->ipsclass->DB->do_insert( 'tracker', array (
'member_id' => $this->ipsclass->member['id'],
'topic_id' => $tid,
'start_date' => time(),
'topic_track_type' => $this->method,
) );
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['sub_added'], "showtopic=$tid&st={$this->ipsclass->input['st']}" );
}
}
$this->class->page_title = $this->ipsclass->lang['t_welcome'];
$this->class->nav = array( "<a href='".$this->ipsclass->base_url."act=usercp&amp;CODE=00'>".$this->ipsclass->lang['t_title']."</a>" );
}
/*-------------------------------------------------------------------------*/
// HANDLE PHOTO OP'S
/*-------------------------------------------------------------------------*/
function do_photo()
{
if ($_POST['act'] == "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//-----------------------------------------
// Nawty, Nawty!
//-----------------------------------------
if ($this->ipsclass->input['auth_key'] != $this->class->md5_check )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post') );
}
//-----------------------------------------
// Did we press "remove"?
//-----------------------------------------
if ( $this->ipsclass->input['remove'] )
{
$this->bash_uploaded_photos($this->ipsclass->member['id']);
$this->ipsclass->DB->simple_construct( array( 'select' => 'id', 'from' => 'member_extra', 'where' => "id=".$this->ipsclass->member['id'] ) );
$this->ipsclass->DB->simple_exec();
if ( $this->ipsclass->DB->get_num_rows() )
{
$this->ipsclass->DB->do_update( 'member_extra', array( 'photo_location' => '',
'photo_type' => '',
'photo_dimensions' => '',
), 'id='.$this->ipsclass->member['id'] );
}
else
{
$this->ipsclass->DB->do_insert( 'member_extra', array( 'photo_location' => '',
'photo_type' => '',
'photo_dimensions' => '',
'id' => $this->ipsclass->member['id']
) );
}
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['photo_c_up'], "act=UserCP&CODE=photo" );
}
//-----------------------------------------
// NO? CARRY ON!!
//-----------------------------------------
list($p_max, $p_width, $p_height) = explode( ":", $this->ipsclass->member['g_photo_max_vars'] );
//-----------------------------------------
// Check to make sure we don't just have
// http:// in the URL box..
//-----------------------------------------
if ( preg_match( "/^http:\/\/$/i", $this->ipsclass->input['url_photo'] ) )
{
$this->ipsclass->input['url_photo'] = "";
}
if ( $this->ipsclass->xss_check_url( $this->ipsclass->input['url_photo'] ) !== TRUE )
{
$this->ipsclass->input['url_photo'] = '';
}
if ( empty($this->ipsclass->input['url_photo']) )
{
//-----------------------------------------
// Lets check for an uploaded photo..
//-----------------------------------------
if ($_FILES['upload_photo']['name'] != "" and ($_FILES['upload_photo']['name'] != "none") )
{
//-----------------------------------------
// Are we allowed to upload this avatar?
//-----------------------------------------
if ( $p_max < 0 )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_upload' ) );
}
//-----------------------------------------
// Remove any uploaded photos...
//-----------------------------------------
$this->bash_uploaded_photos($this->ipsclass->member['id']);
$real_name = 'photo-'.$this->ipsclass->member['id'];
$real_type = 'upload';
//-----------------------------------------
// Load the library
//-----------------------------------------
require_once( KERNEL_PATH.'class_upload.php' );
$upload = new class_upload();
//-----------------------------------------
// Set up the variables
//-----------------------------------------
$upload->out_file_name = 'photo-'.$this->ipsclass->member['id'];
$upload->out_file_dir = $this->ipsclass->vars['upload_dir'];
$upload->max_file_size = ($p_max * 1024) * 8; // Allow xtra for compression
$upload->upload_form_field = 'upload_photo';
//-----------------------------------------
// Populate allowed extensions
//-----------------------------------------
if ( is_array( $this->ipsclass->cache['attachtypes'] ) and count( $this->ipsclass->cache['attachtypes'] ) )
{
foreach( $this->ipsclass->cache['attachtypes'] as $idx => $data )
{
if ( $data['atype_photo'] )
{
$upload->allowed_file_ext[] = $data['atype_extension'];
}
}
}
//-----------------------------------------
// Upload...
//-----------------------------------------
$upload->upload_process();
//-----------------------------------------
// Error?
//-----------------------------------------
if ( $upload->error_no )
{
switch( $upload->error_no )
{
case 1:
// No upload
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_failed' ) );
case 2:
// Invalid file ext
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_type' ) );
case 3:
// Too big...
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_to_big') );
case 4:
// Cannot move uploaded file
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_failed' ) );
case 5:
// Possible XSS attack (image isn't an image)
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_failed' ) );
}
}
//-----------------------------------------
// Still here?
//-----------------------------------------
$real_name = $upload->parsed_file_name;
//-----------------------------------------
// Check image size...
//-----------------------------------------
if ( ! $this->ipsclass->vars['disable_ipbsize'] )
{
$this->image->in_type = 'file';
$this->image->out_type = 'file';
$this->image->in_file_dir = $this->ipsclass->vars['upload_dir'];
$this->image->in_file_name = $real_name;
$this->image->out_file_name = 'photos-'.$this->ipsclass->member['id'];
$this->image->desired_width = $p_width;
$this->image->desired_height = $p_height;
$return = $this->image->generate_thumbnail();
$im['img_width'] = $return['thumb_width'];
$im['img_height'] = $return['thumb_height'];
//-----------------------------------------
// Do we have an attachment?
//-----------------------------------------
if ( strstr( $return['thumb_location'], 'photos-' ) )
{
//-----------------------------------------
// Kill old and rename new...
//-----------------------------------------
@unlink( $this->ipsclass->vars['upload_dir']."/".$real_name );
$real_name = 'photo-'.$this->ipsclass->member['id'].'.'.$this->image->file_extension;
@rename( $this->ipsclass->vars['upload_dir']."/".$return['thumb_location'], $this->ipsclass->vars['upload_dir']."/".$real_name );
@chmod( $this->ipsclass->vars['upload_dir']."/".$real_name, 0777 );
}
}
else
{
$w = intval($this->ipsclass->input['man_width']) ? intval($this->ipsclass->input['man_width']) : $p_width;
$h = intval($this->ipsclass->input['man_height']) ? intval($this->ipsclass->input['man_height']) : $p_height;
$im['img_width'] = $w > $p_width ? $p_width : $w;
$im['img_height'] = $h > $p_height ? $p_height : $h;
}
//-----------------------------------------
// Check the file size (after compression)
//-----------------------------------------
if ( filesize( $this->ipsclass->vars['upload_dir']."/".$real_name ) > ( $p_max * 1024 ) )
{
@unlink( $this->ipsclass->vars['upload_dir']."/".$real_name );
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_to_big' ) );
}
$final_location = $real_name;
$final_type = 'upload';
$final_dimension = $im['img_width'].','.$im['img_height'];
}
else
{
//-----------------------------------------
// URL field and upload field left blank.
//-----------------------------------------
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_photo_selected' ) );
}
}
else
{
//-----------------------------------------
// It's an entered URL 'ting man
//-----------------------------------------
if ( empty($this->ipsclass->vars['allow_dynamic_img']) )
{
if ( preg_match( "/[?&;]/", $this->ipsclass->input['url_photo'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'not_url_photo' ) );
}
}
//-----------------------------------------
// Check extension
//-----------------------------------------
$ext = explode ( ",", $this->ipsclass->vars['photo_ext'] );
$checked = 0;
$av_ext = preg_replace( "/^.*\.(\S+)$/", "\\1", $this->ipsclass->input['url_photo'] );
foreach ($ext as $v )
{
if (strtolower($v) == strtolower($av_ext))
{
$checked = 1;
}
}
if ($checked != 1)
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'photo_invalid_ext' ) );
}
//-----------------------------------------
// Check image size...
//-----------------------------------------
$im = array();
if ( ! $this->ipsclass->vars['disable_ipbsize'] )
{
if ( ! $img_size = @GetImageSize( $this->ipsclass->input['url_photo'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'not_url_photo' ) );
}
$im = $this->ipsclass->scale_image( array(
'max_width' => $p_width,
'max_height' => $p_height,
'cur_width' => $img_size[0],
'cur_height' => $img_size[1]
) );
}
else
{
$w = intval($this->ipsclass->input['man_width']) ? intval($this->ipsclass->input['man_width']) : $p_width;
$h = intval($this->ipsclass->input['man_height']) ? intval($this->ipsclass->input['man_height']) : $p_height;
$im['img_width'] = $w > $p_width ? $p_width : $w;
$im['img_height'] = $h > $p_height ? $p_height : $h;
}
//-----------------------------------------
// Remove any uploaded images..
//-----------------------------------------
$this->bash_uploaded_photos($this->ipsclass->member['id']);
$final_location = $this->ipsclass->input['url_photo'];
$final_type = 'url';
$final_dimension = $im['img_width'].','.$im['img_height'];
}
// Do we have an entry?
$this->ipsclass->DB->simple_construct( array( 'select' => 'id', 'from' => 'member_extra', 'where' => "id=".$this->ipsclass->member['id'] ) );
$this->ipsclass->DB->simple_exec();
if ( $this->ipsclass->DB->get_num_rows() )
{
$this->ipsclass->DB->do_update( 'member_extra', array( 'photo_location' => $final_location,
'photo_type' => $final_type,
'photo_dimensions' => $final_dimension,
), 'id='.$this->ipsclass->member['id'] );
}
else
{
$this->ipsclass->DB->do_insert( 'member_extra', array( 'photo_location' => $final_location,
'photo_type' => $final_type,
'photo_dimensions' => $final_dimension,
'id' => $this->ipsclass->member['id']
) );
}
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['photo_c_up'], "act=UserCP&CODE=photo" );
}
/*-------------------------------------------------------------------------*/
// REMOVE UPLOADED PICCIES
/*-------------------------------------------------------------------------*/
function bash_uploaded_photos($id)
{
foreach( array( 'swf', 'jpg', 'jpeg', 'gif', 'png' ) as $ext )
{
if ( @file_exists( $this->ipsclass->vars['upload_dir']."/photo-".$id.".".$ext ) )
{
@unlink( $this->ipsclass->vars['upload_dir']."/photo-".$id.".".$ext );
}
}
}
function bash_uploaded_avatars($id)
{
foreach( array( 'swf', 'jpg', 'jpeg', 'gif', 'png' ) as $ext )
{
if ( @file_exists( $this->ipsclass->vars['upload_dir']."/av-".$id.".".$ext ) )
{
@unlink( $this->ipsclass->vars['upload_dir']."/av-".$id.".".$ext );
}
}
}
/*-------------------------------------------------------------------------*/
// SAVE SKIN/LANG PREFS
/*-------------------------------------------------------------------------*/
function do_skin_langs()
{
// Check input for 1337 h/\x0r nonsense
if ($_POST['act'] == "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//-----------------------------------------
// Nawty, Nawty!
//-----------------------------------------
if ($this->ipsclass->input['auth_key'] != $this->class->md5_check )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post') );
}
//-----------------------------------------
if ( preg_match( "/\.\./", $this->ipsclass->input['u_skin'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//-----------------------------------------
if ( preg_match( "/\.\./", $this->ipsclass->input['u_language'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//-----------------------------------------
if ($this->ipsclass->vars['allow_skins'] == 1)
{
$this->ipsclass->DB->query("SELECT sid FROM ibf_skins WHERE hidden <> 1 AND sid='".$this->ipsclass->input['u_skin']."'");
if (! $this->ipsclass->DB->get_num_rows() )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'skin_not_found' ) );
}
$db_string = $this->ipsclass->DB->compile_db_update_string( array (
'language' => $this->ipsclass->input['u_language'],
'skin ' => $this->ipsclass->input['u_skin'],
) );
}
else
{
$db_string = $this->ipsclass->DB->compile_db_update_string( array (
'language' => $this->ipsclass->input['u_language'],
) );
}
//-----------------------------------------
$this->ipsclass->DB->query("UPDATE ibf_members SET $db_string WHERE id='".$this->ipsclass->member['id']."'");
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['set_updated'], "act=UserCP&CODE=06" );
}
/*-------------------------------------------------------------------------*/
// Board prefs
/*-------------------------------------------------------------------------*/
function do_board_prefs()
{
// Check the input for naughties :D
//-----------------------------------------
// Nawty, Nawty!
//-----------------------------------------
if ($this->ipsclass->input['auth_key'] != $this->class->md5_check )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post') );
}
if ($_POST['act'] == "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//-----------------------------------------
// Timezone
//-----------------------------------------
if ( ! preg_match( "/^[\-\d\.]+$/", $this->ipsclass->input['u_timezone'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//-----------------------------------------
// Check
//-----------------------------------------
if ($this->ipsclass->vars['postpage_contents'] == "")
{
$this->ipsclass->vars['postpage_contents'] = '5,10,15,20,25,30,35,40';
}
if ($this->ipsclass->vars['topicpage_contents'] == "")
{
$this->ipsclass->vars['topicpage_contents'] = '5,10,15,20,25,30,35,40';
}
$this->ipsclass->vars['postpage_contents'] .= ",-1,";
$this->ipsclass->vars['topicpage_contents'] .= ",-1,";
//-----------------------------------------
// Post page
//-----------------------------------------
if (! preg_match( "/(^|,)".$this->ipsclass->input['postpage'].",/", $this->ipsclass->vars['postpage_contents'] ) )
{
$this->ipsclass->input['postpage'] = '-1';
}
//-----------------------------------------
// Topic page
//-----------------------------------------
if (! preg_match( "/(^|,)".$this->ipsclass->input['topicpage'].",/", $this->ipsclass->vars['topicpage_contents'] ) )
{
$this->ipsclass->input['topicpage'] = '-1';
}
//-----------------------------------------
// RTE
//-----------------------------------------
if ( ! $this->ipsclass->vars['posting_allow_rte'] )
{
$this->ipsclass->input['editor_choice'] = 'std';
}
//-----------------------------------------
// PMS (Childish? Yes. Funny? No)
// 2 means admin says no. :o
//-----------------------------------------
if ( $this->ipsclass->member['members_disable_pm'] == 2 )
{
$this->ipsclass->member['members_disable_pm'] = 2;
}
else
{
$this->ipsclass->member['members_disable_pm'] = intval( $this->ipsclass->input['disable_messenger'] );
}
$this->ipsclass->DB->do_update( 'members', array ( 'time_offset' => $this->ipsclass->input['u_timezone'],
'view_avs' => intval($this->ipsclass->input['VIEW_AVS']),
'view_sigs' => intval($this->ipsclass->input['VIEW_SIGS']),
'view_img' => intval($this->ipsclass->input['VIEW_IMG']),
'view_pop' => intval($this->ipsclass->input['DO_POPUP']),
'dst_in_use' => intval($this->ipsclass->input['DST']),
'members_auto_dst' => intval($this->ipsclass->input['DSTCHECK']),
'members_disable_pm' => intval( $this->ipsclass->member['members_disable_pm'] ),
'members_editor_choice' => substr( $this->ipsclass->input['editor_choice'], 0, 3 ),
'view_prefs' => $this->ipsclass->input['postpage']."&".$this->ipsclass->input['topicpage'],
) , 'id='.$this->ipsclass->member['id'] );
if ($this->ipsclass->input['OPEN_QR'] == 1)
{
$this->ipsclass->my_setcookie('open_qr', '1');
}
else
{
$this->ipsclass->my_setcookie('open_qr', '0');
}
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['set_updated'], "act=UserCP&CODE=04" );
}
/*-------------------------------------------------------------------------*/
// Complete email settings
/*-------------------------------------------------------------------------*/
function do_email_settings()
{
if ($_POST['act'] == "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//-----------------------------------------
// Nawty, Nawty!
//-----------------------------------------
if ($this->ipsclass->input['auth_key'] != $this->class->md5_check )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post') );
}
//-----------------------------------------
// Check and set the rest of the info
//-----------------------------------------
foreach ( array('hide_email', 'admin_send', 'send_full_msg', 'pm_reminder', 'auto_track') as $v )
{
$this->ipsclass->input[ $v ] = $this->ipsclass->is_number( $this->ipsclass->input[ $v ] );
if ( $this->ipsclass->input[ $v ] < 1 )
{
$this->ipsclass->input[ $v ] = 0;
}
}
//-----------------------------------------
// Type of track
//-----------------------------------------
if ( $this->ipsclass->input['auto_track'] )
{
$allowed = array( 'none', 'immediate', 'delayed', 'daily', 'weekly' );
if ( in_array( $this->ipsclass->input['trackchoice'], $allowed ) )
{
$this->ipsclass->input['auto_track'] = $this->ipsclass->input['trackchoice'];
}
}
$this->ipsclass->DB->do_update( 'members', array ( 'hide_email' => $this->ipsclass->input['hide_email'],
'email_full' => $this->ipsclass->input['send_full_msg'],
'email_pm' => $this->ipsclass->input['pm_reminder'],
'allow_admin_mails' => $this->ipsclass->input['admin_send'],
'auto_track' => $this->ipsclass->input['auto_track'],
) ,'id='.$this->ipsclass->member['id'] );
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['email_c_up'], "act=UserCP&CODE=02" );
}
/*-------------------------------------------------------------------------*/
// Set gallery avatar
/*-------------------------------------------------------------------------*/
function set_internal_avatar()
{
if ($_POST['act'] == "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//-----------------------------------------
// Nawty, Nawty!
//-----------------------------------------
if ($this->ipsclass->input['auth_key'] != $this->class->md5_check )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post') );
}
//-----------------------------------------
$real_choice = 'noavatar';
$real_dims = '';
$real_dir = "";
$save_dir = "";
//-----------------------------------------
// Check incoming..
//-----------------------------------------
$current_folder = preg_replace( "/[^\s\w_-]/" , "", urldecode($this->ipsclass->input['current_folder']) );
$selected_avatar = preg_replace( "/[^\s\w\._\-\[\]\(\)]/" , "", urldecode($this->ipsclass->input['avatar']) );
//-----------------------------------------
// Are we in a folder?
//-----------------------------------------
if ($current_folder == 'root')
{
$current_folder = "";
}
if ($current_folder != "")
{
$real_dir = "/".$current_folder;
$save_dir = $current_folder."/";
}
//-----------------------------------------
// Check it out!
//-----------------------------------------
$avatar_gallery = array();
$dh = opendir( CACHE_PATH.'style_avatars'.$real_dir );
while ( $file = readdir( $dh ) )
{
if ( !preg_match( "/^..?$|^index/i", $file ) )
{
$avatar_gallery[] = $file;
}
}
closedir( $dh );
if (!in_array( $selected_avatar, $avatar_gallery ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_avatar_selected' ) );
}
$final_string = $save_dir.$selected_avatar;
// Update the DB
$this->ipsclass->DB->do_update( 'member_extra', array( 'avatar_location' => $final_string, 'avatar_type' => 'local' ), 'id='.$this->ipsclass->member['id'] );
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['av_c_up'], "act=UserCP&CODE=24" );
}
/*-------------------------------------------------------------------------*/
// Save avatar
/*-------------------------------------------------------------------------*/
function do_avatar()
{
//-----------------------------------------
// Got attachment types?
//-----------------------------------------
if ( ! is_array( $this->ipsclass->cache['attachtypes'] ) )
{
$this->ipsclass->cache['attachtypes'] = array();
$this->ipsclass->DB->simple_construct( array( 'select' => 'atype_extension,atype_mimetype,atype_post,atype_photo,atype_img', 'from' => 'attachments_type', 'where' => "atype_photo=1 OR atype_post=1" ) );
$this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
$this->ipsclass->cache['attachtypes'][ $r['atype_extension'] ] = $r;
}
}
$real_type = "";
if ($_POST['act'] == "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//-----------------------------------------
// Nawty, Nawty!
//-----------------------------------------
if ($this->ipsclass->input['auth_key'] != $this->class->md5_check )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post') );
}
//-----------------------------------------
// Did we press "remove"?
//-----------------------------------------
if ( $this->ipsclass->input['remove'] )
{
$this->bash_uploaded_avatars($this->ipsclass->member['id']);
$this->ipsclass->DB->do_update( 'member_extra', array( 'avatar_location' => '',
'avatar_size' => '',
'avatar_type' => '',
), 'id='.$this->ipsclass->member['id'] );
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['av_c_up'], "act=UserCP&CODE=24" );
}
//-----------------------------------------
// NO? CARRY ON!!
//-----------------------------------------
list($p_width, $p_height) = explode( "x", $this->ipsclass->vars['avatar_dims'] );
//-----------------------------------------
// Check to make sure we don't just have
// http:// in the URL box..
//-----------------------------------------
if ( preg_match( "/^http:\/\/$/i", $this->ipsclass->input['url_avatar'] ) )
{
$this->ipsclass->input['url_avatar'] = "";
}
if ( preg_match( "#javascript:#is", $this->ipsclass->input['url_avatar'] ) )
{
$this->ipsclass->input['url_avatar'] = "";
}
if ( $this->ipsclass->xss_check_url( $this->ipsclass->input['url_avatar'] ) !== TRUE )
{
$this->ipsclass->input['url_avatar'] = '';
}
if ( empty($this->ipsclass->input['url_avatar']) )
{
//-----------------------------------------
// Lets check for an uploaded photo..
//-----------------------------------------
if ($_FILES['upload_avatar']['name'] != "" and ($_FILES['upload_avatar']['name'] != "none") )
{
//-----------------------------------------
// Are we allowed to upload this avatar?
//-----------------------------------------
if ( preg_match( "#javascript:#is", $_FILES['upload_avatar']['name'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_upload' ) );
}
if ( ($this->ipsclass->member['g_avatar_upload'] != 1) or ($this->ipsclass->vars['avup_size_max'] < 1) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_upload' ) );
}
//-----------------------------------------
// Remove any uploaded avatars..
//-----------------------------------------
$this->bash_uploaded_avatars($this->ipsclass->member['id']);
$real_name = 'av-'.$this->ipsclass->member['id'];
$real_type = 'upload';
//-----------------------------------------
// Load the library
//-----------------------------------------
require_once( KERNEL_PATH.'class_upload.php' );
$upload = new class_upload();
//-----------------------------------------
// Set up the variables
//-----------------------------------------
$upload->out_file_name = 'av-'.$this->ipsclass->member['id'];
$upload->out_file_dir = $this->ipsclass->vars['upload_dir'];
$upload->max_file_size = ($this->ipsclass->vars['avup_size_max'] * 1024) * 8; // Allow xtra for compression
$upload->upload_form_field = 'upload_avatar';
//-----------------------------------------
// Populate allowed extensions
//-----------------------------------------
if ( is_array( $this->ipsclass->cache['attachtypes'] ) and count( $this->ipsclass->cache['attachtypes'] ) )
{
foreach( $this->ipsclass->cache['attachtypes'] as $idx => $data )
{
if ( $data['atype_photo'] )
{
$upload->allowed_file_ext[] = $data['atype_extension'];
}
}
}
//-----------------------------------------
// Upload...
//-----------------------------------------
$upload->upload_process();
//-----------------------------------------
// Error?
//-----------------------------------------
if ( $upload->error_no )
{
//-----------------------------------------
// Remove it 'cos there's a problem
//-----------------------------------------
$this->ipsclass->DB->do_update( 'member_extra', array( 'avatar_location' => '', 'avatar_size' => '', 'avatar_type' => '' ), 'id='.$this->ipsclass->member['id'] );
switch( $upload->error_no )
{
case 1:
// No upload
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_failed' ) );
case 2:
// Invalid file ext
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_type' ) );
case 3:
// Too big...
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_to_big') );
case 4:
// Cannot move uploaded file
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_failed' ) );
case 5:
// Possible XSS attack (image isn't an image)
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_failed' ) );
}
}
if ( ( $upload->file_extension == 'swf' ) AND ($this->ipsclass->vars['allow_flash'] != 1) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_flash_av' ) );
}
//-----------------------------------------
// Still here?
//-----------------------------------------
$real_name = $upload->parsed_file_name;
if ( ! $this->ipsclass->vars['disable_ipbsize'] and $upload->file_extension != '.swf' )
{
$this->image->in_type = 'file';
$this->image->out_type = 'file';
$this->image->in_file_dir = $this->ipsclass->vars['upload_dir'];
$this->image->in_file_name = $real_name;
$this->image->out_file_name = 'avs-'.$this->ipsclass->member['id'];
$this->image->desired_width = $p_width;
$this->image->desired_height = $p_height;
$return = $this->image->generate_thumbnail();
$im['img_width'] = $return['thumb_width'];
$im['img_height'] = $return['thumb_height'];
//-----------------------------------------
// Do we have an attachment?
//-----------------------------------------
if ( strstr( $return['thumb_location'], 'avs-' ) )
{
//-----------------------------------------
// Kill old and rename new...
//-----------------------------------------
@unlink( $this->ipsclass->vars['upload_dir']."/".$real_name );
$real_name = 'av-'.$this->ipsclass->member['id'].'.'.$this->image->file_extension;
@rename( $this->ipsclass->vars['upload_dir']."/".$return['thumb_location'], $this->ipsclass->vars['upload_dir']."/".$real_name );
@chmod( $this->ipsclass->vars['upload_dir']."/".$real_name, 0777 );
}
}
else
{
$w = intval($this->ipsclass->input['man_width']) ? intval($this->ipsclass->input['man_width']) : $p_width;
$h = intval($this->ipsclass->input['man_height']) ? intval($this->ipsclass->input['man_height']) : $p_height;
$im['img_width'] = $w > $p_width ? $p_width : $w;
$im['img_height'] = $h > $p_height ? $p_height : $h;
}
//-----------------------------------------
// Check the file size (after compression)
//-----------------------------------------
if ( filesize( $this->ipsclass->vars['upload_dir']."/".$real_name ) > ($this->ipsclass->vars['avup_size_max']*1024))
{
@unlink( $this->ipsclass->vars['upload_dir']."/".$real_name );
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_to_big' ) );
}
//-----------------------------------------
// Set the "real" avatar..
//-----------------------------------------
$real_choice = $real_name;
$real_dims = $im['img_width'].'x'.$im['img_height'];
}
else
{
//-----------------------------------------
// URL field and upload field left blank.
//-----------------------------------------
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_avatar_selected' ) );
}
}
else
{
//-----------------------------------------
// It's an entered URL 'ting man
//-----------------------------------------
$this->ipsclass->input['url_avatar'] = trim($this->ipsclass->input['url_avatar']);
if ( empty($this->ipsclass->vars['allow_dynamic_img']) )
{
if ( preg_match( "/[?&;]/", $this->ipsclass->input['url_avatar'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'avatar_invalid_url' ) );
}
}
//-----------------------------------------
// Check extension
//-----------------------------------------
$ext = explode ( ",", $this->ipsclass->vars['avatar_ext'] );
$checked = 0;
$av_ext = preg_replace( "/^.*\.(\S+)$/", "\\1", $this->ipsclass->input['url_avatar'] );
foreach ($ext as $v )
{
if (strtolower($v) == strtolower($av_ext))
{
if ( ( $v == 'swf' ) AND ($this->ipsclass->vars['allow_flash'] != 1) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_flash_av' ) );
}
$checked = 1;
}
}
if ($checked != 1)
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'avatar_invalid_ext' ) );
}
//-----------------------------------------
// Check image size...
//-----------------------------------------
$im = array();
if ( ! $this->ipsclass->vars['disable_ipbsize'] )
{
if ( ! $img_size = @GetImageSize( $this->ipsclass->input['url_avatar'] ) )
{
$img_size[0] = $p_width;
$img_size[1] = $p_height;
}
$im = $this->ipsclass->scale_image( array(
'max_width' => $p_width,
'max_height' => $p_height,
'cur_width' => $img_size[0],
'cur_height' => $img_size[1]
) );
}
else
{
$w = intval($this->ipsclass->input['man_width']) ? intval($this->ipsclass->input['man_width']) : $p_width;
$h = intval($this->ipsclass->input['man_height']) ? intval($this->ipsclass->input['man_height']) : $p_height;
$im['img_width'] = $w > $p_width ? $p_width : $w;
$im['img_height'] = $h > $p_height ? $p_height : $h;
}
//-----------------------------------------
// Remove any uploaded images..
//-----------------------------------------
$this->bash_uploaded_avatars($this->ipsclass->member['id']);
$real_choice = $this->ipsclass->input['url_avatar'];
$real_dims = $im['img_width'].'x'.$im['img_height'];
$real_type = 'url';
}
//-----------------------------------------
// Update the DB
//-----------------------------------------
$this->ipsclass->DB->do_update( 'member_extra', array( 'avatar_location' => $real_choice, 'avatar_size' => $real_dims, 'avatar_type' => $real_type ), 'id='.$this->ipsclass->member['id'] );
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['av_c_up'], "act=UserCP&CODE=24" );
}
function do_profile()
{
//-----------------------------------------
// Check for bad entry
//-----------------------------------------
if ($_POST['act'] == "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//-----------------------------------------
// Nawty, Nawty!
//-----------------------------------------
if ($this->ipsclass->input['auth_key'] != $this->class->md5_check )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post') );
}
//-----------------------------------------
// Custom profile field stuff
//-----------------------------------------
require_once( ROOT_PATH.'sources/classes/class_custom_fields.php' );
$fields = new custom_fields( $this->ipsclass->DB );
$fields->member_id = $this->ipsclass->member['id'];
$fields->mem_data_id = $this->ipsclass->member['id'];
$fields->cache_data = $this->ipsclass->cache['profilefields'];
$fields->admin = intval($this->ipsclass->member['g_access_cp']);
$fields->supmod = intval($this->ipsclass->member['g_is_supmod']);
$fields->init_data();
$fields->parse_to_save();
//-----------------------------------------
// Check...
//-----------------------------------------
if ( count( $fields->error_fields['empty'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form', 'EXTRA' => $fields->error_fields['empty'][0]['pf_title'] ) );
}
if ( count( $fields->error_fields['invalid'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form', 'EXTRA' => $fields->error_fields['invalid'][0]['pf_title'] ) );
}
if ( count( $fields->error_fields['toobig'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cf_to_long', 'EXTRA' => $fields->error_fields['toobig'][0]['pf_title'] ) );
}
//-----------------------------------------
if ( (strlen($_POST['Interests']) > $this->ipsclass->vars['max_interest_length']) and ($this->ipsclass->vars['max_interest_length']) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'int_too_long' ) );
}
//-----------------------------------------
if ( (strlen($_POST['Location']) > $this->ipsclass->vars['max_location_length']) and ($this->ipsclass->vars['max_location_length']) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'loc_too_long' ) );
}
//-----------------------------------------
if (strlen($_POST['WebSite']) > 150)
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'web_too_long' ) );
}
//-----------------------------------------
if (strlen($_POST['Photo']) > 150)
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'photo_too_long' ) );
}
//-----------------------------------------
if ( ($_POST['ICQNumber']) && ( ! preg_match( "/^[\d\-]+$/", $_POST['ICQNumber'] ) ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'not_icq_number' ) );
}
//-----------------------------------------
// make sure that either we entered
// all calendar fields, or we left them
// all blank
//-----------------------------------------
$c_cnt = 0;
foreach ( array('day','month','year') as $v )
{
if (!empty($this->ipsclass->input[$v]))
{
$c_cnt++;
}
}
if ( ($c_cnt > 0) and ($c_cnt != 3) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'calendar_not_all' ) );
}
if ( ! preg_match( "#^http://#", $this->ipsclass->input['WebSite'] ) )
{
$this->ipsclass->input['WebSite'] = 'http://'.$this->ipsclass->input['WebSite'];
}
//-----------------------------------------
// Start off our array
//-----------------------------------------
$set = array(
'bday_day' => $this->ipsclass->input['day'],
'bday_month' => $this->ipsclass->input['month'],
'bday_year' => $this->ipsclass->input['year'],
);
$bet = array( 'website' => $this->ipsclass->input['WebSite'],
'icq_number' => $this->ipsclass->input['ICQNumber'],
'aim_name' => $this->ipsclass->input['AOLName'],
'yahoo' => $this->ipsclass->input['YahooName'],
'msnname' => $this->ipsclass->input['MSNName'],
'location' => $this->ipsclass->input['Location'],
'interests' => $this->ipsclass->input['Interests'],
);
//-----------------------------------------
// check to see if we can enter a member title
// and if one is entered, update it.
//-----------------------------------------
if ( (isset($this->ipsclass->input['member_title'])) and ( isset($this->ipsclass->vars['post_titlechange']) ) and ( $this->ipsclass->member['posts'] >= $this->ipsclass->vars['post_titlechange']) )
{
$set['title'] = $this->ipsclass->input['member_title'];
}
//-----------------------------------------
// Update the DB
//-----------------------------------------
$this->ipsclass->DB->force_data_type = array( 'title' => 'string' );
$this->ipsclass->DB->do_update( 'members' , $set, 'id='.$this->ipsclass->member['id'] );
$this->ipsclass->DB->force_data_type = array( 'icq_number' => 'string' );
$this->ipsclass->DB->do_update( 'member_extra', $bet, 'id='.$this->ipsclass->member['id'] );
//-----------------------------------------
// Save the profile stuffy wuffy
//-----------------------------------------
if ( count( $fields->out_fields ) )
{
//-----------------------------------------
// Do we already have an entry in
// the content table?
//-----------------------------------------
$test = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'member_id', 'from' => 'pfields_content', 'where' => 'member_id='.$this->ipsclass->member['id'] ) );
if ( $test['member_id'] )
{
//-----------------------------------------
// We have it, so simply update
//-----------------------------------------
$this->ipsclass->DB->do_update( 'pfields_content', $fields->out_fields, 'member_id='.$this->ipsclass->member['id'] );
}
else
{
$fields->out_fields['member_id'] = $this->ipsclass->member['id'];
$this->ipsclass->DB->do_insert( 'pfields_content', $fields->out_fields );
}
}
//-----------------------------------------
// Use sync module?
//-----------------------------------------
if ( USE_MODULES == 1 )
{
$bet['id'] = $this->ipsclass->member['id'];
$bet['name'] = $this->ipsclass->member['members_display_name'];
$this->class->modules->register_class($this);
$this->class->modules->on_profile_update($bet, $custom_fields);
}
// Return us!
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['profile_edited'], "act=UserCP&CODE=01" );
}
/*-------------------------------------------------------------------------*/
// SIGNATURE: SAVE
/*-------------------------------------------------------------------------*/
function do_signature()
{
//-----------------------------------------
// Check length
//-----------------------------------------
if ( (strlen($_POST['Post']) > $this->ipsclass->vars['max_sig_length']) and ($this->ipsclass->vars['max_sig_length']) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'sig_too_long' ) );
}
//-----------------------------------------
// Check key
//-----------------------------------------
if ( $_POST['key'] != $this->ipsclass->return_md5_check() )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'del_post' ) );
}
//-----------------------------------------
// Remove board tags
//-----------------------------------------
$this->ipsclass->input['Post'] = $this->ipsclass->remove_tags( $this->ipsclass->input['Post'] );
//-----------------------------------------
// Post process the editor
// Now we have safe HTML and bbcode
//-----------------------------------------
$this->ipsclass->input['Post'] = $this->class->han_editor->process_raw_post( 'Post' );
//-----------------------------------------
// Parse post
//-----------------------------------------
$this->class->parser->parse_smilies = 0;
$this->class->parser->parse_html = intval($this->ipsclass->vars['sig_allow_html']);
$this->class->parser->parse_bbcode = intval($this->ipsclass->vars['sig_allow_ibc']);
$this->ipsclass->input['Post'] = $this->class->parser->pre_db_parse( $this->ipsclass->input['Post'] );
if ($this->class->parser->error != "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => $this->class->parser->error) );
}
//-----------------------------------------
// Write it to the DB.
//-----------------------------------------
if ( $mem = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'id', 'from' => 'member_extra', 'where' => 'id='.$this->ipsclass->member['id'] ) ) )
{
$this->ipsclass->DB->do_update( 'member_extra', array( 'signature' => $this->ipsclass->input['Post'] ), 'id='.$this->ipsclass->member['id'] );
}
else
{
$this->ipsclass->DB->do_insert( 'member_extra', array( 'id' => $this->ipsclass->member['id'], 'signature' => $this->ipsclass->input['Post'] ) );
}
//-----------------------------------------
// Member sync?
//-----------------------------------------
if ( USE_MODULES == 1 )
{
$this->class->modules->register_class($this);
$this->class->modules->on_signature_update($this->ipsclass->member, $this->ipsclass->input['Post']);
}
//-----------------------------------------
// Buh BYE:
//-----------------------------------------
$this->ipsclass->boink_it($this->ipsclass->base_url."act=UserCP&CODE=22");
}
/*-------------------------------------------------------------------------*/
// ADD IGNORE USERS
/*-------------------------------------------------------------------------*/
function ignore_user_add()
{
$temp_users = array();
//-----------------------------------------
// Stored as userid,userid,userid
//-----------------------------------------
$ignored_users = explode( ',', $this->ipsclass->member['ignored_users'] );
foreach( $ignored_users as $id )
{
if ( intval($id) )
{
$temp_users[] = $id;
}
}
$final_string = ",".implode( ',', $temp_users ).",";
$final_string = preg_replace( "/,{2,}/", ",", str_replace( " ", "", $final_string ) );
$lookup_meh_pants = array();
if ( $this->ipsclass->input['newbox_1'] )
{
$lookup_meh_pants[] = "'".strtolower(str_replace( '|', '&#124;', $this->ipsclass->input['newbox_1']))."'";
}
if ( $this->ipsclass->input['newbox_2'] )
{
$lookup_meh_pants[] = "'".strtolower(str_replace( '|', '&#124;', $this->ipsclass->input['newbox_2']))."'";
}
if ( $this->ipsclass->input['newbox_3'] )
{
$lookup_meh_pants[] = "'".strtolower(str_replace( '|', '&#124;', $this->ipsclass->input['newbox_3']))."'";
}
if ( count($lookup_meh_pants) )
{
//-----------------------------------------
// See if we have any MEMBRES IN THE DB
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, name, mgroup', 'from' => 'members', 'where' => "LOWER(members_display_name) IN (".implode(",", $lookup_meh_pants ).")" ) );
$this->ipsclass->DB->simple_exec();
while( $s = $this->ipsclass->DB->fetch_row() )
{
if ( strstr( $this->ipsclass->vars['cannot_ignore_groups'], ','.$s['mgroup'].',' ) )
{
continue;
}
if ( strstr( $final_string, ','.$s['id'].',') )
{
continue;
}
if ( $s['id'] != $this->ipsclass->member['id'] )
{
$members[ $s['name'] ] = $s['id'];
}
}
if ( count($members ) )
{
foreach( $members as $name => $id )
{
foreach( array( 1,2,3 ) as $hehe )
{
if ( strtolower($name) == strtolower($this->ipsclass->input[ 'newbox_'.$hehe ]) )
{
$this->ipsclass->input[ 'newbox_'.$hehe ] = "";
}
}
$final_string .= $id.",";
}
$this->ipsclass->DB->do_update( 'members', array( 'ignored_users' => $final_string ), 'id='.$this->ipsclass->member['id'] );
}
$cant_find = array();
foreach( array( 1,2,3 ) as $hehe )
{
if ( $this->ipsclass->input[ 'newbox_'.$hehe ] != "" )
{
$cant_find[] = $this->ipsclass->input[ 'newbox_'.$hehe ];
}
}
if ( count($cant_find) )
{
$this->ipsclass->member['ignored_users'] = $final_string;
$this->class->ignore_user_splash( sprintf( $this->ipsclass->lang['mi5_cantfind'], implode( ",", $cant_find ) ) );
return;
}
}
$this->ipsclass->member['ignored_users'] = $final_string;
$this->class->ignore_user_splash();
return;
}
function ignore_user_remove()
{
$temp_users = array();
//-----------------------------------------
// Stored as userid,userid,userid
//-----------------------------------------
$ignored_users = explode( ',', $this->ipsclass->member['ignored_users'] );
foreach( $ignored_users as $id )
{
if ( intval($id) and ( $id != $this->ipsclass->input['id'] ) )
{
$temp_users[] = $id;
}
}
$final_string = ",".implode( ',', $temp_users ).",";
$final_string = preg_replace( "/,{2,}/", ",", str_replace( " ", "", $final_string ) );
$this->ipsclass->DB->do_update( 'members', array( 'ignored_users' => $final_string ), 'id='.$this->ipsclass->member['id'] );
$this->ipsclass->member['ignored_users'] = $final_string;
$this->class->ignore_user_splash();
return true;
}
}
?>