Location: PHPKode > projects > FiForms Framework > FiForms/scripts/createConfig.php
<?php
/*  This file is part of the FiForms Framework
    Copyright (C) 2003-2008 by Daniel McFeeters,
    Licensed under the GNU GPL. 
    See LICENSE.txt for details. 
*/

if(!$_POST)
{
    header('Location: editConfig.php');
}
if(file_exists('localconfig.php'))
{
    include_once('localconfig.php');
}
else
{
    include_once('localconfig.php.default');
}
$checkpass = true;
require_once("authenticate.php");
require_once("promptpage.php");
$includePath = $_POST['INCLUDE_PATH'];
$stringData = <<<EOD
<?php \n

    // Local configuration file for FiForms. Please make all your 
    // configuration changes to this file. 
    // For a reference of what variables can be set here, please see
    // http://wiki.fiforms.org/index.php/Configuration

    // Use the following space to override any and all global FiForms 
    // variables for your application:

EOD;

$newPassword = false;

foreach($_POST as $element => $value)
{
    switch($element)
    {
        case "password":
        break;
        case "APP_BASE":
                $stringData .= "    \$FIFORMS_CONFIG['$element'] = \"$value\";\n";
                //$stringData .= "\n   require_once(\$FIFORMS_CONFIG['APP_BASE'].'applications.php');\n";
        break;
        case "CONNECT_EARLY":
        
                if($value)
                {
                        $stringData .= "    \$FIFORMS_CONFIG['$element'] = true; \n";
                }
                break;
        case "SHOW_DEFINITION":
        
                if($value)
                {
                        $stringData .= "    \$FIFORMS_CONFIG['$element'] = true; \n";
                }
                break;
        case "USE_XHTML":
        
                if($value)
                {
                        $stringData .= "    \$FIFORMS_CONFIG['$element'] = true; \n";
                }
                break;
                
        case "PHP_XSLT":
        
                if($value)
                {
                        $stringData .= "    \$FIFORMS_CONFIG['$element'] = true; \n";
                }
                break;
        case "UPDATEPW":
                if($value && $_POST['UPDATEPW_CONFIRM'] = $value)
                {
                    $stringData .= "    \$FIFORMS_CONFIG['UPDATEPW_HASH'] = \"".sha1($value)."\"; \n";
                    $newPassword = true;
                }
                else
                {
                    if($_POST['UPDATEPW_CONFIRM'] != $value)
                    {
                        echo "<p>WARNING: Administration passwords entered do not match. Password not reset.</p>";
                    }
                    $stringData .= "    \$FIFORMS_CONFIG['UPDATEPW_HASH'] = \"".$FIFORMS_CONFIG['UPDATEPW_HASH']."\"; \n";
                }
                break;
        case "UPDATEPW_CONFIRM":
                break;
        case "DEFAULT_LIMIT":
                $stringData .= "    \$FIFORMS_CONFIG['$element'] = $value; \n";
                break;
        default:
                $stringData .= "    \$FIFORMS_CONFIG['$element'] = \"$value\";\n";
    }
}  // foreach

if(!$newPassword)
{
    $stringData .= "    \$FIFORMS_CONFIG['UPDATEPW_HASH'] = \"".$FIFORMS_CONFIG['UPDATEPW_HASH']."\"; \n";

}

$stringData .= "\n\n?>";

$myFile = "localconfig.php";
$fh = @fopen($myFile, 'w');
if(!$fh)
{
   $htmlStringData = htmlentities($stringData);
   promptpage("Config File Could Not Be Written",<<<EOD
       <i>Below is the contents of the new localconfig.php file. Due to 
       the settings on your server, FiForms could not write to this file.
       Please copy the text printed below into the file localconfig.php
       in the scripts folder of FiForms.</i><br /><br />
    <blockquote style="background-color: #dddddd"><pre>
$htmlStringData
       </pre>
       </blockquote>
    <a href="index.php">Click here to return to main menu.</a>
EOD
,"2%","2%","96%");
   die();
}
fwrite($fh, $stringData);
fclose($fh);
promptPage("Configuration File Created",<<<EOD
    <a href="index.php">Continue to Main Menu</a>
EOD
,"10%","10%","80%");
?>
Return current item: FiForms Framework