<?php
/**
* Entier Studio
*
* LICENSE
*
* Copyright 2006 Entier Studio team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package entier.framework
* @copyright Copyright (c) 2006 Entier Studio team. All rights reserved.
* @version $Id: httpsession.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefHttpSession")) {
//-------------------------------------------------------------------------
// Define
define("DefHttpSession", "1");
//
define(HTTP_NO_SESSION, 0);
define(HTTP_COOKIE_BASED, 1);
define(HTTP_URL_BASED, 2);
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . "useripaddress.php");
//-------------------------------------------------------------------------
// Class
class HttpSession {
//---------------------------------------------------------------------
// Attributes
/**
*
* @var integer
*/
var $m_PrivacyID = 0;
/**
*
* @var integer
*/
var $m_SessionID = 0;
/**
*
* @var integer
*/
var $m_AddressID = 0;
/**
*
* @var integer
*/
var $m_LifeStamp = 0;
/**
*
* @var integer
*/
var $m_HttpMethod = 0;
//---------------------------------------------------------------------
// Constructor
/**
* HttpSession constructor
* @param integer
*/
function HttpSession($lifeStamp = 0) {
//
$this->m_LifeStamp = $lifeStamp;
}
//---------------------------------------------------------------------
// Properties
// Property: session_value
/**
*
* @param string
* @param variant
* @return boolean
*/
function set_session_value($field, $value) {
//
$_SESSION[$field] = $value;
//
return (true);
}
/**
*
* @param string
* @return variant
*/
function get_session_value($field) {
//
if (isset($_SESSION[$field])) return ($_SESSION[$field]);
//
return (false);
}
// Property: privacy_id
/**
*
* @param string Field name
* @param string Field value
* @return boolean Return flag
*/
function set_privacy_id($field, $value = 0) {
//
if (empty($value)) $this->m_PrivacyID = uniqid("");
else $this->m_PrivacyID = $value;
//
if (!empty($this->m_PrivacyID)) {
//
@SetCookie($field, @md5($this->m_PrivacyID) , time() +$this->m_LifeStamp, "/", "", 0);
//
return (true);
}
//
return (false);
}
/**
*
* @param string Field name
* @return boolean Return flag
*/
function get_privacy_id($field) {
//
if (isset($_COOKIE[$field])) {
$this->m_PrivacyID = $_COOKIE[$field];
$this->m_HttpMethod = HTTP_COOKIE_BASED;
return ($this->m_PrivacyID);
}
//
$this->m_PrivacyID = 0;
$this->m_HttpMethod = 0;
//
return (false);
}
// Property: session_id
/**
*
* @param string Field name
* @param string Field value
* @return boolean Return flag
*/
function set_session_id($field) {
//
$this->m_SessionID = uniqid("");
if (!empty($this->m_SessionID)) {
//
@SetCookie($field, @md5($this->m_SessionID) , 0, "/", "", 0);
//
return (true);
}
//
return (false);
}
/**
*
* @param string Field name
* @return boolean Return flag
*/
function get_session_id($field) {
//
if (isset($_COOKIE[$field])) {
$this->m_SessionID = $_COOKIE[$field];
$this->m_HttpMethod = HTTP_COOKIE_BASED;
return ($this->m_SessionID);
}
//
$this->m_SessionID = 0;
$this->m_HttpMethod = HTTP_NO_SESSION;
return (false);
}
// Property: address_id
/**
*
* @param string Field name
* @param string Field value
* @return boolean Return flag
*/
function set_address_id($field) {
//
$this->m_AddressID = uniqid("");
if (!empty($this->m_AddressID)) {
//
@SetCookie($field, @md5($this->m_AddressID) , 0, "/", "", 0);
//
return (true);
}
//
return (false);
}
/**
*
* @param string Field name
* @return boolean Return flag
*/
function get_address_id($field) {
//
if (isset($_COOKIE[$field])) {
$this->m_SessionID = $_COOKIE[$field];
$this->m_HttpMethod = HTTP_COOKIE_BASED;
return ($this->m_AddressID);
}
//
$this->m_AddressID = 0;
$this->m_HttpMethod = HTTP_NO_SESSION;
return (false);
}
/**
*
* @param string
*/
function HttpAuthentification($text = "") {
//
header("WWW-Authenticate: Basic realm=\"My Realm\"");
header("HTTP/1.0 401 Unauthorized");
print "$text";
//
return (headers_sent());
}
/**
*
* @param string
*/
function HttpRedirection($page = "") {
//
header("Location: $page");
//
exit(headers_sent());
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>