logo       


Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

[TEP-COMMIT] CVS: catalog/catalog/includes/classes session.php,NONE,1.1 ses: msg#00002

Subject: [TEP-COMMIT] CVS: catalog/catalog/includes/classes session.php,NONE,1.1 session_compatible.php,NONE,1.1
Update of /cvsroot/tep/catalog/catalog/includes/classes
In directory sc8-pr-cvs1:/tmp/cvs-serv14311

Added Files:
        session.php session_compatible.php 
Log Message:
introduction of the new session class, which replaces the session functions
and provides consistent means of accessing session content

the session.php file is used for PHP => 4.1 servers which use the new
super global variables ($_SESSION)

the session_compatible.php file is the same class but is used on PHP 4.0.x
servers which still use the $HTTP_SESSION_VARS variable. [a reference to
this variable is not possible, and thus the reason for two files - might
be merged later in time to save on redundancy]


--- NEW FILE: session.php ---
<?php
/*
  $Id: session.php,v 1.1 2003/11/17 16:55:21 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class osC_Session {
    var $is_started,
        $save_path,
        $name,
        $id;

// class constructor
    function osC_Session() {
      global $cookie_path, $cookie_domain;

      $this->setName('osCsid');
      $this->setSavePath(SESSION_WRITE_DIRECTORY);

      session_set_cookie_params(0, $cookie_path, $cookie_domain);

      if (STORE_SESSIONS == 'mysql') {
        session_set_save_handler(array(&$this, '_open'),
                                 array(&$this, '_close'),
                                 array(&$this, '_read'),
                                 array(&$this, '_write'),
                                 array(&$this, '_destroy'),
                                 array(&$this, '_gc'));
      }

      $this->setStarted(false);
    }

// class methods
    function start() {
      if (session_start()) {
        $this->setStarted(true);

        $this->setID();

        return true;
      }

      return false;
    }

    function exists($variable) {
      if (isset($_SESSION[$variable])) {
        return true;
      }

      return false;
    }

    function set($variable, &$value) {
      if ($this->is_started == true) {
        $_SESSION[$variable] = $value;

        return true;
      }

      return false;
    }

    function remove($variable) {
      if ($this->exists($variable)) {
        unset($_SESSION[$variable]);

        return true;
      }

      return false;
    }

    function &value($variable) {
      if (isset($_SESSION[$variable])) {
        return $_SESSION[$variable];
      }

      return false;
    }

    function close() {
      if (function_exists('session_write_close')) {
        return session_write_close();
      }

      return true;
    }

    function destroy() {
      if (isset($_COOKIE[$this->name])) {
        unset($_COOKIE[$this->name]);
      }

      if (STORE_SESSIONS == '') {
        if (file_exists($this->save_path . '/' . $this->id)) {
          @unlink($this->save_path . '/' . $this->id);
        }
      }

      return session_destroy();
    }

    function recreate() {
      $session_backup = $_SESSION;

      $this->destroy();

      $this->osC_Session();

      $this->start();

      $_SESSION = $session_backup;

      unset($session_backup);
    }

    function setName($name) {
      session_name($name);

      $this->name = session_name();

      return true;
    }

    function setID() {
      $this->id = session_id();

      return true;
    }

    function setSavePath($path) {
      session_save_path($path);

      $this->save_path = session_save_path();

      return true;
    }

    function setStarted($state) {
      if ($state == true) {
        $this->is_started = true;
      } else {
        $this->is_started = false;
      }
    }

    function _open() {
      return true;
    }

    function _close() {
      return true;
    }

    function _read($key) {
      $value_query = tep_db_query("select value from " . TABLE_SESSIONS . " 
where sesskey = '" . tep_db_input($key) . "' and expiry > '" . time() . "'");
      if (tep_db_num_rows($value_query)) {
        $value = tep_db_fetch_array($value_query);

        return $value['value'];
      }

      return false;
    }

    function _write($key, $value) {
      if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
        $SESS_LIFE = 1440;
      }

      $expiry = time() + $SESS_LIFE;

      $check_query = tep_db_query("select count(*) as total from " . 
TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
      $check = tep_db_fetch_array($check_query);

      if ($check['total'] > 0) {
        return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . 
tep_db_input($expiry) . "', value = '" . tep_db_input($value) . "' where 
sesskey = '" . tep_db_input($key) . "'");
      } else {
        return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . 
tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . 
tep_db_input($value) . "')");
      }
    }

    function _destroy($key) {
      return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = 
'" . tep_db_input($key) . "'");
    }

    function _gc($maxlifetime) {
      return tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" 
. time() . "'");
    }
  }
?>

--- NEW FILE: session_compatible.php ---
<?php
/*
  $Id: session_compatible.php,v 1.1 2003/11/17 16:55:21 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class osC_Session {
    var $is_started,
        $save_path,
        $name,
        $id;

// class constructor
    function osC_Session() {
      global $cookie_path, $cookie_domain;

      $this->setName('osCsid');
      $this->setSavePath(SESSION_WRITE_DIRECTORY);

      session_set_cookie_params(0, $cookie_path, $cookie_domain);

      if (STORE_SESSIONS == 'mysql') {
        session_set_save_handler(array(&$this, '_open'),
                                 array(&$this, '_close'),
                                 array(&$this, '_read'),
                                 array(&$this, '_write'),
                                 array(&$this, '_destroy'),
                                 array(&$this, '_gc'));
      }

      $this->setStarted(false);
    }

// class methods
    function start() {
      if (session_start()) {
        $this->setStarted(true);

        $this->setID();

        return true;
      }

      return false;
    }

    function exists($variable) {
      global $HTTP_SESSION_VARS;

      if (isset($HTTP_SESSION_VARS[$variable])) {
        return true;
      }

      return false;
    }

    function set($variable, &$value) {
      global $HTTP_SESSION_VARS;

      if ($this->is_started == true) {
        $HTTP_SESSION_VARS[$variable] = $value;

        return true;
      }

      return false;
    }

    function remove($variable) {
      global $HTTP_SESSION_VARS;

      if ($this->exists($variable)) {
        unset($HTTP_SESSION_VARS[$variable]);

        return true;
      }

      return false;
    }

    function &value($variable) {
      global $HTTP_SESSION_VARS;

      if (isset($HTTP_SESSION_VARS[$variable])) {
        return $HTTP_SESSION_VARS[$variable];
      }

      return false;
    }

    function close() {
      if (function_exists('session_write_close')) {
        return session_write_close();
      }

      return true;
    }

    function destroy() {
      global $_COOKIE;

      if (isset($_COOKIE[$this->name])) {
        unset($_COOKIE[$this->name]);
      }

      if (STORE_SESSIONS == '') {
        if (file_exists($this->save_path . '/' . $this->id)) {
          @unlink($this->save_path . '/' . $this->id);
        }
      }

      return session_destroy();
    }

    function recreate() {
      return false;
    }

    function setName($name) {
      session_name($name);

      $this->name = session_name();

      return true;
    }

    function setID() {
      $this->id = session_id();

      return true;
    }

    function setSavePath($path) {
      session_save_path($path);

      $this->save_path = session_save_path();

      return true;
    }

    function setStarted($state) {
      if ($state == true) {
        $this->is_started = true;
      } else {
        $this->is_started = false;
      }
    }

    function _open() {
      return true;
    }

    function _close() {
      return true;
    }

    function _read($key) {
      $value_query = tep_db_query("select value from " . TABLE_SESSIONS . " 
where sesskey = '" . tep_db_input($key) . "' and expiry > '" . time() . "'");
      if (tep_db_num_rows($value_query)) {
        $value = tep_db_fetch_array($value_query);

        return $value['value'];
      }

      return false;
    }

    function _write($key, $value) {
      if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
        $SESS_LIFE = 1440;
      }

      $expiry = time() + $SESS_LIFE;

      $check_query = tep_db_query("select count(*) as total from " . 
TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
      $check = tep_db_fetch_array($check_query);

      if ($check['total'] > 0) {
        return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . 
tep_db_input($expiry) . "', value = '" . tep_db_input($value) . "' where 
sesskey = '" . tep_db_input($key) . "'");
      } else {
        return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . 
tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . 
tep_db_input($value) . "')");
      }
    }

    function _destroy($key) {
      return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = 
'" . tep_db_input($key) . "'");
    }

    function _gc($maxlifetime) {
      return tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" 
. time() . "'");
    }
  }
?>



-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe