Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

128 lines
2.8 KiB

  1. <?php
  2. function user_allow($hash) {
  3. $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
  4. dbesc($hash)
  5. );
  6. if(! count($register))
  7. return false;
  8. $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
  9. intval($register[0]['uid'])
  10. );
  11. if(! count($user))
  12. killme();
  13. $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
  14. dbesc($register[0]['hash'])
  15. );
  16. $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d LIMIT 1",
  17. intval($register[0]['uid'])
  18. );
  19. $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
  20. intval($user[0]['uid'])
  21. );
  22. if(count($r) && $r[0]['net-publish']) {
  23. $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
  24. if($url && strlen(get_config('system','directory_submit_url')))
  25. proc_run('php',"include/directory.php","$url");
  26. }
  27. push_lang($register[0]['language']);
  28. $email_tpl = get_intltext_template("register_open_eml.tpl");
  29. $email_tpl = replace_macros($email_tpl, array(
  30. '$sitename' => $a->config['sitename'],
  31. '$siteurl' => $a->get_baseurl(),
  32. '$username' => $user[0]['username'],
  33. '$email' => $user[0]['email'],
  34. '$password' => $register[0]['password'],
  35. '$uid' => $user[0]['uid']
  36. ));
  37. $res = mail($user[0]['email'], sprintf(t('Registration details for %s'), $a->config['sitename']),
  38. $email_tpl,
  39. 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
  40. . 'Content-type: text/plain; charset=UTF-8' . "\n"
  41. . 'Content-transfer-encoding: 8bit' );
  42. pop_lang();
  43. if($res) {
  44. info( t('Account approved.') . EOL );
  45. return true;
  46. }
  47. }
  48. function user_deny($hash) {
  49. $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
  50. dbesc($hash)
  51. );
  52. if(! count($register))
  53. return false;
  54. $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
  55. intval($register[0]['uid'])
  56. );
  57. $r = q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1",
  58. intval($register[0]['uid'])
  59. );
  60. $r = q("DELETE FROM `contact` WHERE `uid` = %d LIMIT 1",
  61. intval($register[0]['uid'])
  62. );
  63. $r = q("DELETE FROM `profile` WHERE `uid` = %d LIMIT 1",
  64. intval($register[0]['uid'])
  65. );
  66. $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1",
  67. dbesc($register[0]['hash'])
  68. );
  69. notice( sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
  70. return true;
  71. }
  72. function regmod_content(&$a) {
  73. global $lang;
  74. $_SESSION['return_url'] = $a->cmd;
  75. if(! local_user()) {
  76. info( t('Please login.') . EOL);
  77. $o .= '<br /><br />' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
  78. return $o;
  79. }
  80. if(!is_site_admin()) {
  81. notice( t('Permission denied.') . EOL);
  82. return '';
  83. }
  84. if($a->argc != 3)
  85. killme();
  86. $cmd = $a->argv[1];
  87. $hash = $a->argv[2];
  88. if($cmd === 'deny') {
  89. if (!user_deny($hash)) killme();
  90. }
  91. if($cmd === 'allow') {
  92. if (!user_allow($hash)) killme();
  93. }
  94. }