<?php
	if ( !defined('IN_MFA') )
		die("Hacking attempt");
	
	$user->DieNotValid();
	
	if(!IsSet($_GET['step'])) $_GET['step'] = 1;

	if($_GET['step'] == 1)
	{
		$show_after_header = "<a href='index.php?dir=".$_GET['dir']."'>".$lang['back']."</a><p class='error' width='100%' align='center'>".$lang['new_request']."</p>
													<div width='100%' align='center'>
													<table>
													<form action='index.php?dir=".$_GET['dir']."&amp;mode=new&amp;step=2' method='POST'>
														<tr>	
															<td style='text-align:left'><b>".$lang['file_name']."</b></td>
															<td><input type='text' name='newname'> <b>.</b> <input type='text' name='extension' maxlength='4' size='4'></td>
														</tr>
														<tr>
															<td style='text-align:left'><b>".$lang['isdir']."</td>
															<td><input type='checkbox' name='isdir' value='1'></td>
														</tr>
														<tr>
															<td colspan='2' style='text-align:left'><input type='submit' name='subnew' value='".$lang['makeit']."'></td>
														</tr>
													</form>
													</table>
													</div><p class='hr'></p>";
	}
	
	if($_GET['step'] == 2)
	{
			if(IsSet($_POST['isdir']))
			{
				if(! file_exists(ROOT_DIR."/".$user->user_root_dir.$_GET['dir'].$_POST['newname'].".".$_POST['extension']))
				{
					if(FTP_USED == 1)
						ftp_mkdir($ftp_conn_id, FTP_ROOT."/".$user->user_root_dir."".$_GET['dir']."".$_POST['newname']);
					else
						mkdir(ROOT_DIR."/".$user->user_root_dir."".$_GET['dir']."".$_POST['newname']);
				}
				else
					message_die("File already exists","So there is no need to create it new","Message");
			}
			else
			{	
				if(! file_exists(ROOT_DIR."/".$user->user_root_dir.$_GET['dir'].$_POST['newname'].".".$_POST['extension']))
				{
					$tmpfile = create_tmpfile();
					$tmpfile = new file(SCRIPT_PATH."/".$tmpfile);
					if(FTP_USED == 1)
						ftp_put($ftp_conn_id, FTP_ROOT."/".$user->user_root_dir."".$_GET['dir']."".$_POST['newname'].".".$_POST['extension'], ROOT_DIR."/".$tmpfile->file_path, FTP_BINARY);
					else	
						touch(ROOT_DIR."/".$user->user_root_dir."".$_GET['dir']."".$_POST['newname'].".".$_POST['extension']);
				
					$tmpfile->delete();
					if(LOG_USED == 1) write_in_log("File/DIR '".ROOT_DIR."/".$user->user_root_dir."".$_GET['dir']."".$_POST['newname']."' created");	;
				}
				else
					message_die("File already exists","So there is no need to create it new","Message");
			}
			//hm vll jetzt doch
			$show_explorer = 1;
	}
?>