Example #1
0
function mysql_session_read($SID)
{
    $ip = $_SERVER['REMOTE_ADDR'];
    $sql = "\n    SELECT data,refresh,playerid \n    FROM l_session \n    WHERE id = '{$SID}' \n    and expire > now() \n  ";
    $res = mysql_query($sql);
    if ($res) {
        $row = mysql_fetch_assoc($res);
        if ($row) {
            $session = stripslashes($row['data']);
            if ($row['refresh'] == 'Y' and !empty($row['playerid'])) {
                $_SESSION = unserialize_session_data($session);
                session_data_reload($row['playerid']);
                $session = session_encode();
                unset($_SESSION);
                $sql = "UPDATE l_session SET refresh='N' WHERE id='{$SID}'";
                mysql_query($sql);
            }
            return $session;
        } else {
            mysql_session_destroy($SID);
        }
    }
    sessionStaticInfo();
    return "";
}
/**
 * This function returns the user ID of the logged in user on your site.  Technical support will not
 * help you with this for stand-alone installations.  You must purchase the professional installation
 * if you are having trouble.
 *
 * Suggestion: Check out the other integration files in the functions/integrations directory for
 * many examples of how this can be done.  The easiest way is to get the user ID through a cookie.
 *
 * @return the user ID of the logged in user or NULL if not logged in
 */
function get_user_id()
{
    global $db;
    $userid = NULL;
    $session_id = session_id();
    if (!empty($session_id)) {
        $result = $db->execute("\n\t\t\t\tSELECT data\n\t\t\t\tFROM " . TABLE_PREFIX . "sessions\n\t\t\t\tWHERE id = '" . $db->escape_string($session_id) . "'\n\t\t\t");
        if ($row = $db->fetch_array($result)) {
            if (!empty($row['data'])) {
                $data = unserialize_session_data($row['data']);
                if (!empty($data['Zend_Auth']['storage']->id)) {
                    $userid = $data['Zend_Auth']['storage']->id;
                }
            }
        }
    }
    return $userid;
}
<?php 
$heading = array();
$contents = array();
if ($info) {
    $heading[] = array('text' => '<b>' . TABLE_HEADING_SHOPPING_CART . '</b>');
    if (STORE_SESSIONS == 'mysql') {
        $session_data = vam_db_query("select value from " . TABLE_SESSIONS . " WHERE sesskey = '" . $info . "'");
        $session_data = vam_db_fetch_array($session_data);
        $session_data = trim($session_data['value']);
    } else {
        if (file_exists(vam_session_save_path() . '/sess_' . $info) && filesize(vam_session_save_path() . '/sess_' . $info) > 0) {
            $session_data = file(vam_session_save_path() . '/sess_' . $info);
            $session_data = trim(implode('', $session_data));
        }
    }
    $user_session = unserialize_session_data($session_data);
    if ($user_session) {
        $products = vam_get_products($user_session);
        for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
            $contents[] = array('text' => $products[$i]['quantity'] . ' x ' . $products[$i]['name']);
        }
        if (sizeof($products) > 0) {
            $contents[] = array('text' => vam_draw_separator('pixel_black.gif', '100%', '1'));
            $contents[] = array('align' => 'right', 'text' => TEXT_SHOPPING_CART_SUBTOTAL . ' ' . $user_session['cart']->total . ' ' . $user_session['currency']);
        } else {
            $contents[] = array('text' => '&nbsp;');
        }
    }
}
if (vam_not_null($heading) && vam_not_null($contents)) {
    echo '            <td width="25%" valign="top">' . "\n";