Location: PHPKode > projects > FiForms Framework > FiForms/scripts/update_exec.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. 
*/

        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');
        }
        if(!isset($FIFORMS_CONFIG['AUTH_MODULE']))
            die('Authentication Module not set in localconfig.php');
        require_once($FIFORMS_CONFIG['AUTH_MODULE']);
        require_once('promptpage.php');
        $auth = new FiFormsAuth();
        if(!@mysql_connect($FIFORMS_CONFIG['DEFAULT_SERVER'],$auth->username,$auth->passwd))
        {
                $auth->connectFailure();
                die();
        }
        mysql_close();
        
        if($FIFORMS_CONFIG['UPDATE_HOST'] !== "any" && ($FIFORMS_CONFIG['UPDATE_HOST'] !== "localhost" || $_SERVER['REMOTE_ADDR'] !== "127.0.0.1"))
        {
            die("This feature is not allowed in localconfig.php.");
        }
        
        if(!$_POST['password'] || sha1($_POST['password']) !== $FIFORMS_CONFIG['UPDATEPW_HASH'])
        {
            promptPage("Password Incorrect",'<a href="javascript:history.go(-1)>Go Back</a>','20%','20%','60%');
            die();
        }
        if(!$_FILES['package'] )
        {
             promptPage("Upload Error",'The file did not upload properly. Please try again. <br /><a href="javascript:history.go(-1)>Go Back</a>','20%','20%','60%');
            die();
        }
        if(!file_exists($FIFORMS_CONFIG['TEMP_PATH']))
        {
            die("TEMP_PATH ".$FIFORMS_CONFIG['TEMP_PATH']." does not exist. Cannot Continue.");
        }
        if(!is_writable($FIFORMS_CONFIG['TEMP_PATH']))
        {
             promptPage("Permissions or Path Error","TEMP_PATH ".$FIFORMS_CONFIG['TEMP_PATH']." is not writable. Cannot Continue.".'<br /><a href="javascript:history.go(-1)>Go Back</a>','20%','20%','60%');
            die();
        }
        do
        {
            $randdir = rand();
            $tmpdir = $FIFORMS_CONFIG['TEMP_PATH']."/".$randdir;
        } while(file_exists($tmpdir));
        mkdir($tmpdir) or die('Could Not Make Directory.');
        chdir($tmpdir);
        /*
        if(file_exists("install.php"))
        {
            echo "<p><b>Note:</b>A temporary installation script was found from a previous install.</p>";
            if($_POST['overwrite'])
            {
                echo "<p>Attempting to remove.</p>";
                unlink("install.php");
            }
            else
            {
                die("<p>Please remove before continuing, or enable file overwriting</p>");
            }
        
        }
        if(file_exists("install.php"))
        {
            die("<p>An install script remains from a previous unfinished install process. Please remove before continuing.</p>");
        }
        $ow = $_POST['overwrite'] ? " -o " : "";
        */
        ob_start();
        $ow = " -o ";
        echo "<b>Extracting files to $tmpdir:</b><br /><textarea rows=\"20\" cols=\"70\">";
        passthru($FIFORMS_CONFIG['UNZIP']." $ow".$_FILES['package']['tmp_name']);
        /*
        if(file_exists("install.php"))
        {
            echo "<br /><br /></pre>Calling install script.<br>";
            include($FIFORMS_CONFIG['TEMP_PATH']."/install.php");
            unlink("install.php");
        }
        else
        {
            echo "<br /><br /></pre>No install script found.<br>";
        }
        */
        echo "</textarea><br />Package Extracted.";
        $output = ob_get_contents();
        ob_clean();
        promptPage("FiForms Update and Application Installer",<<<EOD
$output
<form action="update_install.php" method="post">
<input type="hidden" name="password" value="$_POST[password]" />
<input type="hidden" name="randdir" value="$randdir" />

<input type="submit" name="action_install" value="Install" />
<input type="submit" name="action_view" value="View" />

</form>
EOD
,"10%","10%","80%");
?>
Return current item: FiForms Framework