Location: PHPKode > projects > FiForms Framework > FiForms/FiForms-includes/callmenu.inc.php
<?php
/*
*******************************************************************************

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

    Copyright (C) 2003 - 2005 Daniel McFeeters

    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 May 4, 2003
*******************************************************************************
callmenu.php

Script to generate an HTML menu page from and XML menu definition.

*******************************************************************************
*/
    if(!isset($FIFORMS_CONFIG))
    {
        die('No Configuration found. Did you perhaps call an include file' .
                        ' directly instead of calling it as part of the FiForms' .
                        ' application?'); 
    }
if(!isset($FIFORMS_CONFIG['MENU_PATH']))
{
    promptPage('Error in Application','No Application Specified or Application Disabled. <a href="javascript:history.go(-1)">Go Back</a>',"20%","20%","60%");
    die();
}
if(!isset($FIFORMS_CONFIG['AUTH_MODULE']))
{
    promptPage('Error in Application','Authentication Module not defined in FiForms_global.inc.php <a href="javascript:history.go(-1)">Go Back</a>',"20%","20%","60%");
    die();
}
require_once($FIFORMS_CONFIG['AUTH_MODULE']);

function callMenu($index,$complete = 'COMPLETE')
{
    $filename = str_replace(array("..","/","\\","%","*","$","(",")","\"","'",";","`"," ","="),"",$index);
    if(!@chdir($GLOBALS['FIFORMS_CONFIG']['MENU_PATH']))
    {
        promptPage('Error in Application','Could not find the specified menu. Please check your configuration and MENU_PATH and be sure to specify an application and form. <a href="javascript:history.go(-1)">Go Back</a>',"20%","20%","60%");
        die();
    }
    $auth = new FiFormsAuth();
    if(!@mysql_connect($GLOBALS['FIFORMS_CONFIG']['DEFAULT_SERVER'],$auth->username,$auth->passwd))
    {
        $auth->connectFailure();
        promptPage('Database Connection Failure','Could not connect to the database server. Check your password and configuration. <a href="javascript:history.go(-1)">Go Back</a>',"20%","20%","60%");
        die();
    }
    mysql_close();
    if(($filename !== $index) || !file_exists($filename))
    {
        promptPage('Invalid File Name','Could not find the specified menu. <a href="javascript:history.go(-1)">Go Back</a>',"20%","20%","60%");
        die();
    }
    $recursive = isset($_GET['recursive']) ? 'RECURSIVE' : 'NONE';
    $popups = $GLOBALS['FIFORMS_CONFIG']['MENU_POPUPS'];
    if(!$popups)
    {
        $popups = "default";
    }
    $ns = $GLOBALS['FIFORMS_CONFIG']['MENU_XMLNS'] ? 'NS' : '';
        @header("cache-control: private");
        @header("cache-control: no-cache");
        @header("cache-control: no-store");
        @header("pragma: no-cache");
        @header("expires: 0");
    if($GLOBALS['FIFORMS_CONFIG']['PHP_XSLT'] == TRUE)
    {
        $sheet = new DOMDocument();
        $sheet->resolveExternals = false;
        $sheet->load($GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH']."reportList$ns.xsl");
        $xsl = new XSLTProcessor();
    $xsl->resolveExternals = false;
        $xsl->importStyleSheet($sheet);
        $xsl->setParameter('', 'complete', $complete);
        $xsl->setParameter('', 'recursive', $recursive);
        $xsl->setParameter('', 'popups', $popups);
        $xsl->setParameter('', 'xml_path', $GLOBALS['FIFORMS_CONFIG']['XML_PATH']);
        $xsl->setParameter('', 'rpt_path', $GLOBALS['FIFORMS_CONFIG']['RPT_PATH']);
        $xsl->setParameter('', 'app', $GLOBALS['FIFORMS_CONFIG']['APP_NAME']);
        $xsl->setParameter('', 'stylesheet', $GLOBALS['FIFORMS_CONFIG']['URI']."themes/".
                $GLOBALS['FIFORMS_CONFIG']['ICON_SET']."/fiform_style.css");
        $doc = new DOMDocument();
        $doc->resolveExternals = false;
        $doc->load($filename);
        echo $xsl->transformToXML($doc);
    }
    else
    {
        $cmd =  $GLOBALS['FIFORMS_CONFIG']['XSLTPROC']." ".
                $GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH'].
                        "reportList$ns.xsl $filename --nonet " .
                        "--stringparam complete $complete " .
                        "--stringparam recursive $recursive " .
                        "--stringparam popups $popups " .
                        "--stringparam xml_path ".$GLOBALS['FIFORMS_CONFIG']['XML_PATH'].
                        " --stringparam rpt_path ".$GLOBALS['FIFORMS_CONFIG']['RPT_PATH'].
                        " --stringparam app ".$GLOBALS['FIFORMS_CONFIG']['APP_NAME'].
                        " --stringparam stylesheet ".$GLOBALS['FIFORMS_CONFIG']['URI'].
                        "themes/".$GLOBALS['FIFORMS_CONFIG']['ICON_SET']."/fiform_style.css";
        $output = shell_exec($cmd);
        if($output)
        {
            echo $output;
        }
        else
        {
            promptPage('Error Processing XML','Error Executing $cmd Please see FiForms_global.inc.php. <a href="javascript:history.go(-1)">Go Back</a>',"20%","20%","60%");
            die();
        }

    }

}
?>
Return current item: FiForms Framework