📄 usercp_functions.php
字号:
<?php
class usercp_functions
{
var $class;
function usercp_functions( $class )
{
$this->class = $class;
}
function do_skin_langs( )
{
global $ibforums;
global $DB;
global $std;
global $print;
global $HTTP_POST_VARS;
if ( $HTTP_POST_VARS['act'] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "complete_form" ) );
}
if ( preg_match( "/\\.\\./", $ibforums->input['u_skin'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "poss_hack_attempt" ) );
}
if ( preg_match( "/\\.\\./", $ibforums->input['u_language'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "poss_hack_attempt" ) );
}
if ( $ibforums->vars['allow_skins'] == 1 )
{
$DB->query( "SELECT sid FROM ibf_skins WHERE hidden <> 1 AND sid='".$ibforums->input['u_skin']."'" );
if ( !$DB->get_num_rows( ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "skin_not_found" ) );
}
$db_string = $DB->compile_db_update_string( array(
"language" => $ibforums->input['u_language'],
"skin " => $ibforums->input['u_skin']
) );
}
else
{
$db_string = $DB->compile_db_update_string( array(
"language" => $ibforums->input['u_language']
) );
}
$DB->query( "UPDATE ibf_members SET {$db_string} WHERE id='".$this->class->member['id']."'" );
$print->redirect_screen( $ibforums->lang['set_updated'], "act=UserCP&CODE=06" );
}
function do_board_prefs( )
{
global $ibforums;
global $DB;
global $std;
global $print;
global $HTTP_POST_VARS;
if ( $HTTP_POST_VARS['act'] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "complete_form" ) );
}
if ( !preg_match( "/^[\\-\\d\\.]+\$/", $ibforums->input['u_timezone'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "poss_hack_attempt" ) );
}
if ( !preg_match( "/^\\d+\$/", $ibforums->input['VIEW_IMG'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "poss_hack_attempt" ) );
}
if ( !preg_match( "/^\\d+\$/", $ibforums->input['VIEW_SIGS'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "poss_hack_attempt" ) );
}
if ( !preg_match( "/^\\d+\$/", $ibforums->input['VIEW_AVS'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "poss_hack_attempt" ) );
}
if ( !preg_match( "/^\\d+\$/", $ibforums->input['DO_POPUP'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "poss_hack_attempt" ) );
}
if ( !preg_match( "/^\\d+\$/", $ibforums->input['HIDE_SESS'] ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "poss_hack_attempt" ) );
}
if ( $ibforums->vars['postpage_contents'] == "" )
{
$ibforums->vars['postpage_contents'] = "5,10,15,20,25,30,35,40";
}
if ( $ibforums->vars['topicpage_contents'] == "" )
{
$ibforums->vars['topicpage_contents'] = "5,10,15,20,25,30,35,40";
}
$ibforums->vars['postpage_contents'] .= ",-1,";
$ibforums->vars['topicpage_contents'] .= ",-1,";
if ( !preg_match( "/(^|,)".$ibforums->input['postpage'].",/", $ibforums->vars['postpage_contents'] ) )
{
$ibforums->input['postpage'] = "-1";
}
if ( !preg_match( "/(^|,)".$ibforums->input['topicpage'].",/", $ibforums->vars['topicpage_contents'] ) )
{
$ibforums->input['topicpage'] = "-1";
}
$db_string = $DB->compile_db_update_string( array(
"time_offset" => $ibforums->input['u_timezone'],
"view_avs" => $ibforums->input['VIEW_AVS'],
"view_sigs" => $ibforums->input['VIEW_SIGS'],
"view_img" => $ibforums->input['VIEW_IMG'],
"view_pop" => $ibforums->input['DO_POPUP'],
"dst_in_use" => $ibforums->input['DST'],
"view_prefs" => $ibforums->input['postpage']."&".$ibforums->input['topicpage']
) );
$DB->query( "UPDATE ibf_members SET {$db_string} WHERE id='".$this->class->member['id']."'" );
if ( $ibforums->input['HIDE_SESS'] == 1 )
{
$std->my_setcookie( "hide_sess", "1" );
}
else
{
$std->my_setcookie( "hide_sess", "0" );
}
$print->redirect_screen( $ibforums->lang['set_updated'], "act=UserCP&CODE=04" );
}
function do_email_settings( )
{
global $ibforums;
global $DB;
global $std;
global $print;
global $HTTP_POST_VARS;
if ( $HTTP_POST_VARS['act'] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "complete_form" ) );
}
foreach ( array( "hide_email", "admin_send", "send_full_msg", "pm_reminder", "auto_track" ) as $v )
{
$ibforums->input[$v] = $std->is_number( $ibforums->input[$v] );
if ( $ibforums->input[$v] < 1 )
{
$ibforums->input[$v] = 0;
}
}
$db_string = $DB->compile_db_update_string( array(
"hide_email" => $ibforums->input['hide_email'],
"email_full" => $ibforums->input['send_full_msg'],
"email_pm" => $ibforums->input['pm_reminder'],
"allow_admin_mails" => $ibforums->input['admin_send'],
"auto_track" => $ibforums->input['auto_track']
) );
$DB->query( "UPDATE ibf_members SET {$db_string} WHERE id='".$this->class->member['id']."'" );
$print->redirect_screen( "Email Settings updated", "act=UserCP&CODE=02" );
}
function do_avatar( )
{
global $ibforums;
global $DB;
global $std;
global $print;
global $HTTP_POST_VARS;
global $HTTP_POST_FILES;
global $FILE_UPLOAD;
if ( $HTTP_POST_VARS['act'] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "complete_form" ) );
}
$real_choice = "noavatar";
$real_dims = "";
if ( $ibforums->input['choice'] == "gallery" )
{
$avatar_gallery = array( );
if ( preg_match( "/^(\\S+?)\\|(\\S+?)\$/", $HTTP_POST_VARS['gallery_list'] ) )
{
$gallery_hack = explode( "|", $HTTP_POST_VARS['gallery_list'] );
$gallery_dir_a = "/".$gallery_hack[0];
$gallery_dir_b = $gallery_hack[0]."/";
$HTTP_POST_VARS['gallery_list'] = rawurldecode( $gallery_hack[1] );
$ibforums->input['gallery_list'] = rawurldecode( $gallery_hack[1] );
}
else
{
$gallery_dir_a = "";
$gallery_dir_b = "";
}
$dh = opendir( $ibforums->vars['html_dir']."avatars".$gallery_dir_a );
while ( $file = readdir( $dh ) )
{
if ( !preg_match( "/^..?\$|^index/i", $file ) )
{
$avatar_gallery[] = $file;
}
}
closedir( $dh );
if ( !in_array( $HTTP_POST_VARS['gallery_list'], $avatar_gallery ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_avatar_selected" ) );
}
if ( preg_match( "/^upload:/", $this->class->member['avatar'] ) )
{
$remove_file = preg_replace( "/^upload:/", "", $this->class->member['avatar'] );
@unlink( $ibforums->vars['upload_dir']."/".$remove_file );
}
$real_choice = $gallery_dir_b.$ibforums->input['gallery_list'];
}
else
{
if ( $ibforums->input['choice'] == "url" )
{
if ( preg_match( "/^http:\\/\\/\$/i", $ibforums->input['url_avatar'] ) )
{
$ibforums->input['url_avatar'] = "";
}
if ( empty( $ibforums->input['url_avatar'] ) )
{
if ( $HTTP_POST_FILES['FILE_UPLOAD']['name'] != "" && $HTTP_POST_FILES['FILE_UPLOAD']['name'] != "none" )
{
$FILE_NAME = $HTTP_POST_FILES['FILE_UPLOAD']['name'];
$FILE_SIZE = $HTTP_POST_FILES['FILE_UPLOAD']['size'];
$FILE_TYPE = $HTTP_POST_FILES['FILE_UPLOAD']['type'];
if ( $HTTP_POST_FILES['FILE_UPLOAD']['name'] == "" )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_av_name" ) );
}
$FILE_TYPE = preg_replace( "/^(.+?);.*\$/", "\\1", $FILE_TYPE );
if ( $ibforums->member['g_avatar_upload'] != 1 || $ibforums->vars['avup_size_max'] < 1 )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_av_upload" ) );
}
require( "./conf_mime_types.php" );
if ( $mime_types[$FILE_TYPE][3] != 1 )
{
$std->error( array( "LEVEL" => 1, "MSG" => "no_av_type" ) );
}
if ( $ibforums->vars['avup_size_max'] * 1024 < $FILE_SIZE )
{
$std->error( array( "LEVEL" => 1, "MSG" => "upload_to_big" ) );
}
$ext = ".gif";
switch ( $FILE_TYPE )
{
case "image/gif" :
$ext = ".gif";
break;
case "image/jpeg" :
$ext = ".jpg";
break;
case "image/pjpeg" :
$ext = ".jpg";
break;
case "image/x-png" :
$ext = ".png";
break;
default :
$ext = ".gif";
break;
}
$real_name = "av-".$this->class->member['id'].$ext;
if ( !move_uploaded_file( $HTTP_POST_FILES['FILE_UPLOAD']['tmp_name'], $ibforums->vars['upload_dir']."/".$real_name ) )
{
$std->error( array( "LEVEL" => 1, "MSG" => "upload_failed" ) );
}
if ( preg_match( "/^upload:/", $this->class->member['avatar'] ) )
{
$remove_file = preg_replace( "/^upload:/", "", $this->class->member['avatar'] );
if ( $remove_file != $real_name )
{
@unlink( $ibforums->vars['upload_dir']."/".$remove_file );
}
}
$real_choice = "upload:".$real_name;
$w = $ibforums->input['Avatar_width'];
$h = $ibforums->input['Avatar_height'];
list( $aw, $ah ) = explode( "x", $ibforums->vars['avatar_dims'] );
if ( !$w || $w == "" || !$h || $h == "" )
{
$this_dims = @getimagesize( $ibforums->vars['upload_url']."/".$real_name );
if ( $aw < $this_dims[0] || $ah < $this_dims[1] )
{
if ( $this_dims[1] < $this_dims[0] )
{
$multiplier = $aw / $this_dims[0];
$this_dims[0] = $aw;
$this_dims[1] = ceil( $this_dims[1] * $multiplier );
$w = $this_dims[0];
$h = $this_dims[1];
}
else if ( $this_dims[0] < $this_dims[1] )
{
$multiplier = $ah / $this_dims[1];
$this_dims[0] = ceil( $this_dims[0] * $multiplier );
$this_dims[1] = $ah;
$w = $this_dims[0];
$h = $this_dims[1];
}
else
{
$w = $aw;
$h = $ah;
}
}
else if ( !$this_dims[0] || $this_dims[0] == "" || !$this_dims[1] || $this_dims[1] == "" )
{
$w = $aw;
$h = $ah;
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -