~ubuntu-branches/ubuntu/maverick/ilohamail/maverick

« back to all changes in this revision

Viewing changes to IlohaMail/include/session_auth.DB.inc

  • Committer: Bazaar Package Importer
  • Author(s): Joerg Jaspert
  • Date: 2004-02-04 13:44:37 UTC
  • Revision ID: james.westby@ubuntu.com-20040204134437-kz8j3ui2qa7oq8z2
Tags: upstream-0.8.12
ImportĀ upstreamĀ versionĀ 0.8.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/////////////////////////////////////////////////////////
 
3
//      
 
4
//      include/session_auth.DB.inc
 
5
//
 
6
//      (C)Copyright 2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
 
7
//
 
8
//      This file is part of IlohaMail, and released under GPL.
 
9
//      See COPYING, or http://www.fsf.org/copyleft/gpl.html
 
10
//
 
11
/////////////////////////////////////////////////////////
 
12
/********************************************************
 
13
 
 
14
        PURPOSE:
 
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
 
21
        PRE-CONDITIONS:
 
22
                $user - Session ID
 
23
        POST-CONDITIONS:
 
24
        COMMENTS:
 
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.
 
27
 
 
28
********************************************************/
 
29
 
 
30
        include_once("../include/encryption.inc");
 
31
        
 
32
 
 
33
    $my_prefs = false;
 
34
    $my_colors = false;
 
35
    
 
36
    $dataID = 0;
 
37
 
 
38
        //connect to database
 
39
        include_once("../conf/db_conf.php");
 
40
        include_once("../include/idba.$DB_TYPE.inc");
 
41
        $db = new idba_obj;
 
42
        if ($db->connect()){
 
43
            //get session info
 
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"];
 
52
                                $port = $a["port"];
 
53
                $lastSend = $a["lastSend"];
 
54
                $numSent = $a["numSent"];
 
55
                                $userLevel = $a["userLevel"];
 
56
                                $inTime = $a["inTime"];
 
57
                $session_dataID = $dataID;
 
58
                                
 
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'");
 
63
                                }
 
64
                        }else{
 
65
                                echo "Invalid session ID: $user<br>\n";
 
66
                        }
 
67
            
 
68
            //get prefs
 
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;
 
73
            }
 
74
 
 
75
            //get colors
 
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);
 
79
            }
 
80
        }else{
 
81
                echo "DB connection failed<br>\n";
 
82
        }
 
83
    
 
84
    //--------- END DB Specific stuff -----------
 
85
 
 
86
        $ipkey = GetSessionEncKey($user);
 
87
        
 
88
        $loginID = DecodeMessage($ipkey, $encLogin);
 
89
        $password = DecodeMessage($ipkey, $encPass);
 
90
        $host = DecodeMessage($ipkey, $encHost);
 
91
 
 
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);
 
96
 
 
97
        // Read prefs and colors
 
98
        if (!$my_colors) include_once($userPath."/colors.inc");
 
99
        if (!$my_prefs) include_once($userPath."/prefs.inc");
 
100
        
 
101
    }
 
102
    
 
103
    $my_charset=$my_prefs["charset"];
 
104
    
 
105
    if (($dataID==0)&&(!$do_not_die)){
 
106
        exit;
 
107
    }
 
108
?>
 
 
b'\\ No newline at end of file'