3 if(! function_exists('register_post')) {
4 function register_post(&$a) {
11 $arr = array('post' => $_POST);
12 call_hooks('register_post', $arr);
14 $max_dailies = intval(get_config('system','max_daily_registrations'));
16 $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
17 if($r && $r[0]['total'] >= $max_dailies) {
22 switch($a->config['register_policy']) {
30 case REGISTER_APPROVE:
37 if((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) {
38 notice( t('Permission denied.') . EOL );
46 require_once('include/user.php');
50 $arr['blocked'] = $blocked;
51 $arr['verified'] = $verified;
53 $result = create_user($arr);
55 if(! $result['success']) {
56 notice($result['message']);
60 $user = $result['user'];
62 if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
63 $url = $a->get_baseurl() . '/profile/' . $user['nickname'];
64 proc_run('php',"include/directory.php","$url");
67 $using_invites = get_config('system','invitation_only');
68 $num_invites = get_config('system','number_invites');
69 $invite_id = ((x($_POST,'invite_id')) ? notags(trim($_POST['invite_id'])) : '');
72 if( $a->config['register_policy'] == REGISTER_OPEN ) {
74 if($using_invites && $invite_id) {
75 q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
76 set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
79 $email_tpl = get_intltext_template("register_open_eml.tpl");
80 $email_tpl = replace_macros($email_tpl, array(
81 '$sitename' => $a->config['sitename'],
82 '$siteurl' => $a->get_baseurl(),
83 '$username' => $user['username'],
84 '$email' => $user['email'],
85 '$password' => $result['password'],
86 '$uid' => $user['uid'] ));
88 $res = mail($user['email'], sprintf(t('Registration details for %s'), $a->config['sitename']),
90 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
91 . 'Content-type: text/plain; charset=UTF-8' . "\n"
92 . 'Content-transfer-encoding: 8bit' );
96 info( t('Registration successful. Please check your email for further instructions.') . EOL ) ;
100 notice( t('Failed to send email message. Here is the message that failed.') . $email_tpl . EOL );
103 elseif($a->config['register_policy'] == REGISTER_APPROVE) {
104 if(! strlen($a->config['admin_email'])) {
105 notice( t('Your registration can not be processed.') . EOL);
109 $hash = random_string();
110 $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language` ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
112 dbesc(datetime_convert()),
113 intval($user['uid']),
114 dbesc($result['password']),
118 $r = q("SELECT `language` FROM `user` WHERE `email` = '%s' LIMIT 1",
119 dbesc($a->config['admin_email'])
122 push_lang($r[0]['language']);
126 if($using_invites && $invite_id) {
127 q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
128 set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
131 $email_tpl = get_intltext_template("register_verify_eml.tpl");
132 $email_tpl = replace_macros($email_tpl, array(
133 '$sitename' => $a->config['sitename'],
134 '$siteurl' => $a->get_baseurl(),
135 '$username' => $user['username'],
136 '$email' => $user['email'],
137 '$password' => $result['password'],
138 '$uid' => $user['uid'],
142 $res = mail($a->config['admin_email'], sprintf(t('Registration request at %s'), $a->config['sitename']),
144 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
145 . 'Content-type: text/plain; charset=UTF-8' . "\n"
146 . 'Content-transfer-encoding: 8bit' );
151 info( t('Your registration is pending approval by the site owner.') . EOL ) ;
165 if(! function_exists('register_content')) {
166 function register_content(&$a) {
168 // logged in users can register others (people/pages/groups)
169 // even with closed registrations, unless specifically prohibited by site policy.
170 // 'block_extended_register' blocks all registrations, period.
172 $block = get_config('system','block_extended_register');
174 if(local_user() && ($block)) {
175 notice("Permission denied." . EOL);
179 if((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
180 notice("Permission denied." . EOL);
184 $max_dailies = intval(get_config('system','max_daily_registrations'));
186 $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
187 if($r && $r[0]['total'] >= $max_dailies) {
188 logger('max daily registrations exceeded.');
189 notice( t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL);
194 if(x($_SESSION,'theme'))
195 unset($_SESSION['theme']);
196 if(x($_SESSION,'mobile-theme'))
197 unset($_SESSION['mobile-theme']);
200 $username = ((x($_POST,'username')) ? $_POST['username'] : ((x($_GET,'username')) ? $_GET['username'] : ''));
201 $email = ((x($_POST,'email')) ? $_POST['email'] : ((x($_GET,'email')) ? $_GET['email'] : ''));
202 $openid_url = ((x($_POST,'openid_url')) ? $_POST['openid_url'] : ((x($_GET,'openid_url')) ? $_GET['openid_url'] : ''));
203 $nickname = ((x($_POST,'nickname')) ? $_POST['nickname'] : ((x($_GET,'nickname')) ? $_GET['nickname'] : ''));
204 $photo = ((x($_POST,'photo')) ? $_POST['photo'] : ((x($_GET,'photo')) ? hex2bin($_GET['photo']) : ''));
205 $invite_id = ((x($_POST,'invite_id')) ? $_POST['invite_id'] : ((x($_GET,'invite_id')) ? $_GET['invite_id'] : ''));
207 $noid = get_config('system','no_openid');
216 $oidhtml = '<label for="register-openid" id="label-register-openid" >$oidlabel</label><input type="text" maxlength="60" size="32" name="openid_url" class="openid" id="register-openid" value="$openid" >';
217 $fillwith = t("You may \x28optionally\x29 fill in this form via OpenID by supplying your OpenID and clicking 'Register'.");
218 $fillext = t('If you are not familiar with OpenID, please leave that field blank and fill in the rest of the items.');
219 $oidlabel = t("Your OpenID \x28optional\x29: ");
222 // I set this and got even more fake names than before...
224 $realpeople = ''; // t('Members of this network prefer to communicate with real people who use their real names.');
226 if(get_config('system','publish_all')) {
227 $profile_publish_reg = '<input type="hidden" name="profile_publish_reg" value="1" />';
230 $publish_tpl = get_markup_template("profile_publish.tpl");
231 $profile_publish = replace_macros($publish_tpl,array(
232 '$instance' => 'reg',
233 '$pubdesc' => t('Include your profile in member directory?'),
234 '$yes_selected' => ' checked="checked" ',
235 '$no_selected' => '',
236 '$str_yes' => t('Yes'),
244 $o = get_markup_template("register.tpl");
246 $arr = array('template' => $o);
248 call_hooks('register_form',$arr);
250 $o = $arr['template'];
252 $o = replace_macros($o, array(
253 '$oidhtml' => $oidhtml,
254 '$invitations' => get_config('system','invitation_only'),
255 '$invite_desc' => t('Membership on this site is by invitation only.'),
256 '$invite_label' => t('Your invitation ID: '),
257 '$invite_id' => $invite_id,
258 '$realpeople' => $realpeople,
259 '$regtitle' => t('Registration'),
260 '$registertext' =>((x($a->config,'register_text'))
261 ? '<div class="error-message">' . $a->config['register_text'] . '</div>'
263 '$fillwith' => $fillwith,
264 '$fillext' => $fillext,
265 '$oidlabel' => $oidlabel,
266 '$openid' => $openid_url,
267 '$namelabel' => t('Your Full Name ' . "\x28" . 'e.g. Joe Smith' . "\x29" . ': '),
268 '$addrlabel' => t('Your Email Address: '),
269 '$nickdesc' => t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'<strong>nickname@$sitename</strong>\'.'),
270 '$nicklabel' => t('Choose a nickname: '),
272 '$publish' => $profile_publish,
273 '$regbutt' => t('Register'),
274 '$username' => $username,
276 '$nickname' => $nickname,
277 '$license' => $license,
278 '$sitename' => $a->get_hostname()