找到 /phpsso_server/phpcms/modules/phpsso/index.php
/** *上传头像处理 *传入头像压缩包,解压到指定文件夹后删除非图片文件 */ public function uploadavatar() { //根据用户id创建文件夹 if(isset($this->data['uid']) && isset($this->data['avatardata'])) { $this->uid = intval($this->data['uid']); $this->avatardata = $this->data['avatardata']; }else{ exit('0'); } $dir1 = ceil($this->uid / 10000); $dir2 = ceil($this->uid % 10000 / 1000); //创建图片存储文件夹 $avatarfile = pc_base::load_config('system', 'upload_path').'avatar/'; $dir = $avatarfile.$dir1.'/'.$dir2.'/'.$this->uid.'/'; if(!file_exists($dir)) { mkdir($dir, 0777, true); } //存储flashpost图片 $filename = $dir.'80x80.jpg'; $fp = fopen($filename, 'w'); fwrite($fp, $this->avatardata); fclose($fp); $avatararr = array('80x80.jpg', '30x30.jpg', '50x50.jpg'); $files = glob($dir."*"); foreach($files as $_files) { if(is_dir($_files)) dir_delete($_files); if(!in_array(basename($_files), $avatararr)) @unlink($_files); } if($handle = opendir($dir)) { while(false !== ($file = readdir($handle))) { if($file !== '.' && $file !== '..') { if(!in_array($file, $avatararr)) { @unlink($dir.$file); }else{ $info = @getimagesize($dir.$file); if(!$info || $info[2] !=2) { @unlink($dir.$file); } } } } closedir($handle); } pc_base::load_sys_class('image','','0'); $image = new image(1,0); $image->thumb($filename, $dir.'30x30.jpg', 30, 30); $image->thumb($filename, $dir.'50x50.jpg', 50, 50); $this->db->update(array('avatar'=>1), array('uid'=>$this->uid)); exit('1'); }
找到phpcms/modules/member/classes/client.class.php
/** * 根据phpsso uid获取头像url * @param int $uid 用户id * @return array 四个尺寸用户头像数组 */ public function ps_getavatar($uid) { $dir1 = ceil($uid / 10000); $dir2 = ceil($uid % 10000 / 1000); $url = $this->ps_api_url.'/uploadfile/avatar/'.$dir1.'/'.$dir2.'/'.$uid.'/'; $avatar = array('80'=>$url.'80x80.jpg', '50'=>$url.'50x50.jpg', '30'=>$url.'30x30.jpg'); return $avatar; }
前台模板修改对应的{$avatar[80]}中的数字即可
- 前一篇: 第一页
- 后一篇: phpcmsx中让标签tag按照栏目catid进行筛选