<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: Base :: GetObject |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2006 June Systems BV |
// +---------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or modify it |
// | under the terms of the GNU Lesser General Public License as published by |
// | the Free Software Foundation; either version 2.1 of the License, or (at |
// | your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public License |
// | along with this library; if not, write to the Free Software Foundation, |
// | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
// +---------------------------------------------------------------------------+
// | Authors: Siggi Oskarsson <hide@address.com> |
// | Jesper Avot <hide@address.com |
// +---------------------------------------------------------------------------+
//
// $Id: GetObject.php 245 2008-06-26 05:55:13Z andries $
//
// Nitro's GetObject script
//
/**
* Include NitroBaseConfig file
*/
include_once "NitroBaseConfig.inc.php";
/**
* Check if the config is loaded correct.
*/
if ($__NitroConf->isLoaded) {
if (isset($_GET['NitroDefault']) && $_GET['NitroDefault'] != "") {
$getFile = str_replace('..', '.', $_GET['NitroDefault']);
$getFile = strip_tags($getFile);
$getFile = str_replace(array('<', '>'), '', $getFile);
$FileName = NITRO_ROOT.'Nitro/Defaults/'.$getFile;
$MimeType = new getMimeType();
if (file_exists($FileName)) {
header("Content-Type: " . $MimeType->getType($FileName));
header("Content-Length: " . filesize($FileName));
header("Content-Disposition: inline; filename=\"" . $getFile . "\"");
header("Expires: " . gmdate("D, d M Y H:i:s", strtotime("+1 day")) . " GMT");
/**
* The Header below is very important, Internet Explorer does not works with inline files over a secured connection (HTTPS [SSL]).
* So we need to set this header, because PHP sets the Pragma default to 'no-cache'
*/
Header("Pragma: Cache");
header("Cache-Control: Private");
readfile($FileName);
}
} else {
/**
* Retrieve the Object's IDString from the GET array and get its data from the DB.
*/
$ObjectIDString = $_GET["ID"];
$Query = "
SELECT
O.*,
OD.*,
M.File,
M.Class
FROM
(`Object` AS O,
`Module` AS M)
LEFT JOIN `ObjectData` AS OD
ON O.ObjectID = OD.ObjectID
AND (OD.Language = ".NitroPrepareDB($__NSess->Language)." OR OD.Language = '')
AND (OD.VisibleFrom >= CURRENT_TIMESTAMP OR VisibleFrom IS NULL)
AND (OD.VisibleTill < CURRENT_TIMESTAMP OR VisibleTill IS NULL)
AND OD.Published = 1
WHERE O.ModuleID = M.ModuleID
AND O.IDString = '".NitroPrepareDB($ObjectIDString)."'
AND O.AllowView = 1
ORDER BY
OD.Language DESC,
OD.Version
DESC LIMIT 1
";
$Object = $DB["Nitro"]->getRow($Query);
if (is_array($Object)) {
$DefaultSettings = unserialize($Object["DefaultSettings"]);
if (!is_array($DefaultSettings)) $DefaultSettings = Array();
$Settings = unserialize($Object["Settings"]);
if (!is_array($Settings)) $Settings = Array();
$Settings = array_merge($DefaultSettings, $Settings);
if (file_exists($Object["File"])) {
include_once $Object["File"];
eval('$temp = new ' . $Object["Class"] . '($Object["ObjectID"],$Settings);');
$temp->ObjectLanguage = $Object["Language"];
$temp->ObjectVersion = $Object["Version"];
echo $temp->DrawObject();
} else {
echo "File (" . $Object["File"] . ") not found!";
}
} else {
echo (($ObjectIDString && $ObjectIDString != "") ? "Object (" . $ObjectIDString . ") not found!" : "No Object given.");
}
}
} else {
/**
* No NitroBaseConfig file found, error time!
*/
echo "Configuration File could not be loaded. => " . $__NitroConf->Error;
exit;
}
?>