root/trunk/actions/new/record.action.php

Revision 9, 5.2 KB (checked in by alexx, 7 years ago)

#12 resolu (nick non enregistré dans la table de cache)

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
26error_log('NEW: '.print_r($_POST, true));
27
28$_POST['fname']=trim(stripslashes($_POST['fname']));
29$_POST['lname']=trim(stripslashes($_POST['lname']));
30$_POST['nick']=trim(stripslashes($_POST['nick']));
31
32
33if(strlen($_POST['fname'])>0 &&
34   strlen($_POST['lname'])>0 &&
35   $_POST['contact']['country'] != '(null)' &&
36   strlen($_POST['general']['gender'])>0 &&
37   valid_email($_POST['contact']['email']) )
38{
39    $values['user']['fname'] = $_POST['fname'];
40    $values['user']['lname'] = $_POST['lname'];
41    $values['user']['nick'] = $_POST['nick'];
42    $values['user']['status'] = 'ok';
43    if($_SESSION['6nergies_url'])
44        $_POST['professional']['6nergies_url'] = $_SESSION['6nergies_url'];
45    $access = $_POST['access'];
46
47    unset($_POST['fname']);
48    unset($_POST['lname']);
49    unset($_POST['nick']);
50    unset($_POST['access']);
51    unset($_POST['photo']);
52   
53
54    foreach($_POST as $key=>$value)
55        $values['user_'.$key] = $value;
56
57
58    foreach($values as $t_name=>$t_values)
59    {
60        foreach(array_keys($table_fields[$t_name]) as $key)
61        {
62            if(array_key_exists($key, $t_values) )
63            {
64                $value = "";
65                if(is_array($t_values[$key]) && array_key_exists('Day', $t_values[$key]) && array_key_exists('Month', $t_values[$key]) && array_key_exists('Year', $t_values[$key]) )
66                    $value = $t_values[$key]['Year'].'-'.$t_values[$key]['Month'].'-'.$t_values[$key]['Day'];
67                elseif( is_array($t_values[$key]) )
68                    $value = implode(",", $t_values[$key]);
69                elseif( $t_values[$key] == "(null)" || $t_values[$key] == "" || $t_values[$key] == "http://")
70                    $value = NULL;
71                else
72                    $value = $t_values[$key];
73
74                if(is_null($value))
75                    $update_values[$key] = NULL;
76                else
77                    $update_values[$key] = stripslashes($value);
78            }
79        }
80
81        $result =& $db->autoExecute($t_name, $update_values, DB_AUTOQUERY_UPDATE, "id='".$_SESSION['my_id']."'");
82        if (DB::isError($result)) {
83            error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' '.$result->getMessage());
84        }
85        unset($update_values);
86    }
87
88    /******************* cache DB ********************************/
89    $cache_data = array(
90          'fname' => stripslashes($values['user']['fname']),
91          'lname' => stripslashes($values['user']['lname']),
92          'nick' => stripslashes($values['user']['nick']),
93          'gender' => $values['user_general']['gender'],
94          'country' => $values['user_contact']['country'],
95          'relationship_status' => $values['user_general']['relationship_status'],
96                  'fname_sndex' => $db->getOne('SELECT SOUNDEX(?)', stripslashes($values['user']['fname'])),
97                'lname_sndex' => $db->getOne('SELECT SOUNDEX(?)', stripslashes($values['user']['lname']))
98          );
99
100    if($values['user_general']['here_for'])
101        $cache_data['here_for'] = implode(',', $values['user_general']['here_for']);
102   
103
104    $result =& $db->autoExecute('cache_user', $cache_data, DB_AUTOQUERY_UPDATE, "id='".$_SESSION['my_id']."'");
105
106    if (DB::isError($result)) {
107        error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' '.$result->getUserInfo());
108    }
109    /******************************************************************/
110
111    $_SESSION['my_fname'] = stripslashes($values['user']['fname']);
112    $_SESSION['my_lname'] = stripslashes($values['user']['lname']);
113    $_SESSION['status'] = 'member';
114    $_SESSION['my_status'] = 'ok';
115   
116    $cache_user = get_cache_user_info($_SESSION['my_id'], 'country, friends_id, communities_id');
117    $_SESSION['my_country'] = $cache_user['country'];
118    $_SESSION['my_friends_id'] = $cache_user['friends_id'];
119    $_SESSION['my_communities_id'] = $cache_user['communities_id'];
120
121    $_SESSION['nb_new_messages'] = $db->getOne('SELECT COUNT(id_mess) FROM message WHERE id=? AND flag=? AND box=?', array($_SESSION['my_id'], 'new', 'inbox'));
122    $_SESSION['nb_new_messages_timestamp'] = time();
123    $db->query('UPDATE user SET last_visite=?, status=? WHERE id=?', array(time(), 'ok', $_SESSION['my_id'] ));
124
125
126    set_acccess_list($_SESSION['my_id'], $access);
127
128    upload_image($_FILES, 'photo', $_SESSION['my_id'], NULL, BASEPATH, "/photos", true"/photos/thumb", array(246,255,241));
129
130    header('Location: /my');
131}
132else
133{
134    $_SESSION['error']['title'] = _('Form problem');
135    $_SESSION['error']['msg'] = _('The submited form is incorrect').".\n"._('You must enter a valid first name, last name, gender and country to validate your registration');
136    header('Location: /new/profile');
137}
138
139?>
Note: See TracBrowser for help on using the browser.