# Execute Dev-Editor's commands
#
# Author: Patrick Canterino <patshaping@gmx.net>
-# Last modified: 2004-07-03
+# Last modified: 2004-07-11
#
use strict;
use Output;
use Template;
-use Data::Dumper;
-
my $script = $ENV{'SCRIPT_NAME'};
my %dispatch = ('show' => \&exec_show,
my $dir = upper_path($new_virtual);
$new_virtual = encode_entities($new_virtual);
- return error($config->{'errors'}->{'file_exists'},$dir,{FILE => $new_virtual}) if(-e $new_physical);
+ if($new_physical)
+ {
+ return error($config->{'errors'}->{'file_exists'},$dir,{FILE => $new_virtual}) if(-e $new_physical);
+
+ file_create($new_physical) or return error($config->{'errors'}->{'mkfile_failed'},$dir,{FILE => $new_virtual});
+ return devedit_reload({command => 'show', file => $dir});
+ }
+ else
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'mkfile'});
+
+ $tpl->fillin("DIR","/");
+ $tpl->fillin("SCRIPT",$script);
- file_create($new_physical) or return error($config->{'errors'}->{'mkfile_failed'},$dir,{FILE => $new_virtual});
- return devedit_reload({command => 'show', file => $dir});
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
}
# exec_mkdir()
return error($config->{'errors'}->{'file_exists'},$dir,{FILE => $new_virtual}) if(-e $new_physical);
- mkdir($new_physical,0777) or return error($config->{'errors'}->{'mkdir_failed'},$dir,{DIR => $new_virtual});
- return devedit_reload({command => 'show', file => $dir});
+ if($new_physical)
+ {
+ mkdir($new_physical,0777) or return error($config->{'errors'}->{'mkdir_failed'},$dir,{DIR => $new_virtual});
+ return devedit_reload({command => 'show', file => $dir});
+ }
+ else
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'templates'}->{'mkdir'});
+
+ $tpl->fillin("DIR","/");
+ $tpl->fillin("SCRIPT",$script);
+
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
}
# exec_upload()
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+<title>Create new directory</title>
+<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
+</head>
+<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
+
+<h1>Create new directory</h1>
+
+<p><a href="{SCRIPT}?command=show&file={DIR}">Back to {DIR}</a></p>
+
+<p>Using this form, you can create a new directory in the current directory ('{DIR}').</p>
+
+<form action="{SCRIPT}">
+<input type="hidden" name="command" value="mkdir">
+<input type="hidden" name="curdir" value="{DIR}">
+<p>{DIR} <input type="text" name="newfile"> <input type="submit" value="Create!"></p>
+</form>
+
+<hr>
+
+<p align="right"><a href="{SCRIPT}?command=about" target="_blank"><i>About Dev-Editor</i></a></p
+
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+<title>Create new file</title>
+<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
+</head>
+<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
+
+<h1>Create new file</h1>
+
+<p><a href="{SCRIPT}?command=show&file={DIR}">Back to {DIR}</a></p>
+
+<p>Using this form, you can create a new file in the current directory ('{DIR}').</p>
+
+<form action="{SCRIPT}">
+<input type="hidden" name="command" value="mkfile">
+<input type="hidden" name="curdir" value="{DIR}">
+<p>{DIR} <input type="text" name="newfile"> <input type="submit" value="Create!"></p>
+</form>
+
+<hr>
+
+<p align="right"><a href="{SCRIPT}?command=about" target="_blank"><i>About Dev-Editor</i></a></p
+
+</body>
+</html>
\ No newline at end of file