| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | $todo = $db->getRow('SELECT id_todo, param, id, date FROM todo WHERE id=? AND robot=? AND status=?', array($url_id, 'send_password', 'doing')); |
|---|
| 26 | error_log('todo[id]: '.$todo['id']); |
|---|
| 27 | if(isset($todo['id'])) |
|---|
| 28 | { |
|---|
| 29 | if($todo['date']>time()-3600) |
|---|
| 30 | if( $user =& $db->getRow('SELECT id, login, fname, lname, status FROM user WHERE id=?', array($todo['id'])) ) |
|---|
| 31 | { |
|---|
| 32 | session_destroy(); |
|---|
| 33 | |
|---|
| 34 | session_set_save_handler ('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc'); |
|---|
| 35 | session_start(); |
|---|
| 36 | |
|---|
| 37 | $_SESSION['old_password'] = 1; |
|---|
| 38 | |
|---|
| 39 | $_SESSION['status'] = 'member'; |
|---|
| 40 | |
|---|
| 41 | srand(time()); |
|---|
| 42 | $SecID = md5(rand(1,10000000)); |
|---|
| 43 | setcookie('SecID', $SecID, time()+31536000, '/'); |
|---|
| 44 | $_SESSION['SecID'] = $SecID; |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | $_SESSION['my_id'] = $user['id']; |
|---|
| 48 | $_SESSION['my_login'] = $user['login']; |
|---|
| 49 | $_SESSION['my_fname'] = $user['fname']; |
|---|
| 50 | $_SESSION['my_lname'] = $user['lname']; |
|---|
| 51 | if($user['status']=='jail') |
|---|
| 52 | { |
|---|
| 53 | session_unset(); |
|---|
| 54 | session_destroy(); |
|---|
| 55 | header('Location: /pub/join'); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | $_SESSION['my_status'] = $user['status']; |
|---|
| 59 | $_SESSION['my_ip'] = $_SERVER['REMOTE_ADDR']; |
|---|
| 60 | |
|---|
| 61 | $_SESSION['my_photo'] = build_image_url($user['id']); |
|---|
| 62 | |
|---|
| 63 | $cache_user = get_cache_user_info($user['id'], 'country, friends_id, communities_id'); |
|---|
| 64 | $_SESSION['my_country'] = $cache_user['country']; |
|---|
| 65 | $_SESSION['my_friends_id'] = $cache_user['friends_id']; |
|---|
| 66 | $_SESSION['my_communities_id'] = $cache_user['communities_id']; |
|---|
| 67 | |
|---|
| 68 | $_SESSION['nb_new_messages'] = $db->getOne('SELECT COUNT(id_mess) FROM message WHERE id=? AND flag=? AND box=?', array($_SESSION['my_id'], 'new', 'inbox')); |
|---|
| 69 | $_SESSION['nb_new_messages_timestamp'] = time(); |
|---|
| 70 | |
|---|
| 71 | $db->query('UPDATE user SET last_visite=? WHERE id=?', array(time(), $_SESSION['my_id']) ); |
|---|
| 72 | $db->query('UPDATE todo SET status=? WHERE robot=? AND id=? AND status=?', array('done', 'send_password', $user['id'], 'doing')); |
|---|
| 73 | |
|---|
| 74 | header('Location: /my/password'); |
|---|
| 75 | } |
|---|
| 76 | else |
|---|
| 77 | { |
|---|
| 78 | $db->query('DELETE FROM todo WHERE robot=? AND id=?', array('send_password', $todo['id'])); |
|---|
| 79 | header('Location: /error/bad_link/nouser'); |
|---|
| 80 | } |
|---|
| 81 | else |
|---|
| 82 | { |
|---|
| 83 | $db->query('DELETE FROM todo WHERE robot=? AND id=?', array('send_password', $todo['id'])); |
|---|
| 84 | header('Location: /error/bad_link/date_expire'); |
|---|
| 85 | } |
|---|
| 86 | } |
|---|
| 87 | else |
|---|
| 88 | { |
|---|
| 89 | header('Location: /error/bad_link/not_found'); |
|---|
| 90 | } |
|---|
| 91 | ?> |
|---|
| 92 | |
|---|