~cruzjbishop/anelectron/trunk

« back to all changes in this revision

Viewing changes to main/logout.php

  • Committer: Cruz Julian Bishop
  • Date: 2012-03-18 22:16:46 UTC
  • Revision ID: cruzjbishop@gmail.com-20120318221646-se8p54bd2g7i936n
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
//////////////////////////////////////////////////////////////
 
4
//===========================================================
 
5
// logout.php
 
6
//===========================================================
 
7
// AEF : Advanced Electron Forum
 
8
// Version : 1.0.9
 
9
// Inspired by Pulkit and taken over by Electron
 
10
// ----------------------------------------------------------
 
11
// Started by: Electron, Ronak Gupta, Pulkit Gupta
 
12
// Date:       23rd Jan 2006
 
13
// Time:       15:00 hrs
 
14
// Site:       http://www.anelectron.com/ (Anelectron)
 
15
// ----------------------------------------------------------
 
16
// Please Read the Terms of use at http://www.anelectron.com
 
17
// ----------------------------------------------------------
 
18
//===========================================================
 
19
// (C)AEF Group All Rights Reserved.
 
20
//===========================================================
 
21
//////////////////////////////////////////////////////////////
 
22
 
 
23
 
 
24
if (!defined('AEF')) {
 
25
 
 
26
    die('Hacking Attempt');
 
27
}
 
28
 
 
29
/////////////////////////
 
30
// To Logout the User
 
31
// 1 - Delete the Cookies
 
32
// 2 - Delete the Session
 
33
// 3 - Refresh it as a
 
34
//     Guest Session
 
35
/////////////////////////
 
36
 
 
37
 
 
38
function logout() {
 
39
 
 
40
    global $user, $conn, $dbtables, $logged_in, $globals, $l, $AEF_SESS;
 
41
 
 
42
    //Load the Language File
 
43
    if (!load_lang('logout')) {
 
44
 
 
45
        return false;
 
46
    }
 
47
 
 
48
    //Are you even logged in
 
49
    if (empty($logged_in)) {
 
50
 
 
51
        //Show a major error and return
 
52
        reporterror($l['not_logged_in_title'], $l['not_logged_in']);
 
53
 
 
54
        return false;
 
55
    }
 
56
 
 
57
    ///////////////////////
 
58
    // DELETE the COOKIES
 
59
    ///////////////////////
 
60
    //Set a COOKIE for a YEAR of User ID
 
61
    setcookie($globals['cookie_name'] . '[loguid]', "", (time() - (60 * 60 * 24 * 365)), '/');
 
62
 
 
63
    //Set a COOKIE for a YEAR of CookPass
 
64
    setcookie($globals['cookie_name'] . '[logpass]', "", (time() - (60 * 60 * 24 * 365)), '/');
 
65
 
 
66
 
 
67
    //Lets DELETE the USERS Session
 
68
    $qresult = makequery("DELETE FROM " . $dbtables['sessions'] . "
 
69
                WHERE uid = '" . AS_UID . "'
 
70
                AND sid = '" . AS_ID . "'");
 
71
 
 
72
    if (mysql_affected_rows($conn) < 1) {
 
73
 
 
74
        //Show a major error and return
 
75
        reporterror($l['delete_session_error_title'], $l['delete_session_error']);
 
76
 
 
77
        return false;
 
78
    }
 
79
 
 
80
    //Process the DATA
 
81
    $data = process_as_data();
 
82
 
 
83
    //Add the new SESSION ROW
 
84
    $qresult = makequery("INSERT INTO " . $dbtables['sessions'] . "
 
85
                SET sid = '" . AS_ID . "',
 
86
                uid = '-1',
 
87
                time = '" . time() . "',
 
88
                data = '$data',
 
89
                ip = '" . ($_SERVER['REMOTE_ADDR']) . "'");
 
90
 
 
91
    if (mysql_affected_rows($conn) < 1) {
 
92
 
 
93
        //Show a major error and return
 
94
        reporterror($l['guest_session_error_title'], $l['guest_session_error']);
 
95
 
 
96
        return false;
 
97
    }
 
98
 
 
99
 
 
100
    //Redirect to Index
 
101
    redirect('');
 
102
 
 
103
    return true;
 
104
}
 
105
 
 
106
?>