1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2006-01-15 13:49:29 +0000 (Sun, 15 Jan 2006) $ |
---|
10 | // | last modifier : $Author: nikrou $ |
---|
11 | // | revision : $Revision: 1005 $ |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | This program is free software; you can redistribute it and/or modify | |
---|
14 | // | it under the terms of the GNU General Public License as published by | |
---|
15 | // | the Free Software Foundation | |
---|
16 | // | | |
---|
17 | // | This program is distributed in the hope that it will be useful, but | |
---|
18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
20 | // | General Public License for more details. | |
---|
21 | // | | |
---|
22 | // | You should have received a copy of the GNU General Public License | |
---|
23 | // | along with this program; if not, write to the Free Software | |
---|
24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
25 | // | USA. | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | |
---|
28 | // retrieving connected user informations |
---|
29 | if (isset($_COOKIE['id'])) |
---|
30 | { |
---|
31 | $session_id = $_COOKIE['id']; |
---|
32 | $user['has_cookie'] = true; |
---|
33 | } |
---|
34 | else if (isset($_GET['id'])) |
---|
35 | { |
---|
36 | $session_id = $_GET['id']; |
---|
37 | $user['has_cookie'] = false; |
---|
38 | } |
---|
39 | else |
---|
40 | { |
---|
41 | $user['has_cookie'] = false; |
---|
42 | } |
---|
43 | |
---|
44 | if (isset($session_id) |
---|
45 | and ereg("^[0-9a-zA-Z]{".$conf['session_id_size']."}$", $session_id)) |
---|
46 | { |
---|
47 | $page['session_id'] = $session_id; |
---|
48 | $query = ' |
---|
49 | SELECT user_id,expiration,NOW() AS now |
---|
50 | FROM '.SESSIONS_TABLE.' |
---|
51 | WHERE id = \''.$page['session_id'].'\' |
---|
52 | ;'; |
---|
53 | $result = pwg_query($query); |
---|
54 | if (mysql_num_rows($result) > 0) |
---|
55 | { |
---|
56 | $row = mysql_fetch_array($result); |
---|
57 | if (strnatcmp($row['expiration'], $row['now']) < 0) |
---|
58 | { |
---|
59 | // deletion of the session from the database, because it is |
---|
60 | // out-of-date |
---|
61 | $delete_query = ' |
---|
62 | DELETE FROM '.SESSIONS_TABLE.' |
---|
63 | WHERE id = \''.$page['session_id'].'\' |
---|
64 | ;'; |
---|
65 | pwg_query($delete_query); |
---|
66 | } |
---|
67 | else |
---|
68 | { |
---|
69 | $user['id'] = $row['user_id']; |
---|
70 | $user['is_the_guest'] = false; |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | if (!isset($user['id'])) |
---|
75 | { |
---|
76 | $user['id'] = $conf['guest_id']; |
---|
77 | $user['is_the_guest'] = true; |
---|
78 | } |
---|
79 | |
---|
80 | // using Apache authentication override the above user search |
---|
81 | if ($conf['apache_authentication'] and isset($_SERVER['REMOTE_USER'])) |
---|
82 | { |
---|
83 | if (!($user['id'] = get_userid($_SERVER['REMOTE_USER']))) |
---|
84 | { |
---|
85 | register_user($_SERVER['REMOTE_USER'], '', ''); |
---|
86 | $user['id'] = get_userid($_SERVER['REMOTE_USER']); |
---|
87 | } |
---|
88 | |
---|
89 | $user['is_the_guest'] = false; |
---|
90 | } |
---|
91 | |
---|
92 | $use_cache = (defined('IN_ADMIN') and IN_ADMIN) ? false : true; |
---|
93 | $user = array_merge($user, getuserdata($user['id'], $use_cache)); |
---|
94 | |
---|
95 | // properties of user guest are found in the configuration |
---|
96 | if ($user['is_the_guest']) |
---|
97 | { |
---|
98 | $user['template'] = $conf['default_template']; |
---|
99 | $user['nb_image_line'] = $conf['nb_image_line']; |
---|
100 | $user['nb_line_page'] = $conf['nb_line_page']; |
---|
101 | $user['language'] = $conf['default_language']; |
---|
102 | $user['maxwidth'] = $conf['default_maxwidth']; |
---|
103 | $user['maxheight'] = $conf['default_maxheight']; |
---|
104 | $user['recent_period'] = $conf['recent_period']; |
---|
105 | $user['expand'] = $conf['auto_expand']; |
---|
106 | $user['show_nb_comments'] = $conf['show_nb_comments']; |
---|
107 | } |
---|
108 | |
---|
109 | // calculation of the number of picture to display per page |
---|
110 | $user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page']; |
---|
111 | ?> |
---|