Location: PHPKode > projects > FiForms Framework > FiForms/scripts/generate.php
<?php
/*
*******************************************************************************

    FiReportXML -- Rapid XML Report Generator
    Copyright (C) 2004 - 2006  Daniel McFeeters

    included with

    FiForms -- A collection of PHP classes designed
    to facilitate rapid development of web-database software

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation; either
    version 2 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
    General Public License for more details.

    You should have received a copy of the GNU General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


    The original author of this library can be contacted at the following
    address:

    Daniel McFeeters
    182 Baker Rd.
    Faubush, KY 42544-6526
    email:databases [at] fiforms [dot] org
    http://www.fiforms.org/


Project Started February, 2004
*******************************************************************************
generate.php

This script accepts an XML report definition submitted via an HTTP post along
with required parameters, and generates and XML report dataset linked with the
appropriate stylesheet. The XML may also be translated on the server, and a
different type of data (i.e. CSV) sent to the client.
*******************************************************************************
*/

    require_once('localconfig.php');
    if($FIFORMS_CONFIG['USE_COMBINED'])
    {
        include_once(dirname(__FILE__).'/FiForms_combined.inc.php');
    }
    else
    {
        include_once($FIFORMS_CONFIG['INCLUDE_PATH'].'FiForms_genericIcons.inc.php');
        include_once($FIFORMS_CONFIG['INCLUDE_PATH'].'FiForms_global.inc.php');
        include_once($FIFORMS_CONFIG['INCLUDE_PATH'].'FiReports_FiReportXML.inc.php');
    }

if($FIFORMS_CONFIG['ALLOW_USER_QUERIES'] == FALSE && array_key_exists('_DEF',$_POST))
    die('Permission Denied');

{
$rptDef = new FiReportXML();
if(array_key_exists('_DEF',$_POST))
{
    $rptDef->loadDefinition(stripslashes($_POST["_DEF"]));
    $type = $_POST['_TYPE'];
}
else 
{
    if(!isset($FIFORMS_CONFIG['RPT_PATH']))
        die("No Application Specified or Application Disabled.");
    $report = str_replace(array("..","\\","%","*","$","(",")","\"","'",";","`"," ","="),"",$_GET['filename']);
    if(($report !== $_GET['filename']) || !file_exists($FIFORMS_CONFIG['RPT_PATH'].$report))
    {
       die('Invalid File Name');
    }
    $rptDef->loadDefinitionFromFile($FIFORMS_CONFIG['RPT_PATH'].$report);
    $type = $_GET['_TYPE'];
    if(strpos($type,".."))
    {
        die('Invalid Type');
    }

}

switch($type)
{
    case "_default":
      $rptDef->outputXMLNS = TRUE;
          $rptDef->stylesheet = $GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH']."tableViewNS.xsl"; 
          $rptDef->serverTransform = TRUE;
          $rptDef->mimetype = "text/html";
          break;
    case "_csv":
      header("Content-Disposition: inline; filename=report.csv");
      $rptDef->outputXMLNS = TRUE;
          $rptDef->stylesheet = $GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH']."makecsv.xsl";
          $rptDef->mimetype = "text/csv";
          $rptDef->serverTransform = TRUE;
          break; 
    case "_csv_download":
      header("Content-Disposition: inline; filename=report.csv");
          $rptDef->outputXMLNS = TRUE;
      $rptDef->stylesheet = $GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH']."makecsv.xsl";
          $rptDef->mimetype = "binary/octet-stream";
          $rptDef->serverTransform = TRUE;
          break; 
    case "_xml":
          $rptDef->stylesheet = "";
          $rptDef->mimetype = "application/xml";
          break; 
    case "_bin":
          $rptDef->stylesheet = "";
          break; 
    default:    
          $rptDef->mimetype = "text/html";
      $rptDef->stylesheet = dirname($FIFORMS_CONFIG['RPT_PATH'].$report)."/".$type;
      if(!$_POST['def'])
            $rptDef->serverTransform = TRUE;
          break;
}

}

$rptDef->generateReport();

?>
Return current item: FiForms Framework