Location: PHPKode > projects > Netautor Professional > netautor/napro4/admin/install/setup_3.php
<?php
/* +----------------------------------------------------------------------+
   | Netautor Professional Application Server                             |
   +----------------------------------------------------------------------+
   | Copyright (C) 1998-2005 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>    |
   |          Marek  Kadziela      <hide@address.com>	      |
   |          Gregor Wollner                                              |
   |          Helli  Kleinhans     								          |
   +----------------------------------------------------------------------+*/

/**
* Test & create required paths
*
* @author Stefan Rottensteiner
* @package setup
* @version $Revision: 1.28 $
*/

require_once ('./setup.inc');
if (empty($_POST['SETUP_CHECK']))
{
	?><html>
		<body>
		<script language="JavaScript" type="text/javascript">
		if (parent && parent.frames && parent.frames["setupmain"])
		{
			parent.frames["setupmain"].document.location.href="setup.php";
			top.main.document.getElementById('f_installation').rows="*,0,24";
		}
		else
		{
			document.location.href="setup.php"
		}
		</script>
		</body>
	   </html><?php 
	exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<meta name="Description" content="<?php echo SOFTWARE_NAME_FULL;?> <?php echo SOFTWARE_VERSION_FULL;?> Setup Test Step 3">
	<title><?php echo SOFTWARE_NAME_FULL; ?> <?php echo SOFTWARE_VERSION_FULL;?> Setup Test Step 3</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="Expires" content="0">
	<meta name="robots" content="noindex,nofollow">
	<link href="../../include/netautor.css" rel="stylesheet" type="text/css" src="../../include/netautor.css">		
</head>
<script language="JavaScript" type="text/javascript">
function goOn(SiteName,ConfirmText)
{
	if ((ConfirmText && ConfirmText!="") && (!confirm(ConfirmText))) return;
	document.forms[0].action=SiteName;
	document.forms[0].submit();
}

function closeMe() {
	if (top.main && top.main.document.getElementById('f_installation') ) top.main.document.getElementById('f_installation').rows='*,0,24';
	else
	 window.close();
}

parent.frames['SETUP_HEAD'].document.setTitle('<?php echo (strtr($SETUP_LANGUAGE_TEXT['setup_step'],array('%1'=>'3','%2'=>'7')));?>');

</script>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="1" topmargin="1">
<form method="post" action="setup_3.php">
<?php
	echo (setup_getMyVars($_POST));
	if (!ini_get('register_globals'))
 	 foreach( $_POST as $key => $value)
	  if (isset( $GLOBALS[ $key ]) && !isset( $$key)) $$key = &$GLOBALS[ $key ];

	$PATH_CACHE_LAYOUTS		= $PATH_CACHE.'layouts/';
	$PATH_CACHE_TABLES		= $PATH_CACHE.'tables/';
	$PATH_CACHE_DOCU		= $PATH_CACHE.'docu/';
	$PATH_CACHE_SESSION		= $PATH_CACHE.'sessions/';

	$PATH_GRAFIX_2		  	= substr($PATH_INSTALL,0,-(strlen($PATH_INDEX))).$PATH_GRAFIX;
	$PATH_START 			= substr($PATH_INSTALL	,0,-(strlen(SOFTWARE_NAME_SHORT.'/')));
	$PATH_CONFIG_WORKFLOW   = $PATH_CONFIG.'workflow/';
	if (empty($PATH_LOGS)) $PATH_LOGS	= $PATH_START.'logs/';
	function setup_TestPath(&$path,&$SETUP_LANGUAGE_TEXT,&$error,$test_write=true)
	{
		$temp=$path;
		$path= preg_replace("([\\\]+)",'/',$path);
		$path= preg_replace('[^a-zA-Z0-0_\\\.~]','',$path);
		if (empty($path))
		{
			$path=$temp;
			return array('<font class="textred"> ERROR </font>');
		}
		$result=array();
		if (substr($path,-1)!='/') $path.='/';
		$error=false;
		if (file_exists($path))
		{
			$result[]='<font class="textgreen">'.$SETUP_LANGUAGE_TEXT['setup_test_2']['path_exists'].'</font>';
		}
		else
		{
			if (setup_MkDir($path))
			{
				$result[]='<font class="textgreen">'.$SETUP_LANGUAGE_TEXT['setup_test_2']['path_created'].'</font>';
			}
			else
			{
				$error = true;
				$result[]= '<font class="textred">'.$SETUP_LANGUAGE_TEXT['setup_test_2']['path_not_created'].'</font>';
			}
		}
		if (!$error && $test_write)
		{
			$error=true;
			$file = @fopen($path.'setup_test.html','wb');
			$testcontent='<html><body><b>'.SOFTWARE_NAME_FULL.' '.SOFTWARE_VERSION_FULL.'</b><br>You can freely delete this file!</body></html>';
			if ($file)
			{
				if (!@fwrite($file,$testcontent,strlen($testcontent))) $error = true; else $error=false;
				fclose($file);
			}
			//if (!$error) $error=file_exists($path.'setup_test.html');
			if (!$error) @unlink($path.'setup_test.html');

			$result[]='<font class="text'.($error?'red':'green').'">'.$SETUP_LANGUAGE_TEXT['setup_test_2']['path_security_'.($error?'f':'o')].'</font>';
		}
		return $result;
	}

	function setup_displayPathCheck($SETUP_LANGUAGE_TEXT,$text_index,$text_add, &$PATH, $test_write=true )
	{
		$TITLE		= $SETUP_LANGUAGE_TEXT['setup_step_2'][ $text_index ].$text_add;
		$RESULT_TEXT= implode(', ',setup_TestPath($PATH,$SETUP_LANGUAGE_TEXT,$error, $test_write)); 
	?>
		<tr>
			<td valign="top" width="25%" class="text"	><?php echo $TITLE; ?><br></td>
			<td valign="top" width="55%" class="text" 	><?php echo $PATH;?><br></td>
			<td valign="top" width="20%" class="text"	><?php echo $RESULT_TEXT; ?><br></td>
		</tr>
	<?php 
		return $error;
	}

	$error 		= false;	// error for each path test
	$all_error	= false;	// true if at least one sub-test fails
?>
<br>
<br>
<table border="0" cellspacing="0" cellpadding="0" align="center" valign="top">

	<tr>
	<td align="center" valign="top" colspan="3">

		<table width="700" border="0" align="center" class="bgwindow700">
			<input type="hidden" name="PATH_OS" value="<?php echo($PATH_OS);?>">
			<tr>
				<td width="694" colspan="3" align="left" valign="top" class="head">
					<img src="../../grafik/pixel.gif" width="1" height="7"><br>
					<?php echo ($SETUP_LANGUAGE_TEXT['setup_test_2']['title']); ?><br>
					<img src="../../grafik/spacer_700.gif" width="694" height="13"><br>
				</td>
			</tr>					
			<?php 
				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_config','',			$PATH_CONFIG);
				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_config_workflow','',	$PATH_CONFIG_WORKFLOW);
				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_logs','',				$PATH_LOGS);

				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_cache',' 1',			$PATH_CACHE);
				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_cache',' 2',			$PATH_CACHE_TABLES);
				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_cache',' 3',			$PATH_CACHE_LAYOUTS);
				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_cache',' 4',			$PATH_CACHE_SESSION);
				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_cache',' 5',			$PATH_CACHE_DOCU);

				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_layouts','',			$PATH_LAYOUTS);
				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_gfx','',				$PATH_GRAFIX_2, false );
				$all_error = $all_error || setup_displayPathCheck( $SETUP_LANGUAGE_TEXT,'dir_ext_func','',			$PATH_EXTERNAL_FUNC);
			?>
		</table>
		<img src="../../grafik/bgwindow_482_stop.gif" width="700" height="14"><br>
		<script language="JavaScript" type="text/javascript">
		<!--
			var p = document;
			if (parent && parent.frames['setupmain']) var p = parent.frames['setupmain'].document;
			if (window.opener ) var p = window.opener.document;
			if (p) p.forms[0].elements['ERROR_PATH'].value='<?php echo ( $all_error ? '1' : '' );?>';
		//-->
		</script>
		<?php if ($all_error) : ?>
		<table class="bgwindow700" width="700" border=0 align="center" >
			<tr>
				<td class="head"><?php echo $SETUP_LANGUAGE_TEXT['summary'];?> </td>
			</tr>
			<tr>
				<td  valign="top">
				<?php if ($all_error) : ?>
					<span class="textred"><?php echo $SETUP_LANGUAGE_TEXT['setup_test_2']['path_false'];?><br></span>
				<?php else : ?>
					<span class="textgreen"><?php echo $SETUP_LANGUAGE_TEXT['setup_test_2']['path_okay'];?><br></span>		
				<?php endif; ?>				
				</td>
			</tr>
		</table>
		<img src="../../grafik/bgwindow_482_stop.gif" width="700" height="14"><br>
		<?php endif; ?>						
		<table class="bgwindow700" width="700" border=0 align="center" >
			<tr>
				<td class="head" width="33%" align="center" >
					<input type="button" class="create" value="<?php echo ($SETUP_LANGUAGE_TEXT['back']);?>" onClick="goOn('setup_2.php');" >
				</td>
				<td class="head" width="34%" align="center" >
					<input type="button" class="preview" value="<?php echo ($SETUP_LANGUAGE_TEXT['cancel']);?>" onClick="goOn('setup.php');" >				
				</td>				
				<td class="head" width="33%" align="center" >
					<?php if (!$all_error) : ?>
					<input type="button" class="create" value="<?php echo ($SETUP_LANGUAGE_TEXT['next']);?>" onClick="goOn('setup_4.php');" >
					<?php endif; ?>
				</td>
			</tr>
		</table>
		<img src="../../grafik/bgwindow_482_stop.gif" width="700" height="14"><br>
		
	</td>
</table>
</body>
</html>
Return current item: Netautor Professional