function vam_update_whos_online()
{
    if (isset($_SESSION['customer_id'])) {
        $wo_customer_id = $_SESSION['customer_id'];
        $wo_full_name = addslashes($_SESSION['customer_first_name'] . ' ' . $_SESSION['customer_last_name']);
    } else {
        $wo_customer_id = 0;
        $wo_full_name = TEXT_GUEST;
    }
    $wo_session_id = vam_session_id();
    $wo_ip_address = vam_get_ip_address();
    $wo_last_page_url = addslashes(getenv('REQUEST_URI'));
    $current_time = time();
    $xx_mins_ago = $current_time - 900;
    // remove entries that have expired
    vam_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");
    $stored_customer_query = vam_db_query("select count(*) as count from " . TABLE_WHOS_ONLINE . " where session_id = '" . $wo_session_id . "'");
    $stored_customer = vam_db_fetch_array($stored_customer_query);
    if ($stored_customer['count'] > 0) {
        vam_db_query("update " . TABLE_WHOS_ONLINE . " set customer_id = '" . $wo_customer_id . "', full_name = '" . $wo_full_name . "', ip_address = '" . $wo_ip_address . "', time_last_click = '" . $current_time . "', last_page_url = '" . $wo_last_page_url . "' where session_id = '" . $wo_session_id . "'");
    } else {
        vam_db_query("insert into " . TABLE_WHOS_ONLINE . " (customer_id, full_name, session_id, ip_address, time_entry, time_last_click, last_page_url) values ('" . $wo_customer_id . "', '" . $wo_full_name . "', '" . $wo_session_id . "', '" . $wo_ip_address . "', '" . $current_time . "', '" . $current_time . "', '" . $wo_last_page_url . "')");
    }
}
Пример #2
0
// verify the browser user agent if the feature is enabled
if (SESSION_CHECK_USER_AGENT == 'True') {
    $http_user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
    $http_user_agent2 = strtolower(getenv("HTTP_USER_AGENT"));
    $http_user_agent = $http_user_agent == $http_user_agent2 ? $http_user_agent : $http_user_agent . ';' . $http_user_agent2;
    if (!isset($_SESSION['SESSION_USER_AGENT'])) {
        $_SESSION['SESSION_USER_AGENT'] = $http_user_agent;
    }
    if ($_SESSION['SESSION_USER_AGENT'] != $http_user_agent) {
        session_destroy();
        vam_redirect(vam_href_link(FILENAME_LOGIN));
    }
}
// verify the IP address if the feature is enabled
if (SESSION_CHECK_IP_ADDRESS == 'True') {
    $ip_address = vam_get_ip_address();
    if (!isset($_SESSION['SESSION_IP_ADDRESS'])) {
        $_SESSION['SESSION_IP_ADDRESS'] = $ip_address;
    }
    if ($_SESSION['SESSION_IP_ADDRESS'] != $ip_address) {
        session_destroy();
        vam_redirect(vam_href_link(FILENAME_LOGIN));
    }
}
// set the language
if (!isset($_SESSION['language']) || isset($_GET['language'])) {
    include DIR_WS_CLASSES . 'language.php';
    $lng = new language(vam_input_validation($_GET['language'], 'char', ''));
    if (!isset($_GET['language'])) {
        $lng->get_browser_language();
    }