001.$invitepay = getreward('invitecode', 0);
002.$pay = $app ? 0 : $invitepay['credit'];
003.
004.if($uid && $code && !$pay) {
005. $m_space = getspace($uid);
006. if($code == space_key($m_space, $app)) {
007. $invitearr['uid'] = $uid;
008. $invitearr['username'] = $m_space['username'];
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')) {
033.
034.
035. if($_SGLOBAL['supe_uid']) {
036. showmessage('registered', 'space.php');
037. }
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']) {
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']:'';
062. if(empty($email)) {
063. showmessage('email_format_is_wrong');
064. }
065.
066. if($_SCONFIG['checkemail']) {
067. if($count = getcount('spacefield', array('email'=>$email))) {
068. showmessage('email_has_been_registered');
069. }
070. }
071.
072. $onlineip = getonlineip();
073. if($_SCONFIG['regipdate']) {
074. $query = $_SGLOBAL['db']->query("SELECT dateline FROM ".tname('space')." WHERE regip='$onlineip' ORDER BY dateline DESC LIMIT 1");
075. if($value = $_SGLOBAL['db']->fetch_array($query)) {
076. if($_SGLOBAL['timestamp'] - $value['dateline'] < $_SCONFIG['regipdate']*3600) {
077. showmessage('regip_has_been_registered', '', 1, array($_SCONFIG['regipdate']));
078. }
079. }
080. }
081.
082. $newuid = uc_user_register($username, $password, $email);
083. if($newuid <= 0) {
084. if($newuid == -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 {
100. $setarr = array(
101. 'uid' => $newuid,
102. 'username' => $username,
103. 'password' => md5("$newuid|$_SGLOBAL[timestamp]")
104. );
105.
106. inserttable('member', $setarr, 0, true);
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'])).")");
116. while ($value = $_SGLOBAL['db']->fetch_array($query)) {
117. $value = saddslashes($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) {
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.
144. insertsession($setarr);
145.
146.
147. ssetcookie('auth', authcode("$setarr[password]\t$setarr[uid]", 'ENCODE'), 2592000);
148. ssetcookie('loginuser', $username, 31536000);
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") {
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) {
194. showmessage('user_name_is_not_legitimate');
195. } elseif($ucresult == -2) {
196. showmessage('include_not_registered_words');
197. } elseif($ucresult == -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.?>