root/trunk/responses/password.response.php

Revision 1, 3.3 KB (checked in by anonymous, 7 years ago)

initial import

Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
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'));
26error_log('todo[id]: '.$todo['id']);
27if(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}
87else
88{
89    header('Location: /error/bad_link/not_found');
90}
91?>
92
Note: See TracBrowser for help on using the browser.