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.

113 lines
2.7 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. <?php
  2. function manage_post(&$a) {
  3. if(! local_user())
  4. return;
  5. $uid = local_user();
  6. $orig_record = $a->user;
  7. if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
  8. $r = q("select * from user where uid = %d limit 1",
  9. intval($_SESSION['submanage'])
  10. );
  11. if(count($r)) {
  12. $uid = intval($r[0]['uid']);
  13. $orig_record = $r[0];
  14. }
  15. }
  16. $r = q("select * from manage where uid = %d",
  17. intval($uid)
  18. );
  19. $submanage = $r;
  20. $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
  21. if(! $identity)
  22. return;
  23. $limited_id = 0;
  24. $original_id = $uid;
  25. if(count($submanage)) {
  26. foreach($submanage as $m) {
  27. if($identity == $m['mid']) {
  28. $limited_id = $m['mid'];
  29. break;
  30. }
  31. }
  32. }
  33. if($limited_id) {
  34. $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
  35. intval($limited_id)
  36. );
  37. }
  38. else {
  39. $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
  40. intval($identity),
  41. dbesc($orig_record['email']),
  42. dbesc($orig_record['password'])
  43. );
  44. }
  45. if(! count($r))
  46. return;
  47. unset($_SESSION['authenticated']);
  48. unset($_SESSION['uid']);
  49. unset($_SESSION['visitor_id']);
  50. unset($_SESSION['administrator']);
  51. unset($_SESSION['cid']);
  52. unset($_SESSION['theme']);
  53. unset($_SESSION['page_flags']);
  54. unset($_SESSION['return_url']);
  55. if(x($_SESSION,'submanage'))
  56. unset($_SESSION['submanage']);
  57. require_once('include/security.php');
  58. authenticate_success($r[0],true,true);
  59. if($limited_id)
  60. $_SESSION['submanage'] = $original_id;
  61. goaway($a->get_baseurl(true) . '/profile/' . $a->user['nickname']);
  62. // NOTREACHED
  63. }
  64. function manage_content(&$a) {
  65. if(! local_user()) {
  66. notice( t('Permission denied.') . EOL);
  67. return;
  68. }
  69. $o = '<h3>' . t('Manage Identities and/or Pages') . '</h3>';
  70. $o .= '<div id="identity-manage-desc">' . t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions') . '</div>';
  71. $o .= '<div id="identity-manage-choose">' . t('Select an identity to manage: ') . '</div>';
  72. $o .= '<div id="identity-selector-wrapper">' . "\r\n";
  73. $o .= '<form action="manage" method="post" >' . "\r\n";
  74. $o .= '<select name="identity" size="4">' . "\r\n";
  75. foreach($a->identities as $rr) {
  76. $selected = (($rr['nickname'] === $a->user['nickname']) ? ' selected="selected" ' : '');
  77. $o .= '<option ' . $selected . 'value="' . $rr['uid'] . '">' . $rr['username'] . ' (' . $rr['nickname'] . ')</option>' . "\r\n";
  78. }
  79. $o .= '</select>' . "\r\n";
  80. $o .= '<div id="identity-select-break"></div>' . "\r\n";
  81. $o .= '<input id="identity-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div></form>' . "\r\n";
  82. return $o;
  83. }