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 );
67 function user_deny($hash) {
69 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
73 if(! count($register))
76 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
77 intval($register[0]['uid'])
80 $r = q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1",
81 intval($register[0]['uid'])
83 $r = q("DELETE FROM `contact` WHERE `uid` = %d LIMIT 1",
84 intval($register[0]['uid'])
86 $r = q("DELETE FROM `profile` WHERE `uid` = %d LIMIT 1",
87 intval($register[0]['uid'])
90 $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
91 dbesc($register[0]['hash'])
93 notice( sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
98 function regmod_content(&$a) {
102 $_SESSION['return_url'] = $a->cmd;
105 info( t('Please login.') . EOL);
106 $o .= '<br /><br />' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
110 if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) {
111 notice( t('Permission denied.') . EOL);
123 if($cmd === 'deny') {
124 if (!user_deny($hash)) killme();
127 if($cmd === 'allow') {
128 if (!user_allow($hash)) killme();