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 $engine = get_app()->get_template_engine();
45 get_app()->set_template_engine();
47 $email_tpl = get_intltext_template("register_open_eml.tpl");
48 $email_tpl = replace_macros($email_tpl, array(
49 '$sitename' => $a->config['sitename'],
50 '$siteurl' => $a->get_baseurl(),
51 '$username' => $user[0]['username'],
52 '$email' => $user[0]['email'],
53 '$password' => $register[0]['password'],
54 '$uid' => $user[0]['uid']
58 get_app()->set_template_engine($engine);
61 $res = mail($user[0]['email'], email_header_encode( sprintf(t('Registration details for %s'), $a->config['sitename']), 'UTF-8'),
63 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
64 . 'Content-type: text/plain; charset=UTF-8' . "\n"
65 . 'Content-transfer-encoding: 8bit' );
70 info( t('Account approved.') . EOL );
77 // This does not have to go through user_remove() and save the nickname
78 // permanently against re-registration, as the person was not yet
79 // allowed to have friends on this system
81 function user_deny($hash) {
83 $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
87 if(! count($register))
90 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
91 intval($register[0]['uid'])
94 $r = q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1",
95 intval($register[0]['uid'])
97 $r = q("DELETE FROM `contact` WHERE `uid` = %d LIMIT 1",
98 intval($register[0]['uid'])
100 $r = q("DELETE FROM `profile` WHERE `uid` = %d LIMIT 1",
101 intval($register[0]['uid'])
104 $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
105 dbesc($register[0]['hash'])
107 notice( sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
112 function regmod_content(&$a) {
116 $_SESSION['return_url'] = $a->cmd;
119 info( t('Please login.') . EOL);
120 $o .= '<br /><br />' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
124 if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) {
125 notice( t('Permission denied.') . EOL);
137 if($cmd === 'deny') {
138 if (!user_deny($hash)) killme();
141 if($cmd === 'allow') {
142 if (!user_allow($hash)) killme();