2 LibreSSL - CAcert web application
3 Copyright (C) 2004-2008 CAcert Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 include_once("../includes/lib/general.php");
20 require_once("../includes/lib/l10n.php");
22 if($_SERVER['HTTP_HOST'] == $_SESSION['_config']['securehostname'] && $_SESSION['profile']['id'] > 0 && $_SESSION['profile']['loggedin'] != 0)
24 $uid = $_SESSION['profile']['id'];
25 $_SESSION['profile']['loggedin'] = 0;
26 $_SESSION['profile'] = "";
27 foreach($_SESSION as $key)
31 if(is_int($key) ||
is_string($key))
32 unset($_SESSION[$key]);
34 session_unregister($key);
37 $_SESSION['profile'] = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='$uid'"));
38 if($_SESSION['profile']['locked'] == 0)
39 $_SESSION['profile']['loggedin'] = 1;
41 unset($_SESSION['profile']);
44 if($_SERVER['HTTP_HOST'] == $_SESSION['_config']['securehostname'] && ($_SESSION['profile']['id'] == 0 ||
$_SESSION['profile']['loggedin'] == 0))
46 $user_id = get_user_id_from_cert($_SERVER['SSL_CLIENT_M_SERIAL'],
47 $_SERVER['SSL_CLIENT_I_DN_CN']);
51 $_SESSION['profile']['loggedin'] = 0;
52 $_SESSION['profile'] = "";
53 foreach($_SESSION as $key)
57 if(is_int($key) ||
is_string($key))
58 unset($_SESSION[$key]);
60 session_unregister($key);
63 $_SESSION['profile'] = mysql_fetch_assoc(mysql_query(
64 "select * from `users` where `id`='".$user_id."'"));
65 if($_SESSION['profile']['locked'] == 0)
66 $_SESSION['profile']['loggedin'] = 1;
68 unset($_SESSION['profile']);
70 $_SESSION['profile']['loggedin'] = 0;
71 $_SESSION['profile'] = "";
72 foreach($_SESSION as $key)
76 unset($_SESSION[$key]);
78 session_unregister($key);
81 unset($_SESSION['_config']['oldlocation']);
83 foreach($_GET as $key => $val)
85 if($_SESSION['_config']['oldlocation'])
86 $_SESSION['_config']['oldlocation'] .= "&";
88 $key = str_replace(array("\n", "\r"), '', $key);
89 $val = str_replace(array("\n", "\r"), '', $val);
90 $_SESSION['_config']['oldlocation'] .= "$key=$val";
92 $_SESSION['_config']['oldlocation'] = substr($_SERVER['SCRIPT_NAME'], 1)."?".$_SESSION['_config']['oldlocation'];
94 header("location: https://".$_SESSION['_config']['securehostname']."/index.php?id=4");
99 if($_SERVER['HTTP_HOST'] == $_SESSION['_config']['securehostname'] && ($_SESSION['profile']['id'] <= 0 ||
$_SESSION['profile']['loggedin'] == 0))
101 header("location: https://".$_SESSION['_config']['normalhostname']);
105 if($_SERVER['HTTP_HOST'] == $_SESSION['_config']['securehostname'] && $_SESSION['profile']['id'] > 0 && $_SESSION['profile']['loggedin'] > 0)
107 $query = "select sum(`points`) as `total` from `notary` where `to`='".$_SESSION['profile']['id']."' group by `to`";
108 $res = mysql_query($query);
109 $row = mysql_fetch_assoc($res);
110 $_SESSION['profile']['points'] = $row['total'];
112 if($_SESSION['profile']['language'] == "")
114 $query = "update `users` set `language`='".L10n
::get_translation()."'
115 where `id`='".$_SESSION['profile']['id']."'";
118 L10n
::set_translation($_SESSION['profile']['language']);
119 L10n
::init_gettext();
123 if(array_key_exists("id",$_REQUEST) && $_REQUEST['id'] == "logout")
125 $normalhost=$_SESSION['_config']['normalhostname'];
126 $_SESSION['profile']['loggedin'] = 0;
127 $_SESSION['profile'] = "";
128 foreach($_SESSION as $key => $value)
130 unset($_SESSION[$key]);
132 session_unregister($key);
135 header("location: https://".$normalhost."/index.php");
139 if($_SESSION['profile']['loggedin'] < 1)
141 unset($_SESSION['_config']['oldlocation']);
143 foreach($_REQUEST as $key => $val)
145 if($_SESSION['_config']['oldlocation'])
146 $_SESSION['_config']['oldlocation'] .= "&";
148 $key = str_replace(array("\n", "\r"), '', $key);
149 $val = str_replace(array("\n", "\r"), '', $val);
150 $_SESSION['_config']['oldlocation'] .= "$key=$val";
152 $_SESSION['_config']['oldlocation'] = substr($_SERVER['SCRIPT_NAME'], 1)."?".$_SESSION['_config']['oldlocation'];
153 $hostname=$_SERVER['HTTP_HOST'];
154 $hostname = str_replace(array("\n", "\r"), '', $hostname);
155 header("location: https://".$hostname."/index.php?id=4");