3 function user_allow($hash) {
4 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
12 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
13 intval($register[0]['uid'])
19 $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
20 dbesc($register[0]['hash'])
24 $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d LIMIT 1",
25 intval($register[0]['uid'])
28 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
29 intval($user[0]['uid'])
31 if(count($r) && $r[0]['net-publish']) {
32 $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
33 if($url && strlen(get_config('system','directory_submit_url')))
34 proc_run('php',"include/directory.php","$url");
37 push_lang($register[0]['language']);
39 $email_tpl = get_intltext_template("register_open_eml.tpl");
40 $email_tpl = replace_macros($email_tpl, array(
41 '$sitename' => $a->config['sitename'],
42 '$siteurl' => $a->get_baseurl(),
43 '$username' => $user[0]['username'],
44 '$email' => $user[0]['email'],
45 '$password' => $register[0]['password'],
46 '$uid' => $user[0]['uid']
49 $res = mail($user[0]['email'], sprintf(t('Registration details for %s'), $a->config['sitename']),
51 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
52 . 'Content-type: text/plain; charset=UTF-8' . "\n"
53 . 'Content-transfer-encoding: 8bit' );
58 info( t('Account approved.') . EOL );
64 function user_deny($hash) {
66 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
70 if(! count($register))
73 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
74 intval($register[0]['uid'])
77 $r = q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1",
78 intval($register[0]['uid'])
80 $r = q("DELETE FROM `contact` WHERE `uid` = %d LIMIT 1",
81 intval($register[0]['uid'])
83 $r = q("DELETE FROM `profile` WHERE `uid` = %d LIMIT 1",
84 intval($register[0]['uid'])
87 $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
88 dbesc($register[0]['hash'])
90 notice( sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
95 function regmod_content(&$a) {
99 $_SESSION['return_url'] = $a->cmd;
102 info( t('Please login.') . EOL);
103 $o .= '<br /><br />' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
107 if(!is_site_admin()) {
108 notice( t('Permission denied.') . EOL);
120 if($cmd === 'deny') {
121 if (!user_deny($hash)) killme();
124 if($cmd === 'allow') {
125 if (!user_allow($hash)) killme();