4 function manage_post(&$a) {
6 if(! local_user() || ! is_array($a->identities))
9 $identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
13 $r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
15 dbesc($a->user['email']),
16 dbesc($a->user['password'])
22 unset($_SESSION['authenticated']);
23 unset($_SESSION['uid']);
24 unset($_SESSION['visitor_id']);
25 unset($_SESSION['administrator']);
26 unset($_SESSION['cid']);
27 unset($_SESSION['theme']);
28 unset($_SESSION['page_flags']);
31 $_SESSION['uid'] = $r[0]['uid'];
32 $_SESSION['theme'] = $r[0]['theme'];
33 $_SESSION['authenticated'] = 1;
34 $_SESSION['page_flags'] = $r[0]['page-flags'];
35 $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname'];
37 notice( sprintf( t("Welcome back %s") , $r[0]['username']) . EOL);
40 if(strlen($a->user['timezone'])) {
41 date_default_timezone_set($a->user['timezone']);
42 $a->timezone = $a->user['timezone'];
45 $r = q("SELECT `uid`,`username` FROM `user` WHERE `password` = '%s' AND `email` = '%s'",
46 dbesc($a->user['password']),
47 dbesc($a->user['email'])
52 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
53 intval($_SESSION['uid']));
56 $a->cid = $r[0]['id'];
57 $_SESSION['cid'] = $a->cid;
60 q("UPDATE `user` SET `login_date` = '%s' WHERE `uid` = %d LIMIT 1",
61 dbesc(datetime_convert()),
62 intval($_SESSION['uid'])
65 header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] .'"');
66 goaway($a->get_baseurl() . '/profile/' . $a->user['nickname']);
72 function manage_content(&$a) {
74 if(! local_user() || ! is_array($a->identities)) {
75 notice( t('Permission denied.') . EOL);
79 $r = q("SELECT * FROM `user` WHERE `email` = '%s' AND `password` = '%s'",
80 dbesc($a->user['email']),
81 dbesc($a->user['password'])
87 $o = '<h3>' . t('Manage Identities and/or Pages') . '</h3>';
90 $o .= '<div id="identity-manage-desc">' . t("\x28Toggle between different identities or community/group pages which share your account details.\x29") . '</div>';
92 $o .= '<div id="identity-manage-choose">' . t('Select an identity to manage: ') . '</div>';
94 $o .= '<div id="identity-selector-wrapper">' . "\r\n";
95 $o .= '<form action="manage" method="post" >' . "\r\n";
96 $o .= '<select name="identity" size="4">' . "\r\n";
99 $selected = (($rr['nickname'] === $a->user['nickname']) ? ' selected="selected" ' : '');
100 $o .= '<option ' . $selected . 'value="' . $rr['uid'] . '">' . $rr['username'] . ' (' . $rr['nickname'] . ')</option>' . "\r\n";
103 $o .= '</select>' . "\r\n";
104 $o .= '<div id="identity-select-break"></div>' . "\r\n";
106 $o .= '<input id="identity-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div></form>' . "\r\n";