<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: Condition |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2003 June Systems BV |
// +---------------------------------------------------------------------------+
// | This source file is copyrighted by June Systems BV, the Netherlands |
// | If you would like to use this file in your projects, please contact |
// | hide@address.com |
// +---------------------------------------------------------------------------+
// | Authors: Siggi Oskarsson <hide@address.com> |
// +---------------------------------------------------------------------------+
//
// $Id: Condition.inc.php 229 2008-04-17 09:20:31Z oli $
//
// This file contains the Condition functions and classes for Nitro
//
/**
* This file contains the prototype Backend module definition
*
* @package Nitro
* @subpackage Base
* @author Siggi Oskarsson
* @version $Revision: 1.4 $
* @copyright 2004 June Systems BV
*/
/**
* Check condition given
*
* This function uses the condition class to check whether the given
* condition is true or not. It creates its own condition object if
* it does not exist yet and globalizes it for later use.
*
* @param string $Condition Condition to check for validity
*/
function CheckCondition($Condition) {
global $__NitroCondition;
if (!is_object($__NitroCondition)) {
$__NitroCondition = new NitroCondition();
}
return $__NitroCondition->CheckCondition($Condition);
}
/**
* Nitro condition class
*
* @package Nitro
* @subpackage Base
*/
class NitroCondition {
var $PageID;
var $PageIDString;
var $Site;
var $TopLevelDomain;
var $Domain;
var $Host;
var $RemoteURL;
var $RemoteTopLevelDomain;
var $RemoteDomain;
var $RemoteHost;
/**
* Nitro condition class constructor
*
* This function initializes the condition object and sets most of
* the values that can be used in condition checking.
* Properties set include:
* - PageID
* - PageIDString
* - Site (www.foobar.com)
* - TLD (com)
* - Domain (foobar.com)
* - Host (www.foobar.com), same as Site
* - RemoteURL, remote address of user
* - RemoteTLD, remote TLD of user
* - RemoteDomain, remote domain of user
* - RemoteHost, remote host of user
*
* @access public
*/
function NitroCondition() {
$this->PageID = "";
$this->PageIDString = "";
$this->Site = $_SERVER["HTTP_HOST"];
$Domains = explode(".", $this->Site);
$this->TopLevelDomain = array_pop($Domains);
$this->Domain = array_pop($Domains).".".$this->TopLevelDomain;
$this->Host = implode(".", $Domains);
$this->RemoteURL = gethostbyaddr ($_SERVER["REMOTE_ADDR"]);
$Domains = explode(".", $this->RemoteURL);
$this->RemoteTopLevelDomain = array_pop($Domains);
$this->RemoteDomain = array_pop($Domains).".".$this->RemoteTopLevelDomain;
$this->RemoteHost = implode(".", $Domains);
}
/**
* Evaluate condition
*
* This function calls the eval function on the condition to evaluate
* if it is true or false.
*/
function CheckCondition($Condition) {
return eval("return ".$Condition.";");
}
function GetConfiguration() {
$RV = Array("Host" => "Host",
"Domain" => "Domain",
"TopLevelDomain" => "Top Level Domain"
);
}
}
?>