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.
 
 
 
 
 
 

134 lines
2.7 KiB

  1. <?php
  2. require_once('include/enotify.php');
  3. require_once('include/user.php');
  4. function user_allow($hash) {
  5. $a = get_app();
  6. $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
  7. dbesc($hash)
  8. );
  9. if(! count($register))
  10. return false;
  11. $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
  12. intval($register[0]['uid'])
  13. );
  14. if(! count($user))
  15. killme();
  16. $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
  17. dbesc($register[0]['hash'])
  18. );
  19. $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d",
  20. intval($register[0]['uid'])
  21. );
  22. $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
  23. intval($user[0]['uid'])
  24. );
  25. if(count($r) && $r[0]['net-publish']) {
  26. $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
  27. if($url && strlen(get_config('system','directory_submit_url')))
  28. proc_run('php',"include/directory.php","$url");
  29. }
  30. push_lang($register[0]['language']);
  31. send_register_open_eml(
  32. $user[0]['email'],
  33. $a->config['sitename'],
  34. $a->get_baseurl(),
  35. $user[0]['username'],
  36. $register[0]['password']);
  37. pop_lang();
  38. if($res) {
  39. info( t('Account approved.') . EOL );
  40. return true;
  41. }
  42. }
  43. // This does not have to go through user_remove() and save the nickname
  44. // permanently against re-registration, as the person was not yet
  45. // allowed to have friends on this system
  46. function user_deny($hash) {
  47. $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
  48. dbesc($hash)
  49. );
  50. if(! count($register))
  51. return false;
  52. $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
  53. intval($register[0]['uid'])
  54. );
  55. $r = q("DELETE FROM `user` WHERE `uid` = %d",
  56. intval($register[0]['uid'])
  57. );
  58. $r = q("DELETE FROM `contact` WHERE `uid` = %d",
  59. intval($register[0]['uid'])
  60. );
  61. $r = q("DELETE FROM `profile` WHERE `uid` = %d",
  62. intval($register[0]['uid'])
  63. );
  64. $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
  65. dbesc($register[0]['hash'])
  66. );
  67. notice( sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
  68. return true;
  69. }
  70. function regmod_content(&$a) {
  71. global $lang;
  72. $_SESSION['return_url'] = $a->cmd;
  73. if(! local_user()) {
  74. info( t('Please login.') . EOL);
  75. $o .= '<br /><br />' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
  76. return $o;
  77. }
  78. if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) {
  79. notice( t('Permission denied.') . EOL);
  80. return '';
  81. }
  82. if($a->argc != 3)
  83. killme();
  84. $cmd = $a->argv[1];
  85. $hash = $a->argv[2];
  86. if($cmd === 'deny') {
  87. user_deny($hash);
  88. goaway("/admin/users/");
  89. killme();
  90. }
  91. if($cmd === 'allow') {
  92. user_allow($hash);
  93. goaway("/admin/users/");
  94. killme();
  95. }
  96. }