]> git.mxchange.org Git - friendica.git/blob - mod/regmod.php
verified registrations working
[friendica.git] / mod / regmod.php
1 <?php
2
3
4
5 function regmod_content(&$a) {
6
7         if(! local_user()) {
8                 notice( t('Please login.') . EOL);
9                 $o = login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
10                 return $o;
11         }
12
13         if($a->argc != 3)
14                 killme();
15
16         $cmd = $a->argv[1];
17         $hash = $a->argv[2];
18
19
20         $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
21                 dbesc($hash)
22         );
23
24
25         if(! count($register))
26                 killme();
27
28         if($cmd == 'deny') {
29
30                 $r = q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1",
31                         intval($register[0]['uid'])
32                 );
33                 $r = q("DELETE FROM `contact` WHERE `uid` = %d",
34                         intval($register[0]['uid'])
35                 ); 
36                 $r = q("DELETE FROM `profile` WHERE `uid` = %d",
37                         intval($register[0]['uid'])
38                 ); 
39
40                 $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
41                         dbesc($register[0]['hash'])
42                 );
43                 notice( t('Registration revoked.') . EOL);
44                 return;
45
46         }
47
48         if($cmd == 'allow') {
49
50                 $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
51                         intval($register[0]['uid'])
52                 );
53                 if(! count($user))
54                         killme();
55
56                 $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
57                         dbesc($register[0]['hash'])
58                 );
59
60
61                 $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d LIMIT 1",
62                         intval($register[0]['uid'])
63                 );
64                 
65                 $email_tpl = file_get_contents("view/register_open_eml.tpl");
66                 $email_tpl = replace_macros($email_tpl, array(
67                                 '$sitename' => $a->config['sitename'],
68                                 '$siteurl' =>  $a->get_baseurl(),
69                                 '$username' => $user[0]['username'],
70                                 '$email' => $user[0]['email'],
71                                 '$password' => $register[0]['password'],
72                                 '$uid' => $user[0]['uid']
73                 ));
74
75                 $res = mail($user[0]['email'], t('Registration details for '). $a->config['sitename'],
76                         $email_tpl,'From: ' . t('Administrator@') . $_SERVER[SERVER_NAME] );
77
78
79                 if($res) {
80                         notice( t('Account approved.') . EOL );
81                         return;
82                 }
83
84         }
85 }