Location: PHPKode > projects > Netautor Professional > netautor/napro4/admin/install/setup_2_test.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                                              |
   |          Christian Unger										      |
   |          Helli  Kleinhans 											  |
   +----------------------------------------------------------------------+
   | @version	$Revision: 1.21 $										  |
   +----------------------------------------------------------------------+*/

/**
 * Test & create required paths
 *
 * @author Stefan Rottensteiner
 */

require_once ('./setup.inc');
if (empty($_POST['SETUP_CHECK']))
{
	?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
		<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 
	die();
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title><?php echo ($SETUP_LANGUAGE_TEXT['setup_test_2']['title']);?></title>
		<meta name="Description" content="<?php echo SOFTWARE_NAME_FULL;?> <?php echo SOFTWARE_VERSION_FULL;?> Setup Test Step 2">
		<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();
	}
	
	</script>
<body class="brown">
<form method="post" action="setup_2_test.php">
<?php
	echo(setup_getMyVars($_POST));
	$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');
			if ($file)
			{
				$testcontent='<html><body><b>'.SOFTWARE_NAME_FULL.' '.SOFTWARE_VERSION_FULL.'</b><br>You can freely delete this file!</body></html>';
				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;
	}

	$error 		= false;	// error for each path test
	$all_error	= false;	// true if at least one sub-test fails
?>
<br>
<table border="0" cellspacing="0" cellpadding="0" align="center" valign="top">
	<tr>
		<td align="center" class="text"><span class="head"><?php echo ($SETUP_LANGUAGE_TEXT['setup_test_2']['title']);?></span></td>
	</tr>
	<tr>
		<td class="text">&nbsp;</td>
	</tr>
	<tr>
		<td align="center" class="text">
			<input type="button" class="clear" onClick="closeMe();" value="<?php echo($SETUP_LANGUAGE_TEXT['close_window']);?>">
		</td>
	</tr>
	<tr>
		<td class="text">&nbsp;</td>
	</tr>
	<tr>
	<td align="center" valign="top">
	<table width="600" border="0" cellpadding="0" cellspacing="4">

		<tr>
			<td class="text">
				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_config']);?> : </b><?php echo(implode(', ',setup_TestPath($PATH_CONFIG,$SETUP_LANGUAGE_TEXT,$error)));?><br>
				<?php echo($PATH_CONFIG);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_config_workflow']);?> : </b><?php echo(implode(', ',setup_TestPath($PATH_CONFIG_WORKFLOW,$SETUP_LANGUAGE_TEXT,$error)));?><br>
				<?php echo($PATH_CONFIG_WORKFLOW);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_logs']);?> : </b><?php echo(implode(', ',setup_TestPath($PATH_LOGS,$SETUP_LANGUAGE_TEXT,$error)));?><br>
				<?php echo($PATH_LOGS);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_cache']);?> 1 : </b><?php echo(implode(', ',setup_TestPath($PATH_CACHE,$SETUP_LANGUAGE_TEXT,$error)));?><br>
				<?php echo($PATH_CACHE);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_cache']);?> 2 : </b><?php echo(implode(', ',setup_TestPath($PATH_CACHE_TABLES,$SETUP_LANGUAGE_TEXT,$error)));?><br>
				<?php echo($PATH_CACHE_TABLES);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_cache']);?> 3 : </b><?php echo(implode(', ',setup_TestPath($PATH_CACHE_LAYOUTS,$SETUP_LANGUAGE_TEXT,$error)));?><br>
				<?php echo($PATH_CACHE_LAYOUTS);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_cache']);?> 4 : </b><?php echo(implode(', ',setup_TestPath($PATH_CACHE_SESSION,$SETUP_LANGUAGE_TEXT,$error)));?><br>
				<?php echo($PATH_CACHE_SESSION);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_cache']);?> 5 : </b><?php echo(implode(', ',setup_TestPath($PATH_CACHE_DOCU,$SETUP_LANGUAGE_TEXT,$error)));?><br>
				<?php echo($PATH_CACHE_DOCU);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_layouts']);?> : </b><?php echo(implode(', ',setup_TestPath($PATH_LAYOUTS,$SETUP_LANGUAGE_TEXT,$error)));?><br>
				<?php echo($PATH_LAYOUTS);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_gfx']);?> : </b><?php echo(implode(', ',setup_TestPath($PATH_GRAFIX_2,$SETUP_LANGUAGE_TEXT,$error,false)));?><br>
				<?php echo($PATH_GRAFIX_2);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

				<b><?php echo($SETUP_LANGUAGE_TEXT['setup_step_2']['dir_ext_func']);?> : </b><?php echo(implode(', ',setup_TestPath($PATH_EXTERNAL_FUNC,$SETUP_LANGUAGE_TEXT,$error)));?><br>
				<?php echo($PATH_EXTERNAL_FUNC);?><br>
				<br>

<?php $all_error = $all_error || $error; ?>

	</table>
	</td>
	</tr>
	<tr>
		<td class="text"><?php echo($SETUP_LANGUAGE_TEXT['summary'])?></td>
	</tr>
	<tr>
		<td align="left" >
			<script language="JavaScript" type="text/javascript">
			<!--
				if (parent && parent.frames['setupmain']) var p = parent.frames['setupmain'];
				if (window.opener ) var p = window.opener;
				if (p) p.document.forms[0].elements['ERROR_PATH'].value='<?php echo ( $all_error ? '1' : '' );?>';
			//-->
			</script>		
			<?php if ($all_error) : ?>
			<font class="textred"><?php echo $SETUP_LANGUAGE_TEXT['setup_test_2']['path_false'];?></font>
			<?php else : ?>
			<font class="textgreen"><?php echo $SETUP_LANGUAGE_TEXT['setup_test_2']['path_okay'];?></font>		
			<?php endif; ?>
		</td>
	</tr>
</table>

<center>
<input type="button" class="clear" onClick="closeMe();" value="<?php echo($SETUP_LANGUAGE_TEXT['close_window']);?>">
</center>
</form>
</body>
</html>
Return current item: Netautor Professional