func_usercp.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,800 行 · 第 1/4 页
PHP
1,800 行
$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! //-----------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?