UCHome 关于用户注册页面的代码分析
来源:百度文库 编辑:神马文学网 时间:2024/04/29 21:02:59
01 02
03 /**
04 * [UCenter Home] (C) 2007-2008 Comsenz Inc.
05 * @Id: do_register.php 2009-10-2 00:00:00
06 * @author UCHome
07 * @copyrighthttp://www.8100.cc/2046
08 * @deprecated uchome源码交流QQ群:83400173
09 */
10
11 if(!defined('IN_UCHOME')) {
12 exit('Access Denied');
13 }
14
15 $op = $_GET['op'] ? trim($_GET['op']) : '';
16
17 if($_SGLOBAL['supe_uid']) { //如果存在uid则直接进行用户空间
18 showmessage('do_success', 'space.php?do=home', 0);
19 }
20
21 //没有登录表单
22 $_SGLOBAL['nologinform'] = 1;
23
24 //好友邀请
25 $uid = empty($_GET['uid'])?0:intval($_GET['uid']);
26 $code = empty($_GET['code'])?'':$_GET['code'];
27 $app = empty($_GET['app'])?'':intval($_GET['app']); //获取应用的id
28 $invite = empty($_GET['invite'])?'':$_GET['invite'];
29 $invitearr = array();
view source',1)">
print?
001 $invitepay = getreward('invitecode', 0); //获取邀请码,所应该得的积分与经验
002 $pay = $app ? 0 : $invitepay['credit'];
003
004 if($uid && $code && !$pay) { //如果存在uid,code,并且积分为0
005 $m_space = getspace($uid); //获取邀请人的空间信息
006 if($code == space_key($m_space, $app)) {//验证通过
007 $invitearr['uid'] = $uid;
008 $invitearr['username'] = $m_space['username']; //将邀请人的uid与username赋值给invitearr数组
009 }
010 $url_plus = "uid=$uid&app=$app&code=$code";
011 } elseif($uid && $invite) {
012 include_once(S_ROOT.'./source/function_cp.php');
013 $invitearr = invite_get($uid, $invite);
014 $url_plus = "uid=$uid&invite=$invite";
015 }
016
017 $jumpurl = $app?"userapp.php?id=$app&my_extra=invitedby_bi_{$uid}_{$code}&my_suffix=Lw%3D%3D":'space.php?do=home';
018
019 if(empty($op)) {
020
021 if($_SCONFIG['closeregister']) {//判断系统是否关闭注册
022 if($_SCONFIG['closeinvite']) {//如果没有开启好友邀请还不能注册,则提示"非常抱歉,本站目前暂时不开放注册";
023 showmessage('not_open_registration');
024 } elseif(empty($invitearr)) {//否则显示非常抱歉,本站目前暂时不允许用户直接注册,需要有好友邀请链接才能注册
025 showmessage('not_open_registration_invite');
026 }
027 }
028
029 //是否关闭站点
030 checkclose();
031
032 if(submitcheck('registersubmit')) { //判断是否有post提交注册
033
034 //已经注册用户
035 if($_SGLOBAL['supe_uid']) {
036 showmessage('registered', 'space.php');
037 } //如果该uid存在时,则显示"注册成功",跳转到空间
038
039 if($_SCONFIG['seccode_register']) {
040 include_once(S_ROOT.'./source/function_cp.php');
041 if(!ckseccode($_POST['seccode'])) { //验证注册码
042 showmessage('incorrect_code');
043 }
044 }
045
046 if(!@include_once S_ROOT.'./uc_client/client.php') { //引入用户操作入口文件
047 showmessage('system_error');
048 }
049
050 if($_POST['password'] != $_POST['password2']) { //判断两次输入的密码是否相同,一般会使用javascript进行判断
051 showmessage('password_inconsistency');
052 }
053
054 if(!$_POST['password'] || $_POST['password'] != addslashes($_POST['password'])) {
055 showmessage('profile_passwd_illegal');
056 } //如果密码未真写或是填写的密码与转义后的密码不相同时,对话框提示:密码空或包含非法字符,请返回重新填写。
057
058 $username = trim($_POST['username']);
059 $password = $_POST['password']; //获取用户名与密码
060
061 $email = isemail($_POST['email'])?$_POST['email']:'';//验证email的格式
062 if(empty($email)) {
063 showmessage('email_format_is_wrong'); //如果返回为空则显示:填写的 Email 格式有误
064 }
065 //检查邮件
066 if($_SCONFIG['checkemail']) { //是否可以重复注册email
067 if($count = getcount('spacefield', array('email'=>$email))) {
068 showmessage('email_has_been_registered');
069 }
070 }
071 //检查IP
072 $onlineip = getonlineip(); //获取当前的ip
073 if($_SCONFIG['regipdate']) { //是否有限制一个ip注册的间隔时间
074 $query = $_SGLOBAL['db']->query("SELECT dateline FROM ".tname('space')." WHERE regip='$onlineip' ORDER BY dateline DESC LIMIT 1"); //查看该ip的注册时间
075 if($value = $_SGLOBAL['db']->fetch_array($query)) {
076 if($_SGLOBAL['timestamp'] - $value['dateline'] < $_SCONFIG['regipdate']*3600) { //如果当前时间小于ip注册时间限制
077 showmessage('regip_has_been_registered', '', 1, array($_SCONFIG['regipdate'])); //则提示同一个IP在 1 小时内只能注册一个账号
078 }
079 }
080 }
081
082 $newuid = uc_user_register($username, $password, $email); //通过用户操作接口文件进行用户的注册,传入用户名,密码,Email
083 if($newuid <= 0) { //如果返回uid小于0
084 if($newuid == -1) { //如果等于-1:用户名不合法
085 showmessage('user_name_is_not_legitimate');
086 } elseif($newuid == -2) {
087 showmessage('include_not_registered_words');
088 } elseif($newuid == -3) {
089 showmessage('user_name_already_exists');
090 } elseif($newuid == -4) {
091 showmessage('email_format_is_wrong');
092 } elseif($newuid == -5) {
093 showmessage('email_not_registered');
094 } elseif($newuid == -6) {
095 showmessage('email_has_been_registered');
096 } else {
097 showmessage('register_error');
098 }
099 } else { //如果uid>0,则表示注册成功
100 $setarr = array(
101 'uid' => $newuid,
102 'username' => $username,
103 'password' => md5("$newuid|$_SGLOBAL[timestamp]")//本地密码随机生成,密码由:uid|当前时间 生成
104 );
105 //更新本地用户库
106 inserttable('member', $setarr, 0, true); //将用户这三个字段信息添加到member表中
107
108 //开通空间
109 include_once(S_ROOT.'./source/function_space.php');
110 $space = space_open($newuid, $username, 0, $email); //开通用户空间
111
112 //默认好友
113 $flog = $inserts = $fuids = $pokes = array();
114 if(!empty($_SCONFIG['defaultfusername'])) { //查看是否有设置默认好友
115 $query = $_SGLOBAL['db']->query("SELECT uid,username FROM ".tname('space')." WHERE username IN (".simplode(explode(',', $_SCONFIG['defaultfusername'])).")"); //如果有存在设置默认好友,则查着这些好友的uid,username信息
116 while ($value = $_SGLOBAL['db']->fetch_array($query)) {
117 $value = saddslashes($value); //将所得的$value数组进行字符过滤
118 $fuids[] = $value['uid'];
119 $inserts[] = "('$newuid','$value[uid]','$value[username]','1','$_SGLOBAL[timestamp]')";
120 $inserts[] = "('$value[uid]','$newuid','$username','1','$_SGLOBAL[timestamp]')";
121 $pokes[] = "('$newuid','$value[uid]','$value[username]','".addslashes($_SCONFIG['defaultpoke'])."','$_SGLOBAL[timestamp]')";
122 //添加好友变更记录
123 $flog[] = "('$value[uid]','$newuid','add','$_SGLOBAL[timestamp]')";
124 }
125 if($inserts) { //"REPLACE INTO" 如果表中不存在这一条记录都插入数据库,如果已经存在,则修改数据
126 $_SGLOBAL['db']->query("REPLACE INTO ".tname('friend')." (uid,fuid,fusername,status,dateline) VALUES ".implode(',', $inserts)); //将信息插入到好友表
127 $_SGLOBAL['db']->query("REPLACE INTO ".tname('poke')." (uid,fromuid,fromusername,note,dateline) VALUES ".implode(',', $pokes)); //好友动态表
128 $_SGLOBAL['db']->query("REPLACE INTO ".tname('friendlog')." (uid,fuid,action,dateline) VALUES ".implode(',', $flog));
129
130 //添加到附加表
131 $friendstr = empty($fuids)?'':implode(',', $fuids);
132 updatetable('space', array('friendnum'=>count($fuids), 'pokenum'=>count($pokes)), array('uid'=>$newuid)); //更新用户空间信息,修改好友数与动态数
133 updatetable('spacefield', array('friend'=>$friendstr, 'feedfriend'=>$friendstr), array('uid'=>$newuid));
134
135 //更新默认用户好友缓存
136 include_once(S_ROOT.'./source/function_cp.php');
137 foreach ($fuids as $fuid) {
138 friend_cache($fuid); //对好友数据进行缓存
139 }
140 }
141 }
142
143 //在线session
144 insertsession($setarr); //将该用户信息插入到session表中
145
146 //设置cookie
147 ssetcookie('auth', authcode("$setarr[password]\t$setarr[uid]", 'ENCODE'), 2592000); //设置cookie名为auth的值,并自动设置cookie保存时间为一个月
148 ssetcookie('loginuser', $username, 31536000); //设置cookie名为loginuser的值,并自动保存一年
149 ssetcookie('_refer', '');
150
151 //好友邀请
152 if($invitearr) {
153 include_once(S_ROOT.'./source/function_cp.php');
154 invite_update($invitearr['id'], $setarr['uid'], $setarr['username'], $invitearr['uid'], $invitearr['username'], $app);
155 //更新邀请人空间的信息,包括邀请人与被邀请人的好友数
156 //如果提交的邮箱地址与邀请相符的则直接通过邮箱验证
157 if($invitearr['email'] == $email) {
158 updatetable('spacefield', array('emailcheck'=>1), array('uid'=>$newuid));
159 }
160
161 //统计更新
162 include_once(S_ROOT.'./source/function_cp.php');
163 if($app) {
164 updatestat('appinvite');
165 } else {
166 updatestat('invite');
167 }
168 }
169
170 //变更记录
171 if($_SCONFIG['my_status']) inserttable('userlog', array('uid'=>$newuid, 'action'=>'add', 'dateline'=>$_SGLOBAL['timestamp']), 0, true);
172
173 showmessage('registered', $jumpurl);
174 }
175
176 }
177
178 $register_rule = data_get('registerrule');
179
180 include template('do_register');
181
182 } elseif($op == "checkusername") { //ajax验证用户的信息,包括用户名是否为空,用户名在数据库中是否被注册
183
184 $username = trim($_GET['username']);
185 if(empty($username)) {
186 showmessage('user_name_is_not_legitimate');
187 //用户名为空
188 }
189 @include_once (S_ROOT.'./uc_client/client.php');
190 $ucresult = uc_user_checkname($username);
191 //通过数据库验证用户名信息
192
193 if($ucresult == -1) {//返回-1,表示用户名不合法
194 showmessage('user_name_is_not_legitimate');
195 } elseif($ucresult == -2) {//返回-2,表示用户名包含不允许注册的词语
196 showmessage('include_not_registered_words');
197 } elseif($ucresult == -3) { //返回-3,表示用户名已经存在
198 showmessage('user_name_already_exists');
199 } else {//否则返回用户可以使用
200 showmessage('succeed');
201 }
202 } elseif($op == "checkseccode") {//判断验证码
203
204 include_once(S_ROOT.'./source/function_cp.php');
205 if(ckseccode(trim($_GET['seccode']))) {
206 showmessage('succeed');
207 } else {
208 showmessage('incorrect_code');
209 }
210 }
211
212 ?>
_Flash
03 /**
04 * [UCenter Home] (C) 2007-2008 Comsenz Inc.
05 * @Id: do_register.php 2009-10-2 00:00:00
06 * @author UCHome
07 * @copyrighthttp://www.8100.cc/2046
08 * @deprecated uchome源码交流QQ群:83400173
09 */
10
11 if(!defined('IN_UCHOME')) {
12 exit('Access Denied');
13 }
14
15 $op = $_GET['op'] ? trim($_GET['op']) : '';
16
17 if($_SGLOBAL['supe_uid']) { //如果存在uid则直接进行用户空间
18 showmessage('do_success', 'space.php?do=home', 0);
19 }
20
21 //没有登录表单
22 $_SGLOBAL['nologinform'] = 1;
23
24 //好友邀请
25 $uid = empty($_GET['uid'])?0:intval($_GET['uid']);
26 $code = empty($_GET['code'])?'':$_GET['code'];
27 $app = empty($_GET['app'])?'':intval($_GET['app']); //获取应用的id
28 $invite = empty($_GET['invite'])?'':$_GET['invite'];
29 $invitearr = array();
view source',1)">
print?
001 $invitepay = getreward('invitecode', 0); //获取邀请码,所应该得的积分与经验
002 $pay = $app ? 0 : $invitepay['credit'];
003
004 if($uid && $code && !$pay) { //如果存在uid,code,并且积分为0
005 $m_space = getspace($uid); //获取邀请人的空间信息
006 if($code == space_key($m_space, $app)) {//验证通过
007 $invitearr['uid'] = $uid;
008 $invitearr['username'] = $m_space['username']; //将邀请人的uid与username赋值给invitearr数组
009 }
010 $url_plus = "uid=$uid&app=$app&code=$code";
011 } elseif($uid && $invite) {
012 include_once(S_ROOT.'./source/function_cp.php');
013 $invitearr = invite_get($uid, $invite);
014 $url_plus = "uid=$uid&invite=$invite";
015 }
016
017 $jumpurl = $app?"userapp.php?id=$app&my_extra=invitedby_bi_{$uid}_{$code}&my_suffix=Lw%3D%3D":'space.php?do=home';
018
019 if(empty($op)) {
020
021 if($_SCONFIG['closeregister']) {//判断系统是否关闭注册
022 if($_SCONFIG['closeinvite']) {//如果没有开启好友邀请还不能注册,则提示"非常抱歉,本站目前暂时不开放注册";
023 showmessage('not_open_registration');
024 } elseif(empty($invitearr)) {//否则显示非常抱歉,本站目前暂时不允许用户直接注册,需要有好友邀请链接才能注册
025 showmessage('not_open_registration_invite');
026 }
027 }
028
029 //是否关闭站点
030 checkclose();
031
032 if(submitcheck('registersubmit')) { //判断是否有post提交注册
033
034 //已经注册用户
035 if($_SGLOBAL['supe_uid']) {
036 showmessage('registered', 'space.php');
037 } //如果该uid存在时,则显示"注册成功",跳转到空间
038
039 if($_SCONFIG['seccode_register']) {
040 include_once(S_ROOT.'./source/function_cp.php');
041 if(!ckseccode($_POST['seccode'])) { //验证注册码
042 showmessage('incorrect_code');
043 }
044 }
045
046 if(!@include_once S_ROOT.'./uc_client/client.php') { //引入用户操作入口文件
047 showmessage('system_error');
048 }
049
050 if($_POST['password'] != $_POST['password2']) { //判断两次输入的密码是否相同,一般会使用javascript进行判断
051 showmessage('password_inconsistency');
052 }
053
054 if(!$_POST['password'] || $_POST['password'] != addslashes($_POST['password'])) {
055 showmessage('profile_passwd_illegal');
056 } //如果密码未真写或是填写的密码与转义后的密码不相同时,对话框提示:密码空或包含非法字符,请返回重新填写。
057
058 $username = trim($_POST['username']);
059 $password = $_POST['password']; //获取用户名与密码
060
061 $email = isemail($_POST['email'])?$_POST['email']:'';//验证email的格式
062 if(empty($email)) {
063 showmessage('email_format_is_wrong'); //如果返回为空则显示:填写的 Email 格式有误
064 }
065 //检查邮件
066 if($_SCONFIG['checkemail']) { //是否可以重复注册email
067 if($count = getcount('spacefield', array('email'=>$email))) {
068 showmessage('email_has_been_registered');
069 }
070 }
071 //检查IP
072 $onlineip = getonlineip(); //获取当前的ip
073 if($_SCONFIG['regipdate']) { //是否有限制一个ip注册的间隔时间
074 $query = $_SGLOBAL['db']->query("SELECT dateline FROM ".tname('space')." WHERE regip='$onlineip' ORDER BY dateline DESC LIMIT 1"); //查看该ip的注册时间
075 if($value = $_SGLOBAL['db']->fetch_array($query)) {
076 if($_SGLOBAL['timestamp'] - $value['dateline'] < $_SCONFIG['regipdate']*3600) { //如果当前时间小于ip注册时间限制
077 showmessage('regip_has_been_registered', '', 1, array($_SCONFIG['regipdate'])); //则提示同一个IP在 1 小时内只能注册一个账号
078 }
079 }
080 }
081
082 $newuid = uc_user_register($username, $password, $email); //通过用户操作接口文件进行用户的注册,传入用户名,密码,Email
083 if($newuid <= 0) { //如果返回uid小于0
084 if($newuid == -1) { //如果等于-1:用户名不合法
085 showmessage('user_name_is_not_legitimate');
086 } elseif($newuid == -2) {
087 showmessage('include_not_registered_words');
088 } elseif($newuid == -3) {
089 showmessage('user_name_already_exists');
090 } elseif($newuid == -4) {
091 showmessage('email_format_is_wrong');
092 } elseif($newuid == -5) {
093 showmessage('email_not_registered');
094 } elseif($newuid == -6) {
095 showmessage('email_has_been_registered');
096 } else {
097 showmessage('register_error');
098 }
099 } else { //如果uid>0,则表示注册成功
100 $setarr = array(
101 'uid' => $newuid,
102 'username' => $username,
103 'password' => md5("$newuid|$_SGLOBAL[timestamp]")//本地密码随机生成,密码由:uid|当前时间 生成
104 );
105 //更新本地用户库
106 inserttable('member', $setarr, 0, true); //将用户这三个字段信息添加到member表中
107
108 //开通空间
109 include_once(S_ROOT.'./source/function_space.php');
110 $space = space_open($newuid, $username, 0, $email); //开通用户空间
111
112 //默认好友
113 $flog = $inserts = $fuids = $pokes = array();
114 if(!empty($_SCONFIG['defaultfusername'])) { //查看是否有设置默认好友
115 $query = $_SGLOBAL['db']->query("SELECT uid,username FROM ".tname('space')." WHERE username IN (".simplode(explode(',', $_SCONFIG['defaultfusername'])).")"); //如果有存在设置默认好友,则查着这些好友的uid,username信息
116 while ($value = $_SGLOBAL['db']->fetch_array($query)) {
117 $value = saddslashes($value); //将所得的$value数组进行字符过滤
118 $fuids[] = $value['uid'];
119 $inserts[] = "('$newuid','$value[uid]','$value[username]','1','$_SGLOBAL[timestamp]')";
120 $inserts[] = "('$value[uid]','$newuid','$username','1','$_SGLOBAL[timestamp]')";
121 $pokes[] = "('$newuid','$value[uid]','$value[username]','".addslashes($_SCONFIG['defaultpoke'])."','$_SGLOBAL[timestamp]')";
122 //添加好友变更记录
123 $flog[] = "('$value[uid]','$newuid','add','$_SGLOBAL[timestamp]')";
124 }
125 if($inserts) { //"REPLACE INTO" 如果表中不存在这一条记录都插入数据库,如果已经存在,则修改数据
126 $_SGLOBAL['db']->query("REPLACE INTO ".tname('friend')." (uid,fuid,fusername,status,dateline) VALUES ".implode(',', $inserts)); //将信息插入到好友表
127 $_SGLOBAL['db']->query("REPLACE INTO ".tname('poke')." (uid,fromuid,fromusername,note,dateline) VALUES ".implode(',', $pokes)); //好友动态表
128 $_SGLOBAL['db']->query("REPLACE INTO ".tname('friendlog')." (uid,fuid,action,dateline) VALUES ".implode(',', $flog));
129
130 //添加到附加表
131 $friendstr = empty($fuids)?'':implode(',', $fuids);
132 updatetable('space', array('friendnum'=>count($fuids), 'pokenum'=>count($pokes)), array('uid'=>$newuid)); //更新用户空间信息,修改好友数与动态数
133 updatetable('spacefield', array('friend'=>$friendstr, 'feedfriend'=>$friendstr), array('uid'=>$newuid));
134
135 //更新默认用户好友缓存
136 include_once(S_ROOT.'./source/function_cp.php');
137 foreach ($fuids as $fuid) {
138 friend_cache($fuid); //对好友数据进行缓存
139 }
140 }
141 }
142
143 //在线session
144 insertsession($setarr); //将该用户信息插入到session表中
145
146 //设置cookie
147 ssetcookie('auth', authcode("$setarr[password]\t$setarr[uid]", 'ENCODE'), 2592000); //设置cookie名为auth的值,并自动设置cookie保存时间为一个月
148 ssetcookie('loginuser', $username, 31536000); //设置cookie名为loginuser的值,并自动保存一年
149 ssetcookie('_refer', '');
150
151 //好友邀请
152 if($invitearr) {
153 include_once(S_ROOT.'./source/function_cp.php');
154 invite_update($invitearr['id'], $setarr['uid'], $setarr['username'], $invitearr['uid'], $invitearr['username'], $app);
155 //更新邀请人空间的信息,包括邀请人与被邀请人的好友数
156 //如果提交的邮箱地址与邀请相符的则直接通过邮箱验证
157 if($invitearr['email'] == $email) {
158 updatetable('spacefield', array('emailcheck'=>1), array('uid'=>$newuid));
159 }
160
161 //统计更新
162 include_once(S_ROOT.'./source/function_cp.php');
163 if($app) {
164 updatestat('appinvite');
165 } else {
166 updatestat('invite');
167 }
168 }
169
170 //变更记录
171 if($_SCONFIG['my_status']) inserttable('userlog', array('uid'=>$newuid, 'action'=>'add', 'dateline'=>$_SGLOBAL['timestamp']), 0, true);
172
173 showmessage('registered', $jumpurl);
174 }
175
176 }
177
178 $register_rule = data_get('registerrule');
179
180 include template('do_register');
181
182 } elseif($op == "checkusername") { //ajax验证用户的信息,包括用户名是否为空,用户名在数据库中是否被注册
183
184 $username = trim($_GET['username']);
185 if(empty($username)) {
186 showmessage('user_name_is_not_legitimate');
187 //用户名为空
188 }
189 @include_once (S_ROOT.'./uc_client/client.php');
190 $ucresult = uc_user_checkname($username);
191 //通过数据库验证用户名信息
192
193 if($ucresult == -1) {//返回-1,表示用户名不合法
194 showmessage('user_name_is_not_legitimate');
195 } elseif($ucresult == -2) {//返回-2,表示用户名包含不允许注册的词语
196 showmessage('include_not_registered_words');
197 } elseif($ucresult == -3) { //返回-3,表示用户名已经存在
198 showmessage('user_name_already_exists');
199 } else {//否则返回用户可以使用
200 showmessage('succeed');
201 }
202 } elseif($op == "checkseccode") {//判断验证码
203
204 include_once(S_ROOT.'./source/function_cp.php');
205 if(ckseccode(trim($_GET['seccode']))) {
206 showmessage('succeed');
207 } else {
208 showmessage('incorrect_code');
209 }
210 }
211
212 ?>
_Flash
UCHome 关于用户注册页面的代码分析
页面插入视频的代码
关于我国注册质量工程师的调查分析
关于搜索引擎页面分析中的 javascript 处理的2个思路
多媒体页面及播放器的代码
:更换首页页面背景的代码
用ASP实现一个真正的注册页面
页面长度与用户行为的一些数据
页面长度与用户行为的一些数据
页面跳转提示代码
卓彩网用户注册协议
一条人性化设计的代码,top回到页面顶部
Web页面安全之HTML代码优化注意的细节
不可复制页面代码 - 春草的日志 - 网易博客
一条人性化设计的代码,top回到页面顶部
Asp.NET 生成静态页面并分页的代码实现
Asp.NET 生成静态页面并分页的代码00
Twitter考虑适时推出中文注册页面
各种js页面跳转代码
各种js页面跳转代码
四个页面转向代码123
页面设置常用软件下载代码
迅速返回页面顶部代码
页面布局居中css代码