<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
//
// Copyright (C) 2003 - 2007 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
//
// This program 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
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

	function am_set_paths($arr) {
		GLOBAL $lang;
		
		if (!isset($arr['frm_path_www']) || $arr['frm_path_www'] == '') {
			echo "error";
			return false;
		}
		
		if (1==2) {// check regexp on frm_path_www
			echo "error";
			return false;
		}
		else {
			write_config($arr['frm_path_www'], "core_config['node']['url']['www_path']");
		}
		
		if (isset($arr['frm_path_asset']) && $arr['frm_path_asset'] != '') {
			$asset = "../".$arr['frm_path_asset']."/";
			write_config($asset, "core_config['file']['dir']");
			$dir = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])."..")."..")."/".$arr['frm_path_asset']."/";
			mkdir($dir);
		}
		
		return true;
	}
	
?>

	<?php if (isset($_POST['frm_send'])) { ?>
	
		<div class="message">
		<p><b><?php echo $lang['txt_system_message'];?></b></p>
			<?php if (am_set_paths($_POST)) { header("location: install.php?step=6"); exit; } ?>
		</div>
		
	<?php } ?>
	<form method="post" action="install.php" name="frm">
		<input type="hidden" name="step" value="5" />
		<p><?php echo $lang['txt_step_5']; ?></p>
		
		<table width="100%">
		<tr>
			<td><label><?php echo $lang['txt_step_5_path_wwwpath']; ?></label></td>
			<td><input type="text" name="frm_path_www" value="<?php echo isset($_REQUEST['frm_path_www']) ? $_REQUEST['frm_path_www'] : ''; ?>"/></td>
		</tr>
		
		<tr>
			<td><label><?php echo $lang['txt_step_5_path_asset']; ?></label></td>
			<td><input type="text" name="frm_path_asset" value="<?php echo isset($_REQUEST['frm_path_asset']) ? $_REQUEST['frm_path_asset'] : ''; ?>"/></td>
		</tr>
		
		<tr>
			<td></td>
			<td>
				<p align="right">
					<input type="submit" value="<?php echo $lang['frm_step_5_next_step']; ?>" name="frm_send"/>					
				</p>
			</td>
		</tr>
		</table>
	</form>