Location: PHPKode > projects > ZZ/OSS Installer > zic-1.1.0dev1/installer/application_update.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: application_update.php,v 1.7 2004/04/05 09:58: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
    */
	  
	// execute init file
	require_once 'inc/init.php';
	
    /***************************************************************************   
    * INSTALLER FRAMEWORK FUNCTIONS                                            *   
    ***************************************************************************/   
	
	function zi_process()
	{
        global $zi_registry;
        
        if(strlen($_FILES['bundle']['tmp_name'])){
            $data_dir = $zi_registry->getDir();
            if (move_uploaded_file($_FILES['bundle']['tmp_name'], $data_dir.$_FILES['bundle']['name'] )) {
                // Extract the bundle to temporary directory.
                $extract_dir = $zi_registry->getApplicationPath().'update'.DIRECTORY_SEPARATOR;
                System::mkdir(array('-p', $extract_dir));
                
                require_once 'ZZOSS_Package/Package.php';
                if(!$params = ZZOSS_Package::getBundleDescr($data_dir.$_FILES['bundle']['name'], $extract_dir)){
                    $_REQUEST['ZI_LOCATION_NEXT'] = 'application_update.php'.zi_form_querystr().'&error='.rawurlencode('Missing distribution.xml or application.xml');
                    return false;
                }
                $new_version = $params['application']['release']['version'];
                $new_app = $params['application']['name'];
                
                // Get information of installed application
                $application = $zi_registry->getApplication();
                $old_version = $application['release']['version'];
                $old_app =  $application['name'];
                if($new_version <= $old_version){
                    $_REQUEST['ZI_LOCATION_NEXT'] = 'application_update.php'.zi_form_querystr().'&error='.rawurlencode('New version is older or the same (new '.$new_version.' <= old '.$old_version.')');
                    return false;
                }
                $application = $zi_registry->getApplication();
                $_REQUEST['ZI_LOCATION_NEXT'] = 'application_update_confirm.php'.zi_form_querystr().
                    '&update_old='.$old_app.'-'.$old_version.'&update_old_human='.rawurlencode($application["summary"].' '.$application['release']['version']).'&update_new='.$new_app.'-'.$new_version;
                
                // Show warning if application names don't match.
                if($new_app != $old_app){
                    $_REQUEST['ZI_LOCATION_NEXT'] .= '&error='.rawurlencode('Application names do not match ('.$new_app.' != '.$old_app.')');
                }
            }
        } else {
            $_REQUEST['ZI_LOCATION_NEXT'] = $_SERVER['PHP_SELF'].zi_form_querystr().'&error='.rawurlencode('Nothing uploaded');
        }
	}
	
    /***************************************************************************   
    * PAGE CONTENT                                                             *   
    ***************************************************************************/
    
	$application = $zi_registry->getApplication();
	include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
	?>
	<h1>Update Application</h1>
    <?php
    if(isset($_REQUEST['error'])){
        ?>
        <div class="warning"><?php echo $_REQUEST['error']; ?></div>
        <?php
    }
    ?>
    <h2><a href="info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=application&distribution=<?php echo $_REQUEST['distribution']; ?>&application=<?php echo $_REQUEST['application']; ?>" onclick="javascript:window.open('info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=application&distribution=<?php echo $_REQUEST['distribution']; ?>&application=<?php echo $_REQUEST['application']; ?>', 'ApplicationInformation', 'width=500,height=500,resizable=1,status=0,scrollbars=1,toolbar=0,location=0,directories=0,menubar=0,dependent=0');void(0);javascript:return(false);" target="_blank" title="<?php echo $application["summary"].' '.$application['release']['version']; ?>"><?php echo $application["summary"].' '.$application['release']['version']; ?></a></h2>

    <p><span class="label">Load Bundle: </span><input type="file" name="bundle"/></p>
<?php
    $zi_buttons['next'] = 'application_update_confirm.php'.zi_form_querystr();
	include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';

?>
Return current item: ZZ/OSS Installer