ecshop设置会员头像
来源:互联网 发布:pptv网络电视直播 编辑:程序博客网 时间:2024/05/01 23:36
ecshop 会员头像################ 数据库 ################1、ecs_users 表加入 avatar 字段ALTER TABLE `ecs_users` ADD `avatar` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''################ 前端 ################2、themes\default\user_clips.dwt 用户中心默认显示页面 显示头像(新会员显示系统默认的头像)<!-- *用户中心默认显示页面 start--><!-- {if $action eq 'default'} --><style>.avtar .img a{display:none;width:72px;height:23px;background:url(images/change_avtar.gif);position:absolute;margin-left:44px;margin-top:93px}.avtar .hover a{display:block}.Left .img{border:1px solid #d0d0d0;margin-bottom:5px}.Left .img,.Left .img img{width:120px;height:120px}</style><div class="Left avtar" style="float:left;width:122px;text-align:center;"> <div onmouseout="this.className='img'" onmouseover="this.className='img hover'" class="img"> <a title="修改我的头像" href="user.php?act=profile" class="red"></a> <img src="{if $info.avatar}{$info.avatar}{else}images/avatar.gif{/if}"> </div></div>3、themes\default\user_transaction.dwt 用户信息修改页面<!-- 用户信息界面 start--><!--{if $action eq 'profile'}-->里面找到<form name="formEdit" action="user.php" method="post" onSubmit="return userEdit()">修改成<form name="formEdit" action="user.php" method="post" onSubmit="return userEdit()" enctype="multipart/form-data"><input type="hidden" name="MAX_FILE_SIZE" value="1097152" /><!-- 1M图片上传大小设置 -->再找到submit提交之前加入<tr> <td width="28%" align="right" bgcolor="#FFFFFF">会员头像:</td> <td width="72%" align="left" bgcolor="#FFFFFF"> <div style="width:50%;float:left;"> <input id="avatar" type="file" size="40" value="" name="avatar"> <br/> <span style="color:#FF0000"> 图片像素最佳为55px * 55px,<br/>大小不得超过1M</span> </div> <div style="width:50%;float:left;"> <img src="{if $profile.avatar}{$profile.avatar}{else}images/avatar.gif{/if}" alt="" width="55" height="55"> </div> </td></tr>################ php 逻辑处理 ################1、user.php 里面找到require(dirname(__FILE__) . '/includes/init.php');它的下面加入include_once(ROOT_PATH . '/includes/cls_image.php');//会员头像 by neo$image = new cls_image($_CFG['bgcolor']);//会员头像 by neo$allow_suffix = array('gif', 'jpg', 'png', 'jpeg', 'bmp');//会员头像 by neo继续找到/* 更新用户扩展字段的数据 */在它的上面加入$avatar = isset($_POST['avatar']) ? $_POST['avatar'] : '';//会员头像 by neo继续找if (!empty($mobile_phone) && !preg_match('/^[\d-\s]+$/', $mobile_phone)){ show_message($_LANG['passport_js']['mobile_phone_invalid']);}它下面加入 /* 检查图片:如果有错误,检查尺寸是否超过最大值;否则,检查文件类型 */ if (isset($_FILES['avatar']['error'])) // php 4.2 版本才支持 error { // 最大上传文件大小 $php_maxsize = ini_get('upload_max_filesize'); $htm_maxsize = '1M'; // 会员头像 if ($_FILES['avatar']['error'] == 0) { if (!$image->check_img_type($_FILES['avatar']['type'])) { show_message("图片格式不正确!"); } } elseif ($_FILES['avatar']['error'] == 1) { show_message(sprintf('图片文件太大了(最大值:1M),无法上传。', $php_maxsize), $_LANG['profile_lnk'], 'user.php?act=profile', 'info'); } elseif ($_FILES['avatar']['error'] == 2) { show_message(sprintf('图片文件太大了(最大值:1M),无法上传。', $htm_maxsize), $_LANG['profile_lnk'], 'user.php?act=profile', 'info'); } } /* 4.1版本 */ else { // 会员头像 if ($_FILES['avatar']['tmp_name'] != 'none') { if (!$image->check_img_type($_FILES['avatar']['type'])) { show_message("图片格式不正确!"); } } } //会员头像 by neo if (!empty($_FILES['avatar']['name'])) { /* 更新会员头像之前先删除旧的头像 */ $sql = "SELECT avatar " . " FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '$user_id'"; $row = $GLOBALS['db']->getRow($sql); if ($row['avatar'] != '') { @unlink($row['avatar']); } $img_name = $user_id . '.' . end(explode('.', $_FILES['avatar']['name'])); $target = ROOT_PATH . DATA_DIR . '/avatar/'; $original_img = $image->upload_image($_FILES['avatar'], 'avatar', $img_name); // 原始图片 $avatar = $image->make_thumb($original_img, 55, 55, $target); if ($avatar === false) { show_message("图片保存出错!"); } }在它的下面还有个 $profile = array( 'user_id' => $user_id, 'email' => isset($_POST['email']) ? trim($_POST['email']) : '', 'sex' => isset($_POST['sex']) ? intval($_POST['sex']) : 0, 'birthday' => $birthday, 'other' => isset($other) ? $other : array() );修改成 $profile = array( 'user_id' => $user_id, 'email' => isset($_POST['email']) ? trim($_POST['email']) : '', 'sex' => isset($_POST['sex']) ? intval($_POST['sex']) : 0, 'birthday' => $birthday, 'avatar' => $avatar,//会员头像 by neo 'other' => isset($other) ? $other : array() ); 2、includes\lib_clips.php找到function get_user_default($user_id){ $user_bonus = get_user_bonus(); $sql = "SELECT pay_points, user_money, credit_line, last_login, is_validated FROM " .$GLOBALS['ecs']->table('users'). " WHERE user_id = '$user_id'";加入字段function get_user_default($user_id){ $user_bonus = get_user_bonus(); //会员头像 by neo $sql = "SELECT pay_points, user_money, credit_line, last_login, is_validated, avatar FROM " .$GLOBALS['ecs']->table('users'). " WHERE user_id = '$user_id'"; $row = $GLOBALS['db']->getRow($sql);继续下面中的$info = array();加入字段$info['avatar'] = $row['avatar'];//会员头像 by neo3、includes\lib_transaction.php找到if (!$GLOBALS['user']->edit_user($cfg))在它的前面加入//会员头像if (!empty($profile['avatar'])){ $cfg['avatar'] = $profile['avatar'];}继续找到function get_profile($user_id){ global $user; /* 会员帐号信息 */ $info = array(); $infos = array(); $sql = "SELECT user_name, birthday, sex, question, answer, rank_points, pay_points,user_money, user_rank,". " msn, qq, office_phone, home_phone, mobile_phone, passwd_question, passwd_answer ". "FROM " .$GLOBALS['ecs']->table('users') . " WHERE user_id = '$user_id'";加入字段function get_profile($user_id){ global $user; /* 会员帐号信息 */ $info = array(); $infos = array(); $sql = "SELECT user_name, birthday, sex, question, answer, rank_points, pay_points,user_money, user_rank,". " msn, qq, office_phone, home_phone, mobile_phone, passwd_question, passwd_answer, avatar ".//会员头像 by neo "FROM " .$GLOBALS['ecs']->table('users') . " WHERE user_id = '$user_id'";继续找到下面的$info['birthday'] = isset($infos['birthday']) ? $infos['birthday'] : '';在它的下面加入$info['avatar'] = isset($infos['avatar']) ? $infos['avatar'] : '';//会员头像 by neo4、includes\modules\integrates\integrate.php 里面找到var $error = 0;它的下面加入/* 会员头像 by neo */var $field_avatar = '';继续找到if ((!empty($cfg['bday'])) && $this->field_bday != 'NULL'){ $values[] = $this->field_bday . "='" . $cfg['bday'] . "'";}在它的下面加入//会员头像 by neoif ((!empty($cfg['avatar'])) && $this->field_avatar != 'NULL'){ $values[] = $this->field_avatar . "='" . $cfg['avatar'] . "'";}5、includes\modules\integrates\ecshop.php找到$this->field_reg_date = 'reg_time';下面加入$this->field_avatar = 'avatar';//会员头像 by neo################ 后台 ################1、admin\templates\user_info.htm找到<form method="post" action="users.php" name="theForm" onsubmit="return validate()">改成<form method="post" action="users.php" name="theForm" onsubmit="return validate()" enctype="multipart/form-data"><input type="hidden" name="MAX_FILE_SIZE" value="1097152" /><!-- 1M图片上传大小设置 -->继续找 <tr> <td class="label">{$lang.email}:</td> <td><input type="text" name="email" maxlength="60" size="40" value="{$user.email}" />{$lang.require_field}</td> </tr>它的下面加入<tr> <td width="28%" align="right" class="label">会员头像:</td> <td width="72%" align="left" bgcolor="#FFFFFF"> <div style="width:50%;float:left;"> <input id="avatar" type="file" size="40" value="" name="avatar"> <br/> <span style="color:#FF0000"> 图片像素最佳为55px * 55px,<br/>大小不得超过1M</span> </div> <div style="width:50%;float:left;"> <img src="../{if $user.avatar}{$user.avatar}{else}images/avatar.gif{/if}" alt="" width="55" height="55"> </div> </td></tr>2、admin\users.php找到头部的require(dirname(__FILE__) . '/includes/init.php');下面加入include_once(ROOT_PATH . '/includes/cls_image.php');//会员头像 by neo$image = new cls_image($_CFG['bgcolor']);//会员头像 by neo$allow_suffix = array('gif', 'jpg', 'png', 'jpeg', 'bmp');//会员头像 by neo找到$sql = "SELECT u.user_id, u.sex, u.birthday, u.pay_points, u.rank_points, u.user_rank , u.user_money, u.frozen_money, u.credit_line, u.parent_id, u2.user_name as parent_username, u.qq, u.msn, u.office_phone, u.home_phone, u.mobile_phone".修改成$sql = "SELECT u.user_id, u.sex, u.birthday, u.pay_points, u.rank_points, u.user_rank , u.user_money, u.frozen_money, u.credit_line, u.parent_id, u2.user_name as parent_username, u.qq, u.msn, u.office_phone, u.home_phone, u.mobile_phone, u.avatar".//会员头像 by neo下面的$user['mobile_phone'] = $row['mobile_phone'];它的下面加入$user['avatar'] = $row['avatar'];//会员头像 by neo这样,后台编辑会员 就能看到会员的头像了。接下来,处理后台修改会员头像的提交逻辑处理继续找到elseif ($_REQUEST['act'] == 'update')下面的$credit_line = empty($_POST['credit_line']) ? 0 : floatval($_POST['credit_line']);它的下面加入 $user_id = empty($_POST['id']) ? '' : trim($_POST['id']);//会员头像 by neo /* 检查图片:如果有错误,检查尺寸是否超过最大值;否则,检查文件类型 */ if (isset($_FILES['avatar']['error'])) // php 4.2 版本才支持 error { // 最大上传文件大小 $php_maxsize = ini_get('upload_max_filesize'); $htm_maxsize = '1M'; // 会员头像 if ($_FILES['avatar']['error'] == 0) { if (!$image->check_img_type($_FILES['avatar']['type'])) { sys_msg("图片格式不正确!", 1, array(), false); } } elseif ($_FILES['avatar']['error'] == 1) { sys_msg(sprintf('图片文件太大了(最大值:1M),无法上传。', $php_maxsize), 1, array(), false); } elseif ($_FILES['avatar']['error'] == 2) { sys_msg(sprintf('图片文件太大了(最大值:1M),无法上传。', $htm_maxsize), 1, array(), false); } } /* 4.1版本 */ else { // 会员头像 if ($_FILES['avatar']['tmp_name'] != 'none') { if (!$image->check_img_type($_FILES['avatar']['type'])) { sys_msg("图片格式不正确!"); } } } //会员头像 by neo if (!empty($_FILES['avatar']['name'])) { /* 更新会员头像之前先删除旧的头像 */ $sql = "SELECT avatar " . " FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '$user_id'"; $row = $GLOBALS['db']->getRow($sql); if ($row['avatar'] != '') { @unlink('../' . $row['avatar']); } $img_name = $user_id . '.' . end(explode('.', $_FILES['avatar']['name'])); $target = ROOT_PATH . DATA_DIR . '/avatar/'; $original_img = $image->upload_image($_FILES['avatar'], 'avatar', $img_name); // 原始图片 $avatar = $image->make_thumb('../' . $original_img, 55, 55, $target); if ($avatar === false) { sys_msg("图片保存出错!"); } }下面一行的if (!$users->edit_user(array('username'=>$username, 'password'=>$password, 'email'=>$email, 'gender'=>$sex, 'bday'=>$birthday ), 1))加入字段if (!$users->edit_user(array('username'=>$username, 'password'=>$password, 'email'=>$email, 'gender'=>$sex, 'bday'=>$birthday, 'avatar'=>$avatar ), 1))//会员头像 by neo
0 0
- ecshop设置会员头像
- ecshop 添加会员头像功能
- ecshop 添加会员头像功能
- 【ECSHOP插件】ECSHOP会员头像,上传头像评论显示头像
- 开源 免费 java CMS - FreeCMS2.0 会员头像设置
- 开源 java CMS - FreeCMS2.3会员头像设置
- ECshop会员等级~
- 修改ECSHOP中的会员
- discuz 获取会员头像
- ecshop会员登录记录用户名
- 免费使用QQ会员头像
- ecshop二次开始--头像上传
- ecshop二次开始--头像上传
- ecshop二次开始--头像上传
- 头像设置
- ecshop整合会员的教程分析
- ecshop与discuzX1.5的会员整合
- ecshop 会员等级制度和规则分析
- uboot arp地址解析
- js 60秒倒计时
- Matlab 2008找不到VS2008编译器的解决办法
- 有奖话题竞拍丨新手如何学习和研究SDN?
- iOS view的frame和bounds之区别(位置和大小)
- ecshop设置会员头像
- poj2392 Space Elevator
- UILabel加载图片
- 单向联系
- 珍藏文:程序员面试什么最重要?-----性格大于能力
- iOS 6 自动布局 入门 2
- 安卓jni调用之C代码中调用Java代码
- 【数字图像处理】选择题
- 黑马程序员——C语言基础学习(三)---进制和函数的总结学习