Location: PHPKode > projects > ZZ/OSS Installer > zic-1.1.0dev1/installer/setup_datadir.php
<?php   
    /*
    Copyright (C) 2001-2004 ZZOSS GbR, http://www.zzoss.com

    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
    
    /**
    @version $Id: setup_datadir.php,v 1.5 2004/01/29 14:09:16 ordnas Exp $
    @copyright Copyright &copy; 2001-2004 ZZ/OSS GbR, http://www.zzoss.com
    @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
    */
    
    if(!is_writeable('.')){
        header('Location: setup.php');
        exit;
    }
    
    //print_r($_REQUEST);
    require_once 'inc/init.php';
    
    if(!isset($_REQUEST['data_dir'])){
        $_REQUEST['data_dir'] = '';
    }
    
    // Check if this is a fresh setup installation
    // of the installer. If so, then we take over the
    // data of the installer which installed us.
    // This way, the installed installer is registered
    // within itself and can be updated.
    $installs = ZZOSS_InstallerUtils::unserializeFromFile($zi_setup->getDataDir().'.installed_by.reg');
    $installed_by = $installs[getcwd().DIRECTORY_SEPARATOR];
    if(strlen($installed_by)){
        // Modify the .init file.
        $inits = ZZOSS_InstallerUtils::unserializeFromFile($zi_setup->getInitFile());
        $data_dir = $inits[$installed_by];
        $inits[getcwd()] = $data_dir;
        ZZOSS_InstallerUtils::serializeToFile($zi_setup->getInitFile(), $inits);
        /*
        // grab all plugins from the setup installer and copy them
        // to our plugins directory
        require_once 'ZZOSS_Installer/Utils.php';
        ZZOSS_InstallerUtils::copy($installed_by.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR, 'plugins'.DIRECTORY_SEPARATOR);
        */
        // Delete the .htpasswd so that we have a fresh login.
        @unlink($data_dir.'.htpasswd');
        
        header('Location: index.php');
        exit;
    }
    
    function zi_process()
    {
        global $zi_setup;
        
        if(!$zi_setup->isDataDir($_REQUEST['data_dir'])){
            header('Location: setup_datadir.php?data_dir='.rawurlencode($_REQUEST['data_dir']).'&error='.rawurlencode($zi_setup->getError()));
            exit;
        }
        
        if(!$zi_setup->init()){
            header('Location: setup_datadir.php?data_dir='.rawurlencode($_REQUEST['data_dir']).'&error='.rawurlencode($zi_setup->getError()));
            exit;
        }
        
        // Check if there are already installer configs
        // and ask if we should resume from them?
        if($zi_setup->isInstalled($_REQUEST['data_dir'])){
             header('Location: setup_resume.php');
            exit;
        } else {
            if(!$zi_setup->initData()){
                header('Location: setup_datadir.php?data_dir='.rawurlencode($_REQUEST['data_dir']).'&error='.rawurlencode($zi_setup->getError()));
                exit;
            } else {
                // Extract the bundled installer.
                require_once 'ZZOSS_Package/Package.php';
                ZZOSS_Package::extractBundles('bundles'.DIRECTORY_SEPARATOR, $zi_setup->getInstallerDataDir());
                
                header('Location: index.php');
                exit;
            }
        }
    }
    
    require_once 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
?>
<h1>Data Directory</h1>
<?php
    if(!strlen($_REQUEST['data_dir'])){
        $_REQUEST['data_dir'] = $zi_setup->getDataDir(false);
    }
    ?>
        <p>Please specify the directory, where the installer should store its data.</p>
        <ul>
            <li>Provide the absolute path.</li>
            <li>The directory must be readable and writeable by PHP.<?php
            require_once 'PEAR.php';
            if(!OS_WINDOWS){
                $user = posix_getpwuid(posix_getuid());
                $group = posix_getgrgid(posix_getgid());
                ?> (Which runs as user "<?php echo $user['name']; ?>" 
                and group "<?php echo $group['name']; ?>" on your machine.)
                <?php
            }
            ?></li>
            <li>On a production environment, the data directory should be located outside of the Web server 
            document root.</li>
        </ul>
        <?php
        if(isset($_REQUEST['error'])){
            echo '<p class="warning">'.rawurldecode($_REQUEST['error']).'</p>';
        }
        ?>
        <p><span style="inputlabel">Data Directory:</span>&nbsp;<input type="text" name="data_dir" value="<?php echo rawurldecode($_REQUEST['data_dir']); ?>" /></p>
    <?php
    
    $zi_buttons['back'] = 'setup.php';
    $zi_buttons['next'] = 'setup_datadir.php';
    require_once 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
?>
Return current item: ZZ/OSS Installer