3 function user_allow($hash) {
7 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
12 if(! count($register))
15 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
16 intval($register[0]['uid'])
22 $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
23 dbesc($register[0]['hash'])
27 $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d LIMIT 1",
28 intval($register[0]['uid'])
31 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
32 intval($user[0]['uid'])
34 if(count($r) && $r[0]['net-publish']) {
35 $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
36 if($url && strlen(get_config('system','directory_submit_url')))
37 proc_run('php',"include/directory.php","$url");
40 push_lang($register[0]['language']);
42 $email_tpl = get_intltext_template("register_open_eml.tpl");
43 $email_tpl = replace_macros($email_tpl, array(
44 '$sitename' => $a->config['sitename'],
45 '$siteurl' => $a->get_baseurl(),
46 '$username' => $user[0]['username'],
47 '$email' => $user[0]['email'],
48 '$password' => $register[0]['password'],
49 '$uid' => $user[0]['uid']
52 $res = mail($user[0]['email'], sprintf(t('Registration details for %s'), $a->config['sitename']),
54 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
55 . 'Content-type: text/plain; charset=UTF-8' . "\n"
56 . 'Content-transfer-encoding: 8bit' );
61 info( t('Account approved.') . EOL );
68 // This does not have to go through user_remove() and save the nickname
69 // permanently against re-registration, as the person was not yet
70 // allowed to have friends on this system
72 function user_deny($hash) {
74 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
78 if(! count($register))
81 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
82 intval($register[0]['uid'])
85 $r = q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1",
86 intval($register[0]['uid'])
88 $r = q("DELETE FROM `contact` WHERE `uid` = %d LIMIT 1",
89 intval($register[0]['uid'])
91 $r = q("DELETE FROM `profile` WHERE `uid` = %d LIMIT 1",
92 intval($register[0]['uid'])
95 $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
96 dbesc($register[0]['hash'])
98 notice( sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
103 function regmod_content(&$a) {
107 $_SESSION['return_url'] = $a->cmd;
110 info( t('Please login.') . EOL);
111 $o .= '<br /><br />' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
115 if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) {
116 notice( t('Permission denied.') . EOL);
128 if($cmd === 'deny') {
129 if (!user_deny($hash)) killme();
132 if($cmd === 'allow') {
133 if (!user_allow($hash)) killme();