Пример #1
0
<?php

###########################################################################
# Copyright Jamit Software 2012, http://www.jamit.com
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
###########################################################################
require "../config.php";
include 'login_functions.php';
JB_process_login();
JBPLUG_do_callback('can_logout', $A = false);
$now = gmdate("Y-m-d H:i:s");
$sql = "UPDATE `users` SET `logout_date`='{$now}' WHERE `Username`='" . jb_escape_sql($_SESSION['JB_Username']) . "'";
JB_mysql_query($sql) or die(mysql_error());
// clear the session table
$sql = "DELETE FROM `jb_sessions` WHERE session_id='" . jb_escape_sql(session_id()) . "' ";
JB_mysql_query($sql) or die($sql . mysql_error());
unset($_SESSION['JB_ID']);
unset($_SESSION['JB_Domain']);
unset($_SESSION['JB_FirstName']);
unset($_SESSION['JB_LastName']);
unset($_SESSION['JB_Username']);
unset($_SESSION['Rank']);
unset($_SESSION['JB_Base']);
JB_template_candidates_outside_header($page_title);
echo '<p style="text-align:center">' . $label["c_logout_msg"] . '</p>';
JB_template_candidates_outside_footer();
Пример #2
0
function JB_process_login()
{
    global $label;
    global $JBMarkup;
    if (!isset($_REQUEST['page'])) {
        // this us used to forward the user to the relevant page after login
        $q_str = '';
        $amp = '';
        foreach ($_GET as $key => $val) {
            if (!is_array($val)) {
                $q_str .= $amp . $key . '=' . urlencode($val);
            }
            $amp = '&';
        }
        $_REQUEST['page'] = $_SERVER['PHP_SELF'] . '?' . $q_str;
    }
    $session_duration = ini_get("session.gc_maxlifetime");
    if ($session_duration == false) {
        $session_duration = 20 * 60;
    }
    // general house-keeping to end all sessions longer than session.gc_maxlifetime
    $now = gmdate("Y-m-d H:i:s");
    $sql = "UPDATE `users` SET `logout_date`='{$now}' WHERE UNIX_TIMESTAMP(DATE_SUB('{$now}', INTERVAL {$session_duration} SECOND)) > UNIX_TIMESTAMP(last_request_time) AND (`logout_date` ='0000-00-00 00:00:00')";
    JB_mysql_query($sql) or die($sql . mysql_error());
    JBPLUG_do_callback('can_process_login', $A = false);
    // Note for Plugin authors: here your plugin can update your session cookies for your external app, and do other hosekeeping such as update the session tables, etc
    if (!JB_is_can_logged_in() || $_SESSION['JB_Domain'] != "CANDIDATE" || isset($_SESSION['JB_Base']) && $_SESSION['JB_Base'] != JB_BASE_HTTP_PATH) {
        $page_title = $label["c_loginform_title"] . " - " . JB_SITE_NAME;
        JB_template_candidates_outside_header($page_title);
        JB_can_login_form();
        JB_template_candidates_outside_footer();
        die;
    } else {
        JBPLUG_do_callback('can_process_login_passed', $A = false);
        // user is logged in
        $now = gmdate("Y-m-d H:i:s");
        $sql = "UPDATE `users` SET `last_request_time`='{$now}', logout_date='0000-00-00 00:00:00' WHERE `Username`='" . jb_escape_sql(addslashes($_SESSION['JB_Username'])) . "'";
        JB_mysql_query($sql) or die($sql . mysql_error());
        // check membership payment.
        if (JB_CANDIDATE_MEMBERSHIP_ENABLED == 'YES') {
            if (!JB_is_candidate_membership_active($_SESSION['JB_ID'])) {
                if (strpos($_SERVER['PHP_SELF'], 'membership.php') === false && strpos($_SERVER['PHP_SELF'], 'order.php') === false && strpos($_SERVER['PHP_SELF'], 'payment.php') === false && strpos($_SERVER['PHP_SELF'], 'logout.php') === false) {
                    // redirect to the memberhsip page
                    ?>
				   <head>
				   <?php 
                    $JBMarkup->charset_meta_tag();
                    ?>
				   <link rel="stylesheet" type="text/css" href="<?php 
                    echo JB_get_maincss_url();
                    ?>
" >
				   <META HTTP-EQUIV="Refresh" CONTENT="1; URL=membership.php">
				   </head>
				   <body style="background-color:white">
				   <p>&nbsp;</p>

				   <?php 
                    echo $label['membership_please_wait'];
                    ?>

				   </body>


				   <?php 
                    die;
                }
            }
        }
    }
}