func_usercp.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,800 行 · 第 1/4 页

PHP
1,800
字号
        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 ( 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;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?