Location: PHPKode > projects > Netautor Professional > netautor/napro4/admin/install/update/4.5.6/update.php
<?php
 include ('../../../../include/init.inc');


 if (function_exists('ob_end_flush()')) {ob_end_flush ();}
 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.6','>=');

/*
add table mcache !!
*/

?>
<html>
<head><title>Activate Update 4.5.6</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="#FFFFFF" text="#000000" leftmargin="10" topmargin="10" marginwidth="10" marginheight="10">
<br>
<?php

	if ($version_comp==1){
		?>	<font class="setuptextokay">Version 4.5.6 allready installed</font>
			<script language="JavaScript">reloadChoice();</script>
			</body>
			</html>
		<?php
		exit();
	}
	while (ob_get_level()) { ob_end_flush(); }
?>
<font class="setuplinktext">Start : <?php echo(date('d.m.Y H:i:s'));?></font>
<br>
<font class="setuptextokay"><br>1. Installing additional security features</font>
<br>
<br>
<?php

$pck_data = array(	array(	'table'		=> 'feature',
							'fields'	=> 'ft_id,ft_name,ft_remark,ft_value,ft_multiple,ft_area,ft_maxcount,ft_type,ft_scoop,ft_example',
							'values'	=> "130,'deny_npf_create','Deny function : npf_create',0,0,'functions',1,5,3,''"
						),
					array(	'table'		=> 'feature',
							'fields'	=> 'ft_id,ft_name,ft_remark,ft_value,ft_multiple,ft_area,ft_maxcount,ft_type,ft_scoop,ft_example',
							'values'	=> "131,'deny_npf_update','Deny function : npf_update',0,0,'functions',1,5,3,''"
						),
					array(	'table'		=> 'feature',
							'fields'	=> 'ft_id,ft_name,ft_remark,ft_value,ft_multiple,ft_area,ft_maxcount,ft_type,ft_scoop,ft_example',
							'values'	=> "132,'deny_npf_update_multi','Deny function : npf_update_multi',0,0,'functions',1,5,3,''"
						),
					array(	'table'		=> 'feature',
							'fields'	=> 'ft_id,ft_name,ft_remark,ft_value,ft_multiple,ft_area,ft_maxcount,ft_type,ft_scoop,ft_example',
							'values'	=> "133,'deny_npf_update_exact','Deny function : npf_update_exact',0,0,'functions',1,5,3,''"
						),
					array(	'table'		=> 'feature',
							'fields'	=> 'ft_id,ft_name,ft_remark,ft_value,ft_multiple,ft_area,ft_maxcount,ft_type,ft_scoop,ft_example',
							'values'	=> "134,'deny_npf_delete','Deny function : npf_delete',0,0,'functions',1,5,3,''"
						),
					array(	'table'		=> 'feature',
							'fields'	=> 'ft_id,ft_name,ft_remark,ft_value,ft_multiple,ft_area,ft_maxcount,ft_type,ft_scoop,ft_example',
							'values'	=> "135,'deny_npf_create_schema','Deny function : npf_create_schema',0,0,'functions',1,5,3,''"
						),
					array(	'table'		=> 'feature',
							'fields'	=> 'ft_id,ft_name,ft_remark,ft_value,ft_multiple,ft_area,ft_maxcount,ft_type,ft_scoop,ft_example',
							'values'	=> "136,'deny_npf_duplicate','Deny function : npf_duplicate',0,0,'functions',1,5,3,''"
						),
					array(	'table'		=> 'feature',
							'fields'	=> 'ft_id,ft_name,ft_remark,ft_value,ft_multiple,ft_area,ft_maxcount,ft_type,ft_scoop,ft_example',
							'values'	=> "137,'deny_npf_search','Deny function : npf_search',0,0,'functions',1,5,3,''"
						)
				);

				foreach($pck_data as $i => $data)
				{
					flush();
					$i='<font class="setuptexttext">'.sprintf('%04d. ',$i).'</font>';
					@set_time_limit(0);
					$mode 		= (empty($data['mode'])?'insert':$data['mode']);
					$primary 	= (!empty($data['prim_key'])?$data['prim_key']:'');
					if ($mode=='update')
					{ // Test if mode 'update' is valid
						if (empty($primary)) 
						{ // No primary key given, change mode to 'insert'
							$mode='insert';
						}
						else
						{// Wrong primary key given, change mode to 'insert'
							$tab_def= $sql_world->get_table_def($data['table']);
							if ($tab_def['primary'] != $primary) $mode='insert';
						}
					}

					if ($mode=='insert')
					{
						$result	= $sql_world->insert($data['table'],$data['fields'],$data['values'],$primary);
					}
					else
					{
						echo ($i.'<font class="setuptextfalse">Mode UPDATE not yet implemented</font><br>');
					}
					
					if (empty($sql_world->errnr))
					{
						echo ($i.'<font class="setuptextokay">Data successfully imported</font><br>');
					}
					else
					{
						echo ($i.'<font class="setuptextfalse">'.'Error while importing data'.' ('.$sql_world->errstr.')</font><br>');
					}
				}
?>
<br>
<font class="setuptextokay"><br>2. Update Netautor functions (Please be patient) ... </font><br>
<?php 
	@set_time_limit(60*5);
	$source_file = $GLOBALS['DC_ENV']->cachepath.'npf_functions.dat';

	if (file_exists($source_file)){
		$target_file = $GLOBALS['DC_ENV']->cachepath.'_npf_functions.dat';
		if (copy ($source_file,$target_file)){
			if (!unlink($source_file)){
			echo ('<font class="setuptextfalse">Cannot delete "'.$source_file.'"</font><br>');
			}
		}
		else {
			echo ('<font class="setuptextfalse">Cannot copy "'.$source_file.'" to "'.$target_file.'"</font><br>');
		}
	}
	flush();
	includeNapro('array,string,xml,na_functions');
	naf_generate_def_file($GLOBALS['DC_ENV']);
	if (!file_exists($source_file)) {
		echo ('<font class="setuptextfalse">Functions have not been fully updated for some reasons !</font><br>');
		$update_success = false;
	}

?>
<br>
<font class="setuptextokay"><br>3. Checking for new directorys</font>
<br>
<?php

	includeNaPro('file');
	$new_dirs[]	= $GLOBALS['DC_ENV']->cachepath.'sessions/';
	$new_dirs[]	= $GLOBALS['DC_ENV']->cachepath.'layouts/';
	foreach ($new_dirs as $index => $dir ) 
	{
		if (file_exists($dir)) {
			echo '<font class="setuptexttext">&nbsp;&nbsp;&nbsp;Directory '.$dir.' ok</font><br>';
		}
		else {
			$result = File_MkDirs($dir);
			if ($result) {
				echo '<font class="setuptexttext">&nbsp;&nbsp;Directory '.$dir.' created</font><br>';
			}
			else {
				echo '<font class="setuptextfalse">&nbsp;&nbsp;Error while creating '.$dir.' </font><br>';
			}
		}
	}
?>
<br>
<font class="setuptextokay"><br>3. Clear cached documentation</font>
<br>
<?php
	$dir	=$GLOBALS['DC_ENV']->docucache;
	$files 	= File_getFiles($dir,'.html');
	foreach ($files as $index => $file){
		echo '<font class="setuptexttext">&nbsp;&nbsp;&nbsp;Delete '.$dir.$file.'</font><br>';
		@unlink($dir.$file);
	}
?>
<font class="setuptextokay"><br>Registring update informations</font><br>
<?php version_set($sql_world,'software','napro','4.5.6'); ?>

<br><font class="setuplinktext">End : <?php echo(date('d.m.Y H:i:s'));?></font><br>

<script language="JavaScript">reloadChoice();</script>
</body>
</html>
Return current item: Netautor Professional