3 require_once('include/email.php');
5 function user_allow($hash) {
9 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
14 if(! count($register))
17 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
18 intval($register[0]['uid'])
24 $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
25 dbesc($register[0]['hash'])
29 $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d LIMIT 1",
30 intval($register[0]['uid'])
33 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
34 intval($user[0]['uid'])
36 if(count($r) && $r[0]['net-publish']) {
37 $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
38 if($url && strlen(get_config('system','directory_submit_url')))
39 proc_run('php',"include/directory.php","$url");
42 push_lang($register[0]['language']);
44 $email_tpl = get_intltext_template("register_open_eml.tpl");
45 $email_tpl = replace_macros($email_tpl, array(
46 '$sitename' => $a->config['sitename'],
47 '$siteurl' => $a->get_baseurl(),
48 '$username' => $user[0]['username'],
49 '$email' => $user[0]['email'],
50 '$password' => $register[0]['password'],
51 '$uid' => $user[0]['uid']
54 $res = mail($user[0]['email'], email_header_encode( sprintf(t('Registration details for %s'), $a->config['sitename']), 'UTF-8'),
56 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
57 . 'Content-type: text/plain; charset=UTF-8' . "\n"
58 . 'Content-transfer-encoding: 8bit' );
63 info( t('Account approved.') . EOL );
70 // This does not have to go through user_remove() and save the nickname
71 // permanently against re-registration, as the person was not yet
72 // allowed to have friends on this system
74 function user_deny($hash) {
76 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
80 if(! count($register))
83 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
84 intval($register[0]['uid'])
87 $r = q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1",
88 intval($register[0]['uid'])
90 $r = q("DELETE FROM `contact` WHERE `uid` = %d LIMIT 1",
91 intval($register[0]['uid'])
93 $r = q("DELETE FROM `profile` WHERE `uid` = %d LIMIT 1",
94 intval($register[0]['uid'])
97 $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
98 dbesc($register[0]['hash'])
100 notice( sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
105 function regmod_content(&$a) {
109 $_SESSION['return_url'] = $a->cmd;
112 info( t('Please login.') . EOL);
113 $o .= '<br /><br />' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
117 if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) {
118 notice( t('Permission denied.') . EOL);
130 if($cmd === 'deny') {
131 if (!user_deny($hash)) killme();
134 if($cmd === 'allow') {
135 if (!user_allow($hash)) killme();