2
/////////////////////////////////////////////////////////
4
// include/session_auth.DB.inc
6
// (C)Copyright 2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
8
// This file is part of IlohaMail, and released under GPL.
9
// See COPYING, or http://www.fsf.org/copyleft/gpl.html
11
/////////////////////////////////////////////////////////
12
/********************************************************
15
1. Make sure session (pass as $user) is valid
16
2. Initialize $loginID variable, containing IMAP login ID.
17
3. Initialize $host variable, containing IMAP server name
18
4. Initialize $password variable, containing plain text password
19
5. Initialize $my_prefs variable, which should be an associated array containing user preferecnes
20
6. Initialize $my_colors variable, which should be an associated array containing user defined colors
25
All source files should include this file for session verification and user data initialization.
26
This file uses a DB backend for session management.
28
********************************************************/
30
include_once("../include/encryption.inc");
39
include_once("../conf/db_conf.php");
40
include_once("../include/idba.$DB_TYPE.inc");
44
$result = $db->query("select * from $DB_SESSIONS_TABLE where sid = '$user'");
45
if (($result) && ($db->num_rows($result)==1)){
46
$a = $db->fetch_row($result);
47
$encLogin = $a["login"];
48
$encPass = $a["password"];
49
$encHost = $a["host"];
50
$userPath = $a["path"];
51
$dataID = $a["dataID"];
53
$lastSend = $a["lastSend"];
54
$numSent = $a["numSent"];
55
$userLevel = $a["userLevel"];
56
$inTime = $a["inTime"];
57
$session_dataID = $dataID;
59
$ttl = time() - $inTime;
60
if ($STAY_LOGGED_IN && ($MAX_SESSION_TIME/10)<$ttl){
61
// if session time remaining is 10% of max session lifespan, update so we stay logged in
62
$db->query("UPDATE $DB_SESSIONS_TABLE SET inTime=".time()." WHERE sid='$user'");
65
echo "Invalid session ID: $user<br>\n";
69
if ((!empty($DB_PREFS_TABLE)) && ($dataID > 0)){
70
$r = $db->query("select * from $DB_PREFS_TABLE where id='$dataID'");
71
if (($r) && ($db->num_rows($r)==1)) $my_prefs = $db->fetch_row($r);
72
if ($port==110) $my_prefs["list_folders"] = 0;
76
if ((!empty($DB_COLORS_TABLE)) && ($dataID > 0)){
77
$r = $db->query("select * from $DB_COLORS_TABLE where id='$dataID'");
78
if (($r) && ($db->num_rows($r)==1)) $my_colors = $db->fetch_row($r);
81
echo "DB connection failed<br>\n";
84
//--------- END DB Specific stuff -----------
86
$ipkey = GetSessionEncKey($user);
88
$loginID = DecodeMessage($ipkey, $encLogin);
89
$password = DecodeMessage($ipkey, $encPass);
90
$host = DecodeMessage($ipkey, $encHost);
92
// If we're using FS backend for some things, check that out too
93
if (!empty($userPath)){
94
// Find path to user dir
95
$userPath = DecodeMessage($ipkey, $userPath);
97
// Read prefs and colors
98
if (!$my_colors) include_once($userPath."/colors.inc");
99
if (!$my_prefs) include_once($userPath."/prefs.inc");
103
$my_charset=$my_prefs["charset"];
105
if (($dataID==0)&&(!$do_not_die)){
b'\\ No newline at end of file'