Location: PHPKode > projects > Netautor Professional > netautor/napro4/admin/install/update/4.5.0/update.php
<?php
/* +----------------------------------------------------------------------+
   | Netautor Professional Application Server                             |
   +----------------------------------------------------------------------+
   | Copyright (C) 1998-2002 digiconcept GmbH. <www.digiconcept.net>      |
   +----------------------------------------------------------------------+
   | This file is subject to license, that is bundled with this package   |
   | in the file LICENSE.TXT, and is available at through the             |
   | world-wide-web at http://www.netautor.com/license/                   |
   |                                                                      |
   | If you did not receive a copy of the license and are unable to       |
   | obtain it through the world-wide-web, please send a note to          |
   | hide@address.com so we can mail you a copy.                      |
   +----------------------------------------------------------------------+
   | Authors: Stefan Rottensteiner 	<hide@address.com>   |
   |          Christian Unger		<hide@address.com>		          |
   |          Helli  Kleinhans     	<hide@address.com>        |
   +----------------------------------------------------------------------+ */

 /**************************************
 * Activate update to version 4.5.0
 * @version  $Revision: 1.8 $
 * @author	Stefan Rottensteiner
 * @author	Helmut Kleinhans
 */

 include ('../../../../include/init.inc');

 error_reporting(65535);
 if (function_exists('ob_flush_end()')) {ob_flush_end();}
 includeNaPro('mversion,array');

  $update_success 	= true;

 /* Get currently installed version */
 $installed_version = version_normalize(version_get($sql_world,'software','napro'));
 /* Check here for desired version */
 $version_comp		= version_compare($installed_version,'4.5.0','>=');

?>
<html>
<head><title>Activate Update 4.5.0</title></head>
<link href="../../../../include/netautor.css" rel="stylesheet" type="TEXT/CSS" media="screen" >
<script language="JavaScript">
<!--
function reloadChoice(){
	if (parent.frames['update_choice']) {
		parent.frames['update_choice'].document.location.href= 	parent.frames['update_choice'].document.location.href;
	}
}

//-->
</script>

<body bgcolor="White" text="Black"  leftmargin="1" topmargin="1">
<br>
<?php
	if ($version_comp==1){
		?>	<font class="setuptextokay">Version 4.5.0 allready installed</font>
			<script language="JavaScript">reloadChoice();</script>
			</body>
			</html>
		<?php
		exit();
	}
?>
<font class="setuplinktext">Start : <?php echo(date('d.m.Y H:is'));?></font><br><br>

<font class="setuptextokay">1. Update table <b>versions</b></font><br>
<?php
	$sql_world->sql_drop_table('versions');

	$table = array();
	include_once('../../packages/base/tables/versions.def');
	if (!empty($table)){
		$sql_world->sql_create_table($table);
		if (!empty($sql_world->errnr)) {
			echo ('<font class="setuptextfalse">Error during table creation : '.$sql_world->errstr.'</font><br>');
			$update_success = false;
		}
	}
	else {
			echo ('<font class="setuptextfalse">Error while reading table definition</font><br>');
			$update_success = false;
	}
	flush();
?>
<font class="setuptextokay">2. Update table <b>mlayouts</b></font><br>
<?php
	$new_column_def = array(	'name'		=> 'mlay_creation',
								'type'		=> 'int',
								'null'		=> 'NOT NULL',
								'default'	=> date('Ymd'),
								'remark'	=> 'Date of Creation'	);

	$sql_world->sql_add_column('mlayouts',$new_column_def);

	$new_column_def = array(	'name'		=> 'mlay_update',
								'type'		=> 'int',
								'null'		=> 'NOT NULL',
								'default'	=> date('Ymd'),
								'remark'	=> 'Date of Creation'	);

	$sql_world->sql_add_column('mlayouts',$new_column_def);

	// alter table to support biger layouts and documents
	if($sql_world->sql_vendor == 'mysql')
	{
		$statement = "ALTER TABLE mlayouts modify mlay_definition mediumtext null";

		$sql_world->exec($statement);

		$statement = "ALTER TABLE mdocs modify mdoc_content mediumtext not null";

		$sql_world->exec($statement);
	}
	flush();
?>
<font class="setuptextokay">3. Update <b>features</b></font><br>
<?php
	$Admin_name = '';
	$Admin_pass = '';

	include_once('../../packages/base.pck');

	foreach($pck_data as $idx => $value)
	{
		if($value['table']	== 'feature')
		{
			$field_names = explode(',',$value['fields']);
			$field_values= explode(',',$value['values']);

			foreach($field_names as $idx2=>$val)
			{
				$invalue[$val] = str_replace("'",'',$field_values[$idx2]);
			}
			unset($invalue['ft_id']);
			$id = $sql_world->bind_insert('feature',$invalue);
			echo ('<font class="setuptext">Try to create feature '.$invalue['ft_name'].'</font><br>');
		}
	}
	flush();
?>
<font class="setuptextokay">4. Scrambling passwords</font><br>
<?php
	$pwds = $sql_world->select('SELECT user_id,user_name,user_pass FROM users',0,0,2);
	if (empty($sql_world->errn) && is_array($pwds))
	{
		foreach ($pwds as $i => $d)
		{
			// scramble password
			$temp = substr(md5($d['user_pass']),0,32);
			// no need to update?
			if ($temp == $d['user_pass']) continue;
			// set new password
			$data	= array ('user_pass'=> $temp);
			$sql_world->bind_update('users',$data,' user_id='.$d['user_id']);
			if (!empty($sql_world->error))
			{
				echo ('<font class="setuptextfalse">Error during password scrambling for user "'.$d['user_name'].'":'.$sql_world->errstr.'</font><br>');
			}
		}
	}
	else {
		echo('<font class="setuptextfalse">Error reading passwords</font><br>');
	}
	flush();
?>
<font class="setuptextokay"><br>5. Registring update informations</font><br>
<?php 	version_set($sql_world,'software','napro','4.5.0'); ?>

<br><font class="setuplinktext">End : <?php echo(date('d.m.Y H:is'));?></font><br>
<script language="JavaScript">reloadChoice();</script>
</body>
</html>
Return current item: Netautor Professional